D
Dmitry Belous
Hi, All
I use C++ to create new types(inherited from PyTypeObject)
and objects(inherited from PyObject) and virtual
destructor to destroy objects. sizeof() is different
for different objects and therefore i don't know what i must do
with tp_basicsize.
Will the following source code work?
Must i set tp_basicsize to right size? (Can I use zero
for tp_basicsize?)
static void do_instance_dealloc(PyObject* obj) {
if(obj->ob_type == &mytype_base)
delete static_cast<myobject_base*>(obj);
}
PyTypeObject mytype_base = {
....
0, /*tp_basicsize*/ /*i don't know size of object*/
....
&do_instance_dealloc, /*tp_dealloc*/
....
};
class myobject_base : public PyObject {
public:
myobject_base() : ob_type(mytype_base) {}
virtual ~myobject_base() {}
};
class myobject_specific : public myobject_base {
public:
std::string name;
myobject_specific() : myobject_base() {}
};
I use C++ to create new types(inherited from PyTypeObject)
and objects(inherited from PyObject) and virtual
destructor to destroy objects. sizeof() is different
for different objects and therefore i don't know what i must do
with tp_basicsize.
Will the following source code work?
Must i set tp_basicsize to right size? (Can I use zero
for tp_basicsize?)
static void do_instance_dealloc(PyObject* obj) {
if(obj->ob_type == &mytype_base)
delete static_cast<myobject_base*>(obj);
}
PyTypeObject mytype_base = {
....
0, /*tp_basicsize*/ /*i don't know size of object*/
....
&do_instance_dealloc, /*tp_dealloc*/
....
};
class myobject_base : public PyObject {
public:
myobject_base() : ob_type(mytype_base) {}
virtual ~myobject_base() {}
};
class myobject_specific : public myobject_base {
public:
std::string name;
myobject_specific() : myobject_base() {}
};