MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add util.debuglog

+20 -2
+2 -2
include/types.h
··· 25 25 typedef uint64_t ant_offset_t; 26 26 typedef uint64_t ant_value_t; 27 27 28 - typedef ant_value_t (*ant_cfunc_t) 29 - (ant_t *, ant_value_t *, int); 28 + typedef ant_value_t (*ant_cfunc_t) (ant_t *, ant_value_t *, int); 29 + #define ant_params_t ant_t *js, ant_value_t *args, int nargs 30 30 31 31 #endif
+18
src/modules/util.c
··· 210 210 return out; 211 211 } 212 212 213 + static ant_value_t util_debuglog_call(ant_params_t) { 214 + return js_mkundef(); 215 + } 216 + 217 + static ant_value_t util_debuglog(ant_params_t) { 218 + ant_value_t logger = js_mkfun(util_debuglog_call); 219 + js_set(js, logger, "enabled", js_false); 220 + 221 + if (nargs >= 2 && is_callable(args[1])) { 222 + ant_value_t cb_args[1] = { logger }; 223 + ant_value_t result = sv_vm_call(js->vm, js, args[1], js_mkundef(), cb_args, 1, NULL, false); 224 + if (is_err(result) || js->thrown_exists) return result; 225 + } 226 + 227 + return logger; 228 + } 229 + 213 230 static ant_value_t util_strip_vt_control_characters(ant_t *js, ant_value_t *args, int nargs) { 214 231 if (nargs < 1) return js_mkstr(js, "", 0); 215 232 ··· 633 650 634 651 js_set(js, lib, "format", js_mkfun(util_format)); 635 652 js_set(js, lib, "formatWithOptions", js_mkfun(util_format_with_options)); 653 + js_set(js, lib, "debuglog", js_mkfun(util_debuglog)); 636 654 js_set(js, lib, "inspect", js_mkfun(util_inspect)); 637 655 js_set(js, lib, "deprecate", js_mkfun(util_deprecate)); 638 656 js_set(js, lib, "inherits", js_mkfun(util_inherits));