summaryrefslogtreecommitdiff
path: root/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl')
-rw-r--r--mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl39
1 files changed, 39 insertions, 0 deletions
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
new file mode 100644
index 0000000000..ab8c22d49c
--- /dev/null
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
@@ -0,0 +1,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);
+}