You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wrapping a C library (FMOD) which contains a ton of constants. Since a lot of the @callable surface area I'm exposing to Godot take arguments which correspond to these constants, it would be ideal to be able to export these constants to Godot. The GDExtension API has a way to do this via bind_integer_constant() and friends, but we can't access them conveniently from Swift
Describe the solution you'd like
Assuming it's possible, it might be nice to extend the @export macro to handle constants as well. But I'm not tied to a particular syntax.
Describe alternatives you've considered
Re-defining these constants directly in a GD script, but that's messy and I prefer for the "source of truth" for the values to be the original headers. (Also I like having pure Swift in my project)
The text was updated successfully, but these errors were encountered:
Swift macros don't have access to anything but AST, so C constants won't be visible for it to generate GDE API boilerplate.
Or did I misunderstand what you mean?
Can you provide an example of Swift code you want to write and what you expect to see on Godot side?
Oh, I don't want it to see and literally export the #defines for me. I expect I'd have to register them myself someplace as a Swift symbol.
For instance, I have the FMOD constant: #define FMOD_INIT_3D_RIGHTHANDED 0x00000004
This is already brought into Swift via the Bridging header, but I need to turn around and export the value to Godot so, eg, GDScript could access it for instance.
In C++ it's just: BIND_CONSTANT(FMOD_INIT_3D_RIGHTHANDED)
Which is defined in class_db.hpp as: #define BIND_CONSTANT(m_constant) \ ::godot::ClassDB::bind_integer_constant(get_class_static(), "", #m_constant, m_constant);
Since these are global things, maybe it makes sense to do it in the initHook? Something like:
#bindGodotConstant(,"ConstantName")
Though, looks like enums and bitfields are supported too thanks to Miguel here: godotengine/godot-proposals#2242
I'm wrapping a C library (FMOD) which contains a ton of constants. Since a lot of the @callable surface area I'm exposing to Godot take arguments which correspond to these constants, it would be ideal to be able to export these constants to Godot. The GDExtension API has a way to do this via bind_integer_constant() and friends, but we can't access them conveniently from Swift
Describe the solution you'd like
Assuming it's possible, it might be nice to extend the @export macro to handle constants as well. But I'm not tied to a particular syntax.
Describe alternatives you've considered
Re-defining these constants directly in a GD script, but that's messy and I prefer for the "source of truth" for the values to be the original headers. (Also I like having pure Swift in my project)
The text was updated successfully, but these errors were encountered: