Revision: 4358
http://skim-app.svn.sourceforge.net/skim-app/?rev=4358&view=rev
Author: hofman
Date: 2008-08-06 09:41:34 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
add some comments
Modified Paths:
--------------
trunk/SKRuntime.h
trunk/SKRuntime.m
Modified: trunk/SKRuntime.h
===================================================================
--- trunk/SKRuntime.h 2008-08-06 01:37:59 UTC (rev 4357)
+++ trunk/SKRuntime.h 2008-08-06 09:41:34 UTC (rev 4358)
@@ -38,7 +38,6 @@
#import <Cocoa/Cocoa.h>
-// wrappers around 10.5 only functions, use 10.4 API when the function is not
defined
#define OBINITIALIZE \
do { \
@@ -52,3 +51,4 @@
extern IMP SKReplaceMethodImplementation(Class aClass, SEL aSelector, IMP
anImp, const char *types, BOOL isInstance);
extern IMP SKReplaceMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector, BOOL isInstance);
+extern void SKExchangeMethodImplementations(Class aClass, SEL aSelector1, SEL
aSelector2, BOOL isInstance);
Modified: trunk/SKRuntime.m
===================================================================
--- trunk/SKRuntime.m 2008-08-06 01:37:59 UTC (rev 4357)
+++ trunk/SKRuntime.m 2008-08-06 09:41:34 UTC (rev 4358)
@@ -39,6 +39,7 @@
#import "SKRuntime.h"
#import <objc/objc-runtime.h>
+// wrappers around 10.5 only functions, use 10.4 API when the function is not
defined
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
@@ -58,7 +59,7 @@
return method_getTypeEncoding != NULL ? method_getTypeEncoding(aMethod) :
aMethod->method_types;
}
-// generic implementation for SK_class_addMethod/SK_class_replaceMethod, but
only for old API, modeled after actual runtime implementation of
_class_addMethod
+// generic implementation for class_addMethod/class_replaceMethod, but only
for old API, modeled after actual runtime implementation of _class_addMethod
static inline IMP _SK_class_addMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes, BOOL replace) {
IMP imp = NULL;
void *iterator = NULL;
@@ -123,6 +124,9 @@
#endif
+#pragma mark API
+
+// this is essentially class_replaceMethod, but handles instance/class
methods, returns any inherited implementation, and can get the types from an
inherited implementation
IMP SKReplaceMethodImplementation(Class aClass, SEL aSelector, IMP anImp,
const char *types, BOOL isInstance) {
IMP imp = NULL;
if (anImp) {
@@ -142,3 +146,7 @@
Method method = isInstance ? class_getInstanceMethod(aClass, impSelector)
: class_getClassMethod(aClass, impSelector);
return method ? SKReplaceMethodImplementation(aClass, aSelector,
SK_method_getImplementation(method), SK_method_getTypeEncoding(method),
isInstance) : NULL;
}
+
+void SKExchangeMethodImplementationsForSelectors(Class aClass, SEL aSelector1,
SEL aSelector2, BOOL isInstance) {
+ SKReplaceMethodImplementation(aClass, aSelector2,
SKReplaceMethodImplementationFromSelector(aClass, aSelector1, aSelector2,
isInstance), NULL, isInstance);
+}
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