godotengine / godotengine/godot-cpp
Enums defined with enum classes in-engine are not using enum classes in godot-cpp
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
### Godot version
Godot master
### godot-cpp version
Master of godot-cpp 6facde3c29abe4d8b0ff365c252c9aeb16fc5f66
### System information
macOS 14.6.1 arm64
### Issue description
Enums such as `Key`, `MouseButton`, `MouseButtonMask`, and more using `enum class` in-engine are not using `enum class` in godot-cpp, they are just using regular `enum`. Using `enum class` improves type safety, but I am not sure if Godot provides a mechanism for godot-cpp to know which enums are using `enum class`.
This issue is not super important because there is an easy workaround. In my project, I am using these defines that only get used when compiling as a module, and writing `KEY_` in my code, which auto-replace when compiled as a module.
```cpp
#if GODOT_MODULE
#define KEY_A Key::A
#define KEY_D Key::D
#define KEY_E Key::E
#define KEY_F Key::F
#define KEY_Q Key::Q
#define KEY_R Key::R
#define KEY_S Key::S
#define KEY_T Key::T
#define KEY_W Key::W
#define KEY_SHIFT Key::SHIFT
#define MOUSE_BUTTON_LEFT MouseButton::RIGHT
#define MOUSE_BUTTON_MASK_MIDDLE MouseButtonMask::MIDDLE
#define MOUSE_BUTTON_MASK_RIGHT MouseButtonMask::RIGHT
#define MOUSE_BUTTON_RIGHT MouseButton::RIGHT
#define MOUSE_BUTTON_WHEEL_UP MouseButton::WHEEL_UP
#define MOUSE_BUTTON_WHEEL_DOWN MouseButton::WHEEL_DOWN
#endif
```
### Steps to reproduce
Try using one of the values in the `Key` enum in-engine vs in godot-cpp.
### Minimal reproduction project
Trivial to reproduce with one line of code in a new godot-cpp GDExtension project.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.