v2v: DOM: Make 'doc' and 'element' types distinct.

No functional change, just enforces the distinct type for callers.
This commit is contained in:
Richard W.M. Jones
2016-06-12 17:35:14 +01:00
parent 4d09ce2251
commit b8f1ea3fff
2 changed files with 5 additions and 5 deletions

View File

@@ -32,10 +32,10 @@ and element = {
mutable e_children : node list; (* Child elements. *)
}
and attr = string * string
and doc = element
and doc = Doc of element
let doc name attrs children =
{ e_name = name; e_attrs = attrs; e_children = children }
Doc { e_name = name; e_attrs = attrs; e_children = children }
let e name attrs children =
Element { e_name = name; e_attrs = attrs; e_children = children }
@@ -98,12 +98,12 @@ and xml_quote_pcdata str =
let str = String.replace str ">" ">" in
str
let doc_to_chan chan doc =
let doc_to_chan chan (Doc doc) =
fprintf chan "<?xml version='1.0' encoding='utf-8'?>\n";
element_to_chan chan doc;
fprintf chan "\n"
let path_to_nodes doc path =
let path_to_nodes (Doc doc) path =
match path with
| [] -> invalid_arg "path_to_nodes: empty path"
| top_name :: path ->

View File

@@ -19,7 +19,7 @@
(** Poor man's XML DOM, mutable for ease of modification. *)
type element
type doc = element
type doc = Doc of element
type attr = string * string
type node =