Drastic Simplification of MPFunction subclass implementations
This commit is contained in:
@@ -11,12 +11,19 @@
|
||||
#import "MPParseError.h"
|
||||
#import "MPTerm.h"
|
||||
|
||||
#define MPFunctionAccessorImplementation(Accessor, variableName) \
|
||||
- (void)set##Accessor:(MPExpression *)value \
|
||||
{ \
|
||||
variableName.parent = nil; \
|
||||
variableName = value; \
|
||||
variableName.parent = self; \
|
||||
[self didChangeChildAtIndex:[self indexOfChild:variableName]]; \
|
||||
}
|
||||
|
||||
@class MPFunction, MPExpression, MPRangePath;
|
||||
|
||||
@interface MPFunction : NSObject <NSCoding, NSCopying, MPExpressionElement>
|
||||
|
||||
+ (NSString *)localizedFunctionName; // Override
|
||||
|
||||
#pragma mark Creation Methods
|
||||
|
||||
- (instancetype)init;
|
||||
@@ -29,13 +36,14 @@
|
||||
- (MPExpression *)rootExpression;
|
||||
- (NSIndexPath *)indexPath;
|
||||
|
||||
- (NSUInteger)numberOfChildren; // Override
|
||||
- (MPExpression *)childAtIndex:(NSUInteger)index; // Override
|
||||
- (void)setChild:(MPExpression *)child
|
||||
atIndex:(NSUInteger)index; // Override
|
||||
- (NSArray *)childrenAccessors; // Override
|
||||
|
||||
// May be overridden for performance improvements
|
||||
- (NSArray *)children; // Indexes must equal the ones from the native methods
|
||||
- (NSUInteger)numberOfChildren;
|
||||
- (MPExpression *)childAtIndex:(NSUInteger)index;
|
||||
- (void)setChild:(MPExpression *)child
|
||||
atIndex:(NSUInteger)index;
|
||||
|
||||
- (NSArray *)children; // Indexes must equal the ones from the other methods
|
||||
- (NSUInteger)indexOfChild:(MPExpression *)child;
|
||||
|
||||
- (id)elementAtIndexPath:(NSIndexPath *)indexPath;
|
||||
@@ -47,15 +55,14 @@
|
||||
#pragma mark Messages
|
||||
- (void)didChangeElementsInRangePath:(MPRangePath *)rangePath
|
||||
replacementLength:(NSUInteger)replacementLength;
|
||||
- (void)didChangeChild:(MPExpression *)child;
|
||||
- (void)didChangeChildAtIndex:(NSUInteger)index;
|
||||
|
||||
#pragma mark Working With Functions
|
||||
// - (BOOL)isEqualToFunction:(MPFunction *)aFunction; // Override
|
||||
|
||||
- (NSString *)description; // Should be overridden
|
||||
- (NSUInteger)hash;// Override
|
||||
- (NSUInteger)hash;
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone; // Override
|
||||
- (id)copyWithZone:(NSZone *)zone;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user