From: Stefan Z. <sz...@gm...> - 2011-06-23 14:54:17
|
You need to use a %template directive in your swig interface file; something like this: %template(MyObjectMap) std::map<MyObject*, MyObject*>; %template(MyObjectMapVector) std::vector< std::map<MyObject*, MyObject*> >; Take a look at the SWIG docs for more info: http://www.swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_nn30 Stefan On Thu, Jun 23, 2011 at 1:02 AM, Zhenguo Wang <wan...@gm...> wrote: > Hello all, > > We are wrapping C++ into Python via Swig, one of our function is declare as > below: > std::vector<std::map<MyObject*, MyObject*>*>& Search() > > In Python, the function is called correctly, but we can't print out > returned value. > > 1. To print the first element: > *>>> result[0] > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'SwigPyObject' object is unsubscriptable* > > 2. To print the object directly: > *>>> print result > <Swig Object of type 'std::vector< std::map< MyObject *,MyObject > *,std::less< MyObject * >,s > td::allocator< std::pair< MyObject *const,MyObject * > > > > *,std::allocator< std::map< > MyObject *,MyObject *,std::less< MyObject * >,std::allocator< std::pair< > MyObject *const,MyObject * > > > > * > > *' at 0x00BEE298>* > > > In the wrapper code, the returned value been wrappered by > SWIG_NewPointerObj() with the type swig_types[124]. > > > Does anyone have experience on such kind of issue? > > It's appreciative if any suggestion! > > We are using Swig 2.0 and Python 2.5. > > > Thanks in advance! > > Zhenguo Wang > > > ------------------------------------------------------------------------------ > Simplify data backup and recovery for your virtual environment with > vRanger. > Installation's a snap, and flexible recovery options mean your data is > safe, > secure and there when you need it. Data protection magic? > Nope - It's vRanger. Get your free trial download today. > http://p.sf.net/sfu/quest-sfdev2dev > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > > |