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

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

Issue 1539673003: Generate Mojom Types in Dart (Take 2) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Move and Standardize Mojom Type Functions Created 4 years, 10 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 {#--- Begin #} 1 {#--- Begin #}
2 {%- import "encoding_macros.tmpl" as encoding_macros %} 2 {%- import "encoding_macros.tmpl" as encoding_macros %}
3 {%- macro struct_def(struct) %} 3 {% import "mojom_type_macros.tmpl" as mojom_type_macros %}
4 {%- macro struct_def(struct, typepkg, package) %}
4 {#--- Enums #} 5 {#--- Enums #}
5 {%- from "enum_definition.tmpl" import enum_def %} 6 {%- from "enum_definition.tmpl" import enum_def %}
6 {%- for enum in struct.enums %} 7 {%- for enum in struct.enums %}
7 {{enum_def(enum)}} 8 {{enum_def(enum, typepkg, package)}}
8 {%- endfor %} 9 {%- endfor %}
9 10
10 class {{struct|name}} extends bindings.Struct { 11 class {{struct|name}} extends bindings.Struct {
11 static const List<bindings.StructDataHeader> kVersions = const [ 12 static const List<bindings.StructDataHeader> kVersions = const [
12 {%- for version in struct.versions %} 13 {%- for version in struct.versions %}
13 const bindings.StructDataHeader({{version.num_bytes}}, {{version.version}}){ % if not loop.last %},{% endif %} 14 const bindings.StructDataHeader({{version.num_bytes}}, {{version.version}}){ % if not loop.last %},{% endif %}
14 {%- endfor %} 15 {%- endfor %}
15 ]; 16 ];
16 17
17 {#--- Constants #} 18 {#--- Constants #}
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 {%- for packed_field in struct.packed.packed_fields %} 97 {%- for packed_field in struct.packed.packed_fields %}
97 map["{{packed_field.field|name}}"] = {{packed_field.field|name}}; 98 map["{{packed_field.field|name}}"] = {{packed_field.field|name}};
98 {%- endfor %} 99 {%- endfor %}
99 return map; 100 return map;
100 {%- else %} 101 {%- else %}
101 throw new bindings.MojoCodecError( 102 throw new bindings.MojoCodecError(
102 'Object containing handles cannot be encoded to JSON.'); 103 'Object containing handles cannot be encoded to JSON.');
103 {%- endif %} 104 {%- endif %}
104 } 105 }
105 } 106 }
107
zra 2016/01/27 18:15:12 Extra newline?
alexfandrianto 2016/01/28 03:45:13 Done.
108 {{ mojom_type_macros.writeMojomTypeDef(struct, typepkg, package) }}
106 {%- endmacro %} 109 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698