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

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

Issue 611633002: mojom: Add associative arrays to the mojom language. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved test classes to their own shared file. 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 15 matching lines...) Expand all
26 {%- endif %} 26 {%- endif %}
27 if (!mojo::internal::ValidateEncodedPointer(&object->{{name}}.offset)) { 27 if (!mojo::internal::ValidateEncodedPointer(&object->{{name}}.offset)) {
28 ReportValidationError(mojo::internal::VALIDATION_ERROR_ILLEGAL_POINTER); 28 ReportValidationError(mojo::internal::VALIDATION_ERROR_ILLEGAL_POINTER);
29 return false; 29 return false;
30 } 30 }
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 %}
37 if (!{{wrapper_type}}::Data_::Validate<
38 {{kind.value_kind|get_map_validate_params|indent(10)}}>(
39 mojo::internal::DecodePointerRaw(&object->{{name}}.offset),
40 bounds_checker)) {
36 {%- else %} 41 {%- else %}
37 if (!{{wrapper_type}}::Data_::Validate( 42 if (!{{wrapper_type}}::Data_::Validate(
38 mojo::internal::DecodePointerRaw(&object->{{name}}.offset), 43 mojo::internal::DecodePointerRaw(&object->{{name}}.offset),
39 bounds_checker)) { 44 bounds_checker)) {
40 {%- endif %} 45 {%- endif %}
41 return false; 46 return false;
42 } 47 }
43 {%- elif kind|is_any_handle_kind %} 48 {%- elif kind|is_any_handle_kind %}
44 {%- if not kind|is_nullable_kind %} 49 {%- if not kind|is_nullable_kind %}
45 if (object->{{name}}.value() == mojo::internal::kEncodedInvalidHandleValue) { 50 if (object->{{name}}.value() == mojo::internal::kEncodedInvalidHandleValue) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 111
107 {%- macro decodes(struct) -%} 112 {%- macro decodes(struct) -%}
108 {%- for pf in struct.packed.packed_fields %} 113 {%- for pf in struct.packed.packed_fields %}
109 {%- if pf.field.kind|is_object_kind %} 114 {%- if pf.field.kind|is_object_kind %}
110 mojo::internal::Decode(&{{pf.field.name}}, handles); 115 mojo::internal::Decode(&{{pf.field.name}}, handles);
111 {%- elif pf.field.kind|is_any_handle_kind %} 116 {%- elif pf.field.kind|is_any_handle_kind %}
112 mojo::internal::DecodeHandle(&{{pf.field.name}}, handles); 117 mojo::internal::DecodeHandle(&{{pf.field.name}}, handles);
113 {%- endif %} 118 {%- endif %}
114 {%- endfor %} 119 {%- endfor %}
115 {%- endmacro -%} 120 {%- endmacro -%}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698