{% for constructor in struct|struct_constructors %}
{{struct.name}}::{{struct.name}}(
{%- for field in constructor.params %}
{%- set type = field.kind|cpp_wrapper_param_type_new %}
{%- set name = field.name %}
{{type}} {{name}}_in
{%- if not loop.last -%},{%- endif %}
{%- endfor %})
{%- for field, is_parameter in constructor.fields %}
{%- set name = field.name %}
{% if loop.first %}:{% else %} {% endif %} {{name}}(
{%- if is_parameter -%}
std::move({{name}}_in)
{%- else -%}
{{ field|default_value }}
{%- endif -%}
){% if not loop.last %},{% endif %}
{%- endfor %} {}
{% endfor %}
{{struct.name}}::~{{struct.name}}() = default;
{%- if struct|is_hashable %}
size_t {{struct.name}}::Hash(size_t seed) const {
{%- for field in struct.fields %}
{%- if for_blink %}
seed = mojo::internal::WTFHash(seed, this->{{field.name}});
{%- else %}
seed = mojo::internal::Hash(seed, this->{{field.name}});
{%- endif %}
{%- endfor %}
return seed;
}
{%- endif %}
void {{struct.name}}::WriteIntoTrace(
perfetto::TracedValue traced_context) const {
[[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
{%- for field in struct.fields %}
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"{{field.name}}"), {{'this->'+field.name}},
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type {{field.kind|cpp_wrapper_param_type}}>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
{%- endfor %}
}
bool {{struct.name}}::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context);
}