OLD | NEW |
1 {% from "constant_definition.tmpl" import constant_def %} | 1 {% from "constant_definition.tmpl" import constant_def %} |
2 {% from "enum_definition.tmpl" import enum_def %} | 2 {% from "enum_definition.tmpl" import enum_def %} |
3 {% from "struct_definition.tmpl" import struct_def %} | 3 {% from "struct_definition.tmpl" import struct_def %} |
4 | 4 |
5 {%- macro declare_params(parameters, boxed=false) %} | 5 {%- macro declare_params(parameters, boxed=false) %} |
6 {%- for param in parameters -%} | 6 {%- for param in parameters -%} |
7 {{param.kind|java_type(boxed)}} {{param|name}} | 7 {{param.kind|java_type(boxed)}} {{param|name}} |
8 {%- if not loop.last %}, {% endif %} | 8 {%- if not loop.last %}, {% endif %} |
9 {%- endfor %} | 9 {%- endfor %} |
10 {%- endmacro %} | 10 {%- endmacro %} |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return {{client|java_type}}.MANAGER; | 86 return {{client|java_type}}.MANAGER; |
87 } | 87 } |
88 {% endif %} | 88 {% endif %} |
89 }; | 89 }; |
90 {%- endmacro -%} | 90 {%- endmacro -%} |
91 | 91 |
92 {%- macro accept_body(interface, with_response) -%} | 92 {%- macro accept_body(interface, with_response) -%} |
93 {% if (interface|has_method_with_response and with_response) or | 93 {% if (interface|has_method_with_response and with_response) or |
94 (interface|has_method_without_response and not with_response) %} | 94 (interface|has_method_without_response and not with_response) %} |
95 try { | 95 try { |
96 org.chromium.mojo.bindings.MessageWithHeader messageWithHeader = | 96 org.chromium.mojo.bindings.ServiceMessage messageWithHeader = |
97 message.asMojoMessage(); | 97 message.asServiceMessage(); |
98 org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeade
r(); | 98 org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeade
r(); |
99 if (!header.validateHeader({{flags(with_response, True)}})) { | 99 if (!header.validateHeader({{flags(with_response, True)}})) { |
100 return false; | 100 return false; |
101 } | 101 } |
102 switch(header.getType()) { | 102 switch(header.getType()) { |
103 {% for method in interface.methods %} | 103 {% for method in interface.methods %} |
104 {% if (with_response and method.response_parameters) or | 104 {% if (with_response and method.response_parameters) or |
105 (not with_response and not method.response_parameters) %} | 105 (not with_response and not method.response_parameters) %} |
106 {% set request_struct = method|struct_from_method %} | 106 {% set request_struct = method|struct_from_method %} |
107 {% if with_response %} | 107 {% if with_response %} |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 implements org.chromium.mojo.bindings.MessageReceiver { | 227 implements org.chromium.mojo.bindings.MessageReceiver { |
228 private final {{interface|name}}.{{method|interface_response_name}} mCal
lback; | 228 private final {{interface|name}}.{{method|interface_response_name}} mCal
lback; |
229 | 229 |
230 {{response_struct|name}}ForwardToCallback({{interface|name}}.{{method|in
terface_response_name}} callback) { | 230 {{response_struct|name}}ForwardToCallback({{interface|name}}.{{method|in
terface_response_name}} callback) { |
231 this.mCallback = callback; | 231 this.mCallback = callback; |
232 } | 232 } |
233 | 233 |
234 @Override | 234 @Override |
235 public boolean accept(org.chromium.mojo.bindings.Message message) { | 235 public boolean accept(org.chromium.mojo.bindings.Message message) { |
236 try { | 236 try { |
237 org.chromium.mojo.bindings.MessageWithHeader messageWithHeader = | 237 org.chromium.mojo.bindings.ServiceMessage messageWithHeader = |
238 message.asMojoMessage(); | 238 message.asServiceMessage(); |
239 org.chromium.mojo.bindings.MessageHeader header = messageWithHea
der.getHeader(); | 239 org.chromium.mojo.bindings.MessageHeader header = messageWithHea
der.getHeader(); |
240 if (!header.validateHeader({{method|method_ordinal_name}}, | 240 if (!header.validateHeader({{method|method_ordinal_name}}, |
241 {{flags_for_method(method, False)}}))
{ | 241 {{flags_for_method(method, False)}}))
{ |
242 return false; | 242 return false; |
243 } | 243 } |
244 {{response_struct|name}} response = {{response_struct|name}}.des
erialize(messageWithHeader.getPayload()); | 244 {{response_struct|name}} response = {{response_struct|name}}.des
erialize(messageWithHeader.getPayload()); |
245 mCallback.call({{run_callback('response', method.response_parame
ters)}}); | 245 mCallback.call({{run_callback('response', method.response_parame
ters)}}); |
246 return true; | 246 return true; |
247 } catch (org.chromium.mojo.bindings.DeserializationException e) { | 247 } catch (org.chromium.mojo.bindings.DeserializationException e) { |
248 return false; | 248 return false; |
(...skipping 15 matching lines...) Expand all Loading... |
264 mMessageReceiver = messageReceiver; | 264 mMessageReceiver = messageReceiver; |
265 mRequestId = requestId; | 265 mRequestId = requestId; |
266 } | 266 } |
267 | 267 |
268 @Override | 268 @Override |
269 public void call({{declare_params(method.response_parameters, true)}}) { | 269 public void call({{declare_params(method.response_parameters, true)}}) { |
270 {{response_struct|name}} response = new {{response_struct|name}}(); | 270 {{response_struct|name}} response = new {{response_struct|name}}(); |
271 {% for param in method.response_parameters %} | 271 {% for param in method.response_parameters %} |
272 response.{{param|name}} = {{param|name}}; | 272 response.{{param|name}} = {{param|name}}; |
273 {% endfor %} | 273 {% endfor %} |
274 org.chromium.mojo.bindings.MessageWithHeader message = | 274 org.chromium.mojo.bindings.ServiceMessage message = |
275 response.serializeWithHeader( | 275 response.serializeWithHeader( |
276 mCore, | 276 mCore, |
277 new org.chromium.mojo.bindings.MessageHeader( | 277 new org.chromium.mojo.bindings.MessageHeader( |
278 {{method|method_ordinal_name}}, | 278 {{method|method_ordinal_name}}, |
279 {{flags_for_method(method, False)}}, | 279 {{flags_for_method(method, False)}}, |
280 mRequestId)); | 280 mRequestId)); |
281 mMessageReceiver.accept(message); | 281 mMessageReceiver.accept(message); |
282 } | 282 } |
283 } | 283 } |
284 {% endif %} | 284 {% endif %} |
285 {% endfor %} | 285 {% endfor %} |
286 | 286 |
287 } | 287 } |
288 {% endmacro %} | 288 {% endmacro %} |
OLD | NEW |