Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: mojo/public/tools/bindings/generators/dart_templates/encoding_macros.tmpl

Issue 2112313002: Dart: Fixes enum array encoding (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {%- macro encode(variable, kind, offset, bit, level=0, check_for_null=True) %} 1 {%- macro encode(variable, kind, offset, bit, level=0, check_for_null=True) %}
2 {%- if kind|is_pointer_array_kind %} 2 {%- if kind|is_pointer_array_kind or kind|is_enum_array_kind %}
3 {%- set sub_kind = kind.kind %} 3 {%- set sub_kind = kind.kind %}
4 {%- set sub_kind_size = "bindings.kPointerSize" %} 4 {%- set sub_kind_size = "bindings.kPointerSize" %}
5 {%- if sub_kind|is_union_kind %} 5 {%- if sub_kind|is_union_kind %}
6 {%- set sub_kind_size = "bindings.kUnionSize" %} 6 {%- set sub_kind_size = "bindings.kUnionSize" %}
7 {%- elif sub_kind|is_enum_kind %} 7 {%- elif sub_kind|is_enum_kind %}
8 {%- set sub_kind_size = "bindings.kEnumSize" %} 8 {%- set sub_kind_size = "bindings.kEnumSize" %}
9 {%- endif %} 9 {%- endif %}
10 {%- if check_for_null -%} 10 {%- if check_for_null -%}
11 if ({{variable}} == null) { 11 if ({{variable}} == null) {
12 encoder{{level}}.encodeNullPointer({{offset}}, {{kind|is_nullable_kind|dart_tr ue_false}}); 12 encoder{{level}}.encodeNullPointer({{offset}}, {{kind|is_nullable_kind|dart_tr ue_false}});
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 {%- if not kind|is_nullable_kind %} 92 {%- if not kind|is_nullable_kind %}
93 if ({{variable}} == null) { 93 if ({{variable}} == null) {
94 throw new bindings.MojoCodecError( 94 throw new bindings.MojoCodecError(
95 'Trying to decode null union for non-nullable {{kind|dart_type}}.'); 95 'Trying to decode null union for non-nullable {{kind|dart_type}}.');
96 } 96 }
97 {% endif %} 97 {% endif %}
98 {%- else %} 98 {%- else %}
99 {{variable}} = decoder{{level}}.{{kind|decode_method(offset, bit)}}; 99 {{variable}} = decoder{{level}}.{{kind|decode_method(offset, bit)}};
100 {%- endif %} 100 {%- endif %}
101 {%- endmacro %} 101 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698