diff --git a/src/data/CCBitField.ml b/src/data/CCBitField.ml index 873e4ede..a063e397 100644 --- a/src/data/CCBitField.ml +++ b/src/data/CCBitField.ml @@ -9,12 +9,17 @@ let max_width = Sys.word_size - 2 module type EMPTY = sig end -module type BITFIELD = sig +module type S = sig type t = private int + (** Generative type of bitfields. Each instantiation of the functor + should create a new, incompatible type *) val empty : t + (** Empty bitfields (all bits 0) *) type 'a field + (** Field of type ['a], with a given width and position within the + bitfield type *) val get : 'a field -> t -> 'a (** Get a field of type ['a] *) @@ -29,17 +34,17 @@ module type BITFIELD = sig (** Informal name of the field *) val bool : ?name:string -> unit -> bool field - (** New field of type boo + (** New field of type bool @raise Frozen if [freeze ()] was called @raise TooManyFields if there is no room *) val int2 : ?name:string -> unit -> int field - (** New field of type 2-bits int + (** New field of type 2-bits int (same as [int ~width:2]) @raise Frozen if [freeze ()] was called @raise TooManyFields if there is no room *) val int3 : ?name:string -> unit -> int field - (** New field for 3-bits int + (** New field for 3-bits int (same as [int ~width:3]) @raise Frozen if [freeze ()] was called @raise TooManyFields if there is no room *) @@ -49,7 +54,8 @@ module type BITFIELD = sig @raise TooManyFields if there is no room *) val freeze : unit -> unit - (** Prevent new fields from being added *) + (** Prevent new fields from being added. From now on, creating + a field will raise Frozen *) val total_width : unit -> int (** Current width of the bitfield *) @@ -76,7 +82,7 @@ let rec all_bits_ acc w = all_bits_ 0 4 = 15 *) -module Make(X : EMPTY) : BITFIELD = struct +module Make(X : EMPTY) : S = struct type t = int let empty = 0 diff --git a/src/data/CCBitField.mli b/src/data/CCBitField.mli index b7da8920..0d7173a4 100644 --- a/src/data/CCBitField.mli +++ b/src/data/CCBitField.mli @@ -38,12 +38,17 @@ val max_width : int (** System-dependent maximum width for a bitfield *) (** {2 Bitfield Signature} *) -module type BITFIELD = sig +module type S = sig type t = private int + (** Generative type of bitfields. Each instantiation of the functor + should create a new, incompatible type *) val empty : t + (** Empty bitfields (all bits 0) *) type 'a field + (** Field of type ['a], with a given width and position within the + bitfield type *) val get : 'a field -> t -> 'a (** Get a field of type ['a] *) @@ -58,17 +63,17 @@ module type BITFIELD = sig (** Informal name of the field *) val bool : ?name:string -> unit -> bool field - (** New field of type boo + (** New field of type bool @raise Frozen if [freeze ()] was called @raise TooManyFields if there is no room *) val int2 : ?name:string -> unit -> int field - (** New field of type 2-bits int + (** New field of type 2-bits int (same as [int ~width:2]) @raise Frozen if [freeze ()] was called @raise TooManyFields if there is no room *) val int3 : ?name:string -> unit -> int field - (** New field for 3-bits int + (** New field for 3-bits int (same as [int ~width:3]) @raise Frozen if [freeze ()] was called @raise TooManyFields if there is no room *) @@ -78,7 +83,8 @@ module type BITFIELD = sig @raise TooManyFields if there is no room *) val freeze : unit -> unit - (** Prevent new fields from being added *) + (** Prevent new fields from being added. From now on, creating + a field will raise Frozen *) val total_width : unit -> int (** Current width of the bitfield *) @@ -93,7 +99,7 @@ module type BITFIELD = sig end (** Create a new bitfield type *) -module Make(X : EMPTY) : BITFIELD +module Make(X : EMPTY) : S (*$R let module B = CCBitField.Make(struct end) in