LEFT | RIGHT |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 "library.h" | 20 #include "library.h" |
21 | |
22 #if defined(assert) | |
23 #undef assert | |
24 #endif | |
25 | 21 |
26 class String; | 22 class String; |
27 | 23 |
28 struct console_type | 24 struct console_type |
29 { | 25 { |
30 static void log(const String& str) | 26 static void log(const String& str) |
31 { | 27 { |
32 LogString(str); | 28 LogString(str); |
33 } | 29 } |
34 | 30 |
35 static void log(int i) | 31 static void log(int i) |
36 { | 32 { |
37 LogInteger(i); | 33 LogInteger(i); |
38 } | 34 } |
39 | 35 |
40 static void log(const void* ptr) | 36 static void log(const void* ptr) |
41 { | 37 { |
42 LogPointer(ptr); | 38 LogPointer(ptr); |
43 } | 39 } |
44 | 40 |
45 static void error(const String& str) | 41 static void error(const String& str) |
46 { | 42 { |
47 LogError(str); | 43 LogError(str); |
48 } | 44 } |
49 }; | 45 }; |
50 | 46 |
51 static console_type console; | 47 static console_type console; |
52 | 48 |
53 #if defined(DEBUG) | 49 #if defined(DEBUG) |
54 #define assert(condition) \ | |
55 assert2(condition, u"Assertion failed: "##condition""_str) | |
56 | |
57 inline void assert2(bool condition, const String& str) | 50 inline void assert2(bool condition, const String& str) |
58 { | 51 { |
59 if (!condition) | 52 if (!condition) |
60 console.error(str); | 53 console.error(str); |
61 } | 54 } |
62 #else | 55 #else |
63 #define assert(condition) | |
64 #define assert2(condition, str) | 56 #define assert2(condition, str) |
65 #endif | 57 #endif |
66 | 58 |
67 #if defined(__EMSCRIPTEN_TRACING__) | 59 #if defined(__EMSCRIPTEN_TRACING__) |
68 #include <emscripten/trace.h> | 60 #include <emscripten/trace.h> |
69 | 61 |
70 inline void init_tracing() | 62 inline void init_tracing() |
71 { | 63 { |
72 emscripten_trace_configure("http://127.0.0.1:5000/", "MyApplication"); | 64 emscripten_trace_configure("http://127.0.0.1:5000/", "MyApplication"); |
73 } | 65 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 100 |
109 inline void enter_context(const char* context) | 101 inline void enter_context(const char* context) |
110 { | 102 { |
111 } | 103 } |
112 | 104 |
113 inline void exit_context() | 105 inline void exit_context() |
114 { | 106 { |
115 } | 107 } |
116 | 108 |
117 #endif // defined(__EMSCRIPTEN_TRACING__) | 109 #endif // defined(__EMSCRIPTEN_TRACING__) |
LEFT | RIGHT |