Fix enum support in nested containers and tables#45
Open
Conversation
wire-cdt changes (2 files + 2 test files) Bug: adding_explicit_nested_dispatcher (abigen.hpp) and translating_explicit_nested_dispatcher (gen.hpp) handled builtins, aliases, templates, and records as inner types of nested containers — but had no case for enums. When an enum appeared inside std::pair<>, std::vector<>, etc. in a table struct, it hit CDT_INTERNAL_ERROR. Fix: - plugins/sysio/abigen.hpp:316-318 — Added isEnumeralType() branch that calls add_type() (to register the enum in _abi.enums) and returns get_base_type_name() as the type name - plugins/sysio/gen.hpp:547-548 — Added isEnumeralType() branch that returns get_base_type_name() as the type name - New test: abigen_test_enum_table.cpp / .json — covers enums as direct table fields, enums inside std::vector<std::pair<enum, T>>, both enum and enum class
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.
Change Description
This PR resolves an issue where enums used within nested containers and tables (e.g.,
std::pair<>,std::vector<>) would cause aCDT_INTERNAL_ERROR. The fix introduces proper handling for enums within these contexts:abigen.hppto register enums and retrieve their base type names.gen.hppto return the base type names for enums.abigen_test_enum_table.cppand.json) to cover use cases like enums as direct table fields and enums inside nested containers.API Changes
Documentation Additions