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.MessageHeader header = message.getHeader(); | 96 org.chromium.mojo.bindings.MessageWithHeader messageWithHeader = |
| 97 message.asMojoMessage(); |
| 98 org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeade
r(); |
97 if (!header.validateHeader({{flags(with_response, True)}})) { | 99 if (!header.validateHeader({{flags(with_response, True)}})) { |
98 return false; | 100 return false; |
99 } | 101 } |
100 switch(header.getType()) { | 102 switch(header.getType()) { |
101 {% for method in interface.methods %} | 103 {% for method in interface.methods %} |
102 {% if (with_response and method.response_parameters) or | 104 {% if (with_response and method.response_parameters) or |
103 (not with_response and not method.response_parameters) %} | 105 (not with_response and not method.response_parameters) %} |
104 {% set request_struct = method|struct_from_method %} | 106 {% set request_struct = method|struct_from_method %} |
105 {% if with_response %} | 107 {% if with_response %} |
106 {% set response_struct = method|response_struct_from_method %} | 108 {% set response_struct = method|response_struct_from_method %} |
107 {% endif %} | 109 {% endif %} |
108 case {{method|method_ordinal_name}}: { | 110 case {{method|method_ordinal_name}}: { |
109 {% if method.parameters %} | 111 {% if method.parameters %} |
110 {{request_struct|name}} data = | 112 {{request_struct|name}} data = |
111 {{request_struct|name}}.deserialize(message.getPayload()); | 113 {{request_struct|name}}.deserialize(messageWithHeader.getPay
load()); |
112 {% else %} | 114 {% else %} |
113 {{request_struct|name}}.deserialize(message.getPayload()); | 115 {{request_struct|name}}.deserialize(messageWithHeader.getPayload()); |
114 {% endif %} | 116 {% endif %} |
115 getImpl().{{method|name}}({{run_callback('data', method.parameters)}
}{% if with_response %}{% if method.parameters %}, {% endif %}new {{response_str
uct|name}}ProxyToResponder(getCore(), receiver, header.getRequestId()){% endif %
}); | 117 getImpl().{{method|name}}({{run_callback('data', method.parameters)}
}{% if with_response %}{% if method.parameters %}, {% endif %}new {{response_str
uct|name}}ProxyToResponder(getCore(), receiver, header.getRequestId()){% endif %
}); |
116 return true; | 118 return true; |
117 } | 119 } |
118 {% endif %} | 120 {% endif %} |
119 {% endfor %} | 121 {% endfor %} |
120 default: | 122 default: |
121 return false; | 123 return false; |
122 } | 124 } |
123 } catch (org.chromium.mojo.bindings.DeserializationException e) { | 125 } catch (org.chromium.mojo.bindings.DeserializationException e) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 199 |
198 } | 200 } |
199 | 201 |
200 static final class Stub extends org.chromium.mojo.bindings.Interface.Stub<{{
interface|name}}> { | 202 static final class Stub extends org.chromium.mojo.bindings.Interface.Stub<{{
interface|name}}> { |
201 | 203 |
202 Stub(org.chromium.mojo.system.Core core, {{interface|name}} impl) { | 204 Stub(org.chromium.mojo.system.Core core, {{interface|name}} impl) { |
203 super(core, impl); | 205 super(core, impl); |
204 } | 206 } |
205 | 207 |
206 @Override | 208 @Override |
207 public boolean accept(org.chromium.mojo.bindings.MessageWithHeader messa
ge) { | 209 public boolean accept(org.chromium.mojo.bindings.Message message) { |
208 {{accept_body(interface, False)|indent(12)}} | 210 {{accept_body(interface, False)|indent(12)}} |
209 } | 211 } |
210 | 212 |
211 @Override | 213 @Override |
212 public boolean acceptWithResponder(org.chromium.mojo.bindings.MessageWit
hHeader message, org.chromium.mojo.bindings.MessageReceiver receiver) { | 214 public boolean acceptWithResponder(org.chromium.mojo.bindings.Message me
ssage, org.chromium.mojo.bindings.MessageReceiver receiver) { |
213 {{accept_body(interface, True)|indent(12)}} | 215 {{accept_body(interface, True)|indent(12)}} |
214 } | 216 } |
215 } | 217 } |
216 {% for method in interface.methods %} | 218 {% for method in interface.methods %} |
217 | 219 |
218 {{ struct_def(method|struct_from_method, True)|indent(4) }} | 220 {{ struct_def(method|struct_from_method, True)|indent(4) }} |
219 {% if method.response_parameters %} | 221 {% if method.response_parameters %} |
220 {% set response_struct = method|response_struct_from_method %} | 222 {% set response_struct = method|response_struct_from_method %} |
221 | 223 |
222 {{ struct_def(response_struct, True)|indent(4) }} | 224 {{ struct_def(response_struct, True)|indent(4) }} |
223 | 225 |
224 static class {{response_struct|name}}ForwardToCallback extends org.chromium.
mojo.bindings.SideEffectFreeCloseable | 226 static class {{response_struct|name}}ForwardToCallback extends org.chromium.
mojo.bindings.SideEffectFreeCloseable |
225 implements org.chromium.mojo.bindings.MessageReceiver { | 227 implements org.chromium.mojo.bindings.MessageReceiver { |
226 private final {{interface|name}}.{{method|interface_response_name}} mCal
lback; | 228 private final {{interface|name}}.{{method|interface_response_name}} mCal
lback; |
227 | 229 |
228 {{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) { |
229 this.mCallback = callback; | 231 this.mCallback = callback; |
230 } | 232 } |
231 | 233 |
232 @Override | 234 @Override |
233 public boolean accept(org.chromium.mojo.bindings.MessageWithHeader messa
ge) { | 235 public boolean accept(org.chromium.mojo.bindings.Message message) { |
234 try { | 236 try { |
235 org.chromium.mojo.bindings.MessageHeader header = message.getHea
der(); | 237 org.chromium.mojo.bindings.MessageWithHeader messageWithHeader = |
| 238 message.asMojoMessage(); |
| 239 org.chromium.mojo.bindings.MessageHeader header = messageWithHea
der.getHeader(); |
236 if (!header.validateHeader({{method|method_ordinal_name}}, | 240 if (!header.validateHeader({{method|method_ordinal_name}}, |
237 {{flags_for_method(method, False)}}))
{ | 241 {{flags_for_method(method, False)}}))
{ |
238 return false; | 242 return false; |
239 } | 243 } |
240 {{response_struct|name}} response = {{response_struct|name}}.des
erialize(message.getPayload()); | 244 {{response_struct|name}} response = {{response_struct|name}}.des
erialize(messageWithHeader.getPayload()); |
241 mCallback.call({{run_callback('response', method.response_parame
ters)}}); | 245 mCallback.call({{run_callback('response', method.response_parame
ters)}}); |
242 return true; | 246 return true; |
243 } catch (org.chromium.mojo.bindings.DeserializationException e) { | 247 } catch (org.chromium.mojo.bindings.DeserializationException e) { |
244 return false; | 248 return false; |
245 } | 249 } |
246 } | 250 } |
247 } | 251 } |
248 | 252 |
249 static class {{response_struct|name}}ProxyToResponder implements {{interface
|name}}.{{method|interface_response_name}} { | 253 static class {{response_struct|name}}ProxyToResponder implements {{interface
|name}}.{{method|interface_response_name}} { |
250 | 254 |
(...skipping 24 matching lines...) Expand all Loading... |
275 {{flags_for_method(method, False)}}, | 279 {{flags_for_method(method, False)}}, |
276 mRequestId)); | 280 mRequestId)); |
277 mMessageReceiver.accept(message); | 281 mMessageReceiver.accept(message); |
278 } | 282 } |
279 } | 283 } |
280 {% endif %} | 284 {% endif %} |
281 {% endfor %} | 285 {% endfor %} |
282 | 286 |
283 } | 287 } |
284 {% endmacro %} | 288 {% endmacro %} |
OLD | NEW |