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

@ -194,6 +194,47 @@
return self;
}
%newobject select;
Map* select() {
if ( !rb_block_given_p() )
rb_raise( rb_eArgError, "no block given" );
Map* r = new Map;
Map::iterator i = $self->begin();
Map::iterator e = $self->end();
for ( ; i != e; ++i )
{
VALUE k = swig::from<Map::key_type>(i->first);
VALUE v = swig::from<Map::mapped_type>(i->second);
if ( RTEST( rb_yield_values(2, k, v) ) )
$self->insert(r->end(), *i);
}
return r;
}
%typemap(in) (int argc, VALUE* argv) {
$1 = argc;
$2 = argv;
}
VALUE values_at(int argc, VALUE* argv, ...) {
VALUE r = rb_ary_new();
ID id = rb_intern("[]");
swig_type_info* type = swig::type_info< Map >();
VALUE me = SWIG_NewPointerObj( $self, type, 0 );
for ( int i = 0; i < argc; ++i )
{
VALUE key = argv[i];
VALUE tmp = rb_funcall( me, id, 1, key );
rb_ary_push( r, tmp );
}
return r;
}
Map* each_key()
{
if ( !rb_block_given_p() )