Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/debug.h

Issue 29425555: Issue 5201 - [emscripten] Replace EM_ASM calls by a custom JavaScript library (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Moved all declarations into a single header and corrected emscripten.h includes Created April 30, 2017, 3:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #pragma once 18 #pragma once
19 19
20 #include <emscripten.h>
21 #include <emscripten/trace.h> 20 #include <emscripten/trace.h>
sergei 2017/05/02 09:48:06 should it be also wrapped by `#ifdef __EMSCRIPTEN_
22 21
22 #include "library.h"
23
23 #if defined(assert) 24 #if defined(assert)
24 #undef assert 25 #undef assert
25 #endif 26 #endif
26 27
27 class String; 28 class String;
28 29
29 struct console_type 30 struct console_type
30 { 31 {
31 static void log(const String& str) 32 static void log(const String& str)
32 { 33 {
33 EM_ASM_ARGS(console.log(readString($0)), &str); 34 LogString(str);
34 } 35 }
35 36
36 static void log(int i) 37 static void log(int i)
37 { 38 {
38 EM_ASM_ARGS(console.log($0), i); 39 LogInteger(i);
39 } 40 }
40 41
41 static void log(void* ptr) 42 static void log(const void* ptr)
42 { 43 {
43 EM_ASM_ARGS(console.log($0), ptr); 44 LogPointer(ptr);
44 } 45 }
45 46
46 static void error(const String& str) 47 static void error(const String& str)
47 { 48 {
48 EM_ASM_ARGS(console.error(new Error(readString($0)).stack), &str); 49 LogError(str);
49 } 50 }
50 }; 51 };
51 52
52 static console_type console; 53 static console_type console;
53 54
54 #if defined(DEBUG) 55 #if defined(DEBUG)
55 inline void assert(bool condition, const String& str) 56 inline void assert(bool condition, const String& str)
56 { 57 {
57 if (!condition) 58 if (!condition)
58 console.error(str); 59 console.error(str);
(...skipping 15 matching lines...) Expand all
74 emscripten_trace_enter_context(context); 75 emscripten_trace_enter_context(context);
75 #endif 76 #endif
76 } 77 }
77 78
78 inline void exit_context() 79 inline void exit_context()
79 { 80 {
80 #if defined(__EMSCRIPTEN_TRACING__) 81 #if defined(__EMSCRIPTEN_TRACING__)
81 emscripten_trace_exit_context(); 82 emscripten_trace_exit_context();
82 #endif 83 #endif
83 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld