diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-07-22 08:57:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-22 08:57:09 +0200 |
commit | 92b65ff0c604d35dd9960310b772cba574e32926 (patch) | |
tree | 47c60229022fdf85020c04ffadb69ac98e164945 | |
parent | f551457e124e2141fb6cfc75364b2660e8f36853 (diff) | |
parent | 2c85439da00fa7277ef39d23ad29b6da9dd690e0 (diff) |
Merge pull request #30740 from neikeq/typeinfo_static_fail
Make it a build error if a GetTypeInfo specialization cannot be resolved
-rw-r--r-- | core/type_info.h | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/core/type_info.h b/core/type_info.h index d85a63ee42..61ec7b2f20 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -83,15 +83,13 @@ enum Metadata { }; } +// If the compiler fails because it's trying to instantiate the primary 'GetTypeInfo' template +// instead of one of the specializations, it's most likely because the type 'T' is not supported. +// If 'T' is a class that inherits 'Object', make sure it can see the actual class declaration +// instead of a forward declaration. You can always forward declare 'T' in a header file, and then +// include the actual declaration of 'T' in the source file where 'GetTypeInfo<T>' is instantiated. template <class T, typename = void> -struct GetTypeInfo { - static const Variant::Type VARIANT_TYPE = Variant::NIL; - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; - static inline PropertyInfo get_class_info() { - ERR_PRINT("GetTypeInfo fallback. Bug!"); - return PropertyInfo(); // Not "Nil", this is an error - } -}; +struct GetTypeInfo; #define MAKE_TYPE_INFO(m_type, m_var_type) \ template <> \ @@ -283,10 +281,7 @@ inline StringName __constant_get_enum_name(T param, const String &p_constant) { return GetTypeInfo<T>::get_class_info().class_name; } -#define CLASS_INFO(m_type) \ - (GetTypeInfo<m_type *>::VARIANT_TYPE != Variant::NIL ? \ - GetTypeInfo<m_type *>::get_class_info() : \ - GetTypeInfo<m_type>::get_class_info()) +#define CLASS_INFO(m_type) (GetTypeInfo<m_type *>::get_class_info()) #else |