godot
godot copied to clipboard
Implement a struct-like type that can be exposed to scripting.
I am in the process of implementing the proposal https://github.com/godotengine/godot-proposals/issues/7329 of @reduz on adding structs to GDScript. This work is still very much in it's early stages and many features still have yet to be implemented. Nevertheless, I'm making the draft public now so I can get continual feedback on this highly requested feature.
Edit 2023-Oct-18 22:50: Added list of structable methods
I've gone through Godot's API and made a list of about 130 methods that might benefit from structification: https://gist.github.com/nlupugla/01d59094d5fa31230e15bd991b63d33f.
- [x] Add struct attributes to the
Array
class. - [x] Create
Struct<T>
class as a child ofArray
. - [x] Create
STRUCT_LAYOUT
and related macros to facilitate creatingStruct<T>
specializations from actual C++ structs. - [x] Proof of concept: create a struct that is equivalent to the
PropertyInfo
used inObject::get_property_list
. - [x] Implement type validation.
- [x] Find a way to return a typed array of structs (Godot does not yet support
TypedArray<TypedArray<T>>
). - [x] Register structs with
ClassDB
. - [x] Proof of concept: expose a struct to GDScript.
- [ ] Comprehensive unit tests.
- [ ] Performance profiling.
- [ ] Performance optimizations.
- [ ] Probably a million other things I'm forgetting.
- [x] Implement struct syntax in GDScript.
- [x] Implement static analysis for structs in GDScript.
- [ ] Figure out how structs will interoperate with C# and GDExtension.
- [ ] User testing.