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

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

Issue 1405103002: Dart: Merge message pipe query and read into one native call. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 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/dart/mojo/sdk_ext/src/natives.dart ('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 2
3 {%- import "encoding_macros.tmpl" as encoding_macros %} 3 {%- import "encoding_macros.tmpl" as encoding_macros %}
4 4
5 {%- macro struct_def(struct) %} 5 {%- macro struct_def(struct) %}
6 {#--- Enums #} 6 {#--- Enums #}
7 {%- from "enum_definition.tmpl" import enum_def %} 7 {%- from "enum_definition.tmpl" import enum_def %}
8 {%- for enum in struct.enums %} 8 {%- for enum in struct.enums %}
9 {{enum_def(enum)}} 9 {{enum_def(enum)}}
10 {%- endfor %} 10 {%- endfor %}
(...skipping 13 matching lines...) Expand all
24 {#--- initDefaults() #} 24 {#--- initDefaults() #}
25 {%- for packed_field in struct.packed.packed_fields %} 25 {%- for packed_field in struct.packed.packed_fields %}
26 {{packed_field.field.kind|dart_type}} {{packed_field.field|name}} = {{packed_f ield.field|default_value}}; 26 {{packed_field.field.kind|dart_type}} {{packed_field.field|name}} = {{packed_f ield.field|default_value}};
27 {%- endfor %} 27 {%- endfor %}
28 28
29 {{struct|name}}() : super(kVersions.last.size); 29 {{struct|name}}() : super(kVersions.last.size);
30 30
31 static {{struct|name}} deserialize(bindings.Message message) { 31 static {{struct|name}} deserialize(bindings.Message message) {
32 var decoder = new bindings.Decoder(message); 32 var decoder = new bindings.Decoder(message);
33 var result = decode(decoder); 33 var result = decode(decoder);
34 decoder.excessHandles.forEach((h) => h.close()); 34 if (decoder.excessHandles != null) {
35 decoder.excessHandles.forEach((h) => h.close());
36 }
35 return result; 37 return result;
36 } 38 }
37 39
38 static {{struct|name}} decode(bindings.Decoder decoder0) { 40 static {{struct|name}} decode(bindings.Decoder decoder0) {
39 if (decoder0 == null) { 41 if (decoder0 == null) {
40 return null; 42 return null;
41 } 43 }
42 {{struct|name}} result = new {{struct|name}}(); 44 {{struct|name}} result = new {{struct|name}}();
43 45
44 var mainDataHeader = decoder0.decodeStructDataHeader(); 46 var mainDataHeader = decoder0.decodeStructDataHeader();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 map["{{packed_field.field|name}}"] = {{packed_field.field|name}}; 99 map["{{packed_field.field|name}}"] = {{packed_field.field|name}};
98 {%- endfor %} 100 {%- endfor %}
99 return map; 101 return map;
100 {%- else %} 102 {%- else %}
101 throw new bindings.MojoCodecError( 103 throw new bindings.MojoCodecError(
102 'Object containing handles cannot be encoded to JSON.'); 104 'Object containing handles cannot be encoded to JSON.');
103 {%- endif %} 105 {%- endif %}
104 } 106 }
105 } 107 }
106 {%- endmacro %} 108 {%- endmacro %}
OLDNEW
« no previous file with comments | « mojo/public/dart/mojo/sdk_ext/src/natives.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698