OLD | NEW |
1 {% macro encode(field, value) %} | 1 {% macro encode(field, value) %} |
2 {% if field.is_bit_field -%} | 2 {% if field.is_bit_field -%} |
3 static_cast<unsigned>({{value}}) | 3 static_cast<unsigned>({{value}}) |
4 {%- else -%} | 4 {%- else -%} |
5 {{value}} | 5 {{value}} |
6 {%- endif %} | 6 {%- endif %} |
7 {% endmacro %} | 7 {% endmacro %} |
8 | 8 |
9 {% macro decode(field, value) %} | 9 {% macro decode(field, value) %} |
10 {% if field.is_bit_field -%} | 10 {% if field.is_bit_field -%} |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 {{subgroup.member_name}} = other.{{subgroup.member_name}}; | 89 {{subgroup.member_name}} = other.{{subgroup.member_name}}; |
90 {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%} | 90 {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%} |
91 {{fieldwise_copy(subgroup, fields_to_copy)}} | 91 {{fieldwise_copy(subgroup, fields_to_copy)}} |
92 {% endif %} | 92 {% endif %} |
93 {% endfor %} | 93 {% endfor %} |
94 {% for field in group.fields|select("in", fields_to_copy) -%} | 94 {% for field in group.fields|select("in", fields_to_copy) -%} |
95 {{setter_expression(field)}} = other.{{getter_expression(field)}}; | 95 {{setter_expression(field)}} = other.{{getter_expression(field)}}; |
96 {% endfor %} | 96 {% endfor %} |
97 {% endmacro %} | 97 {% endmacro %} |
98 | 98 |
| 99 {% macro fieldwise_pointer_compare_inherited(group) %} |
| 100 {% for subgroup in group.subgroups %} |
| 101 {# If every field in this subgroup is inherited, we directly compare the |
| 102 group pointer instead. #} |
| 103 {% if subgroup.all_fields|rejectattr("is_inherited")|list|length == 0 -%} |
| 104 {{subgroup.member_name}}.Get() == o.{{subgroup.member_name}}.Get() && |
| 105 {# Otherwise, we would have to recursively generate comparison operations |
| 106 on fields in the subgroup. #} |
| 107 {% elif subgroup.fields|selectattr("is_inherited")|list|length > 0 -%} |
| 108 {{fieldwise_pointer_compare_inherited(fields_to_compare)}} |
| 109 {% endif %} |
| 110 {% endfor %} |
| 111 {% for field in group.fields if field.is_inherited -%} |
| 112 {{getter_expression(field)}} == o.{{getter_expression(field)}} && |
| 113 {% endfor %} |
| 114 {% endmacro %} |
| 115 |
99 {% macro fieldwise_diff(group_to_diff) %} | 116 {% macro fieldwise_diff(group_to_diff) %} |
100 {% for group in group_to_diff.subgroups %} | 117 {% for group in group_to_diff.subgroups %} |
101 if ({{group.group_name}}.Get() != other.{{group.group_name}}.Get()) { | 118 if ({{group.group_name}}.Get() != other.{{group.group_name}}.Get()) { |
102 {{fieldwise_diff(group)|indent(2, true)}} | 119 {{fieldwise_diff(group)|indent(2, true)}} |
103 } | 120 } |
104 {% endfor %} | 121 {% endfor %} |
105 {% for expression in group_to_diff.expressions %} | 122 {% for expression in group_to_diff.expressions %} |
106 if ({{expression}} != other.{{expression}}) | 123 if ({{expression}} != other.{{expression}}) |
107 return true; | 124 return true; |
108 {% endfor %} | 125 {% endfor %} |
109 {% endmacro %} | 126 {% endmacro %} |
OLD | NEW |