From: Gregory B. <gre...@gm...> - 2008-02-27 22:23:21
|
Hi, I am running SWIG 1.3.29 (I can't upgrade because an apparent bug where my virtual functions in director classes go into infinite recursion loops in 1.3.30+) with Python 2.4.4. I am trying to wrap a class which provides a custom iterator to access price elements. I tried cloning the std_map.i behavior which I found in the examples/library code, but I'm getting the following error: LINUX_GCC_RELEASE/__mylib__.cpp:3528: instantiated from `static swig_type_info* swig::traits_info<Type>::type_info() [with Type = MyPrice]' LINUX_GCC_RELEASE/__mylib__.cpp:3535: instantiated from `swig_type_info* swig::type_info() [with Type = MyPrice]' LINUX_GCC_RELEASE/__mylib__.cpp:3569: instantiated from `static PyObject* swig::traits_from_ptr<Type>::from(Type*, int) [with Type = MyPrice]' LINUX_GCC_RELEASE/__mylib__.cpp:3575: instantiated from `static PyObject* swig::traits_from<Type>::from(const Type&) [with Type = MyPrice]' LINUX_GCC_RELEASE/__mylib__.cpp:3587: instantiated from `PyObject* swig::from(const Type&) [with Type = MyPrice]' LINUX_GCC_RELEASE/__mylib__.cpp:4077: instantiated from `PyObject* swig::from_oper<ValueType>::operator()(const ValueType&) const [with ValueType = const MyPrice]' LINUX_GCC_RELEASE/__mylib__.cpp:4145: instantiated from `PyObject* swig::PySwigIteratorClosed_T<OutIterator, ValueType, FromOper>::value() const [with OutIterator = MyOrderBook::const_iterator, ValueType = const MyPrice, FromOper = swig::from_oper<const MyPrice>]' /tooltree/boost- 1.33.1-sa_2/include/boost-1_33_1/boost/mpl/aux_/has_type.hpp:20: instantiated from here LINUX_GCC_RELEASE/__mylib__.cpp:3518: error: 'struct swig::traits<MyPrice>' has no member named 'type_name' My wrapping code is as follows where the MyOrderBook class has two methods "const_iterator begin()" and "const_iterator end()": %extend MyOrderBook { %newobject iterator(PyObject **PYTHON_SELF); 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() } } Sadly, I can't use a standard library container for wrapping. Does anyone see anything obvious I'm doing wrong or even better, does anyone have any custom iterator example code outside of the std_*.i and pycontainer.swgfiles included in the distribution? Any help would be greatly appreciated. Thanks, Greg |