abstract classes and caller_owns return =False
Hi,
I have the following problem:
A class method returns a pointer of an other abstract base class. This pointer is afterwards casted into a special subclass.
If I wrap this method with
caller_owns_return = False
Pybindgen creates the following code:
retval = self->obj-
if (!(retval)) {
return Py_None;
}
py_Foo = PyObject_New(PyFoo, &PyFoo_Type);
py_Foo->obj = new Foo(*retval);
py_retval = Py_BuildValue((char *) "N", py_Foo);
return py_retval;
Due to py_Foo->obj = new Foo(*retval); I get the compile error:
error C2259: 'Foo': cannot instantiate abstract class
If I choose caller_owns_return = True the line changes to:
py_Foo->obj = retval;
This compiles and runs.However when the foo object is deleted by python I get a python runtime error since the object is also deleted on c++ side. Changing this on c++ side is not possible.
Is it possible to say caller_owns_return = True and force pybindgen not to delete the object?
Hope I made my point clear.
stefan
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- PyBindGen Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Stefan Stiene
- Solved:
- Last query:
- Last reply: