Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 { | |
| 17 // Avoid infinite loop by overriding serviceDescription field. | |
| 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}} { |
| 43 final {{descpkg}}ServiceDescription serviceDescription = | |
|
zra
2015/11/18 19:24:35
This is probably not the right place for this. See
| |
| 44 {% if descpkg != '' -%} | |
| 45 new _{{interface|name}}ServiceDescription(); | |
| 46 {%- else -%} | |
| 47 null; | |
| 48 {%- endif %} | |
| 49 | |
| 15 {%- for method in interface.methods %} | 50 {%- for method in interface.methods %} |
| 16 {%- if method.response_parameters == None %} | 51 {%- if method.response_parameters == None %} |
| 17 void {{method|name}}( | 52 void {{method|name}}( |
| 18 {%- for parameter in method.parameters -%} | 53 {%- for parameter in method.parameters -%} |
| 19 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} | 54 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} |
| 20 {%- endfor -%} | 55 {%- endfor -%} |
| 21 ); | 56 ); |
| 22 {%- else %} | 57 {%- else %} |
| 23 {%- set response_struct = method.response_param_struct %} | 58 {%- set response_struct = method.response_param_struct %} |
| 24 dynamic {{method|name}}( | 59 dynamic {{method|name}}( |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 46 {{interface|name}}ProxyImpl.unbound() : super.unbound(); | 81 {{interface|name}}ProxyImpl.unbound() : super.unbound(); |
| 47 | 82 |
| 48 static {{interface|name}}ProxyImpl newFromEndpoint( | 83 static {{interface|name}}ProxyImpl newFromEndpoint( |
| 49 core.MojoMessagePipeEndpoint endpoint) { | 84 core.MojoMessagePipeEndpoint endpoint) { |
| 50 assert(endpoint.setDescription("For {{interface|name}}ProxyImpl")); | 85 assert(endpoint.setDescription("For {{interface|name}}ProxyImpl")); |
| 51 return new {{interface|name}}ProxyImpl.fromEndpoint(endpoint); | 86 return new {{interface|name}}ProxyImpl.fromEndpoint(endpoint); |
| 52 } | 87 } |
| 53 | 88 |
| 54 String get name => {{interface|name}}Name; | 89 String get name => {{interface|name}}Name; |
| 55 | 90 |
| 91 {{descpkg}}ServiceDescription get serviceDescription => | |
|
zra
2015/11/18 19:24:36
This seems like the right place. See comment below
| |
| 92 new _{{interface|name}}ServiceDescription(); | |
| 93 | |
| 56 void handleResponse(bindings.ServiceMessage message) { | 94 void handleResponse(bindings.ServiceMessage message) { |
| 57 switch (message.header.type) { | 95 switch (message.header.type) { |
| 58 {%- for method in interface.methods %} | 96 {%- for method in interface.methods %} |
| 59 {%- if method.response_parameters != None %} | 97 {%- if method.response_parameters != None %} |
| 60 {%- set response_struct = method.response_param_struct %} | 98 {%- set response_struct = method.response_param_struct %} |
| 61 case k{{interface|name}}_{{method|name}}_name: | 99 case k{{interface|name}}_{{method|name}}_name: |
| 62 var r = {{response_struct|name}}.deserialize( | 100 var r = {{response_struct|name}}.deserialize( |
| 63 message.payload); | 101 message.payload); |
| 64 if (!message.header.hasRequestId) { | 102 if (!message.header.hasRequestId) { |
| 65 proxyError("Expected a message with a valid request Id."); | 103 proxyError("Expected a message with a valid request Id."); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 87 } | 125 } |
| 88 } | 126 } |
| 89 | 127 |
| 90 String toString() { | 128 String toString() { |
| 91 var superString = super.toString(); | 129 var superString = super.toString(); |
| 92 return "{{interface|name}}ProxyImpl($superString)"; | 130 return "{{interface|name}}ProxyImpl($superString)"; |
| 93 } | 131 } |
| 94 } | 132 } |
| 95 | 133 |
| 96 | 134 |
| 97 class _{{interface|name}}ProxyCalls implements {{interface|name}} { | 135 class _{{interface|name}}ProxyCalls extends {{interface|name}} { |
|
zra
2015/11/18 19:24:36
Sorry for the lack of comments here. The ProxyCall
alexfandrianto
2015/11/19 23:27:23
As discussed offline, the reason for these changes
| |
| 98 {{interface|name}}ProxyImpl _proxyImpl; | 136 {{interface|name}}ProxyImpl _proxyImpl; |
| 99 | 137 |
| 100 _{{interface|name}}ProxyCalls(this._proxyImpl); | 138 _{{interface|name}}ProxyCalls(this._proxyImpl); |
| 101 | 139 |
| 102 {%- for method in interface.methods %} | 140 {%- for method in interface.methods %} |
| 103 {%- if method.response_parameters == None %} | 141 {%- if method.response_parameters == None %} |
| 104 void {{method|name}}( | 142 void {{method|name}}( |
| 105 {%- for parameter in method.parameters -%} | 143 {%- for parameter in method.parameters -%} |
| 106 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} | 144 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} |
| 107 {%- endfor -%} | 145 {%- endfor -%} |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 _impl = d; | 332 _impl = d; |
| 295 } | 333 } |
| 296 | 334 |
| 297 String toString() { | 335 String toString() { |
| 298 var superString = super.toString(); | 336 var superString = super.toString(); |
| 299 return "{{interface|name}}Stub($superString)"; | 337 return "{{interface|name}}Stub($superString)"; |
| 300 } | 338 } |
| 301 | 339 |
| 302 int get version => {{interface.version}}; | 340 int get version => {{interface.version}}; |
| 303 } | 341 } |
| OLD | NEW |