Merge pull request #42607 from Dragoncraft89/type_checks

Raise error if Resource is of wrong type as function argument
This commit is contained in:
Rémi Verschelde 2021-04-28 09:33:22 +02:00 committed by GitHub
commit 5c5cfaabf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,6 +122,18 @@ struct VariantObjectClassChecker {
}
};
template <typename T>
class Ref;
template <typename T>
struct VariantObjectClassChecker<const Ref<T> &> {
static _FORCE_INLINE_ bool check(const Variant &p_variant) {
Object *obj = p_variant;
const Ref<T> node = p_variant;
return node.ptr() || !obj;
}
};
template <>
struct VariantObjectClassChecker<Node *> {
static _FORCE_INLINE_ bool check(const Variant &p_variant) {