mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Merge pull request #97374 from rune-scape/get-native-static-callable
GDScriptNativeClass: Allow getting static function as callable
This commit is contained in:
commit
7444da766a
@ -76,9 +76,16 @@ bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (ok) {
|
||||
r_ret = v;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
MethodBind *method = ClassDB::get_method(name, p_name);
|
||||
if (method && method->is_static()) {
|
||||
// Native static method.
|
||||
r_ret = Callable(this, p_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GDScriptNativeClass::_bind_methods() {
|
||||
|
@ -0,0 +1,8 @@
|
||||
func get_parse_string(t: Variant):
|
||||
return t.parse_string
|
||||
|
||||
func test():
|
||||
var a: Callable = JSON.parse_string
|
||||
var b: Callable = get_parse_string(JSON)
|
||||
prints(a.call("{\"test\": \"a\"}"), a.is_valid())
|
||||
prints(b.call("{\"test\": \"b\"}"), b.is_valid())
|
@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
{ "test": "a" } false
|
||||
{ "test": "b" } false
|
Loading…
Reference in New Issue
Block a user