diff --git a/Lib/python/pyvaltypes.swg b/Lib/python/pyvaltypes.swg index e2feaead3..69d7f0a57 100644 --- a/Lib/python/pyvaltypes.swg +++ b/Lib/python/pyvaltypes.swg @@ -7,7 +7,7 @@ /* in */ %define PYVAL_IN_TYPEMAP(as_meth,pyfrag,...) - %typemap(in,fragment=pyfrag) __VA_ARGS__ + %typemap(in,fragment=pyfrag) __VA_ARGS__ "$1 = ($ltype)as_meth($input); if (PyErr_Occurred()) SWIG_fail;"; %typemap(in,fragment=pyfrag) const __VA_ARGS__ & ($basetype temp) diff --git a/Lib/python/std_deque.i b/Lib/python/std_deque.i index 93d935ccd..6013231cc 100644 --- a/Lib/python/std_deque.i +++ b/Lib/python/std_deque.i @@ -113,7 +113,10 @@ namespace std { typedef value_type reference; typedef value_type const_reference; + %traits_swigtype(T); + %fragment(SWIG_Traits_frag(std::deque), "header", + fragment=SWIG_Traits_frag(T), fragment="StdDequeTraits") { namespace swigpy { template <> struct traits > { diff --git a/Lib/python/std_list.i b/Lib/python/std_list.i index 844728b94..1e716c883 100644 --- a/Lib/python/std_list.i +++ b/Lib/python/std_list.i @@ -124,7 +124,10 @@ namespace std { typedef value_type reference; typedef value_type const_reference; + %traits_swigtype(T); + %fragment(SWIG_Traits_frag(std::list), "header", + fragment=SWIG_Traits_frag(T), fragment="StdListTraits") { namespace swigpy { template <> struct traits > { diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i index 669a7df3f..af33663cc 100644 --- a/Lib/python/std_pair.i +++ b/Lib/python/std_pair.i @@ -138,7 +138,7 @@ namespace std { %typemap_traits_ptr(SWIG_CCode(PAIR), std::pair); pair(); - pair(const T& __a, U* __b); + pair(T __a, U* __b); pair(const pair& __p); T first; @@ -171,7 +171,7 @@ namespace std { %typemap_traits_ptr(SWIG_CCode(PAIR), std::pair); pair(); - pair(T* __a, const U& __b); + pair(T* __a, U __b); pair(const pair& __p); T* first; diff --git a/Lib/python/std_set.i b/Lib/python/std_set.i index b88fe79d6..69c76ca90 100644 --- a/Lib/python/std_set.i +++ b/Lib/python/std_set.i @@ -30,10 +30,26 @@ %define %std_set_methods(set) %std_set_methods_common(set); #ifdef SWIG_EXPORT_ITERATOR_METHODS + pair insert(const value_type& __x); iterator insert(iterator pos); #endif %enddef +%define %pyset_methods(set) + %pycontainer_methods(set); + + %extend { + void append(value_type x) { + self->insert(x); + } + + bool __contains__(value_type x) { + return self->find(x) != self->end(); + } + }; + +%enddef + // ------------------------------------------------------------------------ // std::set // @@ -121,9 +137,8 @@ namespace std { %typemap_traits_ptr(SWIG_CCode(SET), std::set); %std_set_methods(set); - %pycontainer_methods(std::set); + %pyset_methods(std::set); }; - } %define %std_set_ptypen(...) diff --git a/Lib/python/std_vector.i b/Lib/python/std_vector.i index b0adb6a2a..76146b104 100644 --- a/Lib/python/std_vector.i +++ b/Lib/python/std_vector.i @@ -132,6 +132,7 @@ namespace std { %traits_swigtype(T); %fragment(SWIG_Traits_frag(std::vector), "header", + fragment=SWIG_Traits_frag(T), fragment="StdVectorTraits") { namespace swigpy { template <> struct traits > {