swig/Lib/ruby
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
..
Makefile.swig Whitespace cleanup of all Makefiles* 2014-05-02 20:06:11 +02:00
argcargv.i argcargv / OOM-protection follow-ups 2026-05-19 21:01:30 +01:00
attribute.i move attribute.i to the typemap library, now is usable from all the languages 2005-10-25 13:20:50 +00:00
boost_shared_ptr.i More move semantics improvements 2022-07-04 11:19:50 +01:00
carrays.i carrays.i library modified to use size_t instead of int 2023-10-11 08:23:16 +01:00
cmalloc.i more typemaps unification and fixes for valgrind 2005-10-19 10:52:50 +00:00
cpointer.i more typemaps unification and fixes for valgrind 2005-10-19 10:52:50 +00:00
cstring.i Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names 2005-10-24 14:59:05 +00:00
director.swg Fix -Wextra-semi warnings (#3372) 2026-03-18 18:53:05 +00:00
embed.i consistent inclusion of ruby.h 2010-02-13 14:22:31 +00:00
exception.i use internal SWIG_exception_fail, let SWIG_exception as in 1.3.27 2006-01-14 21:23:36 +00:00
extconf.rb Add Ruby support contributed by Masaki Fukushima. 2000-07-05 18:58:49 +00:00
extra-install.list The great merge 2002-11-30 22:01:28 +00:00
factory.i add the factory library for UTL 2006-02-22 18:42:20 +00:00
file.i Fix compiler warnings in generated code when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type 2014-05-24 14:13:19 +01:00
progargcargv.i Clean up after removal of ignore typemaps 2023-06-15 16:22:31 +12:00
ruby.swg Ruby constants and uppercasing regression fix 2023-09-09 23:21:02 +01:00
rubyapi.swg Ruby fix for non-void functions using INOUT typemaps 2024-10-05 23:29:34 +01:00
rubyautodoc.swg Fix typos 2021-11-17 07:07:02 +02:00
rubyclasses.swg Ruby: complete the TypedData migration - GC marker, docs and test enforcement 2026-06-08 22:16:26 +01:00
rubycomplex.swg Remove some locator strings in generated code 2024-04-12 08:12:44 +01:00
rubycontainer.swg Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
rubycontainer_extended.swg Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
rubydef.swg fix -external-runtime and warning arounds in subversion 2006-02-01 08:37:53 +00:00
rubyerrors.swg [ruby] Update comment in rubyerrors.swg 2024-09-20 16:21:29 +12:00
rubyfragments.swg fix comments about fragments - noticed by Josh Cherry 2007-11-20 21:45:06 +00:00
rubyhead.swg Ruby: embed the TypedData wrapper for per-class descriptors too 2026-06-16 23:32:25 +01:00
rubyinit.swg massive typemap unification 2005-10-18 13:24:15 +00:00
rubyiterators.swg Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
rubykw.swg Renames performed by `%namewarn` with `rename=` are printed in warning message 2022-02-06 13:51:37 -05:00
rubymacros.swg Improved algorithm of renaming of methods with numbers at the end. 2007-05-04 13:12:31 +00:00
rubyopers.swg add macros/names to avoid numeric warning codes. use them in tcl,perl,ruby and python 2006-01-07 06:59:32 +00:00
rubyprimtypes.swg Remove some locator strings in generated code 2024-04-12 08:12:44 +01:00
rubyrun.swg [Ruby] Fix segfault for proxies detached with DATA_PTR(obj) = NULL 2026-07-24 23:28:52 +01:00
rubyruntime.swg more comments 2006-02-11 20:36:39 +00:00
rubystdautodoc.swg SWIG license change - The Examples and Lib move to a very permissive license in the LICENSE file, removing the BSD license restrictions as agreed by committers since it was inadvertently introduced. Remove some examples where the impact of the license change is not clear. 2010-02-27 23:26:02 +00:00
rubystdcommon.swg as() now always throws and never creates an invalid object with memset() 2017-07-03 15:35:24 -06:00
rubystdcommon_forward.swg [ruby] treat null shared_ptr in std containers properly. 2017-04-20 18:53:47 +09:00
rubystdfunctors.swg Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
rubystrings.swg Pass SWIG_FromCharPtrAndSize and friends on to the C compiler 2026-07-31 00:10:40 +01:00
rubytracking.swg [Ruby] Fix segfault for proxies detached with DATA_PTR(obj) = NULL 2026-07-24 23:28:52 +01:00
rubytypemaps.swg Use the canonical capitalisation of Unified Typemap Library 2026-07-23 17:30:59 +01:00
rubyuserdir.swg Misc. typos 2018-05-17 10:04:23 -04:00
rubywstrings.swg [ruby] use %fragment to clarify the dependency of code. 2017-02-23 21:08:04 +09:00
std_alloc.i Updated Ruby's STL to new framework. 2007-04-30 06:36:55 +00:00
std_array.i Ruby: 2024-02-22 21:00:12 +00: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_basic_string.i std_basic_string.i fixes 2018-01-04 07:00:26 +00:00
std_char_traits.i STL stream support for Ruby. 2007-05-02 10:00:26 +00:00
std_common.i Fix STL wrappers to not generate <: digraphs. 2015-12-12 14:05:46 +00:00
std_complex.i Add missing declaration for std::complex 2017-10-02 19:07:24 +01:00
std_container.i Updated Ruby's STL to new framework. 2007-04-30 06:36:55 +00:00
std_deque.i Revert "Move fragment StdDequeTraits to std/std_deque.i" 2024-09-26 16:35:00 +12:00
std_except.i add std_except typemaps to the unified typemap library 2005-10-31 09:43:02 +00:00
std_functors.i Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
std_ios.i Made autodoc ignore numinputs=0. 2007-05-02 22:09:06 +00:00
std_iostream.i STL stream support for Ruby. 2007-05-02 10:00:26 +00:00
std_list.i Add missing parameter names in STL container wrappers 2019-02-13 22:45:47 +00:00
std_map.i Fix select of std::map std::vector 2024-05-14 10:26:10 +02:00
std_multimap.i Ruby: Fix warnings in generated code about missing parameter in variadic macro 2022-01-29 11:07:57 +13:00
std_multiset.i [ruby] make std::multiset and std::unordered_multiset include Enumerable. tests added. 2017-02-24 16:59:17 +09:00
std_pair.i Replicate Python memory leak fix in std::pair for Octave and Ruby 2016-12-18 20:00:40 +00:00
std_queue.i Add missing parameter names in STL container wrappers 2019-02-13 22:45:47 +00:00
std_set.i Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
std_shared_ptr.i Remove an unnecessary shared_ptr reference count increment in Ruby wrappers 2020-02-13 19:48:30 +00:00
std_sstream.i STL stream support for Ruby. 2007-05-02 10:00:26 +00:00
std_stack.i Add missing parameter names in STL container wrappers 2019-02-13 22:45:47 +00:00
std_streambuf.i STL stream support for Ruby. 2007-05-02 10:00:26 +00:00
std_string.i Suppress Ruby std::wstring, std::string, std::basic_string warnings 2017-10-10 07:52:10 +01:00
std_string_view.i Add missing new file for Ruby string_view support 2023-05-18 18:42:51 +12:00
std_unique_ptr.i Add const std::unique_ptr & input typemaps 2024-03-06 21:46:58 +00:00
std_unordered_map.i Ruby: Fix warnings in generated code about missing parameter in variadic macro 2022-01-29 11:07:57 +13:00
std_unordered_multimap.i Ruby: Fix warnings in generated code about missing parameter in variadic macro 2022-01-29 11:07:57 +13:00
std_unordered_multiset.i Include all template parameters for std_unordered_multiset and std_unordered_set 2019-03-12 21:47:45 +00:00
std_unordered_set.i Include all template parameters for std_unordered_multiset and std_unordered_set 2019-03-12 21:47:45 +00:00
std_vector.i Fixed renames of std_* containers to a safer 2007-05-16 21:27:08 +00:00
std_vectora.i Rename fixes to STL. 2007-05-05 00:46:20 +00:00
std_wstring.i Convert Doxygen comment markers to plain C comments in SWIG source 2026-06-08 22:16:29 +01:00
stl.i Create a consistent stl.i library file 2019-02-12 18:46:05 +00:00
swigmove.i Provide SWIGTYPE MOVE typemaps in swigmove.i 2022-09-16 08:36:25 +01:00
timeval.i Ruby: Fix warnings in generated code about missing parameter in variadic macro 2022-01-29 11:07:57 +13:00
typemaps.i Remove deprecated BOTH typemap rule 2023-06-15 15:07:04 +12:00