-
-
Notifications
You must be signed in to change notification settings - Fork 103
Closed
godotengine/godot
#86079Milestone
Description
Describe the project you are working on
The Godot editor 🙂
Describe the problem or limitation you are having in your project
Currently, GDNative bindings must assume that all non-primitive return types (such as Node) may be null. This is problematic for safety-oriented languages such as Rust and Swift as it leads to uglier and unsafe code.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
- Add method hints to ClassDB to signal that a return value will never be
null. This hint should only be added to methods that return Object-derived types, not primitive types such asintorVector2as these are non-nullable by design. If this hint is not present, the method is assumed to have a nullable return type (for Object-derived types only). - Add a way to hint specific method arguments as being nullable. In other words, it means that the method will behave correctly if the specified arguments are
null. If this hint is not present, the argument is assumed to be non-nullable.
This information can also be displayed in the generated class reference to improve documentation.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
- Non-null return type hinting could be implemented as a ClassDB method flag such as
METHOD_FLAG_RETURN_NON_NULL. - Nullable argument hinting could be implemented using argument metadata feature (
GodotTypeInfo::Metadata).
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, as this is core engine functionality.
Is there a reason why this should be core and not an add-on in the asset library?
This functionality is part of the engine itself.
Zireael07, raulsntos, migueldeicaza, dsnopek, CedNaru and 15 moreVapidLinus, Rennan24 and monfera