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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
deleted file mode 100644
index d9fee1c57ecb94ed69c4a7718f37ca4fefe787d1..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ /dev/null
@@ -1,189 +0,0 @@
-{%- for method in interface.methods %}
-const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}};
-{%- endfor %}
-
-abstract class {{interface|name}}Calls {
- void sendMessage(bindings.Struct message, int name);
- Future sendMessageWithRequestId(bindings.Struct message, int name, int id);
-
-{%- for method in interface.methods %}
-{%- if method.response_parameters == None %}
- void call{{method|name|upper_camel_case}}(
-{%- for parameter in method.parameters -%}
- {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
-{%- endfor -%}
-{%- set request_struct = method|struct_from_method %}
- ) {
- var params = new {{request_struct|name}}();
-{%- for parameter in method.parameters %}
- params.{{parameter|name}} = {{parameter|name}};
-{%- endfor %}
- sendMessage(params, k{{interface|name}}_{{method|name}}_name);
- }
-{% else %}
-{%- set response_struct = method|response_struct_from_method %}
- Future<{{response_struct|name}}> call{{method|name|upper_camel_case}}(
-{%- for parameter in method.parameters -%}
- {{parameter.kind|dart_type}} {{parameter|name}},
-{%- endfor -%}
-{%- set request_struct = method|struct_from_method %}
- [int requestId = -1]
- ) {
- var params = new {{request_struct|name}}();
-{%- for parameter in method.parameters %}
- params.{{parameter|name}} = {{parameter|name}};
-{%- endfor %}
- return sendMessageWithRequestId(
- params,
- k{{interface|name}}_{{method|name}}_name,
- requestId,
- bindings.MessageHeader.kMessageExpectsResponse);
- }
-{%- endif %}
-{%- endfor %}
-}
-
-class {{interface|name}}Client extends bindings.Client with {{interface|name}}Calls {
- {{interface|name}}Client(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
-
- {{interface|name}}Client.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
-
- {{interface|name}}Client.unbound() : super.unbound();
-
- static {{interface|name}}Client newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) =>
- new {{interface|name}}Client(endpoint);
-
- void handleResponse(bindings.ServiceMessage message) {
- switch (message.header.type) {
-{%- for method in interface.methods %}
-{%- if method.response_parameters != None %}
-{%- set response_struct = method|response_struct_from_method %}
- case k{{interface|name}}_{{method|name}}_name:
- var r = {{response_struct|name}}.deserialize(
- message.payload);
- if (!message.header.hasRequestId) {
- throw 'Expected a message with a valid request Id.';
- }
- Completer c = completerMap[message.header.requestId];
- completerMap[message.header.requestId] = null;
- c.complete(r);
- break;
-{%- endif %}
-{%- endfor %}
- default:
- throw new Exception("Unexpected message name");
- break;
- }
- }
-}
-
-
-class {{interface|name}}Interface extends bindings.Interface
-{% if interface.client != None -%}
-with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Calls
-{% endif -%} {
- {{interface|name}}Interface _delegate = null;
-
- {{interface|name}}Interface(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
-
- {{interface|name}}Interface.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
-
- {{interface|name}}Interface.unbound() : super.unbound();
-
- static {{interface|name}}Interface newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) =>
- new {{interface|name}}Interface(endpoint);
-
- static const String name = '{{namespace|replace(".","::")}}::{{interface|name}}';
-
-{% for method in interface.methods %}
-{%- if method.response_parameters == None %}
- void {{method|name}}(
- {%- for parameter in method.parameters -%}
- {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
- {%- endfor -%}
- ) {
- assert(_delegate != null);
- _delegate.{{method|name}}(
- {%- for parameter in method.parameters -%}
- {{parameter|name}}{% if not loop.last %}, {% endif %}
- {%- endfor %});
- }
-{%- else %}
-{%- set response_struct = method|response_struct_from_method %}
- Future<{{response_struct|name}}> {{method|name}}(
- {%- for parameter in method.parameters -%}
- {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
- {%- endfor -%}
- ) {
- assert(_delegate != null);
- return _delegate.{{method|name}}(
- {%- for parameter in method.parameters -%}
- {{parameter|name}}{% if not loop.last %}, {% endif %}
- {%- endfor %});
- }
-{%- endif %}
-{%- endfor %}
-
- Future<bindings.Message> handleMessage(bindings.ServiceMessage message) {
- switch (message.header.type) {
-{%- for method in interface.methods %}
-{%- set request_struct = method|struct_from_method %}
- case k{{interface|name}}_{{method|name}}_name:
- var params = {{request_struct|name}}.deserialize(
- message.payload);
-{%- if method.response_parameters == None %}
- {{method|name}}(
- {%- for parameter in method.parameters -%}
- params.{{parameter|name}}{% if not loop.last %}, {% endif %}
- {%- endfor -%}
- );
-{%- else %}
- return {{method|name}}(
- {%- for parameter in method.parameters -%}
- params.{{parameter|name}}{% if not loop.last %}, {% endif %}
- {%- endfor -%}
- ).then((response) {
- if (response != null) {
- return buildResponseWithId(
- response,
- k{{interface|name}}_{{method|name}}_name,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
- });
-{%- endif %}
- break;
-{%- endfor %}
- default:
- throw new Exception("Unexpected message name");
- break;
- }
- return null;
- }
-
- {{interface|name}}Interface get delegate => _delegate;
- set delegate({{interface|name}}Interface d) {
- assert(_delegate == null);
- _delegate = d;
- }
-}
-
-
-{#--- TODO(zra): Validation #}
-
-
-{#--- Interface Constants #}
-{% for constant in interface.constants %}
-final {{constant|name}} = {{constant.value|expression_to_text}};
-{%- endfor %}
-
-
-{#--- Interface Enums #}
-{%- from "enum_definition.tmpl" import enum_def -%}
-{%- for enum in interface.enums %}
- {{ enum_def("", enum) }}
-{%- endfor %}

Powered by Google App Engine
This is Rietveld 408576698