X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2FOCamlDriver.cpp;fp=src%2FOCamlDriver.cpp;h=bb007a8ec7a8429c5e7a56c8d16d3c89784cfb09;hb=813b239795aac1844eb233dab7f8f98d8dba845e;hp=8eb3a22ce681aaef83cfa7d9839535adb93dbea3;hpb=ba65a1b770d860132fbb04be4ca931b983dcb915;p=SXSI%2Fxpathcomp.git diff --git a/src/OCamlDriver.cpp b/src/OCamlDriver.cpp index 8eb3a22..bb007a8 100644 --- a/src/OCamlDriver.cpp +++ b/src/OCamlDriver.cpp @@ -23,17 +23,13 @@ #include "Utils.h" #include "common_stub.hpp" -extern "C" { -#include -} - #define CAMLRAISEMSG(msg) (sxsi_raise_msg((char*) (msg))) -#define XMLTREE(x) (Obj_val(x)) +#define XMLTREE(x) (Obj_val(x)) -#define HSET(x) (Obj_val(x)) +#define HSET(x) (Obj_val(x)) -#define XMLTREEBUILDER(x) (Obj_val(x)) +#define XMLTREEBUILDER(x) (Obj_val(x)) #define TREENODEVAL(i) ((treeNode) (Int_val(i))) @@ -56,8 +52,9 @@ extern "C" value caml_xml_tree_builder_create(value unit) { CAMLparam1(unit); CAMLlocal1(result); - result = sxsi_alloc_custom(); - Obj_val(result) = new XMLTreeBuilder(); + result = sxsi_alloc_custom(); + Obj_val(result) = new XMLTreeBuilder(); + CAMLreturn(result); } @@ -102,8 +99,8 @@ extern "C" value caml_xml_tree_builder_close_document(value vbuilder) XMLTree * tree = XMLTREEBUILDER(vbuilder)->CloseDocument(); if (tree == NULL) CAMLRAISEMSG("CloseDocument"); - result = sxsi_alloc_custom(); - Obj_val(result) = tree; + result = sxsi_alloc_custom(); + Obj_val(result) = tree; CAMLreturn (result); } @@ -155,12 +152,16 @@ extern "C" value caml_xml_tree_save(value tree,value fd, value name){ extern "C" value caml_xml_tree_load(value fd, value name, value load_tc,value sf){ CAMLparam4(fd, name, load_tc, sf); - CAMLlocal1(result); + CAMLlocal2(result,tmp); XMLTree * tree; try { + tree = XMLTree::Load(Int_val(fd),Bool_val(load_tc),Int_val(sf), String_val(name)); - result = sxsi_alloc_custom(); - Obj_val(result) = tree; + result = sxsi_alloc_custom(); + + Obj_val(result) = tree; + tmp = sxsi_alloc_custom(); + Obj_val(tmp) = 3l; CAMLreturn(result); } catch (const std::exception& e){ CAMLRAISEMSG(e.what()); } @@ -416,8 +417,8 @@ NoAlloc extern "C" value caml_unordered_set_length(value hset){ extern "C" value caml_unordered_set_alloc(value unit){ CAMLparam1(unit); CAMLlocal1(hset); - hset = sxsi_alloc_custom(); - Obj_val(hset) = new TagIdSet(); + hset = sxsi_alloc_custom(); + Obj_val(hset) = new TagIdSet(); CAMLreturn (hset); }