diff options
| author | jordi.saludes <jordi.saludes@upc.edu> | 2010-06-13 11:42:48 +0000 |
|---|---|---|
| committer | jordi.saludes <jordi.saludes@upc.edu> | 2010-06-13 11:42:48 +0000 |
| commit | 3e5d4381a079ba077164317f2be2b247128358fc (patch) | |
| tree | b33012718ae5202762c1d6fe7f5b862784ec570f /contrib | |
| parent | cd0e3831879ef266af5676946e251cda211cc826 (diff) | |
Added destuctor for python types.
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/py-bindings/gfmodule.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/py-bindings/gfmodule.c b/contrib/py-bindings/gfmodule.c index 716a68009..9b2717e29 100644 --- a/contrib/py-bindings/gfmodule.c +++ b/contrib/py-bindings/gfmodule.c @@ -80,6 +80,18 @@ checkType(PyObject* obj, PyTypeObject* tp) return isRight; } +#define DEALLOCFN(delname,t,cb,cbname) static void \ +delname(t *self){ cb(self->obj);\ + printf("gf_%s has been called for stable pointer 0x%x\n", cbname, self->obj);\ + self->ob_type->tp_free((PyObject*)self); } + + + +DEALLOCFN(gfType_dealloc, gfType, gf_freeType, "freeType") +DEALLOCFN(PGF_dealloc, PGFModule, gf_freePGF, "freePGF") +DEALLOCFN(Lang_dealloc, Lang, gf_freeLanguage, "freeLanguage") + + static gfType* startCategory(PyObject *self, PyObject *noarg) { @@ -163,8 +175,11 @@ initgf(void) PGFType.tp_repr = (reprfunc)PGF_repr; PGFType.tp_methods = pgf_methods; + PGFType.tp_dealloc = (destructor)PGF_dealloc; READYTYPE(PGFType) + LangType.tp_dealloc = (destructor)Lang_dealloc; READYTYPE(LangType) + gfTypeType.tp_dealloc = (destructor)gfType_dealloc; READYTYPE(gfTypeType) ExprType.tp_repr = (reprfunc)expr_repr; READYTYPE(ExprType) |
