summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-05-29 11:02:18 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-05-29 11:02:18 +0000
commit739b10f2a82cb91440e6b0d191d915c3341caba1 (patch)
tree13f448a37f776e0a45363d6ff0f54cfea35d355a /src
parent43bffd3f7d11036c7aa966d431ae475d02c86ce4 (diff)
a simple refactoring in the Python runtime
Diffstat (limited to 'src')
-rw-r--r--src/runtime/python/pypgf.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c
index 7fd6c5cdf..73210fdcc 100644
--- a/src/runtime/python/pypgf.c
+++ b/src/runtime/python/pypgf.c
@@ -535,7 +535,7 @@ static PyMethodDef Iter_methods[] = {
{NULL} /* Sentinel */
};
-static PyTypeObject pgf_ExprIterType = {
+static PyTypeObject pgf_IterType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pgf.Iter", /*tp_name*/
@@ -701,7 +701,7 @@ Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds)
}
IterObject* pyres = (IterObject*)
- pgf_ExprIterType.tp_alloc(&pgf_ExprIterType, 0);
+ pgf_IterType.tp_alloc(&pgf_IterType, 0);
if (pyres == NULL) {
Py_XDECREF(py_lexer);
return NULL;
@@ -794,7 +794,7 @@ Concr_getCompletions(ConcrObject* self, PyObject *args, PyObject *keywds)
}
IterObject* pyres = (IterObject*)
- pgf_ExprIterType.tp_alloc(&pgf_ExprIterType, 0);
+ pgf_IterType.tp_alloc(&pgf_IterType, 0);
if (pyres == NULL) {
Py_XDECREF(py_lexer);
return NULL;
@@ -1265,18 +1265,6 @@ static PyTypeObject pgf_ConcrType = {
(newfunc)Concr_new, /*tp_new */
};
-static PGFObject*
-PGF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- PGFObject* self = (PGFObject *)type->tp_alloc(type, 0);
- if (self != NULL) {
- self->pool = NULL;
- self->pgf = NULL;
- }
-
- return self;
-}
-
static void
PGF_dealloc(PGFObject* self)
{
@@ -1285,12 +1273,6 @@ PGF_dealloc(PGFObject* self)
self->ob_type->tp_free((PyObject*)self);
}
-static int
-PGF_init(PGFObject *self, PyObject *args, PyObject *kwds)
-{
- return -1;
-}
-
static PyObject*
PGF_getAbstractName(PGFObject *self, void *closure)
{
@@ -1513,7 +1495,7 @@ PGF_generate(PGFObject* self, PyObject *args, PyObject *keywds)
return NULL;
IterObject* pyres = (IterObject*)
- pgf_ExprIterType.tp_alloc(&pgf_ExprIterType, 0);
+ pgf_IterType.tp_alloc(&pgf_IterType, 0);
if (pyres == NULL) {
return NULL;
}
@@ -1617,9 +1599,9 @@ static PyTypeObject pgf_PGFType = {
0, /*tp_descr_get */
0, /*tp_descr_set */
0, /*tp_dictoffset */
- (initproc)PGF_init, /*tp_init */
+ 0, /*tp_init */
0, /*tp_alloc */
- (newfunc)PGF_new, /*tp_new */
+ 0, /*tp_new */
};
static PGFObject*
@@ -1710,7 +1692,7 @@ initpgf(void)
if (PyType_Ready(&pgf_ExprType) < 0)
return;
- if (PyType_Ready(&pgf_ExprIterType) < 0)
+ if (PyType_Ready(&pgf_IterType) < 0)
return;
m = Py_InitModule("pgf", module_methods);
@@ -1732,6 +1714,6 @@ initpgf(void)
Py_INCREF(&pgf_PGFType);
Py_INCREF(&pgf_ConcrType);
- Py_INCREF(&pgf_ExprIterType);
+ Py_INCREF(&pgf_IterType);
Py_INCREF(&pgf_BracketType);
}