| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 {%- endif %} | 71 {%- endif %} |
| 72 {% endmacro %} | 72 {% endmacro %} |
| 73 | 73 |
| 74 {# Given a group and a list of fields to compare, this generates a set of | 74 {# Given a group and a list of fields to compare, this generates a set of |
| 75 equality comparisons on those fields. The generated comparisons take | 75 equality comparisons on those fields. The generated comparisons take |
| 76 advantage of group sharing. #} | 76 advantage of group sharing. #} |
| 77 {% macro fieldwise_compare(group, fields_to_compare) %} | 77 {% macro fieldwise_compare(group, fields_to_compare) %} |
| 78 {% for subgroup in group.subgroups %} | 78 {% for subgroup in group.subgroups %} |
| 79 {# If every field in this subgroup is to be compared, we can compare the | 79 {# If every field in this subgroup is to be compared, we can compare the |
| 80 group pointer instead. #} | 80 group pointer instead. #} |
| 81 {% if subgroup.all_fields|reject("in", fields_to_compare)|list|length == 0 -%} | 81 {% if subgroup.all_fields|rejectattr("custom_compare")|reject("in", fields_to_
compare)|list|length == 0 -%} |
| 82 {{subgroup.member_name}} == o.{{subgroup.member_name}} && | 82 {{subgroup.member_name}} == o.{{subgroup.member_name}} && |
| 83 {# Otherwise, we would have to recursively generate comparison operations | 83 {# Otherwise, we would have to recursively generate comparison operations |
| 84 on fields in the subgroup. #} | 84 on fields in the subgroup. #} |
| 85 {% elif subgroup.fields|select("in", fields_to_compare)|list|length > 0 -%} | 85 {% elif subgroup.fields|rejectattr("custom_compare")|select("in", fields_to_co
mpare)|list|length > 0 -%} |
| 86 {{fieldwise_compare(subgroup, fields_to_compare)}} | 86 {{fieldwise_compare(subgroup, fields_to_compare)}} |
| 87 {% endif %} | 87 {% endif %} |
| 88 {% endfor %} | 88 {% endfor %} |
| 89 {% for field in group.fields|select("in", fields_to_compare) -%} | 89 {% for field in group.fields|rejectattr("custom_compare")|select("in", fields_to
_compare) -%} |
| 90 {{compare(field.wrapper_pointer_name, getter_expression(field), "o")}} && | 90 {{compare(field.wrapper_pointer_name, getter_expression(field), "o")}} && |
| 91 {% endfor %} | 91 {% endfor %} |
| 92 {% endmacro %} | 92 {% endmacro %} |
| 93 | 93 |
| 94 {% macro fieldwise_copy(group, fields_to_copy) %} | 94 {% macro fieldwise_copy(group, fields_to_copy) %} |
| 95 {% for subgroup in group.subgroups %} | 95 {% for subgroup in group.subgroups %} |
| 96 {% if subgroup.all_fields|reject("in", fields_to_copy)|list|length == 0 -%} | 96 {% if subgroup.all_fields|rejectattr("custom_copy")|reject("in", fields_to_cop
y)|list|length == 0 -%} |
| 97 {{subgroup.member_name}} = other.{{subgroup.member_name}}; | 97 {{subgroup.member_name}} = other.{{subgroup.member_name}}; |
| 98 {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%} | 98 {% elif subgroup.fields|rejectattr("custom_copy")|select("in", fields_to_copy)
|list|length > 0 -%} |
| 99 {{fieldwise_copy(subgroup, fields_to_copy)}} | 99 {{fieldwise_copy(subgroup, fields_to_copy)}} |
| 100 {% endif %} | 100 {% endif %} |
| 101 {% endfor %} | 101 {% endfor %} |
| 102 {% for field in group.fields|select("in", fields_to_copy) -%} | 102 {% for field in group.fields|rejectattr("custom_copy")|select("in", fields_to_co
py) -%} |
| 103 {{setter_expression(field)}} = other.{{getter_expression(field)}}; | 103 {{setter_expression(field)}} = other.{{getter_expression(field)}}; |
| 104 {% endfor %} | 104 {% endfor %} |
| 105 {% endmacro %} | 105 {% endmacro %} |
| 106 | 106 |
| 107 {% macro fieldwise_pointer_compare_inherited(group) %} | 107 {% macro fieldwise_pointer_compare_inherited(group) %} |
| 108 {% for subgroup in group.subgroups %} | 108 {% for subgroup in group.subgroups %} |
| 109 {# If every field in this subgroup is inherited, we directly compare the | 109 {# If every field in this subgroup is inherited, we directly compare the |
| 110 group pointer instead. #} | 110 group pointer instead. #} |
| 111 {% if subgroup.all_fields|rejectattr("is_inherited")|list|length == 0 -%} | 111 {% if subgroup.all_fields|rejectattr("is_inherited")|list|length == 0 -%} |
| 112 {{subgroup.member_name}}.Get() == o.{{subgroup.member_name}}.Get() && | 112 {{subgroup.member_name}}.Get() == o.{{subgroup.member_name}}.Get() && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 129 {% endfor %} | 129 {% endfor %} |
| 130 {% for expression in group_to_diff.expressions %} | 130 {% for expression in group_to_diff.expressions %} |
| 131 if (self.{{expression}} != other.{{expression}}) | 131 if (self.{{expression}} != other.{{expression}}) |
| 132 return true; | 132 return true; |
| 133 {% endfor %} | 133 {% endfor %} |
| 134 {% for predicate in group_to_diff.predicates %} | 134 {% for predicate in group_to_diff.predicates %} |
| 135 if (!self.{{predicate}}) | 135 if (!self.{{predicate}}) |
| 136 return true; | 136 return true; |
| 137 {% endfor %} | 137 {% endfor %} |
| 138 {% endmacro %} | 138 {% endmacro %} |
| OLD | NEW |