2 // Wrapper handles for Mono Runtime internal structs
5 // Aleksey Kliger <aleksey@xamarin.com>
6 // Rodrigo Kumpera <kumpera@xamarin.com>
8 // Copyright 2016 Dot net foundation.
9 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
13 using System.Runtime.CompilerServices;
17 internal struct RuntimeClassHandle {
18 unsafe RuntimeStructs.MonoClass* value;
20 internal unsafe RuntimeClassHandle (RuntimeStructs.MonoClass* value) {
24 internal unsafe RuntimeClassHandle (IntPtr ptr) {
25 this.value = (RuntimeStructs.MonoClass*) ptr;
28 internal unsafe RuntimeStructs.MonoClass* Value {
32 public override bool Equals (object obj)
34 if (obj == null || GetType () != obj.GetType ())
37 unsafe { return value == ((RuntimeClassHandle)obj).Value; }
40 public override int GetHashCode ()
42 unsafe { return ((IntPtr)value).GetHashCode (); }
45 public bool Equals (RuntimeClassHandle handle)
47 unsafe { return value == handle.Value; }
50 public static bool operator == (RuntimeClassHandle left, Object right)
52 return (right != null) && (right is RuntimeClassHandle) && left.Equals ((RuntimeClassHandle)right);
55 public static bool operator != (RuntimeClassHandle left, Object right)
57 return (right == null) || !(right is RuntimeClassHandle) || !left.Equals ((RuntimeClassHandle)right);
60 public static bool operator == (Object left, RuntimeClassHandle right)
62 return (left != null) && (left is RuntimeClassHandle) && ((RuntimeClassHandle)left).Equals (right);
65 public static bool operator != (Object left, RuntimeClassHandle right)
67 return (left == null) || !(left is RuntimeClassHandle) || !((RuntimeClassHandle)left).Equals (right);
70 [MethodImpl(MethodImplOptions.InternalCall)]
71 internal unsafe extern static IntPtr GetTypeFromClass (RuntimeStructs.MonoClass *klass);
73 internal RuntimeTypeHandle GetTypeHandle ()
75 unsafe { return new RuntimeTypeHandle (GetTypeFromClass (value)); }
79 internal struct RuntimeRemoteClassHandle {
80 unsafe RuntimeStructs.RemoteClass* value;
82 internal unsafe RuntimeRemoteClassHandle (RuntimeStructs.RemoteClass* value)
87 internal RuntimeClassHandle ProxyClass {
90 return new RuntimeClassHandle (value->proxy_class);