[C#] Unexpose GodotSharp

This class seems to have been exposed accidentally, and breaks
documentation on non-mono builds, requiring hacks
This commit is contained in:
A Thousand Ships 2024-05-04 13:20:14 +02:00
parent 7ebc866418
commit aff2e47bff
No known key found for this signature in database
GPG Key ID: 2033189A662F8BD7
8 changed files with 4 additions and 63 deletions

View File

@ -1570,9 +1570,6 @@
<member name="Geometry3D" type="Geometry3D" setter="" getter=""> <member name="Geometry3D" type="Geometry3D" setter="" getter="">
The [Geometry3D] singleton. The [Geometry3D] singleton.
</member> </member>
<member name="GodotSharp" type="GodotSharp" setter="" getter="">
The [GodotSharp] singleton.
</member>
<member name="IP" type="IP" setter="" getter=""> <member name="IP" type="IP" setter="" getter="">
The [IP] singleton. The [IP] singleton.
</member> </member>

View File

@ -344,25 +344,6 @@ void DocTools::merge_from(const DocTools &p_data) {
merge_theme_properties(c.theme_properties, cf.theme_properties); merge_theme_properties(c.theme_properties, cf.theme_properties);
merge_operators(c.operators, cf.operators); 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
} }
} }

View File

@ -5,7 +5,6 @@
</brief_description> </brief_description>
<description> <description>
This class represents a C# script. It is the C# equivalent of the [GDScript] class and is only available in Mono-enabled Godot builds. 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].
</description> </description>
<tutorials> <tutorials>
<link title="C# documentation index">$DOCS_URL/tutorials/scripting/c_sharp/index.html</link> <link title="C# documentation index">$DOCS_URL/tutorials/scripting/c_sharp/index.html</link>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GodotSharp" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Bridge between Godot and the Mono runtime (Mono-enabled builds only).
</brief_description>
<description>
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].
</description>
<tutorials>
</tutorials>
<methods>
<method name="is_runtime_initialized">
<return type="bool" />
<description>
Returns [code]true[/code] if the .NET runtime is initialized, [code]false[/code] otherwise.
</description>
</method>
</methods>
</class>

View File

@ -143,7 +143,7 @@ bool godot_icall_Internal_IsAssembliesReloadingNeeded() {
void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) { void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) {
#ifdef GD_MONO_HOT_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 #endif
} }

View File

@ -564,11 +564,7 @@ namespace mono_bind {
GodotSharp *GodotSharp::singleton = nullptr; GodotSharp *GodotSharp::singleton = nullptr;
bool GodotSharp::_is_runtime_initialized() { void GodotSharp::reload_assemblies(bool p_soft_reload) {
return GDMono::get_singleton() != nullptr && GDMono::get_singleton()->is_runtime_initialized();
}
void GodotSharp::_reload_assemblies(bool p_soft_reload) {
#ifdef GD_MONO_HOT_RELOAD #ifdef GD_MONO_HOT_RELOAD
CRASH_COND(CSharpLanguage::get_singleton() == nullptr); CRASH_COND(CSharpLanguage::get_singleton() == nullptr);
// This method may be called more than once with `call_deferred`, so we need to check // 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 #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() { GodotSharp::GodotSharp() {
singleton = this; singleton = this;
} }

View File

@ -167,18 +167,14 @@ namespace mono_bind {
class GodotSharp : public Object { class GodotSharp : public Object {
GDCLASS(GodotSharp, Object); GDCLASS(GodotSharp, Object);
friend class GDMono;
void _reload_assemblies(bool p_soft_reload);
bool _is_runtime_initialized();
protected: protected:
static GodotSharp *singleton; static GodotSharp *singleton;
static void _bind_methods();
public: public:
static GodotSharp *get_singleton() { return singleton; } static GodotSharp *get_singleton() { return singleton; }
void reload_assemblies(bool p_soft_reload);
GodotSharp(); GodotSharp();
~GodotSharp(); ~GodotSharp();
}; };

View File

@ -49,9 +49,6 @@ void initialize_mono_module(ModuleInitializationLevel p_level) {
_godotsharp = memnew(mono_bind::GodotSharp); _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 = memnew(CSharpLanguage);
script_language_cs->set_language_index(ScriptServer::get_language_count()); script_language_cs->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(script_language_cs); ScriptServer::register_language(script_language_cs);