aboutsummaryrefslogtreecommitdiff
path: root/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
blob: ab8c22d49cd2db24e0515f8b000c6b840ad737b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{% for constructor in struct|struct_constructors %}
{{struct.name}}::{{struct.name}}(
{%-  for field in constructor.params  %}
{%-    set type = field.kind|cpp_wrapper_param_type %}
{%-    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 %}

bool {{struct.name}}::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}