C++: allow iterating over unique enum values#1806
Merged
pwrobeldev merged 5 commits intoMay 25, 2026
Merged
Conversation
This commit implements a new cpp-only attribute called 'EnumeratorValues'. When enumeration is annotated with it, then additional function is generated. It returns std::array with all enumerator values. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This commit implements new LIME input that is properly handled. The committed output of smoke-tests confirm that for the new attribute the C++ generator creates the additional function. Note: the returned enumeration values are unique. Aliasing enumerators are skipped. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This commit brings new functional tests, which check if the generated code for the new 'EnumValues' cpp attribute works correctly and compiles without problems. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
The new attribute can be used for C++ enums to instruct the generator to create a helper function that returns unique enum values. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
diachenko-mischa
approved these changes
May 25, 2026
Contributor
Author
|
The failure for In meantime, I executed all functional tests on my local MacOS with the current branch -- there are no problems. |
pwrobeldev
deleted the
pwrobeldev/provide-way-to-get-all-enumerator-values
branch
May 25, 2026 18:46
Contributor
Author
|
The changes have been merged. The environment issue for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
---------- Motivation ----------
There were a few requests in the past to provide the means for
users of the generated code to iterate over enumeration values.
---------- Solution ----------
Introduced a new cpp-specific attribute in LIME language called 'EnumValues'.
When LIME enumeration is annotated with it, then C++ generator creates additional
helper function that returns the array of unique enumerators. It is achieved via the new
mustache templates. The change implements smoke and functional tests to confirm
that the new functionality works as expected.
For the following input:
The additional function is generated: