summaryrefslogtreecommitdiff
path: root/modules/mono/glue
diff options
context:
space:
mode:
authorIgnacio Roldán Etcheverry <neikeq@users.noreply.github.com>2022-11-03 14:46:26 +0100
committerGitHub <noreply@github.com>2022-11-03 14:46:26 +0100
commitc0de8d32d51d579e6dc1a5aac3fbcd6c7104eb61 (patch)
tree069df59861c86422dd8814c5bc2eb87687a5d376 /modules/mono/glue
parent879aac9db44c90000197ef02ae048c71f7500a2b (diff)
parent99260d972f2459cd26509db405565904a7573648 (diff)
Merge pull request #68092 from raulsntos/dotnet/variant-from-array
C#: Add implicit conversion from arrays to Variant
Diffstat (limited to 'modules/mono/glue')
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Variant.cs56
1 files changed, 52 insertions, 4 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Variant.cs b/modules/mono/glue/GodotSharp/GodotSharp/Variant.cs
index 1f37694995..d354509dbf 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Variant.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Variant.cs
@@ -766,6 +766,58 @@ public partial struct Variant : IDisposable
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSignalInfo(from));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(byte[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(int[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(long[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(float[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(double[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(string[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(Vector2[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(Vector3[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(Color[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(Godot.Object[] from) =>
+ CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfGodotObject(from));
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(StringName[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(NodePath[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(RID[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Variant(Span<byte> from) =>
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromPackedByteArray(from));
@@ -802,10 +854,6 @@ public partial struct Variant : IDisposable
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromPackedColorArray(from));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static implicit operator Variant(Godot.Object[] from) =>
- CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfGodotObject(from));
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Variant(Span<StringName> from) =>
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromSystemArrayOfStringName(from));