Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Fix build of Mac GTM project with static analyzer. Remove GTMGarbageC…
Browse files Browse the repository at this point in the history
…ollection. Remove GC build configs. Remove internal dependence on GTMObjectSingleton.

DELTA=447  (49 added, 296 deleted, 102 changed)

git-svn-id: http://google-toolbox-for-mac.googlecode.com/svn/trunk@649 7dc7ac4e-7543-0410-b95c-c1676fc8e2a3
  • Loading branch information
gtm.daemon committed Dec 19, 2013
1 parent e224f8c commit 9916d4b
Show file tree
Hide file tree
Showing 41 changed files with 141 additions and 388 deletions.
1 change: 0 additions & 1 deletion AddressBook/GTMABAddressBook.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//

#import "GTMABAddressBook.h"
#import "GTMGarbageCollection.h"
#import "GTMTypeCasting.h"

#if GTM_IPHONE_SDK
Expand Down
28 changes: 21 additions & 7 deletions AppKit/GTMCarbonEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#import "GTMCarbonEvent.h"
#import <AppKit/AppKit.h>
#import "GTMObjectSingleton.h"
#import "GTMDebugSelectorValidation.h"
#import "GTMTypeCasting.h"

Expand Down Expand Up @@ -477,8 +476,13 @@ - (void)setDelegate:(id)delegate {

@implementation GTMCarbonEventMonitorHandler

GTMOBJECT_SINGLETON_BOILERPLATE(GTMCarbonEventMonitorHandler,
sharedEventMonitorHandler);
+ (GTMCarbonEventMonitorHandler *)sharedEventMonitorHandler {
static GTMCarbonEventMonitorHandler *obj = nil;
if (!obj) {
obj = [[self alloc] init];
}
return obj;
}

- (EventTargetRef)eventTarget {
return GetEventMonitorTarget();
Expand All @@ -494,8 +498,13 @@ - (EventTargetRef)eventTarget {

@implementation GTMCarbonEventApplicationEventHandler

GTMOBJECT_SINGLETON_BOILERPLATE(GTMCarbonEventApplicationEventHandler,
sharedApplicationEventHandler);
+ (GTMCarbonEventApplicationEventHandler *)sharedApplicationEventHandler {
static GTMCarbonEventApplicationEventHandler *obj = nil;
if (!obj) {
obj = [[self alloc] init];
}
return obj;
}

- (EventTargetRef)eventTarget {
return GetApplicationEventTarget();
Expand All @@ -505,8 +514,13 @@ - (EventTargetRef)eventTarget {

@implementation GTMCarbonEventDispatcherHandler

GTMOBJECT_SINGLETON_BOILERPLATE(GTMCarbonEventDispatcherHandler,
sharedEventDispatcherHandler);
+ (GTMCarbonEventDispatcherHandler *)sharedEventDispatcherHandler {
static GTMCarbonEventDispatcherHandler *obj = nil;
if (!obj) {
obj = [[self alloc] init];
}
return obj;
}

// Register for the events we handle, and set up the dictionaries we need
// to keep track of the hotkeys and commands that we handle.
Expand Down
2 changes: 0 additions & 2 deletions AppKit/GTMGetURLHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
// @end

#import <AppKit/AppKit.h>
#import "GTMGarbageCollection.h"
#import "GTMNSAppleEventDescriptor+Foundation.h"
#import "GTMMethodCheck.h"

Expand Down Expand Up @@ -119,7 +118,6 @@ + (void)getUrl:(NSAppleEventDescriptor *)event
sHandler = [GTMGetURLHandler handlerForBundle:bundle];
if (sHandler) {
[sHandler retain];
GTMNSMakeUncollectable(sHandler);
}
}
[sHandler getUrl:event withReplyEvent:replyEvent];
Expand Down
23 changes: 14 additions & 9 deletions AppKit/GTMGoogleSearch.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
//

#import "GTMGoogleSearch.h"
#import "GTMObjectSingleton.h"
#import "GTMGarbageCollection.h"
#import "GTMDefines.h"

#if GTM_IPHONE_SDK
#import <UIKit/UIKit.h>
Expand Down Expand Up @@ -128,7 +127,13 @@ - (void)updateAllAppsDomain:(NSString*)domain language:(NSString*)language;

@implementation GTMGoogleSearch

GTMOBJECT_SINGLETON_BOILERPLATE(GTMGoogleSearch, sharedInstance);
+ (GTMGoogleSearch *)sharedInstance {
static GTMGoogleSearch *obj;
if (!obj) {
obj = [[self alloc] init];
}
return obj;
}

- (id)init {
self = [super init];
Expand Down Expand Up @@ -166,8 +171,8 @@ - (id)init {
}
}

curAppCachedDomain_ = GTMNSMakeCollectable(domain);
curAppCachedLanguage_ = GTMNSMakeCollectable(lang);
curAppCachedDomain_ = (NSString *)domain;
curAppCachedLanguage_ = (NSString *)lang;

NSBundle *bundle = [NSBundle mainBundle];

Expand All @@ -180,14 +185,14 @@ - (id)init {

#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS
- (void)finalize {
[[NSDistributedNotificationCenter defaultCenter] removeObject:self];
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
[super finalize];
}
#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS

- (void)dealloc {
#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS
[[NSDistributedNotificationCenter defaultCenter] removeObject:self];
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS
[allAppsCachedDomain_ release];
[allAppsCachedLanguage_ release];
Expand Down Expand Up @@ -484,8 +489,8 @@ - (void)reloadAllAppCachedValues:(NSNotification*)notification {
}
}

allAppsCachedDomain_ = GTMNSMakeCollectable(domain);
allAppsCachedLanguage_ = GTMNSMakeCollectable(lang);
allAppsCachedDomain_ = (NSString *)domain;
allAppsCachedLanguage_ = (NSString *)lang;
}

// -updateAllAppsDomain:language:
Expand Down
9 changes: 7 additions & 2 deletions AppKit/GTMHotKeyTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#import "GTMHotKeyTextField.h"

#import <Carbon/Carbon.h>
#import "GTMObjectSingleton.h"

#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
#import "GTMSystemVersion.h"
Expand Down Expand Up @@ -570,7 +569,13 @@ + (NSString *)stringForKeycode:(UInt16)keycode

@implementation GTMHotKeyFieldEditor

GTMOBJECT_SINGLETON_BOILERPLATE(GTMHotKeyFieldEditor, sharedHotKeyFieldEditor)
+ (GTMHotKeyFieldEditor *)sharedHotKeyFieldEditor {
static GTMHotKeyFieldEditor *obj;
if (!obj) {
obj = [[self alloc] init];
}
return obj;
}

- (id)init {
if ((self = [super init])) {
Expand Down
18 changes: 2 additions & 16 deletions AppKit/GTMLargeTypeWindowTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#import "GTMLargeTypeWindow.h"
#import "GTMNSObject+UnitTesting.h"
#import "GTMUnitTestDevLog.h"
#import "GTMGarbageCollection.h"
#import "GTMSystemVersion.h"

NSString *const kLongTextBlock =
Expand Down Expand Up @@ -58,21 +57,8 @@ @interface GTMLargeTypeWindowTest : GTMTestCase

@implementation GTMLargeTypeWindowTest
- (BOOL)shouldDoAnimateCopy {
// NOTE: Animated copy tests are disabled when GC is on.
// See the comment/warning in the GTMLargeTypeWindow.h for more details,
// but we disable them to avoid the tests failing (crashing) when it's Apple's
// bug. Please bump the system check as appropriate when new systems are
// tested. Currently broken on 10.5.6 and below.
// Radar 6137322 CIFilter crashing when run with GC enabled
SInt32 major, minor, bugfix;
[GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugfix];
if (!(GTMIsGarbageCollectionEnabled()
&& major <= 10 && minor <= 5 && bugfix <= 6)) {
return YES;
} else {
NSLog(@"--- animated copy not run because of GC incompatibilites ---");
return NO;
}
// This method previously checked for incompatibilities with garbage collection.
return YES;
}

- (void)setUp {
Expand Down
1 change: 0 additions & 1 deletion AppKit/GTMLoginItems.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#import "GTMLoginItems.h"
#import "GTMDefines.h"
#import "GTMGarbageCollection.h"

#include <Carbon/Carbon.h>

Expand Down
1 change: 0 additions & 1 deletion AppKit/GTMNSBezierPath+CGPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//
#import "GTMNSBezierPath+CGPath.h"
#import "GTMDefines.h"
#import "GTMGarbageCollection.h"

@implementation NSBezierPath (GTMBezierPathCGPathAdditions)

Expand Down
2 changes: 1 addition & 1 deletion AppKit/GTMNSImage+SearchCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//

#import "GTMNSImage+SearchCache.h"
#import "GTMGarbageCollection.h"
#import "GTMDefines.h"

@implementation NSImage (GTMNSImageSearchCache)
+ (NSImage *)gtm_imageWithPath:(NSString *)path {
Expand Down
13 changes: 9 additions & 4 deletions AppKit/GTMNSWorkspace+Running.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
#import "GTMNSWorkspace+Running.h"
#import <Carbon/Carbon.h>
#import <unistd.h>
#import "GTMGarbageCollection.h"
#import "GTMSystemVersion.h"
#import "GTMObjectSingleton.h"


NSString *const kGTMWorkspaceRunningPSN = @"PSN";
NSString *const kGTMWorkspaceRunningFlavor = @"Flavor";
Expand Down Expand Up @@ -190,8 +189,14 @@ - (NSArray *)gtm_launchedApplications {

@implementation GTMWorkspaceRunningApplicationList

GTMOBJECT_SINGLETON_BOILERPLATE(GTMWorkspaceRunningApplicationList,
sharedApplicationList)
+ (GTMWorkspaceRunningApplicationList *)sharedApplicationList {
static GTMWorkspaceRunningApplicationList *obj;
if (!obj) {
obj = [[self alloc] init];
}
return obj;
}

- (id)init {
if ((self = [super init])) {
[self didLaunchOrTerminateApp:nil];
Expand Down
11 changes: 7 additions & 4 deletions AppKit/GTMUILocalizerAndLayoutTweaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#import "GTMUILocalizerAndLayoutTweaker.h"
#import "GTMUILocalizer.h"
#import "GTMNSNumber+64Bit.h"

// Controls if +wrapString:width:font: uses a subclassed TypeSetter to do
// its work in one pass.
Expand Down Expand Up @@ -69,7 +68,7 @@ - (void)dealloc {
}

- (BOOL)shouldBreakLineByWordBeforeCharacterAtIndex:(NSUInteger)charIndex {
[array_ addObject:[NSNumber gtm_numberWithUnsignedInteger:charIndex]];
[array_ addObject:[NSNumber numberWithUnsignedInteger:charIndex]];
return YES;
}

Expand Down Expand Up @@ -207,7 +206,7 @@ + (NSString*)wrapString:(NSString *)string
NSNumber *number;
while ((number = [reverseEnumerator nextObject]) != nil) {
[workerStr insertString:kForcedWrapString
atIndex:[number gtm_unsignedIntegerValue]];
atIndex:[number unsignedIntegerValue]];
}
#else
// Find out how tall lines would be for the layout loop.
Expand Down Expand Up @@ -454,7 +453,11 @@ - (CGFloat)tweakLayoutWithOffset:(NSPoint)offset {
// once we know this view's size.
if (IsRightAnchored(subView)) {
[rightAlignedSubViews addObject:subView];
NSNumber *nsDelta = [NSNumber gtm_numberWithCGFloat:delta];
#if CGFLOAT_IS_DOUBLE
NSNumber *nsDelta = [NSNumber numberWithDouble:delta];
#else
NSNumber *nsDelta = [NSNumber numberWithFloat:delta];
#endif
[rightAlignedSubViewDeltas addObject:nsDelta];
}
}
Expand Down
14 changes: 3 additions & 11 deletions Foundation/GTMAbstractDOListenerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
#import "GTMSenTestCase.h"
#import "GTMAbstractDOListener.h"

// Needed for GTMIsGarbageCollectionEnabled
#import "GTMGarbageCollection.h"

// Needed for GTMUnitTestDevLog expectPattern
#import "GTMUnitTestDevLog.h"

Expand Down Expand Up @@ -358,16 +355,11 @@ - (void)testAbstractDOListenerRelease {
listenerCount + 1, nil);
[pool drain];

if (!GTMIsGarbageCollectionEnabled()) {
// Not much point with GC on.
STAssertEquals([listener retainCount], (NSUInteger)1, nil);
}
STAssertEquals([listener retainCount], (NSUInteger)1, nil);

[listener release];
if (!GTMIsGarbageCollectionEnabled()) {
STAssertEquals([[GTMAbstractDOListener allListeners] count], listenerCount,
nil);
}
STAssertEquals([[GTMAbstractDOListener allListeners] count], listenerCount,
nil);
}

@end
14 changes: 4 additions & 10 deletions Foundation/GTMFileSystemKQueueTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#import "GTMSenTestCase.h"
#import "GTMFileSystemKQueue.h"
#import "GTMGarbageCollection.h"
#import "GTMUnitTestDevLog.h"


Expand Down Expand Up @@ -509,15 +508,10 @@ - (void)testNoSpinHang {
#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5

// Now destroy the queue, with events outstanding from the CFSocket, but
// unconsumed. For GC this involves us using a private method since |helper|
// still has a reference. For non-GC we'll force the release.
if (GTMIsGarbageCollectionEnabled()) {
[testKQ unregisterWithKQueue];
} else {
STAssertEquals([testKQ retainCount], (NSUInteger)1, nil);
[testKQ release];
testKQ = nil;
}
// unconsumed.
STAssertEquals([testKQ retainCount], (NSUInteger)1, nil);
[testKQ release];
testKQ = nil;

// Spin the runloop, no events were delivered (and we should not hang)
[self spinForEvents:helper];
Expand Down
1 change: 0 additions & 1 deletion Foundation/GTMFourCharCode.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#import "GTMDefines.h"
#import "GTMFourCharCode.h"
#import "GTMGarbageCollection.h"
#import <CoreServices/CoreServices.h>

@implementation GTMFourCharCode
Expand Down
Loading

0 comments on commit 9916d4b

Please sign in to comment.