Hi guys, I found a problems with my binds when I work with separated modules. In my function where return a c++ pointer to a object, this not return the same python object used in setter function. The main point here is because this works fine when all classes are exported in the same module but when I split the module this stop work.
Module pybase ========================= class Base { private: Base *_child; public: void setChild(Base *parent); Base* child(); virtual ~Base(); }; class BaseWrapper : public Base, public wrapper<Base> { public: typedef class_<BaseWrapper, noncopyable> class_type; }; BOOST_PYTHON_MODULE(pybase) { BaseWrapper::class_type foo("Base"); foo.def("setChild", &Base::setChild); foo.def("child", &Base::child, return_internal_reference<>()); } Module pyother =================================== class Other : public Base { public: virtual ~Other(); }; class OtherWrapper : public Other, public wrapper<Other> { public: typedef class_<OtherWrapper, bases<Base>, noncopyable > class_type; }; BOOST_PYTHON_MODULE(pyother) { OtherWrapper::class_type other("Other"); } Python test ========================================== #create a class exported in module pyother t = Other() #create a class exported in module pybase o = Base() #set base child o.setChild(t) #get object used in previous function c = o.child() #compare both object this need be true print t print c print t == c this happen when I use "Other" object in "setChild" and "child" function. when I use "Base" object works fine. I put a small example annexed in this e-mail. -- BR Renato Araujo Oliveira Filho
boosttest.tar.gz
Description: GNU Zip compressed data
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig