summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-02-11 15:51:26 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-02-11 15:51:26 +0000
commit6a36ce77fff65076707126fc6803b3b010bed2f7 (patch)
tree19266ceb2b4d1aba15082e1f207fe5fecd430d6a /src
parentd124fa9a124327d8142b9a5c005e6067d93c3e7e (diff)
the class PgfConcr from the Python binding now has a property name which returns the name of the concrete syntax
Diffstat (limited to 'src')
-rw-r--r--src/runtime/c/pgf/pgf.c6
-rw-r--r--src/runtime/c/pgf/pgf.h3
-rw-r--r--src/runtime/python/pypgf.c16
3 files changed, 24 insertions, 1 deletions
diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c
index 898d3be05..f0da5bddf 100644
--- a/src/runtime/c/pgf/pgf.c
+++ b/src/runtime/c/pgf/pgf.c
@@ -109,6 +109,12 @@ pgf_get_language(PgfPGF* pgf, PgfCId lang)
return gu_map_get(pgf->concretes, &lang, PgfConcr*);
}
+GuString
+pgf_concrete_name(PgfConcr* concr)
+{
+ return concr->name;
+}
+
void
pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err)
{
diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h
index 032834d77..ef68e651f 100644
--- a/src/runtime/c/pgf/pgf.h
+++ b/src/runtime/c/pgf/pgf.h
@@ -91,6 +91,9 @@ pgf_iter_languages(PgfPGF*, GuMapItor*, GuExn* err);
PgfConcr*
pgf_get_language(PgfPGF*, PgfCId lang);
+GuString
+pgf_concrete_name(PgfConcr*);
+
void
pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err);
diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c
index 4b2ab5891..95d92fbce 100644
--- a/src/runtime/python/pypgf.c
+++ b/src/runtime/python/pypgf.c
@@ -731,6 +731,20 @@ Concr_linearize(ConcrObject* self, PyObject *args)
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[] = {
{"printName", (PyCFunction)Concr_printName, METH_VARARGS,
"Returns the print name of a function or category"
@@ -775,7 +789,7 @@ static PyTypeObject pgf_ConcrType = {
0, /*tp_iternext */
Concr_methods, /*tp_methods */
0, /*tp_members */
- 0, /*tp_getset */
+ Concr_getseters, /*tp_getset */
0, /*tp_base */
0, /*tp_dict */
0, /*tp_descr_get */