mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
GDScript: Add support for static method calls in native types
This commit is contained in:
parent
e4f0fc50f7
commit
4710e2b278
11 changed files with 135 additions and 20 deletions
|
@ -92,6 +92,21 @@ Object *GDScriptNativeClass::instantiate() {
|
|||
return ClassDB::instantiate(name);
|
||||
}
|
||||
|
||||
Variant GDScriptNativeClass::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_method == SNAME("new")) {
|
||||
// Constructor.
|
||||
return Object::callp(p_method, p_args, p_argcount, r_error);
|
||||
}
|
||||
MethodBind *method = ClassDB::get_method(name, p_method);
|
||||
if (method) {
|
||||
// Native static method.
|
||||
return method->call(nullptr, p_args, p_argcount, r_error);
|
||||
}
|
||||
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
GDScriptFunction *GDScript::_super_constructor(GDScript *p_script) {
|
||||
if (p_script->initializer) {
|
||||
return p_script->initializer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue