From: Ferruccio Guidi Date: Tue, 24 Feb 2004 16:16:31 +0000 (+0000) Subject: interpreter flags were reorganized X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Funlabeled-1.4.2;p=helm.git interpreter flags were reorganized --- diff --git a/helm/ocaml/mathql_interpreter/mQIConn.ml b/helm/ocaml/mathql_interpreter/mQIConn.ml index 460ef41d0..d0dedf143 100644 --- a/helm/ocaml/mathql_interpreter/mQIConn.ml +++ b/helm/ocaml/mathql_interpreter/mQIConn.ml @@ -26,7 +26,7 @@ (* AUTOR: Ferruccio Guidi *) -type flag = Postgres | Galax | Stat | Quiet | Warn | Log +type flag = Galax | Postgres | Queries | Result | Source | Times | Warn type handle = { log : string -> unit; (* logging function *) @@ -51,20 +51,22 @@ let pgc handle = handle.pgc let flags handle = handle.set let string_of_flag = function - | Postgres -> "P" | Galax -> "G" - | Stat -> "S" - | Quiet -> "Q" + | Postgres -> "P" + | Queries -> "Q" + | Result -> "R" + | Source -> "S" + | Times -> "T" | Warn -> "W" - | Log -> "L" let flag_of_char = function - | 'P' -> [Postgres] | 'G' -> [Galax] - | 'S' -> [Stat] - | 'Q' -> [Quiet] + | 'P' -> [Postgres] + | 'Q' -> [Queries] + | 'R' -> [Result] + | 'S' -> [Source] + | 'T' -> [Times] | 'W' -> [Warn] - | 'L' -> [Log] | _ -> [] let string_fold_left f a s = @@ -78,16 +80,22 @@ let string_of_flags flags = let flags_of_string s = string_fold_left (fun l c -> l @ flag_of_char c) [] s -let init myflags mylog = +let init ?(flags = []) ?(log = ignore) () = + let flags = + if flags = [] then + flags_of_string (Helm_registry.get "mathql_interpreter.flags") + else + flags + in let m, a = let g = - if List.mem Galax myflags + if List.mem Galax flags then MQIMap.empty_map else MQIMap.read_map in g () in - {log = mylog; set = myflags; + {log = log; set = flags; pgc = - if List.mem Galax myflags then + if List.mem Galax flags then None else MQIPostgres.init @@ -101,7 +109,6 @@ let close handle = let connected handle = if set handle Galax then false else (pgc handle) <> None -let init_if_connected myflags mylog = - let handle = init myflags mylog in +let init_if_connected ?(flags = []) ?(log = ignore) () = + let handle = init ~flags:flags ~log:log () in ignore (pgc handle); handle - diff --git a/helm/ocaml/mathql_interpreter/mQIConn.mli b/helm/ocaml/mathql_interpreter/mQIConn.mli index 649b54854..b83453ae9 100644 --- a/helm/ocaml/mathql_interpreter/mQIConn.mli +++ b/helm/ocaml/mathql_interpreter/mQIConn.mli @@ -26,18 +26,18 @@ (* AUTOR: Ferruccio Guidi *) -type flag = Postgres | Galax | Stat | Quiet | Warn | Log +type flag = Galax | Postgres | Queries | Result | Source | Times | Warn val string_of_flags : flag list -> string val flags_of_string : string -> flag list type handle -val init : flag list -> (string -> unit) -> handle +val init : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle val close : handle -> unit val connected : handle -> bool -val init_if_connected : flag list -> (string -> unit) -> handle +val init_if_connected : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle (* The following functions allow to read the handle internal fields. * For exclusive use of the interpreter.