Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1584)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl

Issue 1635613002: [mojo-bindings] Support reuse of native enum classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more missing public_deps Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 or 22 {%- if kind|is_array_kind or kind|is_string_kind or
23 kind|is_native_only_kind %} 23 kind|is_native_struct_kind %}
24 const mojo::internal::ArrayValidateParams {{name}}_validate_params( 24 const mojo::internal::ArrayValidateParams {{name}}_validate_params(
25 {{kind|get_array_validate_params_ctor_args|indent(6)}}); 25 {{kind|get_array_validate_params_ctor_args|indent(6)}});
26 if (!mojo::internal::ValidateArray(object->{{name}}, bounds_checker, 26 if (!mojo::internal::ValidateArray(object->{{name}}, bounds_checker,
27 &{{name}}_validate_params)) { 27 &{{name}}_validate_params)) {
28 return false; 28 return false;
29 } 29 }
30 {%- elif kind|is_map_kind %} 30 {%- elif kind|is_map_kind %}
31 const mojo::internal::ArrayValidateParams {{name}}_validate_params( 31 const mojo::internal::ArrayValidateParams {{name}}_validate_params(
32 {{kind.value_kind|get_map_validate_params_ctor_args|indent(6)}}); 32 {{kind.value_kind|get_map_validate_params_ctor_args|indent(6)}});
33 if (!mojo::internal::ValidateMap(object->{{name}}, bounds_checker, 33 if (!mojo::internal::ValidateMap(object->{{name}}, bounds_checker,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 mojo::internal::DecodeHandle(&{{name}}, handles); 217 mojo::internal::DecodeHandle(&{{name}}, handles);
218 {%- endif %} 218 {%- endif %}
219 {%- endif %} 219 {%- endif %}
220 {%- endfor %} 220 {%- endfor %}
221 } 221 }
222 222
223 {{class_name}}::{{class_name}}() { 223 {{class_name}}::{{class_name}}() {
224 header_.num_bytes = sizeof(*this); 224 header_.num_bytes = sizeof(*this);
225 header_.version = {{struct.versions[-1].version}}; 225 header_.version = {{struct.versions[-1].version}};
226 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698