Merge branch 'use-MBytes-set-and-get-char' into 'master'
[data_encoding] use MBytes.{get/set}_char to read/write binary data instead of int8 See merge request !174
This commit is contained in:
commit
deec250be7
@ -42,6 +42,7 @@ module Size = struct
|
|||||||
let bool = 1
|
let bool = 1
|
||||||
let int8 = 1
|
let int8 = 1
|
||||||
let uint8 = 1
|
let uint8 = 1
|
||||||
|
let char = 1
|
||||||
let int16 = 2
|
let int16 = 2
|
||||||
let uint16 = 2
|
let uint16 = 2
|
||||||
let int31 = 4
|
let int31 = 4
|
||||||
@ -847,7 +848,8 @@ let rec length : type x. x t -> x -> int = fun e ->
|
|||||||
ofs + Size.uint8
|
ofs + Size.uint8
|
||||||
|
|
||||||
let char v buf ofs =
|
let char v buf ofs =
|
||||||
uint8 (Char.code v) buf ofs
|
MBytes.set_char buf ofs v;
|
||||||
|
ofs + Size.char
|
||||||
|
|
||||||
let bool v buf ofs =
|
let bool v buf ofs =
|
||||||
uint8 (if v then 255 else 0) buf ofs
|
uint8 (if v then 255 else 0) buf ofs
|
||||||
@ -1012,9 +1014,8 @@ let rec length : type x. x t -> x -> int = fun e ->
|
|||||||
let uint8 buf ofs _len =
|
let uint8 buf ofs _len =
|
||||||
ofs + Size.uint8, MBytes.get_uint8 buf ofs
|
ofs + Size.uint8, MBytes.get_uint8 buf ofs
|
||||||
|
|
||||||
let char buf ofs len =
|
let char buf ofs _len =
|
||||||
let ofs, v = int8 buf ofs len in
|
ofs + Size.char, MBytes.get_char buf ofs
|
||||||
ofs, Char.chr v
|
|
||||||
|
|
||||||
let bool buf ofs len =
|
let bool buf ofs len =
|
||||||
let ofs, v = int8 buf ofs len in
|
let ofs, v = int8 buf ofs len in
|
||||||
|
Loading…
Reference in New Issue
Block a user