Commit f2099695 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

[mojo-bindings] Fix JS lite serialization

Fixes mojom JS lite serialization in cases where fields are
intentionally packed out of order.

This actually simplifies the serialization and deserialization logic
significantly by leveraging precomputed byte/bit offset values from
the bindings generator and preallocating the entire message buffer
prior to serialization.

It also is now correct instead of incorrect, which is nice.

Bug: 904861
Change-Id: If08c301303004d164f4a0afcc3085dac86ca3089
Reviewed-on: https://chromium-review.googlesource.com/c/1335269Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#607980}
parent aed4a114
This diff is collapsed.
......@@ -2,10 +2,13 @@
mojo.mojom.Struct(
{{struct.name}},
'{{struct.name}}',
{{struct.packed|payload_size}},
[
{%- for packed_field in struct.packed.packed_fields %}
{%- for packed_field in struct.packed.packed_fields_in_ordinal_order %}
mojo.mojom.StructField(
'{{packed_field.field.name}}',
'{{packed_field.field.name}}', {{packed_field.offset}},
{% if packed_field.field.kind|is_bool_kind %}{{packed_field.bit}}
{%- else %}0{% endif %},
{{packed_field.field.kind|lite_js_type}},
{{packed_field.field|lite_default_value}},
{%- if packed_field.field.kind.is_nullable %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment