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

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

Issue 628763002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed template indentation Created 6 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
index b41929c245b4138a7b06d7170b1e048639d9d844..391d375e1e6688cc5ed04585dc75aef22ee6939e 100644
--- a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
@@ -1,4 +1,3 @@
-{%- set namespace_as_string = namespace|replace(".","::") %}
{%- for method in interface.methods %}
var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}};
{%- endfor %}
@@ -7,8 +6,6 @@
this.receiver_ = receiver;
}
- {{interface.name}}Proxy.NAME_ = '{{namespace_as_string}}::{{interface.name}}';
-
{%- for method in interface.methods %}
{{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
{%- for parameter in method.parameters -%}
@@ -54,8 +51,6 @@
function {{interface.name}}Stub() {
}
- {{interface.name}}Stub.NAME_ = '{{namespace_as_string}}::{{interface.name}}';
-
{{interface.name}}Stub.prototype.accept = function(message) {
var reader = new codec.MessageReader(message);
switch (reader.messageName) {
@@ -157,22 +152,29 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%}
{%- endif %}
}
+ var {{interface.name}} = {
+ name: '{{namespace|replace(".","::")}}::{{interface.name}}',
+ proxyClass: {{interface.name}}Proxy,
+ stubClass: {{interface.name}}Stub,
+ validateRequest: validate{{interface.name}}Request,
+{%- if interface|has_callbacks %}
+ validateResponse: validate{{interface.name}}Response,
+{%- else %}
+ validateResponse: null,
+{%- endif %}
+ };
+{#--- Interface Constants #}
+{%- for constant in interface.constants %}
+ {{interface.name}}.{{constant.name}} = {{constant.value|expression_to_text}},
+{%- endfor %}
+{#--- Interface Enums #}
+{%- from "enum_definition.tmpl" import enum_def -%}
+{%- for enum in interface.enums %}
+ {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }}
+{%- endfor %}
{{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request;
{%- if interface|has_callbacks %}
{{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Response;
{%- else %}
{{interface.name}}Proxy.prototype.validator = null;
-{%- endif -%}
-
-{#--- Enums #}
-{% from "enum_definition.tmpl" import enum_def -%}
-{% for enum in interface.enums %}
- {{enum_def("%sProxy.%s"|format(interface.name, enum.name), enum, module)}}
- {{interface.name}}Stub.{{enum.name}} = {{interface.name}}Proxy.{{enum.name}};
-{%- endfor %}
-
-{#--- Constants. #}
-{% for constant in interface.constants %}
- {{interface.name}}Proxy.{{constant.name}} = {{constant.value|expression_to_text}};
- {{interface.name}}Stub.{{constant.name}} = {{interface.name}}Proxy.{{constant.name}};
-{%- endfor %}
+{%- endif %}

Powered by Google App Engine
This is Rietveld 408576698