+
+extern "C" {
+ static int caml_empty_vector[] = { 0 };
+}
+
+extern "C" CAMLprim value caml_int_vector_empty(value unit){
+ CAMLparam1(unit);
+ CAMLreturn ((value) caml_empty_vector);
+}
+
+extern "C" CAMLprim value caml_int_vector_length(value vec){
+ CAMLparam1(vec);
+ CAMLreturn (Val_int( ((int*) caml_empty_vector)[0] ));
+}
+extern "C" CAMLprim value caml_int_vector_alloc(value len){
+ CAMLparam1(len);
+ int * vec = (int *) malloc(sizeof(int)*(Int_val(len)+1));
+ vec[0] = Int_val(len);
+ CAMLreturn ((value) vec);
+}
+
+extern "C" CAMLprim value caml_int_vector_set(value vec, value i, value v){
+ CAMLparam3(vec,i,v);
+
+ ((int*) vec)[Int_val(i)+1] = Int_val(v);
+ CAMLreturn (Val_unit);
+}
+
+
+#define VECT(x) ((int*) (x))
+extern "C" CAMLprim value caml_xml_tree_tagged_below(value tree, value node, value ctags, value dtags){
+ CAMLparam4(tree,node,ctags,dtags);
+
+ CAMLreturn (Val_int (
+ (XMLTREE(tree)->TaggedBelow(TREENODEVAL(node),
+ &(VECT(ctags)[1]),
+ VECT(ctags)[0],
+ &(VECT(dtags)[1]),
+ VECT(dtags)[0]))));
+}
+
+extern "C" CAMLprim value caml_xml_tree_tagged_next(value tree, value node, value ctags, value ftags,value root){
+ CAMLparam5(tree,node,ctags,ftags,root);
+ CAMLreturn (Val_int (
+ (XMLTREE(tree)->TaggedNext(TREENODEVAL(node),
+ &(VECT(ctags)[1]),
+ VECT(ctags)[0],
+ &(VECT(ftags)[1]),
+ VECT(ftags)[0],
+ TREENODEVAL(root)))));
+}
+
+extern "C" CAMLprim value caml_xml_tree_tagged_desc_only(value tree, value node,value dtags){
+ CAMLparam3(tree,node,dtags);
+
+ CAMLreturn (Val_int (
+ (XMLTREE(tree)->TaggedDescOnly(TREENODEVAL(node),
+ &(VECT(dtags)[1]),
+ VECT(dtags)[0]))));
+}
+
+extern "C" CAMLprim value caml_xml_tree_tagged_foll_only(value tree, value node, value ftags,value root){
+ CAMLparam4(tree,node,ftags,root);
+ CAMLreturn (Val_int (
+ (XMLTREE(tree)->TaggedFollOnly(TREENODEVAL(node),
+ &(VECT(ftags)[1]),
+ VECT(ftags)[0],
+ TREENODEVAL(root)))));
+}
+
+extern "C" CAMLprim value caml_xml_tree_tagged_desc_or_foll_only(value tree, value node, value ftags,value root){
+ CAMLparam4(tree,node,ftags,root);
+ CAMLreturn (Val_int (
+ (XMLTREE(tree)->TaggedDescOrFollOnly(TREENODEVAL(node),
+ &(VECT(ftags)[1]),
+ VECT(ftags)[0],
+ TREENODEVAL(root)))));
+}
+
+extern "C" CAMLprim value caml_xml_tree_doc_ids(value tree, value node){
+ CAMLparam2(tree,node);
+ CAMLlocal1(tuple);
+ tuple = caml_alloc_tuple(2);
+ range r = (XMLTREE(tree)->DocIds(TREENODEVAL(node)));
+ caml_initialize(&Field(tuple,0),Val_int(r.min));
+ caml_initialize(&Field(tuple,1),Val_int(r.max));
+ CAMLreturn (tuple);
+}