|
@@ -10,14 +10,35 @@ let rec remove m = function
|
|
|
| (m2,_,_) :: l when m = m2 -> l
|
|
|
| x :: l -> x :: remove m l
|
|
|
|
|
|
-let to_string m = fst (get_info m)
|
|
|
+type user_meta = {
|
|
|
+ doc : string;
|
|
|
+ flags : meta_parameter list;
|
|
|
+ source : string option;
|
|
|
+}
|
|
|
+
|
|
|
+type meta_origin =
|
|
|
+ | Compiler
|
|
|
+ | UserDefined of string option
|
|
|
+
|
|
|
+let register_user_meta user_metas s data =
|
|
|
+ Hashtbl.replace user_metas s data
|
|
|
+
|
|
|
+let get_info ?user_metas m = match (user_metas,m) with
|
|
|
+ | (Some(user_metas), Custom(s)) when (Hashtbl.mem user_metas s) ->
|
|
|
+ let infos = Hashtbl.find user_metas s in
|
|
|
+ (s, (infos.doc, infos.flags), (UserDefined infos.source))
|
|
|
+ | _ ->
|
|
|
+ let meta,infos = MetaList.get_info m in
|
|
|
+ (meta, infos, Compiler)
|
|
|
+
|
|
|
+let to_string m = match (get_info m) with (s,_,_) -> s
|
|
|
|
|
|
let hmeta =
|
|
|
let h = Hashtbl.create 0 in
|
|
|
let rec loop i =
|
|
|
let m = Obj.magic i in
|
|
|
if m <> Last then begin
|
|
|
- Hashtbl.add h (fst (get_info m)) m;
|
|
|
+ Hashtbl.add h (to_string m) m;
|
|
|
loop (i + 1);
|
|
|
end;
|
|
|
in
|
|
@@ -32,8 +53,8 @@ let from_string s =
|
|
|
| '$' -> Dollar (String.sub s 1 (String.length s - 1))
|
|
|
| _ -> Custom s
|
|
|
|
|
|
-let get_documentation d =
|
|
|
- let t, (doc,flags) = get_info d in
|
|
|
+let get_documentation user_metas d =
|
|
|
+ let t, (doc,flags), origin = get_info ~user_metas:user_metas d in
|
|
|
if not (List.mem UsedInternally flags) then begin
|
|
|
let params = ref [] and used = ref [] and pfs = ref [] in
|
|
|
List.iter (function
|
|
@@ -48,16 +69,20 @@ let get_documentation d =
|
|
|
| l -> "(<" ^ String.concat ">, <" l ^ ">) "
|
|
|
) in
|
|
|
let pfs = platform_list_help (List.rev !pfs) in
|
|
|
+ let origin = match origin with
|
|
|
+ | UserDefined Some s -> " (from " ^ s ^ ")"
|
|
|
+ | Compiler | UserDefined None -> ""
|
|
|
+ in
|
|
|
let str = "@" ^ t in
|
|
|
- Some (str,params ^ doc ^ pfs)
|
|
|
+ Some (str,params ^ doc ^ pfs ^ origin)
|
|
|
end else
|
|
|
None
|
|
|
|
|
|
-let get_documentation_list () =
|
|
|
+let get_documentation_list user_metas =
|
|
|
let m = ref 0 in
|
|
|
let rec loop i =
|
|
|
let d = Obj.magic i in
|
|
|
- if d <> Last then begin match get_documentation d with
|
|
|
+ if d <> Last then begin match get_documentation user_metas d with
|
|
|
| None -> loop (i + 1)
|
|
|
| Some (str,desc) ->
|
|
|
if String.length str > !m then m := String.length str;
|
|
@@ -68,14 +93,30 @@ let get_documentation_list () =
|
|
|
let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
|
|
|
all,!m
|
|
|
|
|
|
-let get_all () =
|
|
|
- let rec loop i =
|
|
|
+let get_all user_metas =
|
|
|
+ let rec loop i acc =
|
|
|
let d = Obj.magic i in
|
|
|
- if d <> Last then d :: loop (i + 1)
|
|
|
- else []
|
|
|
+ if d <> Last then d :: loop (i + 1) acc
|
|
|
+ else acc
|
|
|
in
|
|
|
- loop 0
|
|
|
+
|
|
|
+ let all = loop 0 (Hashtbl.fold (fun str _ acc -> (Custom str) :: acc) user_metas []) in
|
|
|
+ List.sort (fun m1 m2 -> String.compare (to_string m1) (to_string m2)) all
|
|
|
+
|
|
|
+let get_user_documentation_list user_metas =
|
|
|
+ let m = ref 0 in
|
|
|
+ let user_meta_list = (Hashtbl.fold (fun meta _ acc ->
|
|
|
+ begin match get_documentation user_metas (Custom meta) with
|
|
|
+ | None -> acc
|
|
|
+ | Some (str, desc) ->
|
|
|
+ if String.length str > !m then m := String.length str;
|
|
|
+ (str,desc) :: acc
|
|
|
+ end
|
|
|
+ ) user_metas []) in
|
|
|
+
|
|
|
+ let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) user_meta_list in
|
|
|
+ all,!m
|
|
|
|
|
|
let copy_from_to m src dst =
|
|
|
try (get m src) :: dst
|
|
|
- with Not_found -> dst
|
|
|
+ with Not_found -> dst
|