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

Delta Between Two Patch Sets: compiled/debug.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: How with CSS property filters Created Jan. 20, 2016, 1:12 p.m.
Right Patch Set: Addressed comments from Patch Set 28 Created March 21, 2017, 10:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/bindings.ipp ('k') | compiled/intrusive_ptr.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #ifndef ADBLOCK_PLUS_DEBUG_H 1 #pragma once
2 #define ADBLOCK_PLUS_DEBUG_H
3
4 #include <string>
5 2
6 #include <emscripten.h> 3 #include <emscripten.h>
4 #include <emscripten/trace.h>
5
6 #if defined(assert)
7 #undef assert
8 #endif
9
10 class String;
7 11
8 struct console_type 12 struct console_type
9 { 13 {
10 static void log(const std::u16string& str) 14 static void log(const String& str)
11 { 15 {
12 EM_ASM_ARGS(console.log(getStringData($0)), &str); 16 EM_ASM_ARGS(console.log(readString($0)), &str);
13 } 17 }
14 18
15 static void log(int i) 19 static void log(int i)
16 { 20 {
17 EM_ASM_ARGS(console.log($0), i); 21 EM_ASM_ARGS(console.log($0), i);
18 } 22 }
19 23
20 static void log(void* ptr) 24 static void log(void* ptr)
21 { 25 {
22 EM_ASM_ARGS(console.log($0), ptr); 26 EM_ASM_ARGS(console.log($0), ptr);
23 } 27 }
28
29 static void error(const String& str)
30 {
31 EM_ASM_ARGS(console.error(new Error(readString($0)).stack), &str);
32 }
24 }; 33 };
25 34
26 static console_type console; 35 static console_type console;
27 36
37 #if defined(DEBUG)
38 inline void assert(bool condition, const String& str)
39 {
40 if (!condition)
41 console.error(str);
42 }
43 #else
44 #define assert(condition, str)
28 #endif 45 #endif
46
47 inline void annotate_address(void* address, const char* name)
48 {
49 #if defined(__EMSCRIPTEN_TRACING__)
50 emscripten_trace_annotate_address_type(address, name);
51 #endif
52 }
53
54 inline void enter_context(const char* context)
55 {
56 #if defined(__EMSCRIPTEN_TRACING__)
57 emscripten_trace_enter_context(context);
58 #endif
59 }
60
61 inline void exit_context()
62 {
63 #if defined(__EMSCRIPTEN_TRACING__)
64 emscripten_trace_exit_context();
65 #endif
66 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld