Commit c74af225 authored by Jérôme Maloberti's avatar Jérôme Maloberti

Move suffix in Service from attribute to litteral + namespace in Service.

parent d4f2d9b9
......@@ -1825,7 +1825,6 @@ end
module Service =
struct
type service_attributs = {
mutable suffix : bool;
mutable const : bool;
mutable end_suffix : bool
}
......@@ -1848,9 +1847,26 @@ struct
let get_gname (cu,n) =
Ns.QName.to_string n;;
let get_gtype t name =
let s = get_gname t in
match s with
let get_gtype t =
get_gname t;;
(* from ns:atom, returns :atom. *)
let strip_namespace tagname =
let len = String.length tagname in
let cur = ref len in
for i = 0 to (len - 1) do
let c = String.get tagname i in
match c with
| ':' -> cur := i
| _ -> ()
done;
if !cur = len then
tagname
else
String.sub tagname !cur (len - !cur);;
let convert_gtype t name =
match t with
| "Int" -> TInt(name)
| "String" -> TString(name)
| "Float" -> TFloat(name)
......@@ -1861,7 +1877,12 @@ struct
match s.Print.state with
| `Named n -> trace ("debug:convert " ^ (U.to_string n)) ;
convert_real name s.Print.def
| `GlobalName n -> get_gtype n name
| `GlobalName n ->
let t = get_gtype n in
(match t with
| "Int" | "String" | "Float" | "Bool"
-> convert_gtype t name
| _ -> convert_real name s.Print.def)
| _ -> convert_real name s.Print.def
and convert_real name def =
let rec aux = function
......@@ -1878,20 +1899,20 @@ struct
| Print.Char c -> assert false
| Print.Regexp r -> convert_regexp name r
| Print.Xml (tag,attr,t) ->
let flags = { suffix = false; const = false; end_suffix = false } in
let flags = { const = false; end_suffix = false } in
(convert_attrs flags attr;
let tagname = convert_tag tag in
let res = convert t tagname in
if flags.const then
TConst tagname
else
if flags.end_suffix then
TESuffix tagname
else
if flags.suffix then
TSuffix(true,res)
let tagname = strip_namespace tagname in
match tagname with
| ":suffix" -> TSuffix(true,res)
| _ -> (if flags.const then
TConst tagname
else
res
if flags.end_suffix then
TESuffix tagname
else
res)
)
| _ -> assert false
and convert_regexp name = function
......@@ -1930,7 +1951,6 @@ struct
let attr_label = Label.string_of_attr l in
trace ("convert_record:" ^ attr_label);
match attr_label with
| "suffix" -> flags.suffix <- true
| "const" -> flags.const <- true
| "end_suffix" -> flags.end_suffix <- true
| _ -> output_string stderr
......@@ -1946,6 +1966,7 @@ struct
DescrHash.clear Print.memo;;
let to_service_params t =
Print.unregister_global t;
let s = prepare t in
let ret = convert s "" in
clear ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment