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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 {% endmacro %} | 56 {% endmacro %} |
57 | 57 |
58 {% macro declare_storage(field) %} | 58 {% macro declare_storage(field) %} |
59 {% if field.is_bit_field %} | 59 {% if field.is_bit_field %} |
60 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} | 60 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} |
61 {%- else %} | 61 {%- else %} |
62 {{field.type_name}} {{field.name}}; | 62 {{field.type_name}} {{field.name}}; |
63 {%- endif %} | 63 {%- endif %} |
64 {% endmacro %} | 64 {% endmacro %} |
65 | 65 |
| 66 {% macro compare(is_pointer_type, expr, other_name) %} |
| 67 {% if is_pointer_type -%} |
| 68 DataEquivalent({{expr}}, {{other_name}}.{{expr}}) |
| 69 {%- else -%} |
| 70 {{expr}} == {{other_name}}.{{expr}} |
| 71 {%- endif %} |
| 72 {% endmacro %} |
| 73 |
66 {# 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 |
67 equality comparisons on those fields. The generated comparisons take | 75 equality comparisons on those fields. The generated comparisons take |
68 advantage of group sharing. #} | 76 advantage of group sharing. #} |
69 {% macro fieldwise_compare(group, fields_to_compare) %} | 77 {% macro fieldwise_compare(group, fields_to_compare) %} |
70 {% for subgroup in group.subgroups %} | 78 {% for subgroup in group.subgroups %} |
71 {# 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 |
72 group pointer instead. #} | 80 group pointer instead. #} |
73 {% if subgroup.all_fields|reject("in", fields_to_compare)|list|length == 0 -%} | 81 {% if subgroup.all_fields|reject("in", fields_to_compare)|list|length == 0 -%} |
74 {{subgroup.member_name}} == o.{{subgroup.member_name}} && | 82 {{subgroup.member_name}} == o.{{subgroup.member_name}} && |
75 {# Otherwise, we would have to recursively generate comparison operations | 83 {# Otherwise, we would have to recursively generate comparison operations |
76 on fields in the subgroup. #} | 84 on fields in the subgroup. #} |
77 {% elif subgroup.fields|select("in", fields_to_compare)|list|length > 0 -%} | 85 {% elif subgroup.fields|select("in", fields_to_compare)|list|length > 0 -%} |
78 {{fieldwise_compare(subgroup, fields_to_compare)}} | 86 {{fieldwise_compare(subgroup, fields_to_compare)}} |
79 {% endif %} | 87 {% endif %} |
80 {% endfor %} | 88 {% endfor %} |
81 {% for field in group.fields|select("in", fields_to_compare) -%} | 89 {% for field in group.fields|select("in", fields_to_compare) -%} |
82 {{getter_expression(field)}} == o.{{getter_expression(field)}} && | 90 {{compare(field.wrapper_pointer_name, getter_expression(field), "o")}} && |
83 {% endfor %} | 91 {% endfor %} |
84 {% endmacro %} | 92 {% endmacro %} |
85 | 93 |
86 {% macro fieldwise_copy(group, fields_to_copy) %} | 94 {% macro fieldwise_copy(group, fields_to_copy) %} |
87 {% for subgroup in group.subgroups %} | 95 {% for subgroup in group.subgroups %} |
88 {% if subgroup.all_fields|reject("in", fields_to_copy)|list|length == 0 -%} | 96 {% if subgroup.all_fields|reject("in", fields_to_copy)|list|length == 0 -%} |
89 {{subgroup.member_name}} = other.{{subgroup.member_name}}; | 97 {{subgroup.member_name}} = other.{{subgroup.member_name}}; |
90 {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%} | 98 {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%} |
91 {{fieldwise_copy(subgroup, fields_to_copy)}} | 99 {{fieldwise_copy(subgroup, fields_to_copy)}} |
92 {% endif %} | 100 {% endif %} |
(...skipping 24 matching lines...) Expand all Loading... |
117 {% for group in group_to_diff.subgroups %} | 125 {% for group in group_to_diff.subgroups %} |
118 if ({{group.group_name}}.Get() != other.{{group.group_name}}.Get()) { | 126 if ({{group.group_name}}.Get() != other.{{group.group_name}}.Get()) { |
119 {{fieldwise_diff(group)|indent(2, true)}} | 127 {{fieldwise_diff(group)|indent(2, true)}} |
120 } | 128 } |
121 {% endfor %} | 129 {% endfor %} |
122 {% for expression in group_to_diff.expressions %} | 130 {% for expression in group_to_diff.expressions %} |
123 if (self.{{expression}} != other.{{expression}}) | 131 if (self.{{expression}} != other.{{expression}}) |
124 return true; | 132 return true; |
125 {% endfor %} | 133 {% endfor %} |
126 {% endmacro %} | 134 {% endmacro %} |
OLD | NEW |