Merge pull request #92827 from raulsntos/core/node-to_string

Use GDExtension `to_string` in Node
This commit is contained in:
Rémi Verschelde 2024-06-12 10:00:29 +02:00
commit 5bab95a556
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 8 additions and 1 deletions

View File

@ -923,6 +923,7 @@ void Object::notification(int p_notification, bool p_reversed) {
} }
String Object::to_string() { String Object::to_string() {
// Keep this method in sync with `Node::to_string`.
if (script_instance) { if (script_instance) {
bool valid; bool valid;
String ret = script_instance->to_string(&valid); String ret = script_instance->to_string(&valid);

View File

@ -2583,6 +2583,7 @@ void Node::get_storable_properties(HashSet<StringName> &r_storable_properties) c
} }
String Node::to_string() { String Node::to_string() {
// Keep this method in sync with `Object::to_string`.
ERR_THREAD_GUARD_V(String()); ERR_THREAD_GUARD_V(String());
if (get_script_instance()) { if (get_script_instance()) {
bool valid; bool valid;
@ -2591,7 +2592,12 @@ String Node::to_string() {
return ret; return ret;
} }
} }
if (_get_extension() && _get_extension()->to_string) {
String ret;
GDExtensionBool is_valid;
_get_extension()->to_string(_get_extension_instance(), &is_valid, &ret);
return ret;
}
return (get_name() ? String(get_name()) + ":" : "") + Object::to_string(); return (get_name() ? String(get_name()) + ":" : "") + Object::to_string();
} }