Cosmetic changes in C++11 std_unordered support files

This commit is contained in:
William S Fulton 2017-02-10 19:26:02 +00:00
commit 50f556de39
8 changed files with 12 additions and 32 deletions

View file

@ -21,7 +21,7 @@
typedef std::unordered_map<K,T> map_type;
static int asptr(VALUE obj, map_type **val) {
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
if (TYPE(obj) == T_HASH) {
static ID id_to_a = rb_intern("to_a");
VALUE items = rb_funcall(obj, id_to_a, 0);
res = traits_asptr_stdseq<std::unordered_map<K,T>, std::pair<K, T> >::asptr(items, val);
@ -50,7 +50,7 @@
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (rubysize < 0) {
SWIG_RUBY_THREAD_BEGIN_BLOCK;
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
rb_raise(rb_eRuntimeError, "map size not valid in Ruby");
SWIG_RUBY_THREAD_END_BLOCK;
return Qnil;
}

View file

@ -59,24 +59,22 @@
VALUE key = swig::from(i->first);
VALUE val = swig::from(i->second);
VALUE oldval = rb_hash_aref( obj, key );
if ( oldval == Qnil )
VALUE oldval = rb_hash_aref(obj, key);
if (oldval == Qnil) {
rb_hash_aset(obj, key, val);
else {
} else {
// Multiple values for this key, create array if needed
// and add a new element to it.
VALUE ary;
if ( TYPE(oldval) == T_ARRAY )
if (TYPE(oldval) == T_ARRAY) {
ary = oldval;
else
{
ary = rb_ary_new2(2);
rb_ary_push( ary, oldval );
rb_hash_aset( obj, key, ary );
}
rb_ary_push( ary, val );
} else {
ary = rb_ary_new2(2);
rb_ary_push(ary, oldval);
rb_hash_aset(obj, key, ary);
}
rb_ary_push(ary, val);
}
}
return obj;
}

View file

@ -36,8 +36,6 @@
#define %swig_unordered_multiset_methods(Set...) %swig_unordered_set_methods(Set)
%rename("delete") std::unordered_multiset::__delete__;
%rename("reject!") std::unordered_multiset::reject_bang;
%rename("map!") std::unordered_multiset::map_bang;

View file

@ -38,8 +38,6 @@
%mixin std::unordered_set "Enumerable";
%rename("delete") std::unordered_set::__delete__;
%rename("reject!") std::unordered_set::reject_bang;
%rename("map!") std::unordered_set::map_bang;
@ -49,6 +47,4 @@
%alias std::unordered_set::push "<<";
%include <std/std_unordered_set.i>

View file

@ -1,8 +1,5 @@
//
// std::unordered_map
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_pair.i>
%include <std_container.i>

View file

@ -1,8 +1,5 @@
//
// std::unordered_multimap
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_unordered_map.i>

View file

@ -1,8 +1,5 @@
//
// std::unordered_multiset
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_unordered_set.i>

View file

@ -1,8 +1,5 @@
//
// std::unordered_set
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_container.i>