summaryrefslogtreecommitdiff
path: root/core/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/object.h')
-rw-r--r--core/object.h60
1 files changed, 34 insertions, 26 deletions
diff --git a/core/object.h b/core/object.h
index 20defae095..95662f6208 100644
--- a/core/object.h
+++ b/core/object.h
@@ -138,7 +138,6 @@ enum PropertyUsageFlags {
#define ADD_SUBGROUP(m_name, m_prefix) ClassDB::add_property_subgroup(get_class_static(), m_name, m_prefix)
struct PropertyInfo {
-
Variant::Type type = Variant::NIL;
String name;
StringName class_name; //for classes
@@ -164,7 +163,6 @@ struct PropertyInfo {
hint(p_hint),
hint_string(p_hint_string),
usage(p_usage) {
-
if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
class_name = hint_string;
} else {
@@ -193,7 +191,6 @@ struct PropertyInfo {
Array convert_property_list(const List<PropertyInfo> *p_list);
struct MethodInfo {
-
String name;
PropertyInfo return_val;
uint32_t flags; // NOLINT - prevent clang-tidy to assign method_bind.h constant here, it should stay in .cpp.
@@ -263,8 +260,9 @@ public:
return String(#m_class); \
} \
virtual const StringName *_get_class_namev() const { \
- if (!_class_name) \
+ if (!_class_name) { \
_class_name = get_class_static(); \
+ } \
return &_class_name; \
} \
static _FORCE_INLINE_ void *get_class_ptr_static() { \
@@ -284,8 +282,9 @@ public:
static String get_category_static() { \
String category = m_inherits::get_category_static(); \
if (_get_category != m_inherits::_get_category) { \
- if (category != "") \
+ if (category != "") { \
category += "/"; \
+ } \
category += _get_category(); \
} \
return category; \
@@ -297,7 +296,6 @@ public:
virtual bool is_class_ptr(void *p_ptr) const { return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); } \
\
static void get_valid_parents_static(List<String> *p_parents) { \
- \
if (m_class::_get_valid_parents_static != m_inherits::_get_valid_parents_static) { \
m_class::_get_valid_parents_static(p_parents); \
} \
@@ -313,12 +311,14 @@ protected:
public: \
static void initialize_class() { \
static bool initialized = false; \
- if (initialized) \
+ if (initialized) { \
return; \
+ } \
m_inherits::initialize_class(); \
ClassDB::_add_class<m_class>(); \
- if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) \
+ if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) { \
_bind_methods(); \
+ } \
initialized = true; \
} \
\
@@ -331,8 +331,9 @@ protected:
} \
virtual bool _getv(const StringName &p_name, Variant &r_ret) const { \
if (m_class::_get_get() != m_inherits::_get_get()) { \
- if (_get(p_name, r_ret)) \
+ if (_get(p_name, r_ret)) { \
return true; \
+ } \
} \
return m_inherits::_getv(p_name, r_ret); \
} \
@@ -340,8 +341,9 @@ protected:
return (bool (Object::*)(const StringName &, const Variant &)) & m_class::_set; \
} \
virtual bool _setv(const StringName &p_name, const Variant &p_property) { \
- if (m_inherits::_setv(p_name, p_property)) \
+ if (m_inherits::_setv(p_name, p_property)) { \
return true; \
+ } \
if (m_class::_get_set() != m_inherits::_get_set()) { \
return _set(p_name, p_property); \
} \
@@ -355,13 +357,15 @@ protected:
m_inherits::_get_property_listv(p_list, p_reversed); \
} \
p_list->push_back(PropertyInfo(Variant::NIL, get_class_static(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); \
- if (!_is_gpl_reversed()) \
+ if (!_is_gpl_reversed()) { \
ClassDB::get_property_list(#m_class, p_list, true, this); \
+ } \
if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) { \
_get_property_list(p_list); \
} \
- if (_is_gpl_reversed()) \
+ if (_is_gpl_reversed()) { \
ClassDB::get_property_list(#m_class, p_list, true, this); \
+ } \
if (p_reversed) { \
m_inherits::_get_property_listv(p_list, p_reversed); \
} \
@@ -370,13 +374,15 @@ protected:
return (void (Object::*)(int)) & m_class::_notification; \
} \
virtual void _notificationv(int p_notification, bool p_reversed) { \
- if (!p_reversed) \
+ if (!p_reversed) { \
m_inherits::_notificationv(p_notification, p_reversed); \
+ } \
if (m_class::_get_notification() != m_inherits::_get_notification()) { \
_notification(p_notification); \
} \
- if (p_reversed) \
+ if (p_reversed) { \
m_inherits::_notificationv(p_notification, p_reversed); \
+ } \
} \
\
private:
@@ -406,7 +412,6 @@ public:
};
struct Connection {
-
::Signal signal;
Callable callable;
@@ -432,7 +437,6 @@ private:
friend void postinitialize_handler(Object *);
struct SignalData {
-
struct Slot {
int reference_count = 0;
Connection conn;
@@ -532,8 +536,9 @@ protected:
Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual const StringName *_get_class_namev() const {
- if (!_class_name)
+ if (!_class_name) {
_class_name = get_class_static();
+ }
return &_class_name;
}
@@ -556,8 +561,9 @@ public:
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ void _change_notify(const char *p_property = "") {
_edited = true;
- for (Set<Object *>::Element *E = change_receptors.front(); E; E = E->next())
+ for (Set<Object *>::Element *E = change_receptors.front(); E; E = E->next()) {
((Object *)(E->get()))->_changed_callback(this, p_property);
+ }
}
#else
_FORCE_INLINE_ void _change_notify(const char *p_what = "") {}
@@ -580,12 +586,14 @@ public:
#ifndef NO_SAFE_CAST
return dynamic_cast<T *>(p_object);
#else
- if (!p_object)
+ if (!p_object) {
return nullptr;
- if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ }
+ if (p_object->is_class_ptr(T::get_class_ptr_static())) {
return static_cast<T *>(p_object);
- else
+ } else {
return nullptr;
+ }
#endif
}
@@ -594,12 +602,14 @@ public:
#ifndef NO_SAFE_CAST
return dynamic_cast<const T *>(p_object);
#else
- if (!p_object)
+ if (!p_object) {
return nullptr;
- if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ }
+ if (p_object->is_class_ptr(T::get_class_ptr_static())) {
return static_cast<const T *>(p_object);
- else
+ } else {
return nullptr;
+ }
#endif
}
@@ -744,7 +754,6 @@ bool predelete_handler(Object *p_object);
void postinitialize_handler(Object *p_object);
class ObjectDB {
-
//this needs to add up to 63, 1 bit is for reference
#define OBJECTDB_VALIDATOR_BITS 39
#define OBJECTDB_VALIDATOR_MASK ((uint64_t(1) << OBJECTDB_VALIDATOR_BITS) - 1)
@@ -779,7 +788,6 @@ public:
typedef void (*DebugFunc)(Object *p_obj);
_ALWAYS_INLINE_ static Object *get_instance(ObjectID p_instance_id) {
-
uint64_t id = p_instance_id;
uint32_t slot = id & OBJECTDB_SLOT_MAX_COUNT_MASK;