From b319720cf18014bbe9a262db2e3da1b761360205 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Thu, 4 May 2006 05:48:55 +0000 Subject: [PATCH] fix bug #1480074 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9085 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/std_map.i | 15 ++++++++++----- Lib/python/std_multimap.i | 9 ++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 9e5f50512..b4951f846 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -132,7 +132,7 @@ } } -%define %swig_map_methods(Map...) +%define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map) @@ -145,10 +145,6 @@ throw std::out_of_range("key not found"); } - void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { - self->insert(Map::value_type(key,x)); - } - void __delitem__(const key_type& key) throw (std::out_of_range) { Map::iterator i = self->find(key); if (i != self->end()) @@ -238,5 +234,14 @@ } %enddef +%define %swig_map_methods(Map...) + %swig_map_common(Map) + %extend { + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + (*self)[key] = x; + } + } +%enddef + %include diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index 1b159dc3c..5a6facb58 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -66,7 +66,14 @@ } } -#define %swig_multimap_methods(Type...) %swig_map_methods(Type) +%define %swig_multimap_methods(Type...) + %swig_map_common(Type); + %extend { + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + self->insert(Type::value_type(key,x)); + } + } +%enddef %include