Index: third_party/WebKit/Source/build/scripts/templates/fields/group.tmpl |
diff --git a/third_party/WebKit/Source/build/scripts/templates/fields/group.tmpl b/third_party/WebKit/Source/build/scripts/templates/fields/group.tmpl |
new file mode 100644 |
index 0000000000000000000000000000000000000000..576b8ca9b90c7fc964fb2e713da12d4ba3f7ea79 |
--- /dev/null |
+++ b/third_party/WebKit/Source/build/scripts/templates/fields/group.tmpl |
@@ -0,0 +1,40 @@ |
+{% from 'fields/field.tmpl' import encode, declare_storage %} |
+{% from 'macros.tmpl' import print_if %} |
+{% macro define_field_group(group): -%} |
+class {{group.type_name}} : public RefCounted<{{group.type_name}}> { |
+ public: |
+ static PassRefPtr<{{group.type_name}}> Create() { |
+ return AdoptRef(new {{group.type_name}}); |
+ } |
+ PassRefPtr<{{group.type_name}}> Copy() const { |
meade_UTC10
2017/04/20 03:08:41
Bugs has been working on removing PassRefPtr, perh
shend
2017/04/20 03:22:34
Good idea. Will do in a separate patch.
|
+ return AdoptRef(new {{group.type_name}}(*this)); |
+ } |
+ |
+ bool operator==(const {{group.type_name}}& o) const { |
+ return ( |
+ {% for field in group.fields %} |
+ {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} |
+ {% endfor %} |
+ ); |
+ } |
+ bool operator!=(const {{group.type_name}}& o) const { return !(*this == o); } |
+ |
+ {% for field in group.fields %} |
+ {{declare_storage(field)}} |
+ {% endfor %} |
+ |
+ private: |
+ {{group.type_name}}() : |
+ {% for field in group.fields %} |
+ {{field.name}}({{encode(field, field.default_value)}}){{print_if(not loop.last, ',')}} |
+ {% endfor %} |
+ {} |
+ |
+ ALWAYS_INLINE {{group.type_name}}(const {{group.type_name}}& o) : |
+ RefCounted<{{group.type_name}}>(), |
+ {% for field in group.fields %} |
+ {{field.name}}(o.{{field.name}}){{print_if(not loop.last, ',')}} |
+ {% endfor %} |
+ {} |
+}; |
+{%- endmacro %} |