From 8b5cb79485e87c0e96b2841139fe1578f676ba75 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Fri, 29 Dec 2023 20:53:53 +0100 Subject: [PATCH] [ecmascript] Copy of ecmascript.cpp as ecmascript.c --- src/ecmascript/Makefile | 4 +- src/ecmascript/ecmascript.c | 714 +++++++++++++++++++++++++++++++++ src/ecmascript/ecmascript.cpp | 718 +--------------------------------- src/ecmascript/meson.build | 4 +- 4 files changed, 719 insertions(+), 721 deletions(-) create mode 100644 src/ecmascript/ecmascript.c diff --git a/src/ecmascript/Makefile b/src/ecmascript/Makefile index 3637ef00..1e28e6e2 100644 --- a/src/ecmascript/Makefile +++ b/src/ecmascript/Makefile @@ -12,9 +12,9 @@ SUBDIRS-$(CONFIG_ECMASCRIPT_SMJS) += spidermonkey OBJS-$(CONFIG_ECMASCRIPT_SMJS) += ecmascript.obj ecmascript-c.obj localstorage-db.o spidermonkey.obj timer.o -OBJS-$(CONFIG_MUJS) += ecmascript.obj ecmascript-c.o localstorage-db.o mujs.o timer.o +OBJS-$(CONFIG_MUJS) += ecmascript.o ecmascript-c.o localstorage-db.o mujs.o timer.o -OBJS-$(CONFIG_QUICKJS) += ecmascript.obj ecmascript-c.o localstorage-db.o quickjs.o timer.o +OBJS-$(CONFIG_QUICKJS) += ecmascript.o ecmascript-c.o localstorage-db.o quickjs.o timer.o ifeq ($(CONFIG_ECMASCRIPT_SMJS), yes) CONFIG_ANY_SPIDERMONKEY = yes diff --git a/src/ecmascript/ecmascript.c b/src/ecmascript/ecmascript.c new file mode 100644 index 00000000..0f3a834b --- /dev/null +++ b/src/ecmascript/ecmascript.c @@ -0,0 +1,714 @@ +/* Base ECMAScript file. Mostly a proxy for specific library backends. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "elinks.h" + +#include "config/home.h" +#include "config/options.h" +#include "dialogs/status.h" +#include "document/document.h" +#include "document/libdom/mapa.h" +#include "document/libdom/renderer.h" +#include "document/libdom/renderer2.h" +#include "document/renderer.h" +#include "document/view.h" +#include "ecmascript/ecmascript.h" +#include "ecmascript/ecmascript-c.h" +#include "ecmascript/libdom/parse.h" +#ifdef CONFIG_MUJS +#include "ecmascript/mujs.h" +#else +#ifdef CONFIG_QUICKJS +#include "ecmascript/quickjs.h" +#else +#include "ecmascript/spidermonkey.h" +#endif +#endif +#include "ecmascript/timer.h" +#include "intl/libintl.h" +#include "main/module.h" +#include "main/select.h" +#include "main/timer.h" +#include "osdep/osdep.h" +#include "protocol/protocol.h" +#include "protocol/uri.h" +#include "session/session.h" +#include "session/task.h" +#include "terminal/terminal.h" +#include "terminal/window.h" +#include "util/conv.h" +#include "util/memcount.h" +#include "util/string.h" +#include "viewer/text/draw.h" +#include "viewer/text/view.h" /* current_frame() */ +#include "viewer/text/form.h" /* <-ecmascript_reset_state() */ +#include "viewer/text/vs.h" + +#include + +#undef max +#undef min + +/* TODO: We should have some kind of ACL for the scripts - i.e. ability to + * disallow the scripts to open new windows (or so that the windows are always + * directed to tabs, this particular option would be a tristate), disallow + * messing with your menubar/statusbar visibility, disallow changing the + * statusbar content etc. --pasky */ + +static union option_info ecmascript_options[] = { + INIT_OPT_TREE("", N_("ECMAScript"), + "ecmascript", OPT_ZERO, + N_("ECMAScript options.")), + + INIT_OPT_BOOL("ecmascript", N_("Enable"), + "enable", OPT_ZERO, 0, + N_("Whether to run those scripts inside of documents.")), + + INIT_OPT_BOOL("ecmascript", N_("Console log"), + "enable_console_log", OPT_ZERO, 0, + N_("When enabled logs will be appended to ~/.config/elinks/console.log.")), + + INIT_OPT_BOOL("ecmascript", N_("Script error reporting"), + "error_reporting", OPT_ZERO, 0, + N_("Open a message box when a script reports an error.")), + + INIT_OPT_BOOL("ecmascript", N_("Ignore