From b70018bd80ccccf855a33a189dcb325ad173b4aa Mon Sep 17 00:00:00 2001 From: Stephen Ierodiaconou Date: Sat, 25 Dec 2010 18:22:47 +0200 Subject: [PATCH] Import fixes and lint --- Foundation/CPAttributedString.j | 3 +- Foundation/CPBundle.j | 5 +- Foundation/CPCoder.j | 1 - Foundation/CPCountedSet.j | 2 +- Foundation/CPData.j | 1 - Foundation/CPDate.j | 2 +- Foundation/CPDecimalNumber.j | 2 +- Foundation/CPDictionary.j | 2 +- Foundation/CPEnumerator.j | 1 - Foundation/CPException.j | 19 +++--- Foundation/CPFormatter.j | 5 -- Foundation/CPFunctionOperation.j | 9 +-- Foundation/CPIndexPath.j | 25 +++++++- Foundation/CPIndexSet.j | 2 +- Foundation/CPInvocation.j | 2 - Foundation/CPInvocationOperation.j | 1 - Foundation/CPKeyValueCoding.j | 2 +- Foundation/CPKeyValueObserving.j | 18 +++--- Foundation/CPKeyedArchiver.j | 1 - Foundation/CPKeyedUnarchiver.j | 4 +- Foundation/CPNotification.j | 1 - Foundation/CPNotificationCenter.j | 1 - Foundation/CPNull.j | 1 - Foundation/CPNumber.j | 1 - Foundation/CPObject.j | 2 - Foundation/CPOperation.j | 16 ++--- Foundation/CPOperationQueue.j | 6 +- Foundation/CPPropertyListSerialization.j | 1 - Foundation/CPProxy.j | 2 +- Foundation/CPRunLoop.j | 1 + Foundation/CPScanner.j | 77 ++++++++++++++++-------- 31 files changed, 123 insertions(+), 93 deletions(-) diff --git a/Foundation/CPAttributedString.j b/Foundation/CPAttributedString.j index bcbd9a732..1ea754af7 100644 --- a/Foundation/CPAttributedString.j +++ b/Foundation/CPAttributedString.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import "CPArray.j" @import "CPDictionary.j" +@import "CPException.j" @import "CPObject.j" @import "CPRange.j" @import "CPString.j" - /*! @class CPAttributedString @ingroup foundation diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index 8c8f54bbe..7c4fedf4a 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -21,12 +21,11 @@ */ @import "CPDictionary.j" -@import "CPObject.j" @import "CPNotification.j" @import "CPNotificationCenter.j" +@import "CPObject.j" - -CPBundleDidLoadNotification = "CPBundleDidLoadNotification"; +CPBundleDidLoadNotification = @"CPBundleDidLoadNotification"; /*! @class CPBundle diff --git a/Foundation/CPCoder.j b/Foundation/CPCoder.j index 50fe4f8a2..62ee9cea2 100644 --- a/Foundation/CPCoder.j +++ b/Foundation/CPCoder.j @@ -23,7 +23,6 @@ @import "CPException.j" @import "CPObject.j" - /*! @class CPCoder @ingroup foundation diff --git a/Foundation/CPCountedSet.j b/Foundation/CPCountedSet.j index 8a540b317..cb5c13953 100644 --- a/Foundation/CPCountedSet.j +++ b/Foundation/CPCountedSet.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import "CPObject.j" @import "CPSet.j" - /*! @class CPCountedSet @ingroup foundation diff --git a/Foundation/CPData.j b/Foundation/CPData.j index 69b37d490..fa32c65e7 100644 --- a/Foundation/CPData.j +++ b/Foundation/CPData.j @@ -23,7 +23,6 @@ @import "CPObject.j" @import "CPString.j" - /*! @class CPData @ingroup foundation diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index a46a44c3e..8aab2db72 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -22,7 +22,7 @@ @import "CPObject.j" @import "CPString.j" - +@import "CPException.j" var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0)); diff --git a/Foundation/CPDecimalNumber.j b/Foundation/CPDecimalNumber.j index 3c09dee7d..59c9701bd 100644 --- a/Foundation/CPDecimalNumber.j +++ b/Foundation/CPDecimalNumber.j @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import "CPObject.j" @import "CPDecimal.j" @import "CPException.j" +@import "CPObject.j" /* The protocol is defined as : Make sure CPDecimalNumberHandler implements these methods @protocol CPDecimalNumberBehaviors diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index 6288e688b..69882448e 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -23,9 +23,9 @@ @import "CPArray.j" @import "CPEnumerator.j" @import "CPException.j" +@import "CPNull.j" @import "CPObject.j" - /* @ignore */ @implementation _CPDictionaryValueEnumerator : CPEnumerator { diff --git a/Foundation/CPEnumerator.j b/Foundation/CPEnumerator.j index 50efcb571..ff605a0a5 100755 --- a/Foundation/CPEnumerator.j +++ b/Foundation/CPEnumerator.j @@ -22,7 +22,6 @@ @import "CPObject.j" - /*! @class CPEnumerator @ingroup foundation diff --git a/Foundation/CPException.j b/Foundation/CPException.j index 68b0d4279..7788e2392 100755 --- a/Foundation/CPException.j +++ b/Foundation/CPException.j @@ -24,11 +24,10 @@ @import "CPObject.j" @import "CPString.j" - -CPInvalidArgumentException = "CPInvalidArgumentException"; -CPUnsupportedMethodException = "CPUnsupportedMethodException"; -CPRangeException = "CPRangeException"; -CPInternalInconsistencyException = "CPInternalInconsistencyException"; +CPInvalidArgumentException = @"CPInvalidArgumentException"; +CPUnsupportedMethodException = @"CPUnsupportedMethodException"; +CPRangeException = @"CPRangeException"; +CPInternalInconsistencyException = @"CPInternalInconsistencyException"; /*! @class CPException @@ -90,7 +89,9 @@ if (input == nil) */ - (id)initWithName:(CPString)aName reason:(CPString)aReason userInfo:(CPDictionary)aUserInfo { - if (self = [super init]) + self = [super init]; + + if (self) { name = aName; message = aReason; @@ -162,9 +163,9 @@ if (input == nil) @end -var CPExceptionNameKey = "CPExceptionNameKey", - CPExceptionReasonKey = "CPExceptionReasonKey", - CPExceptionUserInfoKey = "CPExceptionUserInfoKey"; +var CPExceptionNameKey = @"CPExceptionNameKey", + CPExceptionReasonKey = @"CPExceptionReasonKey", + CPExceptionUserInfoKey = @"CPExceptionUserInfoKey"; @implementation CPException (CPCoding) diff --git a/Foundation/CPFormatter.j b/Foundation/CPFormatter.j index e09219db7..459ebc220 100644 --- a/Foundation/CPFormatter.j +++ b/Foundation/CPFormatter.j @@ -36,7 +36,6 @@ @import "CPException.j" @import "CPObject.j" - @implementation CPFormatter : CPObject /*! @@ -57,13 +56,11 @@ return nil; } - /*- (CPAttributedString)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(CPDictionary)attributes { }*/ - /*! The default implementation of this method invokes stringForObjectValue:. @@ -80,7 +77,6 @@ return [self stringForObjectValue:anObject]; } - /*! The default implementation of this method raises an exception. @@ -102,7 +98,6 @@ return NO; } - /*! Returns a Boolean value that indicates whether a partial string is valid. diff --git a/Foundation/CPFunctionOperation.j b/Foundation/CPFunctionOperation.j index 7fb44ed74..34784374f 100644 --- a/Foundation/CPFunctionOperation.j +++ b/Foundation/CPFunctionOperation.j @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import +@import "CPArray.j" +@import "CPObject.j" @import "CPOperation.j" - /*! @class CPFunctionOperation @brief Represents an operation using a JavaScript function that can be run in an CPOperationQueue @@ -32,7 +32,6 @@ CPArray _functions; } - - (void)main { if (_functions && [_functions count] > 0) @@ -50,7 +49,9 @@ - (id)init { - if (self = [super init]) + self = [super init]; + + if (self) { _functions = []; } diff --git a/Foundation/CPIndexPath.j b/Foundation/CPIndexPath.j index d01a9abcd..d1413a2c0 100644 --- a/Foundation/CPIndexPath.j +++ b/Foundation/CPIndexPath.j @@ -1,10 +1,29 @@ +/* + * CPIndexPath.j + * Foundation + * + * Copyright 2008, 280 North, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ -@import "CPObject.j" @import "CPArray.j" +@import "CPException.j" +@import "CPObject.j" @import "CPRange.j" @import "CPSortDescriptor.j" -@import "CPException.j" - @implementation CPIndexPath : CPObject { diff --git a/Foundation/CPIndexSet.j b/Foundation/CPIndexSet.j index 26442d4d5..cd00998fb 100644 --- a/Foundation/CPIndexSet.j +++ b/Foundation/CPIndexSet.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import "CPArray.j" @import "CPObject.j" @import "CPRange.j" - #define _CPMaxRange(aRange) ((aRange).location + (aRange).length) #define _CPMakeRange(aLocation, aLength) { location:(aLocation), length:aLength } #define _CPMakeRangeCopy(aRange) { location:(aRange).location, length:(aRange).length } diff --git a/Foundation/CPInvocation.j b/Foundation/CPInvocation.j index da66a2a68..7cc5fbe32 100644 --- a/Foundation/CPInvocation.j +++ b/Foundation/CPInvocation.j @@ -20,10 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import "CPException.j" @import "CPObject.j" - /*! @class CPInvocation @ingroup foundation diff --git a/Foundation/CPInvocationOperation.j b/Foundation/CPInvocationOperation.j index b897ec161..f0409a4ea 100644 --- a/Foundation/CPInvocationOperation.j +++ b/Foundation/CPInvocationOperation.j @@ -23,7 +23,6 @@ @import "CPObject.j" @import "CPOperation.j" - /*! @class CPInvocationOperation @brief Represents an operation using an invocation that can be run in an CPOperationQueue diff --git a/Foundation/CPKeyValueCoding.j b/Foundation/CPKeyValueCoding.j index b6012e75b..a87f702c9 100644 --- a/Foundation/CPKeyValueCoding.j +++ b/Foundation/CPKeyValueCoding.j @@ -22,11 +22,11 @@ @import "CPArray.j" @import "CPDictionary.j" +@import "CPException.j" @import "CPNull.j" @import "CPObject.j" @import "CPSet.j" - CPUndefinedKeyException = @"CPUndefinedKeyException"; CPTargetObjectUserInfoKey = @"CPTargetObjectUserInfoKey"; CPUnknownUserInfoKey = @"CPUnknownUserInfoKey"; diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index a83bf8bd5..ca7fc12e6 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -207,20 +207,16 @@ var _changeKindForSetMutationKind = function(mutationKind) { switch (mutationKind) { - case CPKeyValueUnionSetMutation: - return CPKeyValueChangeInsertion; - case CPKeyValueMinusSetMutation: - return CPKeyValueChangeRemoval; - case CPKeyValueIntersectSetMutation: - return CPKeyValueChangeRemoval; - case CPKeyValueSetSetMutation: - return CPKeyValueChangeReplacement; + case CPKeyValueUnionSetMutation: return CPKeyValueChangeInsertion; + case CPKeyValueMinusSetMutation: return CPKeyValueChangeRemoval; + case CPKeyValueIntersectSetMutation: return CPKeyValueChangeRemoval; + case CPKeyValueSetSetMutation: return CPKeyValueChangeReplacement; } } -var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld, - DependentKeysKey = "$KVODEPENDENT", - KVOProxyKey = "$KVOPROXY"; +var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld, + DependentKeysKey = "$KVODEPENDENT", + KVOProxyKey = "$KVOPROXY"; //rule of thumb: _ methods are called on the real proxy object, others are called on the "fake" proxy object (aka the real object) diff --git a/Foundation/CPKeyedArchiver.j b/Foundation/CPKeyedArchiver.j index d933458a7..c35b0ee4d 100644 --- a/Foundation/CPKeyedArchiver.j +++ b/Foundation/CPKeyedArchiver.j @@ -28,7 +28,6 @@ @import "CPString.j" @import "CPValue.j" - var CPArchiverReplacementClassNames = nil; var _CPKeyedArchiverDidEncodeObjectSelector = 1, diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index a98853038..73014e46c 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -21,15 +21,15 @@ */ @import "CPArray.j" +@import "CPCoder.j" @import "CPData.j" @import "CPDictionary.j" -@import "CPCoder.j" +@import "CPException.j" @import "CPKeyedArchiver.j" @import "CPNull.j" @import "CPNumber.j" @import "CPString.j" - CPInvalidUnarchiveOperationException = @"CPInvalidUnarchiveOperationException"; var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector = 1 << 0, diff --git a/Foundation/CPNotification.j b/Foundation/CPNotification.j index 60df53e9d..5b9e8d51b 100644 --- a/Foundation/CPNotification.j +++ b/Foundation/CPNotification.j @@ -23,7 +23,6 @@ @import "CPException.j" @import "CPObject.j" - /*! @class CPNotification @ingroup foundation diff --git a/Foundation/CPNotificationCenter.j b/Foundation/CPNotificationCenter.j index b6c9b5e96..c38d7283f 100644 --- a/Foundation/CPNotificationCenter.j +++ b/Foundation/CPNotificationCenter.j @@ -26,7 +26,6 @@ @import "CPNotification.j" @import "CPNull.j" - var CPNotificationDefaultCenter = nil; /*! diff --git a/Foundation/CPNull.j b/Foundation/CPNull.j index 2c267dcb8..af98391f3 100644 --- a/Foundation/CPNull.j +++ b/Foundation/CPNull.j @@ -22,7 +22,6 @@ @import "CPObject.j" - var CPNullSharedNull = nil; /*! diff --git a/Foundation/CPNumber.j b/Foundation/CPNumber.j index 3b503fd0b..37d1b805d 100644 --- a/Foundation/CPNumber.j +++ b/Foundation/CPNumber.j @@ -23,7 +23,6 @@ @import "CPObject.j" @import "CPObjJRuntime.j" - var CPNumberUIDs = new CFMutableDictionary(); /*! diff --git a/Foundation/CPObject.j b/Foundation/CPObject.j index cd8ff3994..a22bbe3d3 100644 --- a/Foundation/CPObject.j +++ b/Foundation/CPObject.j @@ -61,8 +61,6 @@ CPLog(@"Got some class: %@", inst); @todo document KVC usage. */ - - @implementation CPObject { Class isa; diff --git a/Foundation/CPOperation.j b/Foundation/CPOperation.j index 1bf66426c..efe2e5d25 100644 --- a/Foundation/CPOperation.j +++ b/Foundation/CPOperation.j @@ -19,43 +19,43 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import "CPObject.j" @import "CPArray.j" +@import "CPObject.j" /*! Operations receive very low priority for execution. @global @group CPOperationQueuePriority */ -CPOperationQueuePriorityVeryLow = -8; +CPOperationQueuePriorityVeryLow = -8; /*! Operations receive low priority for execution. @global @group CPOperationQueuePriority */ -CPOperationQueuePriorityLow = -4; +CPOperationQueuePriorityLow = -4; /*! Operations receive normal priority for execution. @global @group CPOperationQueuePriority */ -CPOperationQueuePriorityNormal = 0; +CPOperationQueuePriorityNormal = 0; /*! Operations receive high priority for execution. @global @group CPOperationQueuePriority */ -CPOperationQueuePriorityHigh = 4; +CPOperationQueuePriorityHigh = 4; /*! Operations receive very high priority for execution. @global @group CPOperationQueuePriority */ -CPOperationQueuePriorityVeryHigh = 8; +CPOperationQueuePriorityVeryHigh = 8; /*! @@ -83,7 +83,9 @@ CPOperationQueuePriorityVeryHigh = 8; - (id)init { - if (self = [super init]) + self = [super init]; + + if (self) { _cancelled = NO; _executing = NO; diff --git a/Foundation/CPOperationQueue.j b/Foundation/CPOperationQueue.j index f0991b248..16eb27b7d 100644 --- a/Foundation/CPOperationQueue.j +++ b/Foundation/CPOperationQueue.j @@ -19,10 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import "CPArray.j" @import "CPFunctionOperation.j" @import "CPInvocationOperation.j" @import "CPObject.j" @import "CPOperation.j" +@import "CPString.j" @import "CPTimer.j" // the global queue (mainQueue) @@ -42,7 +44,9 @@ var cpOperationMainQueue = nil; - (id)init { - if (self = [super init]) + self = [super init]; + + if (self) { _operations = [[CPArray alloc] init]; _suspended = NO; diff --git a/Foundation/CPPropertyListSerialization.j b/Foundation/CPPropertyListSerialization.j index 4f37b3179..d3db01600 100644 --- a/Foundation/CPPropertyListSerialization.j +++ b/Foundation/CPPropertyListSerialization.j @@ -22,7 +22,6 @@ @import "CPObject.j" - CPPropertyListUnknownFormat = 0; CPPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat; CPPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0; diff --git a/Foundation/CPProxy.j b/Foundation/CPProxy.j index cbb8f0f2f..e935ad344 100644 --- a/Foundation/CPProxy.j +++ b/Foundation/CPProxy.j @@ -22,9 +22,9 @@ @import "CPException.j" @import "CPInvocation.j" +@import "CPObject.j" @import "CPString.j" - @implementation CPProxy { } diff --git a/Foundation/CPRunLoop.j b/Foundation/CPRunLoop.j index 89ad9337a..af897360d 100644 --- a/Foundation/CPRunLoop.j +++ b/Foundation/CPRunLoop.j @@ -21,6 +21,7 @@ */ @import "CPArray.j" +@import "CPDate.j" @import "CPObject.j" @import "CPString.j" diff --git a/Foundation/CPScanner.j b/Foundation/CPScanner.j index 89c6e14bf..a1976ae7c 100644 --- a/Foundation/CPScanner.j +++ b/Foundation/CPScanner.j @@ -1,11 +1,27 @@ -// CPScanner.j -// © Emanuele Vulcano, 2008. -// -// Licensed under the terms of Cappuccino's license -// (the GNU Lesser General Public License, version 2.1). -// Please see Cappuccino's LICENSE file for details. +/* + * CPScanner.j + * Foundation + * + * © Emanuele Vulcano, 2008. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ -@import +@import "CPCharacterSet.j" +@import "CPDictionary.j" +@import "CPString.j" @implementation CPScanner : CPObject { @@ -180,8 +196,8 @@ if ([self isAtEnd]) return nil; - var current = [self scanLocation]; - var str = nil; + var current = [self scanLocation], + str = nil; while (current < _string.length) { @@ -212,9 +228,9 @@ - (void)_movePastCharactersToBeSkipped { - var current = [self scanLocation]; - var string = [self string]; - var toSkip = [self charactersToBeSkipped]; + var current = [self scanLocation], + string = [self string], + toSkip = [self charactersToBeSkipped]; while (current < string.length) { @@ -258,8 +274,10 @@ - (CPString)scanUpToString:(CPString)s { - var current = [self scanLocation], str = [self string]; - var captured = nil; + var current = [self scanLocation], + str = [self string], + captured = nil; + while (current < str.length) { var currentStr = str.substr(current, s.length); @@ -291,16 +309,19 @@ - (float)scanFloat { [self _movePastCharactersToBeSkipped]; - var str = [self string], current = [self scanLocation]; + 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 !! + var s = str.substring(current, str.length), + f = parseFloat(s); // wont work with non . decimal separator !! + if (f) { - var pos, foundDash = NO; + var pos = current, + foundDash = NO; /* var decimalSeparatorString; if (_locale != nil) @@ -312,7 +333,7 @@ */ var separatorCode = 45; - for (pos = current; pos < current + str.length; pos++) + for (; pos < current + str.length; pos++) { var charCode = str.charCodeAt(pos); if (charCode == separatorCode) @@ -335,17 +356,21 @@ - (int)scanInt { [self _movePastCharactersToBeSkipped]; - var str = [self string], current = [self scanLocation]; + var str = [self string], + current = [self scanLocation]; if ([self isAtEnd]) return 0; - var s = str.substring(current, str.length); - var i = parseInt(s); + var s = str.substring(current, str.length), + i = parseInt(s); + if (i) { - var pos, foundDash = NO; - for (pos = current; pos < current + str.length; pos++) + var pos = current, + foundDash = NO; + + for (; pos < current + str.length; pos++) { var charCode = str.charCodeAt(pos); if (charCode == 46) @@ -384,9 +409,9 @@ /* = Debug = */ /* ========= */ -- (void) description +- (void)description { return [super description] + " {" + CPStringFromClass([self class]) + ", state = '" + ([self string].substr(0, _scanLocation) + "{{ SCAN LOCATION ->}}" + [self string].substr(_scanLocation)) + "'; }"; } -@end \ No newline at end of file +@end