summaryrefslogtreecommitdiff
path: root/modules/mono
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs5
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs18
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs16
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs2
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs12
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs16
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs70
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs10
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs10
-rw-r--r--modules/mono/signal_awaiter_utils.cpp2
11 files changed, 88 insertions, 75 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs
index 7aaadb27be..98ca534c66 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs
@@ -39,6 +39,11 @@ namespace Godot.SourceGenerators
for (int i = 0; i < typeArgListSyntax.Arguments.Count; i++)
{
var typeSyntax = typeArgListSyntax.Arguments[i];
+
+ // Ignore omitted type arguments, e.g.: List<>, Dictionary<,>, etc
+ if (typeSyntax is OmittedTypeArgumentSyntax)
+ continue;
+
var typeSymbol = sm.GetSymbolInfo(typeSyntax).Symbol as ITypeSymbol;
Debug.Assert(typeSymbol != null);
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs
index 5ac4f4a47e..1ee31eb1a9 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs
@@ -133,7 +133,9 @@ namespace Godot.SourceGenerators
.Distinct(new MethodOverloadEqualityComparer())
.ToArray();
- source.Append(" private partial class GodotInternal {\n");
+ source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
+
+ source.Append($" public new class MethodName : {symbol.BaseType.FullQualifiedName()}.MethodName {{\n");
// Generate cached StringNames for methods and properties, for fast lookup
@@ -144,7 +146,7 @@ namespace Godot.SourceGenerators
foreach (string methodName in distinctMethodNames)
{
- source.Append(" public static readonly StringName MethodName_");
+ source.Append(" public new static readonly StringName ");
source.Append(methodName);
source.Append(" = \"");
source.Append(methodName);
@@ -157,8 +159,6 @@ namespace Godot.SourceGenerators
if (godotClassMethods.Length > 0)
{
- source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
-
const string listType = "System.Collections.Generic.List<global::Godot.Bridge.MethodInfo>";
source.Append(" internal new static ")
@@ -179,10 +179,10 @@ namespace Godot.SourceGenerators
source.Append(" return methods;\n");
source.Append(" }\n");
-
- source.Append("#pragma warning restore CS0109\n");
}
+ source.Append("#pragma warning restore CS0109\n");
+
// Generate InvokeGodotClassMethod
if (godotClassMethods.Length > 0)
@@ -242,7 +242,7 @@ namespace Godot.SourceGenerators
private static void AppendMethodInfo(StringBuilder source, MethodInfo methodInfo)
{
- source.Append(" methods.Add(new(name: GodotInternal.MethodName_")
+ source.Append(" methods.Add(new(name: MethodName.")
.Append(methodInfo.Name)
.Append(", returnVal: ");
@@ -350,7 +350,7 @@ namespace Godot.SourceGenerators
source.Append(" ");
if (!isFirstEntry)
source.Append("else ");
- source.Append("if (method == GodotInternal.MethodName_");
+ source.Append("if (method == MethodName.");
source.Append(methodName);
source.Append(") {\n return true;\n }\n");
}
@@ -362,7 +362,7 @@ namespace Godot.SourceGenerators
{
string methodName = method.Method.Name;
- source.Append(" if (method == GodotInternal.MethodName_");
+ source.Append(" if (method == MethodName.");
source.Append(methodName);
source.Append(" && argCount == ");
source.Append(method.ParamTypes.Length);
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
index fc46d82dff..b331e2e794 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
@@ -122,14 +122,16 @@ namespace Godot.SourceGenerators
var godotClassProperties = propertySymbols.WhereIsGodotCompatibleType(typeCache).ToArray();
var godotClassFields = fieldSymbols.WhereIsGodotCompatibleType(typeCache).ToArray();
- source.Append(" private partial class GodotInternal {\n");
+ source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
+
+ source.Append($" public new class PropertyName : {symbol.BaseType.FullQualifiedName()}.PropertyName {{\n");
// Generate cached StringNames for methods and properties, for fast lookup
foreach (var property in godotClassProperties)
{
string propertyName = property.PropertySymbol.Name;
- source.Append(" public static readonly StringName PropName_");
+ source.Append(" public new static readonly StringName ");
source.Append(propertyName);
source.Append(" = \"");
source.Append(propertyName);
@@ -139,7 +141,7 @@ namespace Godot.SourceGenerators
foreach (var field in godotClassFields)
{
string fieldName = field.FieldSymbol.Name;
- source.Append(" public static readonly StringName PropName_");
+ source.Append(" public new static readonly StringName ");
source.Append(fieldName);
source.Append(" = \"");
source.Append(fieldName);
@@ -214,8 +216,6 @@ namespace Godot.SourceGenerators
// Generate GetGodotPropertyList
- source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
-
string dictionaryType = "System.Collections.Generic.List<global::Godot.Bridge.PropertyInfo>";
source.Append(" internal new static ")
@@ -289,7 +289,7 @@ namespace Godot.SourceGenerators
if (!isFirstEntry)
source.Append("else ");
- source.Append("if (name == GodotInternal.PropName_")
+ source.Append("if (name == PropertyName.")
.Append(propertyMemberName)
.Append(") {\n")
.Append(" ")
@@ -313,7 +313,7 @@ namespace Godot.SourceGenerators
if (!isFirstEntry)
source.Append("else ");
- source.Append("if (name == GodotInternal.PropName_")
+ source.Append("if (name == PropertyName.")
.Append(propertyMemberName)
.Append(") {\n")
.Append(" value = ")
@@ -342,7 +342,7 @@ namespace Godot.SourceGenerators
{
source.Append(" properties.Add(new(type: (Godot.Variant.Type)")
.Append((int)propertyInfo.Type)
- .Append(", name: GodotInternal.PropName_")
+ .Append(", name: PropertyName.")
.Append(propertyInfo.Name)
.Append(", hint: (Godot.PropertyHint)")
.Append((int)propertyInfo.Hint)
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs
index c7745391d0..65dadcb801 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs
@@ -243,7 +243,7 @@ namespace Godot.SourceGenerators
source.Append(" = ");
source.Append(exportedMember.Value ?? "default");
source.Append(";\n");
- source.Append(" values.Add(GodotInternal.PropName_");
+ source.Append(" values.Add(PropertyName.");
source.Append(exportedMember.Name);
source.Append(", ");
source.Append(defaultValueLocalName);
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs
index 39a99ff8ba..a40220565f 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs
@@ -159,7 +159,7 @@ namespace Godot.SourceGenerators
{
string propertyName = property.PropertySymbol.Name;
- source.Append(" info.AddProperty(GodotInternal.PropName_")
+ source.Append(" info.AddProperty(PropertyName.")
.Append(propertyName)
.Append(", ")
.AppendManagedToVariantExpr(string.Concat("this.", propertyName), property.Type)
@@ -172,7 +172,7 @@ namespace Godot.SourceGenerators
{
string fieldName = field.FieldSymbol.Name;
- source.Append(" info.AddProperty(GodotInternal.PropName_")
+ source.Append(" info.AddProperty(PropertyName.")
.Append(fieldName)
.Append(", ")
.AppendManagedToVariantExpr(string.Concat("this.", fieldName), field.Type)
@@ -185,7 +185,7 @@ namespace Godot.SourceGenerators
{
string signalName = signalDelegate.Name;
- source.Append(" info.AddSignalEventDelegate(GodotInternal.SignalName_")
+ source.Append(" info.AddSignalEventDelegate(SignalName.")
.Append(signalName)
.Append(", this.backing_")
.Append(signalName)
@@ -204,7 +204,7 @@ namespace Godot.SourceGenerators
{
string propertyName = property.PropertySymbol.Name;
- source.Append(" if (info.TryGetProperty(GodotInternal.PropName_")
+ source.Append(" if (info.TryGetProperty(PropertyName.")
.Append(propertyName)
.Append(", out var _value_")
.Append(propertyName)
@@ -223,7 +223,7 @@ namespace Godot.SourceGenerators
{
string fieldName = field.FieldSymbol.Name;
- source.Append(" if (info.TryGetProperty(GodotInternal.PropName_")
+ source.Append(" if (info.TryGetProperty(PropertyName.")
.Append(fieldName)
.Append(", out var _value_")
.Append(fieldName)
@@ -245,7 +245,7 @@ namespace Godot.SourceGenerators
source.Append(" if (info.TryGetSignalEventDelegate<")
.Append(signalDelegateQualifiedName)
- .Append(">(GodotInternal.SignalName_")
+ .Append(">(SignalName.")
.Append(signalName)
.Append(", out var _value_")
.Append(signalName)
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs
index 6b06f10db1..1df41a905b 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs
@@ -173,14 +173,16 @@ namespace Godot.SourceGenerators
godotSignalDelegates.Add(new(signalName, signalDelegateSymbol, invokeMethodData.Value));
}
- source.Append(" private partial class GodotInternal {\n");
+ source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
+
+ source.Append($" public new class SignalName : {symbol.BaseType.FullQualifiedName()}.SignalName {{\n");
// Generate cached StringNames for methods and properties, for fast lookup
foreach (var signalDelegate in godotSignalDelegates)
{
string signalName = signalDelegate.Name;
- source.Append(" public static readonly StringName SignalName_");
+ source.Append(" public new static readonly StringName ");
source.Append(signalName);
source.Append(" = \"");
source.Append(signalName);
@@ -193,8 +195,6 @@ namespace Godot.SourceGenerators
if (godotSignalDelegates.Count > 0)
{
- source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
-
const string listType = "System.Collections.Generic.List<global::Godot.Bridge.MethodInfo>";
source.Append(" internal new static ")
@@ -215,10 +215,10 @@ namespace Godot.SourceGenerators
source.Append(" return signals;\n");
source.Append(" }\n");
-
- source.Append("#pragma warning restore CS0109\n");
}
+ source.Append("#pragma warning restore CS0109\n");
+
// Generate signal event
foreach (var signalDelegate in godotSignalDelegates)
@@ -291,7 +291,7 @@ namespace Godot.SourceGenerators
private static void AppendMethodInfo(StringBuilder source, MethodInfo methodInfo)
{
- source.Append(" signals.Add(new(name: GodotInternal.SignalName_")
+ source.Append(" signals.Add(new(name: SignalName.")
.Append(methodInfo.Name)
.Append(", returnVal: ");
@@ -400,7 +400,7 @@ namespace Godot.SourceGenerators
string signalName = signal.Name;
var invokeMethodData = signal.InvokeMethodData;
- source.Append(" if (signal == GodotInternal.SignalName_");
+ source.Append(" if (signal == SignalName.");
source.Append(signalName);
source.Append(" && argCount == ");
source.Append(invokeMethodData.ParamTypes.Length);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs
index 17f680361d..d8a6644a66 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs
@@ -133,15 +133,6 @@ namespace Godot
}
/// <summary>
- /// Returns the area of the <see cref="AABB"/>.
- /// </summary>
- /// <returns>The area.</returns>
- public real_t GetArea()
- {
- return _size.x * _size.y * _size.z;
- }
-
- /// <summary>
/// Gets the position of one of the 8 endpoints of the <see cref="AABB"/>.
/// </summary>
/// <param name="idx">Which endpoint to get.</param>
@@ -321,6 +312,15 @@ namespace Godot
}
/// <summary>
+ /// Returns the volume of the <see cref="AABB"/>.
+ /// </summary>
+ /// <returns>The volume.</returns>
+ public real_t GetVolume()
+ {
+ return _size.x * _size.y * _size.z;
+ }
+
+ /// <summary>
/// Returns a copy of the <see cref="AABB"/> grown a given amount of units towards all the sides.
/// </summary>
/// <param name="by">The amount to grow by.</param>
@@ -340,30 +340,6 @@ namespace Godot
}
/// <summary>
- /// Returns <see langword="true"/> if the <see cref="AABB"/> is flat or empty,
- /// or <see langword="false"/> otherwise.
- /// </summary>
- /// <returns>
- /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has area.
- /// </returns>
- public bool HasNoArea()
- {
- return _size.x <= 0f || _size.y <= 0f || _size.z <= 0f;
- }
-
- /// <summary>
- /// Returns <see langword="true"/> if the <see cref="AABB"/> has no surface (no size),
- /// or <see langword="false"/> otherwise.
- /// </summary>
- /// <returns>
- /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has area.
- /// </returns>
- public bool HasNoSurface()
- {
- return _size.x <= 0f && _size.y <= 0f && _size.z <= 0f;
- }
-
- /// <summary>
/// Returns <see langword="true"/> if the <see cref="AABB"/> contains a point,
/// or <see langword="false"/> otherwise.
/// </summary>
@@ -390,6 +366,34 @@ namespace Godot
}
/// <summary>
+ /// Returns <see langword="true"/> if the <see cref="AABB"/>
+ /// has a surface or a length, and <see langword="false"/>
+ /// if the <see cref="AABB"/> is empty (all components
+ /// of <see cref="Size"/> are zero or negative).
+ /// </summary>
+ /// <returns>
+ /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has surface.
+ /// </returns>
+ public bool HasSurface()
+ {
+ return _size.x > 0.0f || _size.y > 0.0f || _size.z > 0.0f;
+ }
+
+ /// <summary>
+ /// Returns <see langword="true"/> if the <see cref="AABB"/> has
+ /// area, and <see langword="false"/> if the <see cref="AABB"/>
+ /// is linear, empty, or has a negative <see cref="Size"/>.
+ /// See also <see cref="GetVolume"/>.
+ /// </summary>
+ /// <returns>
+ /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has volume.
+ /// </returns>
+ public bool HasVolume()
+ {
+ return _size.x > 0.0f && _size.y > 0.0f && _size.z > 0.0f;
+ }
+
+ /// <summary>
/// Returns the intersection of this <see cref="AABB"/> and <paramref name="with"/>.
/// </summary>
/// <param name="with">The other <see cref="AABB"/>.</param>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
index b30012d214..f2667c6807 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
@@ -634,7 +634,7 @@ namespace Godot
/// <param name="outFrom">The start value for the output interpolation.</param>
/// <param name="outTo">The destination value for the output interpolation.</param>
/// <returns>The resulting mapped value mapped.</returns>
- public static real_t RangeLerp(real_t value, real_t inFrom, real_t inTo, real_t outFrom, real_t outTo)
+ public static real_t Remap(real_t value, real_t inFrom, real_t inTo, real_t outFrom, real_t outTo)
{
return Lerp(outFrom, outTo, InverseLerp(inFrom, inTo, value));
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
index 0b475fec19..e80d75dacf 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
@@ -234,15 +234,17 @@ namespace Godot
}
/// <summary>
- /// Returns <see langword="true"/> if the <see cref="Rect2"/> is flat or empty,
- /// or <see langword="false"/> otherwise.
+ /// Returns <see langword="true"/> if the <see cref="Rect2"/> has
+ /// area, and <see langword="false"/> if the <see cref="Rect2"/>
+ /// is linear, empty, or has a negative <see cref="Size"/>.
+ /// See also <see cref="GetArea"/>.
/// </summary>
/// <returns>
/// A <see langword="bool"/> for whether or not the <see cref="Rect2"/> has area.
/// </returns>
- public bool HasNoArea()
+ public bool HasArea()
{
- return _size.x <= 0 || _size.y <= 0;
+ return _size.x > 0.0f && _size.y > 0.0f;
}
/// <summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs
index 8a2a98d6ee..b2768476cc 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs
@@ -236,15 +236,17 @@ namespace Godot
}
/// <summary>
- /// Returns <see langword="true"/> if the <see cref="Rect2i"/> is flat or empty,
- /// or <see langword="false"/> otherwise.
+ /// Returns <see langword="true"/> if the <see cref="Rect2i"/> has
+ /// area, and <see langword="false"/> if the <see cref="Rect2i"/>
+ /// is linear, empty, or has a negative <see cref="Size"/>.
+ /// See also <see cref="GetArea"/>.
/// </summary>
/// <returns>
/// A <see langword="bool"/> for whether or not the <see cref="Rect2i"/> has area.
/// </returns>
- public bool HasNoArea()
+ public bool HasArea()
{
- return _size.x <= 0 || _size.y <= 0;
+ return _size.x > 0 && _size.y > 0;
}
/// <summary>
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index 55d2138674..66c9eca616 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -42,7 +42,7 @@ Error gd_mono_connect_signal_awaiter(Object *p_source, const StringName &p_signa
SignalAwaiterCallable *awaiter_callable = memnew(SignalAwaiterCallable(p_target, awaiter_handle, p_signal));
Callable callable = Callable(awaiter_callable);
- return p_source->connect(p_signal, callable, Object::CONNECT_ONESHOT);
+ return p_source->connect(p_signal, callable, Object::CONNECT_ONE_SHOT);
}
bool SignalAwaiterCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) {