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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swig/Lib/python/std_map.i ('k') | swig/Lib/python/std_multiset.i » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 Multimaps
3 */
4 %include <std_map.i>
5
6 %fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
7 {
8 namespace swig {
9 template <class SwigPySeq, class K, class T >
10 inline void
11 assign(const SwigPySeq& swigpyseq, std::multimap<K,T > *multimap) {
12 typedef typename std::multimap<K,T>::value_type value_type;
13 typename SwigPySeq::const_iterator it = swigpyseq.begin();
14 for (;it != swigpyseq.end(); ++it) {
15 multimap->insert(value_type(it->first, it->second));
16 }
17 }
18
19 template <class K, class T>
20 struct traits_asptr<std::multimap<K,T> > {
21 typedef std::multimap<K,T> multimap_type;
22 static int asptr(PyObject *obj, std::multimap<K,T> **val) {
23 int res = SWIG_ERROR;
24 if (PyDict_Check(obj)) {
25 SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL) ;
26 return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::aspt r(items, val);
27 } else {
28 multimap_type *p;
29 res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(), 0);
30 if (SWIG_IsOK(res) && val) *val = p;
31 }
32 return res;
33 }
34 };
35
36 template <class K, class T >
37 struct traits_from<std::multimap<K,T> > {
38 typedef std::multimap<K,T> multimap_type;
39 typedef typename multimap_type::const_iterator const_iterator;
40 typedef typename multimap_type::size_type size_type;
41
42 static PyObject *from(const multimap_type& multimap) {
43 swig_type_info *desc = swig::type_info<multimap_type>();
44 if (desc && desc->clientdata) {
45 return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POIN TER_OWN);
46 } else {
47 size_type size = multimap.size();
48 int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
49 if (pysize < 0) {
50 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
51 PyErr_SetString(PyExc_OverflowError,
52 "multimap size not valid in python");
53 SWIG_PYTHON_THREAD_END_BLOCK;
54 return NULL;
55 }
56 PyObject *obj = PyDict_New();
57 for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) {
58 swig::SwigVar_PyObject key = swig::from(i->first);
59 swig::SwigVar_PyObject val = swig::from(i->second);
60 PyDict_SetItem(obj, key, val);
61 }
62 return obj;
63 }
64 }
65 };
66 }
67 }
68
69 %define %swig_multimap_methods(Type...)
70 %swig_map_common(Type);
71 %extend {
72 void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_ of_range) {
73 self->insert(Type::value_type(key,x));
74 }
75 }
76 %enddef
77
78 %include <std/std_multimap.i>
79
OLDNEW
« 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