From d69f46f7ee03eee66253affa67fe98fd3281d8a3 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 9 Dec 2010 13:45:29 -0800 Subject: [PATCH] More capp_linting. Reviewed by me. --- AppKit/CPMenuItem/CPMenuItem.j | 12 +-- AppKit/CPWindow/_CPWindowView.j | 75 ++++++++-------- AppKit/CoreGraphics/CGColor.j | 46 +++++----- AppKit/CoreGraphics/CGContext.j | 52 +++++------ AppKit/CoreGraphics/CGPath.j | 87 ++++++++++--------- Foundation/CPData.j | 4 +- Foundation/CPDate.j | 4 +- Foundation/CPDecimalNumber.j | 6 +- Foundation/CPDictionary.j | 4 +- Foundation/CPIndexPath.j | 2 +- Foundation/CPRange.j | 6 +- Foundation/CPScanner.j | 48 +++++----- Foundation/CPSet.j | 4 +- Foundation/CPString.j | 7 +- Foundation/CPURL.j | 8 +- Tests/AppKit/CPTreeNodeTest.j | 6 +- Tests/Foundation/CPArrayPerformanceTest.j | 40 ++++++--- Tests/Foundation/CPArrayTest.j | 6 +- Tests/Foundation/CPDictionaryTest.j | 4 +- Tests/Foundation/CPFormatterTest.j | 2 +- Tests/Foundation/CPObjectTest.j | 5 +- Tests/Foundation/CPOperationTest.j | 4 +- Tests/Foundation/CPStringTest.j | 2 +- Tests/Foundation/SubclassTollFreeTest.j | 72 +++++++-------- Tests/Manual/AttachedSheet/AppController.j | 24 ++--- Tests/Manual/CPBrowserTest/AppController.j | 8 +- .../AppController.j | 2 +- .../AppController.j | 2 +- Tests/Manual/CPCursor/AppController.j | 12 +-- Tests/Manual/CPGraphicsTest/AppController.j | 2 +- Tests/Manual/CPSearchField/AppController.j | 2 +- Tests/Manual/CPTabView2/AppController.j | 34 ++++---- 32 files changed, 305 insertions(+), 287 deletions(-) diff --git a/AppKit/CPMenuItem/CPMenuItem.j b/AppKit/CPMenuItem/CPMenuItem.j index aafd0f067..5f34c3367 100644 --- a/AppKit/CPMenuItem/CPMenuItem.j +++ b/AppKit/CPMenuItem/CPMenuItem.j @@ -459,7 +459,7 @@ CPOffState if (supermenu) [CPException raise:CPInvalidArgumentException - reason: @"Can't add submenu \"" + [aMenu title] + "\" to item \"" + [self title] + "\", because it is already submenu of \"" + [[aMenu supermenu] title] + "\""]; + reason: @"Can't add submenu \"" + [aMenu title] + "\" to item \"" + [self title] + "\", because it is already submenu of \"" + [[aMenu supermenu] title] + "\""]; _submenu = aMenu; @@ -592,7 +592,7 @@ CPControlKeyMask return @""; var string = _keyEquivalent.toUpperCase(), - needsShift = _keyEquivalentModifierMask & CPShiftKeyMask || + needsShift = _keyEquivalentModifierMask & CPShiftKeyMask || (string === _keyEquivalent && _keyEquivalent.toLowerCase() !== _keyEquivalent.toUpperCase()); if (CPBrowserIsOperatingSystem(CPMacOperatingSystem)) @@ -791,12 +791,12 @@ CPControlKeyMask - (id)copy { var item = [[CPMenuItem alloc] init]; - + // No point in going through accessors and doing lots of unnecessary state checking/updating item._isSeparator = _isSeparator; - + [item setTitle:_title]; - [item setFont:_font]; + [item setFont:_font]; [item setTarget:_target]; [item setAction:_action]; [item setEnabled:_isEnabled]; @@ -815,7 +815,7 @@ CPControlKeyMask [item setIndentationLevel:_indentationLevel]; [item setToolTip:_toolTip]; [item setRepresentedObject:_representedObject]; - + return item; } diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 381c3cb78..6746567bf 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -29,15 +29,14 @@ var _CPWindowViewResizeIndicatorImage = nil; @implementation _CPWindowView : CPView { unsigned _styleMask; - + CPImageView _resizeIndicator; CGSize _resizeIndicatorOffset; - + CPView _toolbarView; CGSize _toolbarOffset; // BOOL _isAnimatingToolbar; - CGRect _resizeFrame; CGPoint _mouseDraggedPoint; @@ -48,7 +47,7 @@ var _CPWindowViewResizeIndicatorImage = nil; { if (self != [_CPWindowView class]) return; - + _CPWindowViewResizeIndicatorImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPWindow class]] pathForResource:@"_CPWindowView/_CPWindowViewResizeIndicator.png"] size:CGSizeMake(12.0, 12.0)]; } @@ -75,14 +74,14 @@ var _CPWindowViewResizeIndicatorImage = nil; - (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask { self = [super initWithFrame:aFrame]; - + if (self) { _styleMask = aStyleMask; _resizeIndicatorOffset = CGSizeMakeZero(); _toolbarOffset = CGSizeMakeZero(); } - + return self; } @@ -107,14 +106,14 @@ var _CPWindowViewResizeIndicatorImage = nil; { // FIXME: This should be better var frame = [_resizeIndicator frame]; - + if (CGRectContainsPoint(frame, [self convertPoint:[anEvent locationInWindow] fromView:nil])) return [self trackResizeWithEvent:anEvent]; } - + if ([theWindow isMovableByWindowBackground]) [self trackMoveWithEvent:anEvent]; - + else [super mouseDown:anEvent]; } @@ -123,29 +122,29 @@ var _CPWindowViewResizeIndicatorImage = nil; { var location = [anEvent locationInWindow], type = [anEvent type]; - + if (type === CPLeftMouseUp) return; - + var theWindow = [self window]; - + if (type === CPLeftMouseDown) { var frame = [theWindow frame]; - + _resizeFrame = CGRectMake(location.x, location.y, CGRectGetWidth(frame), CGRectGetHeight(frame)); } - + else if (type === CPLeftMouseDragged) - { - var newSize = CGSizeMake(CGRectGetWidth(_resizeFrame) + location.x - CGRectGetMinX(_resizeFrame), CGRectGetHeight(_resizeFrame) + location.y - CGRectGetMinY(_resizeFrame)); - + { + var newSize = CGSizeMake(CGRectGetWidth(_resizeFrame) + location.x - CGRectGetMinX(_resizeFrame), CGRectGetHeight(_resizeFrame) + location.y - CGRectGetMinY(_resizeFrame)); + if (theWindow._isSheet && theWindow._parentView && (theWindow._frame.size.width !== newSize.width)) - [theWindow._parentView _setAttachedSheetFrameOrigin]; - - [theWindow setFrameSize:newSize]; + [theWindow._parentView _setAttachedSheetFrameOrigin]; + + [theWindow setFrameSize:newSize]; } - + [CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; } @@ -161,10 +160,10 @@ var _CPWindowViewResizeIndicatorImage = nil; visibleFrame = [[CPPlatformWindow primaryPlatformWindow] visibleFrame]; var minPointY = 0; - + if([CPMenu menuBarVisible]) minPointY = [[CPApp mainMenu] menuBarHeight]; - + var restrictedPoint = CGPointMake(0, 0); restrictedPoint.x = MIN(MAX(aPoint.x, -_frame.size.width + 4.0), CGRectGetMaxX(visibleFrame) - 4.0); @@ -194,14 +193,14 @@ var _CPWindowViewResizeIndicatorImage = nil; var theWindow = [self window], frame = [theWindow frame], location = [theWindow convertBaseToGlobal:[anEvent locationInWindow]], - origin = [self _pointWithinScreenFrame:CGPointMake(_CGRectGetMinX(frame) + (location.x - _mouseDraggedPoint.x), + origin = [self _pointWithinScreenFrame:CGPointMake(_CGRectGetMinX(frame) + (location.x - _mouseDraggedPoint.x), _CGRectGetMinY(frame) + (location.y - _mouseDraggedPoint.y))]; [theWindow setFrameOrigin:origin]; _mouseDraggedPoint = [self _pointWithinScreenFrame:location]; } - + [CPApp setTarget:self selector:@selector(trackMoveWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; } @@ -211,9 +210,9 @@ var _CPWindowViewResizeIndicatorImage = nil; { var size = [_CPWindowViewResizeIndicatorImage size], boundsSize = [self frame].size; - + _resizeIndicator = [[CPImageView alloc] initWithFrame:CGRectMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height, size.width, size.height)]; - + [_resizeIndicator setImage:_CPWindowViewResizeIndicatorImage]; [_resizeIndicator setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; @@ -236,15 +235,15 @@ var _CPWindowViewResizeIndicatorImage = nil; { if (CGSizeEqualToSize(_resizeIndicatorOffset, anOffset)) return; - + _resizeIndicatorOffset = anOffset; - + if (!_resizeIndicator) return; var size = [_resizeIndicator frame].size, boundsSize = [self frame].size; - + [_resizeIndicator setFrameOrigin:CGPointMake(boundsSize.width - size.width - anOffset.width, boundsSize.height - size.height - anOffset.height)]; } @@ -280,7 +279,7 @@ var _CPWindowViewResizeIndicatorImage = nil; { if (!_toolbarView || [_toolbarView isHidden]) return [self toolbarOffset].height; - + return CGRectGetMaxY([_toolbarView frame]); } @@ -294,20 +293,20 @@ var _CPWindowViewResizeIndicatorImage = nil; var theWindow = [self window], bounds = [self bounds], width = CGRectGetWidth(bounds); - + if ([[theWindow toolbar] isVisible]) { var toolbarView = [self toolbarView], toolbarOffset = [self toolbarOffset]; - + [toolbarView setFrame:CGRectMake(toolbarOffset.width, toolbarOffset.height, width, CGRectGetHeight([toolbarView frame]))]; } - + if ([self showsResizeIndicator]) { var size = [_resizeIndicator frame].size, boundsSize = [self bounds].size; - + [_resizeIndicator setFrameOrigin:CGPointMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height)]; } } @@ -317,11 +316,11 @@ var _CPWindowViewResizeIndicatorImage = nil; var theWindow = [self window], toolbar = [theWindow toolbar], toolbarView = [toolbar _toolbarView]; - + if (_toolbarView !== toolbarView) { [_toolbarView removeFromSuperview]; - + if (toolbarView) { [toolbarView removeFromSuperview]; @@ -329,7 +328,7 @@ var _CPWindowViewResizeIndicatorImage = nil; [self addSubview:toolbarView]; } - + _toolbarView = toolbarView; } diff --git a/AppKit/CoreGraphics/CGColor.j b/AppKit/CoreGraphics/CGColor.j index 96d7fa643..eafac6e42 100644 --- a/AppKit/CoreGraphics/CGColor.j +++ b/AppKit/CoreGraphics/CGColor.j @@ -31,7 +31,7 @@ function CFHashCode(aCFObject) { if (!aCFObject.hash) aCFObject.hash = ++CFTypeGlobalCount; - + return aCFObject; } @@ -47,7 +47,7 @@ function CGColorGetConstantColor(aColorName) } /*! - This function is for source compatability. + This function is for source compatability. */ function CGColorRetain(aColor) { @@ -55,7 +55,7 @@ function CGColorRetain(aColor) } /*! - This function is for source compatability. + This function is for source compatability. */ function CGColorRelease() { @@ -74,14 +74,14 @@ function CGColorCreate(aColorSpace, components) return NULL; var components = components.slice(); - + CGColorSpaceStandardizeComponents(aColorSpace, components); - + var UID = CFHashCode(aColorSpace) + components.join(""); - + if (_CGColorMap[UID]) return _CGColorMap[UID]; - + return _CGColorMap[UID] = { colorspace:aColorSpace, pattern:NULL, components:components }; } @@ -150,9 +150,9 @@ function CGColorCreateGenericCMYK(cyan, magenta, yellow, black, alpha) function CGColorCreateCopyWithAlpha(aColor, anAlpha) { var components = aColor.components; - + if (!aColor || anAlpha == components[components.length - 1]) - return aColor; + return aColor; if (aColor.pattern) var copy = CGColorCreateWithPattern(aColor.colorspace, aColor.pattern, components); @@ -160,7 +160,7 @@ function CGColorCreateCopyWithAlpha(aColor, anAlpha) var copy = CGColorCreate(aColor.colorspace, components); copy.components[components.length - 1] = anAlpha; - + return copy; } @@ -191,7 +191,7 @@ function CGColorEqualToColor(lhs, rhs) { if (lhs == rhs) return true; - + if (!lhs || !rhs) return false; @@ -201,17 +201,17 @@ function CGColorEqualToColor(lhs, rhs) if (lhsComponentCount != rhsComponents.length) return false; - - while (lhsComponentCount--) + + while (lhsComponentCount--) if (lhsComponents[lhsComponentCount] != rhsComponents[lhsComponentCount]) return false; - + if (lhs.pattern != rhs.pattern) return false; - + if (CGColorSpaceEqualToColorSpace(lhs.colorspace, rhs.colorspace)) return false; - + return true; } @@ -224,7 +224,7 @@ function CGColorEqualToColor(lhs, rhs) function CGColorGetAlpha(aColor) { var components = aColor.components; - + return components[components.length - 1]; } @@ -273,13 +273,13 @@ function CGColorGetPattern(aColor) } /* var components = aColor.components; - + case : _CGCSSForColor[CFGetHash(aColor)] = "rgba(" + ROUND(components[0] * 255.0) + ',' + ROUND(components[0] * 255.0) + ',' ROUND(components[0] * 255.0) + ',' + ROUND(components[0] * 255.0); - _cssString = (hasAlpha ? "rgba(" : "rgb(") + - parseInt(_components[0] * 255.0) + ", " + - parseInt(_components[1] * 255.0) + ", " + - parseInt(_components[2] * 255.0) + - (hasAlpha ? (", " + _components[3]) : "") + ")"; + _cssString = (hasAlpha ? "rgba(" : "rgb(") + + parseInt(_components[0] * 255.0) + ", " + + parseInt(_components[1] * 255.0) + ", " + + parseInt(_components[2] * 255.0) + + (hasAlpha ? (", " + _components[3]) : "") + ")"; function CFStringFromColor() { diff --git a/AppKit/CoreGraphics/CGContext.j b/AppKit/CoreGraphics/CGContext.j index 8b3f34cd5..0b1151a5f 100644 --- a/AppKit/CoreGraphics/CGContext.j +++ b/AppKit/CoreGraphics/CGContext.j @@ -27,7 +27,7 @@ kCGLineCapButt = 0; -kCGLineCapRound = 1; +kCGLineCapRound = 1; kCGLineCapSquare = 2; kCGLineJoinMiter = 0; @@ -114,8 +114,8 @@ if (!CPFeatureIsCompatible(CPHTMLCanvasFeature)) */ function CGGStateCreate() { - return { alpha:1.0, strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0, - blendMode:kCGBlendModeNormal, + return { alpha:1.0, strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0, + blendMode:kCGBlendModeNormal, shadowOffset:_CGSizeMakeZero(), shadowBlur:0.0, shadowColor:NULL, CTM:_CGAffineTransformMakeIdentity() }; } @@ -126,9 +126,9 @@ function CGGStateCreate() */ function CGGStateCreateCopy(aGState) { - return { alpha:aGState.alpha, strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth, - lineJoin:aGState.lineJoin, lineCap:aGState.lineCap, miterLimit:aGState.miterLimit, globalAlpha:aGState.globalAlpha, - blendMode:aGState.blendMode, + return { alpha:aGState.alpha, strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth, + lineJoin:aGState.lineJoin, lineCap:aGState.lineCap, miterLimit:aGState.miterLimit, globalAlpha:aGState.globalAlpha, + blendMode:aGState.blendMode, shadowOffset:aGState.shadowOffset, shadowBlur:aGState.shadowBlur, shadowColor:aGState.shadowColor, CTM:_CGAffineTransformMakeCopy(aGState.CTM) }; } @@ -256,10 +256,10 @@ function CGContextAddPath(aContext, aPath) { if (!aContext || CGPathIsEmpty(aPath)) return; - + if (!aContext.path) aContext.path = CGPathCreateMutable(); - + CGPathAddPath(aContext.path, aContext.gState.CTM, aPath); } @@ -332,7 +332,7 @@ function CGContextMoveToPoint(aContext, x, y) { if (!aContext.path) aContext.path = CGPathCreateMutable(); - + CGPathMoveToPoint(aContext.path, aContext.gState.CTM, x, y); } @@ -358,11 +358,11 @@ function CGContextFillRects(aContext, rects, count) { if (arguments[2] === undefined) var count = rects.length; - + CGContextBeginPath(aContext); CGContextAddRects(aContext, rects, count); CGContextClosePath(aContext); - + CGContextDrawPath(aContext, kCGPathFill); } @@ -373,11 +373,11 @@ function CGContextFillRects(aContext, rects, count) @return void */ function CGContextStrokeRect(aContext, aRect) -{ +{ CGContextBeginPath(aContext); CGContextAddRect(aContext, aRect); CGContextClosePath(aContext); - + CGContextDrawPath(aContext, kCGPathStroke); } @@ -391,10 +391,10 @@ function CGContextStrokeRect(aContext, aRect) function CGContextStrokeRectWithWidth(aContext, aRect, aWidth) { CGContextSaveGState(aContext); - + CGContextSetLineWidth(aContext, aWidth); CGContextStrokeRect(aContext, aRect); - + CGContextRestoreGState(aContext); } @@ -407,7 +407,7 @@ function CGContextStrokeRectWithWidth(aContext, aRect, aWidth) function CGContextConcatCTM(aContext, aTransform) { var CTM = aContext.gState.CTM; - + _CGAffineTransformConcatTo(CTM, aTransform, CTM); } @@ -431,7 +431,7 @@ function CGContextGetCTM(aContext) function CGContextRotateCTM(aContext, anAngle) { var gState = aContext.gState; - + gState.CTM = CGAffineTransformRotate(gState.CTM, anAngle); } @@ -445,7 +445,7 @@ function CGContextRotateCTM(aContext, anAngle) function CGContextScaleCTM(aContext, sx, sy) { var gState = aContext.gState; - + gState.CTM = _CGAffineTransformScale(gState.CTM, sx, sy); } @@ -459,7 +459,7 @@ function CGContextScaleCTM(aContext, sx, sy) function CGContextTranslateCTM(aContext, tx, ty) { var gState = aContext.gState; - + gState.CTM = _CGAffineTransformTranslate(gState.CTM, tx, ty); } @@ -474,7 +474,7 @@ function CGContextTranslateCTM(aContext, tx, ty) function CGContextSetShadow(aContext, aSize, aBlur) { var gState = aContext.gState; - + gState.shadowOffset = _CGSizeMakeCopy(aSize); gState.shadowBlur = aBlur; gState.shadowColor = [CPColor shadowColor]; @@ -491,7 +491,7 @@ function CGContextSetShadow(aContext, aSize, aBlur) function CGContextSetShadowWithColor(aContext, aSize, aBlur, aColor) { var gState = aContext.gState; - + gState.shadowOffset = _CGSizeMakeCopy(aSize); gState.shadowBlur = aBlur; gState.shadowColor = aColor; @@ -605,10 +605,10 @@ function CGContextStrokePath(aContext) function CGContextStrokeLineSegments(aContext, points, count) { var i = 0; - + if (arguments["count"] == NULL) var count = points.length; - + CGContextBeginPath(aContext); for (; i < count; i += 2) @@ -616,7 +616,7 @@ function CGContextStrokeLineSegments(aContext, points, count) CGContextMoveToPoint(aContext, points[i].x, points[i].y); CGContextAddLineToPoint(aContext, points[i + 1].x, points[i + 1].y); } - + CGContextStrokePath(aContext); } @@ -681,12 +681,12 @@ function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, s function CGContextStrokeRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw) { CGContextBeginPath(aContext); - CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw)); + CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw)); CGContextClosePath(aContext); CGContextStrokePath(aContext); } -/*! +/*! @} */ diff --git a/AppKit/CoreGraphics/CGPath.j b/AppKit/CoreGraphics/CGPath.j index e0a989401..bd2a6b393 100644 --- a/AppKit/CoreGraphics/CGPath.j +++ b/AppKit/CoreGraphics/CGPath.j @@ -267,21 +267,21 @@ var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0); function CGPathWithEllipseInRect(aRect) { var path = CGPathCreateMutable(); - - if (_CGRectGetWidth(aRect) == _CGRectGetHeight(aRect)) + + if (_CGRectGetWidth(aRect) == _CGRectGetHeight(aRect)) CGPathAddArc(path, nil, _CGRectGetMidX(aRect), _CGRectGetMidY(aRect), _CGRectGetWidth(aRect) / 2.0, 0.0, 2 * PI, YES); - else - { - var axis = _CGSizeMake(_CGRectGetWidth(aRect) / 2.0, _CGRectGetHeight(aRect) / 2.0), - center = _CGPointMake(_CGRectGetMinX(aRect) + axis.width, _CGRectGetMinY(aRect) + axis.height); + else + { + var axis = _CGSizeMake(_CGRectGetWidth(aRect) / 2.0, _CGRectGetHeight(aRect) / 2.0), + center = _CGPointMake(_CGRectGetMinX(aRect) + axis.width, _CGRectGetMinY(aRect) + axis.height); CGPathMoveToPoint(path, nil, center.x, center.y - axis.height); - - CGPathAddCurveToPoint(path, nil, center.x + (KAPPA * axis.width), center.y - axis.height, center.x + axis.width, center.y - (KAPPA * axis.height), center.x + axis.width, center.y); - CGPathAddCurveToPoint(path, nil, center.x + axis.width, center.y + (KAPPA * axis.height), center.x + (KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height); - CGPathAddCurveToPoint(path, nil, center.x - (KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (KAPPA * axis.height), center.x - axis.width, center.y); - CGPathAddCurveToPoint(path, nil, center.x - axis.width, center.y - (KAPPA * axis.height), center.x - (KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height); - } + + CGPathAddCurveToPoint(path, nil, center.x + (KAPPA * axis.width), center.y - axis.height, center.x + axis.width, center.y - (KAPPA * axis.height), center.x + axis.width, center.y); + CGPathAddCurveToPoint(path, nil, center.x + axis.width, center.y + (KAPPA * axis.height), center.x + (KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height); + CGPathAddCurveToPoint(path, nil, center.x - (KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (KAPPA * axis.height), center.x - axis.width, center.y); + CGPathAddCurveToPoint(path, nil, center.x - axis.width, center.y - (KAPPA * axis.height), center.x - (KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height); + } CGPathCloseSubpath(path); @@ -297,37 +297,38 @@ function CGPathWithRoundedRectangleInRect(aRect, xRadius, yRadius/*not currently yMax = _CGRectGetMaxY(aRect); CGPathMoveToPoint(path, nil, xMin + xRadius, yMin); - - if (ne) - { - CGPathAddLineToPoint(path, nil, xMax - xRadius, yMin); - CGPathAddCurveToPoint(path, nil, xMax - xRadius, yMin, xMax, yMin, xMax, yMin + xRadius); - } - else - CGPathAddLineToPoint(path, nil, xMax, yMin); - - if (se) - { - CGPathAddLineToPoint(path, nil, xMax, yMax - xRadius); - CGPathAddCurveToPoint(path, nil, xMax, yMax - xRadius, xMax, yMax, xMax - xRadius, yMax); - } - else - CGPathAddLineToPoint(path, nil, xMax, yMax); - - if (sw) - { - CGPathAddLineToPoint(path, nil, xMin + xRadius, yMax); - CGPathAddCurveToPoint(path, nil, xMin + xRadius, yMax, xMin, yMax, xMin, yMax - xRadius); - } - else - CGPathAddLineToPoint(path, nil, xMin, yMax); - - if (nw) - { - CGPathAddLineToPoint(path, nil, xMin, yMin + xRadius); - CGPathAddCurveToPoint(path, nil, xMin, yMin + xRadius, xMin, yMin, xMin + xRadius, yMin); - } else - CGPathAddLineToPoint(path, nil, xMin, yMin); + + if (ne) + { + CGPathAddLineToPoint(path, nil, xMax - xRadius, yMin); + CGPathAddCurveToPoint(path, nil, xMax - xRadius, yMin, xMax, yMin, xMax, yMin + xRadius); + } + else + CGPathAddLineToPoint(path, nil, xMax, yMin); + + if (se) + { + CGPathAddLineToPoint(path, nil, xMax, yMax - xRadius); + CGPathAddCurveToPoint(path, nil, xMax, yMax - xRadius, xMax, yMax, xMax - xRadius, yMax); + } + else + CGPathAddLineToPoint(path, nil, xMax, yMax); + + if (sw) + { + CGPathAddLineToPoint(path, nil, xMin + xRadius, yMax); + CGPathAddCurveToPoint(path, nil, xMin + xRadius, yMax, xMin, yMax, xMin, yMax - xRadius); + } + else + CGPathAddLineToPoint(path, nil, xMin, yMax); + + if (nw) + { + CGPathAddLineToPoint(path, nil, xMin, yMin + xRadius); + CGPathAddCurveToPoint(path, nil, xMin, yMin + xRadius, xMin, yMin, xMin + xRadius, yMin); + } + else + CGPathAddLineToPoint(path, nil, xMin, yMin); CGPathCloseSubpath(path); diff --git a/Foundation/CPData.j b/Foundation/CPData.j index 3c844b8c9..69b37d490 100644 --- a/Foundation/CPData.j +++ b/Foundation/CPData.j @@ -37,8 +37,8 @@ + (id)alloc { var result = new CFMutableData(); - result.isa = [self class]; - return result; + result.isa = [self class]; + return result; } + (CPData)data diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index f04b3849b..a46a44c3e 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -39,8 +39,8 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0)); + (id)alloc { - var result = new Date; - result.isa = [self class]; + var result = new Date; + result.isa = [self class]; return result; } diff --git a/Foundation/CPDecimalNumber.j b/Foundation/CPDecimalNumber.j index cadb5297c..3c09dee7d 100644 --- a/Foundation/CPDecimalNumber.j +++ b/Foundation/CPDecimalNumber.j @@ -196,7 +196,7 @@ _cappdefaultDcmHandler = [CPDecimalNumberHandler decimalNumberHandlerWithRoundin { if (self = [self init]) { - if( flag ) + if (flag) mantissa *= -1; _data = CPDecimalMakeWithParts(mantissa, exponent); @@ -259,7 +259,7 @@ _cappdefaultDcmHandler = [CPDecimalNumberHandler decimalNumberHandlerWithRoundin { var s = @"", i = 0; - for(;i < CPDecimalMaxDigits; i++) + for (;i < CPDecimalMaxDigits; i++) s += "9"; s += "e" + CPDecimalMaxExponent; return [[self alloc] initWithString:s]; @@ -269,7 +269,7 @@ _cappdefaultDcmHandler = [CPDecimalNumberHandler decimalNumberHandlerWithRoundin { var s = @"-", i = 0; - for(;i < CPDecimalMaxDigits; i++) + for (;i < CPDecimalMaxDigits; i++) s += "9"; s += "e" + CPDecimalMinExponent; return [[self alloc] initWithString:s]; diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index 3d42951c2..6288e688b 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -84,8 +84,8 @@ */ + (id)alloc { - var result = new CFMutableDictionary(); - result.isa = [self class]; + var result = new CFMutableDictionary(); + result.isa = [self class]; return result; } diff --git a/Foundation/CPIndexPath.j b/Foundation/CPIndexPath.j index 42a26784f..d01a9abcd 100644 --- a/Foundation/CPIndexPath.j +++ b/Foundation/CPIndexPath.j @@ -85,7 +85,7 @@ if (anObject === self) return YES; - if([anObject class] !== [CPIndexPath class]) + if ([anObject class] !== [CPIndexPath class]) return NO; return [_indexes isEqualToArray:[anObject indexes]]; diff --git a/Foundation/CPRange.j b/Foundation/CPRange.j index b91a878d3..a6092a483 100755 --- a/Foundation/CPRange.j +++ b/Foundation/CPRange.j @@ -115,7 +115,8 @@ function CPLocationInRange(aLocation, aRange) function CPUnionRange(lhsRange, rhsRange) { var location = MIN(lhsRange.location, rhsRange.location); - return CPMakeRange(location, MAX(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location); + + return CPMakeRange(location, MAX(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location); } /*! @@ -127,10 +128,11 @@ function CPUnionRange(lhsRange, rhsRange) */ function CPIntersectionRange(lhsRange, rhsRange) { - if(CPMaxRange(lhsRange) < rhsRange.location || CPMaxRange(rhsRange) < lhsRange.location) + if (CPMaxRange(lhsRange) < rhsRange.location || CPMaxRange(rhsRange) < lhsRange.location) return CPMakeRange(0, 0); var location = MAX(lhsRange.location, rhsRange.location); + return CPMakeRange(location, MIN(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location); } diff --git a/Foundation/CPScanner.j b/Foundation/CPScanner.j index b5373f0af..89c6e14bf 100644 --- a/Foundation/CPScanner.j +++ b/Foundation/CPScanner.j @@ -72,12 +72,12 @@ - (id)copy { var copy = [[CPScanner alloc] initWithString:[self string]]; - + [copy setCharactersToBeSkipped:[self charactersToBeSkipped]]; [copy setCaseSensitive:[self caseSensitive]]; [copy setLocale:[self locale]]; [copy setScanLocation:[self scanLocation]]; - + return copy; } @@ -179,14 +179,14 @@ { if ([self isAtEnd]) return nil; - + var current = [self scanLocation]; var str = nil; - + while (current < _string.length) { var c = (_string.charAt(current)); - + if ([scanSet characterIsMember:c] == stop) break; @@ -196,13 +196,13 @@ str = ''; str += c; } - + current++; } - + if (str) [self setScanLocation:current]; - + return str; } @@ -215,15 +215,15 @@ var current = [self scanLocation]; var string = [self string]; var toSkip = [self charactersToBeSkipped]; - + while (current < string.length) { if (![toSkip characterIsMember:string.charAt(current)]) break; - + current++; } - + [self setScanLocation:current]; } @@ -265,22 +265,22 @@ var currentStr = str.substr(current, s.length); if (currentStr == s || (!_caseSensitive && currentStr.toLowerCase() == s.toLowerCase())) break; - + if (!captured) captured = ''; captured += str.charAt(current); current++; } - + if (captured) [self setScanLocation:current]; - + // evil private method use! // this method is defined in the category on CPString // in CPCharacterSet.j if ([self charactersToBeSkipped]) captured = [captured _stringByTrimmingCharactersInSet:[self charactersToBeSkipped] options:_CPCharacterSetTrimAtBeginning]; - + return captured; } @@ -292,10 +292,10 @@ { [self _movePastCharactersToBeSkipped]; var str = [self string], current = [self scanLocation]; - + if ([self isAtEnd]) return 0; - + var s = str.substring(current, str.length); var f = parseFloat(s); // wont work with non . decimal separator !! if (f) @@ -303,16 +303,16 @@ var pos, foundDash = NO; /* var decimalSeparatorString; - if(_locale != nil) + if (_locale != nil) decimalSeparatorString = [_locale objectForKey:CPLocaleDecimalSeparator]; else decimalSeparatorString = [[CPLocale systemLocale] objectForKey:CPLocaleDecimalSeparator]; - + var separatorCode = (decimalSeparatorString.length >0) decimalSeparatorString.charCodeAt(0) : 45; */ var separatorCode = 45; - for(pos = current; pos < current + str.length; pos++) + for (pos = current; pos < current + str.length; pos++) { var charCode = str.charCodeAt(pos); if (charCode == separatorCode) @@ -324,11 +324,11 @@ else if (charCode < 48 || charCode > 57 || (charCode == 45 && pos != current)) // not a digit or a "-" but not prefix break; } - + [self setScanLocation:pos]; return f; } - + return nil; } @@ -357,11 +357,11 @@ else if (charCode < 48 || charCode > 57 || (charCode == 45 && pos != current)) break; } - + [self setScanLocation:pos]; return i; } - + return nil; } diff --git a/Foundation/CPSet.j b/Foundation/CPSet.j index 0a1e5f821..57c5c263d 100644 --- a/Foundation/CPSet.j +++ b/Foundation/CPSet.j @@ -152,8 +152,8 @@ { if (self = [self init]) { - var argLength = arguments.length, - i = 2; + var argLength = arguments.length, + i = 2; for (; i < argLength && (argument = arguments[i]) != nil; ++i) [self addObject:argument]; diff --git a/Foundation/CPString.j b/Foundation/CPString.j index cf2942de2..e4dfa459d 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -485,7 +485,7 @@ var CPStringRegexSpecialCharacters = [ rhs = rhs.toLowerCase(); } - if(aMask & CPDiacriticInsensitiveSearch) + if (aMask & CPDiacriticInsensitiveSearch) { lhs = lhs.stripDiacritics(); rhs = rhs.stripDiacritics(); @@ -493,7 +493,8 @@ var CPStringRegexSpecialCharacters = [ if (lhs < rhs) return CPOrderedAscending; - else if (lhs > rhs) + + if (lhs > rhs) return CPOrderedDescending; return CPOrderedSame; @@ -818,7 +819,7 @@ String.prototype.stripDiacritics = function () { var drange = diacritics[i]; - if (code >= drange[0] && code <= drange[drange.length-1]) + if (code >= drange[0] && code <= drange[drange.length - 1]) { code = normalized[i]; break; diff --git a/Foundation/CPURL.j b/Foundation/CPURL.j index a79e1aae4..f9437f71d 100644 --- a/Foundation/CPURL.j +++ b/Foundation/CPURL.j @@ -55,8 +55,8 @@ CPURLCustomIconKey = @"CPURLCustomIconKey"; + (id)alloc { var result = new CFURL(); - result.isa = [self class]; - return result; + result.isa = [self class]; + return result; } - (id)init @@ -84,8 +84,8 @@ CPURLCustomIconKey = @"CPURLCustomIconKey"; - (id)initWithString:(CPString)URLString relativeToURL:(CPURL)aBaseURL { var result = new CFURL(URLString, aBaseURL); - result.isa = [self class]; - return result; + result.isa = [self class]; + return result; } + (id)URLWithString:(CPString)URLString relativeToURL:(CPURL)aBaseURL diff --git a/Tests/AppKit/CPTreeNodeTest.j b/Tests/AppKit/CPTreeNodeTest.j index a9303bf73..3bb5510a8 100644 --- a/Tests/AppKit/CPTreeNodeTest.j +++ b/Tests/AppKit/CPTreeNodeTest.j @@ -11,7 +11,7 @@ - (void)setUp { treeNode = [CPTreeNode treeNodeWithRepresentedObject:nil]; - + childNode = [CPTreeNode treeNodeWithRepresentedObject:nil]; [treeNode insertObject:childNode inChildNodesAtIndex:0]; } @@ -19,9 +19,11 @@ - (void)testDescendantNodeAtIndexPath { var indexPath = [CPIndexPath indexPathWithIndex:0]; + [self assert:childNode equals:[treeNode descendantNodeAtIndexPath:indexPath]]; - + indexPath = [CPIndexPath indexPathWithIndex:1]; + [self assert:undefined equals:[treeNode descendantNodeAtIndexPath:indexPath]]; } diff --git a/Tests/Foundation/CPArrayPerformanceTest.j b/Tests/Foundation/CPArrayPerformanceTest.j index e4d014aa5..573e54dab 100644 --- a/Tests/Foundation/CPArrayPerformanceTest.j +++ b/Tests/Foundation/CPArrayPerformanceTest.j @@ -3,6 +3,7 @@ @import @import + var ELEMENTS = 100, REPEATS = 10; @@ -19,15 +20,16 @@ var ELEMENTS = 100, var start = (new Date).getTime(); - for (var i=0; i0; --i) + for (i = length - 1; i > 0; --i) a.push(self[i]); return a; diff --git a/Tests/Foundation/CPDictionaryTest.j b/Tests/Foundation/CPDictionaryTest.j index 023177beb..e697e2c1c 100644 --- a/Tests/Foundation/CPDictionaryTest.j +++ b/Tests/Foundation/CPDictionaryTest.j @@ -68,9 +68,9 @@ "key2": "This is a string", "key3": null } - + var dict = [CPDictionary dictionaryWithJSObject:json_with_nulls recursively:YES]; - + [self assert:3 equals:[dict count]]; [self assert:[@"key1", @"key2", @"key3"] equals:[dict allKeys]]; [self assert:[CPNull null] equals:[dict objectForKey:@"key3"]]; diff --git a/Tests/Foundation/CPFormatterTest.j b/Tests/Foundation/CPFormatterTest.j index 232d23645..04a4afd7c 100644 --- a/Tests/Foundation/CPFormatterTest.j +++ b/Tests/Foundation/CPFormatterTest.j @@ -2,7 +2,7 @@ @implementation CPFormatterTest : OJTestCase -- (void)testThatCPFormatterIsConstructed +- (void)testThatCPFormatterIsConstructed { [self assertNotNull:[[CPFormatter alloc] init]]; } diff --git a/Tests/Foundation/CPObjectTest.j b/Tests/Foundation/CPObjectTest.j index 729e01c9e..2926f99f5 100644 --- a/Tests/Foundation/CPObjectTest.j +++ b/Tests/Foundation/CPObjectTest.j @@ -7,13 +7,12 @@ - (void)testImplementsSelector { var receiver = [[Receiver alloc] init]; - + [self assertTrue:[receiver implementsSelector:@selector(implementedInReceiverAndSuper)]]; [self assertTrue:[receiver implementsSelector:@selector(implementedInReceiverOnly)]]; - + [self assertFalse:[receiver implementsSelector:@selector(implementedInSuperOnly)]]; [self assertFalse:[receiver implementsSelector:@selector(notImplementedInSuperNorReceiver)]]; - } @end diff --git a/Tests/Foundation/CPOperationTest.j b/Tests/Foundation/CPOperationTest.j index ccb9cf48e..d577a754b 100644 --- a/Tests/Foundation/CPOperationTest.j +++ b/Tests/Foundation/CPOperationTest.j @@ -1,6 +1,6 @@ @import -@implementation TestOperation : CPOperation +@implementation TestOperation : CPOperation { CPString name @accessors; CPString value @accessors; @@ -177,7 +177,7 @@ [to cancel]; - [self assert:@"isCancelled" equals:[[obs changedKeyPaths] objectAtIndex:9]]; + [self assert:@"isCancelled" equals:[[obs changedKeyPaths] objectAtIndex:9]]; } @end diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j index dffaabc87..8bd9c39cd 100644 --- a/Tests/Foundation/CPStringTest.j +++ b/Tests/Foundation/CPStringTest.j @@ -47,7 +47,7 @@ [self assert:"str" equals:str]; } -- (void) testInitWithFormat +- (void)testInitWithFormat { // this could be really big var str = [[CPString alloc] initWithFormat:"%s", "str"]; diff --git a/Tests/Foundation/SubclassTollFreeTest.j b/Tests/Foundation/SubclassTollFreeTest.j index f7b6191b5..d1ea35c54 100644 --- a/Tests/Foundation/SubclassTollFreeTest.j +++ b/Tests/Foundation/SubclassTollFreeTest.j @@ -2,62 +2,62 @@ - (void)testThatSubclassTollFreeDoesAllowForSubclassingDictionary { - var target = [[MyDict alloc] init]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assert:0 equals:[target count]]; + var target = [[MyDict alloc] init]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assert:0 equals:[target count]]; } - (void)testThatSubclassTollFreeDoesAllowForSubclassingString { - var target = [[MyString alloc] initWithString:@"adsf"]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assert:4 equals:[target length]]; - - var target2 = "agdsa"; - [OJAssert assertThrows:function(){ [target2 newMessage]; }]; - [OJAssert assert:5 equals:[target2 length]]; + var target = [[MyString alloc] initWithString:@"adsf"]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assert:4 equals:[target length]]; + + var target2 = "agdsa"; + [OJAssert assertThrows:function(){ [target2 newMessage]; }]; + [OJAssert assert:5 equals:[target2 length]]; } - (void)testThatSubclassTollFreeDoesAllowForSubclassingNumber { - var target = [[MyNum alloc] init]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assertFalse:[target isEqualToNumber:5]]; + var target = [[MyNum alloc] init]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assertFalse:[target isEqualToNumber:5]]; } - (void)testThatSubclassTollFreeDoesAllowForSubclassingException { - var target = [[MyException alloc] init]; - [OJAssert assert:@"a" equals:[target newMessage]]; - // there are no internal properties to test here.. so no need to jimmyrig it. + var target = [[MyException alloc] init]; + [OJAssert assert:@"a" equals:[target newMessage]]; + // there are no internal properties to test here.. so no need to jimmyrig it. } - (void)testThatSubclassTollFreeDoesAllowForSubclassingArray { - var target = [[MyArray alloc] initWithObjects:@"a"]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assert:1 equals:[target count]]; + var target = [[MyArray alloc] initWithObjects:@"a"]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assert:1 equals:[target count]]; } - (void)testThatSubclassTollFreeDoesAllowForSubclassingDate { - var target = [[MyDate alloc] init]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assertTrue:[target timeIntervalSince1970] > 0]; + var target = [[MyDate alloc] init]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assertTrue:[target timeIntervalSince1970] > 0]; } - (void)testThatSubclassTollFreeDoesAllowForSubclassingData { - var target = [[MyData alloc] initWithRawString:@"b"]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assert:@"b" equals:[target rawString]]; + var target = [[MyData alloc] initWithRawString:@"b"]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assert:@"b" equals:[target rawString]]; } - (void)testThatSubclassTollFreeDoesAllowForSubclassingURL { - var target = [[MyURL alloc] initWithString:@"http://www.google.com"]; - [OJAssert assert:@"a" equals:[target newMessage]]; - [OJAssert assert:@"http://www.google.com" equals:[target absoluteString]]; + var target = [[MyURL alloc] initWithString:@"http://www.google.com"]; + [OJAssert assert:@"a" equals:[target newMessage]]; + [OJAssert assert:@"http://www.google.com" equals:[target absoluteString]]; } @@ -69,7 +69,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -78,7 +78,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -87,7 +87,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -96,7 +96,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -105,7 +105,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -114,7 +114,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -123,7 +123,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end @@ -132,7 +132,7 @@ - (id)newMessage { - return "a"; + return "a"; } @end diff --git a/Tests/Manual/AttachedSheet/AppController.j b/Tests/Manual/AttachedSheet/AppController.j index 152197203..fc0bc34cb 100644 --- a/Tests/Manual/AttachedSheet/AppController.j +++ b/Tests/Manual/AttachedSheet/AppController.j @@ -10,17 +10,18 @@ @implementation AppController : CPObject { - CPWindow window; - CPWindow sheet; - CPTextField textField; + CPWindow window; + CPWindow sheet; + CPTextField textField; } - (void)applicationDidFinishLaunching:(CPNotification)aNotification { window = [[CPWindow alloc] initWithContentRect:CGRectMake(100,100,500,300) styleMask:CPResizableWindowMask], contentView = [window contentView]; - [window setMinSize:CGSizeMake(300, 200)]; - sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(0,0,300,100) styleMask:CPDocModalWindowMask|CPResizableWindowMask]; + + [window setMinSize:CGSizeMake(300, 200)]; + sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(0,0,300,100) styleMask:CPDocModalWindowMask | CPResizableWindowMask]; [sheet setMinSize:CGSizeMake(300,100)]; var sheetContent = [sheet contentView]; @@ -35,14 +36,14 @@ [okButton setTarget:self]; [okButton setTag:1]; [okButton setAction:@selector(closeSheet:)]; - [okButton setAutoresizingMask:CPViewMinXMargin|CPViewMinYMargin]; + [okButton setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; var cancelButton = [[CPButton alloc] initWithFrame:CGRectMake(120,70,100,24)]; [cancelButton setTitle:"Cancel"]; [cancelButton setTarget:self]; [cancelButton setTag:0]; [cancelButton setAction:@selector(closeSheet:)]; - [cancelButton setAutoresizingMask:CPViewMinXMargin|CPViewMinYMargin]; + [cancelButton setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; [sheetContent addSubview:textField]; [sheetContent addSubview:okButton]; @@ -52,9 +53,9 @@ [displayButton setTitle:"Display Sheet"]; [displayButton setTarget:self]; [displayButton setAction:@selector(displaySheet:)]; - [contentView addSubview:displayButton]; + [contentView addSubview:displayButton]; - [window orderFront:self] + [window orderFront:self] } - (void)displaySheet:(id)sender @@ -75,10 +76,9 @@ var str = [textField stringValue]; [sheet orderOut:self]; + if (returnCode == CPOKButton && [str length] > 0) - { - [window setTitle:str]; - } + [window setTitle:str]; } @end \ No newline at end of file diff --git a/Tests/Manual/CPBrowserTest/AppController.j b/Tests/Manual/CPBrowserTest/AppController.j index 9a002c9b2..31c236441 100644 --- a/Tests/Manual/CPBrowserTest/AppController.j +++ b/Tests/Manual/CPBrowserTest/AppController.j @@ -55,13 +55,13 @@ var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], contentView = [theWindow contentView]; - var box = [[CPBox alloc] initWithFrame:CGRectMake(0,0,500,300)]; - browser = [[CPBrowser alloc] initWithFrame:CGRectMake(0,0,500,300)]; + var box = [[CPBox alloc] initWithFrame:CGRectMake(0, 0, 500, 300)], + browser = [[CPBrowser alloc] initWithFrame:CGRectMake(0, 0, 500, 300)]; [browser setWidth:300 ofColumn:1]; [box setContentView:browser]; [box setBorderType:CPBezelBorder]; - [box setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable]; + [box setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [box setCenter:[contentView center]]; [contentView addSubview:box]; @@ -96,7 +96,7 @@ - (void)browserClicked:(id)sender { - console.log("selected column: "+[browser selectedColumn]+" row: "+[browser selectedRowInColumn:[browser selectedColumn]]); + console.log("selected column: " + [browser selectedColumn] + " row: " + [browser selectedRowInColumn:[browser selectedColumn]]); } - (void)dblClicked:(id)sender diff --git a/Tests/Manual/CPButtonKeyEquivalentDefaultTest/AppController.j b/Tests/Manual/CPButtonKeyEquivalentDefaultTest/AppController.j index 618505073..2c060f4e2 100644 --- a/Tests/Manual/CPButtonKeyEquivalentDefaultTest/AppController.j +++ b/Tests/Manual/CPButtonKeyEquivalentDefaultTest/AppController.j @@ -62,7 +62,7 @@ CPLogRegister(CPLogConsole); - (void)changeDefault:(id)sender { - var buttonWindow = [sender window] + var buttonWindow = [sender window], tag = [[buttonWindow defaultButton] tag] === 1 ? 2 : 1; [buttonWindow setDefaultButton:[[buttonWindow contentView] viewWithTag:tag]]; diff --git a/Tests/Manual/CPControlPerformClickExceptionTest/AppController.j b/Tests/Manual/CPControlPerformClickExceptionTest/AppController.j index fc07ffc5b..6521d13e1 100644 --- a/Tests/Manual/CPControlPerformClickExceptionTest/AppController.j +++ b/Tests/Manual/CPControlPerformClickExceptionTest/AppController.j @@ -64,7 +64,7 @@ var UseFix = NO; } } --(void)alertDidEnd:(CPAlert)theAlert returnCode:(int)returnCode +- (void)alertDidEnd:(CPAlert)theAlert returnCode:(int)returnCode { [button highlight:NO]; } diff --git a/Tests/Manual/CPCursor/AppController.j b/Tests/Manual/CPCursor/AppController.j index ff79fad15..3e10b58f8 100644 --- a/Tests/Manual/CPCursor/AppController.j +++ b/Tests/Manual/CPCursor/AppController.j @@ -23,39 +23,39 @@ var selectors = ["pointingHandCursor", "resizeDownCursor", "resizeLeftCursor", " popup = [[CPPopUpButton alloc] initWithFrame:CGRectMake(100,100,150,24)]; var menu = [popup menu]; for (var i = 0 , count = [selectors count];i < count;i++) - { + { var selector = selectors[i]; var item = [[CPMenuItem alloc] initWithTitle:selector action:nil keyEquivalent:@""]; [item setTarget:self]; [menu addItem:item]; } [contentView addSubview:popup]; - + var button = [[CPButton alloc] initWithFrame:CGRectMake(270,100,100,24)]; [button setAction:@selector(setCursor:)]; [button setTarget:self]; [button setTitle:@"set Cursor"]; [contentView addSubview:button]; - + var button = [[CPButton alloc] initWithFrame:CGRectMake(270,150,150,24)]; [button setAction:@selector(setUrlCursor:)]; [button setTarget:self]; [button setTitle:@"set Cursor from url"]; [contentView addSubview:button]; - + [theWindow orderFront:self]; // Uncomment the following line to turn on the standard menu bar. //[CPMenu setMenuBarVisible:YES]; } --(void)setCursor:(id)sender +- (void)setCursor:(id)sender { var selector = CPSelectorFromString([popup titleOfSelectedItem]); var cursor = [CPCursor performSelector:selector]; [cursor set]; } --(void)setUrlCursor:(id)sender +- (void)setUrlCursor:(id)sender { // note gifs don't animate when they are used as a cursor. var aImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"spinner.gif"]]; var cursor = [[CPCursor alloc] initWithImage:aImage hotSpot:CGPointMakeZero()]; diff --git a/Tests/Manual/CPGraphicsTest/AppController.j b/Tests/Manual/CPGraphicsTest/AppController.j index 3053982c9..43936c59a 100644 --- a/Tests/Manual/CPGraphicsTest/AppController.j +++ b/Tests/Manual/CPGraphicsTest/AppController.j @@ -34,7 +34,7 @@ { var bounds = [aView bounds], sides = [CPMinYEdge, CPMaxYEdge, CPMinXEdge, CPMaxXEdge], - grays = [192.0/255.0, 1.0, 192.0/255.0, 1.0], + grays = [192.0 / 255.0, 1.0, 192.0 / 255.0, 1.0], clipRect = [aView bounds]; if (aView === view2) diff --git a/Tests/Manual/CPSearchField/AppController.j b/Tests/Manual/CPSearchField/AppController.j index e239f293b..ef4e13cc7 100644 --- a/Tests/Manual/CPSearchField/AppController.j +++ b/Tests/Manual/CPSearchField/AppController.j @@ -31,7 +31,7 @@ var categories = ["firstName","lastName"], [searchField setRecentsAutosaveName:"autosave"]; [searchField setTarget:self]; [searchField setAction:@selector(updateFilter:)]; - [searchField setAutoresizingMask:CPViewMaxXMargin|CPViewMaxYMargin]; + [searchField setAutoresizingMask:CPViewMaxXMargin | CPViewMaxYMargin]; searchMenuTemplate = [searchField defaultSearchMenuTemplate]; diff --git a/Tests/Manual/CPTabView2/AppController.j b/Tests/Manual/CPTabView2/AppController.j index a08c0aa44..1eca4568c 100644 --- a/Tests/Manual/CPTabView2/AppController.j +++ b/Tests/Manual/CPTabView2/AppController.j @@ -17,27 +17,27 @@ var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], contentView = [theWindow contentView]; - var tabView = [[CPTabView alloc] initWithFrame:CGRectMake(50,50,400,400)]; - [tabView setTabViewType:CPNoTabsBezelBorder]; - [tabView setTabViewType:CPTopTabsBezelBorder]; + var tabView = [[CPTabView alloc] initWithFrame:CGRectMake(50,50,400,400)]; + [tabView setTabViewType:CPNoTabsBezelBorder]; + [tabView setTabViewType:CPTopTabsBezelBorder]; - var view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)]; - [view addSubview:[CPTextField labelWithTitle:@"First"]]; - var item = [[CPTabViewItem alloc] initWithIdentifier:@"a"]; - [item setView:view]; - [item setLabel:"Test"]; - [tabView addTabViewItem:item]; + var view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)]; + [view addSubview:[CPTextField labelWithTitle:@"First"]]; + var item = [[CPTabViewItem alloc] initWithIdentifier:@"a"]; + [item setView:view]; + [item setLabel:"Test"]; + [tabView addTabViewItem:item]; - view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)]; - [view addSubview:[CPTextField labelWithTitle:@"Second"]]; - item = [[CPTabViewItem alloc] initWithIdentifier:@"a"]; - [item setView:view]; - [item setLabel:"Test2"]; - [tabView addTabViewItem:item]; + view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)]; + [view addSubview:[CPTextField labelWithTitle:@"Second"]]; + item = [[CPTabViewItem alloc] initWithIdentifier:@"a"]; + [item setView:view]; + [item setLabel:"Test2"]; + [tabView addTabViewItem:item]; - [contentView addSubview:tabView]; + [contentView addSubview:tabView]; - [tabView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + [tabView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [theWindow orderFront:self]; }