« Return to Thread: Recognizing the same objects

Re: Recognizing the same objects

by nitro-4 :: Rate this Message:

Reply to Author | View in Thread

Am 16.05.2008, 01:16 Uhr, schrieb Daniel K. O. <danielko.listas@...>:

> 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.

I haven't tried this, but maybe you can do

a = getFoo()
b = getFoo()

print 'Same objects: ', (a.this == b.this)

-Matthias

-------------------------------------------------------------------------
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