From 5ad233e0ef06c7ba08014d5d1ea98112656fa4d9 Mon Sep 17 00:00:00 2001 From: "jordi.saludes" Date: Thu, 22 Jul 2010 15:13:00 +0000 Subject: [PATCH] Code cleaning in py-bindings. --- contrib/py-bindings/gfmodule.c | 35 +++++----------------------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/contrib/py-bindings/gfmodule.c b/contrib/py-bindings/gfmodule.c index 7da294560..8c04de5d2 100644 --- a/contrib/py-bindings/gfmodule.c +++ b/contrib/py-bindings/gfmodule.c @@ -27,8 +27,8 @@ NEWGF(PGF,GF_PGF,PGFType,"gf.pgf","PGF module") NEWGF(Expr,GF_Expr,ExprType,"gf.expr","gf expression") NEWGF(Tree,GF_Tree,TreeType,"gf.tree","gf tree") -/* CId methods, constructor and destructor */ +/* CId methods, constructor and destructor */ DEALLOCFN(CId_dealloc, CId, gf_freeCId, "freeCId") @@ -45,10 +45,8 @@ CId_repr(CId *self) /* PGF methods, constructor and destructor */ - DEALLOCFN(PGF_dealloc, PGF, gf_freePGF, "freePGF") - static PyObject* pgf_repr(PGF *self) { Lang lang; @@ -58,10 +56,8 @@ pgf_repr(PGF *self) { return PyString_FromFormat("", abs, self->obj); } - - static gfType* -startCategory(PyObject *self, PyObject *noarg) +startCategory(PGF *self, PyObject *noarg) { gfType *cat; if (!checkType(self, &PGFType)) return NULL; @@ -73,15 +69,6 @@ startCategory(PyObject *self, PyObject *noarg) inline static PyObject* categories(PGF* self) { - /* PyObject* cats = PyList_New(0); - GF_CId *p = gf_categories(self); - while (*p) { - CId* c = (CId*)CIdType.tp_new(&CIdType,NULL,NULL); - c->obj = *(p++); - PyList_Append(cats, (PyObject*)c); - Py_DECREF(c); //? - } - return cats; */ return gf_categories(self); } @@ -132,7 +119,6 @@ abstractName(PGF *self) return abs_name; } - static PyObject* printName(PGF *self, PyObject *args) { @@ -150,7 +136,7 @@ printName(PGF *self, PyObject *args) static PyObject* -parse(PyObject *self, PyObject *args, PyObject *kws) +parse(PGF *self, PyObject *args, PyObject *kws) { PyObject *lang, *cat = NULL; //GF_PGF pgf; @@ -295,18 +281,7 @@ PyModule_AddObject(m, "gf", (PyObject *)&t); } -/* inline Lang* newLang() { - return (Lang*)LangType.tp_new(&LangType,NULL,NULL); - } - -inline Tree* newTree() { - return (Tree*)TreeType.tp_new(&TreeType,NULL,NULL); -} - -inline CId* newCId() { - return (CId*)CIdType.tp_new(&CIdType,NULL,NULL); -} -*/ +/* List utilities to be imported by FFI */ inline PyObject* newList() { return PyList_New(0); } -inline void append(PyObject* l, PyObject* ob) { PyList_Append(l, ob); } +inline void append(PyObject* l, PyObject* ob) { PyList_Append(l, ob); }