1919%include " shared/keep_reference.i"
2020
2121
22- // Macros to wrap data iterators
23- %define DATA_ITERATOR_CLASSES (container_type, datum_type)
22+ // Macro to wrap data iterators
23+ %define DATA_ITERATOR (container_type, datum_type)
2424%feature(" python:slot" , " tp_str" , functype=" reprfunc" )
2525 container_type##_iterator::__str__;
2626%feature(" python:slot" , " tp_iter" , functype=" getiterfunc" )
@@ -48,7 +48,6 @@ KEEP_REFERENCE(container_type##_iterator*)
4848 $typemap (out, Exiv2::datum_type*)
4949}
5050%inline %{
51- // Base class implements all methods except dereferencing
5251class container_type ##_iterator {
5352private:
5453 Exiv2::container_type::iterator ptr;
@@ -68,9 +67,7 @@ public:
6867 " container_type changed size during iteration" );
6968 if (ptr == end)
7069 return NULL ;
71- Exiv2::datum_type* result = &(*ptr);
72- ptr++;
73- return result;
70+ return &(*ptr++);
7471 }
7572 Exiv2::container_type::iterator operator *() const { return ptr; }
7673 bool operator ==(const container_type##_iterator &other) const {
@@ -106,10 +103,7 @@ public:
106103 }
107104};
108105%}
109- %enddef // DATA_ITERATOR_CLASSES
110106
111- // Declare typemaps for data iterators.
112- %define DATA_ITERATOR_TYPEMAPS (container_type)
113107%typemap(in) Exiv2::container_type::iterator
114108 (container_type##_iterator *argp=NULL ) %{
115109 {
@@ -153,13 +147,11 @@ public:
153147// Functions to store weak references to iterators (swig >= v4.4)
154148%fragment(" iterator_weakref_funcs" , " header" , fragment=" private_data" ) {
155149static void _process_list (PyObject* list, bool invalidate) {
156- PyObject* ref = NULL ;
157150 PyObject* iterator = NULL ;
158151 for (Py_ssize_t idx = PyList_Size (list); idx > 0 ; idx--) {
159- ref = PyList_GetItem (list, idx - 1 );
160- iterator = PyWeakref_GetObject (ref);
152+ iterator = PyWeakref_GetObject (PyList_GetItem (list, idx-1 ));
161153 if (iterator == Py_None)
162- PyList_SetSlice (list, idx - 1 , idx, NULL );
154+ PyList_SetSlice (list, idx- 1 , idx, NULL );
163155 else if (invalidate)
164156 Py_XDECREF (PyObject_CallMethod (iterator, " _invalidate" , NULL ));
165157 }
@@ -214,7 +206,8 @@ static int store_iterator_weakref(PyObject* py_self, PyObject* iterator) {
214206%newobject Exiv2::container_type::findKey;
215207// Assumes arg1 is the base class parent
216208#if SWIG_VERSION >= 0x040400
217- %typemap(out, fragment=" iterator_weakref_funcs" ) Exiv2::container_type::iterator {
209+ %typemap(out, fragment=" iterator_weakref_funcs" )
210+ Exiv2::container_type::iterator {
218211#else
219212%typemap (out) Exiv2::container_type::iterator {
220213#endif
@@ -231,4 +224,4 @@ static int store_iterator_weakref(PyObject* py_self, PyObject* iterator) {
231224}
232225// Keep a reference to the data being iterated
233226KEEP_REFERENCE (Exiv2::container_type::iterator)
234- %enddef // DATA_ITERATOR_TYPEMAPS
227+ %enddef // DATA_ITERATOR
0 commit comments