X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Futils_stub.cpp;h=8ee3e0be885168768147f610fa836a8a29a279ca;hb=2cb4fceda48a09fc1acd65c54372651b14e0f404;hp=dc3688af639e9b514d587ca992d3a5b9ac73c8a5;hpb=f1181ec507d05a2f9ff5371b282a26f8d6e1ff7e;p=SXSI%2Fxpathcomp.git diff --git a/src/utils_stub.cpp b/src/utils_stub.cpp index dc3688a..8ee3e0b 100644 --- a/src/utils_stub.cpp +++ b/src/utils_stub.cpp @@ -1,4 +1,4 @@ -#include "common_stub.hpp" +#include "utils_stub.hpp" extern "C" value caml_clz(value i) { @@ -9,3 +9,29 @@ extern "C" value caml_leading_bit(value i) { return Val_long( ( 1 << (sizeof(unsigned long)*8 - __builtin_clzl(Long_val(i)) - 1))); } + +xml_tree::tag_t*& TAGLIST(value x) +{ + return Obj_val(x); +} + +static void finalize_tag_list(value x) +{ + xml_tree::tag_t * t = TAGLIST(x); + delete [] t; +} + +extern "C" value caml_tag_list_alloc(value length) +{ + CAMLparam1(length); + CAMLlocal1(tlist); + tlist = sxsi_alloc_custom(); + TAGLIST(tlist) = new xml_tree::tag_t[Int_val(length)]; + CAMLreturn (tlist); +} + +NoAlloc extern "C" value caml_tag_list_set(value tl, value i, value v) +{ + TAGLIST(tl)[Int_val(i)] = Int_val(v); + return Val_unit; +}