diff options
| author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-09-27 00:38:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-27 00:38:39 +0200 |
| commit | 2e877031369c35c918c014a7ae3688b6f555e5bd (patch) | |
| tree | c3dda8c3b7fc74e5a33eef982de88f74313c843b /modules/mono/glue/Managed/Files/Array.cs | |
| parent | a2b6be23ada5e7dc6f5815236d7d2b3bb41ab2db (diff) | |
| parent | 50fd5ef3b5ceb53bd2201441b16b377b2e51c536 (diff) | |
| download | redot-engine-2e877031369c35c918c014a7ae3688b6f555e5bd.tar.gz | |
Merge pull request #22460 from neikeq/issue-22403
Mono: Fix not creating generic Array or Dictionary where expected
Diffstat (limited to 'modules/mono/glue/Managed/Files/Array.cs')
| -rw-r--r-- | modules/mono/glue/Managed/Files/Array.cs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/mono/glue/Managed/Files/Array.cs b/modules/mono/glue/Managed/Files/Array.cs index c80cb7cc83..d5a35d7ae0 100644 --- a/modules/mono/glue/Managed/Files/Array.cs +++ b/modules/mono/glue/Managed/Files/Array.cs @@ -128,7 +128,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { - yield return godot_icall_Array_At(GetPtr(), i); + yield return this[i]; } } @@ -167,6 +167,9 @@ namespace Godot.Collections internal extern static object godot_icall_Array_At(IntPtr ptr, int index); [MethodImpl(MethodImplOptions.InternalCall)] + internal extern static object godot_icall_Array_At_Generic(IntPtr ptr, int index, int elemTypeEncoding, IntPtr elemTypeClass); + + [MethodImpl(MethodImplOptions.InternalCall)] internal extern static void godot_icall_Array_SetAt(IntPtr ptr, int index, object value); [MethodImpl(MethodImplOptions.InternalCall)] @@ -195,12 +198,23 @@ namespace Godot.Collections [MethodImpl(MethodImplOptions.InternalCall)] internal extern static void godot_icall_Array_RemoveAt(IntPtr ptr, int index); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal extern static void godot_icall_Array_Generic_GetElementTypeInfo(Type elemType, out int elemTypeEncoding, out IntPtr elemTypeClass); } public class Array<T> : IList<T>, ICollection<T>, IEnumerable<T> { Array objectArray; + internal static int elemTypeEncoding; + internal static IntPtr elemTypeClass; + + static Array() + { + Array.godot_icall_Array_Generic_GetElementTypeInfo(typeof(T), out elemTypeEncoding, out elemTypeClass); + } + public Array() { objectArray = new Array(); @@ -230,7 +244,7 @@ namespace Godot.Collections { get { - return (T)objectArray[index]; + return (T)Array.godot_icall_Array_At_Generic(GetPtr(), index, elemTypeEncoding, elemTypeClass); } set { @@ -287,7 +301,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { - array[arrayIndex] = (T)objectArray[i]; + array[arrayIndex] = (T)this[i]; arrayIndex++; } } @@ -298,7 +312,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { - yield return (T)objectArray[i]; + yield return (T)this[i]; } } |
