You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add GDExtension function to get Object class name
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user