static ObjectHandle() { DynamicMethod m = new DynamicMethod("GetO", typeof(T), new[] { typeof(IntPtr) }, typeof(ObjectHandle <T>), true); var il = m.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ret); GetO = m.CreateDelegate(typeof(GetO_d)) as GetO_d; }
static Voodoo() { Type t = typeof(T); tptr = t.TypeHandle.Value; tsize = Marshal.ReadInt32(tptr, 4); zero = new byte[tsize]; DynamicMethod m = new DynamicMethod("GetO", typeof(T), new[] { typeof(IntPtr) }, typeof(Voodoo <T>), true); var il = m.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ret); GetO = m.CreateDelegate(typeof(GetO_d)) as GetO_d; m = new DynamicMethod("GetPtr", typeof(IntPtr), new[] { typeof(T) }, typeof(Voodoo <T>), true); il = m.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ret); GetPtr = m.CreateDelegate(typeof(GetPtr_d)) as GetPtr_d; }