From 04ebf294f36eeae859b33299f29ca4dd7c0cf7c1 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Fri, 24 May 2019 00:40:16 +0200 Subject: [PATCH] C#: Implement ScriptInstance::to_string Create a blacklist of methods that must not be generated. Includes: "to_string", "_to_string" and "_init". --- modules/mono/csharp_script.cpp | 28 ++++++++++++++++++++++ modules/mono/csharp_script.h | 2 ++ modules/mono/editor/bindings_generator.cpp | 16 ++++++++++++- modules/mono/editor/bindings_generator.h | 4 ++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index bfbd6ca80ef..72199281ff1 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1855,6 +1855,34 @@ void CSharpInstance::_call_notification(int p_notification) { } } +String CSharpInstance::to_string(bool *r_valid) { + MonoObject *mono_object = get_mono_object(); + + if (mono_object == NULL) { + if (r_valid) + *r_valid = false; + return String(); + } + + MonoException *exc = NULL; + MonoString *result = GDMonoUtils::object_to_string(mono_object, &exc); + + if (exc) { + GDMonoUtils::set_pending_exception(exc); + if (r_valid) + *r_valid = false; + return String(); + } + + if (result == NULL) { + if (r_valid) + *r_valid = false; + return String(); + } + + return GDMonoMarshal::mono_string_to_godot(result); +} + Ref