Revision: 4289
http://skim-app.svn.sourceforge.net/skim-app/?rev=4289&view=rev
Author: hofman
Date: 2008-07-23 23:42:15 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
Fix return value of method replacement methods.
Modified Paths:
--------------
trunk/NSObject_SKExtensions.m
Modified: trunk/NSObject_SKExtensions.m
===================================================================
--- trunk/NSObject_SKExtensions.m 2008-07-23 22:25:53 UTC (rev 4288)
+++ trunk/NSObject_SKExtensions.m 2008-07-23 23:42:15 UTC (rev 4289)
@@ -43,7 +43,12 @@
@implementation NSObject (SKExtensions)
+ (IMP)setMethod:(IMP)anImp typeEncoding:(const char *)types
forSelector:(SEL)aSelector {
- return SK_class_replaceMethod(SK_object_getClass(self), aSelector, anImp,
types);
+ Method method = class_getClassMethod(self, aSelector);
+ IMP imp = SK_method_getImplementation(method);
+ if (method && types == NULL)
+ types = SK_method_getTypeEncoding(method);
+ SK_class_replaceMethod(SK_object_getClass(self), aSelector, anImp, types);
+ return imp;
}
- (IMP)setMethod:(IMP)anImp typeEncoding:(const char *)types
forSelector:(SEL)aSelector {
@@ -51,12 +56,17 @@
}
+ (IMP)setInstanceMethod:(IMP)anImp typeEncoding:(const char *)types
forSelector:(SEL)aSelector {
- return SK_class_replaceMethod(self, aSelector, anImp, types);
+ Method method = class_getInstanceMethod(self, aSelector);
+ IMP imp = SK_method_getImplementation(method);
+ if (method && types == NULL)
+ types = SK_method_getTypeEncoding(method);
+ SK_class_replaceMethod(self, aSelector, anImp, types);
+ return imp;
}
+ (IMP)setMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector {
- Method method = class_getClassMethod(self, aSelector);
- return method ? SK_class_replaceMethod(SK_object_getClass(self),
aSelector, SK_method_getImplementation(method),
SK_method_getTypeEncoding(method)) : NULL;
+ Method method = class_getClassMethod(self, impSelector);
+ return method ? [self setMethod:SK_method_getImplementation(method)
typeEncoding:SK_method_getTypeEncoding(method) forSelector:aSelector] : NULL;
}
- (IMP)setMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector {
@@ -64,8 +74,8 @@
}
+ (IMP)setInstanceMethodFromSelector:(SEL)impSelector
forSelector:(SEL)aSelector {
- Method method = class_getInstanceMethod(self, aSelector);
- return method ? SK_class_replaceMethod(self, aSelector,
SK_method_getImplementation(method), SK_method_getTypeEncoding(method)) : NULL;
+ Method method = class_getInstanceMethod(self, impSelector);
+ return method ? [self
setInstanceMethod:SK_method_getImplementation(method)
typeEncoding:SK_method_getTypeEncoding(method) forSelector:aSelector] : NULL;
}
+ (void)exchangeMethodForSelector:(SEL)aSelector1
withMethodForSelector:(SEL)aSelector2 {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit