C#: Rename Object to GodotObject

This commit is contained in:
Raul Santos 2022-12-07 16:16:51 +01:00
parent a968e51414
commit 1aceacaa6b
No known key found for this signature in database
GPG Key ID: B532473AE3A803E4
38 changed files with 147 additions and 145 deletions

View File

@ -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)) { 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)) { if (p_var_type_name == Variant::get_type_name(Variant::INT)) {

View File

@ -1,6 +1,6 @@
namespace Godot.SourceGenerators.Sample 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
{ {
} }
} }

View File

@ -1,6 +1,6 @@
namespace Godot.SourceGenerators.Sample; namespace Godot.SourceGenerators.Sample;
public partial class EventSignals : Godot.Object public partial class EventSignals : GodotObject
{ {
[Signal] [Signal]
public delegate void MySignalEventHandler(string str, int num); public delegate void MySignalEventHandler(string str, int num);

View File

@ -11,7 +11,7 @@ namespace Godot.SourceGenerators.Sample
[SuppressMessage("ReSharper", "RedundantNameQualifier")] [SuppressMessage("ReSharper", "RedundantNameQualifier")]
[SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")] [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")]
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public partial class ExportedFields : Godot.Object public partial class ExportedFields : GodotObject
{ {
[Export] private Boolean field_Boolean = true; [Export] private Boolean field_Boolean = true;
[Export] private Char field_Char = 'f'; [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 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 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 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 StringName[] field_StringNameArray = { "foo", "bar" };
[Export] private NodePath[] field_NodePathArray = { "foo", "bar" }; [Export] private NodePath[] field_NodePathArray = { "foo", "bar" };
[Export] private Rid[] field_RidArray = { default, default, default }; [Export] private Rid[] field_RidArray = { default, default, default };
@ -93,7 +93,7 @@ namespace Godot.SourceGenerators.Sample
[Export] private Variant field_Variant = "foo"; [Export] private Variant field_Variant = "foo";
// Classes // Classes
[Export] private Godot.Object field_GodotObjectOrDerived; [Export] private GodotObject field_GodotObjectOrDerived;
[Export] private Godot.Texture field_GodotResourceTexture; [Export] private Godot.Texture field_GodotResourceTexture;
[Export] private StringName field_StringName = new StringName("foo"); [Export] private StringName field_StringName = new StringName("foo");
[Export] private NodePath field_NodePath = new NodePath("foo"); [Export] private NodePath field_NodePath = new NodePath("foo");

View File

@ -10,7 +10,7 @@ namespace Godot.SourceGenerators.Sample
[SuppressMessage("ReSharper", "RedundantNameQualifier")] [SuppressMessage("ReSharper", "RedundantNameQualifier")]
[SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")] [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")]
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public partial class ExportedProperties : Godot.Object public partial class ExportedProperties : GodotObject
{ {
// Do not generate default value // Do not generate default value
private String _notGenerate_Property_String = new string("not generate"); 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 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 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 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 StringName[] field_StringNameArray { get; set; } = { "foo", "bar" };
[Export] private NodePath[] field_NodePathArray { get; set; } = { "foo", "bar" }; [Export] private NodePath[] field_NodePathArray { get; set; } = { "foo", "bar" };
[Export] private Rid[] field_RidArray { get; set; } = { default, default, default }; [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"; [Export] private Variant property_Variant { get; set; } = "foo";
// Classes // 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 Godot.Texture property_GodotResourceTexture { get; set; }
[Export] private StringName property_StringName { get; set; } = new StringName("foo"); [Export] private StringName property_StringName { get; set; } = new StringName("foo");
[Export] private NodePath property_NodePath { get; set; } = new NodePath("foo"); [Export] private NodePath property_NodePath { get; set; } = new NodePath("foo");

View File

@ -1,6 +1,6 @@
namespace Godot.SourceGenerators.Sample namespace Godot.SourceGenerators.Sample
{ {
partial class Foo : Godot.Object partial class Foo : GodotObject
{ {
} }

View File

@ -2,19 +2,19 @@
namespace Godot.SourceGenerators.Sample namespace Godot.SourceGenerators.Sample
{ {
partial class Generic<T> : Godot.Object partial class Generic<T> : GodotObject
{ {
private int _field; private int _field;
} }
// Generic again but different generic parameters // Generic again but different generic parameters
partial class Generic<T, R> : Godot.Object partial class Generic<T, R> : GodotObject
{ {
private int _field; private int _field;
} }
// Generic again but without generic parameters // Generic again but without generic parameters
partial class Generic : Godot.Object partial class Generic : GodotObject
{ {
private int _field; private int _field;
} }

View File

@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
namespace Godot.SourceGenerators.Sample; namespace Godot.SourceGenerators.Sample;
[SuppressMessage("ReSharper", "RedundantNameQualifier")] [SuppressMessage("ReSharper", "RedundantNameQualifier")]
public partial class Methods : Godot.Object public partial class Methods : GodotObject
{ {
private void MethodWithOverload() private void MethodWithOverload()
{ {

View File

@ -11,7 +11,7 @@ namespace Godot.SourceGenerators.Sample
[SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")] [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")]
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
// We split the definition of ExportedFields to verify properties work across multiple files. // 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. // Note we use Array and not System.Array. This tests the generated namespace qualification.
[Export] private Int64[] field_empty_Int64Array = Array.Empty<Int64>(); [Export] private Int64[] field_empty_Int64Array = Array.Empty<Int64>();

View File

@ -14,9 +14,9 @@ namespace Godot.SourceGenerators
{ {
string message = string message =
"Missing partial modifier on declaration of type '" + "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."; "must be declared with the partial modifier.";
context.ReportDiagnostic(Diagnostic.Create( context.ReportDiagnostic(Diagnostic.Create(
@ -46,9 +46,9 @@ namespace Godot.SourceGenerators
string message = string message =
$"Missing partial modifier on declaration of type '{fullQualifiedName}', " + $"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."; "containing types must be declared with the partial modifier.";
context.ReportDiagnostic(Diagnostic.Create( context.ReportDiagnostic(Diagnostic.Create(

View File

@ -85,7 +85,7 @@ namespace Godot.SourceGenerators
var classTypeSymbol = sm.GetDeclaredSymbol(cds); var classTypeSymbol = sm.GetDeclaredSymbol(cds);
if (classTypeSymbol?.BaseType == null if (classTypeSymbol?.BaseType == null
|| !classTypeSymbol.BaseType.InheritsFrom("GodotSharp", GodotClasses.Object)) || !classTypeSymbol.BaseType.InheritsFrom("GodotSharp", GodotClasses.GodotObject))
{ {
symbol = null; symbol = null;
return false; return false;

View File

@ -2,7 +2,7 @@ namespace Godot.SourceGenerators
{ {
public static class GodotClasses 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 AssemblyHasScriptsAttr = "Godot.AssemblyHasScriptsAttribute";
public const string ExportAttr = "Godot.ExportAttribute"; public const string ExportAttr = "Godot.ExportAttribute";
public const string ExportCategoryAttr = "Godot.ExportCategoryAttribute"; public const string ExportCategoryAttr = "Godot.ExportCategoryAttribute";

View File

@ -34,7 +34,7 @@ namespace GodotPlugins.Game
{ {
DllImportResolver dllImportResolver = new GodotDllImportResolver(godotDllHandle).OnResolveDllImport; DllImportResolver dllImportResolver = new GodotDllImportResolver(godotDllHandle).OnResolveDllImport;
var coreApiAssembly = typeof(Godot.Object).Assembly; var coreApiAssembly = typeof(global::Godot.GodotObject).Assembly;
NativeLibrary.SetDllImportResolver(coreApiAssembly, dllImportResolver); NativeLibrary.SetDllImportResolver(coreApiAssembly, dllImportResolver);
@ -42,7 +42,7 @@ namespace GodotPlugins.Game
ManagedCallbacks.Create(outManagedCallbacks); ManagedCallbacks.Create(outManagedCallbacks);
ScriptManagerBridge.LookupScriptsInAssembly(typeof(GodotPlugins.Game.Main).Assembly); ScriptManagerBridge.LookupScriptsInAssembly(typeof(global::GodotPlugins.Game.Main).Assembly);
return godot_bool.True; return godot_bool.True;
} }

View File

@ -19,7 +19,7 @@ namespace Godot.SourceGenerators
throw new InvalidOperationException($"Type not found: '{fullyQualifiedMetadataName}'."); throw new InvalidOperationException($"Type not found: '{fullyQualifiedMetadataName}'.");
} }
GodotObjectType = GetTypeByMetadataNameOrThrow("Godot.Object"); GodotObjectType = GetTypeByMetadataNameOrThrow(GodotClasses.GodotObject);
} }
} }

View File

@ -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) { } else if (!p_target_itype || !p_target_itype->is_object_type) {
if (OS::get_singleton()->is_stdout_verbose()) { if (OS::get_singleton()->is_stdout_verbose()) {
if (p_target_itype) { 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 { } else {
OS::get_singleton()->print("Cannot resolve type from method reference in documentation: %s\n", p_link_target.utf8().get_data()); 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) { } else if (!p_target_itype || !p_target_itype->is_object_type) {
if (OS::get_singleton()->is_stdout_verbose()) { if (OS::get_singleton()->is_stdout_verbose()) {
if (p_target_itype) { 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 { } else {
OS::get_singleton()->print("Cannot resolve type from member reference in documentation: %s\n", p_link_target.utf8().get_data()); 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 (!p_target_itype || !p_target_itype->is_object_type) {
if (OS::get_singleton()->is_stdout_verbose()) { if (OS::get_singleton()->is_stdout_verbose()) {
if (p_target_itype) { 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 { } else {
OS::get_singleton()->print("Cannot resolve type from signal reference in documentation: %s\n", p_link_target.utf8().get_data()); 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 (OS::get_singleton()->is_stdout_verbose()) {
if (p_target_itype) { 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 { } else {
OS::get_singleton()->print("Cannot resolve type from constant reference in documentation: %s\n", p_link_target.utf8().get_data()); 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(); bool is_derived_type = itype.base_name != StringName();
if (!is_derived_type) { if (!is_derived_type) {
// Some Godot.Object assertions // Some GodotObject assertions
CRASH_COND(itype.cname != name_cache.type_Object); CRASH_COND(itype.cname != name_cache.type_Object);
CRASH_COND(!itype.is_instantiable); CRASH_COND(!itype.is_instantiable);
CRASH_COND(itype.api_type != ClassDB::API_CORE); 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) { if (itype.is_singleton) {
// Add the type name and the singleton pointer as static fields // 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" << INDENT2 "get\n" INDENT2 "{\n" INDENT3 "if (singleton == null)\n"
<< INDENT4 "singleton = " C_METHOD_ENGINE_GET_SINGLETON "(typeof(" << INDENT4 "singleton = " C_METHOD_ENGINE_GET_SINGLETON "(typeof("
<< itype.proxy_name << itype.proxy_name
@ -1491,8 +1491,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.append(itype.name); output.append(itype.name);
output.append("\";\n"); output.append("\";\n");
} else { } else {
// IMPORTANT: We also generate the static fields for Godot.Object instead of declaring // IMPORTANT: We also generate the static fields for GodotObject instead of declaring
// them manually in the `Object.base.cs` partial class declaration, because they're // them manually in the `GodotObject.base.cs` partial class declaration, because they're
// required by other static fields in this generated partial class declaration. // 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 // 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). // 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 << " = "; << INDENT1 "private static readonly IntPtr " << method_bind_field << " = ";
if (p_itype.is_singleton) { 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. // 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." 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; itype.cs_type = itype.proxy_name;
if (itype.is_singleton) { 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 { } 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);"; 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_arg_in = "(void*)%s";
itype.c_type = "IntPtr"; itype.c_type = "IntPtr";
itype.c_type_in = itype.c_type; itype.c_type_in = itype.c_type;
itype.c_type_out = "Object"; itype.c_type_out = "GodotObject";
// Populate properties // Populate properties

View File

@ -7,7 +7,7 @@ using System;
[Tool] [Tool]
public partial class _CLASS_ : _BASE_ 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. // Modify the contents of the scene upon import.
return scene; // Return the modified root node when you're done. return scene; // Return the modified root node when you're done.

View File

@ -7,7 +7,7 @@ using System;
[Tool] [Tool]
public partial class _CLASS_ : _BASE_ public partial class _CLASS_ : _BASE_
{ {
public override Godot.Object _PostImport(Node scene) public override GodotObject _PostImport(Node scene)
{ {
return scene; return scene;
} }

View File

@ -65,7 +65,7 @@ namespace GodotPlugins
} }
private static readonly List<AssemblyName> SharedAssemblies = new(); private static readonly List<AssemblyName> 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 Assembly? _editorApiAssembly;
private static PluginLoadContextWrapper? _projectLoadContext; private static PluginLoadContextWrapper? _projectLoadContext;
private static bool _editorHint = false; private static bool _editorHint = false;

View File

@ -120,7 +120,7 @@ namespace Godot.Collections
// fine as long as the array is not mutated. However, Span does this type checking at // 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. // instantiation, so it's not possible to use it even when not mutating anything.
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
public Array(ReadOnlySpan<Godot.Object> array) : this() public Array(ReadOnlySpan<GodotObject> array) : this()
{ {
if (array == null) if (array == null)
throw new ArgumentNullException(nameof(array)); throw new ArgumentNullException(nameof(array));

View File

@ -12,7 +12,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (godotObject == null) if (godotObject == null)
{ {
@ -49,7 +49,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (godotObject == null) if (godotObject == null)
throw new InvalidOperationException(); throw new InvalidOperationException();
@ -79,7 +79,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (godotObject == null) if (godotObject == null)
throw new InvalidOperationException(); throw new InvalidOperationException();
@ -134,7 +134,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (okIfNull.ToBool()) if (okIfNull.ToBool())
godotObject?.Dispose(); godotObject?.Dispose();
@ -152,7 +152,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var self = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var self = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (self == null) if (self == null)
{ {
@ -186,7 +186,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (godotObject == null) if (godotObject == null)
return godot_bool.False; return godot_bool.False;
@ -209,7 +209,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (godotObject == null) if (godotObject == null)
return; return;
@ -242,7 +242,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; var godotObject = (GodotObject)GCHandle.FromIntPtr(godotObjectGCHandle).Target;
if (godotObject == null) if (godotObject == null)
return; return;

View File

@ -100,7 +100,7 @@ namespace Godot.Bridge
Type nativeType = TypeGetProxyClass(nativeTypeNameStr) ?? throw new InvalidOperationException( Type nativeType = TypeGetProxyClass(nativeTypeNameStr) ?? throw new InvalidOperationException(
"Wrapper class not found for type: " + nativeTypeNameStr); "Wrapper class not found for type: " + nativeTypeNameStr);
var obj = (Object)FormatterServices.GetUninitializedObject(nativeType); var obj = (GodotObject)FormatterServices.GetUninitializedObject(nativeType);
var ctor = nativeType.GetConstructor( var ctor = nativeType.GetConstructor(
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, 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(); var parameters = ctor.GetParameters();
int paramCount = parameters.Length; int paramCount = parameters.Length;
@ -189,7 +189,7 @@ namespace Godot.Bridge
return; return;
} }
var native = Object.InternalGetClassNativeBase(scriptType); var native = GodotObject.InternalGetClassNativeBase(scriptType);
var field = native?.GetField("NativeName", BindingFlags.DeclaredOnly | BindingFlags.Static | var field = native?.GetField("NativeName", BindingFlags.DeclaredOnly | BindingFlags.Static |
BindingFlags.Public | BindingFlags.NonPublic); BindingFlags.Public | BindingFlags.NonPublic);
@ -222,7 +222,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var target = (Object?)GCHandle.FromIntPtr(gcHandlePtr).Target; var target = (GodotObject?)GCHandle.FromIntPtr(gcHandlePtr).Target;
if (target != null) if (target != null)
target.NativePtr = newPtr; target.NativePtr = newPtr;
} }
@ -239,7 +239,7 @@ namespace Godot.Bridge
if (nativeTypeNameStr[0] == '_') if (nativeTypeNameStr[0] == '_')
nativeTypeNameStr = nativeTypeNameStr.Substring(1); nativeTypeNameStr = nativeTypeNameStr.Substring(1);
Type? wrapperType = typeof(Object).Assembly.GetType("Godot." + nativeTypeNameStr); Type? wrapperType = typeof(GodotObject).Assembly.GetType("Godot." + nativeTypeNameStr);
if (wrapperType == null) if (wrapperType == null)
{ {
@ -252,8 +252,8 @@ namespace Godot.Bridge
if (wrapperType != null && IsStatic(wrapperType)) if (wrapperType != null && IsStatic(wrapperType))
{ {
// A static class means this is a Godot singleton class. If an instance is needed we use Godot.Object. // A static class means this is a Godot singleton class. If an instance is needed we use GodotObject.
return typeof(Object); return typeof(GodotObject);
} }
return wrapperType; return wrapperType;
@ -293,7 +293,7 @@ namespace Godot.Bridge
// such as when disabling C# source generators (for whatever reason) or when using a // 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. // 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()) foreach (var type in assembly.GetTypes())
{ {
@ -331,7 +331,7 @@ namespace Godot.Bridge
{ {
try try
{ {
var owner = (Object?)GCHandle.FromIntPtr(ownerGCHandlePtr).Target; var owner = (GodotObject?)GCHandle.FromIntPtr(ownerGCHandlePtr).Target;
if (owner == null) if (owner == null)
{ {
@ -539,9 +539,9 @@ namespace Godot.Bridge
} }
// ReSharper disable once RedundantNameQualifier // 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; return godot_bool.False;
} }
@ -589,7 +589,7 @@ namespace Godot.Bridge
using var methods = new Collections.Array(); using var methods = new Collections.Array();
Type? top = scriptType; Type? top = scriptType;
Type native = Object.InternalGetClassNativeBase(top); Type native = GodotObject.InternalGetClassNativeBase(top);
while (top != null && top != native) while (top != null && top != native)
{ {
@ -899,7 +899,7 @@ namespace Godot.Bridge
try try
{ {
Type? top = _scriptTypeBiMap.GetScriptType(scriptPtr); Type? top = _scriptTypeBiMap.GetScriptType(scriptPtr);
Type native = Object.InternalGetClassNativeBase(top); Type native = GodotObject.InternalGetClassNativeBase(top);
while (top != null && top != native) while (top != null && top != native)
{ {

View File

@ -28,7 +28,7 @@ namespace Godot
/// </example> /// </example>
public readonly partial struct Callable public readonly partial struct Callable
{ {
private readonly Object _target; private readonly GodotObject _target;
private readonly StringName _method; private readonly StringName _method;
private readonly Delegate _delegate; private readonly Delegate _delegate;
private readonly unsafe delegate* managed<object, NativeVariantPtrArgs, out godot_variant, void> _trampoline; private readonly unsafe delegate* managed<object, NativeVariantPtrArgs, out godot_variant, void> _trampoline;
@ -36,7 +36,7 @@ namespace Godot
/// <summary> /// <summary>
/// Object that contains the method. /// Object that contains the method.
/// </summary> /// </summary>
public Object Target => _target; public GodotObject Target => _target;
/// <summary> /// <summary>
/// Name of the method that will be called. /// Name of the method that will be called.
@ -60,7 +60,7 @@ namespace Godot
/// </summary> /// </summary>
/// <param name="target">Object that contains the method.</param> /// <param name="target">Object that contains the method.</param>
/// <param name="method">Name of the method that will be called.</param> /// <param name="method">Name of the method that will be called.</param>
public unsafe Callable(Object target, StringName method) public unsafe Callable(GodotObject target, StringName method)
{ {
_target = target; _target = target;
_method = method; _method = method;
@ -71,7 +71,7 @@ namespace Godot
private unsafe Callable(Delegate @delegate, private unsafe Callable(Delegate @delegate,
delegate* managed<object, NativeVariantPtrArgs, out godot_variant, void> trampoline) delegate* managed<object, NativeVariantPtrArgs, out godot_variant, void> trampoline)
{ {
_target = @delegate?.Target as Object; _target = @delegate?.Target as GodotObject;
_method = null; _method = null;
_delegate = @delegate; _delegate = @delegate;
_trampoline = trampoline; _trampoline = trampoline;

View File

@ -126,7 +126,7 @@ namespace Godot
} }
} }
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
case Godot.Object godotObject: case GodotObject godotObject:
{ {
using (var stream = new MemoryStream()) using (var stream = new MemoryStream())
using (var writer = new BinaryWriter(stream)) using (var writer = new BinaryWriter(stream))
@ -399,7 +399,7 @@ namespace Godot
{ {
ulong objectId = reader.ReadUInt64(); ulong objectId = reader.ReadUInt64();
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
Godot.Object godotObject = Godot.Object.InstanceFromId(objectId); GodotObject godotObject = GodotObject.InstanceFromId(objectId);
if (godotObject == null) if (godotObject == null)
return false; return false;
@ -641,7 +641,7 @@ namespace Godot
return VariantUtils.CreateFrom(nodePathArray); return VariantUtils.CreateFrom(nodePathArray);
case Rid[] ridArray: case Rid[] ridArray:
return VariantUtils.CreateFrom(ridArray); return VariantUtils.CreateFrom(ridArray);
case Godot.Object[] godotObjectArray: case GodotObject[] godotObjectArray:
return VariantUtils.CreateFrom(godotObjectArray); return VariantUtils.CreateFrom(godotObjectArray);
case StringName stringName: case StringName stringName:
return VariantUtils.CreateFrom(stringName); return VariantUtils.CreateFrom(stringName);
@ -655,7 +655,7 @@ namespace Godot
return VariantUtils.CreateFrom(godotArray); return VariantUtils.CreateFrom(godotArray);
case Variant variant: case Variant variant:
return VariantUtils.CreateFrom(variant); return VariantUtils.CreateFrom(variant);
case Godot.Object godotObject: case GodotObject godotObject:
return VariantUtils.CreateFrom(godotObject); return VariantUtils.CreateFrom(godotObject);
case Enum @enum: case Enum @enum:
return VariantUtils.CreateFrom(Convert.ToInt64(@enum)); return VariantUtils.CreateFrom(Convert.ToInt64(@enum));
@ -736,18 +736,18 @@ namespace Godot
if (ToSystemObjectFuncByType.TryGetValue(type, out var func)) if (ToSystemObjectFuncByType.TryGetValue(type, out var func))
return func(variant); return func(variant);
if (typeof(Godot.Object).IsAssignableFrom(type)) if (typeof(GodotObject).IsAssignableFrom(type))
return Convert.ChangeType(VariantUtils.ConvertTo<Godot.Object>(variant), type); return Convert.ChangeType(VariantUtils.ConvertTo<GodotObject>(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( var array = Collections.Array.CreateTakingOwnershipOfDisposableValue(
NativeFuncs.godotsharp_array_new_copy(nativeArray)); NativeFuncs.godotsharp_array_new_copy(nativeArray));
int length = array.Count; 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++) for (int i = 0; i < length; i++)
ret[i] = array[i].AsGodotObject(); ret[i] = array[i].AsGodotObject();

View File

@ -74,7 +74,7 @@ namespace Godot.Collections
/// the original dictionary. If <see langword="false"/>, a shallow copy is made and /// the original dictionary. If <see langword="false"/>, a shallow copy is made and
/// references to the original nested arrays and dictionaries are kept, so that /// 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 /// modifying a sub-array or dictionary in the copy will also impact those
/// referenced in the source dictionary. Note that any <see cref="Object"/> derived /// referenced in the source dictionary. Note that any <see cref="GodotObject"/> derived
/// elements will be shallow copied regardless of the <paramref name="deep"/> /// elements will be shallow copied regardless of the <paramref name="deep"/>
/// setting. /// setting.
/// </summary> /// </summary>
@ -494,7 +494,7 @@ namespace Godot.Collections
/// the original dictionary. If <see langword="false"/>, a shallow copy is made and /// the original dictionary. If <see langword="false"/>, a shallow copy is made and
/// references to the original nested arrays and dictionaries are kept, so that /// 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 /// modifying a sub-array or dictionary in the copy will also impact those
/// referenced in the source dictionary. Note that any <see cref="Object"/> derived /// referenced in the source dictionary. Note that any <see cref="GodotObject"/> derived
/// elements will be shallow copied regardless of the <paramref name="deep"/> /// elements will be shallow copied regardless of the <paramref name="deep"/>
/// setting. /// setting.
/// </summary> /// </summary>

View File

@ -43,9 +43,9 @@ namespace Godot
// like StringName, NodePath, Godot.Collections.Array/Dictionary, etc. // like StringName, NodePath, Godot.Collections.Array/Dictionary, etc.
// The Godot Object Dispose() method may need any of the later instances. // The Godot Object Dispose() method may need any of the later instances.
foreach (WeakReference<Object> item in GodotObjectInstances.Keys) foreach (WeakReference<GodotObject> item in GodotObjectInstances.Keys)
{ {
if (item.TryGetTarget(out Object? self)) if (item.TryGetTarget(out GodotObject? self))
self.Dispose(); self.Dispose();
} }
@ -60,15 +60,15 @@ namespace Godot
} }
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
private static ConcurrentDictionary<WeakReference<Godot.Object>, byte> GodotObjectInstances { get; } = private static ConcurrentDictionary<WeakReference<GodotObject>, byte> GodotObjectInstances { get; } =
new(); new();
private static ConcurrentDictionary<WeakReference<IDisposable>, byte> OtherInstances { get; } = private static ConcurrentDictionary<WeakReference<IDisposable>, byte> OtherInstances { get; } =
new(); new();
public static WeakReference<Object> RegisterGodotObject(Object godotObject) public static WeakReference<GodotObject> RegisterGodotObject(GodotObject godotObject)
{ {
var weakReferenceToSelf = new WeakReference<Object>(godotObject); var weakReferenceToSelf = new WeakReference<GodotObject>(godotObject);
GodotObjectInstances.TryAdd(weakReferenceToSelf, 0); GodotObjectInstances.TryAdd(weakReferenceToSelf, 0);
return weakReferenceToSelf; return weakReferenceToSelf;
} }
@ -80,7 +80,7 @@ namespace Godot
return weakReferenceToSelf; return weakReferenceToSelf;
} }
public static void UnregisterGodotObject(Object godotObject, WeakReference<Object> weakReferenceToSelf) public static void UnregisterGodotObject(GodotObject godotObject, WeakReference<GodotObject> weakReferenceToSelf)
{ {
if (!GodotObjectInstances.TryRemove(weakReferenceToSelf, out _)) if (!GodotObjectInstances.TryRemove(weakReferenceToSelf, out _))
throw new ArgumentException("Godot Object not registered.", nameof(weakReferenceToSelf)); throw new ArgumentException("Godot Object not registered.", nameof(weakReferenceToSelf));

View File

@ -3,10 +3,10 @@ using Godot.NativeInterop;
namespace Godot namespace Godot
{ {
public partial class Object public partial class GodotObject
{ {
/// <summary> /// <summary>
/// Returns the <see cref="Object"/> that corresponds to <paramref name="instanceId"/>. /// Returns the <see cref="GodotObject"/> that corresponds to <paramref name="instanceId"/>.
/// All Objects have a unique instance ID. See also <see cref="GetInstanceId"/>. /// All Objects have a unique instance ID. See also <see cref="GetInstanceId"/>.
/// </summary> /// </summary>
/// <example> /// <example>
@ -25,14 +25,14 @@ namespace Godot
/// </code> /// </code>
/// </example> /// </example>
/// <param name="instanceId">Instance ID of the Object to retrieve.</param> /// <param name="instanceId">Instance ID of the Object to retrieve.</param>
/// <returns>The <see cref="Object"/> instance.</returns> /// <returns>The <see cref="GodotObject"/> instance.</returns>
public static Object InstanceFromId(ulong instanceId) public static GodotObject InstanceFromId(ulong instanceId)
{ {
return InteropUtils.UnmanagedGetManaged(NativeFuncs.godotsharp_instance_from_id(instanceId)); return InteropUtils.UnmanagedGetManaged(NativeFuncs.godotsharp_instance_from_id(instanceId));
} }
/// <summary> /// <summary>
/// Returns <see langword="true"/> if the <see cref="Object"/> that corresponds /// Returns <see langword="true"/> if the <see cref="GodotObject"/> that corresponds
/// to <paramref name="id"/> is a valid object (e.g. has not been deleted from /// to <paramref name="id"/> is a valid object (e.g. has not been deleted from
/// memory). All Objects have a unique instance ID. /// memory). All Objects have a unique instance ID.
/// </summary> /// </summary>
@ -45,11 +45,11 @@ namespace Godot
/// <summary> /// <summary>
/// Returns <see langword="true"/> if <paramref name="instance"/> is a /// Returns <see langword="true"/> if <paramref name="instance"/> is a
/// valid <see cref="Object"/> (e.g. has not been deleted from memory). /// valid <see cref="GodotObject"/> (e.g. has not been deleted from memory).
/// </summary> /// </summary>
/// <param name="instance">The instance to check.</param> /// <param name="instance">The instance to check.</param>
/// <returns>If the instance is a valid object.</returns> /// <returns>If the instance is a valid object.</returns>
public static bool IsInstanceValid(Object instance) public static bool IsInstanceValid(GodotObject instance)
{ {
return instance != null && instance.NativeInstance != IntPtr.Zero; return instance != null && instance.NativeInstance != IntPtr.Zero;
} }
@ -68,7 +68,7 @@ namespace Godot
/// <returns> /// <returns>
/// The <see cref="WeakRef"/> reference to the object or <see langword="null"/>. /// The <see cref="WeakRef"/> reference to the object or <see langword="null"/>.
/// </returns> /// </returns>
public static WeakRef WeakRef(Object obj) public static WeakRef WeakRef(GodotObject obj)
{ {
if (!IsInstanceValid(obj)) if (!IsInstanceValid(obj))
return null; return null;

View File

@ -5,20 +5,20 @@ using Godot.NativeInterop;
namespace Godot namespace Godot
{ {
public partial class Object : IDisposable public partial class GodotObject : IDisposable
{ {
private bool _disposed = false; private bool _disposed = false;
private static readonly Type CachedType = typeof(Object); private static readonly Type CachedType = typeof(GodotObject);
internal IntPtr NativePtr; internal IntPtr NativePtr;
private bool _memoryOwn; private bool _memoryOwn;
private WeakReference<Object> _weakReferenceToSelf; private WeakReference<GodotObject> _weakReferenceToSelf;
/// <summary> /// <summary>
/// Constructs a new <see cref="Object"/>. /// Constructs a new <see cref="GodotObject"/>.
/// </summary> /// </summary>
public Object() : this(false) public GodotObject() : this(false)
{ {
unsafe unsafe
{ {
@ -49,17 +49,17 @@ namespace Godot
_weakReferenceToSelf = DisposablesTracker.RegisterGodotObject(this); _weakReferenceToSelf = DisposablesTracker.RegisterGodotObject(this);
} }
internal Object(bool memoryOwn) internal GodotObject(bool memoryOwn)
{ {
_memoryOwn = memoryOwn; _memoryOwn = memoryOwn;
} }
/// <summary> /// <summary>
/// The pointer to the native instance of this <see cref="Object"/>. /// The pointer to the native instance of this <see cref="GodotObject"/>.
/// </summary> /// </summary>
public IntPtr NativeInstance => NativePtr; public IntPtr NativeInstance => NativePtr;
internal static IntPtr GetPtr(Object instance) internal static IntPtr GetPtr(GodotObject instance)
{ {
if (instance == null) if (instance == null)
return IntPtr.Zero; return IntPtr.Zero;
@ -75,13 +75,13 @@ namespace Godot
return instance.NativePtr; return instance.NativePtr;
} }
~Object() ~GodotObject()
{ {
Dispose(false); Dispose(false);
} }
/// <summary> /// <summary>
/// Disposes of this <see cref="Object"/>. /// Disposes of this <see cref="GodotObject"/>.
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
@ -90,7 +90,7 @@ namespace Godot
} }
/// <summary> /// <summary>
/// Disposes implementation of this <see cref="Object"/>. /// Disposes implementation of this <see cref="GodotObject"/>.
/// </summary> /// </summary>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
@ -129,7 +129,7 @@ namespace Godot
} }
/// <summary> /// <summary>
/// Converts this <see cref="Object"/> to a string. /// Converts this <see cref="GodotObject"/> to a string.
/// </summary> /// </summary>
/// <returns>A string representation of this object.</returns> /// <returns>A string representation of this object.</returns>
public override string ToString() public override string ToString()
@ -166,7 +166,7 @@ namespace Godot
/// A <see cref="SignalAwaiter"/> that completes when /// A <see cref="SignalAwaiter"/> that completes when
/// <paramref name="source"/> emits the <paramref name="signal"/>. /// <paramref name="source"/> emits the <paramref name="signal"/>.
/// </returns> /// </returns>
public SignalAwaiter ToSignal(Object source, StringName signal) public SignalAwaiter ToSignal(GodotObject source, StringName signal)
{ {
return new SignalAwaiter(source, signal, this); return new SignalAwaiter(source, signal, this);
} }

View File

@ -5,7 +5,7 @@ using System.Text;
namespace Godot namespace Godot
{ {
public partial class Object public partial class GodotObject
{ {
public class NativeMemberNotFoundException : Exception public class NativeMemberNotFoundException : Exception
{ {

View File

@ -8,7 +8,7 @@ namespace Godot.NativeInterop
{ {
internal static class InteropUtils internal static class InteropUtils
{ {
public static Object UnmanagedGetManaged(IntPtr unmanaged) public static GodotObject UnmanagedGetManaged(IntPtr unmanaged)
{ {
// The native pointer may be null // The native pointer may be null
if (unmanaged == IntPtr.Zero) if (unmanaged == IntPtr.Zero)
@ -23,7 +23,7 @@ namespace Godot.NativeInterop
unmanaged, out hasCsScriptInstance); unmanaged, out hasCsScriptInstance);
if (gcHandlePtr != IntPtr.Zero) 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 // 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; object target = gcHandlePtr != IntPtr.Zero ? GCHandle.FromIntPtr(gcHandlePtr).Target : null;
if (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 // If the native instance binding GC handle target was collected, create a new one
gcHandlePtr = NativeFuncs.godotsharp_internal_unmanaged_instance_binding_create_managed( gcHandlePtr = NativeFuncs.godotsharp_internal_unmanaged_instance_binding_create_managed(
unmanaged, gcHandlePtr); 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) StringName nativeName, bool refCounted, Type type, Type nativeType)
{ {
var gcHandle = refCounted ? 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) Type type, Type nativeType)
{ {
if (type == nativeType) if (type == nativeType)
@ -87,7 +87,7 @@ namespace Godot.NativeInterop
GCHandle.ToIntPtr(strongGCHandle), unmanaged); GCHandle.ToIntPtr(strongGCHandle), unmanaged);
} }
public static Object EngineGetSingleton(string name) public static GodotObject EngineGetSingleton(string name)
{ {
using godot_string src = Marshaling.ConvertStringToNative(name); using godot_string src = Marshaling.ConvertStringToNative(name);
return UnmanagedGetManaged(NativeFuncs.godotsharp_engine_get_singleton(src)); return UnmanagedGetManaged(NativeFuncs.godotsharp_engine_get_singleton(src));

View File

@ -143,12 +143,12 @@ namespace Godot.NativeInterop
if (type == typeof(Rid[])) if (type == typeof(Rid[]))
return Variant.Type.Array; return Variant.Type.Array;
if (typeof(Godot.Object[]).IsAssignableFrom(type)) if (typeof(GodotObject[]).IsAssignableFrom(type))
return Variant.Type.Array; return Variant.Type.Array;
} }
else if (type.IsGenericType) else if (type.IsGenericType)
{ {
if (typeof(Godot.Object).IsAssignableFrom(type)) if (typeof(GodotObject).IsAssignableFrom(type))
return Variant.Type.Object; return Variant.Type.Object;
// We use `IsAssignableFrom` with our helper interfaces to detect generic Godot collections // We use `IsAssignableFrom` with our helper interfaces to detect generic Godot collections
@ -167,7 +167,7 @@ namespace Godot.NativeInterop
} }
else else
{ {
if (typeof(Godot.Object).IsAssignableFrom(type)) if (typeof(GodotObject).IsAssignableFrom(type))
return Variant.Type.Object; return Variant.Type.Object;
if (typeof(StringName) == type) if (typeof(StringName) == type)
@ -232,7 +232,7 @@ namespace Godot.NativeInterop
var gcHandle = CustomGCHandle.AllocStrong(p_managed_callable.Delegate); var gcHandle = CustomGCHandle.AllocStrong(p_managed_callable.Delegate);
IntPtr objectPtr = p_managed_callable.Target != null ? IntPtr objectPtr = p_managed_callable.Target != null ?
Object.GetPtr(p_managed_callable.Target) : GodotObject.GetPtr(p_managed_callable.Target) :
IntPtr.Zero; IntPtr.Zero;
unsafe unsafe
@ -310,7 +310,7 @@ namespace Godot.NativeInterop
public static Signal ConvertSignalToManaged(in godot_signal p_signal) 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( var name = StringName.CreateTakingOwnershipOfDisposableValue(
NativeFuncs.godotsharp_string_name_new_copy(p_signal.Name)); NativeFuncs.godotsharp_string_name_new_copy(p_signal.Name));
return new Signal(owner, name); return new Signal(owner, name);
@ -319,7 +319,7 @@ namespace Godot.NativeInterop
// Array // Array
internal static T[] ConvertNativeGodotArrayToSystemArrayOfGodotObjectType<T>(in godot_array p_array) internal static T[] ConvertNativeGodotArrayToSystemArrayOfGodotObjectType<T>(in godot_array p_array)
where T : Godot.Object where T : GodotObject
{ {
var array = Collections.Array.CreateTakingOwnershipOfDisposableValue( var array = Collections.Array.CreateTakingOwnershipOfDisposableValue(
NativeFuncs.godotsharp_array_new_copy(p_array)); NativeFuncs.godotsharp_array_new_copy(p_array));

View File

@ -241,7 +241,7 @@ namespace Godot.NativeInterop
=> CreateFromArray(new Collections.Array(from)); => CreateFromArray(new Collections.Array(from));
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
public static godot_variant CreateFromSystemArrayOfGodotObject(Godot.Object[]? from) public static godot_variant CreateFromSystemArrayOfGodotObject(GodotObject[]? from)
{ {
if (from == null) if (from == null)
return default; // Nil return default; // Nil
@ -307,8 +307,8 @@ namespace Godot.NativeInterop
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
public static godot_variant CreateFromGodotObject(Godot.Object? from) public static godot_variant CreateFromGodotObject(GodotObject? from)
=> from != null ? CreateFromGodotObjectPtr(Object.GetPtr(from)) : default; => from != null ? CreateFromGodotObjectPtr(GodotObject.GetPtr(from)) : default;
// We avoid the internal call if the stored type is the same we want. // We avoid the internal call if the stored type is the same we want.
@ -460,7 +460,7 @@ namespace Godot.NativeInterop
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
// ReSharper disable once RedundantNameQualifier // 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)); => InteropUtils.UnmanagedGetManaged(ConvertToGodotObjectPtr(p_var));
public static string ConvertToString(in godot_variant p_var) public static string ConvertToString(in godot_variant p_var)
@ -616,7 +616,7 @@ namespace Godot.NativeInterop
public static T[] ConvertToSystemArrayOfGodotObject<T>(in godot_variant p_var) public static T[] ConvertToSystemArrayOfGodotObject<T>(in godot_variant p_var)
// ReSharper disable once RedundantNameQualifier // ReSharper disable once RedundantNameQualifier
where T : Godot.Object where T : GodotObject
{ {
using var godotArray = NativeFuncs.godotsharp_variant_as_array(p_var); using var godotArray = NativeFuncs.godotsharp_variant_as_array(p_var);
return Marshaling.ConvertNativeGodotArrayToSystemArrayOfGodotObjectType<T>(godotArray); return Marshaling.ConvertNativeGodotArrayToSystemArrayOfGodotObjectType<T>(godotArray);

View File

@ -192,8 +192,8 @@ public partial class VariantUtils
// `typeof(X).IsAssignableFrom(typeof(T))` is optimized away // `typeof(X).IsAssignableFrom(typeof(T))` is optimized away
if (typeof(Godot.Object).IsAssignableFrom(typeof(T))) if (typeof(GodotObject).IsAssignableFrom(typeof(T)))
return CreateFromGodotObject(UnsafeAs<Godot.Object>(from)); return CreateFromGodotObject(UnsafeAs<GodotObject>(from));
// `typeof(T).IsValueType` is optimized away // `typeof(T).IsValueType` is optimized away
// `typeof(T).IsEnum` is NOT optimized away: https://github.com/dotnet/runtime/issues/67113 // `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 // `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); return (T)(object)ConvertToGodotObject(variant);
// `typeof(T).IsValueType` is optimized away // `typeof(T).IsValueType` is optimized away

View File

@ -24,7 +24,7 @@ namespace Godot
/// <summary> /// <summary>
/// Constructs a new <see cref="Rid"/> for the given <see cref="GodotObject"/> <paramref name="from"/>. /// Constructs a new <see cref="Rid"/> for the given <see cref="GodotObject"/> <paramref name="from"/>.
/// </summary> /// </summary>
public Rid(Godot.Object from) public Rid(GodotObject from)
=> _id = from is Resource res ? res.GetRid()._id : default; => _id = from is Resource res ? res.GetRid()._id : default;
/// <summary> /// <summary>

View File

@ -5,13 +5,14 @@ namespace Godot
/// </summary> /// </summary>
public readonly struct Signal : IAwaitable<Variant[]> public readonly struct Signal : IAwaitable<Variant[]>
{ {
private readonly Object _owner; private readonly GodotObject _owner;
private readonly StringName _signalName; private readonly StringName _signalName;
/// <summary> /// <summary>
/// Object that contains the signal. /// Object that contains the signal.
/// </summary> /// </summary>
public Object Owner => _owner; public GodotObject Owner => _owner;
/// <summary> /// <summary>
/// Name of the signal. /// Name of the signal.
/// </summary> /// </summary>
@ -23,7 +24,7 @@ namespace Godot
/// </summary> /// </summary>
/// <param name="owner">Object that contains the signal.</param> /// <param name="owner">Object that contains the signal.</param>
/// <param name="name">Name of the signal.</param> /// <param name="name">Name of the signal.</param>
public Signal(Object owner, StringName name) public Signal(GodotObject owner, StringName name)
{ {
_owner = owner; _owner = owner;
_signalName = name; _signalName = name;

View File

@ -10,13 +10,13 @@ namespace Godot
private Variant[] _result; private Variant[] _result;
private Action _continuation; private Action _continuation;
public SignalAwaiter(Object source, StringName signal, Object target) public SignalAwaiter(GodotObject source, StringName signal, GodotObject target)
{ {
var awaiterGcHandle = CustomGCHandle.AllocStrong(this); var awaiterGcHandle = CustomGCHandle.AllocStrong(this);
using godot_string_name signalSrc = NativeFuncs.godotsharp_string_name_new_copy( using godot_string_name signalSrc = NativeFuncs.godotsharp_string_name_new_copy(
(godot_string_name)(signal?.NativeValue ?? default)); (godot_string_name)(signal?.NativeValue ?? default));
NativeFuncs.godotsharp_internal_signal_awaiter_connect(Object.GetPtr(source), in signalSrc, NativeFuncs.godotsharp_internal_signal_awaiter_connect(GodotObject.GetPtr(source), in signalSrc,
Object.GetPtr(target), GCHandle.ToIntPtr(awaiterGcHandle)); GodotObject.GetPtr(target), GCHandle.ToIntPtr(awaiterGcHandle));
} }
public bool IsCompleted => _completed; public bool IsCompleted => _completed;

View File

@ -324,7 +324,7 @@ public partial struct Variant : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public T[] AsGodotObjectArray<T>() public T[] AsGodotObjectArray<T>()
where T : Godot.Object => where T : GodotObject =>
VariantUtils.ConvertToSystemArrayOfGodotObject<T>((godot_variant)NativeVar); VariantUtils.ConvertToSystemArrayOfGodotObject<T>((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -348,7 +348,7 @@ public partial struct Variant : IDisposable
VariantUtils.ConvertToSystemArrayOfRid((godot_variant)NativeVar); VariantUtils.ConvertToSystemArrayOfRid((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Godot.Object AsGodotObject() => public GodotObject AsGodotObject() =>
VariantUtils.ConvertToGodotObject((godot_variant)NativeVar); VariantUtils.ConvertToGodotObject((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -503,7 +503,7 @@ public partial struct Variant : IDisposable
public static explicit operator Rid[](Variant from) => from.AsSystemArrayOfRid(); public static explicit operator Rid[](Variant from) => from.AsSystemArrayOfRid();
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static explicit operator StringName(Variant from) => from.AsStringName(); public static explicit operator StringName(Variant from) => from.AsStringName();
@ -644,7 +644,7 @@ public partial struct Variant : IDisposable
public static Variant CreateFrom(Span<Color> from) => from; public static Variant CreateFrom(Span<Color> from) => from;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Variant CreateFrom(Godot.Object[] from) => from; public static Variant CreateFrom(GodotObject[] from) => from;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Variant CreateFrom<[MustBeVariant] TKey, [MustBeVariant] TValue>(Collections.Dictionary<TKey, TValue> from) => public static Variant CreateFrom<[MustBeVariant] TKey, [MustBeVariant] TValue>(Collections.Dictionary<TKey, TValue> from) =>
@ -664,7 +664,7 @@ public partial struct Variant : IDisposable
public static Variant CreateFrom(Span<Rid> from) => from; public static Variant CreateFrom(Span<Rid> from) => from;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Variant CreateFrom(Godot.Object from) => from; public static Variant CreateFrom(GodotObject from) => from;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Variant CreateFrom(StringName from) => from; public static Variant CreateFrom(StringName from) => from;
@ -844,7 +844,7 @@ public partial struct Variant : IDisposable
(Variant)from.AsSpan(); (Variant)from.AsSpan();
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Variant(Godot.Object[] from) => public static implicit operator Variant(GodotObject[] from) =>
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfGodotObject(from)); CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfGodotObject(from));
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -908,7 +908,7 @@ public partial struct Variant : IDisposable
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfRid(from)); CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfRid(from));
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Variant(Godot.Object from) => public static implicit operator Variant(GodotObject from) =>
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromGodotObject(from)); CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromGodotObject(from));
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@ -81,11 +81,13 @@
<Compile Include="Core\DelegateUtils.cs" /> <Compile Include="Core\DelegateUtils.cs" />
<Compile Include="Core\Dictionary.cs" /> <Compile Include="Core\Dictionary.cs" />
<Compile Include="Core\Dispatcher.cs" /> <Compile Include="Core\Dispatcher.cs" />
<Compile Include="Core\Extensions\GodotObjectExtensions.cs" />
<Compile Include="Core\Extensions\NodeExtensions.cs" /> <Compile Include="Core\Extensions\NodeExtensions.cs" />
<Compile Include="Core\Extensions\ObjectExtensions.cs" />
<Compile Include="Core\Extensions\PackedSceneExtensions.cs" /> <Compile Include="Core\Extensions\PackedSceneExtensions.cs" />
<Compile Include="Core\Extensions\ResourceLoaderExtensions.cs" /> <Compile Include="Core\Extensions\ResourceLoaderExtensions.cs" />
<Compile Include="Core\GD.cs" /> <Compile Include="Core\GD.cs" />
<Compile Include="Core\GodotObject.base.cs" />
<Compile Include="Core\GodotObject.exceptions.cs" />
<Compile Include="Core\GodotSynchronizationContext.cs" /> <Compile Include="Core\GodotSynchronizationContext.cs" />
<Compile Include="Core\GodotTaskScheduler.cs" /> <Compile Include="Core\GodotTaskScheduler.cs" />
<Compile Include="Core\GodotTraceListener.cs" /> <Compile Include="Core\GodotTraceListener.cs" />
@ -105,8 +107,6 @@
<Compile Include="Core\NativeInterop\VariantUtils.cs" /> <Compile Include="Core\NativeInterop\VariantUtils.cs" />
<Compile Include="Core\NativeInterop\VariantUtils.generic.cs" /> <Compile Include="Core\NativeInterop\VariantUtils.generic.cs" />
<Compile Include="Core\NodePath.cs" /> <Compile Include="Core\NodePath.cs" />
<Compile Include="Core\Object.base.cs" />
<Compile Include="Core\Object.exceptions.cs" />
<Compile Include="Core\Plane.cs" /> <Compile Include="Core\Plane.cs" />
<Compile Include="Core\Projection.cs" /> <Compile Include="Core\Projection.cs" />
<Compile Include="Core\Quaternion.cs" /> <Compile Include="Core\Quaternion.cs" />

View File

@ -45,6 +45,7 @@ HashMap<String, String> _create_hashmap_from_vector(Vector<Pair<String, String>>
const HashMap<String, String> pascal_case_name_overrides = _create_hashmap_from_vector({ const HashMap<String, String> pascal_case_name_overrides = _create_hashmap_from_vector({
{ "BitMap", "Bitmap" }, { "BitMap", "Bitmap" },
{ "JSONRPC", "JsonRpc" }, { "JSONRPC", "JsonRpc" },
{ "Object", "GodotObject" },
{ "OpenXRIPBinding", "OpenXRIPBinding" }, { "OpenXRIPBinding", "OpenXRIPBinding" },
{ "SkeletonModification2DCCDIK", "SkeletonModification2DCcdik" }, { "SkeletonModification2DCCDIK", "SkeletonModification2DCcdik" },
{ "SkeletonModification2DFABRIK", "SkeletonModification2DFabrik" }, { "SkeletonModification2DFABRIK", "SkeletonModification2DFabrik" },