swig/Lib/javascript/jsc
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 Proper array typemaps in Javascript 2017-01-14 21:10:48 +01:00
ccomplex.i More C99 complex fixes, plus Python tests 2020-06-24 20:21:47 -04:00
cdata.i cdata.i changes and new test li_cdata_bytes 2026-05-25 13:16:09 +01:00
cmalloc.i bring in the `size_t` `cmalloc` in JS 2023-05-31 14:11:13 +02:00
complex.i Merge branch 'devel' of https://github.com/Neha03/gsoc2012-javascript into devel 2012-09-08 00:56:48 +00:00
exception.i Some fixes for the Javascript generator. 2013-09-09 22:25:51 +03:00
factory.i first batch of tests 2023-05-29 12:39:51 +02:00
javascript.swg Move javascriptkw.swg file to Lib/javascript directory 2024-07-18 22:27:52 +02:00
javascriptcode.swg remove hacks and implement default arguments 2023-05-31 13:22:35 +02:00
javascriptcomplex.swg Remove some locator strings in generated code 2024-04-12 08:12:44 +01:00
javascriptfragments.swg Clean up in `javascripttypemaps.swg`. 2013-09-09 17:34:53 +03:00
javascripthelpers.swg Allow using snprintf() instead of sprintf() in wrappers 2023-04-27 10:08:57 +12:00
javascriptinit.swg Lib/javascript/jsc/javascriptinit.swg: shortcut JSGlobalContextRef casts. 2021-03-10 14:48:18 +01:00
javascriptprimtypes.swg Don't use long long if it isn't available 2016-01-06 16:52:37 -05:00
javascriptrun.swg fix JSC too 2023-05-29 21:02:42 +02: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
std_auto_ptr.i Add missing typecheck typemaps for std::auto_ptr and std::unique_ptr 2022-09-17 10:23:51 +01:00
std_common.i Remove execute permissions from various non-executable files 2014-05-02 20:06:11 +02:00
std_complex.i Add missing declaration for std::complex 2017-10-02 19:07:24 +01:00
std_deque.i Add stub std_deque.i files. 2013-09-24 03:56:19 +02:00
std_except.i Merge branch 'devel' of https://github.com/Neha03/gsoc2012-javascript into devel 2012-09-08 00:56:48 +00:00
std_map.i Remove deprecated map and vector specialisation macros 2023-12-03 09:55:35 +13:00
std_pair.i Consistent parameter names for std::pair 2019-02-14 22:44:27 +00:00
std_string.i Javascript: fix warnings in li_std_string test. 2014-05-18 22:40:22 +02:00
std_unique_ptr.i Add const std::unique_ptr & input typemaps 2024-03-06 21:46:58 +00:00
std_vector.i Add STL container copy constructors where missing 2019-02-14 18:53:05 +00:00
stl.i Remove execute permissions from various non-executable files 2014-05-02 20:06:11 +02:00
swigmove.i Provide SWIGTYPE MOVE typemaps in swigmove.i 2022-09-16 08:36:25 +01:00
typemaps.i Fix typos in comments and docs 2023-11-30 17:07:16 +13:00