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

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

Issue 1433183002: Generate Mojom Types for Dart (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Simplify identifier_store for Go and Dart Created 5 years 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 {%- for method in interface.methods %} 1 {%- for method in interface.methods %}
2 const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}}; 2 const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}};
3 {%- endfor %} 3 {%- endfor %}
4 4
5 const String {{interface|name}}Name = 5 const String {{interface|name}}Name =
6 '{{namespace|replace(".","::")}}::{{interface.name}}'; 6 '{{namespace|replace(".","::")}}::{{interface.name}}';
7 7
8 {#--- Interface Enums #} 8 {#--- Interface Enums #}
9 {%- from "enum_definition.tmpl" import enum_def -%} 9 {%- from "enum_definition.tmpl" import enum_def -%}
10 {%- for enum in interface.enums %} 10 {%- for enum in interface.enums %}
11 {{ enum_def(enum) }} 11 {{ enum_def(enum, typepkg, package) }}
12 {%- endfor %} 12 {%- endfor %}
13 13
14 {{ mojom_type_macros.writeMojomTypeDef(interface, typepkg, package) }}
15
16 class _{{interface|name}}ServiceDescription extends {{descpkg}}ServiceDescriptio n {
zra 2015/11/24 17:34:44 Should this be extends or implements?
alexfandrianto 2015/12/18 01:53:19 It doesn't matter, but I think the preference was
17 // Avoid infinite loop by overriding serviceDescription field.
zra 2015/11/24 17:34:44 I don't understand this comment.
alexfandrianto 2015/12/18 01:53:19 It's not needed anymore.
18 final {{descpkg}}ServiceDescription serviceDescription = null;
19 {% if should_gen_mojom_types -%}
20 dynamic getTopLevelInterface([Function responseFactory = null]) {
21 return {{interface|mojom_type_identifier}}();
22 }
23 dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]) {
24 return getAllMojomTypeDefinitions()[typeKey];
25 }
26 dynamic getAllTypeDefinitions([Function responseFactory = null]) {
27 return getAllMojomTypeDefinitions();
28 }
29 {%- else -%}
30 dynamic getTopLevelInterface([Function responseFactory = null]) {
31 return null;
32 }
33 dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]) {
34 return null;
35 }
36 dynamic getAllTypeDefinitions([Function responseFactory = null]) {
37 return null;
38 }
39 {%- endif %}
40 }
41
14 abstract class {{interface|name}} { 42 abstract class {{interface|name}} {
15 {%- for method in interface.methods %} 43 {%- for method in interface.methods %}
16 {%- if method.response_parameters == None %} 44 {%- if method.response_parameters == None %}
17 void {{method|name}}( 45 void {{method|name}}(
18 {%- for parameter in method.parameters -%} 46 {%- for parameter in method.parameters -%}
19 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} 47 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
20 {%- endfor -%} 48 {%- endfor -%}
21 ); 49 );
22 {%- else %} 50 {%- else %}
23 {%- set response_struct = method.response_param_struct %} 51 {%- set response_struct = method.response_param_struct %}
(...skipping 22 matching lines...) Expand all
46 {{interface|name}}ProxyImpl.unbound() : super.unbound(); 74 {{interface|name}}ProxyImpl.unbound() : super.unbound();
47 75
48 static {{interface|name}}ProxyImpl newFromEndpoint( 76 static {{interface|name}}ProxyImpl newFromEndpoint(
49 core.MojoMessagePipeEndpoint endpoint) { 77 core.MojoMessagePipeEndpoint endpoint) {
50 assert(endpoint.setDescription("For {{interface|name}}ProxyImpl")); 78 assert(endpoint.setDescription("For {{interface|name}}ProxyImpl"));
51 return new {{interface|name}}ProxyImpl.fromEndpoint(endpoint); 79 return new {{interface|name}}ProxyImpl.fromEndpoint(endpoint);
52 } 80 }
53 81
54 String get name => {{interface|name}}Name; 82 String get name => {{interface|name}}Name;
55 83
84 {{descpkg}}ServiceDescription get serviceDescription =>
85 new _{{interface|name}}ServiceDescription();
86
56 void handleResponse(bindings.ServiceMessage message) { 87 void handleResponse(bindings.ServiceMessage message) {
57 switch (message.header.type) { 88 switch (message.header.type) {
58 {%- for method in interface.methods %} 89 {%- for method in interface.methods %}
59 {%- if method.response_parameters != None %} 90 {%- if method.response_parameters != None %}
60 {%- set response_struct = method.response_param_struct %} 91 {%- set response_struct = method.response_param_struct %}
61 case k{{interface|name}}_{{method|name}}_name: 92 case k{{interface|name}}_{{method|name}}_name:
62 var r = {{response_struct|name}}.deserialize( 93 var r = {{response_struct|name}}.deserialize(
63 message.payload); 94 message.payload);
64 if (!message.header.hasRequestId) { 95 if (!message.header.hasRequestId) {
65 proxyError("Expected a message with a valid request Id."); 96 proxyError("Expected a message with a valid request Id.");
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 assert(_impl == null); 324 assert(_impl == null);
294 _impl = d; 325 _impl = d;
295 } 326 }
296 327
297 String toString() { 328 String toString() {
298 var superString = super.toString(); 329 var superString = super.toString();
299 return "{{interface|name}}Stub($superString)"; 330 return "{{interface|name}}Stub($superString)";
300 } 331 }
301 332
302 int get version => {{interface.version}}; 333 int get version => {{interface.version}};
334
335 {{descpkg}}ServiceDescription get serviceDescription =>
336 new _{{interface|name}}ServiceDescription();
303 } 337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698