Revision: 4282
http://skim-app.svn.sourceforge.net/skim-app/?rev=4282&view=rev
Author: hofman
Date: 2008-07-23 12:11:22 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
move runtime compatibility functions to separate header file
Modified Paths:
--------------
trunk/NSObject_SKExtensions.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKRuntime.h
Modified: trunk/NSObject_SKExtensions.m
===================================================================
--- trunk/NSObject_SKExtensions.m 2008-07-23 11:48:05 UTC (rev 4281)
+++ trunk/NSObject_SKExtensions.m 2008-07-23 12:11:22 UTC (rev 4282)
@@ -14,113 +14,9 @@
// <http://www.omnigroup.com/developer/sourcecode/sourcelicense/>.
#import "NSObject_SKExtensions.h"
-#import <Foundation/Foundation.h>
-#import <objc/objc.h>
-#import <objc/objc-class.h>
-#import <objc/objc-runtime.h>
+#import "SKRuntime.h"
-#pragma mark Runtime compatibility
-// 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
-
-#pragma mark 10.4 + 10.5
-
-extern void _objc_flush_caches(Class);
-
-static inline Class SK_object_getClass(id object) {
- return object_getClass != NULL ? object_getClass(object) : object->isa;
-}
-
-static inline IMP SK_method_getImplementation(Method aMethod) {
- return method_getImplementation != NULL ?
method_getImplementation(aMethod) : aMethod->method_imp;
-}
-
-static inline IMP SK_method_setImplementation(Method aMethod, IMP anImp) {
- if (method_setImplementation != NULL) {
- return method_setImplementation(aMethod, anImp);
- } else {
- IMP oldImp = aMethod->method_imp;
- aMethod->method_imp = anImp;
- return oldImp;
- }
-}
-
-static inline void SK_method_exchangeImplementations(Method aMethod1, Method
aMethod2) {
- if (method_exchangeImplementations != NULL) {
- method_exchangeImplementations(aMethod1, aMethod2);
- } else {
- IMP imp = aMethod1->method_imp;
- aMethod1->method_imp = aMethod2->method_imp;
- aMethod2->method_imp = imp;
- }
-}
-
-static inline const char *SK_method_getTypeEncoding(Method aMethod) {
- return method_getTypeEncoding != NULL ? method_getTypeEncoding(aMethod) :
aMethod->method_types;
-}
-
-static inline Class SK_class_getSuperclass(Class aClass) {
- return class_getSuperclass != NULL ? class_getSuperclass(aClass) :
aClass->super_class;
-}
-
-static inline void SK_class_addMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
- if (class_addMethod != NULL) {
- class_addMethod(aClass, selector, methodImp, methodTypes);
- } else {
- struct objc_method_list *newMethodList = (struct objc_method_list
*)NSZoneMalloc(NSDefaultMallocZone(), sizeof(struct objc_method_list));
-
- newMethodList->method_count = 1;
- newMethodList->method_list[0].method_name = selector;
- newMethodList->method_list[0].method_imp = methodImp;
- newMethodList->method_list[0].method_types = (char *)methodTypes;
-
- class_addMethods(aClass, newMethodList);
-
- // Flush the method cache
- _objc_flush_caches(aClass);
- }
-}
-
-#else
-
-#pragma mark 10.5
-
-static inline Class SK_object_getClass(id object) {
- return object_getClass(object);
-}
-
-static inline IMP SK_method_getImplementation(Method aMethod) {
- return method_getImplementation(aMethod);
-}
-
-static inline IMP SK_method_setImplementation(Method aMethod, IMP anImp) {
- return method_setImplementation(aMethod, anImp);
-}
-
-static inline void SK_method_exchangeImplementations(Method aMethod1, Method
aMethod2) {
- method_exchangeImplementations(aMethod1, aMethod2);
-}
-
-static inline const char *SK_method_getTypeEncoding(Method aMethod) {
- return method_getTypeEncoding(aMethod);
-}
-
-static inline Class SK_class_getSuperclass(Class aClass) {
- return class_getSuperclass(aClass);
-}
-
-static inline void SK_class_addMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
- class_addMethod(aClass, selector, methodImp, methodTypes);
-}
-
-#endif
-
-static inline Method SK_class_getMethod(Class aClass, SEL aSelector, BOOL
isInstance) {
- return isInstance ? class_getInstanceMethod(aClass, aSelector) :
class_getClassMethod(aClass, aSelector);
-}
-
#pragma mark Basic functions
static IMP SKSetMethodImplementation(Class aClass, SEL aSelector, IMP anImp,
const char *types, BOOL isInstance) {
Added: trunk/SKRuntime.h
===================================================================
--- trunk/SKRuntime.h (rev 0)
+++ trunk/SKRuntime.h 2008-07-23 12:11:22 UTC (rev 4282)
@@ -0,0 +1,139 @@
+/*
+ * SKRuntime.h
+ * Skim
+ *
+ * Created by Christiaan Hofman on 7/23/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#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
+
+#pragma mark 10.4 + 10.5
+
+extern void _objc_flush_caches(Class);
+
+static inline Class SK_object_getClass(id object) {
+ return object_getClass != NULL ? object_getClass(object) : object->isa;
+}
+
+static inline IMP SK_method_getImplementation(Method aMethod) {
+ return method_getImplementation != NULL ?
method_getImplementation(aMethod) : aMethod->method_imp;
+}
+
+static inline IMP SK_method_setImplementation(Method aMethod, IMP anImp) {
+ if (method_setImplementation != NULL) {
+ return method_setImplementation(aMethod, anImp);
+ } else {
+ IMP oldImp = aMethod->method_imp;
+ aMethod->method_imp = anImp;
+ return oldImp;
+ }
+}
+
+static inline void SK_method_exchangeImplementations(Method aMethod1, Method
aMethod2) {
+ if (method_exchangeImplementations != NULL) {
+ method_exchangeImplementations(aMethod1, aMethod2);
+ } else {
+ IMP imp = aMethod1->method_imp;
+ aMethod1->method_imp = aMethod2->method_imp;
+ aMethod2->method_imp = imp;
+ }
+}
+
+static inline const char *SK_method_getTypeEncoding(Method aMethod) {
+ return method_getTypeEncoding != NULL ? method_getTypeEncoding(aMethod) :
aMethod->method_types;
+}
+
+static inline Class SK_class_getSuperclass(Class aClass) {
+ return class_getSuperclass != NULL ? class_getSuperclass(aClass) :
aClass->super_class;
+}
+
+static inline void SK_class_addMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
+ if (class_addMethod != NULL) {
+ class_addMethod(aClass, selector, methodImp, methodTypes);
+ } else {
+ struct objc_method_list *newMethodList = (struct objc_method_list
*)NSZoneMalloc(NSDefaultMallocZone(), sizeof(struct objc_method_list));
+
+ newMethodList->method_count = 1;
+ newMethodList->method_list[0].method_name = selector;
+ newMethodList->method_list[0].method_imp = methodImp;
+ newMethodList->method_list[0].method_types = (char *)methodTypes;
+
+ class_addMethods(aClass, newMethodList);
+
+ // Flush the method cache
+ _objc_flush_caches(aClass);
+ }
+}
+
+#else
+
+#pragma mark 10.5
+
+static inline Class SK_object_getClass(id object) {
+ return object_getClass(object);
+}
+
+static inline IMP SK_method_getImplementation(Method aMethod) {
+ return method_getImplementation(aMethod);
+}
+
+static inline IMP SK_method_setImplementation(Method aMethod, IMP anImp) {
+ return method_setImplementation(aMethod, anImp);
+}
+
+static inline void SK_method_exchangeImplementations(Method aMethod1, Method
aMethod2) {
+ method_exchangeImplementations(aMethod1, aMethod2);
+}
+
+static inline const char *SK_method_getTypeEncoding(Method aMethod) {
+ return method_getTypeEncoding(aMethod);
+}
+
+static inline Class SK_class_getSuperclass(Class aClass) {
+ return class_getSuperclass(aClass);
+}
+
+static inline void SK_class_addMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
+ class_addMethod(aClass, selector, methodImp, methodTypes);
+}
+
+#endif
+
+static inline Method SK_class_getMethod(Class aClass, SEL aSelector, BOOL
isInstance) {
+ return isInstance ? class_getInstanceMethod(aClass, aSelector) :
class_getClassMethod(aClass, aSelector);
+}
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-07-23 11:48:05 UTC (rev
4281)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-07-23 12:11:22 UTC (rev
4282)
@@ -479,6 +479,7 @@
CE1E301B0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc;
path = NSScanner_SKExtensions.m; sourceTree = "<group>"; };
CE1E30260BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = NSCharacterSet_SKExtensions.h; sourceTree = "<group>"; };
CE1E30270BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSCharacterSet_SKExtensions.m; sourceTree =
"<group>"; };
+ CE1F67FD0E37552400E07E76 /* SKRuntime.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKRuntime.h; sourceTree = "<group>"; };
CE20938E0C5F9A8D009D3EFB /* BDSKGradientView.h */ = {isa =
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path =
BDSKGradientView.h; sourceTree = "<group>"; };
CE20938F0C5F9A8D009D3EFB /* BDSKGradientView.m */ = {isa =
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc;
path = BDSKGradientView.m; sourceTree = "<group>"; };
CE209FA70C9D38C6007C72F9 /* SKProgressController.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKProgressController.h; sourceTree = "<group>"; };
@@ -1170,6 +1171,7 @@
CE7F43900DE1F1980061A839 /*
NSUserDefaults_SKExtensions.m */,
CE41B2C90C08D17100E36EB7 /*
NSValue_SKExtensions.h */,
CE41B2CA0C08D17100E36EB7 /*
NSValue_SKExtensions.m */,
+ CE1F67FD0E37552400E07E76 /* SKRuntime.h */,
);
name = "Foundation Categories";
sourceTree = "<group>";
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