aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2015-11-03 10:08:17 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2015-11-03 10:08:17 -0500
commitf2f8cc667b790dcd71709cb3a175944d38b1e78a (patch)
treea1ee53015afcff9e74d0b696401b0514b8b609c6
parentd160301ee824d8c77bcef4af3f8265c8cb376a7c (diff)
Keep GTM building after clang r251041 when targeting 10.6
-rw-r--r--AddressBook/GTMABAddressBook.m2
-rw-r--r--AppKit/GTMCarbonEvent.h2
-rw-r--r--AppKit/GTMWindowSheetController.h7
-rw-r--r--AppKit/GTMWindowSheetController.m2
-rw-r--r--Foundation/GTMAbstractDOListener.h2
-rw-r--r--Foundation/GTMAbstractDOListener.m2
-rw-r--r--Foundation/GTMAbstractDOListenerTest.m2
-rw-r--r--Foundation/GTMFileSystemKQueue.h3
-rw-r--r--Foundation/GTMFileSystemKQueueTest.m2
-rw-r--r--Foundation/GTMLightweightProxy.h3
-rw-r--r--Foundation/GTMLogger+ASL.h2
-rw-r--r--Foundation/GTMNSObject+KeyValueObserving.m4
-rw-r--r--Foundation/GTMNSObject+KeyValueObservingTest.m6
-rw-r--r--Foundation/GTMSignalHandler.h3
-rw-r--r--Foundation/GTMTransientRootProxy.h3
-rw-r--r--GTMDefines.h27
16 files changed, 52 insertions, 20 deletions
diff --git a/AddressBook/GTMABAddressBook.m b/AddressBook/GTMABAddressBook.m
index 8ddb247..d71aa91 100644
--- a/AddressBook/GTMABAddressBook.m
+++ b/AddressBook/GTMABAddressBook.m
@@ -52,7 +52,7 @@ typedef struct {
@interface GTMABMultiValueEnumerator : NSEnumerator {
@private
- __weak ABMultiValueRef ref_; // ref_ cached from enumeree_
+ GTM_WEAK ABMultiValueRef ref_; // ref_ cached from enumeree_
GTMABMultiValue *enumeree_;
unsigned long mutations_;
NSUInteger count_;
diff --git a/AppKit/GTMCarbonEvent.h b/AppKit/GTMCarbonEvent.h
index a234532..364be3a 100644
--- a/AppKit/GTMCarbonEvent.h
+++ b/AppKit/GTMCarbonEvent.h
@@ -235,7 +235,7 @@ GTM_EXTERN NSUInteger GTMCarbonToCocoaKeyModifiers(UInt32 inCarbonModifiers);
// handler we are wrapping
// lazily created in the eventHandler method
EventHandlerRef eventHandler_;
- __weak id delegate_; // Our delegate
+ GTM_WEAK id delegate_; // Our delegate
// Does our delegate respond to the gtm_eventHandler:receivedEvent:handler:
// selector? Cached for performance reasons.
BOOL delegateRespondsToHandleEvent_;
diff --git a/AppKit/GTMWindowSheetController.h b/AppKit/GTMWindowSheetController.h
index 7991112..2ef0198 100644
--- a/AppKit/GTMWindowSheetController.h
+++ b/AppKit/GTMWindowSheetController.h
@@ -17,6 +17,7 @@
//
#import <Cocoa/Cocoa.h>
+#import "GTMDefines.h"
// A class to manage multiple sheets for a window. Use it for tab-style
// interfaces, where each tab might need its own sheet.
@@ -56,9 +57,9 @@
@interface GTMWindowSheetController : NSObject {
@private
- __weak NSWindow* window_;
- __weak NSView* activeView_;
- __weak id <GTMWindowSheetControllerDelegate> delegate_;
+ GTM_WEAK NSWindow* window_;
+ GTM_WEAK NSView* activeView_;
+ GTM_WEAK id <GTMWindowSheetControllerDelegate> delegate_;
NSMutableDictionary* sheets_; // NSValue*(NSView*) -> SheetInfo*
}
diff --git a/AppKit/GTMWindowSheetController.m b/AppKit/GTMWindowSheetController.m
index 7cfeaeb..8e2d13c 100644
--- a/AppKit/GTMWindowSheetController.m
+++ b/AppKit/GTMWindowSheetController.m
@@ -26,7 +26,7 @@
NSWindow* overlayWindow_;
// delegate data
- __weak id modalDelegate_;
+ GTM_WEAK id modalDelegate_;
SEL didEndSelector_;
void* contextInfo_;
diff --git a/Foundation/GTMAbstractDOListener.h b/Foundation/GTMAbstractDOListener.h
index 38e8db4..104ec05 100644
--- a/Foundation/GTMAbstractDOListener.h
+++ b/Foundation/GTMAbstractDOListener.h
@@ -35,7 +35,7 @@
@interface GTMAbstractDOListener : NSObject <NSConnectionDelegate> {
@protected
NSString *registeredName_;
- __weak Protocol *protocol_;
+ GTM_WEAK Protocol *protocol_;
NSConnection *connection_;
BOOL isRunningInNewThread_;
BOOL shouldShutdown_;
diff --git a/Foundation/GTMAbstractDOListener.m b/Foundation/GTMAbstractDOListener.m
index 0e221a8..4ac69bd 100644
--- a/Foundation/GTMAbstractDOListener.m
+++ b/Foundation/GTMAbstractDOListener.m
@@ -29,7 +29,7 @@
// message. This is only need on Tiger.
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
@interface GTMReceivePortDelegate : NSObject {
- __weak id delegate_;
+ GTM_WEAK id delegate_;
}
- (id)initWithDelegate:(id)delegate;
- (void)handlePortMessage:(NSPortMessage *)message;
diff --git a/Foundation/GTMAbstractDOListenerTest.m b/Foundation/GTMAbstractDOListenerTest.m
index d26d4fc..6a5a90a 100644
--- a/Foundation/GTMAbstractDOListenerTest.m
+++ b/Foundation/GTMAbstractDOListenerTest.m
@@ -57,7 +57,7 @@ enum {
@interface TestServer : GTMAbstractDOListener<TestServerDOProtocol> {
@private
- __weak id delegate_;
+ GTM_WEAK id delegate_;
}
- (void)setDelegate:(id)delegate;
@end
diff --git a/Foundation/GTMFileSystemKQueue.h b/Foundation/GTMFileSystemKQueue.h
index a81d433..c167eea 100644
--- a/Foundation/GTMFileSystemKQueue.h
+++ b/Foundation/GTMFileSystemKQueue.h
@@ -17,6 +17,7 @@
//
#import <Foundation/Foundation.h>
+#import "GTMDefines.h"
#import <sys/event.h> // for kqueue() and kevent and the NOTE_* constants
@@ -50,7 +51,7 @@ typedef unsigned int GTMFileSystemKQueueEvents;
int fd_;
GTMFileSystemKQueueEvents events_;
BOOL acrossReplace_;
- __weak id target_;
+ GTM_WEAK id target_;
SEL action_;
}
diff --git a/Foundation/GTMFileSystemKQueueTest.m b/Foundation/GTMFileSystemKQueueTest.m
index a8eec37..3919b86 100644
--- a/Foundation/GTMFileSystemKQueueTest.m
+++ b/Foundation/GTMFileSystemKQueueTest.m
@@ -39,7 +39,7 @@
@interface GTMFSKQTestHelper : NSObject {
@private
int writes_, renames_, deletes_;
- __weak GTMFileSystemKQueue *queue_;
+ GTM_WEAK GTMFileSystemKQueue *queue_;
}
@end
diff --git a/Foundation/GTMLightweightProxy.h b/Foundation/GTMLightweightProxy.h
index 2e2a748..76ef66b 100644
--- a/Foundation/GTMLightweightProxy.h
+++ b/Foundation/GTMLightweightProxy.h
@@ -17,6 +17,7 @@
//
#import <Foundation/Foundation.h>
+#import "GTMDefines.h"
//
// GTMLightweightProxy
@@ -31,7 +32,7 @@
//
@interface GTMLightweightProxy : NSProxy {
@private
- __weak id representedObject_;
+ GTM_WEAK id representedObject_;
}
// Initializes the object to represent |object|.
diff --git a/Foundation/GTMLogger+ASL.h b/Foundation/GTMLogger+ASL.h
index 87a513d..3b41e68 100644
--- a/Foundation/GTMLogger+ASL.h
+++ b/Foundation/GTMLogger+ASL.h
@@ -52,7 +52,7 @@
//
@interface GTMLogASLWriter : NSObject <GTMLogWriter> {
@private
- __weak Class aslClientClass_;
+ GTM_WEAK Class aslClientClass_;
NSString *facility_;
}
diff --git a/Foundation/GTMNSObject+KeyValueObserving.m b/Foundation/GTMNSObject+KeyValueObserving.m
index 814419b..70f5310 100644
--- a/Foundation/GTMNSObject+KeyValueObserving.m
+++ b/Foundation/GTMNSObject+KeyValueObserving.m
@@ -62,10 +62,10 @@
@interface GTMKeyValueObservingHelper : NSObject {
@private
- __weak id observer_;
+ GTM_WEAK id observer_;
SEL selector_;
id userInfo_;
- __weak id target_;
+ GTM_WEAK id target_;
NSString* keyPath_;
}
diff --git a/Foundation/GTMNSObject+KeyValueObservingTest.m b/Foundation/GTMNSObject+KeyValueObservingTest.m
index be3041b..ba59a96 100644
--- a/Foundation/GTMNSObject+KeyValueObservingTest.m
+++ b/Foundation/GTMNSObject+KeyValueObservingTest.m
@@ -34,7 +34,7 @@
@interface GTMNSObject_KeyValueObservingTest : GTMTestCase {
int32_t count_;
NSMutableDictionary *dict_;
- __weak NSString *expectedValue_;
+ GTM_WEAK NSString *expectedValue_;
}
- (void)observeValueChange:(GTMKeyValueChangeNotification *)notification;
@@ -133,8 +133,8 @@
@private
id value_;
id _value2;
- __weak NSArray *value3_;
- __weak NSString *value4;
+ GTM_WEAK NSArray *value3_;
+ GTM_WEAK NSString *value4;
}
- (NSString *)value4;
@end
diff --git a/Foundation/GTMSignalHandler.h b/Foundation/GTMSignalHandler.h
index 6297197..ec21507 100644
--- a/Foundation/GTMSignalHandler.h
+++ b/Foundation/GTMSignalHandler.h
@@ -17,6 +17,7 @@
//
#import <Foundation/Foundation.h>
+#import "GTMDefines.h"
// GTMSignalHandler.
//
@@ -60,7 +61,7 @@
@interface GTMSignalHandler : NSObject {
@private
int signo_;
- __weak id target_;
+ GTM_WEAK id target_;
SEL action_;
}
diff --git a/Foundation/GTMTransientRootProxy.h b/Foundation/GTMTransientRootProxy.h
index b5aa78a..3ebb501 100644
--- a/Foundation/GTMTransientRootProxy.h
+++ b/Foundation/GTMTransientRootProxy.h
@@ -17,6 +17,7 @@
//
#import <Foundation/Foundation.h>
+#import "GTMDefines.h"
// Handle (re-)connecting to a transient root proxy object via DO.
//
@@ -68,7 +69,7 @@
//
@interface GTMTransientRootProxy : NSProxy {
@protected
- __weak Protocol *protocol_;
+ GTM_WEAK Protocol *protocol_;
NSDistantObject *realProxy_;
NSString *registeredName_;
diff --git a/GTMDefines.h b/GTMDefines.h
index d651bb3..2528d19 100644
--- a/GTMDefines.h
+++ b/GTMDefines.h
@@ -500,4 +500,31 @@ GTM_EXTERN void _GTMUnitTestDevLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,
#endif // DEBUG
#endif // GTM_SEL_STRING
+#ifndef GTM_WEAK
+ #if defined(__OBJC_GC__)
+ // In -fobjc-gc mode, __weak means "a reference not visible to the gargabe
+ // collector". __weak references are set to zero when their pointee is
+ // collected. __weak is not needed to prevent cycles because cycles
+ // are cleaned up fine by the garbage collector.
+ #define GTM_WEAK __weak
+ #elif __has_feature(objc_arc_weak)
+ // With ARC enabled, __weak means a reference that isn't implicitly
+ // retained. __weak objects are accessed through runtime functions, so
+ // they are zeroed out, but this requires OS X 10.7+.
+ // At clang r251041+, ARC-style zeroing weak references even work in
+ // non-ARC mode.
+ #define GTM_WEAK __weak
+ #elif __has_feature(objc_arc)
+ // ARC, but targeting 10.6 or older, where zeroing weak references don't
+ // exist.
+ #define GTM_WEAK __unsafe_unretained
+ #else
+ // With manual reference counting, __weak used to be silently ignored.
+ // clang r251041 gives it the ARC semantics instead. This means they
+ // now require a deployment target of 10.7, while some clients of GTM
+ // still target 10.6. In these cases, expand to __unsafe_unretained instead
+ #define GTM_WEAK
+ #endif
+#endif
+
#endif // __OBJC__