Permalink
Browse files

Moving the ARC macros to DDMathParser.h

  • Loading branch information...
1 parent e3d924d commit b7940ccfa6abc28324b647334c634ed4b6ed2acb @davedelong davedelong committed Sep 29, 2011
View
28 DDMathParser.xcodeproj/project.pbxproj
@@ -88,16 +88,16 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
- 08FB7796FE84155DC02AAC07 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 08FB7796FE84155DC02AAC07 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = main.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32A70AAB03705E1F00C91783 /* DDMathParser_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDMathParser_Prefix.pch; sourceTree = "<group>"; };
550C416613BA8BCA00A041BC /* DDMathStringTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDMathStringTokenizer.h; sourceTree = "<group>"; };
- 550C416713BA8BCA00A041BC /* DDMathStringTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDMathStringTokenizer.m; sourceTree = "<group>"; };
+ 550C416713BA8BCA00A041BC /* DDMathStringTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDMathStringTokenizer.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
5514EE291347CE9B0010B9D8 /* DDMathParserMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDMathParserMacros.h; path = DDMathParser/DDMathParserMacros.h; sourceTree = "<group>"; };
551EA4B613CD657300302C67 /* _DDOperatorTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDOperatorTerm.h; sourceTree = "<group>"; };
551EA4B713CD657400302C67 /* _DDOperatorTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDOperatorTerm.m; sourceTree = "<group>"; };
551EA4C313CF415100302C67 /* _DDFunctionContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDFunctionContainer.h; sourceTree = "<group>"; };
- 551EA4C413CF415100302C67 /* _DDFunctionContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDFunctionContainer.m; sourceTree = "<group>"; };
+ 551EA4C413CF415100302C67 /* _DDFunctionContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDFunctionContainer.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
552532B512C1C92D00A942A7 /* _DDFunctionUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDFunctionUtilities.h; sourceTree = "<group>"; };
552532B612C1C92D00A942A7 /* _DDFunctionUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDFunctionUtilities.m; sourceTree = "<group>"; };
5526E9E01310EF880018B4C9 /* DDTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTypes.m; sourceTree = "<group>"; };
@@ -108,22 +108,22 @@
5537E37212AB214D0000CFED /* DemoController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoController.m; sourceTree = "<group>"; };
5537E37412AB229C0000CFED /* Demo.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Demo.xib; sourceTree = "<group>"; };
5554D58912944AFD00A62529 /* DDMathEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDMathEvaluator.h; sourceTree = "<group>"; };
- 5554D58A12944AFD00A62529 /* DDMathEvaluator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDMathEvaluator.m; sourceTree = "<group>"; };
+ 5554D58A12944AFD00A62529 /* DDMathEvaluator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDMathEvaluator.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
5554D5EF129478E800A62529 /* DDMathEvaluator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DDMathEvaluator+Private.h"; sourceTree = "<group>"; };
556C293513CD4276005203F1 /* _DDGroupTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDGroupTerm.h; sourceTree = "<group>"; };
- 556C293613CD4276005203F1 /* _DDGroupTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDGroupTerm.m; sourceTree = "<group>"; };
+ 556C293613CD4276005203F1 /* _DDGroupTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDGroupTerm.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
556C293813CD42A8005203F1 /* _DDFunctionTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDFunctionTerm.h; sourceTree = "<group>"; };
- 556C293913CD42A8005203F1 /* _DDFunctionTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDFunctionTerm.m; sourceTree = "<group>"; };
+ 556C293913CD42A8005203F1 /* _DDFunctionTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDFunctionTerm.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
556C293B13CD42F3005203F1 /* _DDNumberTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDNumberTerm.h; sourceTree = "<group>"; };
556C293C13CD42F4005203F1 /* _DDNumberTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDNumberTerm.m; sourceTree = "<group>"; };
556C293E13CD42FE005203F1 /* _DDVariableTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDVariableTerm.h; sourceTree = "<group>"; };
556C293F13CD42FE005203F1 /* _DDVariableTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDVariableTerm.m; sourceTree = "<group>"; };
557067B613CC0D19004CB1B2 /* _DDParserTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDParserTerm.h; sourceTree = "<group>"; };
- 557067B713CC0D19004CB1B2 /* _DDParserTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDParserTerm.m; sourceTree = "<group>"; };
+ 557067B713CC0D19004CB1B2 /* _DDParserTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDParserTerm.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
5570E3B112AA2D8D002FE945 /* DDParserTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDParserTypes.h; sourceTree = "<group>"; };
- 55ABBAA9142ECB1300BDF29A /* _DDRewriteRule.h */ = {isa = PBXFileReference; fileEncoding = 4; name = _DDRewriteRule.h; path = DDMathParser/_DDRewriteRule.h; sourceTree = "<group>"; };
- 55ABBAAA142ECB1300BDF29A /* _DDRewriteRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _DDRewriteRule.m; path = DDMathParser/_DDRewriteRule.m; sourceTree = "<group>"; };
- 55BA673E1298ECA2002279A5 /* DDMathParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDMathParser.h; path = DDMathParser/DDMathParser.h; sourceTree = "<group>"; };
+ 55ABBAA9142ECB1300BDF29A /* _DDRewriteRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _DDRewriteRule.h; path = DDMathParser/_DDRewriteRule.h; sourceTree = "<group>"; };
+ 55ABBAAA142ECB1300BDF29A /* _DDRewriteRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = _DDRewriteRule.m; path = DDMathParser/_DDRewriteRule.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+ 55BA673E1298ECA2002279A5 /* DDMathParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DDMathParser.h; path = DDMathParser/DDMathParser.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
55BA679E1299FA19002279A5 /* NSString+DDMathParsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+DDMathParsing.h"; sourceTree = "<group>"; };
55BA679F1299FA19002279A5 /* NSString+DDMathParsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+DDMathParsing.m"; sourceTree = "<group>"; };
55BFA9A6128CDDEB00A80228 /* UnitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -133,7 +133,7 @@
55D2AD4E1295834600BA2905 /* EvaluationTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EvaluationTests.h; sourceTree = "<group>"; };
55D2AD4F1295834600BA2905 /* EvaluationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EvaluationTests.m; sourceTree = "<group>"; };
55E2FCB5129DC90400CD6023 /* DDParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDParser.h; sourceTree = "<group>"; };
- 55E2FCB6129DC90400CD6023 /* DDParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDParser.m; sourceTree = "<group>"; };
+ 55E2FCB6129DC90400CD6023 /* DDParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDParser.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
55F795E11293175B00EF2716 /* DDMathStringToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDMathStringToken.h; sourceTree = "<group>"; };
55F795E21293175B00EF2716 /* DDMathStringToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDMathStringToken.m; sourceTree = "<group>"; };
55F795F01293235A00EF2716 /* TokenizerTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenizerTests.h; sourceTree = "<group>"; };
@@ -142,11 +142,11 @@
55F7963612934A1400EF2716 /* DDExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDExpression.m; sourceTree = "<group>"; };
55F9EFE81295A9AB00F4A9FD /* DDTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTypes.h; sourceTree = "<group>"; };
55F9EFE91295AF3D00F4A9FD /* _DDFunctionExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDFunctionExpression.h; sourceTree = "<group>"; };
- 55F9EFEA1295AF3D00F4A9FD /* _DDFunctionExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDFunctionExpression.m; sourceTree = "<group>"; };
+ 55F9EFEA1295AF3D00F4A9FD /* _DDFunctionExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDFunctionExpression.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
55F9EFEC1295AF7500F4A9FD /* _DDNumberExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDNumberExpression.h; sourceTree = "<group>"; };
- 55F9EFED1295AF7500F4A9FD /* _DDNumberExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDNumberExpression.m; sourceTree = "<group>"; };
+ 55F9EFED1295AF7500F4A9FD /* _DDNumberExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDNumberExpression.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
55F9EFEF1295AFB500F4A9FD /* _DDVariableExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DDVariableExpression.h; sourceTree = "<group>"; };
- 55F9EFF01295AFB500F4A9FD /* _DDVariableExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DDVariableExpression.m; sourceTree = "<group>"; };
+ 55F9EFF01295AFB500F4A9FD /* _DDVariableExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = _DDVariableExpression.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
55F9F0121295C19900F4A9FD /* NSExpression+EasyParsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSExpression+EasyParsing.h"; sourceTree = "<group>"; };
55F9F0131295C19900F4A9FD /* NSExpression+EasyParsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSExpression+EasyParsing.m"; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* DDMathParser */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DDMathParser; sourceTree = BUILT_PRODUCTS_DIR; };
View
7 DDMathParser/DDExpression.m
@@ -6,6 +6,7 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "DDExpression.h"
#import "DDMathEvaluator.h"
#import "DDMathEvaluator+Private.h"
@@ -24,15 +25,15 @@ + (id) expressionFromString:(NSString *)expressionString error:(NSError **)error
}
+ (id) numberExpressionWithNumber:(NSNumber *)number {
- return AUTORELEASE([[_DDNumberExpression alloc] initWithNumber:number]);
+ return DD_AUTORELEASE([[_DDNumberExpression alloc] initWithNumber:number]);
}
+ (id) functionExpressionWithFunction:(NSString *)function arguments:(NSArray *)arguments error:(NSError **)error {
- return AUTORELEASE([[_DDFunctionExpression alloc] initWithFunction:function arguments:arguments error:error]);
+ return DD_AUTORELEASE([[_DDFunctionExpression alloc] initWithFunction:function arguments:arguments error:error]);
}
+ (id) variableExpressionWithVariable:(NSString *)variable {
- return AUTORELEASE([[_DDVariableExpression alloc] initWithVariable:variable]);
+ return DD_AUTORELEASE([[_DDVariableExpression alloc] initWithVariable:variable]);
}
#pragma mark -
View
8 DDMathParser/DDMathEvaluator.m
@@ -5,7 +5,7 @@
// Created by Dave DeLong on 11/17/10.
// Copyright 2010 Home. All rights reserved.
//
-
+#import "DDMathParser.h"
#import "DDMathEvaluator.h"
#import "DDMathEvaluator+Private.h"
#import "DDParser.h"
@@ -56,7 +56,7 @@ - (void) dealloc {
if (self == _sharedEvaluator) {
_sharedEvaluator = nil;
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
[functions release];
[functionMap release];
[rewriteRules release];
@@ -75,7 +75,7 @@ - (BOOL) registerFunction:(DDMathFunction)function forName:(NSString *)functionN
_DDFunctionContainer *container = [[_DDFunctionContainer alloc] initWithFunction:function name:name];
[functions addObject:container];
[functionMap setObject:container forKey:name];
- RELEASE(container);
+ DD_RELEASE(container);
return YES;
}
@@ -361,7 +361,7 @@ - (void) _registerStandardFunctions {
_DDFunctionContainer *container = [[_DDFunctionContainer alloc] initWithFunction:function name:functionName];
[functions addObject:container];
[functionMap setObject:container forKey:functionName];
- RELEASE(container);
+ DD_RELEASE(container);
} else {
NSLog(@"error registering function: %@", functionName);
}
View
19 DDMathParser/DDMathParser.h
@@ -16,3 +16,22 @@
#define DDRuleTemplateAnyFunction @"__func"
#define DDRuleTemplateAnyVariable @"__var"
#define DDRuleTemplateAnyExpression @"__exp"
+
+
+
+#if __has_feature(objc_arc)
+
+#define DD_HAS_ARC 1
+#define DD_RETAIN(_o) (_o)
+#define DD_RELEASE(_o)
+#define DD_AUTORELEASE(_o) (_o)
+
+#else
+
+#define DD_HAS_ARC 0
+#define DD_RETAIN(_o) [(_o) retain]
+#define DD_RELEASE(_o) [(_o) release]
+#define DD_AUTORELEASE(_o) [(_o) autorelease]
+
+#endif
+
View
5 DDMathParser/DDMathStringToken.m
@@ -6,12 +6,13 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "DDMathStringToken.h"
@implementation DDMathStringToken
@synthesize token, tokenType, operatorType, operatorPrecedence, operatorArity;
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void) dealloc {
[token release];
[numberValue release];
@@ -110,7 +111,7 @@ - (id) initWithToken:(NSString *)t type:(DDTokenType)type {
}
+ (id) mathStringTokenWithToken:(NSString *)t type:(DDTokenType)type {
- return AUTORELEASE([[self alloc] initWithToken:t type:type]);
+ return DD_AUTORELEASE([[self alloc] initWithToken:t type:type]);
}
- (NSNumber *) numberValue {
View
15 DDMathParser/DDMathStringTokenizer.m
@@ -6,6 +6,7 @@
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
+#import "DDMathParser.h"
#import "DDMathStringTokenizer.h"
#import "DDMathParserMacros.h"
#import "DDMathStringToken.h"
@@ -40,7 +41,7 @@ + (NSCharacterSet *)_operatorCharacterSet {
static dispatch_once_t onceToken;
static NSCharacterSet *_operatorSet = nil;
dispatch_once(&onceToken, ^{
- _operatorSet = RETAIN([NSCharacterSet characterSetWithCharactersInString:@"+-*/&|!%^~()<>,x"]);
+ _operatorSet = DD_RETAIN([NSCharacterSet characterSetWithCharactersInString:@"+-*/&|!%^~()<>,x"]);
});
return _operatorSet;
}
@@ -63,13 +64,13 @@ + (NSCharacterSet *)_singleCharacterFunctionCharacterSet {
static NSCharacterSet *_singleCharFunctionSet = nil;
dispatch_once(&onceToken, ^{
NSString *singleChars = [NSString stringWithFormat:@"\u03C0\u03D5\u03C4"]; // π, ϕ, and τ
- _singleCharFunctionSet = RETAIN([NSCharacterSet characterSetWithCharactersInString:singleChars]);
+ _singleCharFunctionSet = DD_RETAIN([NSCharacterSet characterSetWithCharactersInString:singleChars]);
});
return _singleCharFunctionSet;
}
+ (id)tokenizerWithString:(NSString *)expressionString error:(NSError **)error {
- return AUTORELEASE([[self alloc] initWithString:expressionString error:error]);
+ return DD_AUTORELEASE([[self alloc] initWithString:expressionString error:error]);
}
- (id)initWithString:(NSString *)expressionString error:(NSError **)error {
@@ -87,13 +88,13 @@ - (id)initWithString:(NSString *)expressionString error:(NSError **)error {
DDMathStringToken *token = nil;
while((token = [self _nextTokenWithError:error]) != nil) {
if (![self _processToken:token withError:error]) {
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
}
if (error && *error) {
- RELEASE(self);
+ DD_RELEASE(self);
self = nil;
} else {
[self _processToken:nil withError:nil];
@@ -109,7 +110,7 @@ - (void)finalize {
- (void)dealloc {
free(_characters);
-#if !HAS_ARC
+#if !DD_HAS_ARC
[_tokens release];
[super dealloc];
#endif
@@ -247,7 +248,7 @@ - (void)appendToken:(DDMathStringToken *)token {
#pragma mark Character methods
- (NSArray *)tokens {
- return AUTORELEASE([_tokens copy]);
+ return DD_AUTORELEASE([_tokens copy]);
}
- (DDMathStringToken *) nextToken {
DDMathStringToken *t = [self peekNextToken];
View
19 DDMathParser/DDParser.m
@@ -6,6 +6,7 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "DDParser.h"
#import "DDMathParserMacros.h"
#import "_DDParserTerm.h"
@@ -80,7 +81,7 @@ + (void) setDefaultPowerAssociativity:(DDOperatorAssociativity)newAssociativity
+ (id) parserWithString:(NSString *)string error:(NSError **)error {
- return AUTORELEASE([[self alloc] initWithString:string error:error]);
+ return DD_AUTORELEASE([[self alloc] initWithString:string error:error]);
}
- (id) initWithString:(NSString *)string error:(NSError **)error {
@@ -89,16 +90,16 @@ - (id) initWithString:(NSString *)string error:(NSError **)error {
}
+ (id)parserWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)error {
- return AUTORELEASE([[self alloc] initWithTokenizer:tokenizer error:error]);
+ return DD_AUTORELEASE([[self alloc] initWithTokenizer:tokenizer error:error]);
}
- (id)initWithTokenizer:(DDMathStringTokenizer *)t error:(NSError **)error {
ERR_ASSERT(error);
self = [super init];
if (self) {
- tokenizer = RETAIN(t);
+ tokenizer = DD_RETAIN(t);
if (!tokenizer) {
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
@@ -115,7 +116,7 @@ - (id)initWithTokenizer:(DDMathStringTokenizer *)t error:(NSError **)error {
return self;
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void) dealloc {
[tokenizer release];
[super dealloc];
@@ -156,7 +157,7 @@ - (DDExpression *) parsedExpressionWithError:(NSError **)error {
DDExpression *expression = nil;
-#if HAS_ARC
+#if DD_HAS_ARC
@autoreleasepool {
#else
NSAutoreleasePool * parserPool = [[NSAutoreleasePool alloc] init];
@@ -171,10 +172,10 @@ - (DDExpression *) parsedExpressionWithError:(NSError **)error {
goto errorExit;
}
- expression = RETAIN([root expressionWithError:error]);
+ expression = DD_RETAIN([root expressionWithError:error]);
errorExit:
-#if HAS_ARC
+#if DD_HAS_ARC
;
}
#else
@@ -183,7 +184,7 @@ - (DDExpression *) parsedExpressionWithError:(NSError **)error {
[*error autorelease];
#endif
- return AUTORELEASE(expression);
+ return DD_AUTORELEASE(expression);
}
@end
View
2 DDMathParser/_DDFunctionContainer.m
@@ -26,7 +26,7 @@ - (id)initWithFunction:(DDMathFunction)f name:(NSString *)name {
return self;
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void)dealloc {
[function release];
[aliases release];
View
5 DDMathParser/_DDFunctionExpression.m
@@ -6,6 +6,7 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDFunctionExpression.h"
#import "DDMathEvaluator.h"
#import "DDMathEvaluator+Private.h"
@@ -24,7 +25,7 @@ - (id) initWithFunction:(NSString *)f arguments:(NSArray *)a error:(NSError **)e
*error = ERR_GENERIC(@"function arguments must be DDExpression objects");
*error = nil;
}
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
}
@@ -46,7 +47,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:[self arguments] forKey:@"arguments"];
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void) dealloc {
[function release];
[arguments release];
View
7 DDMathParser/_DDFunctionTerm.m
@@ -6,6 +6,7 @@
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDFunctionTerm.h"
#import "DDMathStringToken.h"
#import "DDMathStringTokenizer.h"
@@ -45,7 +46,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
if (parameterGroup) {
[newSubterms addObject:parameterGroup];
}
- RELEASE(parameterGroup);
+ DD_RELEASE(parameterGroup);
} else {
// there's only one term in this parameter; no need to group it in parentheses
[newSubterms addObject:[parameterGroupTerms objectAtIndex:0]];
@@ -66,7 +67,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
NSArray *lastParameters = [[self subterms] subarrayWithRange:rangeOfLastParameter];
_DDGroupTerm *parameterGroup = [[_DDGroupTerm alloc] _initWithSubterms:lastParameters error:error];
[newSubterms addObject:parameterGroup];
- RELEASE(parameterGroup);
+ DD_RELEASE(parameterGroup);
} else if (rangeOfLastParameter.length == 1) {
[newSubterms addObject:[[self subterms] objectAtIndex:rangeOfLastParameter.location]];
}
@@ -78,7 +79,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
return self;
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void)dealloc {
[functionName release];
[super dealloc];
View
159 DDMathParser/_DDFunctionUtilities.m
@@ -6,6 +6,7 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDFunctionUtilities.h"
#import "DDExpression.h"
#import "DDMathParserMacros.h"
@@ -45,7 +46,7 @@ + (DDMathFunction) addFunction {
NSNumber *result = [NSNumber numberWithDouble:[firstValue doubleValue] + [secondValue doubleValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) subtractFunction {
@@ -59,7 +60,7 @@ + (DDMathFunction) subtractFunction {
NSNumber *result = [NSNumber numberWithDouble:[firstValue doubleValue] - [secondValue doubleValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) multiplyFunction {
@@ -73,7 +74,7 @@ + (DDMathFunction) multiplyFunction {
NSNumber *result = [NSNumber numberWithDouble:[firstValue doubleValue] * [secondValue doubleValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) divideFunction {
@@ -87,7 +88,7 @@ + (DDMathFunction) divideFunction {
NSNumber *result = [NSNumber numberWithDouble:[firstValue doubleValue] / [secondValue doubleValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) modFunction {
@@ -101,7 +102,7 @@ + (DDMathFunction) modFunction {
NSNumber *result = [NSNumber numberWithDouble:fmod([firstValue doubleValue], [secondValue doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) negateFunction {
@@ -113,7 +114,7 @@ + (DDMathFunction) negateFunction {
NSNumber *result = [NSNumber numberWithDouble:-1 * [firstValue doubleValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) factorialFunction {
@@ -125,7 +126,7 @@ + (DDMathFunction) factorialFunction {
NSNumber *result = [NSNumber numberWithDouble:tgamma([firstValue doubleValue]+1)];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) powFunction {
@@ -139,7 +140,7 @@ + (DDMathFunction) powFunction {
NSNumber *result = [NSNumber numberWithDouble:pow([base doubleValue], [exponent doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) nthrootFunction {
@@ -153,7 +154,7 @@ + (DDMathFunction) nthrootFunction {
NSNumber *result = [NSNumber numberWithDouble:pow([base doubleValue], 1/[root doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) andFunction {
@@ -167,7 +168,7 @@ + (DDMathFunction) andFunction {
NSNumber * result = [NSNumber numberWithInteger:([first integerValue] & [second integerValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) orFunction {
@@ -181,7 +182,7 @@ + (DDMathFunction) orFunction {
NSNumber * result = [NSNumber numberWithInteger:([first integerValue] | [second integerValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) notFunction {
@@ -193,7 +194,7 @@ + (DDMathFunction) notFunction {
NSNumber * result = [NSNumber numberWithInteger:(~[first integerValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) xorFunction {
@@ -207,7 +208,7 @@ + (DDMathFunction) xorFunction {
NSNumber * result = [NSNumber numberWithInteger:([first integerValue] ^ [second integerValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) rshiftFunction {
@@ -221,7 +222,7 @@ + (DDMathFunction) rshiftFunction {
NSNumber * result = [NSNumber numberWithInteger:[first integerValue] >> [second integerValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) lshiftFunction {
@@ -235,7 +236,7 @@ + (DDMathFunction) lshiftFunction {
NSNumber * result = [NSNumber numberWithInteger:[first integerValue] << [second integerValue]];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) averageFunction {
@@ -249,7 +250,7 @@ + (DDMathFunction) averageFunction {
NSNumber *avg = [NSNumber numberWithDouble:sum / [arguments count]];
return [DDExpression numberExpressionWithNumber:avg];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) sumFunction {
@@ -269,7 +270,7 @@ + (DDMathFunction) sumFunction {
NSNumber *result = [NSNumber numberWithDouble:sum];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) countFunction {
@@ -278,7 +279,7 @@ + (DDMathFunction) countFunction {
REQUIRE_GTOE_N_ARGS(1);
return [DDExpression numberExpressionWithNumber:[NSDecimalNumber decimalNumberWithMantissa:[arguments count] exponent:0 isNegative:NO]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) minFunction {
@@ -297,7 +298,7 @@ + (DDMathFunction) minFunction {
}
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) maxFunction {
@@ -316,7 +317,7 @@ + (DDMathFunction) maxFunction {
}
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) medianFunction {
@@ -343,7 +344,7 @@ + (DDMathFunction) medianFunction {
}
return [DDExpression numberExpressionWithNumber:median];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) stddevFunction {
@@ -368,7 +369,7 @@ + (DDMathFunction) stddevFunction {
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) sqrtFunction {
@@ -380,7 +381,7 @@ + (DDMathFunction) sqrtFunction {
NSNumber *result = [NSNumber numberWithDouble:sqrt([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) randomFunction {
@@ -424,7 +425,7 @@ + (DDMathFunction) randomFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithLongLong:random]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) logFunction {
@@ -436,7 +437,7 @@ + (DDMathFunction) logFunction {
NSNumber *result = [NSNumber numberWithDouble:log10([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) lnFunction {
@@ -446,7 +447,7 @@ + (DDMathFunction) lnFunction {
RETURN_IF_NIL(n);
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:log([n doubleValue])]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) log2Function {
@@ -458,7 +459,7 @@ + (DDMathFunction) log2Function {
NSNumber *result = [NSNumber numberWithDouble:log2([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) expFunction {
@@ -470,7 +471,7 @@ + (DDMathFunction) expFunction {
NSNumber *result = [NSNumber numberWithDouble:exp([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) ceilFunction {
@@ -482,7 +483,7 @@ + (DDMathFunction) ceilFunction {
NSNumber *result = [NSNumber numberWithDouble:ceil([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) absFunction {
@@ -494,7 +495,7 @@ + (DDMathFunction) absFunction {
NSNumber *result = [NSNumber numberWithLongLong:llabs([n longLongValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) floorFunction {
@@ -506,7 +507,7 @@ + (DDMathFunction) floorFunction {
NSNumber *result = [NSNumber numberWithDouble:floor([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) sinFunction {
@@ -518,7 +519,7 @@ + (DDMathFunction) sinFunction {
NSNumber *result = [NSNumber numberWithDouble:sin([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) cosFunction {
@@ -530,7 +531,7 @@ + (DDMathFunction) cosFunction {
NSNumber *result = [NSNumber numberWithDouble:cos([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) tanFunction {
@@ -542,7 +543,7 @@ + (DDMathFunction) tanFunction {
NSNumber *result = [NSNumber numberWithDouble:tan([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) asinFunction {
@@ -554,7 +555,7 @@ + (DDMathFunction) asinFunction {
NSNumber *result = [NSNumber numberWithDouble:asin([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) acosFunction {
@@ -566,7 +567,7 @@ + (DDMathFunction) acosFunction {
NSNumber *result = [NSNumber numberWithDouble:acos([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) atanFunction {
@@ -578,7 +579,7 @@ + (DDMathFunction) atanFunction {
NSNumber *result = [NSNumber numberWithDouble:atan([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) sinhFunction {
@@ -590,7 +591,7 @@ + (DDMathFunction) sinhFunction {
NSNumber *result = [NSNumber numberWithDouble:sinh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) coshFunction {
@@ -602,7 +603,7 @@ + (DDMathFunction) coshFunction {
NSNumber *result = [NSNumber numberWithDouble:cosh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) tanhFunction {
@@ -614,7 +615,7 @@ + (DDMathFunction) tanhFunction {
NSNumber *result = [NSNumber numberWithDouble:tanh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) asinhFunction {
@@ -626,7 +627,7 @@ + (DDMathFunction) asinhFunction {
NSNumber *result = [NSNumber numberWithDouble:asinh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) acoshFunction {
@@ -638,7 +639,7 @@ + (DDMathFunction) acoshFunction {
NSNumber *result = [NSNumber numberWithDouble:acosh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) atanhFunction {
@@ -650,7 +651,7 @@ + (DDMathFunction) atanhFunction {
NSNumber *result = [NSNumber numberWithDouble:atanh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) cscFunction {
@@ -662,7 +663,7 @@ + (DDMathFunction) cscFunction {
NSNumber *result = [NSNumber numberWithDouble:1/sin([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) secFunction {
@@ -674,7 +675,7 @@ + (DDMathFunction) secFunction {
NSNumber *result = [NSNumber numberWithDouble:1/cos([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) cotanFunction {
@@ -686,7 +687,7 @@ + (DDMathFunction) cotanFunction {
NSNumber *result = [NSNumber numberWithDouble:1/tan([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) acscFunction {
@@ -698,7 +699,7 @@ + (DDMathFunction) acscFunction {
NSNumber *result = [NSNumber numberWithDouble:1/asin([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) asecFunction {
@@ -710,7 +711,7 @@ + (DDMathFunction) asecFunction {
NSNumber *result = [NSNumber numberWithDouble:1/acos([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) acotanFunction {
@@ -722,7 +723,7 @@ + (DDMathFunction) acotanFunction {
NSNumber *result = [NSNumber numberWithDouble:1/atan([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) cschFunction {
@@ -734,7 +735,7 @@ + (DDMathFunction) cschFunction {
NSNumber *result = [NSNumber numberWithDouble:1/sinh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) sechFunction {
@@ -746,7 +747,7 @@ + (DDMathFunction) sechFunction {
NSNumber *result = [NSNumber numberWithDouble:1/cosh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) cotanhFunction {
@@ -758,7 +759,7 @@ + (DDMathFunction) cotanhFunction {
NSNumber *result = [NSNumber numberWithDouble:1/tanh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) acschFunction {
@@ -770,7 +771,7 @@ + (DDMathFunction) acschFunction {
NSNumber *result = [NSNumber numberWithDouble:1/sinh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) asechFunction {
@@ -782,7 +783,7 @@ + (DDMathFunction) asechFunction {
NSNumber *result = [NSNumber numberWithDouble:1/cosh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) acotanhFunction {
@@ -794,7 +795,7 @@ + (DDMathFunction) acotanhFunction {
NSNumber *result = [NSNumber numberWithDouble:1/atanh([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
// more trig functions
@@ -807,7 +808,7 @@ + (DDMathFunction) versinFunction {
NSNumber *result = [NSNumber numberWithDouble:1-cos([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) vercosinFunction {
@@ -819,7 +820,7 @@ + (DDMathFunction) vercosinFunction {
NSNumber *result = [NSNumber numberWithDouble:1+cos([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) coversinFunction {
@@ -831,7 +832,7 @@ + (DDMathFunction) coversinFunction {
NSNumber *result = [NSNumber numberWithDouble:1-sin([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) covercosinFunction {
@@ -843,7 +844,7 @@ + (DDMathFunction) covercosinFunction {
NSNumber *result = [NSNumber numberWithDouble:1+sin([n doubleValue])];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) haversinFunction {
@@ -855,7 +856,7 @@ + (DDMathFunction) haversinFunction {
NSNumber *result = [NSNumber numberWithDouble:(1-cos([n doubleValue]))/2];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) havercosinFunction {
@@ -867,7 +868,7 @@ + (DDMathFunction) havercosinFunction {
NSNumber *result = [NSNumber numberWithDouble:(1+cos([n doubleValue]))/2];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) hacoversinFunction {
@@ -879,7 +880,7 @@ + (DDMathFunction) hacoversinFunction {
NSNumber *result = [NSNumber numberWithDouble:(1-sin([n doubleValue]))/2];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) hacovercosinFunction {
@@ -891,7 +892,7 @@ + (DDMathFunction) hacovercosinFunction {
NSNumber *result = [NSNumber numberWithDouble:(1+sin([n doubleValue]))/2];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) exsecFunction {
@@ -903,7 +904,7 @@ + (DDMathFunction) exsecFunction {
NSNumber *result = [NSNumber numberWithDouble:(1/cos([n doubleValue]))-1];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) excscFunction {
@@ -915,7 +916,7 @@ + (DDMathFunction) excscFunction {
NSNumber *result = [NSNumber numberWithDouble:(1/sin([n doubleValue]))-1];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) crdFunction {
@@ -927,7 +928,7 @@ + (DDMathFunction) crdFunction {
NSNumber *result = [NSNumber numberWithDouble:2*sin([n doubleValue]/2)];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) dtorFunction {
@@ -939,7 +940,7 @@ + (DDMathFunction) dtorFunction {
NSNumber *result = [NSNumber numberWithDouble:[n doubleValue]/180 * M_PI];
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) rtodFunction {
@@ -952,7 +953,7 @@ + (DDMathFunction) rtodFunction {
return [DDExpression numberExpressionWithNumber:result];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
#pragma mark Constant Functions
@@ -964,7 +965,7 @@ + (DDMathFunction) phiFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:1.6180339887498948]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) piFunction {
@@ -974,7 +975,7 @@ + (DDMathFunction) piFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_PI]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) pi_2Function {
@@ -984,7 +985,7 @@ + (DDMathFunction) pi_2Function {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_PI_2]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) pi_4Function {
@@ -994,7 +995,7 @@ + (DDMathFunction) pi_4Function {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_PI_4]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) tauFunction {
@@ -1004,7 +1005,7 @@ + (DDMathFunction) tauFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:2*M_PI]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) sqrt2Function {
@@ -1014,7 +1015,7 @@ + (DDMathFunction) sqrt2Function {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_SQRT2]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) eFunction {
@@ -1024,7 +1025,7 @@ + (DDMathFunction) eFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_E]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) log2eFunction {
@@ -1034,7 +1035,7 @@ + (DDMathFunction) log2eFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_LOG2E]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) log10eFunction {
@@ -1044,7 +1045,7 @@ + (DDMathFunction) log10eFunction {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_LOG10E]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) ln2Function {
@@ -1054,7 +1055,7 @@ + (DDMathFunction) ln2Function {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_LN2]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
+ (DDMathFunction) ln10Function {
@@ -1064,7 +1065,7 @@ + (DDMathFunction) ln10Function {
return [DDExpression numberExpressionWithNumber:[NSNumber numberWithDouble:M_LN10]];
};
- return AUTORELEASE([function copy]);
+ return DD_AUTORELEASE([function copy]);
}
@end
View
15 DDMathParser/_DDGroupTerm.m
@@ -6,6 +6,7 @@
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDGroupTerm.h"
#import "DDMathStringTokenizer.h"
#import "DDMathStringToken.h"
@@ -28,7 +29,7 @@ @implementation _DDGroupTerm
@synthesize subterms;
- (void)_setSubterms:(NSArray *)newTerms {
- RELEASE(subterms);
+ DD_RELEASE(subterms);
subterms = [newTerms mutableCopy];
}
@@ -53,7 +54,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
[terms addObject:nextTerm];
} else {
// extracting a term failed. *error should've been filled already
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
nextToken = [tokenizer peekNextToken];
@@ -62,7 +63,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
// consume the closing parenthesis and verify it exists
if ([tokenizer nextToken] == nil) {
*error = ERR_BADARG(@"imbalanced parentheses");
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
@@ -71,7 +72,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
return self;
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void)dealloc {
[subterms release];
[super dealloc];
@@ -197,7 +198,7 @@ - (BOOL)_reduceBinaryOperatorAtIndex:(NSUInteger)index withParser:(DDParser *)pa
NSArray *rightOperands = [[self subterms] subarrayWithRange:rightOperandRange];
_DDGroupTerm *group = [[_DDGroupTerm alloc] _initWithSubterms:rightOperands error:error];
[[self subterms] replaceObjectsInRange:rightOperandRange withObjectsFromArray:[NSArray arrayWithObject:group]];
- RELEASE(group);
+ DD_RELEASE(group);
rightmostOperand = [[self subterms] objectAtIndex:NSMaxRange(replacementRange)-1];
}
@@ -206,7 +207,7 @@ - (BOOL)_reduceBinaryOperatorAtIndex:(NSUInteger)index withParser:(DDParser *)pa
_DDFunctionTerm *function = [[_DDFunctionTerm alloc] _initWithFunction:[operator operatorFunction] subterms:parameters error:error];
[[self subterms] replaceObjectsInRange:replacementRange withObjectsFromArray:[NSArray arrayWithObject:function]];
- RELEASE(function);
+ DD_RELEASE(function);
return YES;
}
@@ -246,7 +247,7 @@ - (BOOL)_reduceUnaryOperatorAtIndex:(NSUInteger)index withParser:(DDParser *)par
[[self subterms] replaceObjectsInRange:replacementRange withObjectsFromArray:[NSArray arrayWithObject:function]];
- RELEASE(function);
+ DD_RELEASE(function);
return YES;
}
View
5 DDMathParser/_DDNumberExpression.m
@@ -6,6 +6,7 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDNumberExpression.h"
@@ -14,7 +15,7 @@ @implementation _DDNumberExpression
- (id) initWithNumber:(NSNumber *)n {
self = [super init];
if (self) {
- number = RETAIN(n);
+ number = DD_RETAIN(n);
}
return self;
}
@@ -27,7 +28,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:[self number] forKey:@"number"];
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void) dealloc {
[number release];
[super dealloc];
View
9 DDMathParser/_DDParserTerm.m
@@ -6,6 +6,7 @@
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDParserTerm.h"
#import "DDMathStringTokenizer.h"
#import "DDMathStringToken.h"
@@ -41,7 +42,7 @@ + (id)rootTermWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **
[terms addObject:nextTerm];
}
- return AUTORELEASE([[_DDGroupTerm alloc] _initWithSubterms:terms error:error]);
+ return DD_AUTORELEASE([[_DDGroupTerm alloc] _initWithSubterms:terms error:error]);
}
+ (id)termWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)error {
@@ -63,7 +64,7 @@ + (id)termWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)err
term = [[_DDFunctionTerm alloc] _initWithTokenizer:tokenizer error:error];
}
- return AUTORELEASE(term);
+ return DD_AUTORELEASE(term);
} else {
*error = ERR_GENERIC(@"can't create a term with a nil token");
}
@@ -75,7 +76,7 @@ - (id)_initWithToken:(DDMathStringToken *)t error:(NSError **)error {
self = [super init];
if (self) {
resolved = NO;
- token = RETAIN(t);
+ token = DD_RETAIN(t);
}
return self;
}
@@ -84,7 +85,7 @@ - (id)_initWithTokenizer:(DDMathStringTokenizer *)tokenizer error:(NSError **)er
return [self _initWithToken:[tokenizer nextToken] error:error];
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void)dealloc {
[token release];
[super dealloc];
View
10 DDMathParser/_DDRewriteRule.m
@@ -19,26 +19,26 @@ - (id)initWithTemplate:(NSString *)string replacementPattern:(NSString *)pattern
@implementation _DDRewriteRule
+ (_DDRewriteRule *)rewriteRuleWithTemplate:(NSString *)string replacementPattern:(NSString *)replacement {
- return AUTORELEASE([[self alloc] initWithTemplate:string replacementPattern:replacement]);
+ return DD_AUTORELEASE([[self alloc] initWithTemplate:string replacementPattern:replacement]);
}
- (id)initWithTemplate:(NSString *)string replacementPattern:(NSString *)patternFormat {
self = [super init];
if (self) {
NSError *error = nil;
- predicate = RETAIN([DDExpression expressionFromString:string error:&error]);
- pattern = RETAIN([DDExpression expressionFromString:patternFormat error:&error]);
+ predicate = DD_RETAIN([DDExpression expressionFromString:string error:&error]);
+ pattern = DD_RETAIN([DDExpression expressionFromString:patternFormat error:&error]);
if (!predicate || !pattern || [predicate expressionType] != DDExpressionTypeFunction) {
NSLog(@"error creating rule: %@", error);
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
}
return self;
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void)dealloc {
[predicate release];
[pattern release];
View
5 DDMathParser/_DDVariableExpression.m
@@ -6,6 +6,7 @@
// Copyright 2010 Home. All rights reserved.
//
+#import "DDMathParser.h"
#import "_DDVariableExpression.h"
#import "DDMathEvaluator.h"
#import "DDMathEvaluator+Private.h"
@@ -20,7 +21,7 @@ - (id) initWithVariable:(NSString *)v {
v = [v substringFromIndex:1];
}
if ([v length] == 0) {
- RELEASE(self);
+ DD_RELEASE(self);
return nil;
}
variable = [v copy];
@@ -36,7 +37,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:[self variable] forKey:@"variable"];
}
-#if !HAS_ARC
+#if !DD_HAS_ARC
- (void) dealloc {
[variable release];
[super dealloc];
View
18 DDMathParser_Prefix.pch
@@ -4,22 +4,4 @@
#ifdef __OBJC__
#import <Foundation/Foundation.h>
-
-#if __has_feature(objc_arc)
-
-#define HAS_ARC 1
-#define RETAIN(_o) (_o)
-#define RELEASE(_o)
-#define AUTORELEASE(_o) (_o)
-
-#else
-
-#define HAS_ARC 0
-#define RETAIN(_o) [(_o) retain]
-#define RELEASE(_o) [(_o) release]
-#define AUTORELEASE(_o) [(_o) autorelease]
-
-#endif
-
-
#endif
View
8 main.m
@@ -16,7 +16,7 @@
} while (1);
- return AUTORELEASE([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
+ return DD_AUTORELEASE([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}
void listFunctions() {
@@ -30,7 +30,7 @@ void listFunctions() {
int main (int argc, const char * argv[]) {
#pragma unused(argc, argv)
-#if HAS_ARC
+#if DD_HAS_ARC
@autoreleasepool {
#else
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@@ -59,7 +59,7 @@ int main (int argc, const char * argv[]) {
DDExpression *rewritten = [[DDMathEvaluator sharedMathEvaluator] expressionByRewritingExpression:expression];
NSNumber *value = [expression evaluateWithSubstitutions:nil evaluator:nil error:&error];
- RELEASE(tokenizer);
+ DD_RELEASE(tokenizer);
// if (value == nil) {
// printf("\tERROR: %s\n", [[error description] UTF8String]);
@@ -74,7 +74,7 @@ int main (int argc, const char * argv[]) {
// insert code here...
printf("Goodbye!\n");
-#if HAS_ARC
+#if DD_HAS_ARC
}
#else
[pool drain];

0 comments on commit b7940cc

Please sign in to comment.