|
@@ -46,6 +46,7 @@ Graph_get_uri (GraphObject *self, void *closure)
|
|
{
|
|
{
|
|
PyObject *uri = PyUnicode_FromString (
|
|
PyObject *uri = PyUnicode_FromString (
|
|
LSUP_graph_uri (self->ob_struct)->data);
|
|
LSUP_graph_uri (self->ob_struct)->data);
|
|
|
|
+ if ( UNLIKELY (!uri)) return NULL;
|
|
|
|
|
|
Py_INCREF(uri);
|
|
Py_INCREF(uri);
|
|
return uri;
|
|
return uri;
|
|
@@ -55,22 +56,20 @@ Graph_get_uri (GraphObject *self, void *closure)
|
|
static int
|
|
static int
|
|
Graph_set_uri (GraphObject *self, PyObject *value, void *closure)
|
|
Graph_set_uri (GraphObject *self, PyObject *value, void *closure)
|
|
{
|
|
{
|
|
- if (PyUnicode_READY(value) != 0) return -1;
|
|
|
|
- if (PyUnicode_KIND(value) != PyUnicode_1BYTE_KIND) return -1;
|
|
|
|
|
|
+ if (!PyObject_TypeCheck (value, &TermType)) return -1;
|
|
|
|
|
|
- LSUP_rc rc = LSUP_graph_set_uri (self->ob_struct, PyUnicode_DATA(value));
|
|
|
|
|
|
+ LSUP_rc rc = LSUP_graph_set_uri (
|
|
|
|
+ self->ob_struct, ((TermObject*)value)->ob_struct->data);
|
|
|
|
|
|
return rc == LSUP_OK ? 0 : -1;
|
|
return rc == LSUP_OK ? 0 : -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyGetSetDef Graph_getsetters[] = {
|
|
static PyGetSetDef Graph_getsetters[] = {
|
|
- /* FIXME This is throwing strange errors.
|
|
|
|
{
|
|
{
|
|
"uri", (getter) Graph_get_uri, (setter) Graph_set_uri,
|
|
"uri", (getter) Graph_get_uri, (setter) Graph_set_uri,
|
|
"Graph URI.", NULL
|
|
"Graph URI.", NULL
|
|
},
|
|
},
|
|
- */
|
|
|
|
{NULL}
|
|
{NULL}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -90,7 +89,7 @@ Graph_copy (PyTypeObject *cls, PyObject *src)
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
static PyObject *
|
|
-Graph_richcmp (PyObject *gr1, PyObject *gr2, int op)
|
|
|
|
|
|
+Graph_richcmp (PyObject *self, PyObject *other, int op)
|
|
{
|
|
{
|
|
if (op != Py_EQ && op != Py_NE) Py_RETURN_NOTIMPLEMENTED;
|
|
if (op != Py_EQ && op != Py_NE) Py_RETURN_NOTIMPLEMENTED;
|
|
|
|
|
|
@@ -98,8 +97,8 @@ Graph_richcmp (PyObject *gr1, PyObject *gr2, int op)
|
|
/*
|
|
/*
|
|
PyObject *res = NULL;
|
|
PyObject *res = NULL;
|
|
|
|
|
|
- LSUP_Graph *t1 = ((GraphObject *) gr1)->ob_struct;
|
|
|
|
- LSUP_Graph *t2 = ((GraphObject *) gr2)->ob_struct;
|
|
|
|
|
|
+ LSUP_Graph *t1 = ((GraphObject *) self)->ob_struct;
|
|
|
|
+ LSUP_Graph *t2 = ((GraphObject *) other)->ob_struct;
|
|
|
|
|
|
if (LSUP_graph_equals (t1, t2) && op == Py_EQ) Py_RETURN_TRUE;
|
|
if (LSUP_graph_equals (t1, t2) && op == Py_EQ) Py_RETURN_TRUE;
|
|
Py_RETURN_FALSE;
|
|
Py_RETURN_FALSE;
|
|
@@ -194,7 +193,6 @@ static PyObject *Graph_lookup (
|
|
|
|
|
|
|
|
|
|
static PyMethodDef Graph_methods[] = {
|
|
static PyMethodDef Graph_methods[] = {
|
|
- {"uri", (PyCFunction) Graph_get_uri, METH_NOARGS, "Get the graph URI."},
|
|
|
|
{"copy", (PyCFunction) Graph_copy, METH_CLASS, "Copy a graph."},
|
|
{"copy", (PyCFunction) Graph_copy, METH_CLASS, "Copy a graph."},
|
|
{"add", (PyCFunction) Graph_add, METH_O, "Add triples to a graph."},
|
|
{"add", (PyCFunction) Graph_add, METH_O, "Add triples to a graph."},
|
|
{
|
|
{
|
|
@@ -205,6 +203,7 @@ static PyMethodDef Graph_methods[] = {
|
|
"lookup", (PyCFunction) Graph_lookup, METH_VARARGS,
|
|
"lookup", (PyCFunction) Graph_lookup, METH_VARARGS,
|
|
"Look triples in a graph by matching a pattern."
|
|
"Look triples in a graph by matching a pattern."
|
|
},
|
|
},
|
|
|
|
+ {NULL},
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -255,7 +254,7 @@ PyTypeObject GraphType = {
|
|
.tp_dealloc = (destructor) Graph_dealloc,
|
|
.tp_dealloc = (destructor) Graph_dealloc,
|
|
.tp_getset = Graph_getsetters,
|
|
.tp_getset = Graph_getsetters,
|
|
.tp_methods = Graph_methods,
|
|
.tp_methods = Graph_methods,
|
|
- .tp_richcompare = Graph_richcmp,
|
|
|
|
|
|
+ .tp_richcompare = (richcmpfunc) Graph_richcmp,
|
|
.tp_as_number = &Graph_number_methods,
|
|
.tp_as_number = &Graph_number_methods,
|
|
.tp_as_sequence = &Graph_seq_methods,
|
|
.tp_as_sequence = &Graph_seq_methods,
|
|
};
|
|
};
|