Internal Redesign:
- Combined MPExpression and MPMutableExpression - Abstracted children of MPExpression into MPExpressionElement protocol - Abstracted most of MPExpressionLayout and MPFunctionLayout into common superclass MPLayout
This commit is contained in:
@@ -19,11 +19,11 @@
|
||||
|
||||
@implementation MPExpressionStorage
|
||||
|
||||
- (instancetype)initWithSymbols:(NSArray *)symbols
|
||||
- (instancetype)initWithElements:(NSArray *)elements
|
||||
{
|
||||
self = [super initWithSymbols:symbols];
|
||||
self = [super initWithElements:elements];
|
||||
if (self) {
|
||||
_expressionLayout = [[MPExpressionLayout alloc] initRootLayoutWithExpressionStorage:self];
|
||||
_rootLayout = [[MPExpressionLayout alloc] initRootLayoutWithExpressionStorage:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -59,24 +59,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)symbolsChangedInRangePath:(MPRangePath *)rangePath replacementLength:(NSUInteger)length
|
||||
- (void)didChangeElementsInRangePath:(MPRangePath *)rangePath
|
||||
replacementLength:(NSUInteger)replacementLength
|
||||
{
|
||||
if (rangePath.location.length == 0) {
|
||||
return;
|
||||
}
|
||||
id current = self.expressionLayout;
|
||||
for (NSUInteger position = 1; position < rangePath.location.length-1; position++) {
|
||||
if ([current isKindOfClass:[MPExpressionLayout class]]) {
|
||||
current = [(MPExpressionLayout *)current functionLayoutForFunctionAtIndex:position];
|
||||
} else {
|
||||
current = [(MPFunctionLayout *)current expressionLayoutForChildAtIndex:position];
|
||||
}
|
||||
}
|
||||
if ([current isKindOfClass:[MPExpressionLayout class]]) {
|
||||
[(MPExpressionLayout *)current editedExpressionInRange:rangePath.rangeAtLastIndex replacementLength:length];
|
||||
} else {
|
||||
[(MPFunctionLayout *)current editedChildAtIndex:[rangePath.location indexAtPosition:rangePath.location.length-1]];
|
||||
MPLayout *current = self.rootLayout;
|
||||
for (NSUInteger index = 1; index < rangePath.location.length-1; index++) {
|
||||
current = [current childLayoutAtIndex:index];
|
||||
}
|
||||
[current clearCacheInRange:rangePath.rangeAtLastIndex replacementLength:replacementLength];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user