Fixed VALUE less compare function to be a good GC_VALUE

less compare function.  This is used for hashing.
Moved the functor over to rubyclasses to avoid bloat
when GC_VALUE is not used.
Updated std::map test to check for equivalence.
Updated CHANGES.current a tad to move the STL
stuff as last and merge two feature updates as one.




git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9740 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Gonzalo Garramuno 2007-05-01 09:55:44 +00:00
commit a6fa331dae
5 changed files with 161 additions and 73 deletions

View file

@ -71,26 +71,6 @@ namespace swig {
{
%#include <functional>
namespace std {
template <>
struct less< VALUE >: public binary_function< VALUE, VALUE, bool >
{
static ID id;
bool
operator()( VALUE v, VALUE w ) const
{
// SWIG_RUBY_THREAD_BEGIN_BLOCK;
bool res = NUM2INT( rb_funcall(v, id, 1, w) ) < 0;
// SWIG_RUBY_THREAD_END_BLOCK;
return res;
}
};
ID less< VALUE >::id = rb_intern("<=>");
}
namespace swig {
template < class T >
@ -652,6 +632,24 @@ namespace swig
return self;
}
%newobject select
Sequence* select() {
if ( !rb_block_given_p() )
rb_raise( rb_eArgError, "no block given" );
Sequence* r = new Sequence;
Sequence::iterator i = self->begin();
Sequence::iterator e = self->end();
for ( ; i != e; ++i )
{
VALUE v = swig::from<Sequence::value_type>(*i);
if ( RTEST( rb_yield(v) ) )
$self->push_back(*i);
}
return r;
}
%rename("reject!") reject_bang;
%alias reject_bang "delete_if";
@ -659,12 +657,11 @@ namespace swig
if ( !rb_block_given_p() )
rb_raise( rb_eArgError, "no block given" );
VALUE r;
Sequence::iterator i = self->begin();
Sequence::iterator e = self->end();
for ( ; i != e; )
{
r = swig::from<Sequence::value_type>(*i);
VALUE r = swig::from<Sequence::value_type>(*i);
if ( RTEST( rb_yield(r) ) )
$self->erase(i++);
else