diff options
author | Raul Santos <raulsntos@gmail.com> | 2022-12-07 16:11:39 +0100 |
---|---|---|
committer | Raul Santos <raulsntos@gmail.com> | 2023-01-27 02:04:17 +0100 |
commit | a968e514148f3b9be8c1bdff38fffe6972976df2 (patch) | |
tree | 5143496843474cd65ebf49e01c3d9ee6921ce1ba /modules/mono/editor | |
parent | 4788cb35c12d5e094fe1dd633066e27fd4be7734 (diff) |
C#: Renames to follow .NET naming conventions
Renamed C# types and members to use PascalCase and follow .NET naming conventions.
Diffstat (limited to 'modules/mono/editor')
18 files changed, 175 insertions, 200 deletions
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 ccaba4d727..813b810eea 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 @@ -29,19 +29,19 @@ namespace Godot.SourceGenerators.Sample // Godot structs [Export] private Vector2 field_Vector2 = new(10f, 10f); - [Export] private Vector2i field_Vector2i = Vector2i.Up; + [Export] private Vector2I field_Vector2I = Vector2I.Up; [Export] private Rect2 field_Rect2 = new(new Vector2(10f, 10f), new Vector2(10f, 10f)); - [Export] private Rect2i field_Rect2i = new(new Vector2i(10, 10), new Vector2i(10, 10)); + [Export] private Rect2I field_Rect2I = new(new Vector2I(10, 10), new Vector2I(10, 10)); [Export] private Transform2D field_Transform2D = Transform2D.Identity; [Export] private Vector3 field_Vector3 = new(10f, 10f, 10f); - [Export] private Vector3i field_Vector3i = Vector3i.Back; + [Export] private Vector3I field_Vector3I = Vector3I.Back; [Export] private Basis field_Basis = new Basis(Quaternion.Identity); [Export] private Quaternion field_Quaternion = new Quaternion(Basis.Identity); [Export] private Transform3D field_Transform3D = Transform3D.Identity; [Export] private Vector4 field_Vector4 = new(10f, 10f, 10f, 10f); - [Export] private Vector4i field_Vector4i = Vector4i.One; + [Export] private Vector4I field_Vector4I = Vector4I.One; [Export] private Projection field_Projection = Projection.Identity; - [Export] private AABB field_AABB = new AABB(10f, 10f, 10f, new Vector3(1f, 1f, 1f)); + [Export] private Aabb field_Aabb = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f)); [Export] private Color field_Color = Colors.Aquamarine; [Export] private Plane field_Plane = Plane.PlaneXZ; [Export] private Callable field_Callable = new Callable(Engine.GetMainLoop(), "_process"); @@ -83,7 +83,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Godot.Object[] 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 }; + [Export] private Rid[] field_RidArray = { default, default, default }; // Note we use Array and not System.Array. This tests the generated namespace qualification. [Export] private Int32[] field_empty_Int32Array = Array.Empty<Int32>(); // Note we use List and not System.Collections.Generic. @@ -97,7 +97,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Godot.Texture field_GodotResourceTexture; [Export] private StringName field_StringName = new StringName("foo"); [Export] private NodePath field_NodePath = new NodePath("foo"); - [Export] private RID field_RID; + [Export] private Rid field_Rid; [Export] private Godot.Collections.Dictionary field_GodotDictionary = 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 5afaeb736f..cd8559d16c 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 @@ -117,19 +117,19 @@ namespace Godot.SourceGenerators.Sample // Godot structs [Export] private Vector2 property_Vector2 { get; set; } = new(10f, 10f); - [Export] private Vector2i property_Vector2i { get; set; } = Vector2i.Up; + [Export] private Vector2I property_Vector2I { get; set; } = Vector2I.Up; [Export] private Rect2 property_Rect2 { get; set; } = new(new Vector2(10f, 10f), new Vector2(10f, 10f)); - [Export] private Rect2i property_Rect2i { get; set; } = new(new Vector2i(10, 10), new Vector2i(10, 10)); + [Export] private Rect2I property_Rect2I { get; set; } = new(new Vector2I(10, 10), new Vector2I(10, 10)); [Export] private Transform2D property_Transform2D { get; set; } = Transform2D.Identity; [Export] private Vector3 property_Vector3 { get; set; } = new(10f, 10f, 10f); - [Export] private Vector3i property_Vector3i { get; set; } = Vector3i.Back; + [Export] private Vector3I property_Vector3I { get; set; } = Vector3I.Back; [Export] private Basis property_Basis { get; set; } = new Basis(Quaternion.Identity); [Export] private Quaternion property_Quaternion { get; set; } = new Quaternion(Basis.Identity); [Export] private Transform3D property_Transform3D { get; set; } = Transform3D.Identity; [Export] private Vector4 property_Vector4 { get; set; } = new(10f, 10f, 10f, 10f); - [Export] private Vector4i property_Vector4i { get; set; } = Vector4i.One; + [Export] private Vector4I property_Vector4I { get; set; } = Vector4I.One; [Export] private Projection property_Projection { get; set; } = Projection.Identity; - [Export] private AABB property_AABB { get; set; } = new AABB(10f, 10f, 10f, new Vector3(1f, 1f, 1f)); + [Export] private Aabb property_Aabb { get; set; } = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f)); [Export] private Color property_Color { get; set; } = Colors.Aquamarine; [Export] private Plane property_Plane { get; set; } = Plane.PlaneXZ; [Export] private Callable property_Callable { get; set; } = new Callable(Engine.GetMainLoop(), "_process"); @@ -171,7 +171,7 @@ namespace Godot.SourceGenerators.Sample [Export] private Godot.Object[] 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 }; + [Export] private Rid[] field_RidArray { get; set; } = { default, default, default }; // Variant [Export] private Variant property_Variant { get; set; } = "foo"; @@ -181,7 +181,7 @@ namespace Godot.SourceGenerators.Sample [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"); - [Export] private RID property_RID { get; set; } + [Export] private Rid property_Rid { get; set; } [Export] private Godot.Collections.Dictionary property_GodotDictionary { get; set; } = 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 1d8ddbabf2..a0ed1bf1d9 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs @@ -10,7 +10,7 @@ namespace Godot.SourceGenerators public const string ExportSubgroupAttr = "Godot.ExportSubgroupAttribute"; public const string SignalAttr = "Godot.SignalAttribute"; public const string MustBeVariantAttr = "Godot.MustBeVariantAttribute"; - public const string GodotClassNameAttr = "Godot.GodotClassName"; + public const string GodotClassNameAttr = "Godot.GodotClassNameAttribute"; public const string SystemFlagsAttr = "System.FlagsAttribute"; } } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs index 22a21a1754..b30c8c240e 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs @@ -12,19 +12,19 @@ namespace Godot.SourceGenerators Float = 3, String = 4, Vector2 = 5, - Vector2i = 6, + Vector2I = 6, Rect2 = 7, - Rect2i = 8, + Rect2I = 8, Vector3 = 9, - Vector3i = 10, - Transform2d = 11, + Vector3I = 10, + Transform2D = 11, Vector4 = 12, - Vector4i = 13, + Vector4I = 13, Plane = 14, Quaternion = 15, Aabb = 16, Basis = 17, - Transform3d = 18, + Transform3D = 18, Projection = 19, Color = 20, StringName = 21, @@ -56,12 +56,12 @@ namespace Godot.SourceGenerators ExpEasing = 4, Link = 5, Flags = 6, - Layers2dRender = 7, - Layers2dPhysics = 8, - Layers2dNavigation = 9, - Layers3dRender = 10, - Layers3dPhysics = 11, - Layers3dNavigation = 12, + Layers2DRender = 7, + Layers2DPhysics = 8, + Layers2DNavigation = 9, + Layers3DRender = 10, + Layers3DPhysics = 11, + Layers3DNavigation = 12, File = 13, Dir = 14, GlobalFile = 15, diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs index ee1374d0b9..be6af117eb 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs @@ -21,19 +21,19 @@ namespace Godot.SourceGenerators // Godot structs Vector2, - Vector2i, + Vector2I, Rect2, - Rect2i, + Rect2I, Transform2D, Vector3, - Vector3i, + Vector3I, Basis, Quaternion, Transform3D, Vector4, - Vector4i, + Vector4I, Projection, - AABB, + Aabb, Color, Plane, Callable, @@ -55,7 +55,7 @@ namespace Godot.SourceGenerators GodotObjectOrDerivedArray, SystemArrayOfStringName, SystemArrayOfNodePath, - SystemArrayOfRID, + SystemArrayOfRid, // Variant Variant, @@ -64,7 +64,7 @@ namespace Godot.SourceGenerators GodotObjectOrDerived, StringName, NodePath, - RID, + Rid, GodotDictionary, GodotArray, GodotGenericDictionary, 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 f0a6a72281..70fb7d7b2d 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs @@ -40,19 +40,19 @@ namespace Godot.SourceGenerators MarshalType.Double => VariantType.Float, MarshalType.String => VariantType.String, MarshalType.Vector2 => VariantType.Vector2, - MarshalType.Vector2i => VariantType.Vector2i, + MarshalType.Vector2I => VariantType.Vector2I, MarshalType.Rect2 => VariantType.Rect2, - MarshalType.Rect2i => VariantType.Rect2i, - MarshalType.Transform2D => VariantType.Transform2d, + MarshalType.Rect2I => VariantType.Rect2I, + MarshalType.Transform2D => VariantType.Transform2D, MarshalType.Vector3 => VariantType.Vector3, - MarshalType.Vector3i => VariantType.Vector3i, + MarshalType.Vector3I => VariantType.Vector3I, MarshalType.Basis => VariantType.Basis, MarshalType.Quaternion => VariantType.Quaternion, - MarshalType.Transform3D => VariantType.Transform3d, + MarshalType.Transform3D => VariantType.Transform3D, MarshalType.Vector4 => VariantType.Vector4, - MarshalType.Vector4i => VariantType.Vector4i, + MarshalType.Vector4I => VariantType.Vector4I, MarshalType.Projection => VariantType.Projection, - MarshalType.AABB => VariantType.Aabb, + MarshalType.Aabb => VariantType.Aabb, MarshalType.Color => VariantType.Color, MarshalType.Plane => VariantType.Plane, MarshalType.Callable => VariantType.Callable, @@ -70,12 +70,12 @@ namespace Godot.SourceGenerators MarshalType.GodotObjectOrDerivedArray => VariantType.Array, MarshalType.SystemArrayOfStringName => VariantType.Array, MarshalType.SystemArrayOfNodePath => VariantType.Array, - MarshalType.SystemArrayOfRID => VariantType.Array, + MarshalType.SystemArrayOfRid => VariantType.Array, MarshalType.Variant => VariantType.Nil, MarshalType.GodotObjectOrDerived => VariantType.Object, MarshalType.StringName => VariantType.StringName, MarshalType.NodePath => VariantType.NodePath, - MarshalType.RID => VariantType.Rid, + MarshalType.Rid => VariantType.Rid, MarshalType.GodotDictionary => VariantType.Dictionary, MarshalType.GodotArray => VariantType.Array, MarshalType.GodotGenericDictionary => VariantType.Dictionary, @@ -130,22 +130,22 @@ namespace Godot.SourceGenerators return type switch { { Name: "Vector2" } => MarshalType.Vector2, - { Name: "Vector2i" } => MarshalType.Vector2i, + { Name: "Vector2I" } => MarshalType.Vector2I, { Name: "Rect2" } => MarshalType.Rect2, - { Name: "Rect2i" } => MarshalType.Rect2i, + { Name: "Rect2I" } => MarshalType.Rect2I, { Name: "Transform2D" } => MarshalType.Transform2D, { Name: "Vector3" } => MarshalType.Vector3, - { Name: "Vector3i" } => MarshalType.Vector3i, + { Name: "Vector3I" } => MarshalType.Vector3I, { Name: "Basis" } => MarshalType.Basis, { Name: "Quaternion" } => MarshalType.Quaternion, { Name: "Transform3D" } => MarshalType.Transform3D, { Name: "Vector4" } => MarshalType.Vector4, - { Name: "Vector4i" } => MarshalType.Vector4i, + { Name: "Vector4I" } => MarshalType.Vector4I, { Name: "Projection" } => MarshalType.Projection, - { Name: "AABB" } => MarshalType.AABB, + { Name: "Aabb" } => MarshalType.Aabb, { Name: "Color" } => MarshalType.Color, { Name: "Plane" } => MarshalType.Plane, - { Name: "RID" } => MarshalType.RID, + { Name: "Rid" } => MarshalType.Rid, { Name: "Callable" } => MarshalType.Callable, { Name: "Signal" } => MarshalType.Signal, { Name: "Variant" } => MarshalType.Variant, @@ -196,8 +196,8 @@ namespace Godot.SourceGenerators return MarshalType.SystemArrayOfStringName; case { Name: "NodePath" }: return MarshalType.SystemArrayOfNodePath; - case { Name: "RID" }: - return MarshalType.SystemArrayOfRID; + case { Name: "Rid" }: + return MarshalType.SystemArrayOfRid; } } diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs index edbf53a389..a4d5e1a569 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs @@ -23,7 +23,7 @@ namespace GodotTools.Build public Godot.Collections.Array CustomProperties { get; private set; } = new(); public string LogsDirPath => - Path.Combine(GodotSharpDirs.BuildLogsDirs, $"{Solution.MD5Text()}_{Configuration}"); + Path.Combine(GodotSharpDirs.BuildLogsDirs, $"{Solution.Md5Text()}_{Configuration}"); public override bool Equals(object? obj) { diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs index 993c6d9217..349f9d0cb8 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs @@ -55,7 +55,7 @@ namespace GodotTools.Build private static void PrintVerbose(string text) { - if (OS.IsStdoutVerbose()) + if (OS.IsStdOutVerbose()) GD.Print(text); } diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs index e439822666..c083b9cc60 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs @@ -336,7 +336,7 @@ namespace GodotTools.Build _ = index; // Unused _issuesListContextMenu.Clear(); - _issuesListContextMenu.Size = new Vector2i(1, 1); + _issuesListContextMenu.Size = new Vector2I(1, 1); if (_issuesList.IsAnythingSelected()) { @@ -347,7 +347,7 @@ namespace GodotTools.Build if (_issuesListContextMenu.ItemCount > 0) { - _issuesListContextMenu.Position = (Vector2i)(_issuesList.GlobalPosition + atPosition); + _issuesListContextMenu.Position = (Vector2I)(_issuesList.GlobalPosition + atPosition); _issuesListContextMenu.Popup(); } } diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs index d0cd529d1f..ae0ffaf4cb 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs @@ -28,7 +28,7 @@ namespace GodotTools.Build string launchMessage = startInfo.GetCommandLineDisplay(new StringBuilder("Running: ")).ToString(); stdOutHandler?.Invoke(launchMessage); - if (Godot.OS.IsStdoutVerbose()) + if (Godot.OS.IsStdOutVerbose()) Console.WriteLine(launchMessage); startInfo.RedirectStandardOutput = true; @@ -89,7 +89,7 @@ namespace GodotTools.Build string launchMessage = startInfo.GetCommandLineDisplay(new StringBuilder("Running: ")).ToString(); stdOutHandler?.Invoke(launchMessage); - if (Godot.OS.IsStdoutVerbose()) + if (Godot.OS.IsStdOutVerbose()) Console.WriteLine(launchMessage); startInfo.RedirectStandardOutput = true; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs index 2e438f3f8f..8cb64b4f56 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs @@ -122,7 +122,7 @@ namespace GodotTools.Build { base._Ready(); - CustomMinimumSize = new Vector2i(0, (int)(228 * EditorScale)); + CustomMinimumSize = new Vector2(0, 228 * EditorScale); SizeFlagsVertical = SizeFlags.ExpandFill; var toolBarHBox = new HBoxContainer { SizeFlagsHorizontal = SizeFlags.ExpandFill }; diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index 08147d9f6a..5abbe8752c 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -192,7 +192,7 @@ namespace GodotTools try { - if (Godot.OS.IsStdoutVerbose()) + if (Godot.OS.IsStdOutVerbose()) Console.WriteLine( $"Running: \"{command}\" {string.Join(" ", args.Select(a => $"\"{a}\""))}"); @@ -385,7 +385,7 @@ namespace GodotTools // correct version first (`RegisterDefaults` always picks the latest). if (DotNetFinder.TryFindDotNetSdk(dotNetSdkSearchVersion, out var sdkVersion, out string sdkPath)) { - if (Godot.OS.IsStdoutVerbose()) + if (Godot.OS.IsStdOutVerbose()) Console.WriteLine($"Found .NET Sdk version '{sdkVersion}': {sdkPath}"); ProjectUtils.MSBuildLocatorRegisterMSBuildPath(sdkPath); @@ -395,12 +395,12 @@ namespace GodotTools try { ProjectUtils.MSBuildLocatorRegisterDefaults(out sdkVersion, out sdkPath); - if (Godot.OS.IsStdoutVerbose()) + if (Godot.OS.IsStdOutVerbose()) Console.WriteLine($"Found .NET Sdk version '{sdkVersion}': {sdkPath}"); } catch (InvalidOperationException e) { - if (Godot.OS.IsStdoutVerbose()) + if (Godot.OS.IsStdOutVerbose()) GD.PrintErr(e.ToString()); GD.PushError($".NET Sdk not found. The required version is '{dotNetSdkSearchVersion}'."); } diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs index 89ac8058b9..e401910301 100644 --- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs +++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs @@ -11,7 +11,7 @@ namespace GodotTools public override void _Notification(long what) { - if (what == Node.NotificationWmWindowFocusIn) + if (what == Node.NotificationWMWindowFocusIn) { RestartTimer(); diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs index 9df90ac608..5de2c9833b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs @@ -200,13 +200,13 @@ namespace GodotTools.Ides { public void LogDebug(string message) { - if (OS.IsStdoutVerbose()) + if (OS.IsStdOutVerbose()) Console.WriteLine(message); } public void LogInfo(string message) { - if (OS.IsStdoutVerbose()) + if (OS.IsStdOutVerbose()) Console.WriteLine(message); } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 2e8655f9b5..137e222c70 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -38,10 +38,10 @@ #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/os/os.h" -#include "core/string/ucaps.h" #include "main/main.h" #include "../godotsharp_defs.h" +#include "../utils/naming_utils.h" #include "../utils/path_utils.h" #include "../utils/string_utils.h" @@ -146,74 +146,6 @@ static String fix_doc_description(const String &p_bbcode) { .strip_edges(); } -static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_upper = false) { - String ret; - Vector<String> parts = p_identifier.split("_", true); - - for (int i = 0; i < parts.size(); i++) { - String part = parts[i]; - - if (part.length()) { - part[0] = _find_upper(part[0]); - if (p_input_is_upper) { - for (int j = 1; j < part.length(); j++) { - part[j] = _find_lower(part[j]); - } - } - ret += part; - } else { - if (i == 0 || i == (parts.size() - 1)) { - // Preserve underscores at the beginning and end - ret += "_"; - } else { - // Preserve contiguous underscores - if (parts[i - 1].length()) { - ret += "__"; - } else { - ret += "_"; - } - } - } - } - - return ret; -} - -static String snake_to_camel_case(const String &p_identifier, bool p_input_is_upper = false) { - String ret; - Vector<String> parts = p_identifier.split("_", true); - - for (int i = 0; i < parts.size(); i++) { - String part = parts[i]; - - if (part.length()) { - if (i != 0) { - part[0] = _find_upper(part[0]); - } - if (p_input_is_upper) { - for (int j = i != 0 ? 1 : 0; j < part.length(); j++) { - part[j] = _find_lower(part[j]); - } - } - ret += part; - } else { - if (i == 0 || i == (parts.size() - 1)) { - // Preserve underscores at the beginning and end - ret += "_"; - } else { - // Preserve contiguous underscores - if (parts[i - 1].length()) { - ret += "__"; - } else { - ret += "_"; - } - } - } - } - - return ret; -} - String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterface *p_itype) { // Based on the version in EditorHelp @@ -967,11 +899,11 @@ void BindingsGenerator::_generate_array_extensions(StringBuilder &p_output) { ARRAY_ALL(string); ARRAY_ALL(Color); ARRAY_ALL(Vector2); - ARRAY_ALL(Vector2i); + ARRAY_ALL(Vector2I); ARRAY_ALL(Vector3); - ARRAY_ALL(Vector3i); + ARRAY_ALL(Vector3I); ARRAY_ALL(Vector4); - ARRAY_ALL(Vector4i); + ARRAY_ALL(Vector4I); #undef ARRAY_ALL #undef ARRAY_IS_EMPTY @@ -1041,7 +973,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { _log("Declaring global enum '%s' inside struct '%s'\n", enum_proxy_name.utf8().get_data(), enum_class_name.utf8().get_data()); p_output.append("\npublic partial struct "); - p_output.append(enum_class_name); + p_output.append(pascal_to_pascal_case(enum_class_name)); p_output.append("\n" OPEN_BLOCK); } @@ -1050,7 +982,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { } p_output.append("\npublic enum "); - p_output.append(enum_proxy_name); + p_output.append(pascal_to_pascal_case(enum_proxy_name)); p_output.append(" : long"); p_output.append("\n" OPEN_BLOCK); @@ -1502,7 +1434,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str } output.append(MEMBER_BEGIN "public enum "); - output.append(ienum.cname.operator String()); + output.append(pascal_to_pascal_case(ienum.cname.operator String())); output.append(" : long"); output.append(MEMBER_BEGIN OPEN_BLOCK); @@ -2896,7 +2828,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(type_cname); - TypeInterface itype = TypeInterface::create_object_type(type_cname, api_type); + TypeInterface itype = TypeInterface::create_object_type(type_cname, pascal_to_pascal_case(type_cname), api_type); itype.base_name = ClassDB::get_parent_class(type_cname); itype.is_singleton = Engine::get_singleton()->has_singleton(itype.proxy_name); @@ -3241,7 +3173,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { for (const KeyValue<StringName, ClassDB::ClassInfo::EnumInfo> &E : enum_map) { StringName enum_proxy_cname = E.key; - String enum_proxy_name = enum_proxy_cname.operator String(); + String enum_proxy_name = pascal_to_pascal_case(enum_proxy_cname.operator String()); if (itype.find_property_by_proxy_name(enum_proxy_name) || itype.find_method_by_proxy_name(enum_proxy_name) || itype.find_signal_by_proxy_name(enum_proxy_name)) { // In case the enum name conflicts with other PascalCase members, // we append 'Enum' to the enum name in those cases. @@ -3369,7 +3301,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar } break; case Variant::AABB: { AABB aabb = p_val.operator ::AABB(); - r_iarg.default_argument = "new AABB(new Vector3" + aabb.position.operator String() + ", new Vector3" + aabb.size.operator String() + ")"; + r_iarg.default_argument = "new Aabb(new Vector3" + aabb.position.operator String() + ", new Vector3" + aabb.size.operator String() + ")"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; } break; case Variant::RECT2: { @@ -3379,7 +3311,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar } break; case Variant::RECT2I: { Rect2i rect = p_val.operator Rect2i(); - r_iarg.default_argument = "new Rect2i(new Vector2i" + rect.position.operator String() + ", new Vector2i" + rect.size.operator String() + ")"; + r_iarg.default_argument = "new Rect2I(new Vector2I" + rect.position.operator String() + ", new Vector2I" + rect.size.operator String() + ")"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; } break; case Variant::COLOR: @@ -3513,32 +3445,30 @@ void BindingsGenerator::_populate_builtin_type_interfaces() { TypeInterface itype; -#define INSERT_STRUCT_TYPE(m_type) \ - { \ - itype = TypeInterface::create_value_type(String(#m_type)); \ - itype.c_type_in = #m_type "*"; \ - itype.c_type_out = itype.cs_type; \ - itype.cs_in_expr = "&%0"; \ - itype.cs_in_expr_is_unsafe = true; \ - builtin_types.insert(itype.cname, itype); \ - } - - INSERT_STRUCT_TYPE(Vector2) - INSERT_STRUCT_TYPE(Vector2i) - INSERT_STRUCT_TYPE(Rect2) - INSERT_STRUCT_TYPE(Rect2i) - INSERT_STRUCT_TYPE(Transform2D) - INSERT_STRUCT_TYPE(Vector3) - INSERT_STRUCT_TYPE(Vector3i) - INSERT_STRUCT_TYPE(Basis) - INSERT_STRUCT_TYPE(Quaternion) - INSERT_STRUCT_TYPE(Transform3D) - INSERT_STRUCT_TYPE(AABB) - INSERT_STRUCT_TYPE(Color) - INSERT_STRUCT_TYPE(Plane) - INSERT_STRUCT_TYPE(Vector4) - INSERT_STRUCT_TYPE(Vector4i) - INSERT_STRUCT_TYPE(Projection) +#define INSERT_STRUCT_TYPE(m_type, m_proxy_name) \ + { \ + itype = TypeInterface::create_value_type(String(#m_type), String(#m_proxy_name)); \ + itype.cs_in_expr = "&%0"; \ + itype.cs_in_expr_is_unsafe = true; \ + builtin_types.insert(itype.cname, itype); \ + } + + INSERT_STRUCT_TYPE(Vector2, Vector2) + INSERT_STRUCT_TYPE(Vector2i, Vector2I) + INSERT_STRUCT_TYPE(Rect2, Rect2) + INSERT_STRUCT_TYPE(Rect2i, Rect2I) + INSERT_STRUCT_TYPE(Transform2D, Transform2D) + INSERT_STRUCT_TYPE(Vector3, Vector3) + INSERT_STRUCT_TYPE(Vector3i, Vector3I) + INSERT_STRUCT_TYPE(Basis, Basis) + INSERT_STRUCT_TYPE(Quaternion, Quaternion) + INSERT_STRUCT_TYPE(Transform3D, Transform3D) + INSERT_STRUCT_TYPE(AABB, Aabb) + INSERT_STRUCT_TYPE(Color, Color) + INSERT_STRUCT_TYPE(Plane, Plane) + INSERT_STRUCT_TYPE(Vector4, Vector4) + INSERT_STRUCT_TYPE(Vector4i, Vector4I) + INSERT_STRUCT_TYPE(Projection, Projection) #undef INSERT_STRUCT_TYPE @@ -3677,7 +3607,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() { itype = TypeInterface(); itype.name = "RID"; itype.cname = itype.name; - itype.proxy_name = "RID"; + itype.proxy_name = "Rid"; itype.cs_type = itype.proxy_name; itype.c_arg_in = "&%s"; itype.c_type = itype.cs_type; @@ -3891,7 +3821,7 @@ void BindingsGenerator::_populate_global_constants() { enum_itype.is_enum = true; enum_itype.name = ienum.cname.operator String(); enum_itype.cname = ienum.cname; - enum_itype.proxy_name = enum_itype.name; + enum_itype.proxy_name = pascal_to_pascal_case(enum_itype.name); TypeInterface::postsetup_enum_type(enum_itype); enum_types.insert(enum_itype.cname, enum_itype); @@ -3913,9 +3843,9 @@ void BindingsGenerator::_populate_global_constants() { // HARDCODED List<StringName> hardcoded_enums; hardcoded_enums.push_back("Vector2.Axis"); - hardcoded_enums.push_back("Vector2i.Axis"); + hardcoded_enums.push_back("Vector2I.Axis"); hardcoded_enums.push_back("Vector3.Axis"); - hardcoded_enums.push_back("Vector3i.Axis"); + hardcoded_enums.push_back("Vector3I.Axis"); for (const StringName &enum_cname : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore @@ -3923,7 +3853,7 @@ void BindingsGenerator::_populate_global_constants() { enum_itype.is_enum = true; enum_itype.name = enum_cname.operator String(); enum_itype.cname = enum_cname; - enum_itype.proxy_name = enum_itype.name; + enum_itype.proxy_name = pascal_to_pascal_case(enum_itype.name); TypeInterface::postsetup_enum_type(enum_itype); enum_types.insert(enum_itype.cname, enum_itype); } diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index cef8246032..5c266ed31f 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -472,43 +472,88 @@ class BindingsGenerator { } private: + static DocData::ClassDoc *_get_type_doc(TypeInterface &itype) { + String doc_name = itype.name.begins_with("_") ? itype.name.substr(1) : itype.name; + return &EditorHelp::get_doc_data()->class_list[doc_name]; + } + static void _init_value_type(TypeInterface &itype) { - itype.proxy_name = itype.name; + if (itype.proxy_name.is_empty()) { + itype.proxy_name = itype.name; + } - itype.c_type = itype.name; itype.cs_type = itype.proxy_name; - itype.c_type_in = itype.proxy_name + "*"; - itype.c_type_out = itype.proxy_name; - itype.class_doc = &EditorHelp::get_doc_data()->class_list[itype.proxy_name]; + itype.c_type = itype.cs_type; + itype.c_type_in = itype.cs_type + "*"; + itype.c_type_out = itype.cs_type; + + itype.class_doc = _get_type_doc(itype); + } + + static void _init_object_type(TypeInterface &itype, ClassDB::APIType p_api_type) { + if (itype.proxy_name.is_empty()) { + itype.proxy_name = itype.name; + } + + if (itype.proxy_name.begins_with("_")) { + itype.proxy_name = itype.proxy_name.substr(1); + } + + itype.api_type = p_api_type; + itype.is_object_type = true; + + itype.class_doc = _get_type_doc(itype); } public: - static TypeInterface create_value_type(const String &p_name) { + static TypeInterface create_value_type(const String &p_name, const String &p_proxy_name) { TypeInterface itype; itype.name = p_name; - itype.cname = StringName(p_name); + itype.cname = p_name; + itype.proxy_name = p_proxy_name; _init_value_type(itype); return itype; } - static TypeInterface create_value_type(const StringName &p_name) { + static TypeInterface create_value_type(const StringName &p_cname, const String &p_proxy_name) { TypeInterface itype; - itype.name = p_name.operator String(); + itype.name = p_cname; + itype.cname = p_cname; + itype.proxy_name = p_proxy_name; + _init_value_type(itype); + return itype; + } + + static TypeInterface create_value_type(const String &p_name) { + TypeInterface itype; + itype.name = p_name; itype.cname = p_name; _init_value_type(itype); return itype; } - static TypeInterface create_object_type(const StringName &p_cname, ClassDB::APIType p_api_type) { + static TypeInterface create_value_type(const StringName &p_cname) { TypeInterface itype; + itype.name = p_cname; + itype.cname = p_cname; + _init_value_type(itype); + return itype; + } + static TypeInterface create_object_type(const StringName &p_cname, const String &p_proxy_name, ClassDB::APIType p_api_type) { + TypeInterface itype; itype.name = p_cname; itype.cname = p_cname; - itype.proxy_name = itype.name.begins_with("_") ? itype.name.substr(1, itype.name.length()) : itype.name; - itype.api_type = p_api_type; - itype.is_object_type = true; - itype.class_doc = &EditorHelp::get_doc_data()->class_list[itype.proxy_name]; + itype.proxy_name = p_proxy_name; + _init_object_type(itype, p_api_type); + return itype; + } + static TypeInterface create_object_type(const StringName &p_cname, ClassDB::APIType p_api_type) { + TypeInterface itype; + itype.name = p_cname; + itype.cname = p_cname; + _init_object_type(itype, p_api_type); return itype; } diff --git a/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs index fbad482cf6..87468fb433 100644 --- a/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs +++ b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs @@ -17,22 +17,22 @@ public partial class _CLASS_ : _BASE_ // Add the gravity. if (!IsOnFloor()) - velocity.y += gravity * (float)delta; + velocity.Y += gravity * (float)delta; // Handle Jump. if (Input.IsActionJustPressed("ui_accept") && IsOnFloor()) - velocity.y = JumpVelocity; + velocity.Y = JumpVelocity; // Get the input direction and handle the movement/deceleration. // As good practice, you should replace UI actions with custom gameplay actions. Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); if (direction != Vector2.Zero) { - velocity.x = direction.x * Speed; + velocity.X = direction.X * Speed; } else { - velocity.x = Mathf.MoveToward(Velocity.x, 0, Speed); + velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); } Velocity = velocity; diff --git a/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs index abed246a1e..ddeb9d7e00 100644 --- a/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs +++ b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs @@ -17,25 +17,25 @@ public partial class _CLASS_ : _BASE_ // Add the gravity. if (!IsOnFloor()) - velocity.y -= gravity * (float)delta; + velocity.Y -= gravity * (float)delta; // Handle Jump. if (Input.IsActionJustPressed("ui_accept") && IsOnFloor()) - velocity.y = JumpVelocity; + velocity.Y = JumpVelocity; // Get the input direction and handle the movement/deceleration. // As good practice, you should replace UI actions with custom gameplay actions. Vector2 inputDir = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); - Vector3 direction = (Transform.basis * new Vector3(inputDir.x, 0, inputDir.y)).Normalized(); + Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized(); if (direction != Vector3.Zero) { - velocity.x = direction.x * Speed; - velocity.z = direction.z * Speed; + velocity.X = direction.X * Speed; + velocity.Z = direction.Z * Speed; } else { - velocity.x = Mathf.MoveToward(Velocity.x, 0, Speed); - velocity.z = Mathf.MoveToward(Velocity.z, 0, Speed); + velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); + velocity.Z = Mathf.MoveToward(Velocity.Z, 0, Speed); } Velocity = velocity; |