From aff2e47bff7bb70c068772d5bb49b57a2acd19aa Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sat, 4 May 2024 13:20:14 +0200 Subject: [PATCH] [C#] Unexpose `GodotSharp` This class seems to have been exposed accidentally, and breaks documentation on non-mono builds, requiring hacks --- doc/classes/@GlobalScope.xml | 3 --- editor/doc_tools.cpp | 19 ------------------ modules/mono/doc_classes/CSharpScript.xml | 1 - modules/mono/doc_classes/GodotSharp.xml | 20 ------------------- modules/mono/editor/editor_internal_calls.cpp | 2 +- modules/mono/mono_gd/gd_mono.cpp | 11 +--------- modules/mono/mono_gd/gd_mono.h | 8 ++------ modules/mono/register_types.cpp | 3 --- 8 files changed, 4 insertions(+), 63 deletions(-) delete mode 100644 modules/mono/doc_classes/GodotSharp.xml diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 26bf5151358..87bc4c6db28 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1570,9 +1570,6 @@ The [Geometry3D] singleton. - - The [GodotSharp] singleton. - The [IP] singleton. diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index db45478d215..5de31a5c0a7 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -344,25 +344,6 @@ void DocTools::merge_from(const DocTools &p_data) { merge_theme_properties(c.theme_properties, cf.theme_properties); merge_operators(c.operators, cf.operators); - -#ifndef MODULE_MONO_ENABLED - // The Mono module defines some properties that we want to keep when - // re-generating docs with a non-Mono build, to prevent pointless diffs - // (and loss of descriptions) depending on the config of the doc writer. - // We use a horrible hack to force keeping the relevant properties, - // hardcoded below. At least it's an ad hoc hack... ¯\_(ツ)_/¯ - // Don't show this to your kids. - if (c.name == "@GlobalScope") { - // Retrieve GodotSharp singleton. - for (int j = 0; j < cf.properties.size(); j++) { - if (cf.properties[j].name == "GodotSharp") { - c.properties.push_back(cf.properties[j]); - c.properties.sort(); - break; - } - } - } -#endif } } diff --git a/modules/mono/doc_classes/CSharpScript.xml b/modules/mono/doc_classes/CSharpScript.xml index b559ca20b26..7e14259d5a2 100644 --- a/modules/mono/doc_classes/CSharpScript.xml +++ b/modules/mono/doc_classes/CSharpScript.xml @@ -5,7 +5,6 @@ This class represents a C# script. It is the C# equivalent of the [GDScript] class and is only available in Mono-enabled Godot builds. - See also [GodotSharp]. $DOCS_URL/tutorials/scripting/c_sharp/index.html diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml deleted file mode 100644 index 969ca143500..00000000000 --- a/modules/mono/doc_classes/GodotSharp.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - Bridge between Godot and the Mono runtime (Mono-enabled builds only). - - - This class is a bridge between Godot and the Mono runtime. It exposes several low-level operations and is only available in Mono-enabled Godot builds. - See also [CSharpScript]. - - - - - - - - Returns [code]true[/code] if the .NET runtime is initialized, [code]false[/code] otherwise. - - - - diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 05dacd28fb0..03d8b4eab60 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -143,7 +143,7 @@ bool godot_icall_Internal_IsAssembliesReloadingNeeded() { void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) { #ifdef GD_MONO_HOT_RELOAD - mono_bind::GodotSharp::get_singleton()->call_deferred(SNAME("_reload_assemblies"), (bool)p_soft_reload); + callable_mp(mono_bind::GodotSharp::get_singleton(), &mono_bind::GodotSharp::reload_assemblies).call_deferred(p_soft_reload); #endif } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 0e34616951a..48caae8523c 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -564,11 +564,7 @@ namespace mono_bind { GodotSharp *GodotSharp::singleton = nullptr; -bool GodotSharp::_is_runtime_initialized() { - return GDMono::get_singleton() != nullptr && GDMono::get_singleton()->is_runtime_initialized(); -} - -void GodotSharp::_reload_assemblies(bool p_soft_reload) { +void GodotSharp::reload_assemblies(bool p_soft_reload) { #ifdef GD_MONO_HOT_RELOAD CRASH_COND(CSharpLanguage::get_singleton() == nullptr); // This method may be called more than once with `call_deferred`, so we need to check @@ -579,11 +575,6 @@ void GodotSharp::_reload_assemblies(bool p_soft_reload) { #endif } -void GodotSharp::_bind_methods() { - ClassDB::bind_method(D_METHOD("is_runtime_initialized"), &GodotSharp::_is_runtime_initialized); - ClassDB::bind_method(D_METHOD("_reload_assemblies"), &GodotSharp::_reload_assemblies); -} - GodotSharp::GodotSharp() { singleton = this; } diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h index 0cb087db570..614bfc63fb6 100644 --- a/modules/mono/mono_gd/gd_mono.h +++ b/modules/mono/mono_gd/gd_mono.h @@ -167,18 +167,14 @@ namespace mono_bind { class GodotSharp : public Object { GDCLASS(GodotSharp, Object); - friend class GDMono; - - void _reload_assemblies(bool p_soft_reload); - bool _is_runtime_initialized(); - protected: static GodotSharp *singleton; - static void _bind_methods(); public: static GodotSharp *get_singleton() { return singleton; } + void reload_assemblies(bool p_soft_reload); + GodotSharp(); ~GodotSharp(); }; diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index beaa50ecb28..4d5426d96fe 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -49,9 +49,6 @@ void initialize_mono_module(ModuleInitializationLevel p_level) { _godotsharp = memnew(mono_bind::GodotSharp); - GDREGISTER_CLASS(mono_bind::GodotSharp); - Engine::get_singleton()->add_singleton(Engine::Singleton("GodotSharp", mono_bind::GodotSharp::get_singleton())); - script_language_cs = memnew(CSharpLanguage); script_language_cs->set_language_index(ScriptServer::get_language_count()); ScriptServer::register_language(script_language_cs);