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: Created April 30, 2017, 6:54 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/String.h ('k') | compiled/filter/RegExpFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 20 #include <emscripten.h>
21 #include <emscripten/trace.h> 21 #include <emscripten/trace.h>
22 22
23 #if defined(assert) 23 #if defined(assert)
24 #undef assert 24 #undef assert
25 #endif 25 #endif
26 26
27 class String; 27 class String;
28 28
29 extern "C"
30 {
31 void LogString(const String& str);
32 void LogInteger(int i);
33 void LogPointer(const void* ptr);
34 void LogError(const String& str);
35 }
36
29 struct console_type 37 struct console_type
30 { 38 {
31 static void log(const String& str) 39 static void log(const String& str)
32 { 40 {
33 EM_ASM_ARGS(console.log(readString($0)), &str); 41 LogString(str);
34 } 42 }
35 43
36 static void log(int i) 44 static void log(int i)
37 { 45 {
38 EM_ASM_ARGS(console.log($0), i); 46 LogInteger(i);
39 } 47 }
40 48
41 static void log(void* ptr) 49 static void log(const void* ptr)
42 { 50 {
43 EM_ASM_ARGS(console.log($0), ptr); 51 LogPointer(ptr);
44 } 52 }
45 53
46 static void error(const String& str) 54 static void error(const String& str)
47 { 55 {
48 EM_ASM_ARGS(console.error(new Error(readString($0)).stack), &str); 56 LogError(str);
49 } 57 }
50 }; 58 };
51 59
52 static console_type console; 60 static console_type console;
53 61
54 #if defined(DEBUG) 62 #if defined(DEBUG)
55 inline void assert(bool condition, const String& str) 63 inline void assert(bool condition, const String& str)
56 { 64 {
57 if (!condition) 65 if (!condition)
58 console.error(str); 66 console.error(str);
(...skipping 15 matching lines...) Expand all
74 emscripten_trace_enter_context(context); 82 emscripten_trace_enter_context(context);
75 #endif 83 #endif
76 } 84 }
77 85
78 inline void exit_context() 86 inline void exit_context()
79 { 87 {
80 #if defined(__EMSCRIPTEN_TRACING__) 88 #if defined(__EMSCRIPTEN_TRACING__)
81 emscripten_trace_exit_context(); 89 emscripten_trace_exit_context();
82 #endif 90 #endif
83 } 91 }
OLDNEW
« no previous file with comments | « compiled/String.h ('k') | compiled/filter/RegExpFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld