mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
wip: remove some shims
This commit is contained in:
parent
3d87d2672e
commit
59407b0f5e
9 changed files with 48 additions and 54 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
10
src/core/CCShims_.ml
Normal file
10
src/core/CCShims_.ml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
[@@@ifge 4.07]
|
||||
|
||||
module Stdlib = Stdlib
|
||||
|
||||
[@@@else_]
|
||||
|
||||
module Stdlib = Pervasives
|
||||
|
||||
[@@@endif]
|
||||
13
src/core/CCUnit.ml
Normal file
13
src/core/CCUnit.ml
Normal file
|
|
@ -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]
|
||||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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.(<>)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
Loading…
Add table
Reference in a new issue