@@ -43,6 +43,24 @@ pub unsafe extern "C" fn create<T: cap::GodotDefault>(
43
43
create_custom ( T :: __godot_user_init) . unwrap_or ( std:: ptr:: null_mut ( ) )
44
44
}
45
45
46
+ /// Workaround for <https://github.com/godot-rust/gdext/issues/874> before Godot 4.5.
47
+ ///
48
+ /// Godot expects a creator function, but doesn't require an actual object to be instantiated.
49
+ #[ cfg( all( since_api = "4.4" , before_api = "4.5" ) ) ]
50
+ pub unsafe extern "C" fn create_null < T > (
51
+ _class_userdata : * mut std:: ffi:: c_void ,
52
+ _notify_postinitialize : sys:: GDExtensionBool ,
53
+ ) -> sys:: GDExtensionObjectPtr {
54
+ std:: ptr:: null_mut ( )
55
+ }
56
+
57
+ #[ cfg( before_api = "4.4" ) ]
58
+ pub unsafe extern "C" fn create_null < T > (
59
+ _class_userdata : * mut std:: ffi:: c_void ,
60
+ ) -> sys:: GDExtensionObjectPtr {
61
+ std:: ptr:: null_mut ( )
62
+ }
63
+
46
64
/// Godot FFI function for recreating a GDExtension instance, e.g. after a hot reload.
47
65
///
48
66
/// If the `init()` constructor panics, null is returned.
@@ -55,6 +73,17 @@ pub unsafe extern "C" fn recreate<T: cap::GodotDefault>(
55
73
. unwrap_or ( std:: ptr:: null_mut ( ) )
56
74
}
57
75
76
+ /// Workaround for <https://github.com/godot-rust/gdext/issues/874> before Godot 4.5.
77
+ ///
78
+ /// Godot expects a creator function, but doesn't require an actual object to be instantiated.
79
+ #[ cfg( all( since_api = "4.2" , before_api = "4.5" ) ) ]
80
+ pub unsafe extern "C" fn recreate_null < T > (
81
+ _class_userdata : * mut std:: ffi:: c_void ,
82
+ _object : sys:: GDExtensionObjectPtr ,
83
+ ) -> sys:: GDExtensionClassInstancePtr {
84
+ std:: ptr:: null_mut ( )
85
+ }
86
+
58
87
pub ( crate ) fn create_custom < T , F > (
59
88
make_user_instance : F ,
60
89
) -> Result < sys:: GDExtensionObjectPtr , PanicPayload >
0 commit comments