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

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: Created 6 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 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 ca95e979808f3b8e4e1a8e8958986f45130d24e6..d1ab931211246b5c1aa4f67ead193e9ed91c375c 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) {
esprehn 2014/12/29 22:00:44 class {{interface.name}}Proxy extends bindings.Pro
hansmuller1 2014/12/29 23:14:11 I hadn't been using classes in the generated code
- connection.initProxyInstance(this, {{interface.name}}, receiver);
+ bindings.ProxyBase.call(this, receiver);
}
+ {{interface.name}}Proxy.prototype = Object.create(bindings.ProxyBase.prototype);
esprehn 2014/12/29 22:00:44 Use class, then you don't need this at all.
hansmuller1 2014/12/29 23:14:11 Acknowledged.
{%- for method in interface.methods %}
{{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
@@ -46,18 +47,16 @@
{%- endfor %}
function {{interface.name}}Stub(delegate) {
esprehn 2014/12/29 22:00:44 class {{interface.name}}Stub extends StubBase {
hansmuller1 2014/12/29 23:14:11 Oops, that's a mistake.The super class does the de
- this.delegate$ = delegate;
+ bindings.StubBase.call(this, delegate);
+ this.delegate$ = delegate;
}
+ {{interface.name}}Stub.prototype = Object.create(bindings.StubBase.prototype);
esprehn 2014/12/29 22:00:44 don't need this with class.
hansmuller1 2014/12/29 23:14:11 Acknowledged.
{%- 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 %}

Powered by Google App Engine
This is Rietveld 408576698