diff options
Diffstat (limited to 'src/runtime/python')
| -rw-r--r-- | src/runtime/python/pypgf.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c index 98ca25e3a..997f3d3f7 100644 --- a/src/runtime/python/pypgf.c +++ b/src/runtime/python/pypgf.c @@ -36,6 +36,12 @@ gu2py_string(GuString s) { } typedef struct { + PyObject_HEAD + GuPool* pool; + PgfPGF* pgf; +} PGFObject; + +typedef struct { PyObject_HEAD PyObject* master; GuPool* pool; @@ -411,6 +417,7 @@ Expr_getattro(ExprObject *self, PyObject *attr_name) { typedef struct { PyObject_HEAD + PGFObject* grammar; GuPool* pool; int max_count; int counter; @@ -422,6 +429,7 @@ ExprIter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { ExprIterObject* self = (ExprIterObject *)type->tp_alloc(type, 0); if (self != NULL) { + self->grammar = NULL; self->pool = NULL; self->max_count = -1; self->counter = 0; @@ -437,6 +445,8 @@ ExprIter_dealloc(ExprIterObject* self) if (self->pool != NULL) gu_pool_free(self->pool); + Py_XDECREF(self->grammar); + self->ob_type->tp_free((PyObject*)self); } @@ -527,12 +537,6 @@ static PyTypeObject pgf_ExprIterType = { typedef struct { PyObject_HEAD - GuPool* pool; - PgfPGF* pgf; -} PGFObject; - -typedef struct { - PyObject_HEAD PGFObject* grammar; PgfConcr* concr; } ConcrObject; @@ -596,6 +600,9 @@ Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds) return NULL; } + pyres->grammar = self->grammar; + Py_XINCREF(pyres->grammar); + pyres->pool = gu_new_pool(); pyres->max_count = max_count; pyres->counter = 0; @@ -1040,6 +1047,9 @@ PGF_generate(PGFObject* self, PyObject *args, PyObject *keywds) return NULL; } + pyres->grammar = self; + Py_INCREF(self); + pyres->pool = gu_new_pool(); pyres->max_count = max_count; pyres->counter = 0; |
