From 730267b5ecbdb2edace74145abe7aa088bbe9f95 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 19 Oct 2024 08:33:51 +0200 Subject: [PATCH] [quickjs] console.warn --- src/js/quickjs/console.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/js/quickjs/console.c b/src/js/quickjs/console.c index bc8cebf68..9988550d8 100644 --- a/src/js/quickjs/console.c +++ b/src/js/quickjs/console.c @@ -119,6 +119,17 @@ js_console_error(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst * return js_console_log_common(ctx, this_val, argc, argv, console_error_filename); } +static JSValue +js_console_warn(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif + REF_JS(this_val); + + return js_console_log_common(ctx, this_val, argc, argv, console_warn_filename); +} + static JSValue js_console_exit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { @@ -147,10 +158,11 @@ js_console_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons static const JSCFunctionListEntry js_console_funcs[] = { JS_CFUNC_DEF("assert", 2, js_console_assert), - JS_CFUNC_DEF("log", 1, js_console_log), JS_CFUNC_DEF("error", 1, js_console_error), JS_CFUNC_DEF("exit", 0, js_console_exit), - JS_CFUNC_DEF("toString", 0, js_console_toString) + JS_CFUNC_DEF("log", 1, js_console_log), + JS_CFUNC_DEF("toString", 0, js_console_toString), + JS_CFUNC_DEF("warn", 1, js_console_warn) }; static JSClassDef js_console_class = {