diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-22 14:02:59 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-22 14:02:59 +0200 |
commit | 80bf8fd186fad181bcafccf0b4ad15ff70752ed5 (patch) | |
tree | bdfd66318101cae65adfd6fb044c633bfccf9931 /core/object | |
parent | b85269cd8b6c0b8c4b3bf6d1255f79b6cac04ec2 (diff) | |
parent | c6b0d4aae3bdd41e8bd45de03c83609892c6cb41 (diff) | |
download | redot-engine-80bf8fd186fad181bcafccf0b4ad15ff70752ed5.tar.gz |
Merge pull request #73511 from dsnopek/gdextension-object-name
Add GDExtension function to get Object class name
Diffstat (limited to 'core/object')
-rw-r--r-- | core/object/object.cpp | 2 | ||||
-rw-r--r-- | core/object/object.h | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp index f42d604832..f276547e7b 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); |