[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++.
This commit is contained in:
Olly Betts 2022-11-30 13:45:31 +13:00
parent d85fe418a8
commit b508598a42
2 changed files with 5 additions and 9 deletions

View File

@ -49,7 +49,7 @@ _setup = \
ifeq (node,$(JSENGINE)) ifeq (node,$(JSENGINE))
SWIGOPT += -v8 -DBUILDING_NODE_EXTENSION=1 SWIGOPT += -node
# shut up some warnings # shut up some warnings

View File

@ -566,6 +566,7 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
} }
switch (engine) { switch (engine) {
case JSEmitter::NodeJS:
case JSEmitter::V8: case JSEmitter::V8:
{ {
emitter = swig_javascript_create_V8Emitter(); emitter = swig_javascript_create_V8Emitter();
@ -575,6 +576,9 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
if (!cparse_cplusplus) { if (!cparse_cplusplus) {
Swig_cparse_cplusplusout(1); Swig_cparse_cplusplusout(1);
} }
if (engine == JSEmitter::NodeJS) {
Preprocessor_define("BUILDING_NODE_EXTENSION 1", 0);
}
break; break;
} }
case JSEmitter::JavascriptCore: case JSEmitter::JavascriptCore:
@ -584,14 +588,6 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
SWIG_library_directory("javascript/jsc"); SWIG_library_directory("javascript/jsc");
break; 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: default:
{ {
Printf(stderr, "SWIG Javascript: Unknown engine. Please specify one of '-jsc', '-v8' or '-node'.\n"); Printf(stderr, "SWIG Javascript: Unknown engine. Please specify one of '-jsc', '-v8' or '-node'.\n");