« Return to Thread: Recognizing the same objects

Re: Recognizing the same objects

by Bugzilla from w.richert@gmx.net :: Rate this Message:

Reply to Author | View in Thread

Hi,

Basically it is possible if your wrappable function uses a PyObject* instead
of Foo* in the signature. Swig then does not perform any "intelligent"
conversion. Inside the function you can, of course, then extract the Foo
object. But this has to be done in your wrappable function, not in your swig
file.

You can then even check the objects in Python via "is" for euality.

Regards,
wr

On Friday 16 May 2008 01:16:25 Daniel K. O. wrote:

> Hello everybody.
>
> Is it possible to make SWIG recognize that 2 objects are actually the
> same [wrapped object]? Like:
>
> void setFoo(Foo *f);
> Foo* getFoo();
>
> So in the wrapped code (e.g. python):
>
> x = Foo()
> x.name = "some data" # data appended in the python's side
> setFoo(x)
>
> a = getFoo()
> b = getFoo()
>
> print a.name
> print b.name
>
> And I would like the print output to be "some data".
> Assuming I can add data members to Foo itself (in the original C++
> class), would it be possible?
>
> Otherwise I might need to redesign the API (any suggestion?) or stick
> with python+pyrex.
>
>
> Regards



-------------------------------------------------------------------------
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
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: Recognizing the same objects