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

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

Issue 795593004: Update mojo sdk to rev cc531b32182099a5a034a99daff35ed5d38a61c8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More workarounds for MSVC Created 5 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}}Proxy(receiver) { 5 function {{interface.name}}Proxy(receiver) {
6 connection.initProxyInstance(this, {{interface.name}}, receiver); 6 connection.initProxyInstance(this, {{interface.name}}, receiver);
7 } 7 }
8 8
9 {{interface.name}}Proxy.prototype.getConnection$ = function() {
10 return connection.getProxyConnection(this, {{interface.name}});
11 }
12
13 {%- for method in interface.methods %} 9 {%- for method in interface.methods %}
14 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( 10 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
15 {%- for parameter in method.parameters -%} 11 {%- for parameter in method.parameters -%}
16 {{parameter.name}}{% if not loop.last %}, {% endif %} 12 {{parameter.name}}{% if not loop.last %}, {% endif %}
17 {%- endfor -%} 13 {%- endfor -%}
18 ) { 14 ) {
19 var params = new {{interface.name}}_{{method.name}}_Params(); 15 var params = new {{interface.name}}_{{method.name}}_Params();
20 {%- for parameter in method.parameters %} 16 {%- for parameter in method.parameters %}
21 {%- if parameter|is_interface_parameter %} 17 params.{{parameter.name}} = {{parameter|js_proxy_method_parameter_value}};
22 if ({{parameter.name}} instanceof {{parameter.kind|js_type}}.stubClass)
23 params.{{parameter.name}} = {{parameter.name}}.getConnection$().messagePip eHandle;
24 else
25 params.{{parameter.name}} = {{parameter.name}};
26 {%- elif parameter|is_interface_request_parameter %}
27 if ({{parameter.name}} instanceof {{parameter.kind.kind|js_type}}.proxyClass )
28 params.{{parameter.name}} = {{parameter.name}}.getConnection$().messagePip eHandle;
29 else
30 params.{{parameter.name}} = {{parameter.name}};
31 {%- else %}
32 params.{{parameter.name}} = {{parameter.name}};
33 {%- endif %}
34 {%- endfor %} 18 {%- endfor %}
35 19
36 {%- if method.response_parameters == None %} 20 {%- if method.response_parameters == None %}
37 var builder = new codec.MessageBuilder( 21 var builder = new codec.MessageBuilder(
38 k{{interface.name}}_{{method.name}}_Name, 22 k{{interface.name}}_{{method.name}}_Name,
39 codec.align({{interface.name}}_{{method.name}}_Params.encodedSize)); 23 codec.align({{interface.name}}_{{method.name}}_Params.encodedSize));
40 builder.encodeStruct({{interface.name}}_{{method.name}}_Params, params); 24 builder.encodeStruct({{interface.name}}_{{method.name}}_Params, params);
41 var message = builder.finish(); 25 var message = builder.finish();
42 this.receiver_.accept(message); 26 this.receiver_.accept(message);
43 {%- else %} 27 {%- else %}
(...skipping 14 matching lines...) Expand all
58 }); 42 });
59 }.bind(this)); 43 }.bind(this));
60 {%- endif %} 44 {%- endif %}
61 }; 45 };
62 {%- endfor %} 46 {%- endfor %}
63 47
64 function {{interface.name}}Stub(delegate) { 48 function {{interface.name}}Stub(delegate) {
65 this.delegate$ = delegate; 49 this.delegate$ = delegate;
66 } 50 }
67 51
68 {{interface.name}}Stub.prototype.getConnection$ = function() {
69 return connection.getStubConnection(this, {{interface.name}});
70 }
71
72 {%- for method in interface.methods %} 52 {%- for method in interface.methods %}
73 {% macro stub_method_parameters() -%} 53 {% macro stub_method_parameters() -%}
74 {%- for parameter in method.parameters -%} 54 {%- for parameter in method.parameters -%}
75 {{parameter.name}}{% if not loop.last %}, {% endif %} 55 {{parameter.name}}{% if not loop.last %}, {% endif %}
76 {%- endfor %} 56 {%- endfor %}
77 {%- endmacro %} 57 {%- endmacro %}
78 {{interface.name}}Stub.prototype.{{method.name|stylize_method}} = function({{s tub_method_parameters()}}) { 58 {{interface.name}}Stub.prototype.{{method.name|stylize_method}} = function({{s tub_method_parameters()}}) {
79 if (this.delegate$.{{method.name|stylize_method}}) 59 if (this.delegate$.{{method.name|stylize_method}})
80 return this.delegate$.{{method.name|stylize_method}}({{stub_method_paramet ers()}}); 60 return this.delegate$.{{method.name|stylize_method}}({{method.parameters|m ap('js_stub_method_parameter_value')|join(',')}});
81 } 61 }
82 {%- endfor %} 62 {%- endfor %}
83 63
84 {{interface.name}}Stub.prototype.accept = function(message) { 64 {{interface.name}}Stub.prototype.accept = function(message) {
85 var reader = new codec.MessageReader(message); 65 var reader = new codec.MessageReader(message);
86 switch (reader.messageName) { 66 switch (reader.messageName) {
87 {%- for method in interface.methods %} 67 {%- for method in interface.methods %}
88 {%- if method.response_parameters == None %} 68 {%- if method.response_parameters == None %}
89 case k{{interface.name}}_{{method.name}}_Name: 69 case k{{interface.name}}_{{method.name}}_Name:
90 var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params ); 70 var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params );
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 {%- from "enum_definition.tmpl" import enum_def -%} 181 {%- from "enum_definition.tmpl" import enum_def -%}
202 {%- for enum in interface.enums %} 182 {%- for enum in interface.enums %}
203 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }} 183 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }}
204 {%- endfor %} 184 {%- endfor %}
205 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ; 185 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ;
206 {%- if interface|has_callbacks %} 186 {%- if interface|has_callbacks %}
207 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se; 187 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se;
208 {%- else %} 188 {%- else %}
209 {{interface.name}}Proxy.prototype.validator = null; 189 {{interface.name}}Proxy.prototype.validator = null;
210 {%- endif %} 190 {%- endif %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698