[C++-sig] XXX undefined error throw by python, Exception caused by get_override? Safe to ignor or cause for concern?
terence tan
terencebbr at gmail.com
Wed May 20 05:15:47 CEST 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090520/bac13736/attachment.htm>
More information about the Cplusplus-sig
mailing list