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

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

Issue 2615633005: Mojo JS bindings: remove usage of the connection module. (Closed)
Patch Set: . Created 3 years, 11 months 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(handleOrPtrInfo) { 5 function {{interface.name}}Ptr(handleOrPtrInfo) {
6 this.ptr = new bindings.InterfacePtrController({{interface.name}}, 6 this.ptr = new bindings.InterfacePtrController({{interface.name}},
7 handleOrPtrInfo); 7 handleOrPtrInfo);
8 } 8 }
9 9
10 function {{interface.name}}Proxy(receiver) { 10 function {{interface.name}}Proxy(receiver) {
11 bindings.ProxyBase.call(this, receiver); 11 this.receiver_ = receiver;
12 } 12 }
13 {{interface.name}}Proxy.prototype = Object.create(bindings.ProxyBase.prototype );
14 13
15 {%- for method in interface.methods %} 14 {%- for method in interface.methods %}
16 {{interface.name}}Ptr.prototype.{{method.name|stylize_method}} = function() { 15 {{interface.name}}Ptr.prototype.{{method.name|stylize_method}} = function() {
17 return {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} 16 return {{interface.name}}Proxy.prototype.{{method.name|stylize_method}}
18 .apply(this.ptr.getProxy(), arguments); 17 .apply(this.ptr.getProxy(), arguments);
19 }; 18 };
20 19
21 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( 20 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
22 {%- for parameter in method.parameters -%} 21 {%- for parameter in method.parameters -%}
23 {{parameter.name}}{% if not loop.last %}, {% endif %} 22 {{parameter.name}}{% if not loop.last %}, {% endif %}
(...skipping 26 matching lines...) Expand all
50 resolve(responseParams); 49 resolve(responseParams);
51 }).catch(function(result) { 50 }).catch(function(result) {
52 reject(Error("Connection error: " + result)); 51 reject(Error("Connection error: " + result));
53 }); 52 });
54 }.bind(this)); 53 }.bind(this));
55 {%- endif %} 54 {%- endif %}
56 }; 55 };
57 {%- endfor %} 56 {%- endfor %}
58 57
59 function {{interface.name}}Stub(delegate) { 58 function {{interface.name}}Stub(delegate) {
60 bindings.StubBase.call(this, delegate); 59 this.delegate_ = delegate;
61 } 60 }
62 {{interface.name}}Stub.prototype = Object.create(bindings.StubBase.prototype);
63 61
64 {%- for method in interface.methods %} 62 {%- for method in interface.methods %}
65 {%- set js_method_name = method.name|stylize_method %} 63 {%- set js_method_name = method.name|stylize_method %}
66 {%- set delegate_expr = "bindings.StubBindings(this).delegate" %}
67 {{interface.name}}Stub.prototype.{{js_method_name}} = function({{method.parame ters|map(attribute='name')|join(', ')}}) { 64 {{interface.name}}Stub.prototype.{{js_method_name}} = function({{method.parame ters|map(attribute='name')|join(', ')}}) {
68 return {{delegate_expr}} && {{delegate_expr}}.{{js_method_name}} && {{delega te_expr}}.{{js_method_name}}({{method.parameters|map(attribute='name')|join(', ' )}}); 65 return this.delegate_ && this.delegate_.{{js_method_name}} && this.delegate_ .{{js_method_name}}({{method.parameters|map(attribute='name')|join(', ')}});
69 } 66 }
70 {%- endfor %} 67 {%- endfor %}
71 68
72 {{interface.name}}Stub.prototype.accept = function(message) { 69 {{interface.name}}Stub.prototype.accept = function(message) {
73 var reader = new codec.MessageReader(message); 70 var reader = new codec.MessageReader(message);
74 switch (reader.messageName) { 71 switch (reader.messageName) {
75 {%- for method in interface.methods %} 72 {%- for method in interface.methods %}
76 {%- if method.response_parameters == None %} 73 {%- if method.response_parameters == None %}
77 case k{{interface.name}}_{{method.name}}_Name: 74 case k{{interface.name}}_{{method.name}}_Name:
78 var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params ); 75 var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params );
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 {%- from "enum_definition.tmpl" import enum_def -%} 187 {%- from "enum_definition.tmpl" import enum_def -%}
191 {%- for enum in interface.enums %} 188 {%- for enum in interface.enums %}
192 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }} 189 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }}
193 {%- endfor %} 190 {%- endfor %}
194 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ; 191 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ;
195 {%- if interface|has_callbacks %} 192 {%- if interface|has_callbacks %}
196 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se; 193 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se;
197 {%- else %} 194 {%- else %}
198 {{interface.name}}Proxy.prototype.validator = null; 195 {{interface.name}}Proxy.prototype.validator = null;
199 {%- endif %} 196 {%- endif %}
OLDNEW
« no previous file with comments | « mojo/public/js/validation_unittests.js ('k') | mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698