From 597280940dc01ee4124cfd3ed621a4160b496bea Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 19 Oct 2024 08:30:40 +0200 Subject: [PATCH] [spidermonkey] console.warn --- src/js/ecmascript.c | 3 +++ src/js/ecmascript.h | 1 + src/js/spidermonkey/console.cpp | 13 ++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/js/ecmascript.c b/src/js/ecmascript.c index 79d69a068..9f3520b13 100644 --- a/src/js/ecmascript.c +++ b/src/js/ecmascript.c @@ -115,6 +115,7 @@ static INIT_LIST_OF(struct string_list_item, disallowed_urls); char *console_error_filename; char *console_log_filename; +char *console_warn_filename; char *local_storage_filename; @@ -706,6 +707,7 @@ init_ecmascript_module(struct module *module) if (xdg_config_home) { /* ecmascript console log */ console_log_filename = straconcat(xdg_config_home, "/console.log", NULL); + console_warn_filename = straconcat(xdg_config_home, "/console.warn", NULL); console_error_filename = program.testjs ? stracpy("/dev/stderr") : straconcat(xdg_config_home, "/console.err", NULL); /* ecmascript local storage db location */ #ifdef CONFIG_OS_DOS @@ -731,6 +733,7 @@ done_ecmascript_module(struct module *module) free_string_list(&disallowed_urls); mem_free_if(console_log_filename); mem_free_if(console_error_filename); + mem_free_if(console_warn_filename); mem_free_if(local_storage_filename); done_map_timer(); } diff --git a/src/js/ecmascript.h b/src/js/ecmascript.h index 1c6e69b06..4d472698b 100644 --- a/src/js/ecmascript.h +++ b/src/js/ecmascript.h @@ -196,6 +196,7 @@ void location_goto_const(struct document_view *doc_view, const char *url, int re extern char *console_error_filename; extern char *console_log_filename; +extern char *console_warn_filename; extern char *local_storage_filename; extern int local_storage_ready; diff --git a/src/js/spidermonkey/console.cpp b/src/js/spidermonkey/console.cpp index 11137f58a..324b915aa 100644 --- a/src/js/spidermonkey/console.cpp +++ b/src/js/spidermonkey/console.cpp @@ -58,12 +58,14 @@ static bool console_assert(JSContext *ctx, unsigned int argc, JS::Value *vp); static bool console_error(JSContext *ctx, unsigned int argc, JS::Value *vp); static bool console_exit(JSContext *ctx, unsigned int argc, JS::Value *vp); static bool console_log(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool console_warn(JSContext *ctx, unsigned int argc, JS::Value *vp); const spidermonkeyFunctionSpec console_funcs[] = { { "assert", console_assert, 2 }, - { "log", console_log, 1 }, { "error", console_error, 1 }, { "exit", console_exit, 0 }, + { "log", console_log, 1 }, + { "warn", console_warn, 1 }, { NULL } }; @@ -154,6 +156,15 @@ console_error(JSContext *ctx, unsigned int argc, JS::Value *vp) return console_log_common(ctx, argc, vp, console_error_filename); } +static bool +console_warn(JSContext *ctx, unsigned int argc, JS::Value *vp) +{ +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif + return console_log_common(ctx, argc, vp, console_warn_filename); +} + static bool console_exit(JSContext *ctx, unsigned int argc, JS::Value *vp) {