projects
/
SXSI
/
xpathcomp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changes
[SXSI/xpathcomp.git]
/
tag.ml
diff --git
a/tag.ml
b/tag.ml
index
e5c3820
..
82c42b5
100644
(file)
--- a/
tag.ml
+++ b/
tag.ml
@@
-16,24
+16,40
@@
external register_tag : pool -> string -> t = "caml_xml_tree_register_tag"
external tag_name : pool -> t -> string = "caml_xml_tree_tag_name"
let nullt = null_tag ()
external tag_name : pool -> t -> string = "caml_xml_tree_tag_name"
let nullt = null_tag ()
-let pcdata = max_int
-let attribute = max_int - 1
+(* Defined in XMLTree.cpp *)
+let pcdata = 1
+let attribute = 0
-let pool =
ref (null_pool ())
+let pool =
Weak.create 1
-let init p = pool := p
+let init p = Weak.set pool 0 (Some p)
+
+let get_pool () = match Weak.get pool 0 with
+ | Some x -> x
+ | None -> failwith "Tag.ml: Uninitialized Document"
let tag s = match s with
| "<$>" -> pcdata
| "<@>" -> attribute
let tag s = match s with
| "<$>" -> pcdata
| "<@>" -> attribute
- | _ -> register_tag
!pool
s
+ | _ -> register_tag
(get_pool())
s
let compare = (-)
let equal = (==)
let compare = (-)
let equal = (==)
+
+let hash x = x
+
+
let to_string t =
if t = pcdata then "<$>"
else if t = attribute then "<@>"
let to_string t =
if t = pcdata then "<$>"
else if t = attribute then "<@>"
- else tag_name
!pool
t
+ else tag_name
(get_pool())
t
let print ppf t = Format.fprintf ppf "%s" (to_string t)
let print ppf t = Format.fprintf ppf "%s" (to_string t)
+(* Check internal invariants *)
+let check t =
+ if (t != tag (to_string t))
+ then failwith "module Tag: internal check failed"
+
+let dump = print
+