swig/Lib/javascript/napi
William S Fulton de573cda78 Pass SWIG_FromCharPtrAndSize and friends on to the C compiler
A bare #define at the start of a line in a brace delimited %fragment body is
consumed by the SWIG preprocessor and never reaches the generated wrapper. The
macro therefore only exists at SWIG level and code that SWIG does not macro
expand, such as a typemap delimited with %{ ... %}, is left referring to an
undefined name. Use %#define so the definition is emitted for the C compiler.

Fixes SWIG_FromCharPtrAndSize for Python, SWIG_FromBinaryCharPtrAndSize for
Octave, Perl, R and Ruby, SWIG_ToUint8Array and SWIG_FromUint8Array for
JavaScript, and the SWIG_AsVal_* and SWIG_From_* macros in the Scilab char,
short, signed char, unsigned char, unsigned long and long long files.

Lib/scilab/scipointer.swg is deliberately left alone. Its fragments are never
requested by any typemap, so they are only emitted as SWIG preprocessor
definitions; switching them to %#define drops SWIG_ConvertPtr and
SWIG_NewPointerObj from the generated code entirely. Fixing those needs the
definitions moving to a runtime insert, as the other target languages do.

Add a common test case charptr_fragment. It uses a %{ ... %} delimited typemap
so the macro name survives into the wrapper, which only compiles when the
library defines the macro for the C compiler. The target languages without
these macros wrap the same functions using their default typemaps. Verified
that the generated Python module fails to load before this change with an
undefined symbol for SWIG_FromCharPtrAndSize.

Follows on from #3522.

Assisted-by: Claude Code (Opus 5)
2026-07-31 00:10:40 +01:00
..
argcargv.i Use NULL instead of SWIG_NULLPTR 2025-07-02 08:43:32 +01:00
arrays_javascript.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
ccomplex.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
cdata.i cdata.i changes and new test li_cdata_bytes 2026-05-25 13:16:09 +01:00
cmalloc.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
complex.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
exception.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
factory.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
javascript.swg Move javascriptkw.swg file to Lib/javascript directory 2024-07-18 22:27:52 +02:00
javascriptcode.swg Fix -Wextra-semi warnings (#3372) 2026-03-18 18:53:05 +00:00
javascriptcomplex.swg Remove some locator strings in generated code 2024-04-12 08:12:44 +01:00
javascriptfragments.swg Javascript Node-API support added 2023-06-28 07:24:51 +01:00
javascriptinit.swg Javascript Node-API support added 2023-06-28 07:24:51 +01:00
javascriptprimtypes.swg Javascript Node-API support added 2023-06-28 07:24:51 +01:00
javascriptrun.swg Fix -Wextra-semi warnings (#3372) 2026-03-18 18:53:05 +00:00
javascriptruntime.swg Add <errno.h> fragment for errno usage 2024-11-22 19:07:10 +00:00
javascriptstrings.swg Support NULL being passed into char* in typemaps 2024-03-06 21:46:58 +00:00
javascripttypemaps.swg Use the canonical capitalisation of Unified Typemap Library 2026-07-23 17:30:59 +01:00
javascriptuint8array.swg Pass SWIG_FromCharPtrAndSize and friends on to the C compiler 2026-07-31 00:10:40 +01:00
nodejs_buffer.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_auto_ptr.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_common.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_complex.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_deque.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_except.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_map.i Remove deprecated map and vector specialisation macros 2023-12-03 09:55:35 +13:00
std_pair.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_string.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
std_unique_ptr.i Add const std::unique_ptr & input typemaps 2024-03-06 21:46:58 +00:00
std_vector.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
stl.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
swigmove.i Javascript Node-API support added 2023-06-28 07:24:51 +01:00
typemaps.i Remove reintroduced reference to BOTH 2023-10-25 09:37:56 +13:00