Skip to content
This repository
tag: v552
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 74 lines (56 sloc) 2.264 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(* CF mli *)

let generic_make_property printer start ?(quiet=false) mess =
  let t = ref start in
  let set state =
    t := state ;
    if not quiet then printer mess state
  and get () = !t
  in
  set, get

let make_property ?(start=false) =
  generic_make_property
    (fun mess state ->
       OManager.unquiet "%s is %s@\n" mess (if state then "on" else "off"))
    start

let make_int_property ?(start=0) =
  generic_make_property
    (fun mess state ->
       OManager.unquiet "%s level is %d@\n" mess state)
    start

let assert_set, assert_get = make_property ~start:true "assert"
let dddbgen_set, dddbgen_get = make_property "dddbgen"
let dump_set, dump_get = make_property "dump" ~quiet:true
let greedy_set, greedy_get = make_property "greedy" ~quiet:true
let noeval_set, noeval_get = make_property "noeval" ~quiet:true

let prompt_set, prompt_get = make_property ~start:false ~quiet:true "prompt"

let restricted_bypass_set, restricted_bypass_get =
  make_property ~start:true "restricted_bypass"

let value_restriction_set, value_restriction_get = (*make_int_property "value_restriction" ~quiet:false*)
  generic_make_property
    (fun mess state ->
       OManager.unquiet "%s is %s@\n"
         mess (match state with
               | `disabled -> "disabled"
               | `normal -> "normal"
               | `strict -> "strict"))
    `disabled
    ~quiet:true
    "value_restriction"



let switch_typechecker ty_ch_name =
  match QmlTyper.available_typer_of_string ty_ch_name with
  | None -> false
  | Some t -> QmlTyper.DyTyper.switch_typer t ; true



let stdout = ref Format.std_formatter
Something went wrong with that request. Please try again.