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 c638238fae
)
This commit is contained in:
parent
5261d12a66
commit
485d53133d
|
@ -187,6 +187,7 @@ public:
|
||||||
template <class T>
|
template <class T>
|
||||||
static void register_class(bool p_virtual = false) {
|
static void register_class(bool p_virtual = false) {
|
||||||
GLOBAL_LOCK_FUNCTION;
|
GLOBAL_LOCK_FUNCTION;
|
||||||
|
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
|
||||||
T::initialize_class();
|
T::initialize_class();
|
||||||
ClassInfo *t = classes.getptr(T::get_class_static());
|
ClassInfo *t = classes.getptr(T::get_class_static());
|
||||||
ERR_FAIL_COND(!t);
|
ERR_FAIL_COND(!t);
|
||||||
|
@ -201,6 +202,7 @@ public:
|
||||||
template <class T>
|
template <class T>
|
||||||
static void register_abstract_class() {
|
static void register_abstract_class() {
|
||||||
GLOBAL_LOCK_FUNCTION;
|
GLOBAL_LOCK_FUNCTION;
|
||||||
|
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
|
||||||
T::initialize_class();
|
T::initialize_class();
|
||||||
ClassInfo *t = classes.getptr(T::get_class_static());
|
ClassInfo *t = classes.getptr(T::get_class_static());
|
||||||
ERR_FAIL_COND(!t);
|
ERR_FAIL_COND(!t);
|
||||||
|
@ -221,6 +223,7 @@ public:
|
||||||
template <class T>
|
template <class T>
|
||||||
static void register_custom_instance_class() {
|
static void register_custom_instance_class() {
|
||||||
GLOBAL_LOCK_FUNCTION;
|
GLOBAL_LOCK_FUNCTION;
|
||||||
|
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
|
||||||
T::initialize_class();
|
T::initialize_class();
|
||||||
ClassInfo *t = classes.getptr(T::get_class_static());
|
ClassInfo *t = classes.getptr(T::get_class_static());
|
||||||
ERR_FAIL_COND(!t);
|
ERR_FAIL_COND(!t);
|
||||||
|
|
|
@ -382,6 +382,7 @@ private:
|
||||||
friend class ::ClassDB; \
|
friend class ::ClassDB; \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
|
typedef m_class self_type; \
|
||||||
static constexpr bool _class_is_enabled = !bool(GD_IS_DEFINED(ClassDB_Disable_##m_class)) && m_inherits::_class_is_enabled; \
|
static constexpr bool _class_is_enabled = !bool(GD_IS_DEFINED(ClassDB_Disable_##m_class)) && m_inherits::_class_is_enabled; \
|
||||||
virtual String get_class() const override { \
|
virtual String get_class() const override { \
|
||||||
if (_get_extension()) { \
|
if (_get_extension()) { \
|
||||||
|
@ -551,6 +552,8 @@ class ScriptInstance;
|
||||||
|
|
||||||
class Object {
|
class Object {
|
||||||
public:
|
public:
|
||||||
|
typedef Object self_type;
|
||||||
|
|
||||||
enum ConnectFlags {
|
enum ConnectFlags {
|
||||||
CONNECT_DEFERRED = 1,
|
CONNECT_DEFERRED = 1,
|
||||||
CONNECT_PERSIST = 2, // hint for scene to save this connection
|
CONNECT_PERSIST = 2, // hint for scene to save this connection
|
||||||
|
|
Loading…
Reference in New Issue