From 7acee28e2d808ab1cd1e9a39b4b3c9ebf5856987 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 25 Nov 2023 13:07:29 +0100 Subject: [PATCH] [dialogs] Rename info.cpp to info.c Long term goal is to able compile by only C compiler if ecmascript is not compiled-in. --- meson.build | 2 +- src/dialogs/Makefile | 2 +- src/dialogs/{info.cpp => info.c} | 4 +++- src/dialogs/meson.build | 2 +- src/ecmascript/ecmascript-c.cpp | 15 +++++++++++++++ src/ecmascript/ecmascript-c.h | 14 ++++++++++++++ src/ecmascript/ecmascript.cpp | 8 +------- src/ecmascript/ecmascript.h | 1 - src/ecmascript/meson.build | 2 +- 9 files changed, 37 insertions(+), 13 deletions(-) rename src/dialogs/{info.cpp => info.c} (99%) create mode 100644 src/ecmascript/ecmascript-c.cpp create mode 100644 src/ecmascript/ecmascript-c.h diff --git a/meson.build b/meson.build index 4938c170..e8b57023 100644 --- a/meson.build +++ b/meson.build @@ -593,7 +593,7 @@ if not compiler.links('''#include return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); }''', name: 'GCC atomic builtins required -latomic') - dep_atomic = compiler.find_library('atomic', static: st) + dep_atomic = compiler.find_library('atomic', static: st) endif if conf_data.get('CONFIG_QUICKJS') diff --git a/src/dialogs/Makefile b/src/dialogs/Makefile index 00eabeb7..d82b7467 100644 --- a/src/dialogs/Makefile +++ b/src/dialogs/Makefile @@ -3,6 +3,6 @@ include $(top_builddir)/Makefile.config OBJS-$(CONFIG_EXMODE) += exmode.o -OBJS = document.o download.o edit.o info.obj menu.o options.o progress.o status.o +OBJS = document.o download.o edit.o info.o menu.o options.o progress.o status.o include $(top_srcdir)/Makefile.lib diff --git a/src/dialogs/info.cpp b/src/dialogs/info.c similarity index 99% rename from src/dialogs/info.cpp rename to src/dialogs/info.c index 29b522cc..ad3961aa 100644 --- a/src/dialogs/info.cpp +++ b/src/dialogs/info.c @@ -23,7 +23,9 @@ #include "config/options.h" #include "dialogs/info.h" #include "document/renderer.h" -#include "ecmascript/ecmascript.h" +#ifdef CONFIG_ECMASCRIPT_SMJS +#include "ecmascript/ecmascript-c.h" +#endif #include "intl/libintl.h" #include "main/select.h" #include "main/timer.h" diff --git a/src/dialogs/meson.build b/src/dialogs/meson.build index a2cdf393..59ff3e3f 100644 --- a/src/dialogs/meson.build +++ b/src/dialogs/meson.build @@ -1,4 +1,4 @@ if conf_data.get('CONFIG_EXMODE') srcs += files('exmode.c') endif -srcs += files('document.c', 'download.c', 'edit.c', 'info.cpp', 'menu.c', 'options.c', 'progress.c', 'status.c') +srcs += files('document.c', 'download.c', 'edit.c', 'info.c', 'menu.c', 'options.c', 'progress.c', 'status.c') diff --git a/src/ecmascript/ecmascript-c.cpp b/src/ecmascript/ecmascript-c.cpp new file mode 100644 index 00000000..cdb6b8af --- /dev/null +++ b/src/ecmascript/ecmascript-c.cpp @@ -0,0 +1,15 @@ +/* ECMAScript helper functions */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ecmascript/ecmascript-c.h" + +extern int interpreter_count; + +int +ecmascript_get_interpreter_count(void) +{ + return interpreter_count; +} diff --git a/src/ecmascript/ecmascript-c.h b/src/ecmascript/ecmascript-c.h new file mode 100644 index 00000000..abb61cc1 --- /dev/null +++ b/src/ecmascript/ecmascript-c.h @@ -0,0 +1,14 @@ +#ifndef EL__ECMASCRIPT_ECMASCRIPT_C_H +#define EL__ECMASCRIPT_ECMASCRIPT_C_H + +#ifdef __cplusplus +extern "C" { +#endif + +int ecmascript_get_interpreter_count(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/ecmascript/ecmascript.cpp b/src/ecmascript/ecmascript.cpp index ec12132c..a141c629 100644 --- a/src/ecmascript/ecmascript.cpp +++ b/src/ecmascript/ecmascript.cpp @@ -99,7 +99,7 @@ static union option_info ecmascript_options[] = { NULL_OPTION_INFO, }; -static int interpreter_count; +int interpreter_count; static INIT_LIST_OF(struct string_list_item, allowed_urls); static INIT_LIST_OF(struct string_list_item, disallowed_urls); @@ -300,12 +300,6 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter) --interpreter_count; } -int -ecmascript_get_interpreter_count(void) -{ - return interpreter_count; -} - static void delayed_reload(void *data) { diff --git a/src/ecmascript/ecmascript.h b/src/ecmascript/ecmascript.h index d887c4a4..f3d05554 100644 --- a/src/ecmascript/ecmascript.h +++ b/src/ecmascript/ecmascript.h @@ -156,7 +156,6 @@ void ecmascript_free_urls(struct module *module); struct ecmascript_interpreter *ecmascript_get_interpreter(struct view_state*vs); void ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter); -int ecmascript_get_interpreter_count(void); void ecmascript_detach_form_view(struct form_view *fv); void ecmascript_detach_form_state(struct form_state *fs); diff --git a/src/ecmascript/meson.build b/src/ecmascript/meson.build index 13a0b850..749be217 100644 --- a/src/ecmascript/meson.build +++ b/src/ecmascript/meson.build @@ -1,6 +1,6 @@ #INCLUDES += $(SPIDERMONKEY_CFLAGS) if conf_data.get('CONFIG_ECMASCRIPT_SMJS') - srcs += files('ecmascript.cpp', 'localstorage-db.cpp', 'spidermonkey.cpp', 'timer.cpp') + srcs += files('ecmascript.cpp', 'ecmascript-c.cpp', 'localstorage-db.cpp', 'spidermonkey.cpp', 'timer.cpp') subdir('spidermonkey') endif