Skip to content

Commit

Permalink
Upgraded the project to use ARC
Browse files Browse the repository at this point in the history
  • Loading branch information
justMaku committed Mar 31, 2015
1 parent f91303c commit 7b1e223
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 71 deletions.
10 changes: 2 additions & 8 deletions Classes/AMIndeterminateProgressIndicatorCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,17 @@ - (id)init
return self;
}

- (void)dealloc
{
[NSColor release];
[super dealloc];
}

- (NSColor *)color
{
return [[color retain] autorelease];
return color;
}

- (void)setColor:(NSColor *)value
{
CGFloat alphaComponent;
if (color != value) {
[color release];
color = [value retain];
color = value;
[[color colorUsingColorSpaceName:@"NSCalibratedRGBColorSpace"] getRed:&redComponent green:&greenComponent blue:&blueComponent alpha:&alphaComponent];
// NSAssert((alphaComponent > 0.999), @"color must be opaque"); // gives a warning in xcode4
}
Expand Down
9 changes: 3 additions & 6 deletions Classes/CPXcodeWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,17 @@ - (NSArray *)filesAndSymbolsFromProjectForQuery:(NSString *)query
{
query = [self normalizedQueryForQuery:query];

NSArray *resultArray = [NSArray array];
NSArray *files = [NSArray array];
NSArray *symbols = [NSArray array];

files = [self cpFileReferencesMatchingQuery:query];
NSArray *files = [self cpFileReferencesMatchingQuery:query];

if ([files count] < MAX_OBJECT_COUNT_FOR_SORT_AND_FILTER) {
symbols = [self topLevelCPSymbolsMatchingQuery:query];
} else {
USER_LOG(@"not adding symbols - we already have %d entries.", MAX_OBJECT_COUNT_FOR_SORT_AND_FILTER);
}

resultArray = [symbols arrayByAddingObjectsFromArray:files];
NSArray* resultArray = [symbols arrayByAddingObjectsFromArray:files];

// TODO/FIXME: We could add API search here
resultArray = [self arrayByFilteringAndSortingArray:resultArray
Expand Down Expand Up @@ -622,11 +620,10 @@ - (NSArray *)recursiveChildrenOfIDEIndexSymbol:(IDEIndexSymbol *)ideIndexSymbol
- (NSArray *)allIDEIndexSymbolsFromCPFileReference:(CPFileReference *)fileReference
{
NSMutableArray *objects = [NSMutableArray array];
NSArray *topLevelSymbols = [NSArray array];

PBXFileReference *pbxFileReference = [self pbxFileReferenceForCPFileReference:fileReference];

topLevelSymbols = [[self currentIndex] topLevelSymbolsInFile:[pbxFileReference absolutePath]];
NSArray * topLevelSymbols = [[self currentIndex] topLevelSymbolsInFile:[pbxFileReference absolutePath]];

for (IDEIndexSymbol *ideSymbol in topLevelSymbols) {
[objects addObject:ideSymbol];
Expand Down
15 changes: 9 additions & 6 deletions CodePilot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = Macoscope;
};
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "CodePilot" */;
Expand Down Expand Up @@ -629,7 +629,6 @@
4BEE524A1339193600DA9881 /* NSAppleEventDescriptor+ToObject.m in Sources */,
4BEE524B1339193600DA9881 /* MCLog.m in Sources */,
4BEE524E1339193600DA9881 /* CPFileReferenceCell.m in Sources */,
4BEE524F1339193600DA9881 /* RegexKitLite.m in Sources */,
4BEE52501339193600DA9881 /* CPStatusLabel.m in Sources */,
4BEE52511339193600DA9881 /* NSArray+MiscExtensions.m in Sources */,
4BEE52521339193600DA9881 /* NSView+AllSubviews.m in Sources */,
Expand Down Expand Up @@ -690,6 +689,7 @@
1DEB913F08733D840010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_GC = supported;
GCC_OPTIMIZATION_LEVEL = 0;
Expand All @@ -704,6 +704,7 @@
1DEB914008733D840010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_GC = supported;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
Expand All @@ -717,6 +718,7 @@
4BE2963F12E60EBB0026BDAC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_GC = unsupported;
Expand All @@ -728,6 +730,7 @@
4BE2964012E60EBB0026BDAC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_GC = unsupported;
Expand All @@ -739,15 +742,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEPLOYMENT_LOCATION = YES;
DEPLOYMENT_POSTPROCESSING = YES;
DSTROOT = "$(HOME)";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_GC = unsupproted;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -771,14 +774,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_LOCATION = YES;
DEPLOYMENT_POSTPROCESSING = YES;
DSTROOT = "$(HOME)";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_ENABLE_OBJC_GC = unsupproted;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Other Sources/CodePilot_Prefix.pch";
Expand Down
87 changes: 40 additions & 47 deletions MCCommons/MCLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,53 @@
@implementation MCLog
+ (void)prefix:(NSString *)prefixString format:(NSString *)format, ...
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
va_list ap;
NSString *message;
va_start(ap,format);

message = [[NSString alloc] initWithFormat:format arguments:ap];
va_end(ap);

NSLog(@"%@ %@", prefixString, message);

[message release];
[pool release];
@autoreleasepool {
va_list ap;
NSString *message;
va_start(ap,format);

message = [[NSString alloc] initWithFormat:format arguments:ap];
va_end(ap);

NSLog(@"%@ %@", prefixString, message);

}
}

+ (void)file:(char *)sourceFile function:(char *)functionName lineNumber:(int)lineNumber format:(NSString *)format, ...
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
va_list ap;
NSString *print, *file, *function;
va_start(ap,format);

file = [[NSString alloc] initWithBytes:sourceFile length:strlen(sourceFile) encoding:NSUTF8StringEncoding];


function = [NSString stringWithCString:functionName encoding:NSASCIIStringEncoding];
print = [[NSString alloc] initWithFormat:format arguments:ap];
va_end(ap);

@autoreleasepool {
va_list ap;
NSString *print, *file, *function;
va_start(ap,format);
file = [[NSString alloc] initWithBytes:sourceFile length:strlen(sourceFile) encoding:NSUTF8StringEncoding];
function = [NSString stringWithCString:functionName encoding:NSASCIIStringEncoding];
print = [[NSString alloc] initWithFormat:format arguments:ap];
va_end(ap);
NSString *fileLocation = [file lastPathComponent];

NSLog(@"%@:%d %@; %@", fileLocation, lineNumber, function, print);

[print release];
[file release];
[pool release];

NSLog(@"%@:%d %@; %@", fileLocation, lineNumber, function, print);

}
}
+ (NSString *)messageWithFile:(char *)sourceFile function:(char *)functionName lineNumber:(int)lineNumber format:(NSString *)format, ...
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
va_list ap;
NSString *print, *file, *function;
va_start(ap,format);
file = [[NSString alloc] initWithBytes:sourceFile length:strlen(sourceFile) encoding:NSUTF8StringEncoding];

function = [NSString stringWithCString:functionName encoding:NSASCIIStringEncoding];
print = [[NSString alloc] initWithFormat:format arguments:ap];
va_end(ap);
NSString * buffer = [NSString stringWithFormat:@"%@:%d %@; %@", [file lastPathComponent], lineNumber, function, print];
[print release];
[file release];
[pool release];
return buffer;
@autoreleasepool {
va_list ap;
NSString *print, *file, *function;
va_start(ap,format);
file = [[NSString alloc] initWithBytes:sourceFile length:strlen(sourceFile) encoding:NSUTF8StringEncoding];

function = [NSString stringWithCString:functionName encoding:NSASCIIStringEncoding];
print = [[NSString alloc] initWithFormat:format arguments:ap];
va_end(ap);
NSString * buffer = [NSString stringWithFormat:@"%@:%d %@; %@", [file lastPathComponent], lineNumber, function, print];
return buffer;
}
}

NSString * MCToStringFromTypeAndValue(const char * typeCode, void * value)
Expand All @@ -87,11 +82,9 @@ + (NSString *)messageWithFile:(char *)sourceFile function:(char *)functionName l
return NSStringFromRange(*(NSRange *)value);

} else if (strcmp(typeCode, @encode(id)) == 0) {
return MCNSStringWithFormat(@"%@", *(id *)value);

return MCNSStringWithFormat(@"%@", (__bridge id)(value));
} else if (strcmp(typeCode, @encode(BOOL)) == 0) {
return (*(BOOL *)value) ? @"YES" : @"NO";

} else if (strcmp(typeCode, @encode(int)) == 0) {
return MCNSStringWithFormat(@"%d", *(int *)value);

Expand Down
8 changes: 4 additions & 4 deletions MCCommons/MCStringScoring.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ float MCStringScoring_scoreStringForQuery(const char *scoredString, const char *

queryCharMatchIndexes = malloc(sizeof(int *)*queryLength);
for (index = 0; index < queryLength; index++) {
queryCharMatchIndexes[index] = malloc(sizeof(int *)*(valueLength+1));
memset(queryCharMatchIndexes[index], -1, sizeof(int *)*(valueLength+1));
queryCharMatchIndexes[index] = (int *)malloc(sizeof(int)*(valueLength+1));
memset(queryCharMatchIndexes[index], -1, sizeof(int)*(valueLength+1));
}

for (valueIndex = 0; valueIndex < valueLength; valueIndex++) {
Expand Down Expand Up @@ -453,8 +453,8 @@ float MCStringScoring_scoreStringForQueryNEW(const char *scoredString, const cha

queryCharMatchIndexes = malloc(sizeof(int *)*queryLength);
for (index = 0; index < queryLength; index++) {
queryCharMatchIndexes[index] = malloc(sizeof(int *)*(valueLength+1));
memset(queryCharMatchIndexes[index], -1, sizeof(int *)*(valueLength+1));
queryCharMatchIndexes[index] = (int *)malloc(sizeof(int)*(valueLength+1));
memset(queryCharMatchIndexes[index], -1, sizeof(int)*(valueLength+1));
}

for (valueIndex = 0; valueIndex < valueLength; valueIndex++) {
Expand Down

0 comments on commit 7b1e223

Please sign in to comment.