Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Unified Diff: swig/Lib/python/std_multimap.i

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « swig/Lib/python/std_map.i ('k') | swig/Lib/python/std_multiset.i » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: swig/Lib/python/std_multimap.i
===================================================================
--- swig/Lib/python/std_multimap.i (revision 0)
+++ swig/Lib/python/std_multimap.i (revision 0)
@@ -0,0 +1,79 @@
+/*
+ Multimaps
+*/
+%include <std_map.i>
+
+%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
+{
+ namespace swig {
+ template <class SwigPySeq, class K, class T >
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::multimap<K,T > *multimap) {
+ typedef typename std::multimap<K,T>::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ multimap->insert(value_type(it->first, it->second));
+ }
+ }
+
+ template <class K, class T>
+ struct traits_asptr<std::multimap<K,T> > {
+ typedef std::multimap<K,T> multimap_type;
+ static int asptr(PyObject *obj, std::multimap<K,T> **val) {
+ int res = SWIG_ERROR;
+ if (PyDict_Check(obj)) {
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
+ return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
+ } else {
+ multimap_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = p;
+ }
+ return res;
+ }
+ };
+
+ template <class K, class T >
+ struct traits_from<std::multimap<K,T> > {
+ typedef std::multimap<K,T> 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<multimap_type>();
+ 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::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject 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 <std/std_multimap.i>
+
« no previous file with comments | « swig/Lib/python/std_map.i ('k') | swig/Lib/python/std_multiset.i » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698