Implement PGF_getStartCat in Python bindings

This commit is contained in:
John J. Camilleri
2021-09-06 14:15:28 +02:00
parent a8efc61579
commit d58c744361
2 changed files with 9 additions and 16 deletions

View File

@@ -1875,24 +1875,16 @@ PGF_getCategories(PGFObject *self, void *closure)
return categories;
}
static TypeObject*
static TypeObject *
PGF_getStartCat(PGFObject *self, void *closure)
{
TypeObject* pytype = (TypeObject*) pgf_TypeType.tp_alloc(&pgf_TypeType, 0);
if (pytype == NULL)
return NULL;
// // pytype->pool = gu_new_pool();
// pytype->type = pgf_start_cat(self->pgf, /*pytype->pool,*/ &unmarshaller);
// pytype->master = NULL;
//
// if (pytype->type == NULL) {
PgfType type = pgf_start_cat(self->pgf, &unmarshaller);
if (type == 0) {
PyErr_SetString(PGFError, "The start category cannot be found");
// Py_DECREF(pytype);
return NULL;
// }
//
// return pytype;
}
return (TypeObject *)type;
}
static void

View File

@@ -120,5 +120,6 @@ def test_functionType_wrong(PGF):
assert PGF.functionType("c") != pgf.readType("N -> S -> X")
def test_startCat(PGF):
with pytest.raises(pgf.PGFError):
PGF.startCat()
# with pytest.raises(pgf.PGFError):
# PGF.startCat
assert PGF.startCat == pgf.readType("S")