Commit graph

50 commits

Author SHA1 Message Date
William S Fulton
f99a2e6f64 Add Ruby support for std::unique_ptr inputs
Equivalent to Java/C#/Python implementations.
2022-07-17 15:20:25 +01:00
Robin Stocker
962f090001 Fix Ruby 3.2 warning "undefining the allocator of T_DATA class swig_runtime_data"
Ruby 3.2 (still in development) started warning about this, see
https://bugs.ruby-lang.org/issues/18007.

Note that the extension docs mention it in
https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object:

> The klass argument is the class for the object. The klass should
> derive from `rb_cObject`, and the allocator must be set by calling
> `rb_define_alloc_func` or `rb_undef_alloc_func`.

So in this case we call `rb_undef_alloc_func` to fix the warning.
Verified that this works in robinst/taglib-ruby#115.

Fixes #2257.
2022-04-12 08:32:42 +12:00
Thomas Reitmayr
5a10e10399 Ruby: Fix warnings in generated code about missing parameter in variadic macro
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).
2022-01-29 11:07:57 +13:00
Viktor Gal
7d2dbe3670 fix #1199 2020-02-01 11:25:30 +01:00
Takashi Tamura
ff9e9f9f98 [ruby] check whether object is of RTypedData using RTYPEDDATA_P. 2019-02-22 19:55:54 +00:00
William S Fulton
d14c97408d Fix overloading for non-pointers and NULL - Ruby 2018-12-29 14:15:51 +00:00
Olly Betts
90f9117e10 Fix various comment and documentation typos 2017-08-13 18:04:33 +12:00
William S Fulton
b4377488f7 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj.
Closes #935
2017-04-20 18:51:45 +01:00
Takashi Tamura
d0af6fd97d [ruby] must not do null check for VALUE obj, which can be 0x0 == Qfalse, a valid Ruby object. 2017-03-06 15:13:05 +09:00
William S Fulton
763827c2e1 Ruby opaque pointer handling regression fix
This bug was introduced in swig-3.0.8 in #146252 adding shared_ptr
support. An ObjectPreviouslyDeleted error was incorrectly thrown
when the pointer was used as a parameter after being set to zero
via a call to 'DATA_PTR(self) = 0'.

It isn't clear to me which approach is better in this corner case,
so I've gone for backwards compatibility and restored the old behaviour.

Closes #602
2016-05-24 19:09:17 +01:00
William S Fulton
4f2dcfaeeb Fixes for Ruby and using -Wmissing-field-initializers 2015-12-19 16:21:22 +00:00
William S Fulton
146252ff21 SWIG_Ruby_ConvertPtrAndOwn changes for smartptr feature
rb_obj_is_kind_of can no longer be used for type checking as the
smartptr feature type, eg shared_ptr<Derived> cannot be cast to
a smartptr of the base class, eg shared_ptr<Base>.
Previously Derived could be cast to Base as they were in an
inheritance chain and the call to rb_define_class_under() used
SWIGTYPE_p_Base->clientdata for all derived classes.
Now SWIG_TypeCheck is always used.
2015-09-25 22:58:00 +01:00
William S Fulton
3d1e20248f Ruby ownership refactor ready for smart pointers
ruby_owntype replaced with swig_ruby_owntype which contains a member own
for forthcoming smart pointer support.
2015-09-14 07:20:43 +01:00
William S Fulton
1c5246ad66 Fix some gcc -Wall unused warnings in the Ruby wrappers
Fixes SF bug 1333.
2013-10-18 18:13:11 +01:00
William S Fulton
5d529d5a76 Ruby 1.9 fixes.
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.
2013-04-05 23:41:59 +01:00
William S Fulton
2c74c90430 Fix for gcc warning -Wunused-value without triggering -Wunused-parameter
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13735 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-09-07 06:06:00 +00:00
William S Fulton
5effbc386c Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12980 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-14 16:18:04 +00:00
William S Fulton
4308dd03cf 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.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11874 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-27 23:26:02 +00:00
William S Fulton
830de4d2f1 Various ruby-1.9.x compile fixes including patch from Nibble
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11862 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-13 16:59:41 +00:00
William S Fulton
f309dc9262 gcc-4.4 warning fix for ruby
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11781 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-12-12 22:27:22 +00:00
William S Fulton
a91e4906b5 Add newmemory parameter for SWIG_TypeCast
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10240 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-02-10 00:35:11 +00:00
Gonzalo Garramuno
94a6b8ddb1 Revered _mSWIG to rubyhead.swg as some tests would fail.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9931 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-09-04 06:43:28 +00:00
Gonzalo Garramuno
d1defceb95 Moved _mSWIG to rubyrun.swg with all other static
variables.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9927 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-09-04 06:12:38 +00:00
Gonzalo Garramuno
8f6e08dcb5 Silly gcc was complaining about static initializers when
compiling in C.
Code was now moved to initialization and variables were
prefixed with swig_*.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9925 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-09-04 05:40:49 +00:00
Gonzalo Garramuno
bbd80cfa84 Moved some of the common checks for methods/procs and arity
to rubyrun.swg, as they are useful even for not stl stuff.

Added a fragment trait for marking STL containers, but this
fragment cannot be attached due to SWIG %template limitations.




git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9874 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-07-24 05:46:55 +00:00
Gonzalo Garramuno
1cf8fd332b Added constructor that can take functors to all
containers that can use one.
Created file rubystdfunctors.swg to allow passing in
Ruby procs as functors to STL functions (swig-user list
suggestion for Python).
Fixed a bug in type_info() always failing for std::set.
Fixed a bug in type_info() always accepting any failed
conversion which could lead to overloaded functions to
fail when input wrong parameters.




git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9775 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-06 03:56:33 +00:00
Gonzalo Garramuno
81c84b7e8c Rename fixes to STL.
Removed object reporting in non-verbose from 
newobject demos.
Made wstring treat them as normal strings as
advertised.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9771 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-05 00:46:20 +00:00
Gonzalo Garramuno
4cd98d3865 Improved algorithm of renaming of methods with numbers at the end.
Fixed some const issues.
Improved report on overloaded function error.
Fixed some minor iterator potential problems.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9770 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-04 13:12:31 +00:00
Gonzalo Garramuno
7d570676f5 Better autodocs.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9760 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-03 09:56:28 +00:00
Gonzalo Garramuno
57cca3c3cb Minor cleanup. Mode RUBY_INIT_STACK macro
definition to rubyhead.swg where all the backward
compatability macros are kept.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9715 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-29 22:56:18 +00:00
Gonzalo Garramuno
4feaed41f0 Fixed typo for RUBY_EMBEDDED.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-29 20:12:48 +00:00
Gonzalo Garramuno
b6a08f9ec7 Added support to avoid swig director type mismatch errors
on embedded ruby.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9702 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-29 19:39:52 +00:00
Gonzalo Garramuno
18f614364f Improved ruby trackings across DSOs, removing the
need for -DSWIG_EXTERN.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9699 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-29 18:48:22 +00:00
Gonzalo Garramuno
4b8d11d0e2 Fixed ruby's newobject1 and newobject2 demos.
Added swig_assert.rb and started using it in some tests.
Added my patches to ruby.cxx, rubyrun.swg, rubystrings.swg
and rubytracking.swg [see: sourceforge]



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9691 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-28 04:20:28 +00:00
Olly Betts
2f6a268e55 Support building with recent versions of the Ruby 1.9 development branch.
Fixes bug #1560092.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9333 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-09-23 21:39:09 +00:00
William S Fulton
797317163a cosmetics
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8988 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-03-07 22:02:54 +00:00
William S Fulton
49be05f4fd Common template for head of each file detailing licence, distribution and authors information
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8973 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-03-07 00:14:10 +00:00
Charlie Savage
e66f81f904 Fixed a bug in Ruby's object tracking functionality. Previously, an object could be returned even if it did not have the correct type. This could occur if a factory class' creation method had a signature returning a base type (like geometry) but in reality a subclass (like Point) was returned. In that case, it would then be impossible to implement a "downcast" method and get back a Ruby object of type Point. Also updated the test-suite to test this situation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8861 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-22 08:20:48 +00:00
Marcelo Matus
36b96882c5 fix seg. fault for void types
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8694 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-03 22:09:54 +00:00
Marcelo Matus
0f7b502a3b fix -external-runtime and warning arounds in subversion
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8666 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-01 08:37:53 +00:00
Charlie Savage
0d57e7af5b Added SWIG_POINTER_EXCEPTION for backwards compatibility.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8422 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-13 23:43:12 +00:00
Charlie Savage
7e96a9e2d5 Added SWIG_ObjectPreviouslyDeletedError for Ruby. This error happens when a Ruby object's underlying C++ object has been freed. This can happen if a Ruby/C++ object is put into a C++ container that then frees its objects when it goes out of scope, leaving a dangling reference in Ruby.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8340 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-10 00:52:37 +00:00
Charlie Savage
6c8dd53ee8 Reimplementation of tracking objects in Ruby. Instead of passing the $track flag to
the methods SWIG_Ruby_ConvertPtrAndOwn and SWIG_Ruby_NewPointerObj,
now tracking information is held on swig_class.  This change reduces
significantly reduces the amount of code needed in ruby.cxx, is more robust, and is
more cohesive.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8082 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-27 18:02:51 +00:00
Marcelo Matus
f222064ffd fix for ruby -w
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7948 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-08 08:46:04 +00:00
Marcelo Matus
f3c24eff33 fixes for directors + pointers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7860 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-21 21:01:35 +00:00
Marcelo Matus
536621e82b prevents ConvertPtr to modified the result when fails
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7757 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-31 09:41:43 +00:00
Marcelo Matus
3c65cea431 Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-24 14:59:05 +00:00
Marcelo Matus
ba3efb0917 finishing the first stage of the typemap unification scheme, fixing issues with gcc and valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7692 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-20 09:47:56 +00:00
Marcelo Matus
aadff06f45 more typemaps unification and fixes for valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7684 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-19 10:52:50 +00:00
Marcelo Matus
7e5e4fd1f9 massive typemap unification
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-18 13:24:15 +00:00