diff options
Diffstat (limited to 'mojo/public/bindings/generators/js_templates/interface_definition.tmpl')
-rw-r--r-- | mojo/public/bindings/generators/js_templates/interface_definition.tmpl | 63 |
1 files changed, 1 insertions, 62 deletions
diff --git a/mojo/public/bindings/generators/js_templates/interface_definition.tmpl b/mojo/public/bindings/generators/js_templates/interface_definition.tmpl index fc77059..df1483d 100644 --- a/mojo/public/bindings/generators/js_templates/interface_definition.tmpl +++ b/mojo/public/bindings/generators/js_templates/interface_definition.tmpl @@ -10,40 +10,18 @@ {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( {%- for parameter in method.parameters -%} {{parameter.name}}{% if not loop.last %}, {% endif %} -{%- endfor -%} -{%- if method.response_parameters != None -%} -, closure -{%- endif -%} -) { +{%- endfor %}) { var params = new {{interface.name}}_{{method.name}}_Params(); {%- for parameter in method.parameters %} params.{{parameter.name}} = {{parameter.name}}; {%- endfor %} -{%- if method.response_parameters == None %} var builder = new codec.MessageBuilder( k{{interface.name}}_{{method.name}}_Name, codec.align({{interface.name}}_{{method.name}}_Params.encodedSize)); builder.encodeStruct({{interface.name}}_{{method.name}}_Params, params); var message = builder.finish(); this.receiver_.accept(message); -{%- else %} - var builder = new codec.MessageWithRequestIDBuilder( - k{{interface.name}}_{{method.name}}_Name, - codec.align({{interface.name}}_{{method.name}}_Params.encodedSize), - codec.kMessageExpectsResponse, 0); - builder.encodeStruct({{interface.name}}_{{method.name}}_Params, params); - var message = builder.finish(); - this.receiver_.acceptWithResponder(message, { accept: function(message) { - var reader = new codec.MessageReader(message); - var responseParams = - reader.decodeStruct({{interface.name}}_{{method.name}}_ResponseParams); - closure( -{%- for parameter in method.response_parameters -%} -responseParams.{{parameter.name}}{% if not loop.last %}, {% endif %} -{%- endfor -%}); - }}); -{%- endif %} }; {%- endfor %} @@ -54,7 +32,6 @@ responseParams.{{parameter.name}}{% if not loop.last %}, {% endif %} var reader = new codec.MessageReader(message); switch (reader.messageName) { {%- for method in interface.methods %} -{%- if method.response_parameters == None %} case k{{interface.name}}_{{method.name}}_Name: var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params); this.{{method.name|stylize_method}}( @@ -62,44 +39,6 @@ responseParams.{{parameter.name}}{% if not loop.last %}, {% endif %} params.{{parameter.name}}{% if not loop.last %}, {% endif %} {%- endfor %}); return true; -{%- endif %} -{%- endfor %} - default: - return false; - } - }; - - {{interface.name}}Stub.prototype.acceptWithResponder = - function(message, responder) { - var reader = new codec.MessageReader(message); - switch (reader.messageName) { -{%- for method in interface.methods %} -{%- if method.response_parameters != None %} - case k{{interface.name}}_{{method.name}}_Name: - var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params); - this.{{method.name|stylize_method}}( -{%- for parameter in method.parameters -%} -params.{{parameter.name}}, -{%- endfor %} function ( -{%- for parameter in method.response_parameters -%} -{{parameter.name}}{% if not loop.last %}, {% endif -%} -{%- endfor -%}) { - var responseParams = - new {{interface.name}}_{{method.name}}_ResponseParams(); -{%- for parameter in method.response_parameters %} - responseParams.{{parameter.name}} = {{parameter.name}}; -{%- endfor %} - var builder = new codec.MessageWithRequestIDBuilder( - k{{interface.name}}_{{method.name}}_Name, - codec.align({{interface.name}}_{{method.name}}_ResponseParams.encodedSize), - codec.kMessageIsResponse, reader.requestID); - builder.encodeStruct({{interface.name}}_{{method.name}}_ResponseParams, - responseParams); - var message = builder.finish(); - responder.accept(message); - }); - return true; -{%- endif %} {%- endfor %} default: return false; |