From 1aceacaa6b0820629586d49fc6d3d8ba7f1694eb Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Wed, 7 Dec 2022 16:16:51 +0100 Subject: [PATCH] C#: Rename `Object` to `GodotObject` --- modules/mono/csharp_script.cpp | 2 +- .../Godot.SourceGenerators.Sample/Bar.cs | 4 +-- .../EventSignals.cs | 2 +- .../ExportedFields.cs | 6 ++-- .../ExportedProperties.cs | 6 ++-- .../Godot.SourceGenerators.Sample/Foo.cs | 2 +- .../Godot.SourceGenerators.Sample/Generic.cs | 6 ++-- .../Godot.SourceGenerators.Sample/Methods.cs | 2 +- .../MoreExportedFields.cs | 2 +- .../Godot.SourceGenerators/Common.cs | 8 +++--- .../ExtensionMethods.cs | 2 +- .../Godot.SourceGenerators/GodotClasses.cs | 2 +- .../GodotPluginsInitializerGenerator.cs | 4 +-- .../Godot.SourceGenerators/MarshalUtils.cs | 2 +- modules/mono/editor/bindings_generator.cpp | 28 +++++++++---------- .../basic_import_script.cs | 2 +- .../EditorScenePostImport/no_comments.cs | 2 +- .../mono/glue/GodotSharp/GodotPlugins/Main.cs | 2 +- .../glue/GodotSharp/GodotSharp/Core/Array.cs | 2 +- .../Core/Bridge/CSharpInstanceBridge.cs | 16 +++++------ .../Core/Bridge/ScriptManagerBridge.cs | 26 ++++++++--------- .../GodotSharp/GodotSharp/Core/Callable.cs | 8 +++--- .../GodotSharp/Core/DelegateUtils.cs | 18 ++++++------ .../GodotSharp/GodotSharp/Core/Dictionary.cs | 4 +-- .../GodotSharp/Core/DisposablesTracker.cs | 12 ++++---- ...Extensions.cs => GodotObjectExtensions.cs} | 16 +++++------ .../{Object.base.cs => GodotObject.base.cs} | 26 ++++++++--------- ...xceptions.cs => GodotObject.exceptions.cs} | 2 +- .../Core/NativeInterop/InteropUtils.cs | 14 +++++----- .../Core/NativeInterop/Marshaling.cs | 12 ++++---- .../Core/NativeInterop/VariantUtils.cs | 10 +++---- .../NativeInterop/VariantUtils.generic.cs | 6 ++-- .../glue/GodotSharp/GodotSharp/Core/Rid.cs | 2 +- .../glue/GodotSharp/GodotSharp/Core/Signal.cs | 7 +++-- .../GodotSharp/Core/SignalAwaiter.cs | 6 ++-- .../GodotSharp/GodotSharp/Core/Variant.cs | 14 +++++----- .../GodotSharp/GodotSharp/GodotSharp.csproj | 6 ++-- modules/mono/utils/naming_utils.cpp | 1 + 38 files changed, 147 insertions(+), 145 deletions(-) rename modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/{ObjectExtensions.cs => GodotObjectExtensions.cs} (83%) rename modules/mono/glue/GodotSharp/GodotSharp/Core/{Object.base.cs => GodotObject.base.cs} (91%) rename modules/mono/glue/GodotSharp/GodotSharp/Core/{Object.exceptions.cs => GodotObject.exceptions.cs} (99%) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 5172c63e10d..fe0f4aae818 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -410,7 +410,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { } if (p_var_type_name == Variant::get_type_name(Variant::OBJECT)) { - return "Godot.Object"; + return "GodotObject"; } if (p_var_type_name == Variant::get_type_name(Variant::INT)) { diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs index 5eaebc44746..2d797e2f464 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs @@ -1,6 +1,6 @@ namespace Godot.SourceGenerators.Sample { - partial class Bar : Godot.Object + partial class Bar : GodotObject { } @@ -9,7 +9,7 @@ namespace Godot.SourceGenerators.Sample { } - partial class NotSameNameAsFile : Godot.Object + partial class NotSameNameAsFile : GodotObject { } } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/EventSignals.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/EventSignals.cs index 764ba8f1219..ee6aa857fcc 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/EventSignals.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/EventSignals.cs @@ -1,6 +1,6 @@ namespace Godot.SourceGenerators.Sample; -public partial class EventSignals : Godot.Object +public partial class EventSignals : GodotObject { [Signal] public delegate void MySignalEventHandler(string str, int num); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs index 813b810eea9..31e66ac306c 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedFields.cs @@ -11,7 +11,7 @@ namespace Godot.SourceGenerators.Sample [SuppressMessage("ReSharper", "RedundantNameQualifier")] [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")] [SuppressMessage("ReSharper", "InconsistentNaming")] - public partial class ExportedFields : Godot.Object + public partial class ExportedFields : GodotObject { [Export] private Boolean field_Boolean = true; [Export] private Char field_Char = 'f'; @@ -80,7 +80,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Vector2[] field_Vector2Array = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right }; [Export] private Vector3[] field_Vector3Array = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right }; [Export] private Color[] field_ColorArray = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige }; - [Export] private Godot.Object[] field_GodotObjectOrDerivedArray = { null }; + [Export] private GodotObject[] field_GodotObjectOrDerivedArray = { null }; [Export] private StringName[] field_StringNameArray = { "foo", "bar" }; [Export] private NodePath[] field_NodePathArray = { "foo", "bar" }; [Export] private Rid[] field_RidArray = { default, default, default }; @@ -93,7 +93,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Variant field_Variant = "foo"; // Classes - [Export] private Godot.Object field_GodotObjectOrDerived; + [Export] private GodotObject field_GodotObjectOrDerived; [Export] private Godot.Texture field_GodotResourceTexture; [Export] private StringName field_StringName = new StringName("foo"); [Export] private NodePath field_NodePath = new NodePath("foo"); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs index cd8559d16cf..aef2a8824e4 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedProperties.cs @@ -10,7 +10,7 @@ namespace Godot.SourceGenerators.Sample [SuppressMessage("ReSharper", "RedundantNameQualifier")] [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")] [SuppressMessage("ReSharper", "InconsistentNaming")] - public partial class ExportedProperties : Godot.Object + public partial class ExportedProperties : GodotObject { // Do not generate default value private String _notGenerate_Property_String = new string("not generate"); @@ -168,7 +168,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Vector2[] property_Vector2Array { get; set; } = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right }; [Export] private Vector3[] property_Vector3Array { get; set; } = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right }; [Export] private Color[] property_ColorArray { get; set; } = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige }; - [Export] private Godot.Object[] property_GodotObjectOrDerivedArray { get; set; } = { null }; + [Export] private GodotObject[] property_GodotObjectOrDerivedArray { get; set; } = { null }; [Export] private StringName[] field_StringNameArray { get; set; } = { "foo", "bar" }; [Export] private NodePath[] field_NodePathArray { get; set; } = { "foo", "bar" }; [Export] private Rid[] field_RidArray { get; set; } = { default, default, default }; @@ -177,7 +177,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Variant property_Variant { get; set; } = "foo"; // Classes - [Export] private Godot.Object property_GodotObjectOrDerived { get; set; } + [Export] private GodotObject property_GodotObjectOrDerived { get; set; } [Export] private Godot.Texture property_GodotResourceTexture { get; set; } [Export] private StringName property_StringName { get; set; } = new StringName("foo"); [Export] private NodePath property_NodePath { get; set; } = new NodePath("foo"); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs index 21a5bfe5606..9ef72d9e021 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs @@ -1,6 +1,6 @@ namespace Godot.SourceGenerators.Sample { - partial class Foo : Godot.Object + partial class Foo : GodotObject { } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs index b21b035b4d9..2cd1a08c0ee 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs @@ -2,19 +2,19 @@ namespace Godot.SourceGenerators.Sample { - partial class Generic : Godot.Object + partial class Generic : GodotObject { private int _field; } // Generic again but different generic parameters - partial class Generic : Godot.Object + partial class Generic : GodotObject { private int _field; } // Generic again but without generic parameters - partial class Generic : Godot.Object + partial class Generic : GodotObject { private int _field; } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Methods.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Methods.cs index 618ba24abcc..9aa6be39720 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Methods.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Methods.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; namespace Godot.SourceGenerators.Sample; [SuppressMessage("ReSharper", "RedundantNameQualifier")] -public partial class Methods : Godot.Object +public partial class Methods : GodotObject { private void MethodWithOverload() { diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/MoreExportedFields.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/MoreExportedFields.cs index a6c8e526676..64088215e98 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/MoreExportedFields.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/MoreExportedFields.cs @@ -11,7 +11,7 @@ namespace Godot.SourceGenerators.Sample [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")] [SuppressMessage("ReSharper", "InconsistentNaming")] // We split the definition of ExportedFields to verify properties work across multiple files. - public partial class ExportedFields : Godot.Object + public partial class ExportedFields : GodotObject { // Note we use Array and not System.Array. This tests the generated namespace qualification. [Export] private Int64[] field_empty_Int64Array = Array.Empty(); diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs index 4eed2d7b7b2..41bf89e6d8c 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs @@ -14,9 +14,9 @@ namespace Godot.SourceGenerators { string message = "Missing partial modifier on declaration of type '" + - $"{symbol.FullQualifiedNameOmitGlobal()}' which is a subclass of '{GodotClasses.Object}'"; + $"{symbol.FullQualifiedNameOmitGlobal()}' which is a subclass of '{GodotClasses.GodotObject}'"; - string description = $"{message}. Subclasses of '{GodotClasses.Object}' " + + string description = $"{message}. Subclasses of '{GodotClasses.GodotObject}' " + "must be declared with the partial modifier."; context.ReportDiagnostic(Diagnostic.Create( @@ -46,9 +46,9 @@ namespace Godot.SourceGenerators string message = $"Missing partial modifier on declaration of type '{fullQualifiedName}', " + - $"which contains one or more subclasses of '{GodotClasses.Object}'"; + $"which contains one or more subclasses of '{GodotClasses.GodotObject}'"; - string description = $"{message}. Subclasses of '{GodotClasses.Object}' and their " + + string description = $"{message}. Subclasses of '{GodotClasses.GodotObject}' and their " + "containing types must be declared with the partial modifier."; context.ReportDiagnostic(Diagnostic.Create( diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs index 8852b7ebad0..f0c9043fd5c 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs @@ -85,7 +85,7 @@ namespace Godot.SourceGenerators var classTypeSymbol = sm.GetDeclaredSymbol(cds); if (classTypeSymbol?.BaseType == null - || !classTypeSymbol.BaseType.InheritsFrom("GodotSharp", GodotClasses.Object)) + || !classTypeSymbol.BaseType.InheritsFrom("GodotSharp", GodotClasses.GodotObject)) { symbol = null; return false; diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs index a0ed1bf1d9d..b60148b34f7 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs @@ -2,7 +2,7 @@ namespace Godot.SourceGenerators { public static class GodotClasses { - public const string Object = "Godot.Object"; + public const string GodotObject = "Godot.GodotObject"; public const string AssemblyHasScriptsAttr = "Godot.AssemblyHasScriptsAttribute"; public const string ExportAttr = "Godot.ExportAttribute"; public const string ExportCategoryAttr = "Godot.ExportCategoryAttribute"; diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs index 19fdd51dabb..813bdf1e9fd 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs @@ -34,7 +34,7 @@ namespace GodotPlugins.Game { DllImportResolver dllImportResolver = new GodotDllImportResolver(godotDllHandle).OnResolveDllImport; - var coreApiAssembly = typeof(Godot.Object).Assembly; + var coreApiAssembly = typeof(global::Godot.GodotObject).Assembly; NativeLibrary.SetDllImportResolver(coreApiAssembly, dllImportResolver); @@ -42,7 +42,7 @@ namespace GodotPlugins.Game ManagedCallbacks.Create(outManagedCallbacks); - ScriptManagerBridge.LookupScriptsInAssembly(typeof(GodotPlugins.Game.Main).Assembly); + ScriptManagerBridge.LookupScriptsInAssembly(typeof(global::GodotPlugins.Game.Main).Assembly); return godot_bool.True; } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs index 70fb7d7b2d8..0258f53062f 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs @@ -19,7 +19,7 @@ namespace Godot.SourceGenerators throw new InvalidOperationException($"Type not found: '{fullyQualifiedMetadataName}'."); } - GodotObjectType = GetTypeByMetadataNameOrThrow("Godot.Object"); + GodotObjectType = GetTypeByMetadataNameOrThrow(GodotClasses.GodotObject); } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 137e222c705..390d1e5d3d2 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -497,7 +497,7 @@ void BindingsGenerator::_append_xml_method(StringBuilder &p_xml_output, const Ty } else if (!p_target_itype || !p_target_itype->is_object_type) { if (OS::get_singleton()->is_stdout_verbose()) { if (p_target_itype) { - OS::get_singleton()->print("Cannot resolve method reference for non-Godot.Object type in documentation: %s\n", p_link_target.utf8().get_data()); + OS::get_singleton()->print("Cannot resolve method reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); } else { OS::get_singleton()->print("Cannot resolve type from method reference in documentation: %s\n", p_link_target.utf8().get_data()); } @@ -537,7 +537,7 @@ void BindingsGenerator::_append_xml_member(StringBuilder &p_xml_output, const Ty } else if (!p_target_itype || !p_target_itype->is_object_type) { if (OS::get_singleton()->is_stdout_verbose()) { if (p_target_itype) { - OS::get_singleton()->print("Cannot resolve member reference for non-Godot.Object type in documentation: %s\n", p_link_target.utf8().get_data()); + OS::get_singleton()->print("Cannot resolve member reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); } else { OS::get_singleton()->print("Cannot resolve type from member reference in documentation: %s\n", p_link_target.utf8().get_data()); } @@ -573,7 +573,7 @@ void BindingsGenerator::_append_xml_signal(StringBuilder &p_xml_output, const Ty if (!p_target_itype || !p_target_itype->is_object_type) { if (OS::get_singleton()->is_stdout_verbose()) { if (p_target_itype) { - OS::get_singleton()->print("Cannot resolve signal reference for non-Godot.Object type in documentation: %s\n", p_link_target.utf8().get_data()); + OS::get_singleton()->print("Cannot resolve signal reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); } else { OS::get_singleton()->print("Cannot resolve type from signal reference in documentation: %s\n", p_link_target.utf8().get_data()); } @@ -630,7 +630,7 @@ void BindingsGenerator::_append_xml_constant(StringBuilder &p_xml_output, const if (OS::get_singleton()->is_stdout_verbose()) { if (p_target_itype) { - OS::get_singleton()->print("Cannot resolve constant reference for non-Godot.Object type in documentation: %s\n", p_link_target.utf8().get_data()); + OS::get_singleton()->print("Cannot resolve constant reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); } else { OS::get_singleton()->print("Cannot resolve type from constant reference in documentation: %s\n", p_link_target.utf8().get_data()); } @@ -1317,7 +1317,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str bool is_derived_type = itype.base_name != StringName(); if (!is_derived_type) { - // Some Godot.Object assertions + // Some GodotObject assertions CRASH_COND(itype.cname != name_cache.type_Object); CRASH_COND(!itype.is_instantiable); CRASH_COND(itype.api_type != ClassDB::API_CORE); @@ -1479,9 +1479,9 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str if (itype.is_singleton) { // Add the type name and the singleton pointer as static fields - output.append(MEMBER_BEGIN "private static Godot.Object singleton;\n"); + output.append(MEMBER_BEGIN "private static GodotObject singleton;\n"); - output << MEMBER_BEGIN "public static Godot.Object " CS_PROPERTY_SINGLETON "\n" INDENT1 "{\n" + output << MEMBER_BEGIN "public static GodotObject " CS_PROPERTY_SINGLETON "\n" INDENT1 "{\n" << INDENT2 "get\n" INDENT2 "{\n" INDENT3 "if (singleton == null)\n" << INDENT4 "singleton = " C_METHOD_ENGINE_GET_SINGLETON "(typeof(" << itype.proxy_name @@ -1491,8 +1491,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(itype.name); output.append("\";\n"); } else { - // IMPORTANT: We also generate the static fields for Godot.Object instead of declaring - // them manually in the `Object.base.cs` partial class declaration, because they're + // IMPORTANT: We also generate the static fields for GodotObject instead of declaring + // them manually in the `GodotObject.base.cs` partial class declaration, because they're // required by other static fields in this generated partial class declaration. // Static fields are initialized in order of declaration, but when they're in different // partial class declarations then it becomes harder to tell (Rider warns about this). @@ -2062,9 +2062,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf << INDENT1 "private static readonly IntPtr " << method_bind_field << " = "; if (p_itype.is_singleton) { - // Singletons are static classes. They don't derive Godot.Object, + // Singletons are static classes. They don't derive GodotObject, // so we need to specify the type to call the static method. - p_output << "Object."; + p_output << "GodotObject."; } p_output << ICALL_CLASSDB_GET_METHOD "(" BINDINGS_NATIVE_NAME_FIELD ", MethodName." @@ -2843,9 +2843,9 @@ bool BindingsGenerator::_populate_object_type_interfaces() { itype.cs_type = itype.proxy_name; if (itype.is_singleton) { - itype.cs_in_expr = "Object." CS_STATIC_METHOD_GETINSTANCE "(" CS_PROPERTY_SINGLETON ")"; + itype.cs_in_expr = "GodotObject." CS_STATIC_METHOD_GETINSTANCE "(" CS_PROPERTY_SINGLETON ")"; } else { - itype.cs_in_expr = "Object." CS_STATIC_METHOD_GETINSTANCE "(%0)"; + itype.cs_in_expr = "GodotObject." CS_STATIC_METHOD_GETINSTANCE "(%0)"; } itype.cs_out = "%5return (%2)%0(%1);"; @@ -2853,7 +2853,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { itype.c_arg_in = "(void*)%s"; itype.c_type = "IntPtr"; itype.c_type_in = itype.c_type; - itype.c_type_out = "Object"; + itype.c_type_out = "GodotObject"; // Populate properties diff --git a/modules/mono/editor/script_templates/EditorScenePostImport/basic_import_script.cs b/modules/mono/editor/script_templates/EditorScenePostImport/basic_import_script.cs index 9e1b7ef5806..fa2ff30a093 100644 --- a/modules/mono/editor/script_templates/EditorScenePostImport/basic_import_script.cs +++ b/modules/mono/editor/script_templates/EditorScenePostImport/basic_import_script.cs @@ -7,7 +7,7 @@ using System; [Tool] public partial class _CLASS_ : _BASE_ { - public override Godot.Object _PostImport(Node scene) + public override GodotObject _PostImport(Node scene) { // Modify the contents of the scene upon import. return scene; // Return the modified root node when you're done. diff --git a/modules/mono/editor/script_templates/EditorScenePostImport/no_comments.cs b/modules/mono/editor/script_templates/EditorScenePostImport/no_comments.cs index bf2c9434e4a..4365ba5a045 100644 --- a/modules/mono/editor/script_templates/EditorScenePostImport/no_comments.cs +++ b/modules/mono/editor/script_templates/EditorScenePostImport/no_comments.cs @@ -7,7 +7,7 @@ using System; [Tool] public partial class _CLASS_ : _BASE_ { - public override Godot.Object _PostImport(Node scene) + public override GodotObject _PostImport(Node scene) { return scene; } diff --git a/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs b/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs index 4ce02d221e7..2a72b7c53ed 100644 --- a/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs +++ b/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs @@ -65,7 +65,7 @@ namespace GodotPlugins } private static readonly List SharedAssemblies = new(); - private static readonly Assembly CoreApiAssembly = typeof(Godot.Object).Assembly; + private static readonly Assembly CoreApiAssembly = typeof(global::Godot.GodotObject).Assembly; private static Assembly? _editorApiAssembly; private static PluginLoadContextWrapper? _projectLoadContext; private static bool _editorHint = false; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index 469238db4de..f4646d1d3c7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -120,7 +120,7 @@ namespace Godot.Collections // fine as long as the array is not mutated. However, Span does this type checking at // instantiation, so it's not possible to use it even when not mutating anything. // ReSharper disable once RedundantNameQualifier - public Array(ReadOnlySpan array) : this() + public Array(ReadOnlySpan array) : this() { if (array == null) throw new ArgumentNullException(nameof(array)); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs index ccb21502c02..16be494d994 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs @@ -12,7 +12,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) { @@ -49,7 +49,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) throw new InvalidOperationException(); @@ -79,7 +79,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) throw new InvalidOperationException(); @@ -134,7 +134,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (okIfNull.ToBool()) godotObject?.Dispose(); @@ -152,7 +152,7 @@ namespace Godot.Bridge { try { - var self = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var self = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (self == null) { @@ -186,7 +186,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) return godot_bool.False; @@ -209,7 +209,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) return; @@ -242,7 +242,7 @@ namespace Godot.Bridge { try { - var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; + var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) return; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs index feb08bee0db..859b47c276a 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs @@ -100,7 +100,7 @@ namespace Godot.Bridge Type nativeType = TypeGetProxyClass(nativeTypeNameStr) ?? throw new InvalidOperationException( "Wrapper class not found for type: " + nativeTypeNameStr); - var obj = (Object)FormatterServices.GetUninitializedObject(nativeType); + var obj = (GodotObject)FormatterServices.GetUninitializedObject(nativeType); var ctor = nativeType.GetConstructor( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, @@ -150,7 +150,7 @@ namespace Godot.Bridge } } - var obj = (Object)FormatterServices.GetUninitializedObject(scriptType); + var obj = (GodotObject)FormatterServices.GetUninitializedObject(scriptType); var parameters = ctor.GetParameters(); int paramCount = parameters.Length; @@ -189,7 +189,7 @@ namespace Godot.Bridge return; } - var native = Object.InternalGetClassNativeBase(scriptType); + var native = GodotObject.InternalGetClassNativeBase(scriptType); var field = native?.GetField("NativeName", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); @@ -222,7 +222,7 @@ namespace Godot.Bridge { try { - var target = (Object?)GCHandle.FromIntPtr(gcHandlePtr).Target; + var target = (GodotObject?)GCHandle.FromIntPtr(gcHandlePtr).Target; if (target != null) target.NativePtr = newPtr; } @@ -239,7 +239,7 @@ namespace Godot.Bridge if (nativeTypeNameStr[0] == '_') nativeTypeNameStr = nativeTypeNameStr.Substring(1); - Type? wrapperType = typeof(Object).Assembly.GetType("Godot." + nativeTypeNameStr); + Type? wrapperType = typeof(GodotObject).Assembly.GetType("Godot." + nativeTypeNameStr); if (wrapperType == null) { @@ -252,8 +252,8 @@ namespace Godot.Bridge if (wrapperType != null && IsStatic(wrapperType)) { - // A static class means this is a Godot singleton class. If an instance is needed we use Godot.Object. - return typeof(Object); + // A static class means this is a Godot singleton class. If an instance is needed we use GodotObject. + return typeof(GodotObject); } return wrapperType; @@ -293,7 +293,7 @@ namespace Godot.Bridge // such as when disabling C# source generators (for whatever reason) or when using a // language other than C# that has nothing similar to source generators to automate it. - var typeOfGodotObject = typeof(Object); + var typeOfGodotObject = typeof(GodotObject); foreach (var type in assembly.GetTypes()) { @@ -331,7 +331,7 @@ namespace Godot.Bridge { try { - var owner = (Object?)GCHandle.FromIntPtr(ownerGCHandlePtr).Target; + var owner = (GodotObject?)GCHandle.FromIntPtr(ownerGCHandlePtr).Target; if (owner == null) { @@ -539,9 +539,9 @@ namespace Godot.Bridge } // ReSharper disable once RedundantNameQualifier - if (!typeof(Godot.Object).IsAssignableFrom(scriptType)) + if (!typeof(GodotObject).IsAssignableFrom(scriptType)) { - // The class no longer inherits Godot.Object, can't reload + // The class no longer inherits GodotObject, can't reload return godot_bool.False; } @@ -589,7 +589,7 @@ namespace Godot.Bridge using var methods = new Collections.Array(); Type? top = scriptType; - Type native = Object.InternalGetClassNativeBase(top); + Type native = GodotObject.InternalGetClassNativeBase(top); while (top != null && top != native) { @@ -899,7 +899,7 @@ namespace Godot.Bridge try { Type? top = _scriptTypeBiMap.GetScriptType(scriptPtr); - Type native = Object.InternalGetClassNativeBase(top); + Type native = GodotObject.InternalGetClassNativeBase(top); while (top != null && top != native) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs index 23b0aa92043..219a9a8c158 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs @@ -28,7 +28,7 @@ namespace Godot /// public readonly partial struct Callable { - private readonly Object _target; + private readonly GodotObject _target; private readonly StringName _method; private readonly Delegate _delegate; private readonly unsafe delegate* managed _trampoline; @@ -36,7 +36,7 @@ namespace Godot /// /// Object that contains the method. /// - public Object Target => _target; + public GodotObject Target => _target; /// /// Name of the method that will be called. @@ -60,7 +60,7 @@ namespace Godot /// /// Object that contains the method. /// Name of the method that will be called. - public unsafe Callable(Object target, StringName method) + public unsafe Callable(GodotObject target, StringName method) { _target = target; _method = method; @@ -71,7 +71,7 @@ namespace Godot private unsafe Callable(Delegate @delegate, delegate* managed trampoline) { - _target = @delegate?.Target as Object; + _target = @delegate?.Target as GodotObject; _method = null; _delegate = @delegate; _trampoline = trampoline; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs index 43bb5c55981..4a54f67cc9c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs @@ -126,7 +126,7 @@ namespace Godot } } // ReSharper disable once RedundantNameQualifier - case Godot.Object godotObject: + case GodotObject godotObject: { using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) @@ -399,7 +399,7 @@ namespace Godot { ulong objectId = reader.ReadUInt64(); // ReSharper disable once RedundantNameQualifier - Godot.Object godotObject = Godot.Object.InstanceFromId(objectId); + GodotObject godotObject = GodotObject.InstanceFromId(objectId); if (godotObject == null) return false; @@ -641,7 +641,7 @@ namespace Godot return VariantUtils.CreateFrom(nodePathArray); case Rid[] ridArray: return VariantUtils.CreateFrom(ridArray); - case Godot.Object[] godotObjectArray: + case GodotObject[] godotObjectArray: return VariantUtils.CreateFrom(godotObjectArray); case StringName stringName: return VariantUtils.CreateFrom(stringName); @@ -655,7 +655,7 @@ namespace Godot return VariantUtils.CreateFrom(godotArray); case Variant variant: return VariantUtils.CreateFrom(variant); - case Godot.Object godotObject: + case GodotObject godotObject: return VariantUtils.CreateFrom(godotObject); case Enum @enum: return VariantUtils.CreateFrom(Convert.ToInt64(@enum)); @@ -736,18 +736,18 @@ namespace Godot if (ToSystemObjectFuncByType.TryGetValue(type, out var func)) return func(variant); - if (typeof(Godot.Object).IsAssignableFrom(type)) - return Convert.ChangeType(VariantUtils.ConvertTo(variant), type); + if (typeof(GodotObject).IsAssignableFrom(type)) + return Convert.ChangeType(VariantUtils.ConvertTo(variant), type); - if (typeof(Godot.Object[]).IsAssignableFrom(type)) + if (typeof(GodotObject[]).IsAssignableFrom(type)) { - static Godot.Object[] ConvertToSystemArrayOfGodotObject(in godot_array nativeArray, Type type) + static GodotObject[] ConvertToSystemArrayOfGodotObject(in godot_array nativeArray, Type type) { var array = Collections.Array.CreateTakingOwnershipOfDisposableValue( NativeFuncs.godotsharp_array_new_copy(nativeArray)); int length = array.Count; - var ret = (Godot.Object[])Activator.CreateInstance(type, length)!; + var ret = (GodotObject[])Activator.CreateInstance(type, length)!; for (int i = 0; i < length; i++) ret[i] = array[i].AsGodotObject(); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs index 505763e6a25..fa304c1b946 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs @@ -74,7 +74,7 @@ namespace Godot.Collections /// the original dictionary. If , a shallow copy is made and /// references to the original nested arrays and dictionaries are kept, so that /// modifying a sub-array or dictionary in the copy will also impact those - /// referenced in the source dictionary. Note that any derived + /// referenced in the source dictionary. Note that any derived /// elements will be shallow copied regardless of the /// setting. /// @@ -494,7 +494,7 @@ namespace Godot.Collections /// the original dictionary. If , a shallow copy is made and /// references to the original nested arrays and dictionaries are kept, so that /// modifying a sub-array or dictionary in the copy will also impact those - /// referenced in the source dictionary. Note that any derived + /// referenced in the source dictionary. Note that any derived /// elements will be shallow copied regardless of the /// setting. /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs index bdefb3c2c52..53292e10cfd 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DisposablesTracker.cs @@ -43,9 +43,9 @@ namespace Godot // like StringName, NodePath, Godot.Collections.Array/Dictionary, etc. // The Godot Object Dispose() method may need any of the later instances. - foreach (WeakReference item in GodotObjectInstances.Keys) + foreach (WeakReference item in GodotObjectInstances.Keys) { - if (item.TryGetTarget(out Object? self)) + if (item.TryGetTarget(out GodotObject? self)) self.Dispose(); } @@ -60,15 +60,15 @@ namespace Godot } // ReSharper disable once RedundantNameQualifier - private static ConcurrentDictionary, byte> GodotObjectInstances { get; } = + private static ConcurrentDictionary, byte> GodotObjectInstances { get; } = new(); private static ConcurrentDictionary, byte> OtherInstances { get; } = new(); - public static WeakReference RegisterGodotObject(Object godotObject) + public static WeakReference RegisterGodotObject(GodotObject godotObject) { - var weakReferenceToSelf = new WeakReference(godotObject); + var weakReferenceToSelf = new WeakReference(godotObject); GodotObjectInstances.TryAdd(weakReferenceToSelf, 0); return weakReferenceToSelf; } @@ -80,7 +80,7 @@ namespace Godot return weakReferenceToSelf; } - public static void UnregisterGodotObject(Object godotObject, WeakReference weakReferenceToSelf) + public static void UnregisterGodotObject(GodotObject godotObject, WeakReference weakReferenceToSelf) { if (!GodotObjectInstances.TryRemove(weakReferenceToSelf, out _)) throw new ArgumentException("Godot Object not registered.", nameof(weakReferenceToSelf)); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ObjectExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/GodotObjectExtensions.cs similarity index 83% rename from modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ObjectExtensions.cs rename to modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/GodotObjectExtensions.cs index a9f3f028569..6c90c170783 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ObjectExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/GodotObjectExtensions.cs @@ -3,10 +3,10 @@ using Godot.NativeInterop; namespace Godot { - public partial class Object + public partial class GodotObject { /// - /// Returns the that corresponds to . + /// Returns the that corresponds to . /// All Objects have a unique instance ID. See also . /// /// @@ -25,14 +25,14 @@ namespace Godot /// /// /// Instance ID of the Object to retrieve. - /// The instance. - public static Object InstanceFromId(ulong instanceId) + /// The instance. + public static GodotObject InstanceFromId(ulong instanceId) { return InteropUtils.UnmanagedGetManaged(NativeFuncs.godotsharp_instance_from_id(instanceId)); } /// - /// Returns if the that corresponds + /// Returns if the that corresponds /// to is a valid object (e.g. has not been deleted from /// memory). All Objects have a unique instance ID. /// @@ -45,11 +45,11 @@ namespace Godot /// /// Returns if is a - /// valid (e.g. has not been deleted from memory). + /// valid (e.g. has not been deleted from memory). /// /// The instance to check. /// If the instance is a valid object. - public static bool IsInstanceValid(Object instance) + public static bool IsInstanceValid(GodotObject instance) { return instance != null && instance.NativeInstance != IntPtr.Zero; } @@ -68,7 +68,7 @@ namespace Godot /// /// The reference to the object or . /// - public static WeakRef WeakRef(Object obj) + public static WeakRef WeakRef(GodotObject obj) { if (!IsInstanceValid(obj)) return null; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs similarity index 91% rename from modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs rename to modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs index 60ee6eb6f40..b9a5ac82d13 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs @@ -5,20 +5,20 @@ using Godot.NativeInterop; namespace Godot { - public partial class Object : IDisposable + public partial class GodotObject : IDisposable { private bool _disposed = false; - private static readonly Type CachedType = typeof(Object); + private static readonly Type CachedType = typeof(GodotObject); internal IntPtr NativePtr; private bool _memoryOwn; - private WeakReference _weakReferenceToSelf; + private WeakReference _weakReferenceToSelf; /// - /// Constructs a new . + /// Constructs a new . /// - public Object() : this(false) + public GodotObject() : this(false) { unsafe { @@ -49,17 +49,17 @@ namespace Godot _weakReferenceToSelf = DisposablesTracker.RegisterGodotObject(this); } - internal Object(bool memoryOwn) + internal GodotObject(bool memoryOwn) { _memoryOwn = memoryOwn; } /// - /// The pointer to the native instance of this . + /// The pointer to the native instance of this . /// public IntPtr NativeInstance => NativePtr; - internal static IntPtr GetPtr(Object instance) + internal static IntPtr GetPtr(GodotObject instance) { if (instance == null) return IntPtr.Zero; @@ -75,13 +75,13 @@ namespace Godot return instance.NativePtr; } - ~Object() + ~GodotObject() { Dispose(false); } /// - /// Disposes of this . + /// Disposes of this . /// public void Dispose() { @@ -90,7 +90,7 @@ namespace Godot } /// - /// Disposes implementation of this . + /// Disposes implementation of this . /// protected virtual void Dispose(bool disposing) { @@ -129,7 +129,7 @@ namespace Godot } /// - /// Converts this to a string. + /// Converts this to a string. /// /// A string representation of this object. public override string ToString() @@ -166,7 +166,7 @@ namespace Godot /// A that completes when /// emits the . /// - public SignalAwaiter ToSignal(Object source, StringName signal) + public SignalAwaiter ToSignal(GodotObject source, StringName signal) { return new SignalAwaiter(source, signal, this); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.exceptions.cs similarity index 99% rename from modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs rename to modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.exceptions.cs index 0fcc4ee01bb..a7640043cef 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.exceptions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.exceptions.cs @@ -5,7 +5,7 @@ using System.Text; namespace Godot { - public partial class Object + public partial class GodotObject { public class NativeMemberNotFoundException : Exception { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropUtils.cs index 82f1c04d403..cc308bfdb3b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropUtils.cs @@ -8,7 +8,7 @@ namespace Godot.NativeInterop { internal static class InteropUtils { - public static Object UnmanagedGetManaged(IntPtr unmanaged) + public static GodotObject UnmanagedGetManaged(IntPtr unmanaged) { // The native pointer may be null if (unmanaged == IntPtr.Zero) @@ -23,7 +23,7 @@ namespace Godot.NativeInterop unmanaged, out hasCsScriptInstance); if (gcHandlePtr != IntPtr.Zero) - return (Object)GCHandle.FromIntPtr(gcHandlePtr).Target; + return (GodotObject)GCHandle.FromIntPtr(gcHandlePtr).Target; // Otherwise, if the object has a CSharpInstance script instance, return null @@ -37,17 +37,17 @@ namespace Godot.NativeInterop object target = gcHandlePtr != IntPtr.Zero ? GCHandle.FromIntPtr(gcHandlePtr).Target : null; if (target != null) - return (Object)target; + return (GodotObject)target; // If the native instance binding GC handle target was collected, create a new one gcHandlePtr = NativeFuncs.godotsharp_internal_unmanaged_instance_binding_create_managed( unmanaged, gcHandlePtr); - return gcHandlePtr != IntPtr.Zero ? (Object)GCHandle.FromIntPtr(gcHandlePtr).Target : null; + return gcHandlePtr != IntPtr.Zero ? (GodotObject)GCHandle.FromIntPtr(gcHandlePtr).Target : null; } - public static void TieManagedToUnmanaged(Object managed, IntPtr unmanaged, + public static void TieManagedToUnmanaged(GodotObject managed, IntPtr unmanaged, StringName nativeName, bool refCounted, Type type, Type nativeType) { var gcHandle = refCounted ? @@ -76,7 +76,7 @@ namespace Godot.NativeInterop } } - public static void TieManagedToUnmanagedWithPreSetup(Object managed, IntPtr unmanaged, + public static void TieManagedToUnmanagedWithPreSetup(GodotObject managed, IntPtr unmanaged, Type type, Type nativeType) { if (type == nativeType) @@ -87,7 +87,7 @@ namespace Godot.NativeInterop GCHandle.ToIntPtr(strongGCHandle), unmanaged); } - public static Object EngineGetSingleton(string name) + public static GodotObject EngineGetSingleton(string name) { using godot_string src = Marshaling.ConvertStringToNative(name); return UnmanagedGetManaged(NativeFuncs.godotsharp_engine_get_singleton(src)); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs index f79ad2c0ed2..93a83b701b7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs @@ -143,12 +143,12 @@ namespace Godot.NativeInterop if (type == typeof(Rid[])) return Variant.Type.Array; - if (typeof(Godot.Object[]).IsAssignableFrom(type)) + if (typeof(GodotObject[]).IsAssignableFrom(type)) return Variant.Type.Array; } else if (type.IsGenericType) { - if (typeof(Godot.Object).IsAssignableFrom(type)) + if (typeof(GodotObject).IsAssignableFrom(type)) return Variant.Type.Object; // We use `IsAssignableFrom` with our helper interfaces to detect generic Godot collections @@ -167,7 +167,7 @@ namespace Godot.NativeInterop } else { - if (typeof(Godot.Object).IsAssignableFrom(type)) + if (typeof(GodotObject).IsAssignableFrom(type)) return Variant.Type.Object; if (typeof(StringName) == type) @@ -232,7 +232,7 @@ namespace Godot.NativeInterop var gcHandle = CustomGCHandle.AllocStrong(p_managed_callable.Delegate); IntPtr objectPtr = p_managed_callable.Target != null ? - Object.GetPtr(p_managed_callable.Target) : + GodotObject.GetPtr(p_managed_callable.Target) : IntPtr.Zero; unsafe @@ -310,7 +310,7 @@ namespace Godot.NativeInterop public static Signal ConvertSignalToManaged(in godot_signal p_signal) { - var owner = Godot.Object.InstanceFromId(p_signal.ObjectId); + var owner = GodotObject.InstanceFromId(p_signal.ObjectId); var name = StringName.CreateTakingOwnershipOfDisposableValue( NativeFuncs.godotsharp_string_name_new_copy(p_signal.Name)); return new Signal(owner, name); @@ -319,7 +319,7 @@ namespace Godot.NativeInterop // Array internal static T[] ConvertNativeGodotArrayToSystemArrayOfGodotObjectType(in godot_array p_array) - where T : Godot.Object + where T : GodotObject { var array = Collections.Array.CreateTakingOwnershipOfDisposableValue( NativeFuncs.godotsharp_array_new_copy(p_array)); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs index ff083929d4c..e6bcd9393da 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs @@ -241,7 +241,7 @@ namespace Godot.NativeInterop => CreateFromArray(new Collections.Array(from)); // ReSharper disable once RedundantNameQualifier - public static godot_variant CreateFromSystemArrayOfGodotObject(Godot.Object[]? from) + public static godot_variant CreateFromSystemArrayOfGodotObject(GodotObject[]? from) { if (from == null) return default; // Nil @@ -307,8 +307,8 @@ namespace Godot.NativeInterop [MethodImpl(MethodImplOptions.AggressiveInlining)] // ReSharper disable once RedundantNameQualifier - public static godot_variant CreateFromGodotObject(Godot.Object? from) - => from != null ? CreateFromGodotObjectPtr(Object.GetPtr(from)) : default; + public static godot_variant CreateFromGodotObject(GodotObject? from) + => from != null ? CreateFromGodotObjectPtr(GodotObject.GetPtr(from)) : default; // We avoid the internal call if the stored type is the same we want. @@ -460,7 +460,7 @@ namespace Godot.NativeInterop [MethodImpl(MethodImplOptions.AggressiveInlining)] // ReSharper disable once RedundantNameQualifier - public static Godot.Object ConvertToGodotObject(in godot_variant p_var) + public static GodotObject ConvertToGodotObject(in godot_variant p_var) => InteropUtils.UnmanagedGetManaged(ConvertToGodotObjectPtr(p_var)); public static string ConvertToString(in godot_variant p_var) @@ -616,7 +616,7 @@ namespace Godot.NativeInterop public static T[] ConvertToSystemArrayOfGodotObject(in godot_variant p_var) // ReSharper disable once RedundantNameQualifier - where T : Godot.Object + where T : GodotObject { using var godotArray = NativeFuncs.godotsharp_variant_as_array(p_var); return Marshaling.ConvertNativeGodotArrayToSystemArrayOfGodotObjectType(godotArray); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs index bfa5bc7f412..12b0a470798 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs @@ -192,8 +192,8 @@ public partial class VariantUtils // `typeof(X).IsAssignableFrom(typeof(T))` is optimized away - if (typeof(Godot.Object).IsAssignableFrom(typeof(T))) - return CreateFromGodotObject(UnsafeAs(from)); + if (typeof(GodotObject).IsAssignableFrom(typeof(T))) + return CreateFromGodotObject(UnsafeAs(from)); // `typeof(T).IsValueType` is optimized away // `typeof(T).IsEnum` is NOT optimized away: https://github.com/dotnet/runtime/issues/67113 @@ -381,7 +381,7 @@ public partial class VariantUtils // `typeof(X).IsAssignableFrom(typeof(T))` is optimized away - if (typeof(Godot.Object).IsAssignableFrom(typeof(T))) + if (typeof(GodotObject).IsAssignableFrom(typeof(T))) return (T)(object)ConvertToGodotObject(variant); // `typeof(T).IsValueType` is optimized away diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rid.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rid.cs index e727526ec33..150eb98fc7d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rid.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rid.cs @@ -24,7 +24,7 @@ namespace Godot /// /// Constructs a new for the given . /// - public Rid(Godot.Object from) + public Rid(GodotObject from) => _id = from is Resource res ? res.GetRid()._id : default; /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Signal.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Signal.cs index f9b8f06603a..9ac8abd37b1 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Signal.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Signal.cs @@ -5,13 +5,14 @@ namespace Godot /// public readonly struct Signal : IAwaitable { - private readonly Object _owner; + private readonly GodotObject _owner; private readonly StringName _signalName; /// /// Object that contains the signal. /// - public Object Owner => _owner; + public GodotObject Owner => _owner; + /// /// Name of the signal. /// @@ -23,7 +24,7 @@ namespace Godot /// /// Object that contains the signal. /// Name of the signal. - public Signal(Object owner, StringName name) + public Signal(GodotObject owner, StringName name) { _owner = owner; _signalName = name; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/SignalAwaiter.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/SignalAwaiter.cs index 96fb8910866..a67f626d354 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/SignalAwaiter.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/SignalAwaiter.cs @@ -10,13 +10,13 @@ namespace Godot private Variant[] _result; private Action _continuation; - public SignalAwaiter(Object source, StringName signal, Object target) + public SignalAwaiter(GodotObject source, StringName signal, GodotObject target) { var awaiterGcHandle = CustomGCHandle.AllocStrong(this); using godot_string_name signalSrc = NativeFuncs.godotsharp_string_name_new_copy( (godot_string_name)(signal?.NativeValue ?? default)); - NativeFuncs.godotsharp_internal_signal_awaiter_connect(Object.GetPtr(source), in signalSrc, - Object.GetPtr(target), GCHandle.ToIntPtr(awaiterGcHandle)); + NativeFuncs.godotsharp_internal_signal_awaiter_connect(GodotObject.GetPtr(source), in signalSrc, + GodotObject.GetPtr(target), GCHandle.ToIntPtr(awaiterGcHandle)); } public bool IsCompleted => _completed; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs index 63a9ba27472..9aad965ad0e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs @@ -324,7 +324,7 @@ public partial struct Variant : IDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] public T[] AsGodotObjectArray() - where T : Godot.Object => + where T : GodotObject => VariantUtils.ConvertToSystemArrayOfGodotObject((godot_variant)NativeVar); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -348,7 +348,7 @@ public partial struct Variant : IDisposable VariantUtils.ConvertToSystemArrayOfRid((godot_variant)NativeVar); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Godot.Object AsGodotObject() => + public GodotObject AsGodotObject() => VariantUtils.ConvertToGodotObject((godot_variant)NativeVar); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -503,7 +503,7 @@ public partial struct Variant : IDisposable public static explicit operator Rid[](Variant from) => from.AsSystemArrayOfRid(); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Godot.Object(Variant from) => from.AsGodotObject(); + public static explicit operator GodotObject(Variant from) => from.AsGodotObject(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator StringName(Variant from) => from.AsStringName(); @@ -644,7 +644,7 @@ public partial struct Variant : IDisposable public static Variant CreateFrom(Span from) => from; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Variant CreateFrom(Godot.Object[] from) => from; + public static Variant CreateFrom(GodotObject[] from) => from; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Variant CreateFrom<[MustBeVariant] TKey, [MustBeVariant] TValue>(Collections.Dictionary from) => @@ -664,7 +664,7 @@ public partial struct Variant : IDisposable public static Variant CreateFrom(Span from) => from; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Variant CreateFrom(Godot.Object from) => from; + public static Variant CreateFrom(GodotObject from) => from; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Variant CreateFrom(StringName from) => from; @@ -844,7 +844,7 @@ public partial struct Variant : IDisposable (Variant)from.AsSpan(); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Variant(Godot.Object[] from) => + public static implicit operator Variant(GodotObject[] from) => CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfGodotObject(from)); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -908,7 +908,7 @@ public partial struct Variant : IDisposable CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfRid(from)); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Variant(Godot.Object from) => + public static implicit operator Variant(GodotObject from) => CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromGodotObject(from)); [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj index 465d6f1a5e8..7aa2f7e9593 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -81,11 +81,13 @@ + - + + @@ -105,8 +107,6 @@ - - diff --git a/modules/mono/utils/naming_utils.cpp b/modules/mono/utils/naming_utils.cpp index b96abb7eb4a..dc9bc3485a4 100644 --- a/modules/mono/utils/naming_utils.cpp +++ b/modules/mono/utils/naming_utils.cpp @@ -45,6 +45,7 @@ HashMap _create_hashmap_from_vector(Vector> const HashMap pascal_case_name_overrides = _create_hashmap_from_vector({ { "BitMap", "Bitmap" }, { "JSONRPC", "JsonRpc" }, + { "Object", "GodotObject" }, { "OpenXRIPBinding", "OpenXRIPBinding" }, { "SkeletonModification2DCCDIK", "SkeletonModification2DCcdik" }, { "SkeletonModification2DFABRIK", "SkeletonModification2DFabrik" },