Fix for std::pair< iterator, iterator > making the

iterator non-consts, when the key is always const
and will prevent modification.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9816 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Gonzalo Garramuno 2007-05-17 10:28:20 +00:00
commit 211ee4eb0a

View file

@ -453,13 +453,16 @@ namespace swig
RARRAY_LEN($result) = 2;
}
// std::map/multimap allow returning std::pair< iterator, iterator > from
// equal_range, but we cannot still modify the key, so the iterator is
// const.
%typemap(out,noblock=1,fragment="RubySequence_Cont")
std::pair<iterator, iterator> {
$result = rb_ary_new2(2);
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_nonconst_iterator(%static_cast($1,const $type &).first),
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_nonconst_iterator(%static_cast($1,const $type &).second),
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
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;
}
@ -478,7 +481,7 @@ namespace swig
%typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator")
std::pair<iterator, bool> {
$result = rb_ary_new2(2);
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_nonconst_iterator(%static_cast($1,const $type &).first),
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_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;