On Fri, Apr 29, 2011 at 10:14 AM, zeb <zeb...@gmail.com> wrote: > Hi, I'm trying to export the following code to python, but failed. Please > help me! > Here is the code: > -------------- > c++ code: > -------------- > class IWorker { > public: > virtual int getData() = 0; > }; > > class Worker : public IWorker { > public: > int getData() { > return 100; > } > }; > > extern "C" { > IWorker* createWorker(); > } > > -------------- > py++ code: > -------------- > mb.free_fun('createWorker').call_policies = > call_policies.return_value_policy(call_policies.return_pointee_value)
If createWorker is implemented as "return new Worker(....);", then you should use "return_value_policy<manage_new_object>" ( http://www.boost.org/doc/libs/1_46_1/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies ) If you change the function return type to "std::auto_ptr<...>" then you don't need to specify the call policies. HTH _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig