I am implementing a interface between my C++ class and a python class that requires the ability for the python class to have a Initialize/Update method called from C++ but still call the default methods of the original C++ class I am integrating. If no such methods are defined in the python class then the default C++ methods are called. So I approach it by writing a wrapper.
Right now python is throw an exception XXX undefined error saying that the Initialize(or Update method) is undefined. I believe it is the get_override method. Am I approaching this the wrong way? The Initialize and Update function are virtual. struct BaseGameWrap : BaseGame, wrapper<BaseGame> { void Initialize() { if (override Initialize = this->get_override("Initialize")) { BaseGame::Initialize(); #ifdef WIN32 return call<void>(Initialize.ptr()); #else return Initialize(); #endif } // This supresses a XXX undefined error thrown by // by get_override when Initialize is not found. Unless a better way // is found to handle this. PyErr_Clear(); return BaseGame::Initialize(); } }; void exportBaseGame() { class_<BaseGameWrap,boost::noncopyable,bases<Game>>("BaseGame") .def("Run",&BaseGame::Run) .def("GetComponents",&BaseGame::GetComponents,return_value_policy<reference_existing_object>()) .def("Exit",&BaseGame::Exit); ; } Terence
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig