From f88bdac40305b824a9ceb6ed1dfb2dd5133c3e27 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Sun, 27 Mar 2022 21:31:00 +0200 Subject: [PATCH] GDExtension: change to_string signature to accept GDNativeStringPtr instead of returning const char* --- core/extension/gdnative_interface.h | 2 +- core/object/object.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index cc2957ec56b..c86bee316db 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -208,7 +208,7 @@ typedef struct { typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count); typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list); typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); -typedef const char *(*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance); +typedef void (*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDNativeStringPtr p_out); typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); diff --git a/core/object/object.cpp b/core/object/object.cpp index 226d3ef0b84..7db62fdc5c0 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -865,7 +865,9 @@ String Object::to_string() { } } if (_extension && _extension->to_string) { - return _extension->to_string(_extension_instance); + String ret; + _extension->to_string(_extension_instance, &ret); + return ret; } return "[" + get_class() + ":" + itos(get_instance_id()) + "]"; }