Kaydet (Commit) bca26dfb authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz Kaydeden (comit) GitHub

make changes

üst 6072075d
...@@ -40,6 +40,7 @@ typedef struct { ...@@ -40,6 +40,7 @@ typedef struct {
char *tagname; char *tagname;
} Iter; } Iter;
/*** Document ***/
static void static void
Document_dealloc(Document *self) Document_dealloc(Document *self)
{ {
...@@ -88,6 +89,8 @@ static PyTypeObject Document_type = { ...@@ -88,6 +89,8 @@ static PyTypeObject Document_type = {
0 /* tp_new */ 0 /* tp_new */
}; };
/*** Iterator ***/
static PyObject * static PyObject *
Iter_iter(Iter *self) Iter_iter(Iter *self)
{ {
...@@ -158,6 +161,29 @@ static PyTypeObject Iter_type = { ...@@ -158,6 +161,29 @@ static PyTypeObject Iter_type = {
0 /* tp_new */ 0 /* tp_new */
}; };
/*** Nodes ***/
static PyObject *
new_node(Document *doc, iks *xml)
{
Node *node;
int ref = 1;
if (!xml) return PyErr_NoMemory();
if (!doc) {
doc = PyObject_New(Document, &Document_type);
doc->document = xml;
ref = 0;
}
node = PyObject_New(Node, &Node_type);
node->doc = doc;
if (ref) {
Py_INCREF(doc);
}
node->node = xml;
return (PyObject *)node;
}
static void static void
Node_dealloc(Node *self) Node_dealloc(Node *self)
{ {
...@@ -166,6 +192,20 @@ Node_dealloc(Node *self) ...@@ -166,6 +192,20 @@ Node_dealloc(Node *self)
} }
PyTypeObject* ob_type(PyObject *self); PyTypeObject* ob_type(PyObject *self);
} }
static PyObject *
Node_toString(Node *self, PyObject *args)
{
PyObject *ret;
char *str;
str = iks_string(NULL, self->node);
ret = Py_BuildValue("s", str);
iks_free(str);
return ret;
}
static PyObject * static PyObject *
Node_iter(Node *self) Node_iter(Node *self)
{ {
...@@ -527,19 +567,6 @@ Node_previousTag(Node *self, PyObject *args) ...@@ -527,19 +567,6 @@ Node_previousTag(Node *self, PyObject *args)
return new_node(self->doc, sibling); return new_node(self->doc, sibling);
} }
static PyObject *
Node_toString(Node *self, PyObject *args)
{
PyObject *ret;
char *str;
str = iks_string(NULL, self->node);
ret = Py_BuildValue("s", str);
iks_free(str);
return ret;
}
struct makeup_ctx { struct makeup_ctx {
unsigned int level; unsigned int level;
int can_indent; int can_indent;
...@@ -858,28 +885,6 @@ static PyTypeObject Node_type = { ...@@ -858,28 +885,6 @@ static PyTypeObject Node_type = {
0 /* tp_new */ 0 /* tp_new */
}; };
static PyObject *
new_node(Document *doc, iks *xml)
{
Node *node;
int ref = 1;
if (!xml) return PyErr_NoMemory();
if (!doc) {
doc = PyObject_New(Document, &Document_type);
doc->document = xml;
ref = 0;
}
node = PyObject_New(Node, &Node_type);
node->doc = doc;
if (ref) {
Py_INCREF(doc);
}
node->node = xml;
return (PyObject *)node;
}
/*** Module Functions ***/ /*** Module Functions ***/
static PyObject * static PyObject *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment