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 391d375e1e6688cc5ed04585dc75aef22ee6939e..1212dae59ffc259a6a61a9bcb34ef14514cf56ec 100644 |
| --- a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl |
| +++ b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl |
| @@ -103,6 +103,24 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%} |
| } |
| }; |
| + function {{interface.name}}DelegatingStub() { |
| + } |
| + |
| + {{interface.name}}DelegatingStub.prototype = |
| + Object.create({{interface.name}}Stub.prototype); |
|
abarth-chromium
2014/10/10 17:45:07
It would be nice if the main stub was delegating i
|
| + |
| + {{interface.name}}DelegatingStub.prototype.callDelegateMethod$ = function(methodName, args) { |
| + var method = this.delegate$ && this.delegate$[methodName]; |
| + return method && method.apply(this.delegate$, args); |
| + } |
| + |
| +{%- for method in interface.methods %} |
| +{%- set method_name = method.name|stylize_method %} |
| + {{interface.name}}DelegatingStub.prototype.{{method_name}} = function() { |
| + return this.callDelegateMethod$("{{method_name}}", arguments); |
| + } |
| +{%- endfor %} |
|
abarth-chromium
2014/10/10 17:45:07
When we merge DelegatingStub into the Sub, we shou
|
| + |
| {#--- Validation #} |
| function validate{{interface.name}}Request(messageValidator) { |
| @@ -156,6 +174,7 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%} |
| name: '{{namespace|replace(".","::")}}::{{interface.name}}', |
| proxyClass: {{interface.name}}Proxy, |
| stubClass: {{interface.name}}Stub, |
| + delegatingStubClass: {{interface.name}}DelegatingStub, |
| validateRequest: validate{{interface.name}}Request, |
| {%- if interface|has_callbacks %} |
| validateResponse: validate{{interface.name}}Response, |