summaryrefslogtreecommitdiffstats
path: root/core/object
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-02-16 09:38:57 -0600
committerDavid Snopek <dsnopek@gmail.com>2023-05-22 06:58:59 -0500
commitc6b0d4aae3bdd41e8bd45de03c83609892c6cb41 (patch)
treeadaceeb0d0ceb15c751d220c45904cd49b8e2a76 /core/object
parenta8453cb3337c2e27c061a385f9c772cf670e38e0 (diff)
downloadredot-engine-c6b0d4aae3bdd41e8bd45de03c83609892c6cb41.tar.gz
Add GDExtension function to get Object class name
Diffstat (limited to 'core/object')
-rw-r--r--core/object/object.cpp2
-rw-r--r--core/object/object.h14
2 files changed, 15 insertions, 1 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 5a34328ec4..18e7f65a97 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -1739,7 +1739,7 @@ void *Object::get_instance_binding(void *p_token, const GDExtensionInstanceBindi
break;
}
}
- if (unlikely(!binding)) {
+ if (unlikely(!binding && p_callbacks)) {
uint32_t current_size = next_power_of_2(_instance_binding_count);
uint32_t new_size = next_power_of_2(_instance_binding_count + 1);
diff --git a/core/object/object.h b/core/object/object.h
index c4d287a71c..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);