Add check to ensure registered classes are declared

Checks that all classes registered to `ClassDB` have been properly declared with `GDCLASS`

(cherry picked from commit 4b205afd3d)
This commit is contained in:
A Thousand Ships 2023-08-27 16:22:01 +02:00 committed by Rémi Verschelde
parent 442677a3f0
commit dc095b8ad4
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 6 additions and 0 deletions

View File

@ -170,6 +170,7 @@ public:
template <class T>
static void register_class() {
GLOBAL_LOCK_FUNCTION;
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
@ -182,6 +183,7 @@ public:
template <class T>
static void register_virtual_class() {
GLOBAL_LOCK_FUNCTION;
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
@ -198,6 +200,7 @@ public:
template <class T>
static void register_custom_instance_class() {
GLOBAL_LOCK_FUNCTION;
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);

View File

@ -267,6 +267,7 @@ private:
friend class ClassDB; \
\
public: \
typedef m_class self_type; \
virtual String get_class() const { \
return String(#m_class); \
} \
@ -405,6 +406,8 @@ class ObjectRC;
class Object {
public:
typedef Object self_type;
enum ConnectFlags {
CONNECT_DEFERRED = 1,