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)
This is the oldest we are able to test in CI, and only then via it being
the version use by the oldest node.js we can test in CI. We have no
direct testing with v8 in CI currently, and it seems hard to
v8_shell.cxx no longer building with more recent v8 versions.
See #2537
Context-aware initialization allows to instantiate add-ons multiple
times, most importantly in multiple Workers' contexts. Workers made
first appearance in v10.5. Context-aware initialization was option
earlier than that, even before supported minimum v6.x, yet condition
is chosen more conservatively as NODE_MODULE_VERSION >= 64, a.k.a.
v10.0.
The proposed changes targetted at 5.2 (or 5.4 to be more precise, since there is no Node release with V8 5.2 or 5.3) work for lower versions as well and bust the deprecation warnings there.
* Use WeakCallbackInfo instead of WeakCallbackData
* Use GetPrivate instead of GetHiddenValue
* Adopted new signature for SetWeak to support destructor calling
* SetAccessor deprecation fixed
* Proper version checks where applicable
- v8 generator uses the correct mangled name for class templates
- removed symbols for template variables in favor of using the string
literals directly, as it is easier to understand when debugging.
I did not realize this branch has some JavaScriptCore stuff in it too. Unfortunately, it seems to have its own unique problems (like creating C++ files when it should be generating C files). My changes are targeted for v8, and I don't think my JSCore changes fully reach in this JSCore implementation so more work would need to be done to get this branch working. I think my Neha fork is in better shape at the moment.
Also, I did port over the 'NULL out the dtor function pointer' in the %nodefaultdtor fix to v8.
Usage case:
struct MyData {
%extend {
~MyData() {
FreeData($self);
}
}
};
%newobject CreateData;
struct MyData* CreateData(void);
%delobject FreeData;
void FreeData(struct MyData* the_data);
where the use case is something like:
var my_data = example.CreateData();
my_data = null;