Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enhance] opabsl: binary is now Buf.t in OCaml.

  • Loading branch information...
commit 0b98f85f9e947cab01c7c1654143a4a95ed2a972 1 parent 0636c81
@arthuraa arthuraa authored
View
8 lib/plugins/iconv/bslIconv.ml
@@ -1,7 +1,7 @@
##extern-type Iconv.t = Iconv.iconv_t
##property[mli]
-##extern-type binary = Buffer.t
+##extern-type binary = Buf.t
##property[endmli]
##register iconv_open : string, string -> Iconv.t
@@ -10,9 +10,9 @@ let iconv_open tocode fromcode = Iconv.iconv_open ~tocode ~fromcode
##register iconv : Iconv.t, binary -> opa[option(binary)]
let iconv t s =
try
- let s = Iconv.iconv_prim t (Buffer.contents s) in
- let x = Buffer.create (String.length s) in
- Buffer.add_string x s;
+ let s = Iconv.iconv_prim t (Buf.contents s) in
+ let x = Buf.create (String.length s) in
+ Buf.add_string x s;
ServerLib.some (x)
with
Failure s -> ServerLib.none
View
299 lib/plugins/opabsl/mlbsl/bslBinary.ml
@@ -1,43 +1,44 @@
+##property[mli]
+##extern-type binary = Buf.t
+##property[endmli]
-##extern-type binary = Buffer.t
+##register create\ `Buf.create`: int -> binary
-##register create\ `Buffer.create`: int -> binary
-
-##register length\ `Buffer.length`: binary -> int
+##register length\ `Buf.length`: binary -> int
##register binary_of_string : string -> binary
let binary_of_string s =
- let b = Buffer.create (String.length s) in
- Buffer.add_string b s;
+ let b = Buf.create (String.length s) in
+ Buf.add_string b s;
b
-##register string_of_binary\ `Buffer.contents`: binary -> string
+##register string_of_binary\ `Buf.contents`: binary -> string
##register resize : binary, int -> void
let resize b size =
(* There's no way of changing the hint size for OCaml buffers *)
- let len = Buffer.length b in
+ let len = Buf.length b in
if size <> len
then
- let s = if size < len then Buffer.sub b 0 size else Buffer.contents b in
- Buffer.reset b;
- Buffer.add_string b s
+ let s = if size < len then Buf.sub b 0 size else Buf.contents b in
+ Buf.reset b;
+ Buf.add_string b s
-##register clear\ `Buffer.clear`: binary -> void
+##register clear\ `Buf.clear`: binary -> void
##register trim: binary -> void
let trim b =
- let s = Buffer.contents b in
- let b = Buffer.create (String.length s) in
- Buffer.add_string b s
+ let s = Buf.contents b in
+ let b = Buf.create (String.length s) in
+ Buf.add_string b s
-##register reset\ `Buffer.reset`: binary -> void
+##register reset\ `Buf.reset`: binary -> void
-##register add_string\ `Buffer.add_string`: binary, string -> void
+##register add_string\ `Buf.add_string`: binary, string -> void
##register add_binary : binary, binary -> void
let add_binary b nb =
- Buffer.add_string b (Buffer.contents nb)
+ Buf.add_string b (Buf.contents nb)
exception BslBinaryError of string
let error str = raise (BslBinaryError str)
@@ -45,38 +46,38 @@ let error str = raise (BslBinaryError str)
##register add_int8 : binary, int -> void
let add_int8 b i =
(* if (i < -0x80 || i > 0x7f) then error (Printf.sprintf "BslBinary.add_int8: out of range int %d" i); *)
- Buffer.add_char b (Char.chr (if i < 0 then i+0x100 else i))
+ Buf.add_char b (Char.chr (if i < 0 then i+0x100 else i))
##register add_uint8 : binary, int -> void
let add_uint8 b i =
(* if (i < 0 || i > 0xff) then error (Printf.sprintf "BslBinary.add_uint8: out of range int %d" i); *)
- Buffer.add_char b (Char.chr i)
+ Buf.add_char b (Char.chr i)
##register add_int16_le : binary, int -> void
let add_int16_le b i =
(* if (i < -0x8000 || i > 0x7fff) then error (Printf.sprintf "BslBinary.add_int16_le: out of range int %d" i); *)
let i = if i < 0 then 0x10000 + i else i in
- Buffer.add_char b (Char.chr ( i land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff))
+ Buf.add_char b (Char.chr ( i land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff))
##register add_int16_be : binary, int -> void
let add_int16_be b i =
(* if (i < -0x8000 || i > 0x7fff) then error (Printf.sprintf "BslBinary.add_int16_be: out of range int %d" i); *)
let i = if i < 0 then 0x10000 + i else i in
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff));
- Buffer.add_char b (Char.chr ( i land 0xff))
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff));
+ Buf.add_char b (Char.chr ( i land 0xff))
##register add_uint16_le : binary, int -> void
let add_uint16_le b i =
(* if (i < 0 || i > 0xffff) then error (Printf.sprintf "BslBinary.add_uint16_le: out of range int %d" i); *)
- Buffer.add_char b (Char.chr ( i land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff))
+ Buf.add_char b (Char.chr ( i land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff))
##register add_uint16_be : binary, int -> void
let add_uint16_be b i =
(* if (i < 0 || i > 0xffff) then error (Printf.sprintf "BslBinary.add_uint16_be: out of range int %d" i); *)
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff));
- Buffer.add_char b (Char.chr ( i land 0xff))
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff));
+ Buf.add_char b (Char.chr ( i land 0xff))
let _0x100000000 =
#<Ifstatic:OCAML_WORD_SIZE 64>
@@ -89,57 +90,57 @@ let _0x100000000 =
let add_int32_le b i =
(* if (i < -0x80000000 || i > 0x7fffffff) then error (Printf.sprintf "BslBinary.add_int32_le: out of range int %d" i); *)
let i = if i < 0 then _0x100000000 + i else i in
- Buffer.add_char b (Char.chr ( i land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 16) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 24) land 0xff))
+ Buf.add_char b (Char.chr ( i land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 16) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 24) land 0xff))
##register add_int32_be : binary, int -> void
let add_int32_be b i =
(* if (i < -0x80000000 || i > 0x7fffffff) then error (Printf.sprintf "BslBinary.add_int32_be: out of range int %d" i); *)
let i = if i < 0 then _0x100000000 + i else i in
- Buffer.add_char b (Char.chr ((i lsr 24) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 16) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff));
- Buffer.add_char b (Char.chr ( i land 0xff))
+ Buf.add_char b (Char.chr ((i lsr 24) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 16) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff));
+ Buf.add_char b (Char.chr ( i land 0xff))
##register add_uint32_le : binary, int -> void
let add_uint32_le b i =
(* if (i < 0 || i > 0xffffffff) then error (Printf.sprintf "BslBinary.add_uint32_le: out of range int %d" i); *)
- Buffer.add_char b (Char.chr ( i land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 16) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 24) land 0xff))
+ Buf.add_char b (Char.chr ( i land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 16) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 24) land 0xff))
##register add_uint32_be : binary, int -> void
let add_uint32_be b i =
(* if (i < 0 || i > 0xffffffff) then error (Printf.sprintf "BslBinary.add_uint32_be: out of range int %d" i); *)
- Buffer.add_char b (Char.chr ((i lsr 24) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 16) land 0xff));
- Buffer.add_char b (Char.chr ((i lsr 8 ) land 0xff));
- Buffer.add_char b (Char.chr ( i land 0xff))
+ Buf.add_char b (Char.chr ((i lsr 24) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 16) land 0xff));
+ Buf.add_char b (Char.chr ((i lsr 8 ) land 0xff));
+ Buf.add_char b (Char.chr ( i land 0xff))
##register add_uint64_le : binary, int64 -> void
let add_uint64_le b i =
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)))
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)))
##register add_uint64_be : binary, int64 -> void
let add_uint64_be b i =
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)))
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)))
##register add_int53_le : binary, int -> void
let add_int53_le b i =
@@ -159,97 +160,97 @@ let _FLOATMAX32 = 3.402823466e38
let add_float_le b f =
(* if f < _FLOATMIN32 || f > _FLOATMAX32 then error (Printf.sprintf "BslBinary.add_float_le: out of range float %g" f); *)
let i = Int32.bits_of_float f in
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand ( i ) 0xffl)));
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 8 ) 0xffl)));
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 16) 0xffl)));
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 24) 0xffl)))
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand ( i ) 0xffl)));
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 8 ) 0xffl)));
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 16) 0xffl)));
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 24) 0xffl)))
##register add_float_be : binary, float -> void
let add_float_be b f =
(* if f < _FLOATMIN32 || f > _FLOATMAX32 then error (Printf.sprintf "BslBinary.add_float_le: out of range float %g" f); *)
let i = Int32.bits_of_float f in
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 24) 0xffl)));
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 16) 0xffl)));
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 8 ) 0xffl)));
- Buffer.add_char b (Char.chr (Int32.to_int (Int32.logand ( i ) 0xffl)))
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 24) 0xffl)));
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 16) 0xffl)));
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand (Int32.shift_right_logical i 8 ) 0xffl)));
+ Buf.add_char b (Char.chr (Int32.to_int (Int32.logand ( i ) 0xffl)))
##register add_double_le : binary, float -> void
let add_double_le b f =
let i = Int64.bits_of_float f in
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)))
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)))
##register add_double_be : binary, float -> void
let add_double_be b f =
let i = Int64.bits_of_float f in
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
- Buffer.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)))
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 56) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 48) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 40) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 32) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 24) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 16) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand (Int64.shift_right_logical i 8 ) 0xffL)));
+ Buf.add_char b (Char.chr (Int64.to_int (Int64.logand ( i ) 0xffL)))
##register get_string : binary, int, int -> string
let get_string b start length =
- Buffer.sub b start length
+ Buf.sub b start length
##register get_binary : binary, int, int -> binary
let get_binary b start length =
- let blen = Buffer.length b in
+ let blen = Buf.length b in
if start < 0 || start >= blen || length < 0
- then Buffer.create 0
+ then Buf.create 0
else
- try binary_of_string (Buffer.sub b start (if blen < start + length then blen - start else length))
- with Invalid_argument _ -> Buffer.create 0
+ try binary_of_string (Buf.sub b start (if blen < start + length then blen - start else length))
+ with Invalid_argument _ -> Buf.create 0
##register get_int8 : binary, int -> int
let get_int8 b start =
- if start >= Buffer.length b then error "BslBinary.get_int8: insufficient buffer data";
- let i = Char.code (Buffer.nth b start) in
+ if start >= Buf.length b then error "BslBinary.get_int8: insufficient buffer data";
+ let i = Char.code (Buf.nth b start) in
if i > 0x7f then i - 0x100 else i
##register get_uint8 : binary, int -> int
let get_uint8 b start =
- if start >= Buffer.length b then error "BslBinary.get_uint8: insufficient buffer data";
- Char.code (Buffer.nth b start)
+ if start >= Buf.length b then error "BslBinary.get_uint8: insufficient buffer data";
+ Char.code (Buf.nth b start)
##register get_int16_le : binary, int -> int
let get_int16_le b start =
- if start > Buffer.length b - 2 then error "BslBinary.get_int16_le: insufficient buffer data";
+ if start > Buf.length b - 2 then error "BslBinary.get_int16_le: insufficient buffer data";
let i =
- (Char.code (Buffer.nth b start ) land 0x00ff)
- lor (((Char.code (Buffer.nth b (start + 1))) lsl 8) land 0xff00)
+ (Char.code (Buf.nth b start ) land 0x00ff)
+ lor (((Char.code (Buf.nth b (start + 1))) lsl 8) land 0xff00)
in
if i > 0x7fff then i - 0x10000 else i
##register get_int16_be : binary, int -> int
let get_int16_be b start =
- if start > Buffer.length b - 2 then error "BslBinary.get_int16_be: insufficient buffer data";
+ if start > Buf.length b - 2 then error "BslBinary.get_int16_be: insufficient buffer data";
let i =
- (Char.code (Buffer.nth b (start + 1) ) land 0x00ff)
- lor (((Char.code (Buffer.nth b start )) lsl 8) land 0xff00)
+ (Char.code (Buf.nth b (start + 1) ) land 0x00ff)
+ lor (((Char.code (Buf.nth b start )) lsl 8) land 0xff00)
in
if i > 0x7fff then i - 0x10000 else i
##register get_uint16_le : binary, int -> int
let get_uint16_le b start =
- if start > Buffer.length b - 2 then error "BslBinary.get_uint16_le: insufficient buffer data";
- (Char.code (Buffer.nth b start ) land 0x00ff)
- lor (((Char.code (Buffer.nth b (start + 1))) lsl 8) land 0xff00)
+ if start > Buf.length b - 2 then error "BslBinary.get_uint16_le: insufficient buffer data";
+ (Char.code (Buf.nth b start ) land 0x00ff)
+ lor (((Char.code (Buf.nth b (start + 1))) lsl 8) land 0xff00)
##register get_uint16_be : binary, int -> int
let get_uint16_be b start =
- if start > Buffer.length b - 2 then error "BslBinary.get_uint16_be: insufficient buffer data";
- (Char.code (Buffer.nth b (start + 1) ) land 0x00ff)
- lor (((Char.code (Buffer.nth b start )) lsl 8) land 0xff00)
+ if start > Buf.length b - 2 then error "BslBinary.get_uint16_be: insufficient buffer data";
+ (Char.code (Buf.nth b (start + 1) ) land 0x00ff)
+ lor (((Char.code (Buf.nth b start )) lsl 8) land 0xff00)
let _0xff000000 =
#<Ifstatic:OCAML_WORD_SIZE 64>
@@ -261,12 +262,12 @@ let _0xff000000 =
##register get_int32_le : binary, int -> int
let get_int32_le b start =
- if start > Buffer.length b - 4 then error "BslBinary.get_int32_le: insufficient buffer data";
+ if start > Buf.length b - 4 then error "BslBinary.get_int32_le: insufficient buffer data";
let i =
- (Char.code (Buffer.nth b start ) land 0x000000ff)
- lor (((Char.code (Buffer.nth b (start + 1))) lsl 8 ) land 0x0000ff00)
- lor (((Char.code (Buffer.nth b (start + 2))) lsl 16) land 0x00ff0000)
- lor (((Char.code (Buffer.nth b (start + 3))) lsl 24) land _0xff000000)
+ (Char.code (Buf.nth b start ) land 0x000000ff)
+ lor (((Char.code (Buf.nth b (start + 1))) lsl 8 ) land 0x0000ff00)
+ lor (((Char.code (Buf.nth b (start + 2))) lsl 16) land 0x00ff0000)
+ lor (((Char.code (Buf.nth b (start + 3))) lsl 24) land _0xff000000)
in
#<Ifstatic:OCAML_WORD_SIZE 64>
if i > 0x7fffffff then i - 0x100000000 else i
@@ -276,12 +277,12 @@ let get_int32_le b start =
##register get_int32_be : binary, int -> int
let get_int32_be b start =
- if start > Buffer.length b - 4 then error "BslBinary.get_int32_be: insufficient buffer data";
+ if start > Buf.length b - 4 then error "BslBinary.get_int32_be: insufficient buffer data";
let i =
- (Char.code (Buffer.nth b (start + 3) ) land 0x000000ff)
- lor (((Char.code (Buffer.nth b (start + 2))) lsl 8 ) land 0x0000ff00)
- lor (((Char.code (Buffer.nth b (start + 1))) lsl 16) land 0x00ff0000)
- lor (((Char.code (Buffer.nth b start )) lsl 24) land _0xff000000)
+ (Char.code (Buf.nth b (start + 3) ) land 0x000000ff)
+ lor (((Char.code (Buf.nth b (start + 2))) lsl 8 ) land 0x0000ff00)
+ lor (((Char.code (Buf.nth b (start + 1))) lsl 16) land 0x00ff0000)
+ lor (((Char.code (Buf.nth b start )) lsl 24) land _0xff000000)
in
#<Ifstatic:OCAML_WORD_SIZE 64>
if i > 0x7fffffff then i - 0x100000000 else i
@@ -291,39 +292,39 @@ let get_int32_be b start =
##register get_uint32_le : binary, int -> int
let get_uint32_le b start =
- if start > Buffer.length b - 4 then error "BslBinary.get_uint32_le: insufficient buffer data";
- (Char.code (Buffer.nth b start ) land 0x000000ff)
- lor (((Char.code (Buffer.nth b (start + 1))) lsl 8 ) land 0x0000ff00)
- lor (((Char.code (Buffer.nth b (start + 2))) lsl 16) land 0x00ff0000)
- lor (((Char.code (Buffer.nth b (start + 3))) lsl 24) land _0xff000000)
+ if start > Buf.length b - 4 then error "BslBinary.get_uint32_le: insufficient buffer data";
+ (Char.code (Buf.nth b start ) land 0x000000ff)
+ lor (((Char.code (Buf.nth b (start + 1))) lsl 8 ) land 0x0000ff00)
+ lor (((Char.code (Buf.nth b (start + 2))) lsl 16) land 0x00ff0000)
+ lor (((Char.code (Buf.nth b (start + 3))) lsl 24) land _0xff000000)
##register get_uint32_be : binary, int -> int
let get_uint32_be b start =
- if start > Buffer.length b - 4 then error "BslBinary.get_uint32_be: insufficient buffer data";
- (Char.code (Buffer.nth b (start + 3) ) land 0x000000ff)
- lor (((Char.code (Buffer.nth b (start + 2))) lsl 8 ) land 0x0000ff00)
- lor (((Char.code (Buffer.nth b (start + 1))) lsl 16) land 0x00ff0000)
- lor (((Char.code (Buffer.nth b start )) lsl 24) land _0xff000000)
+ if start > Buf.length b - 4 then error "BslBinary.get_uint32_be: insufficient buffer data";
+ (Char.code (Buf.nth b (start + 3) ) land 0x000000ff)
+ lor (((Char.code (Buf.nth b (start + 2))) lsl 8 ) land 0x0000ff00)
+ lor (((Char.code (Buf.nth b (start + 1))) lsl 16) land 0x00ff0000)
+ lor (((Char.code (Buf.nth b start )) lsl 24) land _0xff000000)
let get_int64_le b p =
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+7)))) 56) 0xff00000000000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+6)))) 48) 0x00ff000000000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+5)))) 40) 0x0000ff0000000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+4)))) 32) 0x000000ff00000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+3)))) 24) 0x00000000ff000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+2)))) 16) 0x0000000000ff0000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+1)))) 8) 0x000000000000ff00L)
- (Int64.logand ( (Int64.of_int (Char.code (Buffer.nth b p ))) ) 0x00000000000000ffL))))))))
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+7)))) 56) 0xff00000000000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+6)))) 48) 0x00ff000000000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+5)))) 40) 0x0000ff0000000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+4)))) 32) 0x000000ff00000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+3)))) 24) 0x00000000ff000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+2)))) 16) 0x0000000000ff0000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+1)))) 8) 0x000000000000ff00L)
+ (Int64.logand ( (Int64.of_int (Char.code (Buf.nth b p ))) ) 0x00000000000000ffL))))))))
let get_int64_be b p =
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b p ))) 56) 0xff00000000000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+1)))) 48) 0x00ff000000000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+2)))) 40) 0x0000ff0000000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+3)))) 32) 0x000000ff00000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+4)))) 24) 0x00000000ff000000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+5)))) 16) 0x0000000000ff0000L)
- (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buffer.nth b (p+6)))) 8) 0x000000000000ff00L)
- (Int64.logand ( (Int64.of_int (Char.code (Buffer.nth b (p+7)))) ) 0x00000000000000ffL))))))))
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b p ))) 56) 0xff00000000000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+1)))) 48) 0x00ff000000000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+2)))) 40) 0x0000ff0000000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+3)))) 32) 0x000000ff00000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+4)))) 24) 0x00000000ff000000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+5)))) 16) 0x0000000000ff0000L)
+ (Int64.logor (Int64.logand (Int64.shift_left (Int64.of_int (Char.code (Buf.nth b (p+6)))) 8) 0x000000000000ff00L)
+ (Int64.logand ( (Int64.of_int (Char.code (Buf.nth b (p+7)))) ) 0x00000000000000ffL))))))))
##register get_int53_le : binary, int -> int
let get_int53_le b p = Int64.to_int (get_int64_le b p) (* will overflow *)
@@ -340,18 +341,18 @@ let get_uint64_be b p = get_int64_be b p (* it's actually signed *)
##register get_float_le : binary, int -> float
let get_float_le b p =
Int32.float_of_bits
- (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buffer.nth b (p+3)))) 24) 0xff000000l)
- (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buffer.nth b (p+2)))) 16) 0x00ff0000l)
- (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buffer.nth b (p+1)))) 8) 0x0000ff00l)
- (Int32.logand ( (Int32.of_int (Char.code (Buffer.nth b p ))) ) 0x000000ffl))))
+ (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buf.nth b (p+3)))) 24) 0xff000000l)
+ (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buf.nth b (p+2)))) 16) 0x00ff0000l)
+ (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buf.nth b (p+1)))) 8) 0x0000ff00l)
+ (Int32.logand ( (Int32.of_int (Char.code (Buf.nth b p ))) ) 0x000000ffl))))
##register get_float_be : binary, int -> float
let get_float_be b p =
Int32.float_of_bits
- (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buffer.nth b p ))) 24) 0xff000000l)
- (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buffer.nth b (p+1)))) 16) 0x00ff0000l)
- (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buffer.nth b (p+2)))) 8) 0x0000ff00l)
- (Int32.logand ( (Int32.of_int (Char.code (Buffer.nth b (p+3)))) ) 0x000000ffl))))
+ (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buf.nth b p ))) 24) 0xff000000l)
+ (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buf.nth b (p+1)))) 16) 0x00ff0000l)
+ (Int32.logor (Int32.logand (Int32.shift_left (Int32.of_int (Char.code (Buf.nth b (p+2)))) 8) 0x0000ff00l)
+ (Int32.logand ( (Int32.of_int (Char.code (Buf.nth b (p+3)))) ) 0x000000ffl))))
##register get_double_le : binary, int -> float
let get_double_le b p = Int64.float_of_bits (get_int64_le b p)
View
4 lib/plugins/opabsl/mlbsl/bslPervasivesServer.ml
@@ -16,6 +16,6 @@ let flush_all () = Pervasives.flush_all ()
##register bin_of_base64 : string -> binary
let bin_of_base64 s =
let s = BaseString.base64decode s in
- let b = Buffer.create (String.length s) in
- Buffer.add_string b s;
+ let b = Buf.create (String.length s) in
+ Buf.add_string b s;
b
View
8 lib/plugins/server/bslNet.ml
@@ -22,7 +22,7 @@ let default_scheduler = BslScheduler.opa
##extern-type caml_list('a) = 'a list
##extern-type endpoint = Hlnet.endpoint
##extern-type llarray('a) = Obj.t array
-##extern-type binary = Buffer.t
+##extern-type binary = Buf.t
##property[endmli]
let caml_list_to_opa_list = BslNativeLib.caml_list_to_opa_list
@@ -182,7 +182,7 @@ let opa_list_to_ocaml_list = BslNativeLib.opa_list_to_ocaml_list
let make_response ms req stat headers s1 s2 k =
let modified_since = Option.map Time.milliseconds ms in
HttpServer.make_response_with_headers ~modified_since ~req headers stat s1
- (Http_common.Result (Buffer.contents s2)) (function r -> QmlCpsServerLib.return k r)
+ (Http_common.Result (Buf.contents s2)) (function r -> QmlCpsServerLib.return k r)
##register [cps-bypass] make_response_modified_since : \
option(time_t), \
@@ -194,7 +194,7 @@ let opa_list_to_ocaml_list = BslNativeLib.opa_list_to_ocaml_list
let make_response_modified_since modified_since req stat s1 s2 k =
let ms = Option.map Time.milliseconds modified_since in
HttpServer.make_response ~modified_since:ms ~expires:Time.zero ~req stat s1
- (Http_common.Result (Buffer.contents s2)) (function r -> QmlCpsServerLib.return k r)
+ (Http_common.Result (Buf.contents s2)) (function r -> QmlCpsServerLib.return k r)
##register [cps-bypass] make_response_expires_at : \
option(time_t), \
@@ -212,7 +212,7 @@ let opa_list_to_ocaml_list = BslNativeLib.opa_list_to_ocaml_list
in
let modified_since = Option.map Time.milliseconds modified_since in
HttpServer.make_response ~expires ~modified_since ~req stat s1
- (Http_common.Result (Buffer.contents s2)) (function r -> QmlCpsServerLib.return k r)
+ (Http_common.Result (Buf.contents s2)) (function r -> QmlCpsServerLib.return k r)
##register [cps-bypass] make_response_req : time_t, WebInfo.private.native_request, web_server_status, string, string, \
continuation(WebInfo.private.native_response) -> void
View
8 lib/plugins/unix/bslFile.ml
@@ -15,7 +15,7 @@ module U = Unix
##property[mli]
##extern-type time_t = int
##extern-type continuation('a) = 'a QmlCpsServerLib.continuation
-##extern-type binary = Buffer.t
+##extern-type binary = Buf.t
(** *****************************)
##register mlstate_dir : void -> string
@@ -110,14 +110,14 @@ let remove_rec file = ignore (File.remove_rec file)
let path = Filename.dirname n in
ignore (File.check_create_path path);
open_out n
- in output_string och (Buffer.contents content) ; close_out och
+ in output_string och (Buf.contents content) ; close_out och
##register create_full_path: string -> void
let create_full_path path = ignore (File.check_create_path path)
let buffer_of_string s =
- let b = Buffer.create (String.length s) in
- Buffer.add_string b s;
+ let b = Buf.create (String.length s) in
+ Buf.add_string b s;
b
##register content_opt: string -> option(binary)
Please sign in to comment.
Something went wrong with that request. Please try again.