 Issue 29333474:
  Issue 4125 - [emscripten] Convert filter classes to C++  (Closed)
    
  
    Issue 29333474:
  Issue 4125 - [emscripten] Convert filter classes to C++  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 #pragma once | |
| 2 | |
| 3 #include <emscripten.h> | |
| 4 #include <emscripten/trace.h> | |
| 5 | |
| 6 #if defined(assert) | |
| 7 #undef assert | |
| 8 #endif | |
| 9 | |
| 10 class String; | |
| 11 | |
| 12 struct console_type | |
| 13 { | |
| 14 static void log(const String& str) | |
| 15 { | |
| 16 EM_ASM_ARGS(console.log(getStringData($0)), &str); | |
| 17 } | |
| 18 | |
| 19 static void log(int i) | |
| 20 { | |
| 21 EM_ASM_ARGS(console.log($0), i); | |
| 22 } | |
| 23 | |
| 24 static void log(void* ptr) | |
| 25 { | |
| 26 EM_ASM_ARGS(console.log($0), ptr); | |
| 27 } | |
| 28 | |
| 29 static void error(const String& str) | |
| 30 { | |
| 31 EM_ASM_ARGS(console.error(new Error(getStringData($0)).stack), &str); | |
| 32 } | |
| 33 }; | |
| 34 | |
| 35 static console_type console; | |
| 36 | |
| 37 inline void assert(bool condition, const String& str) | |
| 38 { | |
| 39 #if defined(DEBUG) | |
| 40 if (!condition) | |
| 41 console.error(str); | |
| 42 #endif | |
| 43 } | |
| 
sergei
2016/02/23 15:45:57
BTW, I would #define `assert` to nothing when DEBU
 
Wladimir Palant
2016/02/23 21:35:01
Done.
 | |
| 44 | |
| 45 inline void annotate_address(void* address, const char* name) | |
| 46 { | |
| 47 #if defined(__EMSCRIPTEN_TRACING__) | |
| 48 emscripten_trace_annotate_address_type(address, name); | |
| 49 #endif | |
| 50 } | |
| 51 | |
| 52 inline void enter_context(const char* context) | |
| 53 { | |
| 54 #if defined(__EMSCRIPTEN_TRACING__) | |
| 55 emscripten_trace_enter_context(context); | |
| 56 #endif | |
| 57 } | |
| 58 | |
| 59 inline void exit_context() | |
| 60 { | |
| 61 #if defined(__EMSCRIPTEN_TRACING__) | |
| 62 emscripten_trace_exit_context(); | |
| 63 #endif | |
| 64 } | |
| OLD | NEW |