Archived
1

Add Documentation and Clean Code

This commit is contained in:
Kim Wittenburg
2017-08-31 00:03:24 +02:00
parent cfa3723ce1
commit 43b907ba88
5 changed files with 12 additions and 11 deletions

4
MathKit/MPExpressionView.m Normal file → Executable file
View File

@@ -713,7 +713,9 @@
if (self.functionsPopover.isShown) { if (self.functionsPopover.isShown) {
[self.functionsPopover close]; [self.functionsPopover close];
} else { } else {
[self.functionsPopover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge]; [self.functionsPopover showRelativeToRect:[sender bounds]
ofView:self.functionsButton
preferredEdge:NSMaxYEdge];
} }
} }

4
MathKit/MPFractionFunctionLayout.m Normal file → Executable file
View File

@@ -11,8 +11,8 @@
#import "MPFractionFunction.h" #import "MPFractionFunction.h"
#define kFractionFunctionLineWidth 1.0 #define kFractionFunctionLineWidth 1
#define kFractionFunctionHorizontalInset 2.0 #define kFractionFunctionHorizontalInset 2
#define kFractionFunctionNominatorOffset 0 #define kFractionFunctionNominatorOffset 0
#define kFractionFunctionDenominatorOffset 0 #define kFractionFunctionDenominatorOffset 0

2
MathKit/MPFractionTerm.h Normal file → Executable file
View File

@@ -24,7 +24,7 @@
@abstract Represens a <code>@link @abstract Represens a <code>@link
//apple_ref/occ/cl/MPFractionFunction@/link</code>. //apple_ref/occ/cl/MPFractionFunction@/link</code>.
@discussion A fraction is evaluating by dividing the numerator by the @discussion A fraction is evaluated by dividing the numerator by the
denominator. denominator.
*/ */
@interface MPFractionTerm : MPFunctionTerm @interface MPFractionTerm : MPFunctionTerm

8
MathKit/MPSumFunction.h Normal file → Executable file
View File

@@ -29,9 +29,9 @@
the start expression and the target expressions are included in the start expression and the target expressions are included in
the iterations. the iterations.
Each iteration the sum value is incremented by <code>1</code>. If Each iteration the iteration value is incremented by
the start and target expression evaluate to the same value the <code>1</code>. If the start and target expression evaluate to
sum is evaluated once. the same value the sum is evaluated once.
*/ */
@interface MPSumFunction : MPFunction @interface MPSumFunction : MPFunction
@@ -41,7 +41,7 @@
@discussion The start expression must define a variable that may be used in @discussion The start expression must define a variable that may be used in
the sum expression. If the start expression does not define a the sum expression. If the start expression does not define a
variable the sum function will fail on validation. variable the sum function will not be evaluatable.
*/ */
@property (nonatomic, strong) MPExpression *startExpression; /* Index 0 */ @property (nonatomic, strong) MPExpression *startExpression; /* Index 0 */

5
MathKit/MPSumFunctionTerm.m Normal file → Executable file
View File

@@ -17,13 +17,12 @@
- (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error - (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error
{ {
MPParsedExpression *startExpression = [self expressionAtIndex:0]; MPParsedExpression *startExpression = [self expressionAtIndex:0];
MPParsedExpression *sumExpression = [self expressionAtIndex:2];
NSDecimalNumber *start = [startExpression evaluate:error]; NSDecimalNumber *start = [startExpression evaluate:error];
ReturnNilIfNil(start); ReturnNilIfNil(start);
MPEvaluateExpression(target, 1); MPEvaluateExpression(target, 1);
NSDecimalNumber *value = [NSDecimalNumber zero];
MPParsedExpression *sumExpression = [self expressionAtIndex:2];
NSDecimalNumber *value = [NSDecimalNumber zero];
for (NSDecimalNumber *current = start; for (NSDecimalNumber *current = start;
[current compare:target] <= 0; [current compare:target] <= 0;
current = [current decimalNumberByAdding:[[NSDecimalNumber alloc] initWithInteger:1]]) { current = [current decimalNumberByAdding:[[NSDecimalNumber alloc] initWithInteger:1]]) {