diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-05-16 22:32:52 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-05-16 22:32:52 +0000 |
| commit | 3dad242cb2e4a27731622d6c94ae7fa330bad227 (patch) | |
| tree | 04a5de019fde3672a828239ba3f2863efb5221e2 | |
| parent | 98d6264eadc827ff34e1bee2d3643f43567c00d0 (diff) | |
| download | lasso-3dad242cb2e4a27731622d6c94ae7fa330bad227.tar.gz lasso-3dad242cb2e4a27731622d6c94ae7fa330bad227.tar.xz lasso-3dad242cb2e4a27731622d6c94ae7fa330bad227.zip | |
New method lasso_node_destroy() added in class LassoNode
| -rw-r--r-- | lasso/xml/xml.c | 25 | ||||
| -rw-r--r-- | lasso/xml/xml.h | 3 | ||||
| -rw-r--r-- | python/lasso.py | 6 | ||||
| -rw-r--r-- | python/lassomod.c | 2 | ||||
| -rw-r--r-- | python/xml/py_xml.c | 31 | ||||
| -rw-r--r-- | python/xml/py_xml.h | 2 |
6 files changed, 45 insertions, 24 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 1e82b035..b4285f4b 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -56,6 +56,15 @@ lasso_node_dump(LassoNode *node, return (class->dump(node, encoding, format)); } +void +lasso_node_destroy(LassoNode *node) +{ + g_return_val_if_fail (LASSO_IS_NODE(node), NULL); + + LassoNodeClass *class = LASSO_NODE_GET_CLASS(node); + return (class->destroy(node)); +} + xmlChar * lasso_node_export(LassoNode *node) { @@ -334,6 +343,12 @@ lasso_node_impl_copy(LassoNode *node) return (lasso_node_new_from_xmlNode(xmlCopyNode(lasso_node_get_xmlNode(node), 1))); } +static void +lasso_node_impl_destroy(LassoNode *node) +{ + g_object_unref(G_OBJECT(node)); +} + static xmlChar * lasso_node_impl_dump(LassoNode *node, const xmlChar *encoding, @@ -724,7 +739,6 @@ lasso_node_impl_add_child(LassoNode *node, /* if child is not unbounded, we search it */ if (!unbounded) { - //old_child = lasso_node_get_child(node, child->private->node->name); old_child = xmlSecFindNode(node->private->node, child->private->node->name, NULL); } @@ -746,7 +760,7 @@ lasso_node_impl_add_child(LassoNode *node, /* else child is added */ xmlAddChild(node->private->node, child->private->node); } - /* child added in children array */ + /* child added in childrens' array */ g_ptr_array_add(node->private->children, (gpointer)child); } @@ -1034,13 +1048,17 @@ lasso_node_finalize(LassoNode *node) LassoNode *child; g_print("%s 0x%x finalized ...\n", lasso_node_get_name(node), node); - for(i=0;i<node->private->children->len;i++) { + + for(i=0; i<node->private->children->len; i++) { child = LASSO_NODE(g_ptr_array_index(node->private->children, i)); g_ptr_array_remove_index(node->private->children, i); g_object_unref(G_OBJECT(child)); } + g_ptr_array_free(node->private->children, TRUE); + xmlUnlinkNode(node->private->node); xmlFreeNode(node->private->node); + g_free (node->private); } @@ -1066,6 +1084,7 @@ lasso_node_class_init(LassoNodeClass *class) /* virtual public methods */ class->copy = lasso_node_impl_copy; + class->destroy = lasso_node_impl_destroy; class->dump = lasso_node_impl_dump; class->export = lasso_node_impl_export; class->export_to_base64 = lasso_node_impl_export_to_base64; diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h index 050f90c5..8b75218e 100644 --- a/lasso/xml/xml.h +++ b/lasso/xml/xml.h @@ -61,6 +61,7 @@ struct _LassoNodeClass { /*< vtable >*/ /*< public >*/ LassoNode* (* copy) (LassoNode *node); + void (* destroy) (LassoNode *node); xmlChar* (* dump) (LassoNode *node, const xmlChar *encoding, int format); @@ -128,6 +129,8 @@ LASSO_EXPORT LassoNode* lasso_node_new_from_xmlNode (xmlNodePtr node); LASSO_EXPORT LassoNode* lasso_node_copy (LassoNode *node); +LASSO_EXPORT void lasso_node_destroy (LassoNode *node); + LASSO_EXPORT xmlChar* lasso_node_dump (LassoNode *node, const xmlChar *encoding, int format); diff --git a/python/lasso.py b/python/lasso.py index bdf24867..666065ce 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -61,6 +61,9 @@ class Node: ## #self._o = lassomod.(size) ## if self._o is None: raise Error('lasso_node_new() failed') + def destroy(self): + lassomod.node_destroy(self) + def dump(self, encoding="utf8", format=1): return lassomod.node_dump(self, encoding, format) @@ -76,9 +79,6 @@ class Node: def export_to_soap(self): return lassomod.node_export_to_soap(self) - def destroy(self): - lassomod.node_unref(self) - def get_attr_value(self, name): return lassomod.node_get_attr_value(self, name) diff --git a/python/lassomod.c b/python/lassomod.c index a393cfd5..2d719914 100644 --- a/python/lassomod.c +++ b/python/lassomod.c @@ -63,6 +63,7 @@ static PyMethodDef lasso_methods[] = { /* xml */ /* py_xml.h */ + {"node_destroy", node_destroy, METH_VARARGS}, {"node_dump", node_dump, METH_VARARGS}, {"node_export", node_export, METH_VARARGS}, {"node_export_to_base64", node_export_to_base64, METH_VARARGS}, @@ -71,7 +72,6 @@ static PyMethodDef lasso_methods[] = { {"node_get_attr_value", node_get_attr_value, METH_VARARGS}, {"node_get_child", node_get_child, METH_VARARGS}, {"node_get_content", node_get_content, METH_VARARGS}, - {"node_unref", node_unref, METH_VARARGS}, {"node_verify_signature", node_verify_signature, METH_VARARGS}, /* py_lib_authentication_statement.h */ diff --git a/python/xml/py_xml.c b/python/xml/py_xml.c index d7a44583..4085ccaf 100644 --- a/python/xml/py_xml.c +++ b/python/xml/py_xml.c @@ -43,6 +43,21 @@ PyObject *LassoNode_wrap(LassoNode *node) { /* LassoNode */ /******************************************************************************/ +PyObject *node_destroy(PyObject *self, PyObject *args) { + PyObject *node_obj; + + if (CheckArgs(args, "O:node_destroy")) { + if(!PyArg_ParseTuple(args, (char *) "O:node_destroy", &node_obj)) + return NULL; + } + else return NULL; + + lasso_node_destroy(LassoNode_get(node_obj)); + + Py_INCREF(Py_None); + return (Py_None); +} + PyObject *node_dump(PyObject *self, PyObject *args) { PyObject *node_obj; xmlChar *encoding; @@ -176,22 +191,6 @@ PyObject *node_get_content(PyObject *self, PyObject *args) { return (xmlCharPtr_wrap(ret)); } -PyObject *node_unref(PyObject *self, PyObject *args) { - PyObject *node_obj; - - if (CheckArgs(args, "O:node_unref")) { - if(!PyArg_ParseTuple(args, (char *) "O:node_unref", &node_obj)) - return NULL; - } - else return NULL; - - /* FIXME: should used a fct lasso_node_unref() ??? */ - g_object_unref (G_OBJECT (LassoNode_get(node_obj))); - - Py_INCREF(Py_None); - return (Py_None); -} - PyObject *node_verify_signature(PyObject *self, PyObject *args) { PyObject *node_obj; const gchar *certificate_file; diff --git a/python/xml/py_xml.h b/python/xml/py_xml.h index 82d9fed4..35665f84 100644 --- a/python/xml/py_xml.h +++ b/python/xml/py_xml.h @@ -36,6 +36,7 @@ typedef struct { #define LassoNode_get(v) (((v) == Py_None) ? NULL : (((LassoNode_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj)) PyObject *LassoNode_wrap(LassoNode *node); +PyObject *node_destroy(PyObject *self, PyObject *args); PyObject *node_dump(PyObject *self, PyObject *args); PyObject *node_export(PyObject *self, PyObject *args); PyObject *node_export_to_base64(PyObject *self, PyObject *args); @@ -44,7 +45,6 @@ PyObject *node_export_to_soap(PyObject *self, PyObject *args); PyObject *node_get_attr_value(PyObject *self, PyObject *args); PyObject *node_get_child(PyObject *self, PyObject *args); PyObject *node_get_content(PyObject *self, PyObject *args); -PyObject *node_unref(PyObject *self, PyObject *args); PyObject *node_verify_signature(PyObject *self, PyObject *args); #endif /* __PYLASSO_PY_XML_H__ */ |
