@@ -72,7 +72,7 @@ impl Callable {
72
72
/// If the builtin type does not have the method, the returned callable will be invalid.
73
73
///
74
74
/// Static builtin methods (e.g. `String.humanize_size`) are not supported in reflection as of Godot 4.4. For static _class_ functions,
75
- /// use [`from_local_static ()`][Self::from_local_static ] instead.
75
+ /// use [`from_class_static ()`][Self::from_class_static ] instead.
76
76
///
77
77
/// _Godot equivalent: `Callable.create(Variant variant, StringName method)`_
78
78
#[ cfg( since_api = "4.3" ) ]
@@ -84,17 +84,15 @@ impl Callable {
84
84
inner:: InnerCallable :: create ( variant, method_name)
85
85
}
86
86
87
- /// Create a callable for the static method `class_name::function` (single-threaded).
87
+ /// Create a callable for the static method `class_name::function`
88
88
///
89
- /// Allows you to call static functions through `Callable`.
89
+ /// Allows you to call static functions through `Callable`. Allows both single- and multi-threaded calls; what happens on Godot side
90
+ /// is your responsibility.
90
91
///
91
- /// Does not support built-in types (such as `String`), only classes.
92
- ///
93
- /// # Compatibility
94
- /// Not available before Godot 4.4. Library versions <0.3 used to provide this, however the polyfill used to emulate it was half-broken
95
- /// (not supporting signals, bind(), method_name(), is_valid(), etc).
92
+ /// Does not support built-in types (such as `String`), only classes. Static functions on built-in types are not supported in Godot's
93
+ /// reflection APIs at the moment.
96
94
#[ cfg( since_api = "4.4" ) ]
97
- pub fn from_local_static (
95
+ pub fn from_class_static (
98
96
class_name : impl meta:: AsArg < StringName > ,
99
97
function_name : impl meta:: AsArg < StringName > ,
100
98
) -> Self {
@@ -103,7 +101,7 @@ impl Callable {
103
101
104
102
let callable_name = format ! ( "{class_name}.{function_name}" ) ;
105
103
106
- Self :: from_local_fn ( & callable_name , move |args| {
104
+ let function = move |args : & [ & Variant ] | {
107
105
let args = args. iter ( ) . cloned ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
108
106
109
107
let result: Variant = classes:: ClassDb :: singleton ( ) . class_call_static (
@@ -112,7 +110,24 @@ impl Callable {
112
110
args. as_slice ( ) ,
113
111
) ;
114
112
result
115
- } )
113
+ } ;
114
+
115
+ #[ cfg( feature = "experimental-threads" ) ]
116
+ let callable = Self :: from_sync_fn ( & callable_name, function) ;
117
+
118
+ #[ cfg( not( feature = "experimental-threads" ) ) ]
119
+ let callable = Self :: from_local_fn ( & callable_name, function) ;
120
+
121
+ callable
122
+ }
123
+
124
+ #[ deprecated = "Renamed to `from_class_static`." ]
125
+ #[ cfg( since_api = "4.4" ) ]
126
+ pub fn from_local_static (
127
+ class_name : impl meta:: AsArg < StringName > ,
128
+ function_name : impl meta:: AsArg < StringName > ,
129
+ ) -> Self {
130
+ Self :: from_class_static ( class_name, function_name)
116
131
}
117
132
118
133
fn default_callable_custom_info ( ) -> CallableCustomInfo {
0 commit comments