OLD | NEW |
---|---|
(Empty) | |
1 {% from 'fields/field.tmpl' import encode, declare_storage %} | |
2 {% from 'macros.tmpl' import print_if %} | |
3 {% macro define_field_group(group): -%} | |
4 class {{group.type_name}} : public RefCounted<{{group.type_name}}> { | |
5 public: | |
6 static PassRefPtr<{{group.type_name}}> Create() { | |
7 return AdoptRef(new {{group.type_name}}); | |
8 } | |
9 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.
| |
10 return AdoptRef(new {{group.type_name}}(*this)); | |
11 } | |
12 | |
13 bool operator==(const {{group.type_name}}& o) const { | |
14 return ( | |
15 {% for field in group.fields %} | |
16 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} | |
17 {% endfor %} | |
18 ); | |
19 } | |
20 bool operator!=(const {{group.type_name}}& o) const { return !(*this == o); } | |
21 | |
22 {% for field in group.fields %} | |
23 {{declare_storage(field)}} | |
24 {% endfor %} | |
25 | |
26 private: | |
27 {{group.type_name}}() : | |
28 {% for field in group.fields %} | |
29 {{field.name}}({{encode(field, field.default_value)}}){{print_if(not loop. last, ',')}} | |
30 {% endfor %} | |
31 {} | |
32 | |
33 ALWAYS_INLINE {{group.type_name}}(const {{group.type_name}}& o) : | |
34 RefCounted<{{group.type_name}}>(), | |
35 {% for field in group.fields %} | |
36 {{field.name}}(o.{{field.name}}){{print_if(not loop.last, ',')}} | |
37 {% endfor %} | |
38 {} | |
39 }; | |
40 {%- endmacro %} | |
OLD | NEW |