Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed VARIANT_ENUM/BITFIELD_CAST to show the correct names #956

Merged
merged 1 commit into from
Jan 30, 2023
Merged

Fixed VARIANT_ENUM/BITFIELD_CAST to show the correct names #956

merged 1 commit into from
Jan 30, 2023

Conversation

DmitriySalnikov
Copy link
Contributor

@DmitriySalnikov DmitriySalnikov commented Dec 9, 2022

This PR changes how Enums and Bitfields are registered, and also corrects the names of registered enums. Breaks compatibility.

Previously VARIANT_ENUM_CAST could be written in 3 ways:

VARIANT_ENUM_CAST(Example, Example::Constants);
VARIANT_ENUM_CAST(Example, Constants);
VARIANT_ENUM_CAST(, Constants);

The first way was used throughout the generated API. At the same time, VARIANT_BITFIELD_CAST could only be written like this:

VARIANT_BITFIELD_CAST(Example, Example::Flags);

This would not be a problem if such a way of writing would not lead to an incorrect display of enums in the editor.
Godot_v4 0-beta7_win64_YUSdRFsh9e
I changed it to be the same as in Godot itself. Now VARIANT_ENUM_CAST and VARIANT_BITFIELD_CAST can be written like this:

VARIANT_ENUM_CAST(Example::Constants);
VARIANT_BITFIELD_CAST(Example::Flags);
// Or like this for enums outside of classes
VARIANT_ENUM_CAST(Constants);
VARIANT_BITFIELD_CAST(Flags);

Godot_v4 0-beta7_win64_M1VrKy83Jy
Like in Godot, the enum_qualified_name_to_class_info_name function is now used to convert Example::Constants -> Example.Constants.
Added tests.

Actually, if it's very important to keep VARIANT_ENUM_CAST(m_class, m_enum) and VARIANT_BITFIELD_CAST(m_class, m_enum), then I can only leave fixes for VARIANT_BITFIELD_CAST, but I prefer the current version.

@DmitriySalnikov DmitriySalnikov requested a review from a team as a code owner December 9, 2022 14:00
@akien-mga akien-mga added the bug This has been identified as a bug label Jan 11, 2023
@akien-mga akien-mga merged commit 2ef10f9 into godotengine:master Jan 30, 2023
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks compat bug This has been identified as a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants