From 30f59ffe2286283fb01ae2418bf6464f78f18e05 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Mar 2019 20:03:14 +0000 Subject: [PATCH] Include all template parameters for std_unordered_multimap and std_unordered_map --- Examples/test-suite/cpp11_std_unordered_map.i | 4 +++ Lib/python/std_unordered_map.i | 6 ++-- Lib/python/std_unordered_multimap.i | 28 +++++++++---------- Lib/ruby/std_unordered_map.i | 20 ++++++------- Lib/ruby/std_unordered_multimap.i | 22 +++++++-------- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/Examples/test-suite/cpp11_std_unordered_map.i b/Examples/test-suite/cpp11_std_unordered_map.i index b11d8f275..4bdec9c7c 100644 --- a/Examples/test-suite/cpp11_std_unordered_map.i +++ b/Examples/test-suite/cpp11_std_unordered_map.i @@ -5,3 +5,7 @@ %template(UnorderedMapIntInt) std::unordered_map; %template(UnorderedMapStringInt) std::unordered_map; + +%inline %{ +std::unordered_map,std::equal_to< std::string >,std::allocator< std::pair< std::string const,int > > > inout(std::unordered_map m) { return m; } +%} diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 76acbb1ec..042d5b671 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -56,9 +56,9 @@ %fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { + assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { typedef typename std::unordered_map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { @@ -97,7 +97,7 @@ } }; - template + template struct traits_from > { typedef std::unordered_map unordered_map_type; typedef typename unordered_map_type::const_iterator const_iterator; diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index aa29a7cff..281140445 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -6,27 +6,27 @@ %fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_multimap *unordered_multimap) { - typedef typename std::unordered_multimap::value_type value_type; + assign(const SwigPySeq& swigpyseq, std::unordered_multimap *unordered_multimap) { + typedef typename std::unordered_multimap::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_multimap->insert(value_type(it->first, it->second)); } } - template - struct traits_reserve > { - static void reserve(std::unordered_multimap &seq, typename std::unordered_multimap::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_multimap &seq, typename std::unordered_multimap::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - typedef std::unordered_multimap unordered_multimap_type; - static int asptr(PyObject *obj, std::unordered_multimap **val) { + template + struct traits_asptr > { + typedef std::unordered_multimap unordered_multimap_type; + static int asptr(PyObject *obj, std::unordered_multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); @@ -34,7 +34,7 @@ /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif - res = traits_asptr_stdseq, std::pair >::asptr(items, val); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_multimap_type *p; swig_type_info *descriptor = swig::type_info(); @@ -45,9 +45,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_multimap unordered_multimap_type; + template + struct traits_from > { + typedef std::unordered_multimap unordered_multimap_type; typedef typename unordered_multimap_type::const_iterator const_iterator; typedef typename unordered_multimap_type::size_type size_type; diff --git a/Lib/ruby/std_unordered_map.i b/Lib/ruby/std_unordered_map.i index c3f60bbba..48c875214 100644 --- a/Lib/ruby/std_unordered_map.i +++ b/Lib/ruby/std_unordered_map.i @@ -6,25 +6,25 @@ %fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_map *map) { - typedef typename std::unordered_map::value_type value_type; + assign(const RubySeq& rubyseq, std::unordered_map *map) { + typedef typename std::unordered_map::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } - template - struct traits_asptr > { - typedef std::unordered_map map_type; + template + struct traits_asptr > { + typedef std::unordered_map map_type; static int asptr(VALUE obj, map_type **val) { int res = SWIG_ERROR; 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::pair >::asptr(items, val); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; swig_type_info *descriptor = swig::type_info(); @@ -35,9 +35,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_map map_type; + template + struct traits_from > { + typedef std::unordered_map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; diff --git a/Lib/ruby/std_unordered_multimap.i b/Lib/ruby/std_unordered_multimap.i index b663c1298..ebc53b597 100644 --- a/Lib/ruby/std_unordered_multimap.i +++ b/Lib/ruby/std_unordered_multimap.i @@ -6,25 +6,25 @@ %fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_multimap *multimap) { - typedef typename std::unordered_multimap::value_type value_type; + assign(const RubySeq& rubyseq, std::unordered_multimap *multimap) { + typedef typename std::unordered_multimap::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } - template - struct traits_asptr > { - typedef std::unordered_multimap multimap_type; - static int asptr(VALUE obj, std::unordered_multimap **val) { + template + struct traits_asptr > { + typedef std::unordered_multimap multimap_type; + static int asptr(VALUE obj, std::unordered_multimap **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_HASH ) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); - return traits_asptr_stdseq, std::pair >::asptr(items, val); + return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); @@ -34,9 +34,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_multimap multimap_type; + template + struct traits_from > { + typedef std::unordered_multimap multimap_type; typedef typename multimap_type::const_iterator const_iterator; typedef typename multimap_type::size_type size_type;