aboutsummaryrefslogtreecommitdiff
path: root/library/goptions.ml
diff options
context:
space:
mode:
authorThéo Zimmermann2020-04-20 16:18:01 +0200
committerThéo Zimmermann2020-04-20 16:18:01 +0200
commit2618b5dab38c9a3c2322e886d0b46b67b5cecfbf (patch)
tree1dcd570915b2897e40af219dfff36e3c3703ac00 /library/goptions.ml
parent51cc164e858433961acc166e83e69880700a89f1 (diff)
Move new iter_table function to Goptions.
Diffstat (limited to 'library/goptions.ml')
-rw-r--r--library/goptions.ml21
1 files changed, 21 insertions, 0 deletions
diff --git a/library/goptions.ml b/library/goptions.ml
index fbacd07226..666ba8ee2e 100644
--- a/library/goptions.ml
+++ b/library/goptions.ml
@@ -24,6 +24,10 @@ type option_value =
| StringValue of string
| StringOptValue of string option
+type table_value =
+ | StringRefValue of string
+ | QualidRefValue of qualid
+
(** Summary of an option status *)
type option_state = {
opt_depr : bool;
@@ -189,6 +193,23 @@ end
module MakeRefTable =
functor (A : RefConvertArg) -> MakeTable (RefConvert(A))
+type iter_table_aux = { aux : 'a. 'a table_of_A -> Environ.env -> 'a -> unit }
+
+let iter_table f key lv =
+ let aux = function
+ | StringRefValue s ->
+ begin
+ try f.aux (get_string_table key) (Global.env()) s
+ with Not_found -> error_no_table_of_this_type ~kind:"string" key
+ end
+ | QualidRefValue locqid ->
+ begin
+ try f.aux (get_ref_table key) (Global.env()) locqid
+ with Not_found -> error_no_table_of_this_type ~kind:"qualid" key
+ end
+ in
+ List.iter aux lv
+
(****************************************************************************)
(* 2- Flags. *)