Make destructors of all generated Py class protected
This is to avoid to create an object on the stack and thus to clutter Python's reference counting mechanism
This commit is contained in:
@@ -203,10 +203,12 @@ std::string AreaPy::representation(void) const
|
||||
|
||||
PyObject *AreaPy::PyMake(struct _typeobject *, PyObject *args, PyObject *kwd) // Python wrapper
|
||||
{
|
||||
std::unique_ptr<AreaPy> ret(new AreaPy(new Area));
|
||||
if(!ret->setParams(args,kwd))
|
||||
AreaPy* ret = new AreaPy(new Area);
|
||||
if(!ret->setParams(args,kwd)) {
|
||||
Py_DecRef(ret);
|
||||
return 0;
|
||||
return ret.release();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// constructor method
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace @self.export.Namespace@
|
||||
*/
|
||||
class @self.export.Namespace@Export @self.export.Name@ : public @self.export.FatherNamespace@::@self.export.Father@
|
||||
{
|
||||
protected:
|
||||
~@self.export.Name@();
|
||||
|
||||
public:
|
||||
static PyTypeObject Type;
|
||||
static PyMethodDef Methods[];
|
||||
@@ -76,8 +79,7 @@ public:
|
||||
@self.export.Name@(@self.export.TwinPointer@ *pcObject, PyTypeObject *T = &Type);
|
||||
static PyObject *PyMake(struct _typeobject *, PyObject *, PyObject *);
|
||||
virtual int PyInit(PyObject* args, PyObject*k);
|
||||
~@self.export.Name@();
|
||||
|
||||
|
||||
+ if (self.export.Initialization):
|
||||
int initialization();
|
||||
int finalization();
|
||||
|
||||
Reference in New Issue
Block a user