From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- devtools/swigwin-1.3.34/Lib/python/std_multimap.i | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 devtools/swigwin-1.3.34/Lib/python/std_multimap.i (limited to 'devtools/swigwin-1.3.34/Lib/python/std_multimap.i') diff --git a/devtools/swigwin-1.3.34/Lib/python/std_multimap.i b/devtools/swigwin-1.3.34/Lib/python/std_multimap.i new file mode 100644 index 0000000..f923af0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_multimap.i @@ -0,0 +1,79 @@ +/* + Multimaps +*/ +%include + +%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template + inline void + assign(const PySeq& pyseq, std::multimap *multimap) { + typedef typename std::multimap::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { + multimap->insert(value_type(it->first, it->second)); + } + } + + template + struct traits_asptr > { + typedef std::multimap multimap_type; + static int asptr(PyObject *obj, std::multimap **val) { + int res = SWIG_ERROR; + if (PyDict_Check(obj)) { + PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); + return traits_asptr_stdseq, std::pair >::asptr(items, val); + } else { + multimap_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template + struct traits_from > { + typedef std::multimap multimap_type; + typedef typename multimap_type::const_iterator const_iterator; + typedef typename multimap_type::size_type size_type; + + static PyObject *from(const multimap_type& multimap) { + swig_type_info *desc = swig::type_info(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); + } else { + size_type size = multimap.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "multimap size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { + swig::PyObject_var key = swig::from(i->first); + swig::PyObject_var val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + return obj; + } + } + }; + } +} + +%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 + -- cgit v1.2.3