OLD | NEW |
1 size_t GetSerializedSize_(const {{union.name}}Ptr& input, bool inlined) { | 1 size_t GetSerializedSize_(const {{union.name}}Ptr& input, bool inlined) { |
2 size_t size = 0U; | 2 size_t size = 0U; |
3 if (!inlined) { | 3 if (!inlined) { |
4 size += sizeof(internal::{{union.name}}_Data); | 4 size += sizeof(internal::{{union.name}}_Data); |
5 } | 5 } |
6 | 6 |
7 if (!input) | 7 if (!input) |
8 return size; | 8 return size; |
9 | 9 |
10 mojo::internal::UnionAccessor<{{union.name}}> input_acc(input.get()); | 10 mojo::internal::UnionAccessor<{{union.name}}> input_acc(input.get()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 input_acc.data()->{{field.name}}->release().value(); | 72 input_acc.data()->{{field.name}}->release().value(); |
73 {% elif field.kind|is_interface_kind %} | 73 {% elif field.kind|is_interface_kind %} |
74 mojo::internal::Interface_Data* {{field.name}} = | 74 mojo::internal::Interface_Data* {{field.name}} = |
75 reinterpret_cast<mojo::internal::Interface_Data*>( | 75 reinterpret_cast<mojo::internal::Interface_Data*>( |
76 &result->data.f_{{field.name}}); | 76 &result->data.f_{{field.name}}); |
77 mojo::internal::InterfacePointerToData( | 77 mojo::internal::InterfacePointerToData( |
78 std::move(*input_acc.data()->{{field.name}}), {{field.name}}); | 78 std::move(*input_acc.data()->{{field.name}}), {{field.name}}); |
79 {%- elif field.kind|is_associated_kind %} | 79 {%- elif field.kind|is_associated_kind %} |
80 // TODO(yzshen): add seralization logic for associated kinds. | 80 // TODO(yzshen): add seralization logic for associated kinds. |
81 {% elif field.kind|is_enum_kind %} | 81 {% elif field.kind|is_enum_kind %} |
82 result->data.f_{{field.name}} = static_cast<int32_t>(input_acc.data()->{
{field.name}}); | 82 result->data.f_{{field.name}}.value = static_cast<int32_t>(input_acc.dat
a()->{{field.name}}); |
83 {% else %} | 83 {% else %} |
84 result->data.f_{{field.name}} = input_acc.data()->{{field.name}}; | 84 result->data.f_{{field.name}} = input_acc.data()->{{field.name}}; |
85 {%- endif %} | 85 {%- endif %} |
86 break; | 86 break; |
87 } | 87 } |
88 {%- endfor %} | 88 {%- endfor %} |
89 } | 89 } |
90 } else if (inlined) { | 90 } else if (inlined) { |
91 result->set_null(); | 91 result->set_null(); |
92 } else { | 92 } else { |
(...skipping 24 matching lines...) Expand all Loading... |
117 {{field.kind|cpp_wrapper_type}} {{field.name}}_out; | 117 {{field.kind|cpp_wrapper_type}} {{field.name}}_out; |
118 mojo::internal::Interface_Data* {{field.name}}_in = | 118 mojo::internal::Interface_Data* {{field.name}}_in = |
119 reinterpret_cast<mojo::internal::Interface_Data*>( | 119 reinterpret_cast<mojo::internal::Interface_Data*>( |
120 &input->data.f_{{field.name}}); | 120 &input->data.f_{{field.name}}); |
121 mojo::internal::InterfaceDataToPointer( | 121 mojo::internal::InterfaceDataToPointer( |
122 {{field.name}}_in, &{{field.name}}_out); | 122 {{field.name}}_in, &{{field.name}}_out); |
123 result->set_{{field.name}}(std::move({{field.name}}_out)); | 123 result->set_{{field.name}}(std::move({{field.name}}_out)); |
124 {%- elif field.kind|is_associated_kind %} | 124 {%- elif field.kind|is_associated_kind %} |
125 // TODO(yzshen): add deserialization logic for associated kinds. | 125 // TODO(yzshen): add deserialization logic for associated kinds. |
126 {% elif field.kind|is_enum_kind %} | 126 {% elif field.kind|is_enum_kind %} |
127 result->set_{{field.name}}(static_cast<{{field.kind|cpp_wrapper_type}}>(
input->data.f_{{field.name}})); | 127 result->set_{{field.name}}(static_cast<{{field.kind|cpp_wrapper_type}}>(
input->data.f_{{field.name}}.value)); |
128 {% else %} | 128 {% else %} |
129 result->set_{{field.name}}(input->data.f_{{field.name}}); | 129 result->set_{{field.name}}(input->data.f_{{field.name}}); |
130 {%- endif %} | 130 {%- endif %} |
131 break; | 131 break; |
132 } | 132 } |
133 {%- endfor %} | 133 {%- endfor %} |
134 } | 134 } |
135 *output = std::move(result); | 135 *output = std::move(result); |
136 } else { | 136 } else { |
137 output->reset(); | 137 output->reset(); |
138 } | 138 } |
139 return success; | 139 return success; |
140 } | 140 } |
OLD | NEW |