Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Enum.pm
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ sub render_enum_tables($$$$$$) {

with_emit_traits {
emit_block {
emit "static const bool is_complex = " . ($complex ? 'true' : 'false') . ";";
emit "typedef $base_type base_type;";
emit "typedef $full_name enum_type;";
emit "static const base_type first_item_value = $base;";
emit "static const base_type last_item_value = $last_value;";
emit "static constexpr bool is_complex = " . ($complex ? 'true' : 'false') . ";";
emit "using base_type = $base_type;";
emit "using enum_type = $full_name;";
emit "static constexpr base_type first_item_value = $base;";
emit "static constexpr base_type last_item_value = $last_value;";
# Cast the enum to integer in order to avoid GCC <= 4.5 assuming the value range is correct.
emit_block {
emit "return (value >= first_item_value && ",
"value <= last_item_value);";
} "static inline bool is_valid(base_type value) ";
emit "static const enum_type first_item = (enum_type)first_item_value;";
emit "static const enum_type last_item = (enum_type)last_item_value;";
emit "static constexpr enum_type first_item = (enum_type)first_item_value;";
emit "static constexpr enum_type last_item = (enum_type)last_item_value;";
emit "static const char *const key_table[", $count, "];";
if ($complex) {
emit "static const DFHack::enum_identity::ComplexData complex;";
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Template for new versions:

# Future

## Structures
- updated codegen to generate enum trait constants as ``constexpr``

## Structures

# 53.06-r1
Expand Down