diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-04-06 20:57:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 20:57:34 +0200 |
commit | 4d0fdf2e98be631e90b8320d10d842a042e31c8a (patch) | |
tree | 8221e3e892cb5eacda6d4b3ab6623bb4825b78c4 /modules/gdscript/gdscript.cpp | |
parent | ac591d9904e4e5cf7841b3e79caabf558d37db0e (diff) | |
parent | 4710e2b278bfaa60cfcd3158e2d23e8e9a901e1f (diff) |
Merge pull request #59947 from vnen/gdscript-static-methods-classdb
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 3a0e320e9b..6c7d5cc3e1 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -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; |