add 'iterator'(sequences) and 'key_iterator'(maps). The first returns allways the C++ iterator. In sequences __iter__ returns 'iterator()', in maps, __iter__ returns 'key_iterator()'
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7775 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9b9aee8eca
commit
a3424e36e1
3 changed files with 30 additions and 23 deletions
|
|
@ -140,8 +140,7 @@
|
|||
return self->find(key) != self->end();
|
||||
}
|
||||
|
||||
#if !defined(SWIG_EXPORT_ITERATOR_METHODS) || defined(SWIG_USE_OLD_MAP_ITERATOR)
|
||||
PyObject* __iter__() {
|
||||
PyObject* key_iterator() {
|
||||
Map::size_type size = self->size();
|
||||
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||
if (pysize < 0) {
|
||||
|
|
@ -162,6 +161,11 @@
|
|||
return keyTuple;
|
||||
%#endif
|
||||
}
|
||||
#if !defined(SWIG_USE_STD_MAP_ITERATOR)
|
||||
%pythoncode {
|
||||
def __iter__(self):
|
||||
return self.key_iterator()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
%enddef
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue