X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Flablgtk_gtkmathview%2Flablgtk-20000829_gtkmathview-0.2.1%2Fminidom%2Fml_minidom.c;fp=helm%2FDEVEL%2Flablgtk_gtkmathview%2Flablgtk-20000829_gtkmathview-0.2.1%2Fminidom%2Fml_minidom.c;h=10626143c01f1eaedb87476a8e324185b86f33c1;hb=d70d5de1ec9ccc86c9df45036245af34c37575ea;hp=0000000000000000000000000000000000000000;hpb=99d60351f793983bb7633334ea59e95feb36c72c;p=helm.git diff --git a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.1/minidom/ml_minidom.c b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.1/minidom/ml_minidom.c new file mode 100644 index 000000000..10626143c --- /dev/null +++ b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.1/minidom/ml_minidom.c @@ -0,0 +1,288 @@ + +#include +#include +#include + +#include "minidom.h" + +#define Val_ptr(p) ((value) (p)) +#define Val_option(p,f) ((p != NULL) ? ml_some(f(p)) : Val_unit) +#define Val_mDOMString(s) (copy_string((char*) (s))) +#define mDOMString_val(v) ((mDOMStringRef) String_val(v)) + +static value +ml_some(value v) +{ + CAMLparam1(v); + value ret = alloc_small(1,0); + Field(ret,0) = v; + CAMLreturn(ret); +} + +value +ml_string_of_mDOMString(value s) +{ + CAMLparam1(s); + CAMLreturn(s); +} + +value +ml_mDOMString_of_string(value s) +{ + CAMLparam1(s); + CAMLreturn(s); +} + +value +ml_doc_load(value file_name) +{ + mDOMDocRef doc_ref; + + CAMLparam1(file_name); + + doc_ref = mdom_load(String_val(file_name), FALSE, NULL); + if (doc_ref == NULL) failwith("minidom: could not load document"); + + CAMLreturn((value) doc_ref); +} + +value +ml_doc_unload(value doc) +{ + CAMLparam1(doc); + + mdom_unload((mDOMDocRef) doc); + + CAMLreturn(Val_unit); +} + +value +ml_doc_new(value s) +{ + mDOMDocRef doc_ref; + + CAMLparam1(s); + + doc_ref = mdom_doc_new(mDOMString_val(s)); + if (doc_ref == NULL) failwith("minidom: could not create new document"); + + CAMLreturn((value) doc_ref); +} + + +value +ml_doc_get_root_node(value doc) +{ + mDOMNodeRef root; + + CAMLparam1(doc); + root = mdom_doc_get_root_node((mDOMDocRef) doc); + if (root == NULL) failwith("minidom: document has no root node!"); + + CAMLreturn((value) root); +} + +value +ml_doc_add_entity(value doc, value name, value content) +{ + mDOMEntityRef ent; + + CAMLparam3(doc, name, content); + ent = mdom_doc_add_entity((mDOMDocRef) doc, mDOMString_val(name), mDOMString_val(content)); + if (ent == NULL) failwith("minidom: could not add entity"); + + CAMLreturn((value) ent); +} + +value +ml_doc_get_entity(value doc, value name) +{ + mDOMEntityRef ent; + + CAMLparam2(doc, name); + ent = mdom_doc_get_entity((mDOMDocRef) doc, mDOMString_val(name)); + + CAMLreturn(Val_option(ent, Val_ptr)); +} + +value +ml_doc_get_predefined_entity(value name) +{ + mDOMEntityRef ent; + + CAMLparam1(name); + ent = mdom_get_predefined_entity(mDOMString_val(name)); + + CAMLreturn(Val_option(ent, Val_ptr)); +} + +value +ml_entity_get_content(value ent) +{ + CAMLparam1(ent); + CAMLreturn(Val_mDOMString(mdom_entity_get_content((mDOMEntityRef) ent))); +} + +value +ml_node_is_text(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_bool(mdom_node_is_text((mDOMNodeRef) node))); +} + +value +ml_node_is_element(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_bool(mdom_node_is_element((mDOMNodeRef) node))); +} + +value +ml_node_is_blank(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_bool(mdom_node_is_blank((mDOMNodeRef) node))); +} + +value +ml_node_is_entity_ref(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_bool(mdom_node_is_entity_ref((mDOMNodeRef) node))); +} + +value +ml_node_get_type(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_int(mdom_node_get_type((mDOMNodeRef) node))); +} + +value +ml_node_get_name(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_name((mDOMNodeRef) node), Val_mDOMString)); +} + +value +ml_node_get_content(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_content((mDOMNodeRef) node), Val_mDOMString)); +} + +value +ml_node_get_ns_uri(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_ns_uri((mDOMNodeRef) node), Val_mDOMString)); +} + +value +ml_node_get_attribute(value node, value name) +{ + CAMLparam2(node,name); + CAMLreturn(Val_option(mdom_node_get_attribute((mDOMNodeRef) node, String_val(name)), Val_mDOMString)); +} + +value +ml_node_get_attribute_ns(value node, value name, value ns_uri) +{ + CAMLparam2(node,name); + CAMLreturn(Val_option(mdom_node_get_attribute_ns((mDOMNodeRef) node, + String_val(name), + String_val(ns_uri)), Val_mDOMString)); +} + +value +ml_node_get_parent(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_parent((mDOMNodeRef) node), Val_ptr)); +} + +value +ml_node_get_prev_sibling(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_prev_sibling((mDOMNodeRef) node), Val_ptr)); +} + +value +ml_node_get_next_sibling(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_next_sibling((mDOMNodeRef) node), Val_ptr)); +} + +value +ml_node_get_first_child(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_first_child((mDOMNodeRef) node), Val_ptr)); +} + +value +ml_node_get_first_attribute(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_option(mdom_node_get_first_attribute((mDOMNodeRef) node), Val_ptr)); +} + +value +ml_node_is_first(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_bool(mdom_node_is_first((mDOMNodeRef) node))); +} + +value +ml_node_is_last(value node) +{ + CAMLparam1(node); + CAMLreturn(Val_bool(mdom_node_is_last((mDOMNodeRef) node))); +} + +value +ml_attr_get_name(value attr) +{ + CAMLparam1(attr); + CAMLreturn(Val_option(mdom_attr_get_name((mDOMAttrRef) attr), Val_mDOMString)); +} + +value +ml_attr_get_ns_uri(value attr) +{ + CAMLparam1(attr); + CAMLreturn(Val_option(mdom_attr_get_ns_uri((mDOMAttrRef) attr), Val_mDOMString)); +} + +value +ml_attr_get_value(value attr) +{ + CAMLparam1(attr); + CAMLreturn(Val_option(mdom_attr_get_value((mDOMAttrRef) attr), Val_mDOMString)); +} + +value +ml_attr_get_prev_sibling(value attr) +{ + CAMLparam1(attr); + CAMLreturn(Val_option(mdom_attr_get_prev_sibling((mDOMAttrRef) attr), Val_ptr)); +} + +value +ml_attr_get_next_sibling(value attr) +{ + CAMLparam1(attr); + CAMLreturn(Val_option(mdom_attr_get_next_sibling((mDOMAttrRef) attr), Val_ptr)); +} + +value +ml_attr_get_parent(value attr) +{ + CAMLparam1(attr); + CAMLreturn(Val_option(mdom_attr_get_parent((mDOMAttrRef) attr), Val_ptr)); +} +