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

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

Issue 803173009: Mojo JS Bindings: Eliminate foo$ Stub and Proxy class members (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sync 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
« no previous file with comments | « mojo/public/sky/BUILD.gn ('k') | mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ca95e979808f3b8e4e1a8e8958986f45130d24e6..1b5cafa01e4501e67a3e9694bdb55d818a98513e 100644
--- a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
@@ -3,8 +3,9 @@
{%- endfor %}
function {{interface.name}}Proxy(receiver) {
- connection.initProxyInstance(this, {{interface.name}}, receiver);
+ bindings.ProxyBase.call(this, receiver);
}
+ {{interface.name}}Proxy.prototype = Object.create(bindings.ProxyBase.prototype);
{%- for method in interface.methods %}
{{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
@@ -46,18 +47,15 @@
{%- endfor %}
function {{interface.name}}Stub(delegate) {
- this.delegate$ = delegate;
+ bindings.StubBase.call(this, delegate);
}
+ {{interface.name}}Stub.prototype = Object.create(bindings.StubBase.prototype);
{%- for method in interface.methods %}
-{% macro stub_method_parameters() -%}
-{%- for parameter in method.parameters -%}
- {{parameter.name}}{% if not loop.last %}, {% endif %}
-{%- endfor %}
-{%- endmacro %}
- {{interface.name}}Stub.prototype.{{method.name|stylize_method}} = function({{stub_method_parameters()}}) {
- if (this.delegate$.{{method.name|stylize_method}})
- return this.delegate$.{{method.name|stylize_method}}({{method.parameters|map('js_stub_method_parameter_value')|join(',')}});
+{%- set js_method_name = method.name|stylize_method %}
+{%- set delegate_expr = "bindings.StubBindings(this).delegate" %}
+ {{interface.name}}Stub.prototype.{{js_method_name}} = function({{method.parameters|map(attribute='name')|join(', ')}}) {
+ return {{delegate_expr}} && {{delegate_expr}}.{{js_method_name}} && {{delegate_expr}}.{{js_method_name}}({{method.parameters|map('js_stub_method_parameter_value')|join(', ')}});
}
{%- endfor %}
« no previous file with comments | « mojo/public/sky/BUILD.gn ('k') | mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698