Migrate APL plug-in to use ARC.

CQTexperiment
Chris Moeller 2016-05-03 00:57:52 -07:00
parent a2ff3dcb0a
commit 3c229f2017
3 changed files with 6 additions and 18 deletions

View File

@ -186,6 +186,7 @@
1DEB913F08733D840010E9CD /* Debug */ = { 1DEB913F08733D840010E9CD /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
@ -200,6 +201,7 @@
1DEB914008733D840010E9CD /* Release */ = { 1DEB914008733D840010E9CD /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_IDENTITY = "Developer ID Application";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;

View File

@ -22,7 +22,7 @@
//Need to alter length //Need to alter length
[properties setObject:[NSNumber numberWithLong:trackLength] forKey:@"totalFrames"]; [properties setObject:[NSNumber numberWithLong:trackLength] forKey:@"totalFrames"];
return [properties autorelease]; return properties;
} }
- (BOOL)open:(id<CogSource>)s - (BOOL)open:(id<CogSource>)s
@ -35,18 +35,15 @@
[s close]; [s close];
apl = [APLFile createWithFile:[url path]]; apl = [APLFile createWithFile:[url path]];
[apl retain];
//Kind of a hackish way of accessing outside classes. //Kind of a hackish way of accessing outside classes.
source = [NSClassFromString(@"AudioSource") audioSourceForURL:[apl file]]; source = [NSClassFromString(@"AudioSource") audioSourceForURL:[apl file]];
[source retain];
if (![source open:[apl file]]) { if (![source open:[apl file]]) {
ALog(@"Could not open source for file '%@' referenced in apl", [apl file]); ALog(@"Could not open source for file '%@' referenced in apl", [apl file]);
return NO; return NO;
} }
decoder = [NSClassFromString(@"AudioDecoder") audioDecoderForSource:source]; decoder = [NSClassFromString(@"AudioDecoder") audioDecoderForSource:source];
[decoder retain];
if (![decoder open:source]) { if (![decoder open:source]) {
ALog(@"Could not open decoder for source for apl"); ALog(@"Could not open decoder for source for apl");
@ -80,19 +77,12 @@
- (void)close { - (void)close {
if (decoder) { if (decoder) {
[decoder close]; [decoder close];
[decoder release];
decoder = nil; decoder = nil;
} }
if (source) {
[source release];
source = nil; source = nil;
}
if (apl) {
[apl release];
apl = nil; apl = nil;
} }
}
- (long)seek:(long)frame - (long)seek:(long)frame

View File

@ -39,7 +39,6 @@
[unixPath insertString:basePath atIndex:0]; [unixPath insertString:basePath atIndex:0];
} }
NSURL *url = [NSURL URLWithString:[[NSURL fileURLWithPath:unixPath] absoluteString]]; NSURL *url = [NSURL URLWithString:[[NSURL fileURLWithPath:unixPath] absoluteString]];
[unixPath release];
return url; return url;
} }
@ -59,7 +58,7 @@
ALog(@"Cannot read header"); ALog(@"Cannot read header");
return nil; return nil;
} }
NSString* str = [[[NSString alloc] autorelease] initWithData:da encoding: NSASCIIStringEncoding]; NSString* str = [[NSString alloc] initWithData:da encoding: NSASCIIStringEncoding];
if([str compare:header options:NSCaseInsensitiveSearch]) { if([str compare:header options:NSCaseInsensitiveSearch]) {
ALog(@"APL header mismatch"); ALog(@"APL header mismatch");
return nil; return nil;
@ -71,7 +70,6 @@
while((line = [self readline:f])) { while((line = [self readline:f])) {
if (![line compare:@"----- APE TAG (DO NOT TOUCH!!!) -----\r\n" options:NSCaseInsensitiveSearch]) break; if (![line compare:@"----- APE TAG (DO NOT TOUCH!!!) -----\r\n" options:NSCaseInsensitiveSearch]) break;
if([line characterAtIndex:0] == '-') break; if([line characterAtIndex:0] == '-') break;
[scanner release];
scanner = [[NSScanner alloc] initWithString:line]; scanner = [[NSScanner alloc] initWithString:line];
NSString* field = nil, *value = nil; NSString* field = nil, *value = nil;
if (![scanner scanUpToString:@"=" intoString:&field]) continue; if (![scanner scanUpToString:@"=" intoString:&field]) continue;
@ -79,7 +77,6 @@
if (![scanner scanUpToString:@"\r\n" intoString:&value]) continue; if (![scanner scanUpToString:@"\r\n" intoString:&value]) continue;
if (![field compare:@"Image File" options:NSCaseInsensitiveSearch]) if (![field compare:@"Image File" options:NSCaseInsensitiveSearch])
{ {
[file release];
file = [self urlForPath:value relativeTo:filename]; file = [self urlForPath:value relativeTo:filename];
DLog(@"APL refers to file '%@' read '%@'", file, value); DLog(@"APL refers to file '%@' read '%@'", file, value);
continue; continue;
@ -97,7 +94,6 @@
continue; continue;
} }
} }
[scanner release];
//check here for EOF? cocoa does not have this functionality :( //check here for EOF? cocoa does not have this functionality :(
[f closeFile]; [f closeFile];
} }