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

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

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: rebase Created 4 years, 11 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 This macro is expanded to compute seriailized size for both: 8 This macro is expanded to compute seriailized size for both:
9 - user-defined structs: the input is an instance of the corresponding struct 9 - user-defined structs: the input is an instance of the corresponding struct
10 wrapper class. 10 wrapper class.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, 103 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
104 "invalid {{name}} in {{struct_display_name}}"); 104 "invalid {{name}} in {{struct_display_name}}");
105 {%- endif %} 105 {%- endif %}
106 {%- elif kind|is_associated_kind %} 106 {%- elif kind|is_associated_kind %}
107 // TODO(yzshen): add some DCHECKs for non-nullable, is_local, correct router, etc. 107 // TODO(yzshen): add some DCHECKs for non-nullable, is_local, correct router, etc.
108 {%- if kind|is_associated_interface_kind %} 108 {%- if kind|is_associated_interface_kind %}
109 mojo::internal::AssociatedInterfacePtrInfoToData(std::move({{input_field}}), & {{output}}->{{name}}); 109 mojo::internal::AssociatedInterfacePtrInfoToData(std::move({{input_field}}), & {{output}}->{{name}});
110 {%- else %} 110 {%- else %}
111 {{output}}->{{name}} = mojo::internal::AssociatedInterfaceRequestHelper::PassH andle(&{{input_field}}).release(); 111 {{output}}->{{name}} = mojo::internal::AssociatedInterfaceRequestHelper::PassH andle(&{{input_field}}).release();
112 {%- endif %} 112 {%- endif %}
113 {%- elif kind|is_enum_kind %}
114 {{output}}->{{name}} = static_cast<int32_t>({{input_field}});
113 {%- else %} 115 {%- else %}
114 {{output}}->{{name}} = {{input_field}}; 116 {{output}}->{{name}} = {{input_field}};
115 {%- endif %} 117 {%- endif %}
116 {%- endfor %} 118 {%- endfor %}
117 {%- endmacro -%} 119 {%- endmacro -%}
118 120
119 {# Deserializes the specified struct. 121 {# Deserializes the specified struct.
120 |struct| is the struct definition. 122 |struct| is the struct definition.
121 |input| is the name of the input struct instance. 123 |input| is the name of the input struct instance.
122 |output_field_pattern| should be a pattern that contains one string 124 |output_field_pattern| should be a pattern that contains one string
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 &{{output_field}}, 181 &{{output_field}},
180 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn dReset(&{{input}}->{{name}}))); 182 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn dReset(&{{input}}->{{name}})));
181 {%- elif kind|is_enum_kind %} 183 {%- elif kind|is_enum_kind %}
182 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name} }); 184 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name} });
183 {%- else %} 185 {%- else %}
184 {{output_field}} = {{input}}->{{name}}; 186 {{output_field}} = {{input}}->{{name}};
185 {%- endif %} 187 {%- endif %}
186 {%- endfor %} 188 {%- endfor %}
187 } while (false); 189 } while (false);
188 {%- endmacro %} 190 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698