Archived
1

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:
Kim Wittenburg
2014-08-11 13:57:48 +02:00
parent 740c3fd80a
commit 60760b8b3d
31 changed files with 1222 additions and 1343 deletions

View File

@@ -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