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

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

Issue 2259283003: Mojo C++ bindings: share DataView class between chromium and blink variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@92_change_traits_param
Patch Set: . Created 4 years, 3 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 {# TODO(yzshen): Make these templates more readable. #} 1 {# TODO(yzshen): Make these templates more readable. #}
2 2
3 {# Computes the serialized size for the specified struct. 3 {# Computes the serialized size for the specified struct.
4 |struct| is the struct definition. 4 |struct| is the struct definition.
5 |input_field_pattern| should be a pattern that contains one string 5 |input_field_pattern| should be a pattern that contains one string
6 placeholder, for example, "input->%s", "p_%s". The placeholder will be 6 placeholder, for example, "input->%s", "p_%s". The placeholder will be
7 substituted with struct field names to refer to the input fields. 7 substituted with struct field names to refer to the input fields.
8 |context| is the name of the serialization context. 8 |context| is the name of the serialization context.
9 |input_may_be_temp| indicates whether any input may be temporary obejcts. 9 |input_may_be_temp| indicates whether any input may be temporary obejcts.
10 We need to assign temporary objects to local variables before passing it to 10 We need to assign temporary objects to local variables before passing it to
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 - method parameters/response parameters: the output is a list of 141 - method parameters/response parameters: the output is a list of
142 arguments. #} 142 arguments. #}
143 {%- macro deserialize(struct, input, output_field_pattern, success) -%} 143 {%- macro deserialize(struct, input, output_field_pattern, success) -%}
144 {%- for pf in struct.packed.packed_fields_in_ordinal_order %} 144 {%- for pf in struct.packed.packed_fields_in_ordinal_order %}
145 {%- set output_field = output_field_pattern|format(pf.field.name) %} 145 {%- set output_field = output_field_pattern|format(pf.field.name) %}
146 {%- set name = pf.field.name %} 146 {%- set name = pf.field.name %}
147 {%- set kind = pf.field.kind %} 147 {%- set kind = pf.field.kind %}
148 {%- if kind|is_object_kind or kind|is_enum_kind %} 148 {%- if kind|is_object_kind or kind|is_enum_kind %}
149 if (!{{input}}.Read{{name|under_to_camel}}(&{{output_field}})) 149 if (!{{input}}.Read{{name|under_to_camel}}(&{{output_field}}))
150 {{success}} = false; 150 {{success}} = false;
151 {%- elif kind|is_any_handle_or_interface_kind %} 151 {%- elif kind|is_any_handle_kind %}
152 {{output_field}} = {{input}}.Take{{name|under_to_camel}}(); 152 {{output_field}} = {{input}}.Take{{name|under_to_camel}}();
153 {%- elif kind|is_any_interface_kind %}
154 {{output_field}} =
155 {{input}}.Take{{name|under_to_camel}}<decltype({{output_field}})>();
153 {%- else %} 156 {%- else %}
154 {{output_field}} = {{input}}.{{name}}(); 157 {{output_field}} = {{input}}.{{name}}();
155 {%- endif %} 158 {%- endif %}
156 {%- endfor %} 159 {%- endfor %}
157 {%- endmacro %} 160 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698