OLD | NEW |
1 {%- import "interface_macros.tmpl" as interface_macros %} | 1 {%- import "interface_macros.tmpl" as interface_macros %} |
2 {%- import "struct_macros.tmpl" as struct_macros %} | 2 {%- import "struct_macros.tmpl" as struct_macros %} |
3 {%- from "enum_macros.tmpl" import is_valid_enum_def %} | 3 {%- from "enum_macros.tmpl" import is_valid_enum_def %} |
4 | 4 |
5 {%- set class_name = interface.name %} | 5 {%- set class_name = interface.name %} |
6 {%- set proxy_name = interface.name ~ "Proxy" %} | 6 {%- set proxy_name = interface.name ~ "Proxy" %} |
7 {%- set namespace_as_string = "%s"|format(namespace|replace(".","::")) %} | 7 {%- set namespace_as_string = "%s"|format(namespace|replace(".","::")) %} |
8 | 8 |
9 {%- macro alloc_params(struct, serialization_context) %} | 9 {%- macro alloc_params(struct, serialization_context) %} |
| 10 bool success = true; |
10 {%- for param in struct.packed.packed_fields_in_ordinal_order %} | 11 {%- for param in struct.packed.packed_fields_in_ordinal_order %} |
11 {{param.field.kind|cpp_result_type}} p_{{param.field.name}}{}; | 12 {{param.field.kind|cpp_result_type}} p_{{param.field.name}}{}; |
12 {%- endfor %} | 13 {%- endfor %} |
13 {{struct_macros.deserialize(struct, "params", "p_%s", serialization_context)}} | 14 {{struct_macros.deserialize(struct, "params", "p_%s", serialization_context, "
success")}} |
| 15 if (!success) |
| 16 return false; |
14 {%- endmacro %} | 17 {%- endmacro %} |
15 | 18 |
16 {%- macro pass_params(parameters) %} | 19 {%- macro pass_params(parameters) %} |
17 {%- for param in parameters %} | 20 {%- for param in parameters %} |
18 {%- if param.kind|is_move_only_kind -%} | 21 {%- if param.kind|is_move_only_kind -%} |
19 std::move(p_{{param.name}}) | 22 std::move(p_{{param.name}}) |
20 {%- else -%} | 23 {%- else -%} |
21 p_{{param.name}} | 24 p_{{param.name}} |
22 {%- endif -%} | 25 {%- endif -%} |
23 {%- if not loop.last %}, {% endif %} | 26 {%- if not loop.last %}, {% endif %} |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 switch (message->header()->name) { | 220 switch (message->header()->name) { |
218 {%- for method in interface.methods %} | 221 {%- for method in interface.methods %} |
219 case internal::k{{class_name}}_{{method.name}}_Name: { | 222 case internal::k{{class_name}}_{{method.name}}_Name: { |
220 mojo::internal::ScopedTaskTracking task_id("mojo::{{namespace_as_string}}:
:{{class_name}}::{{method.name}}", __FILE__, __LINE__); | 223 mojo::internal::ScopedTaskTracking task_id("mojo::{{namespace_as_string}}:
:{{class_name}}::{{method.name}}", __FILE__, __LINE__); |
221 {%- if method.response_parameters != None %} | 224 {%- if method.response_parameters != None %} |
222 internal::{{class_name}}_{{method.name}}_Params_Data* params = | 225 internal::{{class_name}}_{{method.name}}_Params_Data* params = |
223 reinterpret_cast<internal::{{class_name}}_{{method.name}}_Params_Data*
>( | 226 reinterpret_cast<internal::{{class_name}}_{{method.name}}_Params_Data*
>( |
224 message->mutable_payload()); | 227 message->mutable_payload()); |
225 | 228 |
226 params->DecodePointersAndHandles(message->mutable_handles()); | 229 params->DecodePointersAndHandles(message->mutable_handles()); |
| 230 {{alloc_params(method.param_struct, "&serialization_context_")|indent(4)}} |
227 {{class_name}}::{{method.name}}Callback::Runnable* runnable = | 231 {{class_name}}::{{method.name}}Callback::Runnable* runnable = |
228 new {{class_name}}_{{method.name}}_ProxyToResponder( | 232 new {{class_name}}_{{method.name}}_ProxyToResponder( |
229 message->request_id(), responder); | 233 message->request_id(), responder); |
230 {{class_name}}::{{method.name}}Callback callback(runnable); | 234 {{class_name}}::{{method.name}}Callback callback(runnable); |
231 {{alloc_params(method.param_struct, "&serialization_context_")|indent(4)}} | |
232 // A null |sink_| means no implementation was bound. | 235 // A null |sink_| means no implementation was bound. |
233 assert(sink_); | 236 assert(sink_); |
234 TRACE_EVENT0("mojom", "{{class_name}}::{{method.name}}"); | 237 TRACE_EVENT0("mojom", "{{class_name}}::{{method.name}}"); |
235 sink_->{{method.name}}( | 238 sink_->{{method.name}}( |
236 {%- if method.parameters -%}{{pass_params(method.parameters)}}, {% endif -%}call
back); | 239 {%- if method.parameters -%}{{pass_params(method.parameters)}}, {% endif -%}call
back); |
237 return true; | 240 return true; |
238 {%- else %} | 241 {%- else %} |
239 break; | 242 break; |
240 {%- endif %} | 243 {%- endif %} |
241 } | 244 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 default: | 320 default: |
318 break; | 321 break; |
319 } | 322 } |
320 | 323 |
321 // Unrecognized message. | 324 // Unrecognized message. |
322 ReportValidationError( | 325 ReportValidationError( |
323 mojo::internal::VALIDATION_ERROR_MESSAGE_HEADER_UNKNOWN_METHOD); | 326 mojo::internal::VALIDATION_ERROR_MESSAGE_HEADER_UNKNOWN_METHOD); |
324 return false; | 327 return false; |
325 } | 328 } |
326 {%- endif -%} | 329 {%- endif -%} |
OLD | NEW |