Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Upgrade to new emscripten_log prototype in 1.39.12 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: | fea1e09c300cc0fdbe12f5976fea346d |
User & Date: | Beuc 2020-04-18 11:53:48 |
Context
2020-04-20
| ||
13:45 | Tidy JavaScript snippets check-in: 1da4ec9b97 user: Beuc tags: trunk | |
2020-04-18
| ||
11:53 | Upgrade to new emscripten_log prototype in 1.39.12 check-in: fea1e09c30 user: Beuc tags: trunk | |
2020-03-07
| ||
12:11 | Typo check-in: 9b78bab422 user: Beuc tags: trunk | |
Changes
Changes to emscripten.pyx.
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
EM_LOG_JS_STACK EM_LOG_DEMANGLE EM_LOG_NO_PATHS EM_LOG_FUNC_PARAMS int emscripten_get_compiler_setting(const char *name) void emscripten_debugger() void emscripten_log(int flags, ...) int emscripten_get_callstack(int flags, char *out, int maxbytes) LOG_CONSOLE = EM_LOG_CONSOLE LOG_WARN = EM_LOG_WARN LOG_ERROR = EM_LOG_ERROR LOG_C_STACK = EM_LOG_C_STACK LOG_JS_STACK = EM_LOG_JS_STACK ................................................................................ # u'invalid compiler setting: EXPORTED_FUNCTIONS' # :( def debugger(): emscripten_debugger() # open the JavaScript console # emscripten.debugger() def log(flags, *args): # No variadic function support in Cython? # No va_arg variant for emscripten_log either. # Let's offer limited support cdef char* format cdef char* cstr if len(args) == 0: emscripten_log(flags) elif len(args) > 0: format = args[0] if len(args) == 1: emscripten_log(flags, format) elif len(args) == 2: arg = args[1] if type(arg) == int: emscripten_log(flags, format, <int>arg) elif type(arg) == float: emscripten_log(flags, format, <float>arg) elif type(arg) in (str, unicode): pystr = arg.encode('UTF-8') cstr = pystr emscripten_log(flags, format, cstr) else: pystr = ("emscripten.log: unsupported argument " + str(type(arg))).encode('UTF-8') cstr = pystr emscripten_log(flags, cstr) else: emscripten_log(flags, "emscripten.log: only up to 2 arguments are supported") # import emscripten; emscripten.log(0, "hello %02d", 1) # import emscripten; emscripten.log(emscripten.LOG_WARN|emscripten.LOG_CONSOLE|emscripten.LOG_C_STACK, "warning!") def get_callstack(flags): cdef int size = emscripten_get_callstack(flags, NULL, 0) # "subsequent calls will carry different line numbers, so it is # best to allocate a few bytes extra to be safe" size += 1024 cdef char* buf = <char*>PyMem_Malloc(size) |
|
|
|
|
>
>
|
<
<
<
|
|
|
|
>
>
>
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
EM_LOG_JS_STACK EM_LOG_DEMANGLE EM_LOG_NO_PATHS EM_LOG_FUNC_PARAMS int emscripten_get_compiler_setting(const char *name) void emscripten_debugger() void emscripten_log(int flags, const char* format, ...) int emscripten_get_callstack(int flags, char *out, int maxbytes) LOG_CONSOLE = EM_LOG_CONSOLE LOG_WARN = EM_LOG_WARN LOG_ERROR = EM_LOG_ERROR LOG_C_STACK = EM_LOG_C_STACK LOG_JS_STACK = EM_LOG_JS_STACK ................................................................................ # u'invalid compiler setting: EXPORTED_FUNCTIONS' # :( def debugger(): emscripten_debugger() # open the JavaScript console # emscripten.debugger() def log(flags, fmt, *args): # No variadic function support in Cython? # No va_arg variant for emscripten_log either. # Let's offer limited support cdef char* cstr cdef char* cformat pystrfmt = fmt.encode('UTF-8') cformat = pystrfmt if len(args) == 0: emscripten_log(flags, cformat) elif len(args) > 0: if len(args) == 1: arg = args[0] if type(arg) == int: emscripten_log(flags, cformat, <int>arg) elif type(arg) == float: emscripten_log(flags, cformat, <float>arg) elif type(arg) in (str, unicode): pystr = arg.encode('UTF-8') cstr = pystr emscripten_log(flags, cformat, cstr) else: pystr = ("emscripten.log: unsupported argument " + str(type(arg))).encode('UTF-8') cstr = pystr emscripten_log(flags, cstr) else: emscripten_log(flags, "emscripten.log: only up to 2 arguments are supported") # import emscripten; emscripten.log(0, "hello %02d", 1) # import emscripten; emscripten.log(emscripten.LOG_WARN|emscripten.LOG_CONSOLE|emscripten.LOG_C_STACK, "warning!") # emscripten_log doesn't to properly support UTF-8 # import emscripten; emscripten.log(0, u"é") # import emscripten; emscripten.log(0, "%s", u"é") def get_callstack(flags): cdef int size = emscripten_get_callstack(flags, NULL, 0) # "subsequent calls will carry different line numbers, so it is # best to allocate a few bytes extra to be safe" size += 1024 cdef char* buf = <char*>PyMem_Malloc(size) |