1
0
forked from GitHub/gf-core

the class PgfConcr from the Python binding now has a property name which returns the name of the concrete syntax

This commit is contained in:
kr.angelov
2013-02-11 15:51:26 +00:00
parent d124fa9a12
commit 6a36ce77ff
3 changed files with 24 additions and 1 deletions

View File

@@ -109,6 +109,12 @@ pgf_get_language(PgfPGF* pgf, PgfCId lang)
return gu_map_get(pgf->concretes, &lang, PgfConcr*); return gu_map_get(pgf->concretes, &lang, PgfConcr*);
} }
GuString
pgf_concrete_name(PgfConcr* concr)
{
return concr->name;
}
void void
pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err) pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err)
{ {

View File

@@ -91,6 +91,9 @@ pgf_iter_languages(PgfPGF*, GuMapItor*, GuExn* err);
PgfConcr* PgfConcr*
pgf_get_language(PgfPGF*, PgfCId lang); pgf_get_language(PgfPGF*, PgfCId lang);
GuString
pgf_concrete_name(PgfConcr*);
void void
pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err); pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err);

View File

@@ -731,6 +731,20 @@ Concr_linearize(ConcrObject* self, PyObject *args)
return pystr; return pystr;
} }
static PyObject*
Concr_getName(ConcrObject *self, void *closure)
{
return gu2py_string(pgf_concrete_name(self->concr));
}
static PyGetSetDef Concr_getseters[] = {
{"name",
(getter)Concr_getName, NULL,
"the name of the concrete syntax",
},
{NULL} /* Sentinel */
};
static PyMethodDef Concr_methods[] = { static PyMethodDef Concr_methods[] = {
{"printName", (PyCFunction)Concr_printName, METH_VARARGS, {"printName", (PyCFunction)Concr_printName, METH_VARARGS,
"Returns the print name of a function or category" "Returns the print name of a function or category"
@@ -775,7 +789,7 @@ static PyTypeObject pgf_ConcrType = {
0, /*tp_iternext */ 0, /*tp_iternext */
Concr_methods, /*tp_methods */ Concr_methods, /*tp_methods */
0, /*tp_members */ 0, /*tp_members */
0, /*tp_getset */ Concr_getseters, /*tp_getset */
0, /*tp_base */ 0, /*tp_base */
0, /*tp_dict */ 0, /*tp_dict */
0, /*tp_descr_get */ 0, /*tp_descr_get */