mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
Merge branch 'majestic' of github.com:GrammaticalFramework/gf-core into majestic
This commit is contained in:
@@ -1768,9 +1768,15 @@ PGF_repr(PGFObject *self)
|
|||||||
static PyObject*
|
static PyObject*
|
||||||
PGF_getAbstractName(PGFObject *self, void *closure)
|
PGF_getAbstractName(PGFObject *self, void *closure)
|
||||||
{
|
{
|
||||||
PgfText* txt = pgf_abstract_name(self->db, self->revision);
|
PgfExn err;
|
||||||
|
PgfText* txt = pgf_abstract_name(self->db, self->revision, &err);
|
||||||
|
|
||||||
|
if (err.type != PGF_EXN_NONE) {
|
||||||
|
PyErr_SetString(PGFError, err.msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject *name = PyString_FromStringAndSize(txt->text, txt->size);
|
PyObject *name = PyString_FromStringAndSize(txt->text, txt->size);
|
||||||
free(txt);
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1879,11 +1885,17 @@ PGF_getCategories(PGFObject *self, void *closure)
|
|||||||
static TypeObject *
|
static TypeObject *
|
||||||
PGF_getStartCat(PGFObject *self, void *closure)
|
PGF_getStartCat(PGFObject *self, void *closure)
|
||||||
{
|
{
|
||||||
PgfType type = pgf_start_cat(self->db, self->revision, &unmarshaller);
|
PgfExn err;
|
||||||
|
PgfType type = pgf_start_cat(self->db, self->revision, &unmarshaller, &err);
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
PyErr_SetString(PGFError, "start category cannot be found");
|
PyErr_SetString(PGFError, "start category cannot be found");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else if (err.type != PGF_EXN_NONE) {
|
||||||
|
PyErr_SetString(PGFError, err.msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return (TypeObject *)type;
|
return (TypeObject *)type;
|
||||||
}
|
}
|
||||||
@@ -1966,12 +1978,17 @@ PGF_functionType(PGFObject *self, PyObject *args)
|
|||||||
memcpy(funname->text, s, size+1);
|
memcpy(funname->text, s, size+1);
|
||||||
funname->size = size;
|
funname->size = size;
|
||||||
|
|
||||||
PgfType type = pgf_function_type(self->db, self->revision, funname, &unmarshaller);
|
PgfExn err;
|
||||||
|
PgfType type = pgf_function_type(self->db, self->revision, funname, &unmarshaller, &err);
|
||||||
PyMem_Free(funname);
|
PyMem_Free(funname);
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
PyErr_Format(PyExc_KeyError, "function '%s' is not defined", s);
|
PyErr_Format(PyExc_KeyError, "function '%s' is not defined", s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else if (err.type != PGF_EXN_NONE) {
|
||||||
|
PyErr_SetString(PGFError, err.msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return (TypeObject *)type;
|
return (TypeObject *)type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ def test_readType_inequality_1():
|
|||||||
def test_readType_inequality_2():
|
def test_readType_inequality_2():
|
||||||
assert pgf.readType("A -> B") != pgf.readType("B->B")
|
assert pgf.readType("A -> B") != pgf.readType("B->B")
|
||||||
|
|
||||||
def test_Type_str_1():
|
# def test_Type_str_1():
|
||||||
assert str(pgf.readType("A-> B")) == "A -> B"
|
# assert str(pgf.readType("A-> B")) == "A -> B"
|
||||||
|
|
||||||
def test_functionType_1(PGF):
|
def test_functionType_1(PGF):
|
||||||
assert PGF.functionType("z") == pgf.readType("N")
|
assert PGF.functionType("z") == pgf.readType("N")
|
||||||
|
|||||||
Reference in New Issue
Block a user