summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjordi.saludes <jordi.saludes@upc.edu>2010-06-18 15:34:08 +0000
committerjordi.saludes <jordi.saludes@upc.edu>2010-06-18 15:34:08 +0000
commit9e2c360ffbb8db360d44f9997a8d2858b8c1ad30 (patch)
tree95483f0fa74af8ccfd923630a5e7059d6fe43625
parent7bee8ce0c7e79ef82387d2a375e172de867dcd1c (diff)
Added 'languageCode' to py-bindings.
-rw-r--r--contrib/py-bindings/gfmodule.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/py-bindings/gfmodule.c b/contrib/py-bindings/gfmodule.c
index 34375a85d..5e0406182 100644
--- a/contrib/py-bindings/gfmodule.c
+++ b/contrib/py-bindings/gfmodule.c
@@ -146,6 +146,23 @@ languages(PGFModule* self)
}
static PyObject*
+languageCode(PGFModule *self, PyObject *args)
+{
+ Lang *lang;
+ if (!PyArg_ParseTuple(args, "O", &lang))
+ return NULL;
+ char* scode = gf_languageCode(self->obj, lang->obj);
+ if (scode) {
+ PyObject* result = PyString_FromString(scode);
+ free(scode);
+ return result;
+ } else {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+}
+
+static PyObject*
linearize(PGFModule *self, PyObject *args)
{
Lang *lang;
@@ -226,6 +243,7 @@ readPGF(PyObject *self, PyObject *args)
static PyMethodDef pgf_methods[] = {
{"parse", (PyCFunction)parse, METH_VARARGS|METH_KEYWORDS,"Parse a string."},
{"lin", (PyCFunction)linearize, METH_VARARGS,"Linearize tree."},
+ {"lang_code", (PyCFunction)languageCode, METH_VARARGS,"Get the language code."},
{"startcat", (PyCFunction)startCategory, METH_NOARGS,"Get the start category."},
{"categories", (PyCFunction)categories, METH_NOARGS,"Get all categories."},
{"abstract", (PyCFunction)abstractName, METH_NOARGS,"Get the module abstract name."},