Fix VARIANT_ENUM_CAST to support enum class#1914
Fix VARIANT_ENUM_CAST to support enum class#1914daniellopez2002 wants to merge 2 commits intogodotengine:4.5from
Conversation
|
Thanks! We still don't "officially" support enum classes, although, if this is really all it takes to make them work in godot-cpp, the change is small enough that it could be alright. I remember when discussing binding enum classes in Godot itself, it turned out there were a lot more changes than initially expected |
|
Can it be merged? Or does it need any changes or improvements? |
dsnopek
left a comment
There was a problem hiding this comment.
It looks like Godot itself already basically has this cast via this code:
We should eventually sync the changes from godotengine/godot#105231 into godot-cpp, but I think this is OK for now
|
Thanks a lot for the clarification and for the review! This is actually my first time contributing a PR to an open source project, so I really appreciate the feedback and the approval. Happy to help later on if syncing with core changes becomes necessary. |
Problem
VARIANT_ENUM_CAST assumes implicit conversion from enum values to int64_t when
encoding arguments. This is invalid for enum class types according to the C++
standard and fails to compile on MSVC.
Solution
Explicitly cast enum values to int64_t when encoding, matching the behavior
already implemented in VARIANT_BITFIELD_CAST.
Notes
Fixes #1917