Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11859 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-02-13 15:06:26 +00:00
commit 12b89ff406
4 changed files with 20 additions and 22 deletions

View file

@ -1,6 +1,10 @@
Version 1.3.41 (in progress) Version 1.3.41 (in progress)
============================ ============================
2010-02-13: wsfulton
[Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x
used in various STL wrappers.
2010-02-13: wsfulton 2010-02-13: wsfulton
[C#, Java] Fix incorrect multiply defined symbol name error when an enum item [C#, Java] Fix incorrect multiply defined symbol name error when an enum item
and class name have the same name, as reported by Nathan Krieger. Example: and class name have the same name, as reported by Nathan Krieger. Example:

View file

@ -446,11 +446,10 @@ namespace swig
%typemap(out,noblock=1,fragment="RubySequence_Cont") %typemap(out,noblock=1,fragment="RubySequence_Cont")
std::pair<const_iterator, const_iterator> { std::pair<const_iterator, const_iterator> {
$result = rb_ary_new2(2); $result = rb_ary_new2(2);
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first),
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second),
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
RARRAY_LEN($result) = 2;
} }
// std::map/multimap/set allow returning std::pair< iterator, iterator > from // std::map/multimap/set allow returning std::pair< iterator, iterator > from
@ -459,11 +458,10 @@ namespace swig
%typemap(out,noblock=1,fragment="RubySequence_Cont") %typemap(out,noblock=1,fragment="RubySequence_Cont")
std::pair<iterator, iterator> { std::pair<iterator, iterator> {
$result = rb_ary_new2(2); $result = rb_ary_new2(2);
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first),
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second),
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
RARRAY_LEN($result) = 2;
} }
@ -1089,9 +1087,8 @@ namespace swig {
int i = 0; int i = 0;
for (const_iterator it = seq.begin(); for (const_iterator it = seq.begin();
it != seq.end(); ++it, ++i) { it != seq.end(); ++it, ++i) {
RARRAY_PTR(obj)[i] = swig::from< value_type >(*it); rb_ary_push(obj, swig::from< value_type >(*it));
} }
RARRAY_LEN(obj) = size;
rb_obj_freeze(obj); // treat as immutable result rb_obj_freeze(obj); // treat as immutable result
return obj; return obj;
} else { } else {

View file

@ -118,13 +118,11 @@
static VALUE from(const std::pair<T,U>& val) { static VALUE from(const std::pair<T,U>& val) {
VALUE obj = rb_ary_new2(2); VALUE obj = rb_ary_new2(2);
RARRAY_PTR(obj)[0] = swig::from< rb_ary_push(obj, swig::from<typename swig::noconst_traits<T >::noconst_type>(val.first));
typename swig::noconst_traits<T >::noconst_type>(val.first); rb_ary_push(obj, swig::from(val.second));
RARRAY_PTR(obj)[1] = swig::from(val.second); rb_define_singleton_method(obj, "second",
RARRAY_LEN(obj) = 2;
rb_define_singleton_method(obj, "second",
VALUEFUNC(_wrap_pair_second), 0 ); VALUEFUNC(_wrap_pair_second), 0 );
rb_define_singleton_method(obj, "second=", rb_define_singleton_method(obj, "second=",
VALUEFUNC(_wrap_pair_second_eq), 1 ); VALUEFUNC(_wrap_pair_second_eq), 1 );
rb_obj_freeze(obj); // treat as immutable tuple rb_obj_freeze(obj); // treat as immutable tuple
return obj; return obj;

View file

@ -170,10 +170,9 @@
%typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator") %typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator")
std::pair<iterator, bool> { std::pair<iterator, bool> {
$result = rb_ary_new2(2); $result = rb_ary_new2(2);
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first), rb_ary_push($result, SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first),
swig::Iterator::descriptor(),SWIG_POINTER_OWN); swig::Iterator::descriptor(),SWIG_POINTER_OWN));
RARRAY_PTR($result)[1] = SWIG_From(bool)(%static_cast($1,const $type &).second); rb_ary_push($result, SWIG_From(bool)(%static_cast($1,const $type &).second));
RARRAY_LEN($result) = 2;
} }
%extend { %extend {