summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2022-11-30 13:45:31 +1300
committerOlly Betts <olly@survex.com>2023-04-22 13:33:46 +1200
commitb508598a42b80f9e63f6ebbaf04fdbfee30ea2a2 (patch)
tree271c454ee90a1a47d1029811f76be80cca792775
parentd85fe418a8c7a074a5e985ff531724919ea0fceb (diff)
downloadswig-b508598a42b80f9e63f6ebbaf04fdbfee30ea2a2.tar.gz
[js] Turn on C++ output for node too
Nodejs is like V8 and needs C++ output enabled when wrapping C code. The testsuite was masking this bug by using SWIG options `-v8 -DBUILDING_NODE_EXTENSION=1` rather than `-node` when testing with nodejs, while the javascript examples currently all seem to all get processed with -c++.
-rw-r--r--Examples/test-suite/javascript/Makefile.in2
-rw-r--r--Source/Modules/javascript.cxx12
2 files changed, 5 insertions, 9 deletions
diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
index 4835453cc..a124a068f 100644
--- a/Examples/test-suite/javascript/Makefile.in
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -49,7 +49,7 @@ _setup = \
ifeq (node,$(JSENGINE))
- SWIGOPT += -v8 -DBUILDING_NODE_EXTENSION=1
+ SWIGOPT += -node
# shut up some warnings
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index 17ba4f766..2fbc5505c 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -566,6 +566,7 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
}
switch (engine) {
+ case JSEmitter::NodeJS:
case JSEmitter::V8:
{
emitter = swig_javascript_create_V8Emitter();
@@ -575,6 +576,9 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
if (!cparse_cplusplus) {
Swig_cparse_cplusplusout(1);
}
+ if (engine == JSEmitter::NodeJS) {
+ Preprocessor_define("BUILDING_NODE_EXTENSION 1", 0);
+ }
break;
}
case JSEmitter::JavascriptCore:
@@ -584,14 +588,6 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
SWIG_library_directory("javascript/jsc");
break;
}
- case JSEmitter::NodeJS:
- {
- emitter = swig_javascript_create_V8Emitter();
- Preprocessor_define("SWIG_JAVASCRIPT_V8 1", 0);
- Preprocessor_define("BUILDING_NODE_EXTENSION 1", 0);
- SWIG_library_directory("javascript/v8");
- break;
- }
default:
{
Printf(stderr, "SWIG Javascript: Unknown engine. Please specify one of '-jsc', '-v8' or '-node'.\n");