mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
a simple refactoring in the Python runtime
This commit is contained in:
@@ -535,7 +535,7 @@ static PyMethodDef Iter_methods[] = {
|
|||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject pgf_ExprIterType = {
|
static PyTypeObject pgf_IterType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyObject_HEAD_INIT(NULL)
|
||||||
0, /*ob_size*/
|
0, /*ob_size*/
|
||||||
"pgf.Iter", /*tp_name*/
|
"pgf.Iter", /*tp_name*/
|
||||||
@@ -701,7 +701,7 @@ Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IterObject* pyres = (IterObject*)
|
IterObject* pyres = (IterObject*)
|
||||||
pgf_ExprIterType.tp_alloc(&pgf_ExprIterType, 0);
|
pgf_IterType.tp_alloc(&pgf_IterType, 0);
|
||||||
if (pyres == NULL) {
|
if (pyres == NULL) {
|
||||||
Py_XDECREF(py_lexer);
|
Py_XDECREF(py_lexer);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -794,7 +794,7 @@ Concr_getCompletions(ConcrObject* self, PyObject *args, PyObject *keywds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IterObject* pyres = (IterObject*)
|
IterObject* pyres = (IterObject*)
|
||||||
pgf_ExprIterType.tp_alloc(&pgf_ExprIterType, 0);
|
pgf_IterType.tp_alloc(&pgf_IterType, 0);
|
||||||
if (pyres == NULL) {
|
if (pyres == NULL) {
|
||||||
Py_XDECREF(py_lexer);
|
Py_XDECREF(py_lexer);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1265,18 +1265,6 @@ static PyTypeObject pgf_ConcrType = {
|
|||||||
(newfunc)Concr_new, /*tp_new */
|
(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
|
static void
|
||||||
PGF_dealloc(PGFObject* self)
|
PGF_dealloc(PGFObject* self)
|
||||||
{
|
{
|
||||||
@@ -1285,12 +1273,6 @@ PGF_dealloc(PGFObject* self)
|
|||||||
self->ob_type->tp_free((PyObject*)self);
|
self->ob_type->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
PGF_init(PGFObject *self, PyObject *args, PyObject *kwds)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
PGF_getAbstractName(PGFObject *self, void *closure)
|
PGF_getAbstractName(PGFObject *self, void *closure)
|
||||||
{
|
{
|
||||||
@@ -1513,7 +1495,7 @@ PGF_generate(PGFObject* self, PyObject *args, PyObject *keywds)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
IterObject* pyres = (IterObject*)
|
IterObject* pyres = (IterObject*)
|
||||||
pgf_ExprIterType.tp_alloc(&pgf_ExprIterType, 0);
|
pgf_IterType.tp_alloc(&pgf_IterType, 0);
|
||||||
if (pyres == NULL) {
|
if (pyres == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1617,9 +1599,9 @@ static PyTypeObject pgf_PGFType = {
|
|||||||
0, /*tp_descr_get */
|
0, /*tp_descr_get */
|
||||||
0, /*tp_descr_set */
|
0, /*tp_descr_set */
|
||||||
0, /*tp_dictoffset */
|
0, /*tp_dictoffset */
|
||||||
(initproc)PGF_init, /*tp_init */
|
0, /*tp_init */
|
||||||
0, /*tp_alloc */
|
0, /*tp_alloc */
|
||||||
(newfunc)PGF_new, /*tp_new */
|
0, /*tp_new */
|
||||||
};
|
};
|
||||||
|
|
||||||
static PGFObject*
|
static PGFObject*
|
||||||
@@ -1710,7 +1692,7 @@ initpgf(void)
|
|||||||
if (PyType_Ready(&pgf_ExprType) < 0)
|
if (PyType_Ready(&pgf_ExprType) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PyType_Ready(&pgf_ExprIterType) < 0)
|
if (PyType_Ready(&pgf_IterType) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m = Py_InitModule("pgf", module_methods);
|
m = Py_InitModule("pgf", module_methods);
|
||||||
@@ -1732,6 +1714,6 @@ initpgf(void)
|
|||||||
|
|
||||||
Py_INCREF(&pgf_PGFType);
|
Py_INCREF(&pgf_PGFType);
|
||||||
Py_INCREF(&pgf_ConcrType);
|
Py_INCREF(&pgf_ConcrType);
|
||||||
Py_INCREF(&pgf_ExprIterType);
|
Py_INCREF(&pgf_IterType);
|
||||||
Py_INCREF(&pgf_BracketType);
|
Py_INCREF(&pgf_BracketType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user