From 1a8dd6e901911d8f798b6a2d92e04cfcf8a6321b Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Fri, 9 Jan 2015 15:58:15 +0100 Subject: [PATCH] Corrected Fractions' property name: nominator to numerator --- MathKit/MPExpressionView.m | 25 ++++++++++++------------- MathKit/MPFractionFunction.h | 12 ++++++------ MathKit/MPFractionFunction.m | 6 +++--- MathKit/MPFractionFunctionLayout.h | 2 +- MathKit/MPFractionFunctionLayout.m | 12 ++++++------ MathKit/MPFractionTerm.h | 2 +- MathKit/MPFractionTerm.m | 4 ++-- 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/MathKit/MPExpressionView.m b/MathKit/MPExpressionView.m index ff6e0b1..8a6405d 100644 --- a/MathKit/MPExpressionView.m +++ b/MathKit/MPExpressionView.m @@ -145,7 +145,6 @@ if (!selectWords && !extendingSelection && (locationInElement == 0 || locationInTarget == targetExpression.countSymbols)) { // First or last index in an element or expression - // Last element in the expression if (locationInTarget == targetExpression.countSymbols) { // The selection is inside a function and should proceed if (selectionPath.length > 1) { @@ -805,7 +804,7 @@ if (self.selection.length == 0) { MPExpression *targetExpression = [self.expressionStorage elementAtIndexPath:[self.selection.location indexPathByRemovingLastIndex]]; NSInteger index = self.selection.location.lastIndex; - NSRange nominatorSymbols = NSMakeRange(index, 0); + NSRange numeratorSymbols = NSMakeRange(index, 0); while (--index >= 0) { id symbol = [targetExpression symbolAtIndex:index]; if ([symbol isString]) { @@ -814,33 +813,33 @@ toReferenceFrame:MPTokenReferenceFrame]; id token = [targetExpression tokenAtIndex:tokenIndex]; if (token.tokenType == MPNumberToken || token.tokenType == MPVariableToken || token.tokenType == MPElementaryFunctionToken) { - nominatorSymbols.location--; - nominatorSymbols.length++; + numeratorSymbols.location--; + numeratorSymbols.length++; } else { break; } - } else if (nominatorSymbols.length == 0) { - nominatorSymbols.location--; - nominatorSymbols.length++; + } else if (numeratorSymbols.length == 0) { + numeratorSymbols.location--; + numeratorSymbols.length++; } else { break; } } - MPExpression *nominatorExpression = [targetExpression subexpressionWithRange:nominatorSymbols + MPExpression *numeratorExpression = [targetExpression subexpressionWithRange:numeratorSymbols referenceFrame:MPSymbolReferenceFrame]; MPFractionFunction *function = [[MPFractionFunction alloc] init]; - function.nominatorExpression = nominatorExpression; - [targetExpression replaceItemsInRange:nominatorSymbols referenceFrame:MPSymbolReferenceFrame withElements:@[function]]; - NSUInteger functionElementIndex = [targetExpression convertIndex:nominatorSymbols.location + function.numeratorExpression = numeratorExpression; + [targetExpression replaceItemsInRange:numeratorSymbols referenceFrame:MPSymbolReferenceFrame withElements:@[function]]; + NSUInteger functionElementIndex = [targetExpression convertIndex:numeratorSymbols.location fromReferenceFrame:MPSymbolReferenceFrame toReferenceFrame:MPElementReferenceFrame]; - NSUInteger selectedSubexpression = nominatorSymbols.length == 0 ? 0 : 1; + NSUInteger selectedSubexpression = numeratorSymbols.length == 0 ? 0 : 1; self.selection = MPMakeRangePath([[[self.selection.location indexPathByReplacingLastIndexWithIndex:functionElementIndex] indexPathByAddingIndex:selectedSubexpression] indexPathByAddingIndex:0], 0); } else { MPExpression *selectedElementsExpression = [self.expressionStorage subexpressionWithRangePath:self.selection referenceFrame:MPSymbolReferenceFrame]; MPFractionFunction *function = [[MPFractionFunction alloc] init]; - function.nominatorExpression = selectedElementsExpression; + function.numeratorExpression = selectedElementsExpression; [self.expressionStorage replaceItemsInRangePath:self.selection referenceFrame:MPSymbolReferenceFrame withElements:@[function]]; diff --git a/MathKit/MPFractionFunction.h b/MathKit/MPFractionFunction.h index 297eb52..70a1707 100644 --- a/MathKit/MPFractionFunction.h +++ b/MathKit/MPFractionFunction.h @@ -23,21 +23,21 @@ @class MPFractionFunction @abstract This class represents a fraction. - @discussion A fraction has two children: the nominator and the denominator. + @discussion A fraction has two children: the numerator and the denominator. Typically it is displayed with a horizontal bar between the two child expressions which are on top and below the bar - respectively. When a fraction is evaluated the nominator is + respectively. When a fraction is evaluated the numerator is divided by the denominator. */ @interface MPFractionFunction : MPFunction /*! - @property nominatorExpression - @abstract The receiver's nominator. + @property numeratorExpression + @abstract The receiver's numerator. - @discussion The nominator must not define a variable. + @discussion The numerator must not define a variable. */ -@property (nonatomic, strong) MPExpression *nominatorExpression; /* Index 0 */ +@property (nonatomic, strong) MPExpression *numeratorExpression; /* Index 0 */ /*! diff --git a/MathKit/MPFractionFunction.m b/MathKit/MPFractionFunction.m index a1fb6fb..0698e9b 100644 --- a/MathKit/MPFractionFunction.m +++ b/MathKit/MPFractionFunction.m @@ -15,13 +15,13 @@ @implementation MPFractionFunction -MPFunctionAccessorImplementation(NominatorExpression, _nominatorExpression) +MPFunctionAccessorImplementation(NumeratorExpression, _numeratorExpression) MPFunctionAccessorImplementation(DenominatorExpression, _denominatorExpression) - (NSArray *)childrenAccessors { - return @[@"nominatorExpression", @"denominatorExpression"]; + return @[@"numeratorExpression", @"denominatorExpression"]; } @@ -33,7 +33,7 @@ MPFunctionAccessorImplementation(DenominatorExpression, _denominatorExpression) - (NSString *)description { - return [NSString stringWithFormat:@"%@ / %@", self.nominatorExpression, self.denominatorExpression]; + return [NSString stringWithFormat:@"%@ / %@", self.numeratorExpression, self.denominatorExpression]; } @end diff --git a/MathKit/MPFractionFunctionLayout.h b/MathKit/MPFractionFunctionLayout.h index c053f5b..be8d6ea 100644 --- a/MathKit/MPFractionFunctionLayout.h +++ b/MathKit/MPFractionFunctionLayout.h @@ -24,7 +24,7 @@ @abstract A fraction function layout displays a @link //apple_ref/occ/cl/MPFractionFunction@/link. - @discussion The nominator is displayed above the denominator. Between the two + @discussion The numerator is displayed above the denominator. Between the two children a horizontal bar is drawn. */ @interface MPFractionFunctionLayout : MPFunctionLayout diff --git a/MathKit/MPFractionFunctionLayout.m b/MathKit/MPFractionFunctionLayout.m index da43b84..eea7dfd 100644 --- a/MathKit/MPFractionFunctionLayout.m +++ b/MathKit/MPFractionFunctionLayout.m @@ -50,9 +50,9 @@ { NSRect bounds = self.bounds; if (index == 0) { - NSRect nominatorBounds = [self childLayoutAtIndex:0].bounds; - CGFloat y = MPFractionMiddle + kFractionFunctionLineWidth / 2 - nominatorBounds.origin.y; - return NSMakePoint((bounds.size.width - nominatorBounds.size.width) / 2, y); + NSRect numeratorBounds = [self childLayoutAtIndex:0].bounds; + CGFloat y = MPFractionMiddle + kFractionFunctionLineWidth / 2 - numeratorBounds.origin.y; + return NSMakePoint((bounds.size.width - numeratorBounds.size.width) / 2, y); } else { NSRect denominatorBounds = [self childLayoutAtIndex:1].bounds; CGFloat y = MPFractionMiddle - kFractionFunctionLineWidth / 2; @@ -80,13 +80,13 @@ - (NSRect)generateBounds { - NSRect nominatorBounds = [self childLayoutAtIndex:0].bounds; + NSRect numeratorBounds = [self childLayoutAtIndex:0].bounds; NSRect denominatorBounds = [self childLayoutAtIndex:1].bounds; NSRect bounds; bounds.origin.x = 0; bounds.origin.y = MPFractionMiddle - kFractionFunctionLineWidth / 2 - denominatorBounds.size.height; - bounds.size.width = MAX(nominatorBounds.size.width, denominatorBounds.size.width) + 2 * kFractionFunctionHorizontalInset; - bounds.size.height = nominatorBounds.size.height + denominatorBounds.size.height + kFractionFunctionLineWidth; + bounds.size.width = MAX(numeratorBounds.size.width, denominatorBounds.size.width) + 2 * kFractionFunctionHorizontalInset; + bounds.size.height = numeratorBounds.size.height + denominatorBounds.size.height + kFractionFunctionLineWidth; return bounds; } diff --git a/MathKit/MPFractionTerm.h b/MathKit/MPFractionTerm.h index 02b2dad..69f93f1 100644 --- a/MathKit/MPFractionTerm.h +++ b/MathKit/MPFractionTerm.h @@ -24,7 +24,7 @@ @abstract Represens a @link //apple_ref/occ/cl/MPFractionFunction@/link. - @discussion A fraction is evaluating by dividing the nominator by the + @discussion A fraction is evaluating by dividing the numerator by the denominator. */ @interface MPFractionTerm : MPFunctionTerm diff --git a/MathKit/MPFractionTerm.m b/MathKit/MPFractionTerm.m index efb11b8..2aa0b6a 100644 --- a/MathKit/MPFractionTerm.m +++ b/MathKit/MPFractionTerm.m @@ -16,7 +16,7 @@ - (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error { - MPEvaluateExpression(nominator, 0); + MPEvaluateExpression(numerator, 0); MPEvaluateExpression(denominator, 1); if ([denominator isEqualToNumber:@0]) { if (error) { @@ -26,7 +26,7 @@ } return nil; } else { - return [nominator decimalNumberByDividingBy:denominator]; + return [numerator decimalNumberByDividingBy:denominator]; } }