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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 {%- endif %} | 46 {%- endif %} |
47 {% endmacro %} | 47 {% endmacro %} |
48 | 48 |
49 {% macro declare_storage(field) %} | 49 {% macro declare_storage(field) %} |
50 {% if field.is_bit_field %} | 50 {% if field.is_bit_field %} |
51 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} | 51 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} |
52 {%- else %} | 52 {%- else %} |
53 {{field.type_name}} {{field.name}}; | 53 {{field.type_name}} {{field.name}}; |
54 {%- endif %} | 54 {%- endif %} |
55 {% endmacro %} | 55 {% endmacro %} |
| 56 |
| 57 {# Given a group and a list of fields to compare, this generates a set of |
| 58 equality comparisons on those fields. The generated comparisons take |
| 59 advantage of group sharing. #} |
| 60 {% macro fieldwise_compare(group, fields_to_compare) %} |
| 61 {% for subgroup in group.subgroups %} |
| 62 {# If every field in this subgroup is to be compared, we can compare the |
| 63 group pointer instead. #} |
| 64 {% if subgroup.all_fields|reject("in", fields_to_compare)|list|length == 0 -%} |
| 65 {{subgroup.member_name}} == o.{{subgroup.member_name}} && |
| 66 {# Otherwise, we would have to recursively generate comparison operations |
| 67 on fields in the subgroup. #} |
| 68 {% elif subgroup.fields|select("in", fields_to_compare)|list|length > 0 -%} |
| 69 {{fieldwise_compare(subgroup, fields_to_compare)}} |
| 70 {% endif %} |
| 71 {% endfor %} |
| 72 {% for field in group.fields|select("in", fields_to_compare) -%} |
| 73 {{getter_expression(field)}} == o.{{getter_expression(field)}} && |
| 74 {% endfor %} |
| 75 {% endmacro %} |
| 76 |
| 77 {% macro fieldwise_copy(group, fields_to_copy) %} |
| 78 {% for subgroup in group.subgroups %} |
| 79 {% if subgroup.all_fields|reject("in", fields_to_copy)|list|length == 0 -%} |
| 80 {{subgroup.member_name}} = other.{{subgroup.member_name}}; |
| 81 {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%} |
| 82 {{fieldwise_copy(subgroup, fields_to_copy)}} |
| 83 {% endif %} |
| 84 {% endfor %} |
| 85 {% for field in group.fields|select("in", fields_to_copy) -%} |
| 86 {{setter_expression(field)}} = other.{{getter_expression(field)}}; |
| 87 {% endfor %} |
| 88 {% endmacro %} |
OLD | NEW |