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:
parent
cb6e87d0e9
commit
12b89ff406
4 changed files with 20 additions and 22 deletions
|
|
@ -446,11 +446,10 @@ namespace swig
|
|||
%typemap(out,noblock=1,fragment="RubySequence_Cont")
|
||||
std::pair<const_iterator, const_iterator> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_LEN($result) = 2;
|
||||
rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// std::map/multimap/set allow returning std::pair< iterator, iterator > from
|
||||
|
|
@ -459,11 +458,10 @@ namespace swig
|
|||
%typemap(out,noblock=1,fragment="RubySequence_Cont")
|
||||
std::pair<iterator, iterator> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_LEN($result) = 2;
|
||||
rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second),
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1089,9 +1087,8 @@ namespace swig {
|
|||
int i = 0;
|
||||
for (const_iterator it = seq.begin();
|
||||
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
|
||||
return obj;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -118,13 +118,11 @@
|
|||
|
||||
static VALUE from(const std::pair<T,U>& val) {
|
||||
VALUE obj = rb_ary_new2(2);
|
||||
RARRAY_PTR(obj)[0] = swig::from<
|
||||
typename swig::noconst_traits<T >::noconst_type>(val.first);
|
||||
RARRAY_PTR(obj)[1] = swig::from(val.second);
|
||||
RARRAY_LEN(obj) = 2;
|
||||
rb_define_singleton_method(obj, "second",
|
||||
rb_ary_push(obj, swig::from<typename swig::noconst_traits<T >::noconst_type>(val.first));
|
||||
rb_ary_push(obj, swig::from(val.second));
|
||||
rb_define_singleton_method(obj, "second",
|
||||
VALUEFUNC(_wrap_pair_second), 0 );
|
||||
rb_define_singleton_method(obj, "second=",
|
||||
rb_define_singleton_method(obj, "second=",
|
||||
VALUEFUNC(_wrap_pair_second_eq), 1 );
|
||||
rb_obj_freeze(obj); // treat as immutable tuple
|
||||
return obj;
|
||||
|
|
|
|||
|
|
@ -170,10 +170,9 @@
|
|||
%typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator")
|
||||
std::pair<iterator, bool> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first),
|
||||
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_From(bool)(%static_cast($1,const $type &).second);
|
||||
RARRAY_LEN($result) = 2;
|
||||
rb_ary_push($result, SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first),
|
||||
swig::Iterator::descriptor(),SWIG_POINTER_OWN));
|
||||
rb_ary_push($result, SWIG_From(bool)(%static_cast($1,const $type &).second));
|
||||
}
|
||||
|
||||
%extend {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue