From: Anton D. <ant...@jh...> - 2008-01-25 21:15:31
|
Thanks, That worked. Based on your answer I did a quick search on the share/ swig directory and found that very often the last parameter is: $owner | %newpointer_flags Is this what I should use? Anton --- Anton Deguet, Research Engineer, ERC-CISST/LCSR, Johns Hopkins University e-mail: ant...@jh..., iChat: ant...@ma... office phone: 410-516-5261, cell phone: 410-790-0456 JHU, LCSR, CSEB 137b, 3400 North Charles Street, Baltimore, MD 21218, USA On Jan 25, 2008, at 3:37 PM, Josh Cherry wrote: > > > On Fri, 25 Jan 2008, Anton Deguet wrote: > >> I need to reproduce something similar to the %newobject for a method >> returning a type (pointer on type ) handled by my own typemap(out) >> myType *. >> >> In my typemap I end up using existing SWIG know types and call: >> %typemap(out) myType * { >> ... >> resultobj = SWIG_NewPointerObj((void*)(result), typeInfo, 0); >> ... >> } >> >> I looked at code generated for functions with %newobject without my >> typemap and the difference is that the last parameter for >> SWIG_NewPointerObj is: >> SWIG_POINTER_OWN | 0. >> >> So I have two questions: >> - Is this the proper way to make sure Python/SWIG will delete the >> object created by the C function when the reference counting will >> reach zero? >> - How can I tell in my typemap is the function currently wrapped has >> been "tagged" with %newobject or not? > > I think the thing to do is use $owner for that parameter, and SWIG > will > substitute the appropriate thing, depending (in part) on %newobject. > > Josh > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user |