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