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

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

Issue 622593002: mojo: Allow circular dependencies between structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 {%- macro validate(struct, class_name) %} 1 {%- macro validate(struct, class_name) %}
2 if (!data) 2 if (!data)
3 return true; 3 return true;
4 4
5 if (!ValidateStructHeader( 5 if (!ValidateStructHeader(
6 data, sizeof({{class_name}}), 6 data, sizeof({{class_name}}),
7 {{struct.packed.packed_fields|length}}, bounds_checker)) { 7 {{struct.packed.packed_fields|length}}, bounds_checker)) {
8 return false; 8 return false;
9 } 9 }
10 10
(...skipping 20 matching lines...) Expand all
31 {%- if kind|is_any_array_kind or kind|is_string_kind %} 31 {%- if kind|is_any_array_kind or kind|is_string_kind %}
32 if (!{{wrapper_type}}::Data_::Validate< 32 if (!{{wrapper_type}}::Data_::Validate<
33 {{kind|get_array_validate_params|indent(10)}}>( 33 {{kind|get_array_validate_params|indent(10)}}>(
34 mojo::internal::DecodePointerRaw(&object->{{name}}.offset), 34 mojo::internal::DecodePointerRaw(&object->{{name}}.offset),
35 bounds_checker)) { 35 bounds_checker)) {
36 {%- elif kind|is_map_kind %} 36 {%- elif kind|is_map_kind %}
37 if (!{{wrapper_type}}::Data_::Validate< 37 if (!{{wrapper_type}}::Data_::Validate<
38 {{kind.value_kind|get_map_validate_params|indent(10)}}>( 38 {{kind.value_kind|get_map_validate_params|indent(10)}}>(
39 mojo::internal::DecodePointerRaw(&object->{{name}}.offset), 39 mojo::internal::DecodePointerRaw(&object->{{name}}.offset),
40 bounds_checker)) { 40 bounds_checker)) {
41 {%- elif kind|is_struct_kind %}
42 if (!{{kind|get_name_for_kind}}::Data_::Validate(
43 mojo::internal::DecodePointerRaw(&object->{{name}}.offset),
44 bounds_checker)) {
41 {%- else %} 45 {%- else %}
42 if (!{{wrapper_type}}::Data_::Validate( 46 if (!{{wrapper_type}}::Data_::Validate(
43 mojo::internal::DecodePointerRaw(&object->{{name}}.offset), 47 mojo::internal::DecodePointerRaw(&object->{{name}}.offset),
44 bounds_checker)) { 48 bounds_checker)) {
45 {%- endif %} 49 {%- endif %}
46 return false; 50 return false;
47 } 51 }
48 {%- elif kind|is_any_handle_kind %} 52 {%- elif kind|is_any_handle_kind %}
49 {%- if not kind|is_nullable_kind %} 53 {%- if not kind|is_nullable_kind %}
50 if (object->{{name}}.value() == mojo::internal::kEncodedInvalidHandleValue) { 54 if (object->{{name}}.value() == mojo::internal::kEncodedInvalidHandleValue) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 115
112 {%- macro decodes(struct) -%} 116 {%- macro decodes(struct) -%}
113 {%- for pf in struct.packed.packed_fields %} 117 {%- for pf in struct.packed.packed_fields %}
114 {%- if pf.field.kind|is_object_kind %} 118 {%- if pf.field.kind|is_object_kind %}
115 mojo::internal::Decode(&{{pf.field.name}}, handles); 119 mojo::internal::Decode(&{{pf.field.name}}, handles);
116 {%- elif pf.field.kind|is_any_handle_kind %} 120 {%- elif pf.field.kind|is_any_handle_kind %}
117 mojo::internal::DecodeHandle(&{{pf.field.name}}, handles); 121 mojo::internal::DecodeHandle(&{{pf.field.name}}, handles);
118 {%- endif %} 122 {%- endif %}
119 {%- endfor %} 123 {%- endfor %}
120 {%- endmacro -%} 124 {%- endmacro -%}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698