From e7c7bd5bed1125a1aa073fd1bf0797a2df42e6aa Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 18 Jul 2013 20:29:07 +0000 Subject: [PATCH] Allow bitstring to be compiled with Core. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (Patch by Andreas Garnæs) --- bitstring.ml | 6 ++++++ bitstring.mli | 4 ++++ pa_bitstring.ml | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bitstring.ml b/bitstring.ml index 1c51a73..c860c08 100644 --- a/bitstring.ml +++ b/bitstring.ml @@ -1212,3 +1212,9 @@ let hexdump_bitstring chan (data, off, len) = fprintf chan " |%s|\n%!" linechars ) else fprintf chan "\n%!" + +(*----------------------------------------------------------------------*) +(* Alias of functions shadowed by Core. *) + +let char_code = Char.code +let int32_of_int = Int32.of_int diff --git a/bitstring.mli b/bitstring.mli index 33f85f4..c23c321 100644 --- a/bitstring.mli +++ b/bitstring.mli @@ -1084,3 +1084,7 @@ val construct_int64_ee_unsigned : endian -> Buffer.t -> int64 -> int -> exn -> u val construct_string : Buffer.t -> string -> unit val construct_bitstring : Buffer.t -> bitstring -> unit + +(* Alias of functions shadowed by Core. *) +val char_code : char -> int +val int32_of_int : int -> int32 diff --git a/pa_bitstring.ml b/pa_bitstring.ml index 58fe1ed..5b7b16e 100644 --- a/pa_bitstring.ml +++ b/pa_bitstring.ml @@ -631,7 +631,7 @@ let output_bitmatch _loc bs cases = <:expr< let o = ($lid:original_off$ lsr 3) + $`int:field_byte_offset$ in - Char.code (String.unsafe_get $lid:data$ o) + Bitstring.char_code (String.unsafe_get $lid:data$ o) >> in <:expr< @@ -668,7 +668,7 @@ let output_bitmatch _loc bs cases = | 32 -> <:expr< (* must allocate a new zero each time *) - let zero = Int32.of_int 0 in + let zero = Bitstring.int32_of_int 0 in Bitstring.$lid:name$ $lid:data$ o zero >> | 64 -> -- 1.8.3.1