diff options
Diffstat (limited to 'modules/mono/glue')
70 files changed, 507 insertions, 270 deletions
diff --git a/modules/mono/glue/GodotSharp/.gitignore b/modules/mono/glue/GodotSharp/.gitignore new file mode 100644 index 0000000000..aa9f614a9d --- /dev/null +++ b/modules/mono/glue/GodotSharp/.gitignore @@ -0,0 +1,3 @@ +# Generated Godot API sources directories +GodotSharp/Generated +GodotSharpEditor/Generated diff --git a/modules/mono/glue/GodotSharp/GodotSharp.sln b/modules/mono/glue/GodotSharp/GodotSharp.sln new file mode 100644 index 0000000000..a496e36da3 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharp", "GodotSharp\GodotSharp.csproj", "{AEBF0036-DA76-4341-B651-A3F2856AB2FA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharpEditor", "GodotSharpEditor\GodotSharpEditor.csproj", "{8FBEC238-D944-4074-8548-B3B524305905}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Release|Any CPU.Build.0 = Release|Any CPU + {8FBEC238-D944-4074-8548-B3B524305905}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FBEC238-D944-4074-8548-B3B524305905}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FBEC238-D944-4074-8548-B3B524305905}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FBEC238-D944-4074-8548-B3B524305905}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/modules/mono/glue/Managed/Files/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs index 6a4f785551..6a4f785551 100644 --- a/modules/mono/glue/Managed/Files/AABB.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs diff --git a/modules/mono/glue/Managed/Files/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index 0e7b0362e0..aba1065498 100644 --- a/modules/mono/glue/Managed/Files/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -64,6 +64,11 @@ namespace Godot.Collections return safeHandle.DangerousGetHandle(); } + public Array Duplicate(bool deep = false) + { + return new Array(godot_icall_Array_Duplicate(GetPtr(), deep)); + } + public Error Resize(int newSize) { return godot_icall_Array_Resize(GetPtr(), newSize); @@ -179,6 +184,9 @@ namespace Godot.Collections internal extern static void godot_icall_Array_CopyTo(IntPtr ptr, System.Array array, int arrayIndex); [MethodImpl(MethodImplOptions.InternalCall)] + internal extern static IntPtr godot_icall_Array_Duplicate(IntPtr ptr, bool deep); + + [MethodImpl(MethodImplOptions.InternalCall)] internal extern static int godot_icall_Array_IndexOf(IntPtr ptr, object item); [MethodImpl(MethodImplOptions.InternalCall)] @@ -250,6 +258,11 @@ namespace Godot.Collections return from.objectArray; } + public Array<T> Duplicate(bool deep = false) + { + return new Array<T>(objectArray.Duplicate(deep)); + } + public Error Resize(int newSize) { return objectArray.Resize(newSize); diff --git a/modules/mono/glue/Managed/Files/Attributes/ExportAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportAttribute.cs index 6adf044886..6adf044886 100644 --- a/modules/mono/glue/Managed/Files/Attributes/ExportAttribute.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportAttribute.cs diff --git a/modules/mono/glue/Managed/Files/Attributes/GodotMethodAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/GodotMethodAttribute.cs index 55848769d5..55848769d5 100644 --- a/modules/mono/glue/Managed/Files/Attributes/GodotMethodAttribute.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/GodotMethodAttribute.cs diff --git a/modules/mono/glue/Managed/Files/Attributes/RPCAttributes.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs index 1bf6d5199a..1bf6d5199a 100644 --- a/modules/mono/glue/Managed/Files/Attributes/RPCAttributes.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs diff --git a/modules/mono/glue/Managed/Files/Attributes/SignalAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs index 3957387be9..3957387be9 100644 --- a/modules/mono/glue/Managed/Files/Attributes/SignalAttribute.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs diff --git a/modules/mono/glue/Managed/Files/Attributes/ToolAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ToolAttribute.cs index d0437409af..d0437409af 100644 --- a/modules/mono/glue/Managed/Files/Attributes/ToolAttribute.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ToolAttribute.cs diff --git a/modules/mono/glue/Managed/Files/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index c5e62b77c8..d38589013e 100644 --- a/modules/mono/glue/Managed/Files/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -387,6 +387,19 @@ namespace Godot return b; } + public Basis Slerp(Basis target, real_t t) + { + var from = new Quat(this); + var to = new Quat(target); + + var b = new Basis(from.Slerp(to, t)); + b.Row0 *= Mathf.Lerp(Row0.Length(), target.Row0.Length(), t); + b.Row1 *= Mathf.Lerp(Row1.Length(), target.Row1.Length(), t); + b.Row2 *= Mathf.Lerp(Row2.Length(), target.Row2.Length(), t); + + return b; + } + public real_t Tdotx(Vector3 with) { return this.Row0[0] * with[0] + this.Row1[0] * with[1] + this.Row2[0] * with[2]; diff --git a/modules/mono/glue/Managed/Files/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index df817e47e9..1d1a49945f 100644 --- a/modules/mono/glue/Managed/Files/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -318,9 +318,9 @@ namespace Godot return res; } - public int ToAbgr32() + public uint ToAbgr32() { - int c = (byte)Math.Round(a * 255); + uint c = (byte)Math.Round(a * 255); c <<= 8; c |= (byte)Math.Round(b * 255); c <<= 8; @@ -331,9 +331,9 @@ namespace Godot return c; } - public long ToAbgr64() + public ulong ToAbgr64() { - long c = (ushort)Math.Round(a * 65535); + ulong c = (ushort)Math.Round(a * 65535); c <<= 16; c |= (ushort)Math.Round(b * 65535); c <<= 16; @@ -344,9 +344,9 @@ namespace Godot return c; } - public int ToArgb32() + public uint ToArgb32() { - int c = (byte)Math.Round(a * 255); + uint c = (byte)Math.Round(a * 255); c <<= 8; c |= (byte)Math.Round(r * 255); c <<= 8; @@ -357,9 +357,9 @@ namespace Godot return c; } - public long ToArgb64() + public ulong ToArgb64() { - long c = (ushort)Math.Round(a * 65535); + ulong c = (ushort)Math.Round(a * 65535); c <<= 16; c |= (ushort)Math.Round(r * 65535); c <<= 16; @@ -370,9 +370,9 @@ namespace Godot return c; } - public int ToRgba32() + public uint ToRgba32() { - int c = (byte)Math.Round(r * 255); + uint c = (byte)Math.Round(r * 255); c <<= 8; c |= (byte)Math.Round(g * 255); c <<= 8; @@ -383,9 +383,9 @@ namespace Godot return c; } - public long ToRgba64() + public ulong ToRgba64() { - long c = (ushort)Math.Round(r * 65535); + ulong c = (ushort)Math.Round(r * 65535); c <<= 16; c |= (ushort)Math.Round(g * 65535); c <<= 16; @@ -419,7 +419,7 @@ namespace Godot this.a = a; } - public Color(int rgba) + public Color(uint rgba) { a = (rgba & 0xFF) / 255.0f; rgba >>= 8; @@ -430,7 +430,7 @@ namespace Godot r = (rgba & 0xFF) / 255.0f; } - public Color(long rgba) + public Color(ulong rgba) { a = (rgba & 0xFFFF) / 65535.0f; rgba >>= 16; @@ -541,7 +541,7 @@ namespace Godot return true; } - public static Color Color8(byte r8, byte g8, byte b8, byte a8) + public static Color Color8(byte r8, byte g8, byte b8, byte a8 = 255) { return new Color(r8 / 255f, g8 / 255f, b8 / 255f, a8 / 255f); } @@ -605,6 +605,74 @@ namespace Godot throw new ArgumentOutOfRangeException("Invalid color code. Blue part is not valid hexadecimal: " + rgba); } + public static Color operator +(Color left, Color right) + { + left.r += right.r; + left.g += right.g; + left.b += right.b; + left.a += right.a; + return left; + } + + public static Color operator -(Color left, Color right) + { + left.r -= right.r; + left.g -= right.g; + left.b -= right.b; + left.a -= right.a; + return left; + } + + public static Color operator -(Color color) + { + return Colors.White - color; + } + + public static Color operator *(Color color, float scale) + { + color.r *= scale; + color.g *= scale; + color.b *= scale; + color.a *= scale; + return color; + } + + public static Color operator *(float scale, Color color) + { + color.r *= scale; + color.g *= scale; + color.b *= scale; + color.a *= scale; + return color; + } + + public static Color operator *(Color left, Color right) + { + left.r *= right.r; + left.g *= right.g; + left.b *= right.b; + left.a *= right.a; + return left; + } + + public static Color operator /(Color color, float scale) + { + color.r /= scale; + color.g /= scale; + color.b /= scale; + color.a /= scale; + return color; + } + + public static Color operator /(Color left, Color right) + { + left.r /= right.r; + left.g /= right.g; + left.b /= right.b; + left.a /= right.a; + return left; + } + public static bool operator ==(Color left, Color right) { return left.Equals(right); diff --git a/modules/mono/glue/Managed/Files/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index f41f5e9fc8..f41f5e9fc8 100644 --- a/modules/mono/glue/Managed/Files/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs diff --git a/modules/mono/glue/Managed/Files/DebuggingUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DebuggingUtils.cs index edfe3464ec..edfe3464ec 100644 --- a/modules/mono/glue/Managed/Files/DebuggingUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DebuggingUtils.cs diff --git a/modules/mono/glue/Managed/Files/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs index 6ab8549a01..d72109de92 100644 --- a/modules/mono/glue/Managed/Files/Dictionary.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs @@ -80,6 +80,11 @@ namespace Godot.Collections disposed = true; } + public Dictionary Duplicate(bool deep = false) + { + return new Dictionary(godot_icall_Dictionary_Duplicate(GetPtr(), deep)); + } + // IDictionary public ICollection Keys @@ -235,6 +240,9 @@ namespace Godot.Collections internal extern static bool godot_icall_Dictionary_ContainsKey(IntPtr ptr, object key); [MethodImpl(MethodImplOptions.InternalCall)] + internal extern static IntPtr godot_icall_Dictionary_Duplicate(IntPtr ptr, bool deep); + + [MethodImpl(MethodImplOptions.InternalCall)] internal extern static bool godot_icall_Dictionary_RemoveKey(IntPtr ptr, object key); [MethodImpl(MethodImplOptions.InternalCall)] @@ -313,6 +321,11 @@ namespace Godot.Collections return objectDict.GetPtr(); } + public Dictionary<TKey, TValue> Duplicate(bool deep = false) + { + return new Dictionary<TKey, TValue>(objectDict.Duplicate(deep)); + } + // IDictionary<TKey, TValue> public TValue this[TKey key] diff --git a/modules/mono/glue/Managed/Files/Dispatcher.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dispatcher.cs index 072e0f20ff..072e0f20ff 100644 --- a/modules/mono/glue/Managed/Files/Dispatcher.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dispatcher.cs diff --git a/modules/mono/glue/Managed/Files/DynamicObject.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs index a0f105d55e..a0f105d55e 100644 --- a/modules/mono/glue/Managed/Files/DynamicObject.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs diff --git a/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs index 5023725f17..5d16260f5d 100644 --- a/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs @@ -9,7 +9,7 @@ namespace Godot public T GetNodeOrNull<T>(NodePath path) where T : class { - return GetNode(path) as T; + return GetNodeOrNull(path) as T; } public T GetChild<T>(int idx) where T : class diff --git a/modules/mono/glue/Managed/Files/Extensions/ObjectExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ObjectExtensions.cs index 9ef0959750..9ef0959750 100644 --- a/modules/mono/glue/Managed/Files/Extensions/ObjectExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ObjectExtensions.cs diff --git a/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs index 684d160b57..684d160b57 100644 --- a/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs diff --git a/modules/mono/glue/Managed/Files/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index 2068099ac6..19962d418a 100644 --- a/modules/mono/glue/Managed/Files/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -93,22 +93,22 @@ namespace Godot public static void PrintErr(params object[] what) { - godot_icall_GD_printerr(Array.ConvertAll(what, x => x.ToString())); + godot_icall_GD_printerr(Array.ConvertAll(what, x => x?.ToString())); } public static void PrintRaw(params object[] what) { - godot_icall_GD_printraw(Array.ConvertAll(what, x => x.ToString())); + godot_icall_GD_printraw(Array.ConvertAll(what, x => x?.ToString())); } public static void PrintS(params object[] what) { - godot_icall_GD_prints(Array.ConvertAll(what, x => x.ToString())); + godot_icall_GD_prints(Array.ConvertAll(what, x => x?.ToString())); } public static void PrintT(params object[] what) { - godot_icall_GD_printt(Array.ConvertAll(what, x => x.ToString())); + godot_icall_GD_printt(Array.ConvertAll(what, x => x?.ToString())); } public static float Randf() diff --git a/modules/mono/glue/Managed/Files/GodotSynchronizationContext.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotSynchronizationContext.cs index 4b5e3f8761..4b5e3f8761 100644 --- a/modules/mono/glue/Managed/Files/GodotSynchronizationContext.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotSynchronizationContext.cs diff --git a/modules/mono/glue/Managed/Files/GodotTaskScheduler.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTaskScheduler.cs index 8eaeea50dc..8eaeea50dc 100644 --- a/modules/mono/glue/Managed/Files/GodotTaskScheduler.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTaskScheduler.cs diff --git a/modules/mono/glue/Managed/Files/GodotTraceListener.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTraceListener.cs index f1a00ae0fa..f1a00ae0fa 100644 --- a/modules/mono/glue/Managed/Files/GodotTraceListener.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTraceListener.cs diff --git a/modules/mono/glue/Managed/Files/Interfaces/IAwaitable.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Interfaces/IAwaitable.cs index 0397957d00..0397957d00 100644 --- a/modules/mono/glue/Managed/Files/Interfaces/IAwaitable.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Interfaces/IAwaitable.cs diff --git a/modules/mono/glue/Managed/Files/Interfaces/IAwaiter.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Interfaces/IAwaiter.cs index d3be9d781c..d3be9d781c 100644 --- a/modules/mono/glue/Managed/Files/Interfaces/IAwaiter.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Interfaces/IAwaiter.cs diff --git a/modules/mono/glue/Managed/Files/Interfaces/ISerializationListener.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Interfaces/ISerializationListener.cs index c3fa2f3e82..c3fa2f3e82 100644 --- a/modules/mono/glue/Managed/Files/Interfaces/ISerializationListener.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Interfaces/ISerializationListener.cs diff --git a/modules/mono/glue/Managed/Files/MarshalUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs index a1d63a62ef..a1d63a62ef 100644 --- a/modules/mono/glue/Managed/Files/MarshalUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs diff --git a/modules/mono/glue/Managed/Files/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index 54821fe790..ddfed180b5 100644 --- a/modules/mono/glue/Managed/Files/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -266,12 +266,14 @@ namespace Godot public static int Sign(int s) { + if (s == 0) return 0; return s < 0 ? -1 : 1; } - public static real_t Sign(real_t s) + public static int Sign(real_t s) { - return s < 0f ? -1f : 1f; + if (s == 0) return 0; + return s < 0 ? -1 : 1; } public static real_t Sin(real_t s) diff --git a/modules/mono/glue/Managed/Files/MathfEx.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/MathfEx.cs index 1b7fd4906f..1b7fd4906f 100644 --- a/modules/mono/glue/Managed/Files/MathfEx.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/MathfEx.cs diff --git a/modules/mono/glue/Managed/Files/NodePath.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs index 8c5872ba5a..8c5872ba5a 100644 --- a/modules/mono/glue/Managed/Files/NodePath.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs diff --git a/modules/mono/glue/Managed/Files/Object.base.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs index de80f7fddc..de80f7fddc 100644 --- a/modules/mono/glue/Managed/Files/Object.base.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs diff --git a/modules/mono/glue/Managed/Files/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index 885845e3a4..885845e3a4 100644 --- a/modules/mono/glue/Managed/Files/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs diff --git a/modules/mono/glue/Managed/Files/Quat.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs index 8f60867ac3..6702634c51 100644 --- a/modules/mono/glue/Managed/Files/Quat.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs @@ -82,12 +82,20 @@ namespace Godot public Vector3 GetEuler() { +#if DEBUG + if (!IsNormalized()) + throw new InvalidOperationException("Quat is not normalized"); +#endif var basis = new Basis(this); return basis.GetEuler(); } public Quat Inverse() { +#if DEBUG + if (!IsNormalized()) + throw new InvalidOperationException("Quat is not normalized"); +#endif return new Quat(-x, -y, -z, w); } @@ -125,6 +133,13 @@ namespace Godot public Quat Slerp(Quat b, real_t t) { +#if DEBUG + if (!IsNormalized()) + throw new InvalidOperationException("Quat is not normalized"); + if (!b.IsNormalized()) + throw new ArgumentException("Argument is not normalized", nameof(b)); +#endif + // Calculate cosine real_t cosom = x * b.x + y * b.y + z * b.z + w * b.w; @@ -200,9 +215,13 @@ namespace Godot public Vector3 Xform(Vector3 v) { - Quat q = this * v; - q *= Inverse(); - return new Vector3(q.x, q.y, q.z); +#if DEBUG + if (!IsNormalized()) + throw new InvalidOperationException("Quat is not normalized"); +#endif + var u = new Vector3(x, y, z); + Vector3 uv = u.Cross(v); + return v + ((uv * w) + u.Cross(uv)) * 2; } // Static Readonly Properties @@ -257,8 +276,12 @@ namespace Godot public Quat(Vector3 axis, real_t angle) { +#if DEBUG + if (!axis.IsNormalized()) + throw new ArgumentException("Argument is not normalized", nameof(axis)); +#endif + real_t d = axis.Length(); - real_t angle_t = angle; if (d == 0f) { @@ -269,12 +292,14 @@ namespace Godot } else { - real_t s = Mathf.Sin(angle_t * 0.5f) / d; + real_t sinAngle = Mathf.Sin(angle * 0.5f); + real_t cosAngle = Mathf.Cos(angle * 0.5f); + real_t s = sinAngle / d; x = axis.x * s; y = axis.y * s; z = axis.z * s; - w = Mathf.Cos(angle_t * 0.5f); + w = cosAngle; } } diff --git a/modules/mono/glue/Managed/Files/RID.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/RID.cs index 94761531b1..94761531b1 100644 --- a/modules/mono/glue/Managed/Files/RID.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/RID.cs diff --git a/modules/mono/glue/Managed/Files/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs index 91e614dc7b..91e614dc7b 100644 --- a/modules/mono/glue/Managed/Files/Rect2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs diff --git a/modules/mono/glue/Managed/Files/SignalAwaiter.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/SignalAwaiter.cs index 9483b6ffb4..9483b6ffb4 100644 --- a/modules/mono/glue/Managed/Files/SignalAwaiter.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/SignalAwaiter.cs diff --git a/modules/mono/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index 6045c83e95..e096d37a6f 100644 --- a/modules/mono/glue/Managed/Files/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -18,7 +18,7 @@ namespace Godot int pos = 0; int slices = 1; - while ((pos = instance.Find(splitter, pos)) >= 0) + while ((pos = instance.Find(splitter, pos, caseSensitive: true)) >= 0) { slices++; pos += splitter.Length; @@ -229,7 +229,7 @@ namespace Godot // </summary> public static int CasecmpTo(this string instance, string to) { - return instance.CompareTo(to, true); + return instance.CompareTo(to, caseSensitive: true); } // <summary> @@ -322,28 +322,32 @@ namespace Godot return instance.Substring(pos + 1); } - // <summary> - // Find the first occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> - public static int Find(this string instance, string what, int from = 0) + /// <summary>Find the first occurrence of a substring. Optionally, the search starting position can be passed.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int Find(this string instance, string what, int from = 0, bool caseSensitive = true) { - return instance.IndexOf(what, StringComparison.OrdinalIgnoreCase); + return instance.IndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - // <summary> - // Find the last occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> - public static int FindLast(this string instance, string what) + /// <summary>Find the last occurrence of a substring.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int FindLast(this string instance, string what, bool caseSensitive = true) { - return instance.LastIndexOf(what, StringComparison.OrdinalIgnoreCase); + return instance.FindLast(what, instance.Length - 1, caseSensitive); } - // <summary> - // Find the first occurrence of a substring but search as case-insensitive, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> + /// <summary>Find the last occurrence of a substring specifying the search starting position.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int FindLast(this string instance, string what, int from, bool caseSensitive = true) + { + return instance.LastIndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); + } + + /// <summary>Find the first occurrence of a substring but search as case-insensitive. Optionally, the search starting position can be passed.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> public static int FindN(this string instance, string what, int from = 0) { - return instance.IndexOf(what, StringComparison.Ordinal); + return instance.IndexOf(what, from, StringComparison.OrdinalIgnoreCase); } // <summary> @@ -470,7 +474,7 @@ namespace Godot int source = 0; int target = 0; - while (instance[source] != 0 && text[target] != 0) + while (source < len && target < text.Length) { bool match; @@ -487,7 +491,7 @@ namespace Godot if (match) { source++; - if (instance[source] == 0) + if (source >= len) return true; } @@ -502,7 +506,7 @@ namespace Godot // </summary> public static bool IsSubsequenceOfI(this string instance, string text) { - return instance.IsSubsequenceOf(text, false); + return instance.IsSubsequenceOf(text, caseSensitive: false); } // <summary> @@ -662,7 +666,7 @@ namespace Godot // </summary> public static bool MatchN(this string instance, string expr) { - return instance.ExprMatch(expr, false); + return instance.ExprMatch(expr, caseSensitive: false); } // <summary> @@ -692,7 +696,7 @@ namespace Godot // </summary> public static int NocasecmpTo(this string instance, string to) { - return instance.CompareTo(to, false); + return instance.CompareTo(to, caseSensitive: false); } // <summary> @@ -928,7 +932,7 @@ namespace Godot while (true) { - int end = instance.Find(divisor, from); + int end = instance.Find(divisor, from, caseSensitive: true); if (end < 0) end = len; if (allowEmpty || end > from) diff --git a/modules/mono/glue/Managed/Files/Transform.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs index 0b84050f07..0b84050f07 100644 --- a/modules/mono/glue/Managed/Files/Transform.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs diff --git a/modules/mono/glue/Managed/Files/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index 77ea3e5830..77ea3e5830 100644 --- a/modules/mono/glue/Managed/Files/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs diff --git a/modules/mono/glue/Managed/Files/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index f92453f546..f92453f546 100644 --- a/modules/mono/glue/Managed/Files/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs diff --git a/modules/mono/glue/Managed/Files/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 025b09199f..fded34002d 100644 --- a/modules/mono/glue/Managed/Files/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -255,7 +255,7 @@ namespace Godot { #if DEBUG if (!n.IsNormalized()) - throw new ArgumentException(String.Format("{0} is not normalized", n), nameof(n)); + throw new ArgumentException("Argument is not normalized", nameof(n)); #endif return 2.0f * n * Dot(n) - this; } @@ -296,6 +296,10 @@ namespace Godot public Vector3 Slerp(Vector3 b, real_t t) { +#if DEBUG + if (!IsNormalized()) + throw new InvalidOperationException("Vector3 is not normalized"); +#endif real_t theta = AngleTo(b); return Rotated(Cross(b), theta * t); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj new file mode 100644 index 0000000000..5419cd06e6 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{AEBF0036-DA76-4341-B651-A3F2856AB2FA}</ProjectGuid> + <OutputType>Library</OutputType> + <OutputPath>bin/$(Configuration)</OutputPath> + <RootNamespace>Godot</RootNamespace> + <AssemblyName>GodotSharp</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <DocumentationFile>$(OutputPath)/$(AssemblyName).xml</DocumentationFile> + <BaseIntermediateOutputPath>obj</BaseIntermediateOutputPath> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>portable</DebugType> + <Optimize>false</Optimize> + <DefineConstants>$(GodotDefineConstants);GODOT;DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>portable</DebugType> + <Optimize>true</Optimize> + <DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Core\AABB.cs" /> + <Compile Include="Core\Array.cs" /> + <Compile Include="Core\Attributes\ExportAttribute.cs" /> + <Compile Include="Core\Attributes\GodotMethodAttribute.cs" /> + <Compile Include="Core\Attributes\RPCAttributes.cs" /> + <Compile Include="Core\Attributes\SignalAttribute.cs" /> + <Compile Include="Core\Attributes\ToolAttribute.cs" /> + <Compile Include="Core\Basis.cs" /> + <Compile Include="Core\Color.cs" /> + <Compile Include="Core\Colors.cs" /> + <Compile Include="Core\DebuggingUtils.cs" /> + <Compile Include="Core\Dictionary.cs" /> + <Compile Include="Core\Dispatcher.cs" /> + <Compile Include="Core\DynamicObject.cs" /> + <Compile Include="Core\Extensions\NodeExtensions.cs" /> + <Compile Include="Core\Extensions\ObjectExtensions.cs" /> + <Compile Include="Core\Extensions\ResourceLoaderExtensions.cs" /> + <Compile Include="Core\GD.cs" /> + <Compile Include="Core\GodotSynchronizationContext.cs" /> + <Compile Include="Core\GodotTaskScheduler.cs" /> + <Compile Include="Core\GodotTraceListener.cs" /> + <Compile Include="Core\Interfaces\IAwaitable.cs" /> + <Compile Include="Core\Interfaces\IAwaiter.cs" /> + <Compile Include="Core\Interfaces\ISerializationListener.cs" /> + <Compile Include="Core\MarshalUtils.cs" /> + <Compile Include="Core\Mathf.cs" /> + <Compile Include="Core\MathfEx.cs" /> + <Compile Include="Core\NodePath.cs" /> + <Compile Include="Core\Object.base.cs" /> + <Compile Include="Core\Plane.cs" /> + <Compile Include="Core\Quat.cs" /> + <Compile Include="Core\Rect2.cs" /> + <Compile Include="Core\RID.cs" /> + <Compile Include="Core\SignalAwaiter.cs" /> + <Compile Include="Core\StringExtensions.cs" /> + <Compile Include="Core\Transform.cs" /> + <Compile Include="Core\Transform2D.cs" /> + <Compile Include="Core\Vector2.cs" /> + <Compile Include="Core\Vector3.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <!-- + We import a props file with auto-generated includes. This works well with Rider. + However, Visual Studio and MonoDevelop won't list them in the solution explorer. + We can't use wildcards as there may be undesired old files still hanging around. + Fortunately code completion, go to definition and such still work. + --> + <Import Project="Generated\GeneratedIncludes.props" /> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> +</Project> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Properties/AssemblyInfo.cs b/modules/mono/glue/GodotSharp/GodotSharp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f84e0183f6 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("GodotSharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] +[assembly: InternalsVisibleTo("GodotSharpEditor")] diff --git a/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj b/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj new file mode 100644 index 0000000000..22853797c1 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{8FBEC238-D944-4074-8548-B3B524305905}</ProjectGuid> + <OutputType>Library</OutputType> + <OutputPath>bin/$(Configuration)</OutputPath> + <RootNamespace>Godot</RootNamespace> + <AssemblyName>GodotSharpEditor</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <DocumentationFile>$(OutputPath)/$(AssemblyName).xml</DocumentationFile> + <BaseIntermediateOutputPath>obj</BaseIntermediateOutputPath> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>portable</DebugType> + <Optimize>false</Optimize> + <DefineConstants>$(GodotDefineConstants);GODOT;DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>portable</DebugType> + <Optimize>true</Optimize> + <DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="Generated\GeneratedIncludes.props" /> + <ItemGroup> + <ProjectReference Include="..\GodotSharp\GodotSharp.csproj"> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> +</Project> diff --git a/modules/mono/glue/Managed/Properties/AssemblyInfo.cs b/modules/mono/glue/GodotSharp/GodotSharpEditor/Properties/AssemblyInfo.cs index 77b3774e81..3684b7a3cb 100644 --- a/modules/mono/glue/Managed/Properties/AssemblyInfo.cs +++ b/modules/mono/glue/GodotSharp/GodotSharpEditor/Properties/AssemblyInfo.cs @@ -1,10 +1,9 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Reflection; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. -[assembly: AssemblyTitle("Managed")] +[assembly: AssemblyTitle("GodotSharpEditor")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] diff --git a/modules/mono/glue/Managed/.gitignore b/modules/mono/glue/Managed/.gitignore deleted file mode 100644 index 146421cac8..0000000000 --- a/modules/mono/glue/Managed/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Generated Godot API solution folder -Generated diff --git a/modules/mono/glue/Managed/IgnoredFiles/Enums.cs b/modules/mono/glue/Managed/IgnoredFiles/Enums.cs deleted file mode 100644 index 05f1abcf93..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/Enums.cs +++ /dev/null @@ -1,21 +0,0 @@ - -namespace Godot -{ - public enum Margin - { - Left = 0, - Top = 1, - Right = 2, - Bottom = 3 - } - - public enum Error - { - Ok = 0 - } - - public enum PropertyHint - { - None = 0 - } -} diff --git a/modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs b/modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs deleted file mode 100644 index 83504fe49f..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace Godot -{ - public partial class FuncRef - { - public void SetInstance(Object instance) - { - throw new NotImplementedException(); - } - - public void SetFunction(string name) - { - throw new NotImplementedException(); - } - } -} diff --git a/modules/mono/glue/Managed/IgnoredFiles/Node.cs b/modules/mono/glue/Managed/IgnoredFiles/Node.cs deleted file mode 100644 index cff61b1e0b..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/Node.cs +++ /dev/null @@ -1,29 +0,0 @@ - -using System; - -namespace Godot -{ - public partial class Node - { - public Node GetChild(int idx) - { - throw new NotImplementedException(); - } - - public Node GetNode(NodePath path) - { - throw new NotImplementedException(); - } - - public Node Owner - { - get => throw new NotImplementedException(); - set => throw new NotImplementedException(); - } - - public Node GetParent() - { - throw new NotImplementedException(); - } - } -} diff --git a/modules/mono/glue/Managed/IgnoredFiles/Resource.cs b/modules/mono/glue/Managed/IgnoredFiles/Resource.cs deleted file mode 100644 index cc0a5555b1..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/Resource.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Godot -{ - public partial class Resource - { - - } -} diff --git a/modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs b/modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs deleted file mode 100644 index 6461d35146..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Godot -{ - public partial class ResourceLoader - { - public static Resource Load(string path, string typeHint = "", bool pNoCache = false) - { - throw new NotImplementedException(); - } - } -} diff --git a/modules/mono/glue/Managed/IgnoredFiles/Variant.cs b/modules/mono/glue/Managed/IgnoredFiles/Variant.cs deleted file mode 100644 index 802140b062..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/Variant.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace Godot -{ - public static class Variant - { - public enum Type - { - - } - } -} diff --git a/modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs b/modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs deleted file mode 100644 index 1498b7836b..0000000000 --- a/modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Godot -{ - public partial class WeakRef - { - - } -} diff --git a/modules/mono/glue/Managed/Managed.csproj b/modules/mono/glue/Managed/Managed.csproj deleted file mode 100644 index c8eca71199..0000000000 --- a/modules/mono/glue/Managed/Managed.csproj +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">x86</Platform> - <ProjectGuid>{DAA3DEF8-5112-407C-A5E5-6C608CF5F955}</ProjectGuid> - <OutputType>Library</OutputType> - <RootNamespace>Managed</RootNamespace> - <AssemblyName>Managed</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <LangVersion>7</LangVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>portable</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug</OutputPath> - <DefineConstants>DEBUG;</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <ExternalConsole>true</ExternalConsole> - <PlatformTarget>x86</PlatformTarget> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> - <Optimize>true</Optimize> - <OutputPath>bin\Release</OutputPath> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <ExternalConsole>true</ExternalConsole> - <PlatformTarget>x86</PlatformTarget> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Files\**\*.cs" /> - <Compile Include="IgnoredFiles\**\*.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -</Project>
\ No newline at end of file diff --git a/modules/mono/glue/Managed/Managed.sln b/modules/mono/glue/Managed/Managed.sln deleted file mode 100644 index 61ddde0fb7..0000000000 --- a/modules/mono/glue/Managed/Managed.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managed", "Managed.csproj", "{DAA3DEF8-5112-407C-A5E5-6C608CF5F955}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Debug|x86.ActiveCfg = Debug|x86 - {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Debug|x86.Build.0 = Debug|x86 - {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Release|x86.ActiveCfg = Release|x86 - {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Release|x86.Build.0 = Release|x86 - EndGlobalSection -EndGlobal diff --git a/modules/mono/glue/Managed/README.md b/modules/mono/glue/Managed/README.md deleted file mode 100644 index 65e63cae37..0000000000 --- a/modules/mono/glue/Managed/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The directory `Files` contains C# files from the core assembly project that are not part of the generated API. Any file with the `.cs` extension in this directory will be added to the core assembly project. - -A dummy solution and project is provided to get tooling help while editing these files, like code completion and name refactoring. - -The directory `IgnoredFiles` contains C# files that are needed to build the dummy project but must not be added to the core assembly project. They contain placeholders for the declarations that are part of the generated API. diff --git a/modules/mono/glue/arguments_vector.h b/modules/mono/glue/arguments_vector.h index 8c0f308c15..aeb466ba72 100644 --- a/modules/mono/glue/arguments_vector.h +++ b/modules/mono/glue/arguments_vector.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 2488f78350..02246b2f2f 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -108,6 +108,7 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea // Unsafe refcount decrement. The managed instance also counts as a reference. // See: CSharpLanguage::alloc_instance_binding_data(Object *p_object) + CSharpLanguage::get_singleton()->pre_unsafe_unreference(ref); if (ref->unreference()) { memdelete(ref); } else { diff --git a/modules/mono/glue/base_object_glue.h b/modules/mono/glue/base_object_glue.h index e4ac9fb99d..22532dcff9 100644 --- a/modules/mono/glue/base_object_glue.h +++ b/modules/mono/glue/base_object_glue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index bfb7b0f775..b7fa7fcab2 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -103,6 +103,10 @@ void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int array_index) { } } +Array *godot_icall_Array_Duplicate(Array *ptr, MonoBoolean deep) { + return memnew(Array(ptr->duplicate(deep))); +} + int godot_icall_Array_IndexOf(Array *ptr, MonoObject *item) { return ptr->find(GDMonoMarshal::mono_object_to_variant(item)); } @@ -224,6 +228,10 @@ MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key) return ptr->has(GDMonoMarshal::mono_object_to_variant(key)); } +Dictionary *godot_icall_Dictionary_Duplicate(Dictionary *ptr, MonoBoolean deep) { + return memnew(Dictionary(ptr->duplicate(deep))); +} + MonoBoolean godot_icall_Dictionary_RemoveKey(Dictionary *ptr, MonoObject *key) { return ptr->erase(GDMonoMarshal::mono_object_to_variant(key)); } @@ -284,6 +292,7 @@ void godot_register_collections_icalls() { mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Clear", (void *)godot_icall_Array_Clear); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Contains", (void *)godot_icall_Array_Contains); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_CopyTo", (void *)godot_icall_Array_CopyTo); + mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Duplicate", (void *)godot_icall_Array_Duplicate); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_IndexOf", (void *)godot_icall_Array_IndexOf); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Insert", (void *)godot_icall_Array_Insert); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Remove", (void *)godot_icall_Array_Remove); @@ -304,6 +313,7 @@ void godot_register_collections_icalls() { mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Clear", (void *)godot_icall_Dictionary_Clear); mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Contains", (void *)godot_icall_Dictionary_Contains); mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_ContainsKey", (void *)godot_icall_Dictionary_ContainsKey); + mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Duplicate", (void *)godot_icall_Dictionary_Duplicate); mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_RemoveKey", (void *)godot_icall_Dictionary_RemoveKey); mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Remove", (void *)godot_icall_Dictionary_Remove); mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_TryGetValue", (void *)godot_icall_Dictionary_TryGetValue); diff --git a/modules/mono/glue/collections_glue.h b/modules/mono/glue/collections_glue.h index 54ed42c3b6..f8351a1fc7 100644 --- a/modules/mono/glue/collections_glue.h +++ b/modules/mono/glue/collections_glue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -59,6 +59,8 @@ MonoBoolean godot_icall_Array_Contains(Array *ptr, MonoObject *item); void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int array_index); +Array *godot_icall_Array_Duplicate(Array *ptr, MonoBoolean deep); + int godot_icall_Array_IndexOf(Array *ptr, MonoObject *item); void godot_icall_Array_Insert(Array *ptr, int index, MonoObject *item); @@ -99,6 +101,8 @@ MonoBoolean godot_icall_Dictionary_Contains(Dictionary *ptr, MonoObject *key, Mo MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key); +Dictionary *godot_icall_Dictionary_Duplicate(Dictionary *ptr, MonoBoolean deep); + MonoBoolean godot_icall_Dictionary_RemoveKey(Dictionary *ptr, MonoObject *key); MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, MonoObject *value); diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp index 1381d79e2e..17483c4457 100644 --- a/modules/mono/glue/gd_glue.cpp +++ b/modules/mono/glue/gd_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -71,48 +71,114 @@ MonoObject *godot_icall_GD_instance_from_id(uint64_t p_instance_id) { } void godot_icall_GD_print(MonoArray *p_what) { - Array what = GDMonoMarshal::mono_array_to_Array(p_what); String str; - for (int i = 0; i < what.size(); i++) - str += what[i].operator String(); + int length = mono_array_length(p_what); + + for (int i = 0; i < length; i++) { + MonoObject *elem = mono_array_get(p_what, MonoObject *, i); + + MonoException *exc = NULL; + String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); + + if (exc) { + GDMonoUtils::set_pending_exception(exc); + return; + } + + str += elem_str; + } + print_line(str); } void godot_icall_GD_printerr(MonoArray *p_what) { - Array what = GDMonoMarshal::mono_array_to_Array(p_what); + String str; - for (int i = 0; i < what.size(); i++) - str += what[i].operator String(); - OS::get_singleton()->printerr("%s\n", str.utf8().get_data()); + int length = mono_array_length(p_what); + + for (int i = 0; i < length; i++) { + MonoObject *elem = mono_array_get(p_what, MonoObject *, i); + + MonoException *exc = NULL; + String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); + + if (exc) { + GDMonoUtils::set_pending_exception(exc); + return; + } + + str += elem_str; + } + + print_error(str); } void godot_icall_GD_printraw(MonoArray *p_what) { - Array what = GDMonoMarshal::mono_array_to_Array(p_what); String str; - for (int i = 0; i < what.size(); i++) - str += what[i].operator String(); + int length = mono_array_length(p_what); + + for (int i = 0; i < length; i++) { + MonoObject *elem = mono_array_get(p_what, MonoObject *, i); + + MonoException *exc = NULL; + String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); + + if (exc) { + GDMonoUtils::set_pending_exception(exc); + return; + } + + str += elem_str; + } + OS::get_singleton()->print("%s", str.utf8().get_data()); } void godot_icall_GD_prints(MonoArray *p_what) { - Array what = GDMonoMarshal::mono_array_to_Array(p_what); String str; - for (int i = 0; i < what.size(); i++) { + int length = mono_array_length(p_what); + + for (int i = 0; i < length; i++) { + MonoObject *elem = mono_array_get(p_what, MonoObject *, i); + + MonoException *exc = NULL; + String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); + + if (exc) { + GDMonoUtils::set_pending_exception(exc); + return; + } + if (i) str += " "; - str += what[i].operator String(); + + str += elem_str; } + print_line(str); } void godot_icall_GD_printt(MonoArray *p_what) { - Array what = GDMonoMarshal::mono_array_to_Array(p_what); String str; - for (int i = 0; i < what.size(); i++) { + int length = mono_array_length(p_what); + + for (int i = 0; i < length; i++) { + MonoObject *elem = mono_array_get(p_what, MonoObject *, i); + + MonoException *exc = NULL; + String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); + + if (exc) { + GDMonoUtils::set_pending_exception(exc); + return; + } + if (i) str += "\t"; - str += what[i].operator String(); + + str += elem_str; } + print_line(str); } @@ -169,7 +235,7 @@ MonoObject *godot_icall_GD_str2var(MonoString *p_str) { Error err = VariantParser::parse(&ss, ret, errs, line); if (err != OK) { String err_str = "Parse error at line " + itos(line) + ": " + errs + "."; - ERR_PRINTS(err_str); + ERR_PRINT(err_str); ret = err_str; } @@ -181,11 +247,11 @@ MonoBoolean godot_icall_GD_type_exists(MonoString *p_type) { } void godot_icall_GD_pusherror(MonoString *p_str) { - ERR_PRINTS(GDMonoMarshal::mono_string_to_godot(p_str)); + ERR_PRINT(GDMonoMarshal::mono_string_to_godot(p_str)); } void godot_icall_GD_pushwarning(MonoString *p_str) { - WARN_PRINTS(GDMonoMarshal::mono_string_to_godot(p_str)); + WARN_PRINT(GDMonoMarshal::mono_string_to_godot(p_str)); } MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_objects) { diff --git a/modules/mono/glue/gd_glue.h b/modules/mono/glue/gd_glue.h index a34c0bc50f..f00e2efc5d 100644 --- a/modules/mono/glue/gd_glue.h +++ b/modules/mono/glue/gd_glue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h index 1836130b76..758b71f719 100644 --- a/modules/mono/glue/glue_header.h +++ b/modules/mono/glue/glue_header.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/nodepath_glue.cpp b/modules/mono/glue/nodepath_glue.cpp index 2edc43af8d..e413f404d8 100644 --- a/modules/mono/glue/nodepath_glue.cpp +++ b/modules/mono/glue/nodepath_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/nodepath_glue.h b/modules/mono/glue/nodepath_glue.h index 2192444336..727679c278 100644 --- a/modules/mono/glue/nodepath_glue.h +++ b/modules/mono/glue/nodepath_glue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/rid_glue.cpp b/modules/mono/glue/rid_glue.cpp index 6a9810d0d4..66a49d8fec 100644 --- a/modules/mono/glue/rid_glue.cpp +++ b/modules/mono/glue/rid_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/rid_glue.h b/modules/mono/glue/rid_glue.h index 4b593e8a95..506d715451 100644 --- a/modules/mono/glue/rid_glue.h +++ b/modules/mono/glue/rid_glue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/string_glue.cpp b/modules/mono/glue/string_glue.cpp index e9373fb486..e407a70db9 100644 --- a/modules/mono/glue/string_glue.cpp +++ b/modules/mono/glue/string_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/mono/glue/string_glue.h b/modules/mono/glue/string_glue.h index c9052edd40..a5e833ba61 100644 --- a/modules/mono/glue/string_glue.h +++ b/modules/mono/glue/string_glue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |