From 59407b0f5e8d0fd07dc27e8a2ac817c6b0225199 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 21 Feb 2022 17:12:32 -0500 Subject: [PATCH] wip: remove some shims --- src/core/CCInt.ml | 12 ++++++++++-- src/core/CCInt.mli | 10 ++++++++-- src/core/CCShims_.ml | 10 ++++++++++ src/core/CCUnit.ml | 13 +++++++++++++ src/core/dune | 4 ++-- src/core/mkshims.ml | 24 ------------------------ src/monomorphic/CCMonomorphic.ml | 5 ++++- src/monomorphic/dune | 13 +------------ src/monomorphic/mkshims.ml | 11 ----------- 9 files changed, 48 insertions(+), 54 deletions(-) create mode 100644 src/core/CCShims_.ml create mode 100644 src/core/CCUnit.ml delete mode 100644 src/monomorphic/mkshims.ml diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index 191a44ed..8f2e38f6 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -1,9 +1,17 @@ (* This file is free software, part of containers. See file "license" for more details. *) -open CCShims_ +[@@@ifge 4.07] +[@@@else_] -include CCShimsInt_ +module Stdlib = Pervasives +[@@@endif] + +[@@@ifge 4.08] + +include Int + +[@@@endif] type t = int type 'a iter = ('a -> unit) -> unit diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index 182a51df..d430f07b 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -3,8 +3,14 @@ (** Basic Int functions *) -include module type of CCShimsInt_ -(** @inline *) +[@@@ifge 4.08] + +include module type of Int +(** @inline + + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Int.html} Documentation for the standard Int module}*) + +[@@@endif] type t = int diff --git a/src/core/CCShims_.ml b/src/core/CCShims_.ml new file mode 100644 index 00000000..7fd31b22 --- /dev/null +++ b/src/core/CCShims_.ml @@ -0,0 +1,10 @@ + +[@@@ifge 4.07] + +module Stdlib = Stdlib + +[@@@else_] + +module Stdlib = Pervasives + +[@@@endif] diff --git a/src/core/CCUnit.ml b/src/core/CCUnit.ml new file mode 100644 index 00000000..9aee1240 --- /dev/null +++ b/src/core/CCUnit.ml @@ -0,0 +1,13 @@ + +[@@@ifge 4.08] + +include Unit + +[@@@else_] + +type t = unit +let[@inline] equal (_:t) (_:t) = true +let[@inline] compare (_:t) (_:t) = 0 +let to_string () = "()" + +[@@@endif] diff --git a/src/core/dune b/src/core/dune index d925f8d8..552b5e69 100644 --- a/src/core/dune +++ b/src/core/dune @@ -5,9 +5,9 @@ (libraries dune.configurator)) (rule - (targets CCShims_.ml CCShimsList_.ml + (targets CCShimsList_.ml CCShimsArray_.ml CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsMkLetList_.ml - CCShimsArrayLabels_.ml CCShimsInt_.ml CCUnit.ml) + CCShimsArrayLabels_.ml) (deps ./mkshims.exe) (action (run ./mkshims.exe))) diff --git a/src/core/mkshims.ml b/src/core/mkshims.ml index bcd8f075..33fe608a 100644 --- a/src/core/mkshims.ml +++ b/src/core/mkshims.ml @@ -4,10 +4,6 @@ let write_file f s = let out = open_out f in output_string out s; flush out; close_out out -let shims_pre_407 = "module Stdlib = Pervasives" - -let shims_post_407 = "module Stdlib = Stdlib" - let shims_fmt_pre_408 = " include Format let cc_update_funs funs f1 f2 = @@ -184,26 +180,10 @@ let shims_let_op_list_post_408 = end " -let shims_int_pre_408 = "" -let shims_int_post_408 = " - include Int - (** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Int.html} Documentation for the standard Int module}*) -" - -let shims_unit_before_408 = {| -type t = unit -let[@inline] equal (_:t) (_:t) = true -let[@inline] compare (_:t) (_:t) = 0 -let to_string () = "()" -|} - -let shims_unit_after_408 = "include Unit" - let () = C.main ~name:"mkshims" (fun c -> let version = C.ocaml_config_var_exn c "version" in let major, minor = Scanf.sscanf version "%u.%u" (fun maj min -> maj, min) in - write_file "CCShims_.ml" (if (major, minor) >= (4,7) then shims_post_407 else shims_pre_407); write_file "CCShimsList_.ml" (if (major, minor) >= (4,8) then shims_list_post_408 else shims_list_pre_408); write_file "CCShimsArray_.ml" (if (major, minor) >= (4,8) then shims_array_post_408 @@ -216,8 +196,4 @@ let () = write_file "CCShimsFormat_.ml" (if (major, minor) >= (4,8) then shims_fmt_post_408 else shims_fmt_pre_408); write_file "CCShimsMkLet_.ml" (if (major, minor) >= (4,8) then shims_let_op_post_408 else shims_let_op_pre_408); write_file "CCShimsMkLetList_.ml" (if (major, minor) >= (4,8) then shims_let_op_list_post_408 else shims_let_op_list_pre_408); - write_file "CCShimsInt_.ml" - (if (major, minor) >= (4,8) then shims_int_post_408 else shims_int_pre_408); - write_file "CCUnit.ml" - (if (major, minor) >= (4,8) then shims_unit_after_408 else shims_unit_before_408); ) diff --git a/src/monomorphic/CCMonomorphic.ml b/src/monomorphic/CCMonomorphic.ml index 462cf2b1..2810e5c3 100644 --- a/src/monomorphic/CCMonomorphic.ml +++ b/src/monomorphic/CCMonomorphic.ml @@ -1,7 +1,10 @@ (* This file is free software, part of containers. See file "license" for more details. *) -open CCMonomorphicShims_ +[@@@ifle 4.07] +[@@@else_] +module Stdlib = Pervasives +[@@@endif] let (=) : int -> int -> bool = Stdlib.(=) let (<>) : int -> int -> bool = Stdlib.(<>) diff --git a/src/monomorphic/dune b/src/monomorphic/dune index 318db32a..c01b2478 100644 --- a/src/monomorphic/dune +++ b/src/monomorphic/dune @@ -1,16 +1,5 @@ - -(executable - (name mkshims) - (modules mkshims) - (libraries dune.configurator)) - -(rule - (targets CCMonomorphicShims_.ml) - (deps ./mkshims.exe) - (action (with-stdout-to %{targets} (run ./mkshims.exe)))) - (library (name containers_monomorphic) (public_name containers.monomorphic) - (modules CCMonomorphic CCMonomorphicShims_) + (modules CCMonomorphic) (wrapped false)) diff --git a/src/monomorphic/mkshims.ml b/src/monomorphic/mkshims.ml deleted file mode 100644 index f391a32c..00000000 --- a/src/monomorphic/mkshims.ml +++ /dev/null @@ -1,11 +0,0 @@ - -module C = Configurator.V1 - -let shims_pre_408 = "module Stdlib = Pervasives" -let shims_post_408 = "module Stdlib = Stdlib" - -let () = - C.main ~name:"mkshims" (fun c -> - let version = C.ocaml_config_var_exn c "version" in - let major, minor = Scanf.sscanf version "%u.%u" (fun maj min -> maj, min) in - print_endline (if (major, minor) >= (4,8) then shims_post_408 else shims_pre_408))