For the benefit of other readers, Renato told me that Shiboken uses a hash map on the C++ pointer to find the wrapper associated with an object and always return the same object back into Python.
In answer to my Boost question, Hugo pointed me to the PySide code from before the switch to Shiboken. My reading of that code is as follows: http://qt.gitorious.org/pyside/pyside-boost/blobs/master/base/parent_policy.hppis the file relevant to that question. It defines a new return policy "return_ptr_object" that returns the same object at each call. Nathan On Sat, Sep 17, 2011 at 7:18 PM, Nathan Smith <nathanjsm...@gmail.com>wrote: > I've been exploring C++/Python binding layers. The two that interest me > the most are Boost.Python and Shiboken. Looking at PySide and also > libsample/samplebinding that ships with Shiboken, I've seen that the > following behaves as one would expect: > > a = ObjectType() > b = ObjectType() > b.setParent(a) > assert(a is b.parent()) > > I've tried something similar in Boost.Python, but I cannot get the > assertion to pass. It seems that Boost.Python will generate a new python > wrapper each time you call b.parent(), so the ID of the returned object > changes at each call (even though it is the same C++ object being returned). > > How does Shiboken ensure the same Python object is returned at each call to > parent()? Since PySide started out in Boost.Python, was that able to > support this behavior using Boost, or was that part of the motivation in > creating a new binding generator? > > Thanks! > > Nathan >
_______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside