From 4790ae9981628f12a4e6d485d07af7d4fbbff412 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 16 Jun 2022 17:33:06 +0200 Subject: [PATCH] [smjs] Compilation fixes when -Dsm-scripting=true and -Dspidermonkey=false. Refs #176 --- meson.build | 4 ++-- src/document/document.c | 4 ++-- src/ecmascript/ecmascript.h | 2 ++ src/main/timer.c | 8 ++++---- src/viewer/action.c | 2 +- src/viewer/text/form.c | 4 ++-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 30569d433..277322393 100644 --- a/meson.build +++ b/meson.build @@ -363,12 +363,12 @@ if conf_data.get('CONFIG_BZIP2') deps += bz2deps endif -if conf_data.get('CONFIG_ECMASCRIPT_SMJS') +if conf_data.get('CONFIG_ECMASCRIPT_SMJS') or conf_data.get('CONFIG_SCRIPTING_SPIDERMONKEY') mozjsdeps = dependency('mozjs-78', static: st) deps += mozjsdeps endif -if conf_data.get('CONFIG_ECMASCRIPT') +if conf_data.get('CONFIG_ECMASCRIPT_SMJS') or conf_data.get('CONFIG_QUICKJS') sqlite3deps = dependency('sqlite3', static: st) deps += sqlite3deps conf_data.set('CONFIG_XML', true) diff --git a/src/document/document.c b/src/document/document.c index 8a3d94b6f..7b2325a28 100644 --- a/src/document/document.c +++ b/src/document/document.c @@ -278,7 +278,7 @@ reset_document(struct document *document) #ifdef CONFIG_CSS free_uri_list(&document->css_imports); #endif -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) free_string_list(&document->onload_snippets); free_uri_list(&document->ecmascript_imports); mem_free_set(&document->text, NULL); @@ -348,7 +348,7 @@ done_document(struct document *document) #ifdef CONFIG_CSS free_uri_list(&document->css_imports); #endif -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) free_string_list(&document->onload_snippets); free_uri_list(&document->ecmascript_imports); kill_timer(&document->timeout); diff --git a/src/ecmascript/ecmascript.h b/src/ecmascript/ecmascript.h index 3f6183bb7..c839868e1 100644 --- a/src/ecmascript/ecmascript.h +++ b/src/ecmascript/ecmascript.h @@ -86,7 +86,9 @@ struct ecmascript_interpreter { #ifdef CONFIG_QUICKJS JSValueConst fun; #else +#ifdef CONFIG_ECMASCRIPT_SMJS JS::RootedValue fun; +#endif #endif bool changed; }; diff --git a/src/main/timer.c b/src/main/timer.c index be9f9ba17..7ead93b85 100644 --- a/src/main/timer.c +++ b/src/main/timer.c @@ -33,7 +33,7 @@ #include "util/memory.h" #include "util/time.h" -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) #include "ecmascript/timer.h" #endif @@ -106,7 +106,7 @@ check_timers(timeval_T *last_time) break; del_from_list(timer); -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) del_from_map_timer(timer); #endif /* At this point, *@timer is to be considered invalid @@ -192,7 +192,7 @@ install_timer(timer_id_T *id, milliseconds_T delay, void (*func)(void *), void * add_at_pos(timer->prev, new_timer); } -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) add_to_map_timer(new_timer); #endif } @@ -206,7 +206,7 @@ kill_timer(timer_id_T *id) if (*id == TIMER_ID_UNDEF) return; timer = *id; del_from_list(timer); -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) del_from_map_timer(timer); #endif diff --git a/src/viewer/action.c b/src/viewer/action.c index cdadb0f7a..3528e6eaa 100644 --- a/src/viewer/action.c +++ b/src/viewer/action.c @@ -672,7 +672,7 @@ do_action(struct session *ses, main_action_T action_id, int verbose) break; case ACT_MAIN_TOGGLE_ECMASCRIPT: -#ifdef CONFIG_ECMASCRIPT +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) toggle_ecmascript(ses); #endif break; diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index 1ac0d5ada..f0ef83fd8 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -355,7 +355,7 @@ find_form_by_form_view(struct document *document, struct form_view *fv) void done_form_state(struct form_state *fs) { -#if defined(CONFIG_ECMASCRIPT) || defined(CONFIG_ECMASCRIPT_SMJS) +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) ecmascript_detach_form_state(fs); #endif mem_free_if(fs->value); @@ -367,7 +367,7 @@ done_form_state(struct form_state *fs) void done_form_view(struct form_view *fv) { -#if defined(CONFIG_ECMASCRIPT) || defined(CONFIG_ECMASCRIPT_SMJS) +#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) ecmascript_detach_form_view(fv); #endif mem_free(fv);