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

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

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 6 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
« no previous file with comments | « mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, typepkg, package) %} 3 {%- macro struct_def(struct, typepkg, package) %}
4 {#--- Enums #} 4 {#--- Enums #}
5 {%- from "enum_definition.tmpl" import enum_def %} 5 {%- from "enum_definition.tmpl" import enum_def %}
6 {%- for enum in struct.enums %} 6 {%- for enum in struct.enums %}
7 {{enum_def(enum, typepkg, package)}} 7 {{enum_def(enum, typepkg, package)}}
8 {%- endfor %} 8 {%- endfor %}
9 9
10 class {{struct|name}} extends bindings.Struct { 10 class {{struct|name}} extends bindings.Struct {
11 static const List<bindings.StructDataHeader> kVersions = const [ 11 static const List<bindings.StructDataHeader> kVersions = const [
12 {%- for version in struct.versions %} 12 {%- for version in struct.versions %}
13 const bindings.StructDataHeader({{version.num_bytes}}, {{version.version}}){ % if not loop.last %},{% endif %} 13 const bindings.StructDataHeader({{version.num_bytes}}, {{version.version}}){ % if not loop.last %},{% endif %}
14 {%- endfor %} 14 {%- endfor %}
15 ]; 15 ];
16 16
17 {#--- Constants #} 17 {#--- Constants #}
18 {%- for constant in struct.constants %} 18 {%- for constant in struct.constants %}
19 static const {{constant.kind|dart_type}} {{constant|name}} = {{constant.resolv ed_value}}; 19 static const {{constant.kind|dart_type}} {{constant|name}} = {{constant.resolv ed_value}};
20 {%- endfor %} 20 {%- endfor %}
21 21
22 {#--- initDefaults() #} 22 {#--- initDefaults() #}
23 {%- for packed_field in struct.packed.packed_fields %} 23 {%- for packed_field in struct.packed.packed_fields %}
24 {{packed_field.field.kind|dart_type}} {{packed_field.field|name}} = {{packed_f ield.field|default_value}}; 24 {{packed_field.field.kind|dart_type}} {{packed_field.field|name}} = {{packed_f ield.field|default_value}};
25 {%- endfor %} 25 {%- endfor %}
26 26
27 {{struct|name}}() : super(kVersions.last.size); 27 {{struct|name}}() : super(kVersions.last.size);
28 28
29 {{struct|name}}.init(
30 {%- for packed_field in struct.packed.packed_fields %}
31 {{packed_field.field.kind|dart_type}} this.{{packed_field.field|name}}{% if not loop.last %}, {% endif %}
32 {%- endfor %}
33 ) : super(kVersions.last.size);
34
29 static {{struct|name}} deserialize(bindings.Message message) { 35 static {{struct|name}} deserialize(bindings.Message message) {
30 var decoder = new bindings.Decoder(message); 36 var decoder = new bindings.Decoder(message);
31 var result = decode(decoder); 37 var result = decode(decoder);
32 if (decoder.excessHandles != null) { 38 if (decoder.excessHandles != null) {
33 decoder.excessHandles.forEach((h) => h.close()); 39 decoder.excessHandles.forEach((h) => h.close());
34 } 40 }
35 return result; 41 return result;
36 } 42 }
37 43
38 static {{struct|name}} decode(bindings.Decoder decoder0) { 44 static {{struct|name}} decode(bindings.Decoder decoder0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 {%- endfor %} 110 {%- endfor %}
105 return map; 111 return map;
106 {%- else %} 112 {%- else %}
107 throw new bindings.MojoCodecError( 113 throw new bindings.MojoCodecError(
108 'Object containing handles cannot be encoded to JSON.'); 114 'Object containing handles cannot be encoded to JSON.');
109 {%- endif %} 115 {%- endif %}
110 } 116 }
111 } 117 }
112 118
113 {%- endmacro %} 119 {%- endmacro %}
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698