Browse files

Fixing for iOS6

  • Loading branch information...
1 parent 2930600 commit 9cba3ff5a455b59f2dd5550049ce68ecb529c7cd @gabriel gabriel committed Sep 26, 2012
View
2 Classes/GHAsyncTestCase.m
@@ -143,7 +143,7 @@ - (void)runForInterval:(NSTimeInterval)interval {
NSInteger runIndex = 0;
- while ([runUntilDate compare:[NSDate date]] == NSOrderedDescending) {
+ while ([runUntilDate compare:[NSDate dateWithTimeIntervalSinceNow:0]] == NSOrderedDescending) {
NSString *mode = [_runLoopModes objectAtIndex:(runIndex++ % [_runLoopModes count])];
[lock_ unlock];
View
2 Classes/GHTest/GHTestRunner.m
@@ -206,7 +206,7 @@ - (void)testDidEnd:(id<GHTest>)test source:(id<GHTest>)source {
});
} else {
- [self log:[NSString stringWithFormat:@"Cancelled\n", [source identifier]]];
+ [self log:@"Cancelled\n"];
}
if (cancelling_) {
View
2 Classes/GHTest/NSValue+GHValueFormatter.m
@@ -119,7 +119,7 @@ - (NSString *)ghu_contentDescription {
case 'I': {
unsigned int long scalarValue = 0;
[self getValue:(void *)&scalarValue];
- return [NSString stringWithFormat:@"%u", scalarValue];
+ return [NSString stringWithFormat:@"%lu", scalarValue];
}
case 'f': {
float scalarValue = 0.0f;
View
56 Libraries/GTM/Foundation/GTMObjC2Runtime.h
@@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -17,12 +17,13 @@
//
#import <objc/objc-api.h>
+#import <objc/objc-auto.h>
#import "GTMDefines.h"
-// These functions exist for code that we want to compile on both the < 10.5
-// sdks and on the >= 10.5 sdks without warnings. It basically reimplements
-// certain parts of the objc2 runtime in terms of the objc1 runtime. It is not
-// a complete implementation as I've only implemented the routines I know we
+// These functions exist for code that we want to compile on both the < 10.5
+// sdks and on the >= 10.5 sdks without warnings. It basically reimplements
+// certain parts of the objc2 runtime in terms of the objc1 runtime. It is not
+// a complete implementation as I've only implemented the routines I know we
// use. Feel free to add more as necessary.
// These functions are not documented because they conform to the documentation
// for the ObjC2 Runtime.
@@ -35,25 +36,28 @@
#define AT_REQUIRED
#endif
-// The file objc-runtime.h was moved to runtime.h and in Leopard, objc-runtime.h
+// The file objc-runtime.h was moved to runtime.h and in Leopard, objc-runtime.h
// was just a wrapper around runtime.h. For the iPhone SDK, this objc-runtime.h
// is removed in the iPhoneOS2.0 SDK.
//
// The |Object| class was removed in the iPhone2.0 SDK too.
#if GTM_IPHONE_SDK
+#import <objc/message.h>
#import <objc/runtime.h>
#else
#import <objc/objc-runtime.h>
#import <objc/Object.h>
#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
-#import "objc/Protocol.h"
#import <libkern/OSAtomic.h>
+#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
+#import "objc/Protocol.h"
+
OBJC_EXPORT Class object_getClass(id obj);
OBJC_EXPORT const char *class_getName(Class cls);
OBJC_EXPORT BOOL class_conformsToProtocol(Class cls, Protocol *protocol);
+OBJC_EXPORT BOOL class_respondsToSelector(Class cls, SEL sel);
OBJC_EXPORT Class class_getSuperclass(Class cls);
OBJC_EXPORT Method *class_copyMethodList(Class cls, unsigned int *outCount);
OBJC_EXPORT SEL method_getName(Method m);
@@ -64,6 +68,7 @@ OBJC_EXPORT struct objc_method_description protocol_getMethodDescription(Protoco
SEL aSel,
BOOL isRequiredMethod,
BOOL isInstanceMethod);
+OBJC_EXPORT BOOL sel_isEqual(SEL lhs, SEL rhs);
// If building for 10.4 but using the 10.5 SDK, don't include these.
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
@@ -74,7 +79,7 @@ OBJC_EXPORT struct objc_method_description protocol_getMethodDescription(Protoco
// barrier versions.
GTM_INLINE bool OSAtomicCompareAndSwapPtrBarrier(void *predicate,
void *replacement,
- volatile void *theValue) {
+ void * volatile *theValue) {
#if defined(__LP64__) && __LP64__
return OSAtomicCompareAndSwap64Barrier((int64_t)predicate,
(int64_t)replacement,
@@ -85,21 +90,24 @@ GTM_INLINE bool OSAtomicCompareAndSwapPtrBarrier(void *predicate,
(int32_t *)theValue);
#endif // defined(__LP64__) && __LP64__
}
-
-GTM_INLINE BOOL objc_atomicCompareAndSwapGlobalBarrier(id predicate,
- id replacement,
+
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+#endif // GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
+
+#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
+
+GTM_INLINE BOOL objc_atomicCompareAndSwapGlobalBarrier(id predicate,
+ id replacement,
volatile id *objectLocation) {
- return OSAtomicCompareAndSwapPtrBarrier(predicate,
- replacement,
- objectLocation);
+ return OSAtomicCompareAndSwapPtrBarrier(predicate,
+ replacement,
+ (void * volatile *)objectLocation);
}
-GTM_INLINE BOOL objc_atomicCompareAndSwapInstanceVariableBarrier(id predicate,
- id replacement,
+GTM_INLINE BOOL objc_atomicCompareAndSwapInstanceVariableBarrier(id predicate,
+ id replacement,
volatile id *objectLocation) {
- return OSAtomicCompareAndSwapPtrBarrier(predicate,
- replacement,
- objectLocation);
+ return OSAtomicCompareAndSwapPtrBarrier(predicate,
+ replacement,
+ (void * volatile *)objectLocation);
}
-#endif
-
-#endif // OBJC2_UNAVAILABLE
+#endif // GTM_MACOS_SDK && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
View
25 Libraries/GTM/Foundation/GTMObjC2Runtime.m
@@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -18,7 +18,7 @@
#import "GTMObjC2Runtime.h"
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
#import <stdlib.h>
#import <string.h>
@@ -58,6 +58,10 @@ Class class_getSuperclass(Class cls) {
return cls->super_class;
}
+BOOL class_respondsToSelector(Class cls, SEL sel) {
+ return class_getInstanceMethod(cls, sel) != nil;
+}
+
Method *class_copyMethodList(Class cls, unsigned int *outCount) {
if (!cls) return NULL;
@@ -69,7 +73,7 @@ Class class_getSuperclass(Class cls) {
while ( (mlist = class_nextMethodList(cls, &iterator)) ) {
if (mlist->method_count == 0) continue;
- methods = (Method *)realloc(methods,
+ methods = (Method *)realloc(methods,
sizeof(Method) * (count + mlist->method_count + 1));
if (!methods) {
//Memory alloc failed, so what can we do?
@@ -103,7 +107,7 @@ IMP method_setImplementation(Method method, IMP imp) {
// We intentionally don't test method for nil.
// Leopard fails here, so should we.
// I logged this as Radar:
- // 5572981 method_setImplementation crashes if you pass nil for the
+ // 5572981 method_setImplementation crashes if you pass nil for the
// method arg (arg 1)
// because it seems odd that this API won't accept nil for method considering
// all the other apis will accept nil args.
@@ -117,7 +121,7 @@ IMP method_setImplementation(Method method, IMP imp) {
if (imp) {
oldImp = method->method_imp;
method->method_imp = imp;
- }
+ }
return oldImp;
}
@@ -150,7 +154,10 @@ struct objc_method_description protocol_getMethodDescription(Protocol *p,
return desc;
}
+BOOL sel_isEqual(SEL lhs, SEL rhs) {
+ // Apple (informally) promises this will work in the future:
+ // http://twitter.com/#!/gparker/status/2400099786
+ return (lhs == rhs) ? YES : NO;
+}
-#endif
-
-
+#endif // GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
View
2 XcodeConfig/Shared.xcconfig
@@ -1,4 +1,4 @@
-GHUNIT_VERSION = 0.5.3
+GHUNIT_VERSION = 0.5.4
GHUNIT_GENERAL_OTHER_CFLAGS = -Wdiv-by-zero -Wbad-function-cast -Wnested-externs -Wold-style-definition

0 comments on commit 9cba3ff

Please sign in to comment.