OLD | NEW |
1 {%- set class_name = struct.name ~ "_Data" %} | 1 {%- set class_name = struct.name ~ "_Data" %} |
2 | 2 |
3 {#- Validates the specified struct field, which is supposed to be an object | 3 {#- Validates the specified struct field, which is supposed to be an object |
4 (struct/array/string/map/union). | 4 (struct/array/string/map/union). |
5 This macro is expanded by the Validate() method. #} | 5 This macro is expanded by the Validate() method. #} |
6 {%- macro _validate_object(struct, packed_field) %} | 6 {%- macro _validate_object(struct, packed_field) %} |
7 {%- set name = packed_field.field.name %} | 7 {%- set name = packed_field.field.name %} |
8 {%- set kind = packed_field.field.kind %} | 8 {%- set kind = packed_field.field.kind %} |
9 {%- if not kind|is_nullable_kind %} | 9 {%- if not kind|is_nullable_kind %} |
10 {%- if kind|is_union_kind %} | 10 {%- if kind|is_union_kind %} |
11 if (!mojo::internal::ValidateInlinedUnionNonNullable( | 11 if (!mojo::internal::ValidateInlinedUnionNonNullable( |
12 object->{{name}}, "null {{name}} field in {{struct.name}} struct")) { | 12 object->{{name}}, "null {{name}} field in {{struct.name}} struct")) { |
13 return false; | 13 return false; |
14 } | 14 } |
15 {%- else %} | 15 {%- else %} |
16 if (!mojo::internal::ValidatePointerNonNullable( | 16 if (!mojo::internal::ValidatePointerNonNullable( |
17 object->{{name}}, "null {{name}} field in {{struct.name}} struct")) { | 17 object->{{name}}, "null {{name}} field in {{struct.name}} struct")) { |
18 return false; | 18 return false; |
19 } | 19 } |
20 {%- endif %} | 20 {%- endif %} |
21 {%- endif %} | 21 {%- endif %} |
22 {%- if kind|is_array_kind or kind|is_string_kind %} | 22 {%- if kind|is_array_kind or kind|is_string_kind or |
| 23 kind|is_native_only_kind %} |
23 const mojo::internal::ArrayValidateParams {{name}}_validate_params( | 24 const mojo::internal::ArrayValidateParams {{name}}_validate_params( |
24 {{kind|get_array_validate_params_ctor_args|indent(6)}}); | 25 {{kind|get_array_validate_params_ctor_args|indent(6)}}); |
25 if (!mojo::internal::ValidateArray(object->{{name}}, bounds_checker, | 26 if (!mojo::internal::ValidateArray(object->{{name}}, bounds_checker, |
26 &{{name}}_validate_params)) { | 27 &{{name}}_validate_params)) { |
27 return false; | 28 return false; |
28 } | 29 } |
29 {%- elif kind|is_map_kind %} | 30 {%- elif kind|is_map_kind %} |
30 const mojo::internal::ArrayValidateParams {{name}}_validate_params( | 31 const mojo::internal::ArrayValidateParams {{name}}_validate_params( |
31 {{kind.value_kind|get_map_validate_params_ctor_args|indent(6)}}); | 32 {{kind.value_kind|get_map_validate_params_ctor_args|indent(6)}}); |
32 if (!mojo::internal::ValidateMap(object->{{name}}, bounds_checker, | 33 if (!mojo::internal::ValidateMap(object->{{name}}, bounds_checker, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 mojo::internal::DecodeHandle(&{{name}}, handles); | 205 mojo::internal::DecodeHandle(&{{name}}, handles); |
205 {%- endif %} | 206 {%- endif %} |
206 {%- endif %} | 207 {%- endif %} |
207 {%- endfor %} | 208 {%- endfor %} |
208 } | 209 } |
209 | 210 |
210 {{class_name}}::{{class_name}}() { | 211 {{class_name}}::{{class_name}}() { |
211 header_.num_bytes = sizeof(*this); | 212 header_.num_bytes = sizeof(*this); |
212 header_.version = {{struct.versions[-1].version}}; | 213 header_.version = {{struct.versions[-1].version}}; |
213 } | 214 } |
OLD | NEW |