diff options
author | jfrijters <jfrijters> | 2011-12-01 10:30:50 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-12-01 10:30:50 +0400 |
commit | 3c49c20346609d4c397dff93d25bb68297301516 (patch) | |
tree | 926cbcef8a32139fb0cbaa3ad15e9690351a1379 /reflect/Util.cs | |
parent | ed23e4ca4ec0e5fc797e47e7dea004941e02e853 (diff) |
- Rewrote custom modifier handling to retain ordering.
- Added ConstructorInfo.__ReturnParameter to expose custom modifiers.
- Added __GetCustomModifiers() to various *Info types.
- Added CustomModifiers type to encapsulate a custom modifier sequence.
- Added CustomModifiersBuilder to create a CustomModifiers sequence.
- Marked a number of IKVM.Reflection specific methods Obsolete, because they are replaced with method that take CustomModifiers value(s).
Diffstat (limited to 'reflect/Util.cs')
-rw-r--r-- | reflect/Util.cs | 93 |
1 files changed, 27 insertions, 66 deletions
diff --git a/reflect/Util.cs b/reflect/Util.cs index 1a95679a..8bdcaca9 100644 --- a/reflect/Util.cs +++ b/reflect/Util.cs @@ -163,62 +163,6 @@ namespace IKVM.Reflection return false; } - internal static bool ArrayEquals(Type[][] t1, Type[][] t2) - { - if (t1 == t2) - { - return true; - } - if (t1 == null) - { - return t2.Length == 0; - } - else if (t2 == null) - { - return t1.Length == 0; - } - if (t1.Length == t2.Length) - { - for (int i = 0; i < t1.Length; i++) - { - if (!ArrayEquals(t1[i], t2[i])) - { - return false; - } - } - return true; - } - return false; - } - - internal static bool ArrayEquals(Type[][][] t1, Type[][][] t2) - { - if (t1 == t2) - { - return true; - } - if (t1 == null) - { - return t2.Length == 0; - } - else if (t2 == null) - { - return t1.Length == 0; - } - if (t1.Length == t2.Length) - { - for (int i = 0; i < t1.Length; i++) - { - if (!ArrayEquals(t1[i], t2[i])) - { - return false; - } - } - return true; - } - return false; - } - internal static bool TypeEquals(Type t1, Type t2) { if (t1 == t2) @@ -250,31 +194,48 @@ namespace IKVM.Reflection return h; } - internal static int GetHashCode(Type[][] types) + internal static bool ArrayEquals(CustomModifiers[] m1, CustomModifiers[] m2) { - int h = 0; - if (types != null) + if (m1 == null || m2 == null) + { + return m1 == m2; + } + if (m1.Length != m2.Length) + { + return false; + } + for (int i = 0; i < m1.Length; i++) { - foreach (Type[] array in types) + if (!m1[i].Equals(m2[i])) { - h ^= GetHashCode(array); + return false; } } - return h; + return true; } - internal static int GetHashCode(Type[][][] types) + internal static int GetHashCode(CustomModifiers[] mods) { int h = 0; - if (types != null) + if (mods != null) { - foreach (Type[][] array in types) + foreach (CustomModifiers mod in mods) { - h ^= GetHashCode(array); + h ^= mod.GetHashCode(); } } return h; } + + internal static T NullSafeElementAt<T>(T[] array, int index) + { + return array == null ? default(T) : array[index]; + } + + internal static int NullSafeLength<T>(T[] array) + { + return array == null ? 0 : array.Length; + } } [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)] |