Revision: 4290
http://skim-app.svn.sourceforge.net/skim-app/?rev=4290&view=rev
Author: hofman
Date: 2008-07-24 09:57:53 +0000 (Thu, 24 Jul 2008)
Log Message:
-----------
hide implementation of runtime wrapper functions in implementation file.
Modified Paths:
--------------
trunk/SKRuntime.h
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKRuntime.m
Modified: trunk/SKRuntime.h
===================================================================
--- trunk/SKRuntime.h 2008-07-23 23:42:15 UTC (rev 4289)
+++ trunk/SKRuntime.h 2008-07-24 09:57:53 UTC (rev 4290)
@@ -40,136 +40,14 @@
// 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
+extern Class SK_object_getClass(id object);
-#pragma mark 10.4 + 10.5
+extern SEL SK_method_getName(Method aMethod);
+extern IMP SK_method_getImplementation(Method aMethod);
+extern const char *SK_method_getTypeEncoding(Method aMethod);
+extern IMP SK_method_setImplementation(Method aMethod, IMP anImp);
+extern void SK_method_exchangeImplementations(Method aMethod1, Method
aMethod2);
-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;
-}
-
-// generic implementation for SK_class_addMethod/SK_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;
- struct objc_method_list *mlist;
- Method m, method = NULL;
- int i;
- while (method == NULL && (mlist = class_nextMethodList(aClass,
&iterator))) {
- for (i = 0; i < mlist->method_count; i++) {
- m = &mlist->method_list[i];
- if (m->method_name == selector) {
- method = m;
- break;
- }
- }
- }
- if (method) {
- imp = method->method_imp;
- if (replace)
- method->method_imp = methodImp;
- } else {
- mlist = (struct objc_method_list *)NSZoneCalloc(NSDefaultMallocZone(),
1, sizeof(struct objc_method_list));
-
- mlist->method_count = 1;
- mlist->method_list[0].method_name = selector;
- mlist->method_list[0].method_imp = methodImp;
- mlist->method_list[0].method_types = strdup(methodTypes);
-
- class_addMethods(aClass, mlist);
-
- // Flush the method cache
- _objc_flush_caches(aClass);
- }
- return imp;
-}
-
-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
- _SK_class_addMethod(aClass, selector, methodImp, methodTypes, NO);
-}
-
-static inline IMP SK_class_replaceMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
- if (class_replaceMethod != NULL)
- return class_replaceMethod(aClass, selector, methodImp, methodTypes);
- else
- return _SK_class_addMethod(aClass, selector, methodImp, methodTypes,
YES);
-}
-
-#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);
-}
-
-static inline void SK_class_addMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
- return class_addMethod(aClass, selector, methodImp, methodTypes);
-}
-
-static inline void SK_class_replaceMethod(Class aClass, SEL selector, IMP
methodImp, const char *methodTypes) {
- return class_replaceMethod(aClass, selector, methodImp, methodTypes);
-}
-
-#endif
+extern Class SK_class_getSuperclass(Class aClass);
+extern void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp,
const char *methodTypes);
+extern IMP SK_class_replaceMethod(Class aClass, SEL selector, IMP methodImp,
const char *methodTypes);
Added: trunk/SKRuntime.m
===================================================================
--- trunk/SKRuntime.m (rev 0)
+++ trunk/SKRuntime.m 2008-07-24 09:57:53 UTC (rev 4290)
@@ -0,0 +1,178 @@
+//
+// SKRuntime.m
+// 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 "SKRuntime.h"
+
+
+#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);
+
+Class SK_object_getClass(id object) {
+ return object_getClass != NULL ? object_getClass(object) : object->isa;
+}
+
+SEL SK_method_getName(Method aMethod) {
+ return method_getName != NULL ? method_getName(aMethod) :
aMethod->method_name;
+}
+
+IMP SK_method_getImplementation(Method aMethod) {
+ return method_getImplementation != NULL ?
method_getImplementation(aMethod) : aMethod->method_imp;
+}
+
+const char *SK_method_getTypeEncoding(Method aMethod) {
+ return method_getTypeEncoding != NULL ? method_getTypeEncoding(aMethod) :
aMethod->method_types;
+}
+
+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;
+ }
+}
+
+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;
+ }
+}
+
+Class SK_class_getSuperclass(Class aClass) {
+ return class_getSuperclass != NULL ? class_getSuperclass(aClass) :
aClass->super_class;
+}
+
+// generic implementation for SK_class_addMethod/SK_class_replaceMethod, but
only for old API, modeled after actual runtime implementation of
_class_addMethod
+IMP _SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char
*methodTypes, BOOL replace) {
+ IMP imp = NULL;
+ void *iterator = NULL;
+ struct objc_method_list *mlist;
+ Method m, method = NULL;
+ int i;
+ while (method == NULL && (mlist = class_nextMethodList(aClass,
&iterator))) {
+ for (i = 0; i < mlist->method_count; i++) {
+ m = &mlist->method_list[i];
+ if (m->method_name == selector) {
+ method = m;
+ break;
+ }
+ }
+ }
+ if (method) {
+ imp = method->method_imp;
+ if (replace)
+ method->method_imp = methodImp;
+ } else {
+ mlist = (struct objc_method_list *)NSZoneCalloc(NSDefaultMallocZone(),
1, sizeof(struct objc_method_list));
+
+ mlist->method_count = 1;
+ mlist->method_list[0].method_name = selector;
+ mlist->method_list[0].method_imp = methodImp;
+ mlist->method_list[0].method_types = strdup(methodTypes);
+
+ class_addMethods(aClass, mlist);
+
+ // Flush the method cache
+ _objc_flush_caches(aClass);
+ }
+ return imp;
+}
+
+void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char
*methodTypes) {
+ if (class_addMethod != NULL)
+ class_addMethod(aClass, selector, methodImp, methodTypes);
+ else
+ _SK_class_addMethod(aClass, selector, methodImp, methodTypes, NO);
+}
+
+IMP SK_class_replaceMethod(Class aClass, SEL selector, IMP methodImp, const
char *methodTypes) {
+ if (class_replaceMethod != NULL)
+ return class_replaceMethod(aClass, selector, methodImp, methodTypes);
+ else
+ return _SK_class_addMethod(aClass, selector, methodImp, methodTypes,
YES);
+}
+
+#else
+
+#pragma mark 10.5
+
+Class SK_object_getClass(id object) {
+ return object_getClass(object);
+}
+
+SEL SK_method_getName(Method aMethod) {
+ return method_getName(aMethod);
+}
+
+IMP SK_method_getImplementation(Method aMethod) {
+ return method_getImplementation(aMethod);
+}
+
+const char *SK_method_getTypeEncoding(Method aMethod) {
+ return method_getTypeEncoding(aMethod);
+}
+
+IMP SK_method_setImplementation(Method aMethod, IMP anImp) {
+ return method_setImplementation(aMethod, anImp);
+}
+
+void SK_method_exchangeImplementations(Method aMethod1, Method aMethod2) {
+ method_exchangeImplementations(aMethod1, aMethod2);
+}
+
+Class SK_class_getSuperclass(Class aClass) {
+ return class_getSuperclass(aClass);
+}
+
+void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char
*methodTypes) {
+ class_addMethod(aClass, selector, methodImp, methodTypes);
+}
+
+IMP SK_class_replaceMethod(Class aClass, SEL selector, IMP methodImp, const
char *methodTypes) {
+ return class_replaceMethod(aClass, selector, methodImp, methodTypes);
+}
+
+#endif
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-07-23 23:42:15 UTC (rev
4289)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-07-24 09:57:53 UTC (rev
4290)
@@ -47,6 +47,7 @@
CE07158B0B8A3D6500733CC8 /* NoteDocument.icns in Resources */ =
{isa = PBXBuildFile; fileRef = CE0715890B8A3D6300733CC8 /* NoteDocument.icns
*/; };
CE07158C0B8A3D6500733CC8 /* PDFDocument.icns in Resources */ =
{isa = PBXBuildFile; fileRef = CE07158A0B8A3D6300733CC8 /* PDFDocument.icns */;
};
CE0859D20DAE912500760AFC /* SKSnapshotPageCell.m in Sources */
= {isa = PBXBuildFile; fileRef = CE0859D10DAE912500760AFC /*
SKSnapshotPageCell.m */; };
+ CE09FC3C0E3886C100BDF413 /* SKRuntime.m in Sources */ = {isa =
PBXBuildFile; fileRef = CE09FC3B0E3886C100BDF413 /* SKRuntime.m */; };
CE0EB4D60DD054DC0034DF92 /* NSInvocation_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE0EB4D50DD054DC0034DF92 /*
NSInvocation_SKExtensions.m */; };
CE0ECCD90DE71868006EEDDB /* Templates in Resources */ = {isa =
PBXBuildFile; fileRef = CE0ECCD40DE71868006EEDDB /* Templates */; };
CE0ECCDA0DE7188C006EEDDB /* Templates in CopyFiles */ = {isa =
PBXBuildFile; fileRef = CE0ECCD40DE71868006EEDDB /* Templates */; };
@@ -458,6 +459,7 @@
CE07158A0B8A3D6300733CC8 /* PDFDocument.icns */ = {isa =
PBXFileReference; lastKnownFileType = image.icns; name = PDFDocument.icns; path
= Images/PDFDocument.icns; sourceTree = "<group>"; };
CE0859D00DAE912500760AFC /* SKSnapshotPageCell.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKSnapshotPageCell.h; sourceTree = "<group>"; };
CE0859D10DAE912500760AFC /* SKSnapshotPageCell.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKSnapshotPageCell.m; sourceTree = "<group>"; };
+ CE09FC3B0E3886C100BDF413 /* SKRuntime.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKRuntime.m; sourceTree = "<group>"; };
CE0EB4D40DD054DC0034DF92 /* NSInvocation_SKExtensions.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = NSInvocation_SKExtensions.h; sourceTree = "<group>"; };
CE0EB4D50DD054DC0034DF92 /* NSInvocation_SKExtensions.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSInvocation_SKExtensions.m; sourceTree = "<group>";
};
CE0ECCD40DE71868006EEDDB /* Templates */ = {isa =
PBXFileReference; lastKnownFileType = folder; path = Templates; sourceTree =
"<group>"; };
@@ -1172,6 +1174,7 @@
CE41B2C90C08D17100E36EB7 /*
NSValue_SKExtensions.h */,
CE41B2CA0C08D17100E36EB7 /*
NSValue_SKExtensions.m */,
CE1F67FD0E37552400E07E76 /* SKRuntime.h */,
+ CE09FC3B0E3886C100BDF413 /* SKRuntime.m */,
);
name = "Foundation Categories";
sourceTree = "<group>";
@@ -2125,6 +2128,7 @@
CEC3AD240E23EC0300F40B0B /*
PDFAnnotationLink_SKExtensions.m in Sources */,
CE3364310E2761E9005F99E6 /* synctex_parser.m in
Sources */,
CE3366DF0E28BCFA005F99E6 /* SKPDFSyncRecord.m
in Sources */,
+ CE09FC3C0E3886C100BDF413 /* SKRuntime.m in
Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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