mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-09-28 13:13:37 -06:00
merge
This commit is contained in:
@@ -93,8 +93,8 @@ public:
|
||||
iterator begin() { return iterator(ref<A>::from_ptr(&v()->data[0])); }
|
||||
iterator end() { return iterator(ref<A>::from_ptr(&v()->data[v()->len])); }
|
||||
|
||||
bool operator ==(vector<A>& other) const { return offset==other.as_object(); }
|
||||
bool operator !=(vector<A>& other) const { return offset!=other.as_object(); }
|
||||
bool operator ==(vector<A>& other) const { return offset==other.offset; }
|
||||
bool operator !=(vector<A>& other) const { return offset!=other.offset; }
|
||||
bool operator ==(object other_offset) const { return offset==other_offset; }
|
||||
bool operator !=(object other_offset) const { return offset!=other_offset; }
|
||||
|
||||
|
||||
@@ -355,6 +355,59 @@ PgfLinearizationOutputIfaceVtbl pypgf_lin_out_iface_vtbl =
|
||||
(void*) pypgf_lin_out_flush
|
||||
};
|
||||
|
||||
static PyObject*
|
||||
Concr_tabularLinearize(ConcrObject* self, PyObject *args)
|
||||
{
|
||||
ExprObject* pyexpr;
|
||||
if (!PyArg_ParseTuple(args, "O!", &pgf_ExprType, &pyexpr))
|
||||
return NULL;
|
||||
|
||||
PgfExn err;
|
||||
PgfText **texts =
|
||||
pgf_tabular_linearize(self->grammar->db, self->concr, (PgfExpr) pyexpr, NULL,
|
||||
&marshaller, &err);
|
||||
if (handleError(err) != PGF_EXN_NONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (texts == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject *res = PyList_New(0);
|
||||
if (!res)
|
||||
goto fail;
|
||||
|
||||
while (texts[0] != NULL && texts[1] != NULL) {
|
||||
PyObject* pyfield = PyUnicode_FromStringAndSize(texts[0]->text, texts[0]->size);
|
||||
free(texts[0]); texts++;
|
||||
if (!pyfield)
|
||||
goto fail;
|
||||
|
||||
PyObject* pylin = PyUnicode_FromStringAndSize(texts[0]->text, texts[0]->size);
|
||||
free(texts[0]); texts++;
|
||||
if (!pylin)
|
||||
goto fail;
|
||||
|
||||
PyObject *tup = PyTuple_New(2);
|
||||
PyTuple_SetItem(tup, 0, pyfield);
|
||||
PyTuple_SetItem(tup, 1, pylin);
|
||||
PyList_Append(res, tup);
|
||||
Py_DECREF(tup);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
fail:
|
||||
Py_XDECREF(res);
|
||||
|
||||
while (texts[0]) {
|
||||
free(texts[0]); texts++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
Concr_bracketedLinearize(ConcrObject* self, PyObject *args)
|
||||
{
|
||||
@@ -548,10 +601,10 @@ static PyMethodDef Concr_methods[] = {
|
||||
},
|
||||
/*{"linearizeAll", (PyCFunction)Concr_linearizeAll, METH_VARARGS | METH_KEYWORDS,
|
||||
"Takes an abstract tree and linearizes with all variants"
|
||||
},
|
||||
},*/
|
||||
{"tabularLinearize", (PyCFunction)Concr_tabularLinearize, METH_VARARGS,
|
||||
"Takes an abstract tree and linearizes it to a table containing all fields"
|
||||
},*/
|
||||
},
|
||||
{"bracketedLinearize", (PyCFunction)Concr_bracketedLinearize, METH_VARARGS,
|
||||
"Takes an abstract tree and linearizes it to a bracketed string"
|
||||
},
|
||||
@@ -806,8 +859,8 @@ _collect_cats(PgfItor *fn, PgfText *key, object value, PgfExn *err)
|
||||
|
||||
if (PyList_Append((PyObject*) clo->collection, py_name) != 0) {
|
||||
err->type = PGF_EXN_OTHER_ERROR;
|
||||
Py_DECREF(py_name);
|
||||
}
|
||||
Py_DECREF(py_name);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
@@ -892,8 +945,8 @@ _collect_funs(PgfItor *fn, PgfText *key, object value, PgfExn *err)
|
||||
|
||||
if (PyList_Append((PyObject*) clo->collection, py_name) != 0) {
|
||||
err->type = PGF_EXN_OTHER_ERROR;
|
||||
Py_DECREF(py_name);
|
||||
}
|
||||
Py_DECREF(py_name);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
||||
Reference in New Issue
Block a user