Convert the hidden SwigGCReferences marker object - added with the deprecated
Data_Wrap_Struct by the #3385 GC compaction fix - to TypedData_Wrap_Struct,
removing the last use of the untyped Data API from the Ruby runtime. The
st_table registry and the pinning mark are unchanged; the marker still wraps a
non-NULL pointer so its mark function is not skipped by the garbage collector.
Drop -Wno-deprecated-declarations from the Ruby test flags so that any
reintroduced Data_Wrap_Struct, Data_Make_Struct or Data_Get_Struct fails to
compile under -Werror: Ruby 3.4 warns about the untyped Data API by default and
Ruby 4.0 removes it entirely, so no extra define is needed. The flag dated to an
unrelated macOS isfinite/finite workaround, which is still applied on macOS
through the common flags.
Also add the CHANGES entry and the Ruby manual note describing the migration and
the DATA_PTR / Data_Get_Struct replacement that hand written code must use.
Issue #3170
Assisted-by: Claude Code (Opus 4.8)
Ruby objects stored in wrapped STL containers are held by swig::GC_VALUE
as raw VALUEs in C++ - the std::map and std::set keys and the
BinaryPredicate comparator proc. The keep alive registry SwigGCReferences
kept those objects alive but did not pin them, so Ruby 3.x heap
compaction (GC.compact or GC.auto_compact) could relocate them, leaving
the C++ copies dangling and segfaulting the next time the comparator ran.
SwigGCReferences now backs its registry with an st_table instead of a
Ruby Hash, avoiding any C++ STL dependency in the wrapper, and registers
a mark callback that marks every tracked object with the pinning mark
rb_gc_mark. That keeps the objects alive and stops compaction moving
them. Keying the st_table by the VALUE also means register and unregister
no longer dispatch a method on the object.
Add a compaction stress regression to li_std_functors_runme.rb, and drop
the Ruby 3.3 skip that was previously hiding this crash.
Assisted-by: Claude Code (Opus 4.8)
The Ruby C API function 'rb_funcall' is used in various places in generated
code for invoking a Ruby method without parameters. The C function uses a
variadic parameter list for the arguments passed to Ruby, therefore in these
cases the list of variadic parameters is empty.
As an optimization Ruby may implement the 'rb_funcall' function as a macro
which however will not accept an empty list of arguments for '...' as of
C99 and C++11.
In order to prevent compiler warnings, this commit replaces all such
occurrences with a call to 'rb_funcall2' (which in its current name
'rb_funcallv' is invoked by the 'rb_funcall' macro anyway, at least for
Ruby 2.6.6).
This commit fixes the signatures of various callback methods
and cleans up the macro definitions used for casting callbacks.
Note that the transparent version of the macro RUBY_METHOD_FUNC
is currently masked behind RUBY_DEVEL, see commit
1d91feaf13
In order to still support strict signature checking and prevent
nasty deprecation warnings, the use of RUBY_METHOD_FUNC had to
be replaced with VALUEFUNC.
Move to construct on first use idiom for singleton definition,
which prevents problems with singletons between ruby swig modules
in an environment with multiple modules on MacOS 10.9 with xcode 5.1.
Before this fix, data was being shared between modules which caused
a crash on shutdown of the ruby interpreter if more than one
module was loaded at a time.
SF Bug#1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL wrappers that override the default predicate, such as:
%template(Map) std::map<swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ, swig::BinaryPredicate<> >;
Fixes li_std_functors testcases for Ruby 1.9.
Also rb_respond_to return values have changed subtely in 1.9 and return should be treated as a flag instead of checking for Qtrue, see SF Bug #1159.
Also fix li_std_map, li_std_set silently failing - rb_protect behaviour seems to have changed when an exception is thrown, so code has been changed to use rb_rescue. A call to 'rb_set_errinfo(Qnil)' could have solved this after the rb_protect call, but it is only available in 1.9+ and Ruby API changes are not easily and transparently detectable.
This file contains standard ruby algorithms but
which place some restriction on the class inside
the STL container.
Fixed GC_VALUE so that it cannot be instantiated
from the language manually.
Fixed delete autodoc.
Started documenting each portion of the SWIG
templates/macros so it makes sense to people.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9773 626c5289-ae23-0410-ae9c-e8d60b6d4f22
failing due to having been done with old hash sort.
Improved rubycontainer a little bit. Made GC_VALUE
sort an rb_protect function to prevent bad sorting
attempt of an Array against a String.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9747 626c5289-ae23-0410-ae9c-e8d60b6d4f22
less compare function. This is used for hashing.
Moved the functor over to rubyclasses to avoid bloat
when GC_VALUE is not used.
Updated std::map test to check for equivalence.
Updated CHANGES.current a tad to move the STL
stuff as last and merge two feature updates as one.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9740 626c5289-ae23-0410-ae9c-e8d60b6d4f22
of const correctness in the std swig STL library.
Need to bring it up in the swig-devel list.
Added new functions to swig_assert.
Changed some tests to reflect these changes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9730 626c5289-ae23-0410-ae9c-e8d60b6d4f22