From: Daniel K. O. <dan...@gm...> - 2008-05-16 01:09:52
|
2008/5/15 Dustin J. Mitchell <du...@zm...>: > I had similar difficulties with Perl bindings. > > The basic answer is, "no." SWIG's bindings will create a new Python > object every time they are handed a pointer from the C/C++ layer. > > You can work around this by writing typemaps that will keep some kind > of (weak-ref) dictionary of extant wrapped objects, and look up any > new pointer values in that dictionary. SWIG doesn't implement this > itself as it's really fairly domain-specific. I was hoping for something along these lines: struct Foo { void *data; ... }; And make the [SWIG] Foo constructor store a pointer to the SWIG object in the [C++] Foo object. So the getFoo() function would be overwritten as: SwigFoo* getFooSwig() { Foo *f = getFoo(); swigobj = f->data; return swigobj; } Could this be done with the help of typemaps? -- Daniel K. O. "The only way to succeed is to build success yourself" |