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

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

Issue 2549683002: Mojo JS bindings: introduce concepts that are more similar to C++ bindings: (Closed)
Patch Set: put interface control methods in the |ptr| property Created 4 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 unified diff | Download patch
OLDNEW
1 {%- for method in interface.methods %} 1 {%- for method in interface.methods %}
2 var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}}; 2 var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}};
3 {%- endfor %} 3 {%- endfor %}
4 4
5 function {{interface.name}}Ptr() {
6 this.ptr = new bindings.InterfacePtrController({{interface.name}});
7 }
8
5 function {{interface.name}}Proxy(receiver) { 9 function {{interface.name}}Proxy(receiver) {
6 bindings.ProxyBase.call(this, receiver); 10 bindings.ProxyBase.call(this, receiver);
7 } 11 }
8 {{interface.name}}Proxy.prototype = Object.create(bindings.ProxyBase.prototype ); 12 {{interface.name}}Proxy.prototype = Object.create(bindings.ProxyBase.prototype );
9 13
10 {%- for method in interface.methods %} 14 {%- for method in interface.methods %}
15 {{interface.name}}Ptr.prototype.{{method.name|stylize_method}} = function() {
16 return {{interface.name}}Proxy.prototype.{{method.name|stylize_method}}
17 .apply(this.ptr.connection.remote, arguments);
18 };
19
11 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( 20 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
12 {%- for parameter in method.parameters -%} 21 {%- for parameter in method.parameters -%}
13 {{parameter.name}}{% if not loop.last %}, {% endif %} 22 {{parameter.name}}{% if not loop.last %}, {% endif %}
14 {%- endfor -%} 23 {%- endfor -%}
15 ) { 24 ) {
16 var params = new {{interface.name}}_{{method.name}}_Params(); 25 var params = new {{interface.name}}_{{method.name}}_Params();
17 {%- for parameter in method.parameters %} 26 {%- for parameter in method.parameters %}
18 params.{{parameter.name}} = {{parameter|js_proxy_method_parameter_value}}; 27 params.{{parameter.name}} = {{parameter|js_proxy_method_parameter_value}};
19 {%- endfor %} 28 {%- endfor %}
20 29
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 {%- from "enum_definition.tmpl" import enum_def -%} 188 {%- from "enum_definition.tmpl" import enum_def -%}
180 {%- for enum in interface.enums %} 189 {%- for enum in interface.enums %}
181 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }} 190 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }}
182 {%- endfor %} 191 {%- endfor %}
183 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ; 192 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ;
184 {%- if interface|has_callbacks %} 193 {%- if interface|has_callbacks %}
185 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se; 194 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se;
186 {%- else %} 195 {%- else %}
187 {{interface.name}}Proxy.prototype.validator = null; 196 {{interface.name}}Proxy.prototype.validator = null;
188 {%- endif %} 197 {%- endif %}
OLDNEW
« no previous file with comments | « mojo/public/js/connection.js ('k') | mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698