Drastic Simplification of MPFunction subclass implementations
This commit is contained in:
@@ -24,6 +24,12 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
for (NSString *key in self.childrenAccessors) {
|
||||
MPExpression *emptyExpression = [[MPExpression alloc] init];
|
||||
emptyExpression.parent = self;
|
||||
[self setValue:emptyExpression
|
||||
forKey:key];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -42,17 +48,18 @@
|
||||
|
||||
- (NSUInteger)numberOfChildren
|
||||
{
|
||||
return 0;
|
||||
return self.childrenAccessors.count;
|
||||
}
|
||||
|
||||
- (MPExpression *)childAtIndex:(NSUInteger)index
|
||||
{
|
||||
return nil;
|
||||
return [self valueForKey:self.childrenAccessors[index]];
|
||||
}
|
||||
|
||||
- (void)setChild:(MPExpression *)child
|
||||
atIndex:(NSUInteger)index
|
||||
{
|
||||
[self setValue:child forKey:self.childrenAccessors[index]];
|
||||
[self didChangeChildAtIndex:index];
|
||||
}
|
||||
|
||||
@@ -86,12 +93,6 @@
|
||||
return [child elementAtIndexPath:[indexPath indexPathByRemovingFirstIndex]];
|
||||
}
|
||||
|
||||
#pragma mark Evaluating Functions
|
||||
- (MPTerm *)parseWithError:(MPParseError *__autoreleasing *)error
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark Notifications
|
||||
- (void)didChangeElementsInRangePath:(MPRangePath *)rangePath
|
||||
replacementLength:(NSUInteger)replacementLength
|
||||
@@ -102,11 +103,6 @@
|
||||
replacementLength:replacementLength];
|
||||
}
|
||||
|
||||
- (void)didChangeChild:(MPExpression *)child
|
||||
{
|
||||
[self didChangeChildAtIndex:[self indexOfChild:child]];
|
||||
}
|
||||
|
||||
- (void)didChangeChildAtIndex:(NSUInteger)index
|
||||
{
|
||||
MPRangePath *path = [[MPRangePath alloc] initWithRange:NSMakeRange(index, 1)];
|
||||
@@ -142,13 +138,19 @@
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
#warning Unimplemented Method
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
return [[MPFunction allocWithZone:zone] init];
|
||||
id copy = [[self.class allocWithZone:zone] init];
|
||||
for (NSString *key in self.childrenAccessors) {
|
||||
MPExpression *child = [[self valueForKey:key] copy];
|
||||
[copy setValue:child forKey:key];
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
#pragma mark - NSCoding
|
||||
|
||||
Reference in New Issue
Block a user