summaryrefslogtreecommitdiff
path: root/swig/ResPool.i
diff options
context:
space:
mode:
authorMichael Andres <ma@suse.de>2007-12-03 17:49:13 +0000
committerMichael Andres <ma@suse.de>2007-12-03 17:49:13 +0000
commit1d4478e7c0ac28ed7a8b988f426a601312b6cc79 (patch)
treee8103fbf2c58e986977371282451a41fb3654287 /swig/ResPool.i
parentb3b1664484f6c5762ad36fa6b3921f3ae9da76b6 (diff)
downloadlibzypp-bindings-1d4478e7c0ac28ed7a8b988f426a601312b6cc79.tar.gz
libzypp-bindings-1d4478e7c0ac28ed7a8b988f426a601312b6cc79.tar.bz2
libzypp-bindings-1d4478e7c0ac28ed7a8b988f426a601312b6cc79.zip
Added python iterator for ResPool
Diffstat (limited to 'swig/ResPool.i')
-rw-r--r--swig/ResPool.i23
1 files changed, 22 insertions, 1 deletions
diff --git a/swig/ResPool.i b/swig/ResPool.i
index 19c5782..a49480a 100644
--- a/swig/ResPool.i
+++ b/swig/ResPool.i
@@ -1,3 +1,9 @@
+#ifdef SWIGPERL5
+#else
+%template(PoolItemSet) std::set<PoolItem_Ref>;
+%apply std::set<PoolItem_Ref>::const_iterator { ResPool::const_iterator };
+%apply unsigned { ResPool::size_type };
+#endif
class ResPool
{
@@ -27,7 +33,7 @@ class ResPool
/** \name Iterate through all ResObjects (all kinds). */
//@{
- #ifdef SWIGPERL5
+ #ifdef SWIGPERL5
const_iterator begin() const;
const_iterator end() const;
#endif
@@ -194,3 +200,18 @@ iter3(ResPool, PoolItem_Ref*);
}
#endif
+
+#ifdef SWIGPYTHON
+%newobject ResPool::const_iterator(PyObject **PYTHON_SELF);
+%extend ResPool {
+ swig::PySwigIterator* iterator(PyObject **PYTHON_SELF)
+ {
+ return swig::make_output_iterator(self->begin(), self->begin(),
+ self->end(), *PYTHON_SELF);
+ }
+%pythoncode {
+ def __iter__(self): return self.iterator()
+}
+}
+
+#endif