v8 12.6 deprecated FunctionCallbackInfo::Holder() and 13.5 removed it, so the
generated code did not compile with Node.js 24. This() has been available for
as long as SWIG has supported v8 and is the documented replacement, so it is
used unconditionally via the new SWIGV8_ARGS_THIS macro.
PropertyCallbackInfo needs a version check as its Holder() replacement,
HolderV2(), was only added in v8 12.7 - SWIGV8_INFO_HOLDER handles this.
v8 13.3 added Utf8LengthV2 and WriteUtf8V2 and deprecated Utf8Length and
WriteUtf8, which is fatal as the examples are compiled with -Werror. The
existing SWIGV8_UTF8_LENGTH and SWIGV8_WRITE_UTF8 macros now select between
them. The buffer size passed to SWIGV8_WRITE_UTF8 now always includes room
for the NUL and the returned count includes the NUL, matching WriteUtf8V2
with WriteFlags::kNullTerminate.
The ARGC/ARGV typemap relied on the old behaviour of passing a buffer size
excluding the NUL. With WriteUtf8V2 that silently truncates the last
character while still returning the expected count, so the length check
would have passed for a corrupted string.
Node.js 24 is added to the CI test matrix for both the node and napi engines.
The minimum supported v8 version is unchanged at 7.4.
Assisted-by: Claude Code (Opus 5)
SWIG source is not run through Doxygen, so the Doxygen comment markers /**,
/*!, /// and //! are just noise; SWIG uses plain /* ... */ block comments.
Document this in the swig-conventions skill and convert the existing Doxygen
markers in SWIG's own C/C++ source (the Source/ tree and the Ruby runtime in
Lib/ruby) to plain /* comments.
Target language documentation comments that the library templates emit into generated code
- for example the C# /// comments in Lib/csharp and the JavaScript and Java /** comments -
are left unchanged, since they are part of the generated output rather than SWIG's own source.
Assisted-by: Claude Code (Opus 4.8)
The $isvoid special variable expands to 1 if the
wrapped function has a void return, otherwise expands to 0.
In the implementation, use a consistent variable name, returntype,
for a node's "type" attribute.
Issue #2907
Avoids confusion with newly created Allocate::is_assignable.
Language::is_immutable is just a wrapper around the
"feature:immutable" flag since previous commit.
is_mutable rename wip
Improve the constructor rename detection and attempts to ignore it.
This has not worked previously, but the recent addition of the
template_templated_constructors testcase resulted in code that did not
compile.
These are the testcases that are affected as they attempt to use a
renamed constructor:
constructor_rename
conversion_ns_template
overload_rename
template_templated_constructors
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++.
Add Swig_obligatory_macros which must be called by each
target language to define SWIG_VERSION correctly
in the generated code, as well as the language specific
macro SWIGXXX where XXX is the target language name.
Drop the #ifdef SWIGXXX that was previously generated -
I can't see the point of this and if users are defining
this macro somehow, then users will need to change this
Closes#1050
Ensure that SWIG_VERSION is defined both at SWIG-time and in the
generated C/C++ wrapper code (it was only defined in the wrapper
for some target languages previously).
SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.
Stop defining SWIGVERSION in the wrapper. This only happened as a
side-effect of how SWIG_VERSION was defined but was never documented and
is redundant.
The new testcase also checks that SWIG is defined at SWIG-time but not
in the generated wrapper, and that exactly one of a list of
target-language specific macros is defined.
Fixes#1050
The debug command line options that display parse tree nodes
(-debug-module, -debug-top, -debug-symtabs) now display previously hidden
linked list pointers which are useful for debugging parse trees.
Added new command line option -debug-quiet. This suppresses the display
of most linked list pointers and symbol table pointers in the parse tree nodes.
The keys in the parse tree node are now shown in alphabetical order.
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.
This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.
This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).
Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms. Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.
Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
Remove redundant NULL checks before free()/delete
The ISO C and C++ standards guarantee that it's safe to call these
on a NULL pointer, so it's not necessary for the calling code to
also check.
Fixes https://sourceforge.net/p/swig/feature-requests/70/
When building SWIG for Android, there is no support for C++ exceptions.
In the cases there is "Illegal state", it seems more like an internal
error, so we can replace the throw calls with a debug print and exit
immediately.
Closes#1858
This fix takes into account the classname while generating overload
handlers.
Example:
If you have two classes:
class A {
public:
void doSomething(int);
void doSomething(double);
};
class B {
public:
void doSomething(int);
void doSomething(double);
};
Before this patch, the overload handlers for A::doSomething and
B::doSomething create conflicting names and function redefinition errors
are caused.
After the patch, the overload handlers are named classname_doSomething
and no longer conflict.
This is might not the best way to implement this, but it
solves a critical problem on large projects, and specifically can affect
operator overloads that are being wrapped.