| Index: mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_definition.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_definition.tmpl
|
| index 2be92b30a3044507971cf071a010b5c2ec915681..175eb1e8a6d214069b8ba39001c9efb2d2bd4df7 100644
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_definition.tmpl
|
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_definition.tmpl
|
| @@ -1,16 +1,49 @@
|
| {{struct.name}}DataView::{{struct.name}}DataView(
|
| internal::{{struct.name}}_Data* data,
|
| mojo::internal::SerializationContext* context)
|
| - : data_(data), context_(context) {
|
| - DCHECK(data_);
|
| -}
|
| + : data_(data), context_(context) {}
|
|
|
| {%- for pf in struct.packed.packed_fields_in_ordinal_order %}
|
| -{%- set kind = pf.field.kind -%}
|
| -{%- set name = pf.field.name -%}
|
| -{%- if kind|is_struct_kind or kind|is_array_kind or kind|is_string_kind or
|
| - kind|is_map_kind %}
|
| -{#- Does nothing. They are already defined in the class declaration. #}
|
| +{%- set kind = pf.field.kind %}
|
| +{%- set name = pf.field.name %}
|
| +
|
| +{%- if kind|is_object_kind %}
|
| +{%- if kind|is_union_kind %}
|
| +void {{struct.name}}DataView::Get{{name|under_to_camel}}DataView(
|
| + {{kind|cpp_data_view_type}}* output) {
|
| +{%- if pf.min_version != 0 %}
|
| + auto pointer = data_->header_.version >= {{pf.min_version}}
|
| + ? &data_->{{name}} : nullptr;
|
| +{%- else %}
|
| + auto pointer = &data_->{{name}};
|
| +{%- endif %}
|
| + *output = {{kind|cpp_data_view_type}}(pointer, context_);
|
| +}
|
| +
|
| +bool {{struct.name}}DataView::Read{{name|under_to_camel}}(
|
| + {{kind|cpp_wrapper_type}}* output) {
|
| +{%- if pf.min_version != 0 %}
|
| + auto pointer = data_->header_.version >= {{pf.min_version}}
|
| + ? &data_->{{name}} : nullptr;
|
| +{%- else %}
|
| + auto pointer = &data_->{{name}};
|
| +{%- endif %}
|
| + return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>(
|
| + pointer, output, context_);
|
| +}
|
| +
|
| +{%- else %}
|
| +void {{struct.name}}DataView::Get{{name|under_to_camel}}DataView(
|
| + {{kind|cpp_data_view_type}}* output) {
|
| +{%- if pf.min_version != 0 %}
|
| + auto pointer = data_->header_.version >= {{pf.min_version}}
|
| + ? data_->{{name}}.Get() : nullptr;
|
| +{%- else %}
|
| + auto pointer = data_->{{name}}.Get();
|
| +{%- endif %}
|
| + *output = {{kind|cpp_data_view_type}}(pointer, context_);
|
| +}
|
| +{%- endif %}
|
|
|
| {%- elif kind|is_enum_kind %}
|
| {{kind|get_qualified_name_for_kind}} {{struct.name}}DataView::{{name}}() const {
|
| @@ -21,19 +54,6 @@
|
| return static_cast<{{kind|get_qualified_name_for_kind}}>(data_->{{name}});
|
| }
|
|
|
| -{%- elif kind|is_union_kind %}
|
| -bool {{struct.name}}DataView::Read{{name|under_to_camel}}(
|
| - {{kind|cpp_wrapper_type}}* value) {
|
| -{%- if pf.min_version != 0 %}
|
| - auto pointer = data_->header_.version >= {{pf.min_version}}
|
| - ? &data_->{{name}} : nullptr;
|
| -{%- else %}
|
| - auto pointer = &data_->{{name}};
|
| -{%- endif %}
|
| - return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>(
|
| - pointer, value, context_);
|
| -}
|
| -
|
| {%- elif kind|is_any_handle_or_interface_kind %}
|
| {{kind|cpp_wrapper_type}} {{struct.name}}DataView::Take{{name|under_to_camel}}() {
|
| {{kind|cpp_wrapper_type}} result;
|
|
|