summaryrefslogtreecommitdiffstats
path: root/core/object/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/object/object.h')
-rw-r--r--core/object/object.h55
1 files changed, 38 insertions, 17 deletions
diff --git a/core/object/object.h b/core/object/object.h
index ae22851c15..6f626b0ed0 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -304,8 +304,10 @@ struct MethodInfo {
// API used to extend in GDExtension and other C compatible compiled languages.
class MethodBind;
+class GDExtension;
struct ObjectGDExtension {
+ GDExtension *library = nullptr;
ObjectGDExtension *parent = nullptr;
List<ObjectGDExtension *> children;
StringName parent_class_name;
@@ -798,6 +800,18 @@ public:
return *_class_name_ptr;
}
+ _FORCE_INLINE_ const StringName &get_class_name_for_extension(const GDExtension *p_library) const {
+ // Only return the class name per the extension if it matches the given p_library.
+ if (_extension && _extension->library == p_library) {
+ return _extension->class_name;
+ }
+ // Otherwise, return the name of the built-in class.
+ if (unlikely(!_class_name_ptr)) {
+ return *_get_class_namev();
+ }
+ return *_class_name_ptr;
+ }
+
/* IAPI */
void set(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr);
@@ -836,14 +850,21 @@ public:
/* SCRIPT */
- void set_script(const Variant &p_script);
- Variant get_script() const;
+// When in debug, some non-virtual functions can be overridden for multithreaded guards.
+#ifdef DEBUG_ENABLED
+#define MTVIRTUAL virtual
+#else
+#define MTVIRTUAL
+#endif
+
+ MTVIRTUAL void set_script(const Variant &p_script);
+ MTVIRTUAL Variant get_script() const;
- bool has_meta(const StringName &p_name) const;
- void set_meta(const StringName &p_name, const Variant &p_value);
- void remove_meta(const StringName &p_name);
- Variant get_meta(const StringName &p_name, const Variant &p_default = Variant()) const;
- void get_meta_list(List<StringName> *p_list) const;
+ MTVIRTUAL bool has_meta(const StringName &p_name) const;
+ MTVIRTUAL void set_meta(const StringName &p_name, const Variant &p_value);
+ MTVIRTUAL void remove_meta(const StringName &p_name);
+ MTVIRTUAL Variant get_meta(const StringName &p_name, const Variant &p_default = Variant()) const;
+ MTVIRTUAL void get_meta_list(List<StringName> *p_list) const;
#ifdef TOOLS_ENABLED
void set_edited(bool p_edited);
@@ -870,17 +891,17 @@ public:
return emit_signalp(p_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
}
- Error emit_signalp(const StringName &p_name, const Variant **p_args, int p_argcount);
- bool has_signal(const StringName &p_name) const;
- void get_signal_list(List<MethodInfo> *p_signals) const;
- void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const;
- void get_all_signal_connections(List<Connection> *p_connections) const;
- int get_persistent_signal_connection_count() const;
- void get_signals_connected_to_this(List<Connection> *p_connections) const;
+ MTVIRTUAL Error emit_signalp(const StringName &p_name, const Variant **p_args, int p_argcount);
+ MTVIRTUAL bool has_signal(const StringName &p_name) const;
+ MTVIRTUAL void get_signal_list(List<MethodInfo> *p_signals) const;
+ MTVIRTUAL void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const;
+ MTVIRTUAL void get_all_signal_connections(List<Connection> *p_connections) const;
+ MTVIRTUAL int get_persistent_signal_connection_count() const;
+ MTVIRTUAL void get_signals_connected_to_this(List<Connection> *p_connections) const;
- Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0);
- void disconnect(const StringName &p_signal, const Callable &p_callable);
- bool is_connected(const StringName &p_signal, const Callable &p_callable) const;
+ MTVIRTUAL Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0);
+ MTVIRTUAL void disconnect(const StringName &p_signal, const Callable &p_callable);
+ MTVIRTUAL bool is_connected(const StringName &p_signal, const Callable &p_callable) const;
template <typename... VarArgs>
void call_deferred(const StringName &p_name, VarArgs... p_args) {