Chromium Code Reviews| 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 %} |