Add Ruby missing methods for vector<bool> specialization
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11576 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
06c06f8742
commit
55170f0f88
3 changed files with 12 additions and 24 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
Version 1.3.40 (in progress)
|
Version 1.3.40 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2009-08-15: wsfulton
|
||||||
|
[Ruby] Add numerous missing wrapped methods for std::vector<bool> specialization
|
||||||
|
as reported by Youssef Jones.
|
||||||
|
|
||||||
2009-08-14: wsfulton
|
2009-08-14: wsfulton
|
||||||
[Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
|
[Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
|
||||||
memory ownership control. shared_ptr support still to be added. Patch from
|
memory ownership control. shared_ptr support still to be added. Patch from
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,13 @@ sv[1] = Li_std_vector::Struct.new
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
bv = BoolVector.new(2)
|
||||||
|
[true, false, true, true].each { |i| bv.push(i) }
|
||||||
|
0.upto(bv.size-1) { |i| bv[i] = !bv[i] }
|
||||||
|
bv_check = [true, true, false, true, false, false]
|
||||||
|
for i in 0..bv.size-1 do
|
||||||
|
swig_assert(bv_check[i] == bv[i], binding, "bv[#{i}]")
|
||||||
|
end
|
||||||
|
|
||||||
swig_assert_each_line(<<'EOF', binding)
|
swig_assert_each_line(<<'EOF', binding)
|
||||||
lv = LanguageVector.new
|
lv = LanguageVector.new
|
||||||
|
|
|
||||||
|
|
@ -875,31 +875,8 @@ namespace swig
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
// ..I don't think %swig_sequence_methods_val are really used at all anymore...
|
|
||||||
%define %swig_sequence_methods_val(Sequence...)
|
%define %swig_sequence_methods_val(Sequence...)
|
||||||
%swig_sequence_methods_common(%arg(Sequence))
|
%swig_sequence_methods(%arg(Sequence))
|
||||||
%extend {
|
|
||||||
|
|
||||||
VALUE __getitem__(difference_type i) {
|
|
||||||
VALUE r = Qnil;
|
|
||||||
try {
|
|
||||||
r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
|
|
||||||
}
|
|
||||||
catch( std::out_of_range )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE __setitem__(difference_type i, value_type x) {
|
|
||||||
std::size_t len = $self->size();
|
|
||||||
if ( i < 0 ) i = len - i;
|
|
||||||
else if ( static_cast<std::size_t>(i) >= len )
|
|
||||||
$self->resize( i+1, x );
|
|
||||||
else *(swig::getpos(self,i)) = x;
|
|
||||||
return swig::from< Sequence::value_type >( x );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue