C#: Rename Object to GodotObject
This commit is contained in:
parent
a968e51414
commit
1aceacaa6b
38 changed files with 147 additions and 145 deletions
|
|
@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
partial class Foo : Godot.Object
|
||||
partial class Foo : GodotObject
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
partial class Generic<T> : Godot.Object
|
||||
partial class Generic<T> : GodotObject
|
||||
{
|
||||
private int _field;
|
||||
}
|
||||
|
||||
// Generic again but different generic parameters
|
||||
partial class Generic<T, R> : Godot.Object
|
||||
partial class Generic<T, R> : GodotObject
|
||||
{
|
||||
private int _field;
|
||||
}
|
||||
|
||||
// Generic again but without generic parameters
|
||||
partial class Generic : Godot.Object
|
||||
partial class Generic : GodotObject
|
||||
{
|
||||
private int _field;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<Int64>();
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Godot.SourceGenerators
|
|||
throw new InvalidOperationException($"Type not found: '{fullyQualifiedMetadataName}'.");
|
||||
}
|
||||
|
||||
GodotObjectType = GetTypeByMetadataNameOrThrow("Godot.Object");
|
||||
GodotObjectType = GetTypeByMetadataNameOrThrow(GodotClasses.GodotObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue