Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 104 lines (87 sloc) 3.352 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (*
19 @author Louis Gesbert
20 **)
21
22 (* Exported module with reduced interface *)
23
24 (* Because of a lack of functionality in OCaml module handling, we can't use include *)
25
26 module Sch = Schema_private
27 module Schema = struct
28 type t = Sch.meta_schema
29 let mapi = Sch.mapi
30 let initial = Sch.initial
31 let is_empty = Sch.is_empty_or_unused
32 let register_path = Sch.register_path
33 let register_default = Sch.register_default
34 let register_db_declaration = Sch.register_db_declaration
35 let register_new_db_value = Sch.register_new_db_value
36 (* let get_type_of_path = get_type_of_path *)
37 (* let preprocess_path = preprocess_path *)
38 let preprocess_paths_expr = Sch.preprocess_paths_expr
39 let preprocess_paths_code_elt = Sch.preprocess_paths_code_elt
40 let preprocess_paths_ast = Sch.preprocess_paths_ast
41 let finalize = Sch.finalize
42 let of_package = Sch.of_package
43 let merge = Sch.merge
44 let map_types = Sch.map_types
45 let map_expr = Sch.map_expr
46 let fold_expr = Sch.fold_expr
47 let foldmap_expr = Sch.foldmap_expr
48 let from_gml s =
49 StringListMap.singleton []
50 ({ Sch.ident = None;
51 Sch.path_aliases = [];
52 Sch.options = [];
53 Sch.schema = Schema_io.from_gml_string s;
54 Sch.virtual_path = Sch.PathMap.empty;
55 })
56 let to_dot t chan =
57 StringListMap.iter
58 (fun key db_def ->
59 output_string chan (String.concat "/" key);
60 output_char chan '\n';
61 Schema_io.to_dot db_def.Sch.schema chan)
62 t
63
64 let find_db_def t db_ident_opt =
65 if StringListMap.size t = 1 && db_ident_opt = None
66 then StringListMap.min t
67 else
68 StringListMap.min (* may raise Not_found *)
69 (StringListMap.filter_val
70 (fun db_def -> db_ident_opt = Option.map Ident.original_name db_def.Sch.ident)
71 t)
72 let db_to_dot t db_ident_opt chan =
73 let _, db_def = find_db_def t db_ident_opt in
74 Schema_io.to_dot db_def.Sch.schema chan
75 let db_to_gml t db_ident_opt chan =
76 let _, db_def = find_db_def t db_ident_opt in
77 Schema_io.to_gml db_def.Sch.schema chan
78
79 module HacksForPositions = Sch.HacksForPositions
80 end
81
82 module type S = sig include DbGenByPass.S end
83
84 type dbinfo = DbGen_private.dbinfo
85
86 let merge_dbinfo = DbGen_private.merge_dbinfo
87
88 module DbGen ( Arg : DbGenByPass.S ) = struct
89
90 module Access = DbGen_private.DatabaseAccess (Arg)
91 let initialize = Access.initialize
92 let replace_path_exprs = Access.replace_path_exprs
93 let replace_path_code_elt = Access.replace_path_code_elt
94 let replace_path_ast = Access.replace_path_ast
95 end
96
97 module DbGenByPass = DbGenByPass
98
99 let warning_set =
100 WarningClass.Set.create_from_list [
101 WarningClass.dbgen;
102 WarningClass.dbgen_schema;
103 ]
Something went wrong with that request. Please try again.