Skip to content

Commit

Permalink
Irmin.Type: support for >256 variant cases
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Mar 13, 2019
1 parent ff8d0b2 commit 66571c1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/irmin/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,8 @@ module Size_of = struct

and variant: type a. a variant -> a size_of = fun v ?headers:_ x ->
match v.vget x with
| CV0 _ -> char '\000'
| CV1 (x, vx) -> `Size (size (char '\000') + size (t x.ctype1 vx))
| CV0 v -> int v.ctag0
| CV1 (x, vx) -> `Size (size (int x.ctag1) + size (t x.ctype1 vx))

end

Expand Down Expand Up @@ -1240,9 +1240,9 @@ module Encode_bin = struct

and case_v: type a. a case_v encode_bin = fun ?headers:_ buf c ->
match c with
| CV0 c -> char buf (char_of_int c.ctag0)
| CV0 c -> int buf c.ctag0
| CV1 (c, v) ->
char buf (char_of_int c.ctag1);
int buf c.ctag1;
t c.ctype1 buf v

end
Expand Down Expand Up @@ -1400,9 +1400,8 @@ module Decode_bin = struct
and field: type a b. (a, b) field -> b decode_bin = fun f -> t f.ftype

and variant: type a. a variant -> a decode_bin = fun v ?headers:_ buf ofs ->
(* FIXME: we support 'only' 256 variants *)
char buf ofs >>= fun (ofs, i) ->
case v.vcases.(int_of_char i) buf ofs
int buf ofs >>= fun (ofs, i) ->
case v.vcases.(i) buf ofs

and case: type a. a a_case -> a decode_bin = fun c ?headers:_ buf ofs ->
match c with
Expand Down

0 comments on commit 66571c1

Please sign in to comment.