Add Callable.is_valid() analogous to FuncRef.is_valid() from 3.x

This commit is contained in:
Lyuma
2021-06-30 07:36:46 -07:00
parent bb409efa1c
commit 8f1efa656b
4 changed files with 13 additions and 0 deletions

View File

@@ -89,6 +89,10 @@ Callable Callable::unbind(int p_argcount) const {
return Callable(memnew(CallableCustomUnbind(*this, p_argcount)));
}
bool Callable::is_valid() const {
return get_object() && (is_custom() || get_object()->has_method(get_method()));
}
Object *Callable::get_object() const {
if (is_null()) {
return nullptr;