Data_encoding: skip zero_width field in binary description

This commit is contained in:
Grégoire Henry 2018-05-31 12:42:05 +02:00 committed by Benjamin Canou
parent 7c2ef081d5
commit 6922a793fe

View File

@ -157,12 +157,15 @@ let describe (type x) ?toplevel_name (encoding : x Encoding.t) =
| Dft { name ; encoding = { encoding } } -> | Dft { name ; encoding = { encoding } } ->
let (dynamics, ref_name, P field) = extract_dynamic None encoding in let (dynamics, ref_name, P field) = extract_dynamic None encoding in
let (layout, references) = layout ref_name recursives references field in let (layout, references) = layout ref_name recursives references field in
let field_descr = if layout = Zero_width && dynamics then
Binary_schema.Named_field (name, classify_desc field, layout) in ([], references) (* FIXME what if (dynamic_size empty) ?? *)
if dynamics then
([ Dynamic_field 1 ; field_descr ], references)
else else
([ field_descr], references) let field_descr =
Binary_schema.Named_field (name, classify_desc field, layout) in
if dynamics then
([ Dynamic_field 1 ; field_descr ], references)
else
([ field_descr], references)
| Opt { kind = `Variable ; name ; encoding = { encoding } } -> | Opt { kind = `Variable ; name ; encoding = { encoding } } ->
let (layout, references) = let (layout, references) =
layout None recursives references encoding in layout None recursives references encoding in
@ -274,7 +277,10 @@ let describe (type x) ?toplevel_name (encoding : x Encoding.t) =
| Tup { encoding } -> | Tup { encoding } ->
let (layout, references) = let (layout, references) =
layout ref_name recursives references encoding in layout ref_name recursives references encoding in
([ Anonymous_field (classify_desc encoding, layout) ], references) if layout = Zero_width then
([], references)
else
([ Anonymous_field (classify_desc encoding, layout) ], references)
| Tups { left ; right } -> | Tups { left ; right } ->
let (fields1, references) = let (fields1, references) =
fields None recursives references left.encoding in fields None recursives references left.encoding in