Skip to content
Snippets Groups Projects
Commit 90084ad4 authored by Valentin Perrelle's avatar Valentin Perrelle Committed by Virgile Prevosto
Browse files

[kernel] datatype: add Make_with_set_and_map and Make_with_hashtbl

parent 7e3623cb
No related branches found
No related tags found
No related merge requests found
......@@ -265,6 +265,17 @@ module type Hashtbl = sig
module Make(Data: S) : S with type t = Data.t t
end
module type S_with_set_and_map = sig
include S
module Set: Set with type elt = t
module Map: Map with type key = t
end
module type S_with_hashtbl = sig
include S
module Hashtbl: Hashtbl with type key = t
end
module type S_with_collections = sig
include S
module Set: Set with type elt = t
......@@ -1459,7 +1470,7 @@ end
(** {2 Simple type values} *)
(* ****************************************************************************)
module With_collections(X: S)(Info: Functor_info) = struct
module With_set_and_map(X: S)(Info: Functor_info) = struct
module D = X
include D
......@@ -1476,6 +1487,18 @@ module With_collections(X: S)(Info: Functor_info) = struct
(D)
(struct let module_name = Info.module_name ^ ".Map" end)
end
module Make_with_set_and_map(X: Make_input) =
With_set_and_map
(Make(X))
(struct let module_name = String.capitalize_ascii X.name end)
module With_hashtbl(X: S)(Info: Functor_info) = struct
module D = X
include D
module Hashtbl =
Hashtbl
(struct
......@@ -1503,6 +1526,16 @@ module With_collections(X: S)(Info: Functor_info) = struct
end
module Make_with_hashtbl(X: Make_input) =
With_hashtbl
(Make(X))
(struct let module_name = String.capitalize_ascii X.name end)
module With_collections(X: S)(Info: Functor_info) = struct
include (With_set_and_map(X)(Info) : S_with_set_and_map with type t = X.t)
include (With_hashtbl(X)(Info) : S_with_hashtbl with type t := X.t)
end
module Make_with_collections(X: Make_input) =
With_collections
(Make(X))
......
......@@ -267,6 +267,28 @@ module type Hashtbl = sig
end
(** A datatype for a type [t] extended with predefined hashtbl over [t].
@see <https://frama-c.com/download/frama-c-plugin-development-guide.pdf>
*)
module type S_with_hashtbl = sig
include S
module Hashtbl: Hashtbl with type key = t
(** @see <https://frama-c.com/download/frama-c-plugin-development-guide.pdf> *)
end
(** A datatype for a type [t] extended with predefined set and map over [t].
@see <https://frama-c.com/download/frama-c-plugin-development-guide.pdf>
*)
module type S_with_set_and_map = sig
include S
module Set: Set with type elt = t
(** @see <https://frama-c.com/download/frama-c-plugin-development-guide.pdf> *)
module Map: Map with type key = t
end
(** A datatype for a type [t] extended with predefined set, map and hashtbl
over [t].
......@@ -282,6 +304,28 @@ module type S_with_collections = sig
(** @see <https://frama-c.com/download/frama-c-plugin-development-guide.pdf> *)
end
(** Generic comparable datatype builder: functions [equal] and [compare] must
not be {!undefined}. *)
module Make_with_set_and_map(X: Make_input):
S_with_set_and_map with type t = X.t
(** Add sets and maps to an existing datatype, provided the [equal] and
[compare] are not {!undefined}.
@since Oxygen-20120901 *)
module With_set_and_map(X: S)(_: Functor_info):
S_with_set_and_map with type t = X.t
(** Generic comparable datatype builder: functions [equal] and [hash] must not
be {!undefined}. *)
module Make_with_hashtbl(X: Make_input):
S_with_hashtbl with type t = X.t
(** Add hashtables modules to an existing datatype, provided the [equal] and
[hash] functions are not {!undefined}.
@since Oxygen-20120901 *)
module With_hashtbl(X: S)(_: Functor_info):
S_with_hashtbl with type t = X.t
(** Generic comparable datatype builder: functions [equal], [compare] and
[hash] must not be {!undefined}. *)
module Make_with_collections(X: Make_input):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment