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

Side by Side Diff: compiled/debug.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Improved performance Created Jan. 28, 2016, 2:31 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
« no previous file with comments | « compiled/api.cpp ('k') | compiled/shell.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifndef ADBLOCK_PLUS_DEBUG_H
2 #define ADBLOCK_PLUS_DEBUG_H
3
4 #include <emscripten.h>
5 #include <emscripten/trace.h>
6
7 #if defined(assert)
8 #undef assert
9 #endif
10
11 class String;
12
13 struct console_type
14 {
15 static void log(const String& str)
16 {
17 EM_ASM_ARGS(console.log(getStringData($0)), &str);
18 }
19
20 static void log(int i)
21 {
22 EM_ASM_ARGS(console.log($0), i);
23 }
24
25 static void log(void* ptr)
26 {
27 EM_ASM_ARGS(console.log($0), ptr);
28 }
29
30 static void error(const String& str)
31 {
32 EM_ASM_ARGS(console.error(new Error(getStringData($0)).stack), &str);
33 }
34 };
35
36 static console_type console;
37
38 inline void assert(bool condition, const String& str)
39 {
40 #if defined(DEBUG)
41 if (!condition)
42 console.error(str);
43 #endif
44 }
45
46 inline void annotate_address(void* address, const char* name)
47 {
48 #if defined(__EMSCRIPTEN_TRACING__)
49 emscripten_trace_annotate_address_type(address, name);
50 #endif
51 }
52
53 inline void enter_context(const char* context)
54 {
55 #if defined(__EMSCRIPTEN_TRACING__)
56 emscripten_trace_enter_context(context);
57 #endif
58 }
59
60 inline void exit_context()
61 {
62 #if defined(__EMSCRIPTEN_TRACING__)
63 emscripten_trace_exit_context();
64 #endif
65 }
66
67 #endif
OLDNEW
« no previous file with comments | « compiled/api.cpp ('k') | compiled/shell.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld