[C++-sig] Re: Making copy of function derived from C++ pure virtual function
Paul F. Kunz
Paul_Kunz at slac.stanford.edu
Fri Dec 10 20:20:06 CET 2004
>>>>> On Fri, 10 Dec 2004 07:38:12 -0800, "Paul F. Kunz" <Paul_Kunz at slac.stanford.edu> said:
>>>>> On Thu, 09 Dec 2004 20:37:18 -0500, David Abrahams <dave at boost-consulting.com> said:
>> Sorry, this should be:
>> class_<FunctionWrap, std::auto_ptr<FunctionWrap> >( "FunctionBase",
>> init<FunctionBase const&>())
> Ok, that compiles. Obvious no that I see it.
> But now at run time I get...
Replying to my own item, I got pass the runtime error by doing the
following instead of the above...
class_ < FunctionBase, std::auto_ptr< FunctionWrap> >
( "FunctionBase" )
with the constructor of the class as ...
FunctionWrap::
FunctionWrap ( PyObject * self )
: FunctionBase (),
m_self ( self )
{
}
`m_self' is data member to hold the PyObject.
Now at runtime I crash in the suggested FunctionWrap::clone()
method when trying to call get_ower(). With gdb I see ...
<boost::python::wrapper<FunctionBase>> = {
<boost::python::detail::wrapper_base> = {
m_self = 0x0
}, <No data fields>},
members of FunctionWrap:
m_self = 0x4060911c,
invert_ownership = {
<boost::python::api::object_base> = {
<boost::python::api::object_operators<boost::python::api::object>> = {
<boost::python::def_visitor<boost::python::api::object>> = {<No data fields>}, <No data fields>},
members of boost::python::api::object_base:
m_ptr = 0x8125d60
}, <No data fields>}
}
(gdb)
Note that the wrapper_base data member `m_self' is a null pointer.
So I guess my FunctionWrap class ...
class FunctionWrap : public FunctionBase,
public boost::python::wrapper < FunctionBase >
{
didn't get initialized properly. Looking at the wrapper.hpp and
detail/wrapper_base.hpp files, I don't see how to initialize it.
Do I really need it? If get_owner had worked, would it have returned
FunctionWrap::m_self?
More information about the Cplusplus-sig
mailing list