OLD | NEW |
1 {#--- | 1 {#--- |
2 Macro for enum definition, and the declaration of associated functions. | 2 Macro for enum definition, and the declaration of associated functions. |
3 `is_static` is relevant if this enum declaration is defined within a class, in | 3 `is_static` is relevant if this enum declaration is defined within a class, in |
4 which case associated functions need to be static. | 4 which case associated functions need to be static. |
5 ---#} | 5 ---#} |
6 {%- macro enum_decl(enum, is_static=false) %} | 6 {%- macro enum_decl(enum, is_static=false) %} |
7 enum {{enum.name}} : int32_t { | 7 enum {{enum.name}} : int32_t { |
8 {%- for field in enum.fields %} | 8 {%- for field in enum.fields %} |
9 {%- if field.value %} | 9 {%- if field.value %} |
10 {{enum.name|to_all_caps}}_{{field.name}} = {{field.value|expression_to_text}}, | 10 {{enum.name|to_all_caps}}_{{field.name}} = {{field.value|expression_to_text}}, |
(...skipping 26 matching lines...) Expand all Loading... |
37 {{enum.name}}_IsValidValue({{enum.name}} value) { | 37 {{enum.name}}_IsValidValue({{enum.name}} value) { |
38 switch (static_cast<int32_t>(value)) { | 38 switch (static_cast<int32_t>(value)) { |
39 {%- for enum_field in enum.fields|groupby('numeric_value') %} | 39 {%- for enum_field in enum.fields|groupby('numeric_value') %} |
40 case {{enum_field[0]}}: | 40 case {{enum_field[0]}}: |
41 {%- endfor %} | 41 {%- endfor %} |
42 return true; | 42 return true; |
43 } | 43 } |
44 return false; | 44 return false; |
45 } | 45 } |
46 {%- endmacro %} | 46 {%- endmacro %} |
OLD | NEW |