Archived
1

Added Documentation

This commit is contained in:
Kim Wittenburg
2014-11-10 21:45:50 +01:00
parent f4f924bd71
commit 10f0e73ad3
32 changed files with 1847 additions and 318 deletions

View File

@@ -12,9 +12,13 @@
#import "MPRangePath.h"
#import "NSIndexPath+MPAdditions.h"
@implementation MPFunction
#pragma mark Creation Methods
- (instancetype)init
{
self = [super init];
@@ -29,35 +33,49 @@
return self;
}
#pragma mark Working With the Expression Tree
- (MPExpression *)rootExpression
{
return [self.parent rootExpression];
}
- (NSIndexPath *)indexPath
{
if (!self.parent) {
return nil;
}
NSUInteger selfIndex = [self.parent indexOfElement:self];
return [[self.parent indexPath] indexPathByAddingIndex:selfIndex];
}
- (NSUInteger)numberOfChildren
{
return self.childrenAccessors.count;
}
- (MPExpression *)childAtIndex:(NSUInteger)index
{
return [self valueForKey:self.childrenAccessors[index]];
}
- (void)setChild:(MPExpression *)child
atIndex:(NSUInteger)index
{
[self setValue:child forKey:self.childrenAccessors[index]];
[[self valueForKey:self.childrenAccessors[index]] setParent:nil];
[self setValue:child
forKey:self.childrenAccessors[index]];
child.parent = self;
[self didChangeChildAtIndex:index];
}
- (NSArray *)children
{
NSUInteger childCount = [self numberOfChildren];
@@ -68,8 +86,10 @@
return [children copy];
}
- (NSUInteger)indexOfChild:(MPExpression *)child
{
NSUInteger index = 0;
for (; index < [self numberOfChildren]; index++) {
if ([self childAtIndex:index] == child) {
@@ -79,6 +99,7 @@
return NSNotFound;
}
- (id)elementAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.length == 0) {
@@ -88,7 +109,10 @@
return [child elementAtIndexPath:[indexPath indexPathByRemovingFirstIndex]];
}
#pragma mark Notifications
- (void)didChangeElementsInRangePath:(MPRangePath *)rangePath
replacementLength:(NSUInteger)replacementLength
{
@@ -98,6 +122,7 @@
replacementLength:replacementLength];
}
- (void)didChangeChildAtIndex:(NSUInteger)index
{
MPRangePath *path = [[MPRangePath alloc] initWithRange:NSMakeRange(index, 1)];
@@ -105,39 +130,26 @@
replacementLength:1];
}
#pragma mark Working With Functions
/*
- (BOOL)isEqual:(id)object
{
if (self == object) {
return YES;
}
if (object == nil) {
return NO;
}
if (![object isKindOfClass:[MPFunction class]]) {
return NO;
}
return [self isEqualToFunction:(MPFunction *)object];
}
- (BOOL)isEqualToFunction:(MPFunction *)aFunction
{
return [aFunction isMemberOfClass:[MPFunction class]] && [self isMemberOfClass:[MPFunction class]];
}*/
#pragma mark Working With Functions
- (NSString *)description
{
return @"[]";
}
- (NSUInteger)hash
{
#warning Unimplemented Method
return 0;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
id copy = [[self.class allocWithZone:zone] init];
@@ -148,7 +160,10 @@
return copy;
}
#pragma mark - NSCoding
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
@@ -163,22 +178,28 @@
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.children];
}
#pragma mark - MPExpressionElement
- (BOOL)isString
{
return NO;
}
- (BOOL)isFunction
{
return YES;
}
- (NSUInteger)length
{
return 1;