typedef IMP MethodListIMP;
#endif
+EXTERN_C void _method_setImplementationRawUnsafe(Method m, IMP imp);
+
static int Retains;
static int Releases;
static int Autoreleases;
#if SWIZZLE_AWZ
method_setImplementation(meth, (IMP)HackAllocWithZone);
#else
- ((MethodListIMP *)meth)[2] = (IMP)HackAllocWithZone;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackAllocWithZone);
#endif
meth = class_getClassMethod(cls, @selector(new));
#if SWIZZLE_CORE
method_setImplementation(meth, (IMP)HackPlusNew);
#else
- ((MethodListIMP *)meth)[2] = (IMP)HackPlusNew;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackPlusNew);
#endif
meth = class_getClassMethod(cls, @selector(self));
#if SWIZZLE_CORE
method_setImplementation(meth, (IMP)HackPlusSelf);
#else
- ((MethodListIMP *)meth)[2] = (IMP)HackPlusSelf;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackPlusSelf);
#endif
meth = class_getInstanceMethod(cls, @selector(self));
#if SWIZZLE_CORE
method_setImplementation(meth, (IMP)HackSelf);
#else
- ((MethodListIMP *)meth)[2] = (IMP)HackSelf;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackSelf);
#endif
meth = class_getInstanceMethod(cls, @selector(release));
#if SWIZZLE_RELEASE
method_setImplementation(meth, (IMP)HackRelease);
#else
- ((MethodListIMP *)meth)[2] = (IMP)HackRelease;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackRelease);
#endif
// These other methods get hacked for counting purposes only
meth = class_getInstanceMethod(cls, @selector(retain));
RealRetain = (typeof(RealRetain))method_getImplementation(meth);
- ((MethodListIMP *)meth)[2] = (IMP)HackRetain;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackRetain);
meth = class_getInstanceMethod(cls, @selector(autorelease));
RealAutorelease = (typeof(RealAutorelease))method_getImplementation(meth);
- ((MethodListIMP *)meth)[2] = (IMP)HackAutorelease;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackAutorelease);
meth = class_getClassMethod(cls, @selector(alloc));
RealAlloc = (typeof(RealAlloc))method_getImplementation(meth);
- ((MethodListIMP *)meth)[2] = (IMP)HackAlloc;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackAlloc);
meth = class_getInstanceMethod(cls, @selector(init));
- ((MethodListIMP *)meth)[2] = (IMP)HackInit;
+ _method_setImplementationRawUnsafe(meth, (IMP)HackInit);
// Verify that the swizzles occurred before +initialize by provoking it now
testassert(PlusInitializes == 0);