diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index b10d40fe7..e95225562 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -172,7 +172,7 @@ var bottomHeight = 71; BOOL _needsLayout; } -#pragma mark Creating Alerts +// MARK: Creating Alerts /*! Returns a CPAlert object with the provided info @@ -249,8 +249,8 @@ var bottomHeight = 71; } -#pragma mark - -#pragma mark Delegate +// MARK: - +// MARK: Delegate /*! Set the delegate of the receiver @@ -272,7 +272,7 @@ var bottomHeight = 71; } -#pragma mark Accessors +// MARK: Accessors - (CPTheme)theme { @@ -402,7 +402,7 @@ var bottomHeight = 71; _needsLayout = YES; } -#pragma mark Accessing Buttons +// MARK: Accessing Buttons /*! Adds a button with a given title to the receiver. @@ -443,7 +443,7 @@ var bottomHeight = 71; [_buttons insertObject:button atIndex:0]; } -#pragma mark Layout +// MARK: Layout /*! @ignore @@ -708,7 +708,7 @@ var bottomHeight = 71; _needsLayout = NO; } -#pragma mark Displaying Alerts +// MARK: Displaying Alerts /*! Displays the \c CPAlert panel as a modal dialog. The user will not be @@ -786,7 +786,7 @@ var bottomHeight = 71; [self beginSheetModalForWindow:aWindow modalDelegate:nil didEndSelector:nil contextInfo:nil]; } -#pragma mark Private +// MARK: Private /*! @ignore diff --git a/AppKit/CPAppearance.j b/AppKit/CPAppearance.j index e80c20a4a..d0dcc9ce0 100644 --- a/AppKit/CPAppearance.j +++ b/AppKit/CPAppearance.j @@ -63,8 +63,8 @@ CPThemeStateAppearanceVibrantDark = CPThemeState("appearance-vibrant-dark") } -#pragma mark - -#pragma mark Class Methods +// MARK: - +// MARK: Class Methods /*! Returns the current default CPAppearance */ @@ -99,8 +99,8 @@ CPThemeStateAppearanceVibrantDark = CPThemeState("appearance-vibrant-dark") } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Creates a CPAppearance object initialized to the specified appearance file in the specified bundle This method does actually nothing special. It just creates a default appearance object @@ -122,8 +122,8 @@ CPThemeStateAppearanceVibrantDark = CPThemeState("appearance-vibrant-dark") } -#pragma mark - -#pragma mark Implementation +// MARK: - +// MARK: Implementation - (BOOL)isEqual:(id)anObject { @@ -139,8 +139,8 @@ CPThemeStateAppearanceVibrantDark = CPThemeState("appearance-vibrant-dark") } -#pragma mark - -#pragma mark CPCoding +// MARK: - +// MARK: CPCoding - (id)initWithCoder:(CPCoder)aCoder { @@ -159,4 +159,4 @@ CPThemeStateAppearanceVibrantDark = CPThemeState("appearance-vibrant-dark") [aCoder encodeBool:_allowsVibrancy forKey:@"_allowsVibrancy"]; } -@end \ No newline at end of file +@end diff --git a/AppKit/CPBox.j b/AppKit/CPBox.j index 799580a50..7e8b1727c 100644 --- a/AppKit/CPBox.j +++ b/AppKit/CPBox.j @@ -264,8 +264,8 @@ CPBelowBottom = 6; [self _manageTitlePositioning]; } -#pragma mark - -#pragma mark Style properties which override theme values +// MARK: - +// MARK: Style properties which override theme values /*! The borderColor, borderWidth, cornerRadius and fillColor properties for the receiver are only supported for boxes with boxType === CPBoxCustom and borderType === CPLineBorder. @@ -282,7 +282,7 @@ CPBelowBottom = 6; */ // See discussion above. -#pragma mark borderColor +// MARK: borderColor - (CPColor)borderColor { return [self currentValueForThemeAttribute:@"border-color"]; @@ -308,7 +308,7 @@ CPBelowBottom = 6; } // See discussion above. -#pragma mark borderWidth +// MARK: borderWidth - (float)borderWidth { return [self valueForThemeAttribute:@"border-width"]; @@ -334,7 +334,7 @@ CPBelowBottom = 6; } // See discussion above. -#pragma mark cornerRadius +// MARK: cornerRadius - (float)cornerRadius { return [self valueForThemeAttribute:@"corner-radius"]; @@ -360,7 +360,7 @@ CPBelowBottom = 6; } // See discussion above. -#pragma mark fillColor +// MARK: fillColor - (CPColor)fillColor { return [self valueForThemeAttribute:@"background-color"]; @@ -761,7 +761,7 @@ CPBelowBottom = 6; @end -#pragma mark - +// MARK: - @implementation CPBox (CSSTheming) @@ -829,7 +829,7 @@ CPBelowBottom = 6; @end -#pragma mark - +// MARK: - var CPBoxTypeKey = @"CPBoxTypeKey", CPBoxBorderTypeKey = @"CPBoxBorderTypeKey", diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index a21baed43..0d043ef6e 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -221,8 +221,8 @@ CPButtonImageOffset = 3.0; [self setButtonType:CPMomentaryPushInButton]; } -#pragma mark - -#pragma mark Control Size +// MARK: - +// MARK: Control Size - (void)setControlSize:(CPControlSize)aControlSize { @@ -233,7 +233,7 @@ CPButtonImageOffset = 3.0; } -#pragma mark - +// MARK: - // Setting the state /*! diff --git a/AppKit/CPCheckBox.j b/AppKit/CPCheckBox.j index ecc99bb06..90d24f92b 100644 --- a/AppKit/CPCheckBox.j +++ b/AppKit/CPCheckBox.j @@ -95,8 +95,8 @@ CPCheckBoxImageOffset = 4.0; } -#pragma mark - -#pragma mark Override methods from CPButton +// MARK: - +// MARK: Override methods from CPButton - (CGSize)_minimumFrameSize { @@ -177,7 +177,7 @@ CPCheckBoxImageOffset = 4.0; @end -#pragma mark - +// MARK: - @implementation CPCheckBox (TableDataView) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 076e76d1d..1d89aefcf 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -202,8 +202,8 @@ var HORIZONTAL_MARGIN = 2; -#pragma mark - -#pragma mark Delegate +// MARK: - +// MARK: Delegate /*! Set the delegate of the receiver diff --git a/AppKit/CPColor.j b/AppKit/CPColor.j index 99f7027f9..1d1199350 100644 --- a/AppKit/CPColor.j +++ b/AppKit/CPColor.j @@ -89,8 +89,8 @@ var cachedBlackColor, } @global document -#pragma mark - -#pragma mark Theming +// MARK: - +// MARK: Theming + (CPString)defaultThemeClass { @@ -109,8 +109,8 @@ var cachedBlackColor, } -#pragma mark - -#pragma mark Static methods +// MARK: - +// MARK: Static methods /*! Creates a color in the RGB colorspace, with an alpha value. @@ -884,8 +884,8 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image @end -#pragma mark - -#pragma mark CSS Theming +// MARK: - +// MARK: CSS Theming // The code below adds support for CSS theming with 100% compatibility with current theming system. // The idea is to extend CPColor (and CPImage) with CSS components and adapt low level UI components to @@ -1091,7 +1091,7 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image @end -#pragma mark - +// MARK: - /// @cond IGNORE var CPColorComponentsKey = @"CPColorComponentsKey", diff --git a/AppKit/CPColorWell.j b/AppKit/CPColorWell.j index 9f3131f5c..5c7362b08 100644 --- a/AppKit/CPColorWell.j +++ b/AppKit/CPColorWell.j @@ -123,8 +123,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv return self; } -#pragma mark - -#pragma mark Draw +// MARK: - +// MARK: Draw /*! Sets whether the color well is bordered. @@ -145,8 +145,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv return [self hasThemeState:CPThemeStateBordered]; } -#pragma mark - -#pragma mark Managing Color +// MARK: - +// MARK: Managing Color /*! Returns the color well's current color. @@ -199,8 +199,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv } } -#pragma mark - -#pragma mark Activating and Deactivating +// MARK: - +// MARK: Activating and Deactivating /*! Activates the color well, displays the color panel, and makes the panel's current color the same as its own. @@ -241,8 +241,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv return YES; } -#pragma mark - -#pragma mark Event Handling +// MARK: - +// MARK: Event Handling - (void)mouseDown:(CPEvent)anEvent { @@ -289,8 +289,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv } -#pragma mark - -#pragma mark Drag and Drop +// MARK: - +// MARK: Drag and Drop - (void)draggingEntered:(id)sender { @@ -346,8 +346,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv return CPDragOperationCopy; } -#pragma mark - -#pragma mark Layout +// MARK: - +// MARK: Layout - (CGRect)contentRectForBounds:(CGRect)bounds { diff --git a/AppKit/CPComboBox.j b/AppKit/CPComboBox.j index d5305b606..2c31d7cc9 100644 --- a/AppKit/CPComboBox.j +++ b/AppKit/CPComboBox.j @@ -133,7 +133,7 @@ var CPComboBoxTextSubview = @"text", [self setThemeState:CPComboBoxStateButtonBordered]; } -#pragma mark Setting Display Attributes +// MARK: Setting Display Attributes - (BOOL)hasVerticalScroller { @@ -214,7 +214,7 @@ var CPComboBoxTextSubview = @"text", _numberOfVisibleItems = MAX(visibleItems, 1); } -#pragma mark Setting a Delegate +// MARK: Setting a Delegate - (id )delegate { @@ -254,7 +254,7 @@ var CPComboBoxTextSubview = @"text", [super setDelegate:aDelegate]; } -#pragma mark Setting a Data Source +// MARK: Setting a Data Source - (id )dataSource { @@ -305,7 +305,7 @@ var CPComboBoxTextSubview = @"text", [self reloadData]; } -#pragma mark Working with an Internal List +// MARK: Working with an Internal List - (void)addItemsWithObjectValues:(CPArray)objects { @@ -378,7 +378,7 @@ var CPComboBoxTextSubview = @"text", return _items.length; } -#pragma mark Manipulating the Displayed List +// MARK: Manipulating the Displayed List /*! Returns the delegate to be used when creating the pop up list. @@ -601,7 +601,7 @@ var CPComboBoxTextSubview = @"text", [self sendAction:[self action] to:[self target]]; } -#pragma mark Manipulating the Selection +// MARK: Manipulating the Selection - (void)deselectItemAtIndex:(int)index { @@ -653,7 +653,7 @@ var CPComboBoxTextSubview = @"text", [self selectItemAtIndex:index]; } -#pragma mark Completing the Text Field +// MARK: Completing the Text Field - (BOOL)completes { @@ -700,7 +700,7 @@ var CPComboBoxTextSubview = @"text", _forceSelection = !!flag; } -#pragma mark CPTextField Delegate Methods and Overrides +// MARK: CPTextField Delegate Methods and Overrides /*! @ignore */ - (BOOL)sendAction:(SEL)anAction to:(id)anObject @@ -900,7 +900,7 @@ var CPComboBoxTextSubview = @"text", [_listDelegate setAlignment:alignment]; } -#pragma mark Pop Up Button Layout +// MARK: Pop Up Button Layout - (CGRect)popupButtonRectForBounds:(CGRect)bounds { @@ -945,7 +945,7 @@ var CPComboBoxTextSubview = @"text", relativeToEphemeralSubviewNamed:@"content-view"]; } -#pragma mark Internal Helpers +// MARK: Internal Helpers /*! @ignore */ - (void)_dataSourceWarningForMethod:(SEL)cmd condition:(CPString)flag @@ -1006,8 +1006,8 @@ var CPComboBoxTextSubview = @"text", } -#pragma mark - -#pragma mark Observers method +// MARK: - +// MARK: Observers method - (void)_addObservers { diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 4fa5cebb5..1dec17504 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -208,8 +208,8 @@ var CPControlBlackColor = [CPColor blackColor]; return self; } -#pragma mark - -#pragma mark Control Size +// MARK: - +// MARK: Control Size /*! Returns the control's control size @@ -290,7 +290,7 @@ var CPControlBlackColor = [CPColor blackColor]; } -#pragma mark - +// MARK: - /*! Sets the receiver's target action. @@ -1027,8 +1027,8 @@ var CPControlBlackColor = [CPColor blackColor]; } -#pragma mark - -#pragma mark Base writing direction +// MARK: - +// MARK: Base writing direction /*! Sets the initial writing direction of the receiver diff --git a/AppKit/CPDatePicker/CPDatePicker.j b/AppKit/CPDatePicker/CPDatePicker.j index 7fb715b9c..1cf4ca6cf 100644 --- a/AppKit/CPDatePicker/CPDatePicker.j +++ b/AppKit/CPDatePicker/CPDatePicker.j @@ -82,8 +82,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark Theme methods +// MARK: - +// MARK: Theme methods + (CPString)defaultThemeClass { @@ -174,8 +174,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark Binding methods +// MARK: - +// MARK: Binding methods + (Class)_binderClassForBinding:(CPString)theBinding { @@ -200,8 +200,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)initWithFrame:(CGRect)aFrame { @@ -271,8 +271,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark Control Size +// MARK: - +// MARK: Control Size - (void)setControlSize:(CPControlSize)aControlSize { @@ -285,8 +285,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark Delegate methods +// MARK: - +// MARK: Delegate methods /*! Set the delegate of the datePicker @param aDelegate delegate of the datePicker @@ -302,8 +302,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark Layout method +// MARK: - +// MARK: Layout method /*! Layout the subviews */ @@ -313,8 +313,8 @@ CPEraDatePickerElementFlag = 0x0100; [_datePickerComponent setNeedsDisplay:YES]; } -#pragma mark - -#pragma mark Setter +// MARK: - +// MARK: Setter /*! Return the objectValue of the datePicker. The objectValue should take the timeZoneEffect */ @@ -651,8 +651,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark First responder methods +// MARK: - +// MARK: First responder methods /*! Return YES if style is set to CPTextFieldAndStepperDatePickerStyle or CPTextFieldDatePickerStyle */ @@ -689,8 +689,8 @@ CPEraDatePickerElementFlag = 0x0100; } -#pragma mark - -#pragma mark getter +// MARK: - +// MARK: getter /*! Returns \c YES if the textfield is bezeled. @@ -723,8 +723,8 @@ CPEraDatePickerElementFlag = 0x0100; return [[_locale objectForKey:CPLocaleCountryCode] isEqualToString:@"US"]; } -#pragma mark - -#pragma mark Key event +// MARK: - +// MARK: Key event /*! Key down event @param anEvent diff --git a/AppKit/CPDatePicker/_CPDatePickerCalendar.j b/AppKit/CPDatePicker/_CPDatePickerCalendar.j index 101185add..6480f60ae 100644 --- a/AppKit/CPDatePicker/_CPDatePickerCalendar.j +++ b/AppKit/CPDatePicker/_CPDatePickerCalendar.j @@ -52,7 +52,7 @@ } -#pragma mark Init method +// MARK: Init method /*! Init a _CPDatePickerCalendar @param aFrame @@ -111,8 +111,8 @@ } -#pragma mark - -#pragma mark Responder methods +// MARK: - +// MARK: Responder methods - (BOOL)acceptsFirstResponder { @@ -120,8 +120,8 @@ } -#pragma mark - -#pragma mark Getter Setter methods +// MARK: - +// MARK: Getter Setter methods /*! Set the date value of the component. It sets the dateValue of the header and the monthView also @param aDateValue @@ -160,8 +160,8 @@ [self _init]; } -#pragma mark - -#pragma mark Layout methods +// MARK: - +// MARK: Layout methods /*! Manager the subviews. It hides or not the clock. */ @@ -221,8 +221,8 @@ } -#pragma mark - -#pragma mark Action methods +// MARK: - +// MARK: Action methods /*! Move to the nextMonth without changing the dateValue of the datePicker */ diff --git a/AppKit/CPDatePicker/_CPDatePickerClock.j b/AppKit/CPDatePicker/_CPDatePickerClock.j index 87a0e60a0..a756209e9 100644 --- a/AppKit/CPDatePicker/_CPDatePickerClock.j +++ b/AppKit/CPDatePicker/_CPDatePickerClock.j @@ -76,8 +76,8 @@ _CPDatePickerClockSeconds = 3; CPInteger _datePickerElements @accessors(getter=datePickerElements); } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)initWithFrame:(CGRect)aFrame datePicker:(CPDatePicker)aDatePicker { @@ -186,7 +186,7 @@ _CPDatePickerClockSeconds = 3; [_secondHandView setHidden:!((_datePickerElements & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)]; } -#pragma mark Layout methods +// MARK: Layout methods - (void)layoutSubviews { @@ -267,7 +267,7 @@ _CPDatePickerClockSeconds = 3; [self _rotateView:_secondHandView byAngle:_secondAngle]; } -#pragma mark Accessors +// MARK: Accessors - (void)setEnabled:(BOOL)shouldEnable { @@ -281,7 +281,7 @@ _CPDatePickerClockSeconds = 3; [self setNeedsLayout]; } -#pragma mark Mouse actions +// MARK: Mouse actions // Since we rotate using Pure CSS, Cappuccino's `convertPoint:` doesn't know about it. // So we use standard Trigonometry to perfectly hit-test the rotated hands! diff --git a/AppKit/CPDatePicker/_CPDatePickerDayView.j b/AppKit/CPDatePicker/_CPDatePickerDayView.j index bc8cf73ce..4ba8744f2 100644 --- a/AppKit/CPDatePicker/_CPDatePickerDayView.j +++ b/AppKit/CPDatePicker/_CPDatePickerDayView.j @@ -41,7 +41,7 @@ } -#pragma mark Init methods +// MARK: Init methods /*! Create a new instance of _CPDatePickerDayView @param aFrame @@ -123,8 +123,8 @@ } -#pragma mark - -#pragma mark Theme methods +// MARK: - +// MARK: Theme methods /*! Set a theme */ @@ -143,8 +143,8 @@ } -#pragma mark - -#pragma mark Getter methods +// MARK: - +// MARK: Getter methods /*! Select the tile */ @@ -205,8 +205,8 @@ } -#pragma mark - -#pragma mark Layout methods +// MARK: - +// MARK: Layout methods /*! Layout the subviews */ diff --git a/AppKit/CPDatePicker/_CPDatePickerElementTextField.j b/AppKit/CPDatePicker/_CPDatePickerElementTextField.j index f24d0d15d..49bacb985 100644 --- a/AppKit/CPDatePicker/_CPDatePickerElementTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerElementTextField.j @@ -481,8 +481,8 @@ CPAMPMDateType = 6; } -#pragma mark - -#pragma mark Mouse event +// MARK: - +// MARK: Mouse event /*! Mouse down event. Launch a notification to notif the new first responder textField */ @@ -496,8 +496,8 @@ CPAMPMDateType = 6; } -#pragma mark - -#pragma mark Theme functions +// MARK: - +// MARK: Theme functions /*! Set the theme CPThemeStateSelected */ @@ -517,8 +517,8 @@ CPAMPMDateType = 6; } -#pragma mark - -#pragma mark Override +// MARK: - +// MARK: Override /*! We override this method to get all the time the good width @@ -584,7 +584,7 @@ CPAMPMDateType = 6; @end -#pragma mark - +// MARK: - @implementation _CPDatePickerElementSeparator : CPTextField diff --git a/AppKit/CPDatePicker/_CPDatePickerElementView.j b/AppKit/CPDatePicker/_CPDatePickerElementView.j index ce4c8702b..d6339d43f 100644 --- a/AppKit/CPDatePicker/_CPDatePickerElementView.j +++ b/AppKit/CPDatePicker/_CPDatePickerElementView.j @@ -50,7 +50,7 @@ } -#pragma mark Init +// MARK: Init - (id)initWithFrame:(CGRect)aFrame withDatePicker:(CPDatePicker)aDatePicker { @@ -141,8 +141,8 @@ } -#pragma mark - -#pragma mark Responder methods +// MARK: - +// MARK: Responder methods /*! @ignore */ - (BOOL)acceptsFirstResponder @@ -154,8 +154,8 @@ } -#pragma mark - -#pragma mark Override observers +// MARK: - +// MARK: Override observers - (void)_removeObservers { @@ -177,8 +177,8 @@ [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldAMPMChangedNotification:) name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM]; } -#pragma mark - -#pragma mark Mouse event +// MARK: - +// MARK: Mouse event - (BOOL)continueTracking:(CGPoint)lastPoint at:(CGPoint)aPoint { @@ -229,8 +229,8 @@ return nil; } -#pragma mark - -#pragma mark Setter Getter methods +// MARK: - +// MARK: Setter Getter methods /*! Set the value of the textFields @param aDateValue the value @@ -378,8 +378,8 @@ } -#pragma mark - -#pragma mark Notification methods +// MARK: - +// MARK: Notification methods /*! Called when changing AM or PM @param aNotification @@ -413,8 +413,8 @@ } -#pragma mark - -#pragma mark Layout methods +// MARK: - +// MARK: Layout methods - (CGRect)rectForEphemeralSubviewNamed:(CPString)aName { @@ -886,8 +886,8 @@ } -#pragma mark - -#pragma mark Responder methods +// MARK: - +// MARK: Responder methods - (void)_updateResponderTextField { diff --git a/AppKit/CPDatePicker/_CPDatePickerHeaderView.j b/AppKit/CPDatePicker/_CPDatePickerHeaderView.j index 816120e1f..be8670ec3 100644 --- a/AppKit/CPDatePicker/_CPDatePickerHeaderView.j +++ b/AppKit/CPDatePicker/_CPDatePickerHeaderView.j @@ -50,7 +50,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su" } -#pragma mark Init methods +// MARK: Init methods /*! Init a new instance of _CPDatePickerHeaderView @param aFrame @@ -153,8 +153,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su" } -#pragma mark - -#pragma mark Getter Setter methods +// MARK: - +// MARK: Getter Setter methods /*! Return the day names depending on the CPLocale of the datePicker @return an array @@ -242,8 +242,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su" } -#pragma mark - -#pragma mark Layout methods +// MARK: - +// MARK: Layout methods /*! Layout the subviews */ diff --git a/AppKit/CPDatePicker/_CPDatePickerMonthView.j b/AppKit/CPDatePicker/_CPDatePickerMonthView.j index 9a09b06f9..f1d4470e4 100644 --- a/AppKit/CPDatePicker/_CPDatePickerMonthView.j +++ b/AppKit/CPDatePicker/_CPDatePickerMonthView.j @@ -46,7 +46,7 @@ } -#pragma mark Init methods +// MARK: Init methods /*! Init a _CPDatePickerMonthView @param aFrame @@ -77,8 +77,8 @@ } -#pragma mark - -#pragma mark Getter Setter methods +// MARK: - +// MARK: Getter Setter methods /*! Set the monthDate of the component @param aDate @@ -194,8 +194,8 @@ return tileIndex; } -#pragma mark - -#pragma mark Reload data +// MARK: - +// MARK: Reload data /*! Reload the data */ @@ -235,8 +235,8 @@ } -#pragma mark - -#pragma mark Select methods +// MARK: - +// MARK: Select methods /*! Select one date or several date depending of the giving interval @param aStartDate @@ -297,8 +297,8 @@ } } -#pragma mark - -#pragma mark Layout methods +// MARK: - +// MARK: Layout methods /*! Tile the view */ @@ -438,8 +438,8 @@ } -#pragma mark - -#pragma mark Mouse event +// MARK: - +// MARK: Mouse event /*! Mouse down event */ @@ -596,8 +596,8 @@ } -#pragma mark - -#pragma mark Timer +// MARK: - +// MARK: Timer - (void)_timerNextMonthEvent:(CPEvent)anEvent { @@ -618,8 +618,8 @@ } -#pragma mark - -#pragma mark Date methods +// MARK: - +// MARK: Date methods - (CPDate)_hoursMinutesSecondsFromDatePickerForDate:(CPDate)aDate { diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index 2fc284b3d..cbeda2865 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -62,7 +62,7 @@ } -#pragma mark Init +// MARK: Init - (id)initWithFrame:(CGRect)aFrame withDatePicker:(CPDatePicker)aDatePicker { @@ -103,8 +103,8 @@ } -#pragma mark - -#pragma mark Override responder methods +// MARK: - +// MARK: Override responder methods - (BOOL)becomeFirstResponder { @@ -138,8 +138,8 @@ } -#pragma mark - -#pragma mark Setter Getter methods +// MARK: - +// MARK: Setter Getter methods /*! Set the value of the control @param aDateValue @@ -188,8 +188,8 @@ [self setNeedsLayout]; } -#pragma mark - -#pragma mark Notification methods +// MARK: - +// MARK: Notification methods /*! This is called to when the user just changed the selected textField @param aNotification @@ -207,8 +207,8 @@ } -#pragma mark - -#pragma mark SelectTextField action +// MARK: - +// MARK: SelectTextField action - (void)_selectTextFieldWithFlags:(unsigned)flags { @@ -273,8 +273,8 @@ } -#pragma mark - -#pragma mark Events +// MARK: - +// MARK: Events /*! Called when the user click on the stepper */ @@ -557,8 +557,8 @@ } -#pragma mark - -#pragma mark Layout methods +// MARK: - +// MARK: Layout methods /*! Layout the subviews */ @@ -607,8 +607,8 @@ } -#pragma mark - -#pragma mark Override observers +// MARK: - +// MARK: Override observers - (void)_removeObservers { diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index fc32f5ebf..3ee6bfeaa 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -517,8 +517,8 @@ function CPAppKitImage(aFilename, aSize) @end -#pragma mark - -#pragma mark CSS Theming +// MARK: - +// MARK: CSS Theming // The code below adds support for CSS theming with 100% compatibility with current theming system. // The idea is to extend CPImage (and CPColor) with CSS components and adapt low level UI components to @@ -738,7 +738,7 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey", CPImageCSSBeforeDictionaryKey = @"CPImageCSSBeforeDictionaryKey", CPImageCSSAfterDictionaryKey = @"CPImageCSSAfterDictionaryKey"; -#pragma mark - +// MARK: - @implementation CPImage (CPCoding) @@ -775,8 +775,8 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey", @end -#pragma mark - -#pragma mark Drawing +// MARK: - +// MARK: Drawing @implementation CPImage (Drawing) @@ -813,7 +813,7 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey", @end -#pragma mark - +// MARK: - @implementation _CPMaterialIconImage : CPImage { @@ -973,7 +973,7 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey", @end -#pragma mark - +// MARK: - @implementation CPThreePartImage : CPObject { @@ -1116,7 +1116,7 @@ var CPNinePartImageImageSlicesKey = @"CPNinePartImageImageSlicesKey"; @end -#pragma mark - +// MARK: - @implementation CPImage (Duplication) diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j index 0c3014819..9700956a2 100644 --- a/AppKit/CPMenu/CPMenu.j +++ b/AppKit/CPMenu/CPMenu.j @@ -1400,7 +1400,7 @@ var CPMenuTitleKey = @"CPMenuTitleKey", @end -#pragma mark - +// MARK: - @implementation CPMenu (CSSTheming) diff --git a/AppKit/CPMenu/_CPMenuWindow.j b/AppKit/CPMenu/_CPMenuWindow.j index 6ea55f012..d7f1fbd98 100644 --- a/AppKit/CPMenu/_CPMenuWindow.j +++ b/AppKit/CPMenu/_CPMenuWindow.j @@ -465,7 +465,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2; @end -#pragma mark - +// MARK: - @implementation _CPMenuWindow (CSSTheming) @@ -478,7 +478,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2; @end -#pragma mark - +// MARK: - /* @ignore @@ -664,7 +664,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2; @end -#pragma mark - +// MARK: - @implementation _CPMenuView (CSSTheming) diff --git a/AppKit/CPMenuItem/CPMenuItem.j b/AppKit/CPMenuItem/CPMenuItem.j index d7933f4a4..1a25128bd 100644 --- a/AppKit/CPMenuItem/CPMenuItem.j +++ b/AppKit/CPMenuItem/CPMenuItem.j @@ -826,7 +826,7 @@ CPControlKeyMask return [[self menu] highlightedItem] == self; } -#pragma mark CPObject Overrides +// MARK: CPObject Overrides /*! Returns a copy of the item. The copy does not belong If the item has a submenu, it is NOT copied. @@ -867,7 +867,7 @@ CPControlKeyMask return [self copy]; } -#pragma mark Internal +// MARK: Internal /* @ignore @@ -897,7 +897,7 @@ CPControlKeyMask @end -#pragma mark - +// MARK: - @implementation CPMenuItem (CSSTheming) @@ -909,7 +909,7 @@ CPControlKeyMask @end -#pragma mark - +// MARK: - var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey", diff --git a/AppKit/CPMenuItem/_CPMenuItemStandardView.j b/AppKit/CPMenuItem/_CPMenuItemStandardView.j index 83affa8ac..5c9558427 100644 --- a/AppKit/CPMenuItem/_CPMenuItemStandardView.j +++ b/AppKit/CPMenuItem/_CPMenuItemStandardView.j @@ -436,11 +436,11 @@ @end -#pragma mark - +// MARK: - @implementation _CPMenuItemStandardView (CSSTheming) -#pragma mark Override +// MARK: Override - (void)_setThemeIncludingDescendants:(CPTheme)aTheme { @@ -450,7 +450,7 @@ @end -#pragma mark - +// MARK: - @implementation _CPMenuItemSubmenuIndicatorView : CPView { diff --git a/AppKit/CPMenuItem/_CPMenuItemView.j b/AppKit/CPMenuItem/_CPMenuItemView.j index 3e0926c43..4312bdb4a 100644 --- a/AppKit/CPMenuItem/_CPMenuItemView.j +++ b/AppKit/CPMenuItem/_CPMenuItemView.j @@ -274,11 +274,11 @@ @end -#pragma mark - +// MARK: - @implementation _CPMenuItemView (CSSTheming) -#pragma mark Override +// MARK: Override - (void)_setThemeIncludingDescendants:(CPTheme)aTheme { @@ -297,7 +297,7 @@ @end -#pragma mark - +// MARK: - @implementation _CPMenuItemArrowView : CPView { diff --git a/AppKit/CPPanel.j b/AppKit/CPPanel.j index c6292c475..6f5293c67 100644 --- a/AppKit/CPPanel.j +++ b/AppKit/CPPanel.j @@ -121,8 +121,8 @@ CPDocModalWindowMask = 1 << 6; } -#pragma mark - -#pragma mark Overrides +// MARK: - +// MARK: Overrides /*! @ignore diff --git a/AppKit/CPPopover.j b/AppKit/CPPopover.j index 38ef4dd23..e745cc6a1 100644 --- a/AppKit/CPPopover.j +++ b/AppKit/CPPopover.j @@ -84,8 +84,8 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0, } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Initialize the CPPopover witn default values @@ -105,8 +105,8 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0, } -#pragma mark - -#pragma mark Getters / Setters +// MARK: - +// MARK: Getters / Setters /*! Returns the current rect of the popover @@ -220,8 +220,8 @@ Set the behavior of the CPPopover. It can be: _implementedDelegateMethods |= CPPopoverDelegate_popover_didClose_; } -#pragma mark - -#pragma mark Positioning +// MARK: - +// MARK: Positioning /*! Show the popover @@ -298,8 +298,8 @@ Set the behavior of the CPPopover. It can be: } -#pragma mark - -#pragma mark Action +// MARK: - +// MARK: Action /*! Close the popover @@ -318,8 +318,8 @@ Set the behavior of the CPPopover. It can be: } -#pragma mark - -#pragma mark Delegates +// MARK: - +// MARK: Delegates /*! @ignore */ - (BOOL)_popoverWindowShouldClose diff --git a/AppKit/CPRadio.j b/AppKit/CPRadio.j index 93442aacf..87d552faf 100644 --- a/AppKit/CPRadio.j +++ b/AppKit/CPRadio.j @@ -187,7 +187,7 @@ CPRadioImageOffset = 4.0; [self _setRadioGroup]; } -#pragma mark Private methods +// MARK: Private methods - (void)_setRadioGroup { @@ -260,8 +260,8 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey"; [aCoder encodeObject:_radioGroup forKey:CPRadioRadioGroupKey]; } -#pragma mark - -#pragma mark Override methods from CPButton +// MARK: - +// MARK: Override methods from CPButton - (CPThemeState)_contentVisualState { @@ -412,7 +412,7 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey"; [_radios makeObjectsPerformSelector:@selector(setHidden:) withObject:hidden]; } -#pragma mark Private +// MARK: Private - (void)_addRadio:(CPRadio)aRadio { diff --git a/AppKit/CPRuleEditor/CPPredicateEditor.j b/AppKit/CPRuleEditor/CPPredicateEditor.j index 5076b7ddc..314723bce 100644 --- a/AppKit/CPRuleEditor/CPPredicateEditor.j +++ b/AppKit/CPRuleEditor/CPPredicateEditor.j @@ -34,7 +34,7 @@ SEL _predicateAction @accessors(property=action); } -#pragma mark public methods +// MARK: public methods /*! @ingroup appkit @class CPPredicateEditor @@ -251,7 +251,7 @@ return tree; } -#pragma mark Set the Predicate +// MARK: Set the Predicate - (void)setObjectValue:(id)objectValue { @@ -374,7 +374,7 @@ return row; } -#pragma mark Get the predicate +// MARK: Get the predicate - (void)_updatePredicate { @@ -452,7 +452,7 @@ return CPAndPredicateType; } -#pragma mark Control delegate +// MARK: Control delegate - (void)_sendRuleAction { @@ -487,7 +487,7 @@ } */ -#pragma mark RuleEditor delegate methods +// MARK: RuleEditor delegate methods - (int)_queryNumberOfChildrenOfItem:(id)rowItem withRowType:(CPRuleEditorRowType)type { diff --git a/AppKit/CPRuleEditor/CPRuleEditor.j b/AppKit/CPRuleEditor/CPRuleEditor.j index 78e301614..38cb4e7e4 100644 --- a/AppKit/CPRuleEditor/CPRuleEditor.j +++ b/AppKit/CPRuleEditor/CPRuleEditor.j @@ -1304,7 +1304,7 @@ TODO: implement return shouldHide; } -#pragma mark Rows management +// MARK: Rows management - (id)_rowCacheForIndex:(int)index { @@ -1566,7 +1566,7 @@ TODO: implement return row; } -#pragma mark Key value observing +// MARK: Key value observing - (void)_startObservingRowObjectsRecursively:(CPArray)rowObjects { @@ -2354,33 +2354,41 @@ TODO: implement - (BOOL)performDragOperation:(id /*< CPDraggingInfo >*/)info { - var aboveInsertIndexCount = 0, - object, - removeIndex; + var object; var rowObjects = [_rowCache valueForKey:@"rowObject"], index = [_draggingRows lastIndex]; - var parentRowIndex = [self parentRowForRow:index], // first index of draggingrows + var firstDraggingIndex = [_draggingRows firstIndex], + parentRowIndex = [self parentRowForRow:firstDraggingIndex], parentRowObject = (parentRowIndex === -1) ? _boundArrayOwner : [[self _rowCacheForIndex:parentRowIndex] rowObject], insertIndex = _subviewIndexOfDropLine; while (index !== CPNotFound) { - if (index >= insertIndex) + // Identify if this row's parent is also inside the dragging set. + // If it is, we skip it because it will move automatically with its parent. + var parentOfCurrent = [self parentRowForRow:index]; + if (parentOfCurrent !== -1 && [_draggingRows containsIndex:parentOfCurrent]) { - removeIndex = index + aboveInsertIndexCount; - aboveInsertIndexCount += 1; - } - else - { - removeIndex = index; - insertIndex -= 1; + index = [_draggingRows indexLessThanIndex:index]; + continue; } - object = [rowObjects objectAtIndex:removeIndex]; - [self removeRowAtIndex:removeIndex]; - [[self _subrowObjectsOfObject:parentRowObject] insertObject:object atIndex:insertIndex - parentRowIndex - 1]; + object = [rowObjects objectAtIndex:index]; + + // Find the current live index of the object inside the editor + var cache = [self _searchCacheForRowObject:object]; + var liveIndex = [_rowCache indexOfObjectIdenticalTo:cache]; + + if (liveIndex !== CPNotFound) + { + if (liveIndex < insertIndex) + insertIndex -= 1; + + [self removeRowAtIndex:liveIndex]; + [[self _subrowObjectsOfObject:parentRowObject] insertObject:object atIndex:insertIndex - parentRowIndex - 1]; + } index = [_draggingRows indexLessThanIndex:index]; } @@ -2390,6 +2398,7 @@ TODO: implement return YES; } + - (CPIndexSet)_draggingTypes { return [CPIndexSet indexSetWithIndex:CPDragOperationMove]; diff --git a/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j b/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j index 14404e0ed..5e056b42f 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j @@ -97,7 +97,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+) return aString; } -#pragma mark - Formatting & Reordering Helpers +// MARK: - Formatting & Reordering Helpers - (CPString)_englishRepresentationForView:(id)aView { diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 9f1b9e113..7795419cd 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -159,8 +159,8 @@ var _CPScrollViews; } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods + (void)initialize { @@ -320,8 +320,8 @@ var _CPScrollViews; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization - (id)initWithFrame:(CGRect)aFrame { @@ -366,8 +366,8 @@ var _CPScrollViews; } -#pragma mark - -#pragma mark Getters / Setters +// MARK: - +// MARK: Getters / Setters /*! The delegate of the scroll view @@ -845,8 +845,8 @@ Notifies the delegate when the scroll view has finished scrolling. } -#pragma mark - -#pragma mark Rulers +// MARK: - +// MARK: Rulers - (BOOL)hasHorizontalRuler { @@ -942,8 +942,8 @@ Notifies the delegate when the scroll view has finished scrolling. } -#pragma mark - -#pragma mark Privates +// MARK: - +// MARK: Privates /* @ignore */ - (void)_updateScrollerStyle @@ -1263,8 +1263,8 @@ Notifies the delegate when the scroll view has finished scrolling. -#pragma mark - -#pragma mark Utilities +// MARK: - +// MARK: Utilities /*! Lays out the scroll view's components. @@ -1530,8 +1530,8 @@ Notifies the delegate when the scroll view has finished scrolling. return [_contentView documentVisibleRect]; } -#pragma mark - -#pragma mark Overrides +// MARK: - +// MARK: Overrides - (void)_removeObservers { @@ -1765,7 +1765,7 @@ Notifies the delegate when the scroll view has finished scrolling. @end -#pragma mark - +// MARK: - @implementation CPScrollView (CSSTheming) @@ -1840,7 +1840,7 @@ Notifies the delegate when the scroll view has finished scrolling. @end -#pragma mark - +// MARK: - var CPScrollViewContentViewKey = @"CPScrollViewContentView", CPScrollViewHeaderClipViewKey = @"CPScrollViewHeaderClipViewKey", diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j index 9b7271844..edc501e4d 100644 --- a/AppKit/CPScroller.j +++ b/AppKit/CPScroller.j @@ -102,8 +102,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods + (CPString)defaultThemeClass { @@ -167,8 +167,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization - (id)initWithFrame:(CGRect)aFrame { @@ -203,8 +203,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Getters / Setters +// MARK: - +// MARK: Getters / Setters /*! Returns the scroller's style @@ -269,8 +269,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Privates +// MARK: - +// MARK: Privates /*! @ignore */ - (void)_adjustScrollerSize @@ -295,8 +295,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Utilities +// MARK: - +// MARK: Utilities - (CGRect)rectForPart:(CPScrollerPart)aPart { @@ -486,8 +486,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Drawing +// MARK: - +// MARK: Drawing /*! Draws the specified arrow and sets the highlight. @@ -721,8 +721,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); } -#pragma mark - -#pragma mark Overrides +// MARK: - +// MARK: Overrides - (id)currentValueForThemeAttribute:(CPString)anAttributeName { @@ -798,8 +798,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark"); return [self currentValueForThemeAttribute:@"scroller-width"]; } -#pragma mark - -#pragma mark Delegates +// MARK: - +// MARK: Delegates - (void)animationDidEnd:(CPAnimation)animation { diff --git a/AppKit/CPSearchField.j b/AppKit/CPSearchField.j index 8270cc76c..b8b091fe5 100644 --- a/AppKit/CPSearchField.j +++ b/AppKit/CPSearchField.j @@ -143,8 +143,8 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat } -#pragma mark - -#pragma mark Override observers +// MARK: - +// MARK: Override observers - (void)_removeObservers { @@ -795,7 +795,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat @end -#pragma mark - +// MARK: - @implementation CPSearchField (ThemingAdditions) @@ -987,7 +987,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat @end -#pragma mark - +// MARK: - @implementation CPSearchField (CPTrackingArea) { @@ -1042,7 +1042,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat @end -#pragma mark - +// MARK: - var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey", CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey", diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index 04c7f5ce8..c72f49c1d 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -586,7 +586,7 @@ var AFFINITY = 5; return [self setFloatValue:1.0]; } -#pragma mark - New methods as in High Sierra (10.13) +// MARK: - New methods as in High Sierra (10.13) /*! Creates and returns a continuous horizontal slider whose values range from 0.0 to 1.0. @@ -812,7 +812,7 @@ var AFFINITY = 5; return [self valueForThemeAttribute:@"left-track-color" inStates:normalState]; } -#pragma mark - Private methods +// MARK: - Private methods - (void)_refreshCachesAndStates { @@ -1050,7 +1050,7 @@ var AFFINITY = 5; return value; } -#pragma mark - Overrides +// MARK: - Overrides - (void)setFrameSize:(CGSize)aSize { @@ -1060,7 +1060,7 @@ var AFFINITY = 5; [self setNeedsDisplay:YES]; } -#pragma mark - +// MARK: - @end diff --git a/AppKit/CPSound.j b/AppKit/CPSound.j index eea37ba33..f07fda11f 100644 --- a/AppKit/CPSound.j +++ b/AppKit/CPSound.j @@ -66,8 +66,8 @@ CPSoundPlayBackStatePause = 2; unsigned _implementedDelegateMethods; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization - (id)init { @@ -147,8 +147,8 @@ CPSoundPlayBackStatePause = 2; } -#pragma mark - -#pragma mark Delegate methods +// MARK: - +// MARK: Delegate methods /*! Sets the sound's delegate. @@ -166,8 +166,8 @@ CPSoundPlayBackStatePause = 2; _implementedDelegateMethods |= CPSoundDelegate_sound_didFinishPlaying_; } -#pragma mark - -#pragma mark Events listener +// MARK: - +// MARK: Events listener /*! @ignore */ @@ -199,8 +199,8 @@ CPSoundPlayBackStatePause = 2; } -#pragma mark - -#pragma mark Media controls +// MARK: - +// MARK: Media controls /*! Play the sound. @@ -324,8 +324,8 @@ CPSoundPlayBackStatePause = 2; _audioTag.volume = aVolume; } -#pragma mark - -#pragma mark Accessors +// MARK: - +// MARK: Accessors /*! Returns the duration in seconds of the sound. @@ -364,4 +364,4 @@ CPSoundPlayBackStatePause = 2; [_delegate sound:self didFinishPlaying:finishedPlaying]; } -@end \ No newline at end of file +@end diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 854366be4..aa3fbcd44 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -216,7 +216,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle [self _setVertical:YES]; } -#pragma mark - Properties +// MARK: - Properties - (CPSplitViewDividerStyle)dividerStyle { @@ -479,7 +479,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle return _delegate; } -#pragma mark - Subviews management +// MARK: - Subviews management // FIXME: il faut également tenir compte des button bars quand on ajouter / insert une vue. // Par exemple, si une button bar est placée sur la dernière vue, pas de resize à droite mais @@ -652,7 +652,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle _subviewsManagementDisabled = NO; } -#pragma mark - Layout subviews +// MARK: - Layout subviews - (CGRect)rectOfDividerAtIndex:(int)aDivider { @@ -851,7 +851,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle [self updateTrackingAreas]; } -#pragma mark - Private layout utilities +// MARK: - Private layout utilities - (void)_distribute:(CPInteger)remainingSpace amoung:(CPInteger)count onFlexible:(BOOL)onFlexible fromIndex:(CPInteger)fromIndex toIndex:(CPInteger)toIndex { @@ -906,7 +906,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle [_ratios addObject:(_initialSizes[i] / fixedSpace)]; } -#pragma mark - +// MARK: - /*! Returns YES if the supplied subview is collapsed, otherwise NO. @@ -1493,7 +1493,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle @end -#pragma mark - +// MARK: - @implementation CPSplitView (CPTrackingArea) { @@ -1573,7 +1573,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle @end -#pragma mark - +// MARK: - @implementation CPSplitView (CPSplitViewDelegate) @@ -1751,7 +1751,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle @end -#pragma mark - +// MARK: - var CPSplitViewDelegateKey = @"CPSplitViewDelegateKey", CPSplitViewIsVerticalKey = @"CPSplitViewIsVerticalKey", @@ -1876,7 +1876,7 @@ var CPSplitViewDelegateKey = @"CPSplitViewDelegateKey", @end -#pragma mark - +// MARK: - @implementation CPSplitView (Deprecated) diff --git a/AppKit/CPStackView.j b/AppKit/CPStackView.j index dbd3a7d88..dd44f73c4 100644 --- a/AppKit/CPStackView.j +++ b/AppKit/CPStackView.j @@ -82,8 +82,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX CPMapTable _visibilityPriorities; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization + (CPStackView)stackViewWithViews:(CPArray)views { @@ -116,8 +116,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX return self; } -#pragma mark - -#pragma mark Configuration +// MARK: - +// MARK: Configuration /*! The horizontal or vertical layout direction of the stack view. @@ -222,8 +222,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX [self setNeedsLayout:YES]; } -#pragma mark - -#pragma mark Managing Views in Gravity Areas +// MARK: - +// MARK: Managing Views in Gravity Areas - (CPArray)_containerForGravity:(CPStackViewGravity)gravity { @@ -358,8 +358,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX [self removeView:view]; } -#pragma mark - -#pragma mark Custom Spacing +// MARK: - +// MARK: Custom Spacing - (float)customSpacingAfterView:(CPView)aView { @@ -388,8 +388,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX return _spacing; } -#pragma mark - -#pragma mark Visibility Priority +// MARK: - +// MARK: Visibility Priority - (void)setVisibilityPriority:(float)priority forView:(CPView)aView { @@ -418,8 +418,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX return CPStackViewVisibilityPriorityMustHold; } -#pragma mark - -#pragma mark Layout +// MARK: - +// MARK: Layout - (void)resizeSubviewsWithOldSize:(CGSize)oldSize { @@ -649,8 +649,8 @@ var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX return cursor; } -#pragma mark - -#pragma mark CPCoding +// MARK: - +// MARK: CPCoding - (id)initWithCoder:(CPCoder)aCoder { diff --git a/AppKit/CPStepper.j b/AppKit/CPStepper.j index 7695d96a8..5f64faba8 100644 --- a/AppKit/CPStepper.j +++ b/AppKit/CPStepper.j @@ -42,8 +42,8 @@ CPButton _buttonUp; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Initializes a CPStepper with given values. @@ -147,8 +147,8 @@ [self _sizeToFit]; } -#pragma mark - -#pragma mark Superclass overrides +// MARK: - +// MARK: Superclass overrides /*! Set if the CPStepper is enabled or not. @@ -290,8 +290,8 @@ [super setDoubleValue:aValue]; } -#pragma mark - -#pragma mark Actions +// MARK: - +// MARK: Actions /*! @ignore */ - (IBAction)_buttonDidClick:(id)aSender @@ -326,8 +326,8 @@ } -#pragma mark - -#pragma mark Theming +// MARK: - +// MARK: Theming + (CPString)defaultThemeClass { diff --git a/AppKit/CPTabView.j b/AppKit/CPTabView.j index ce6ff664b..54444de55 100644 --- a/AppKit/CPTabView.j +++ b/AppKit/CPTabView.j @@ -696,8 +696,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1, [self _displayItemView:_placeholderView]; } -#pragma mark - -#pragma mark Override +// MARK: - +// MARK: Override /*! Enabled controls accept first mouse by default. @@ -886,11 +886,11 @@ var CPTabViewItemsKey = "CPTabViewItemsKey", @end -#pragma mark - +// MARK: - @implementation CPTabView (CSSTheming) -#pragma mark Override +// MARK: Override - (void)_setThemeIncludingDescendants:(CPTheme)aTheme { @@ -906,7 +906,7 @@ var CPTabViewItemsKey = "CPTabViewItemsKey", @end -#pragma mark - +// MARK: - @implementation _CPTabViewBox : CPBox { @@ -915,8 +915,8 @@ var CPTabViewItemsKey = "CPTabViewItemsKey", } -#pragma mark - -#pragma mark Override +// MARK: - +// MARK: Override - (id)initWithFrame:(CGRect)aFrame { diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index e9376612e..fe8f078ef 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -5811,8 +5811,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad } -#pragma mark - -#pragma mark DataSource methods to implement +// MARK: - +// MARK: DataSource methods to implement /*! @ignore @@ -6080,8 +6080,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad } -#pragma mark - -#pragma mark Delegate methods to implement +// MARK: - +// MARK: Delegate methods to implement /*! @ignore diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 249606753..d17c9b7f1 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -245,8 +245,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); } -#pragma mark - -#pragma mark Control Size +// MARK: - +// MARK: Control Size - (void)setControlSize:(CPControlSize)aControlSize { @@ -257,7 +257,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); } -#pragma mark - +// MARK: - #if PLATFORM(DOM) - (DOMElement)_inputElement @@ -381,7 +381,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); return self; } -#pragma mark Controlling Editability and Selectability +// MARK: Controlling Editability and Selectability /*! Sets whether or not the receiver text field can be edited. If NO, any @@ -1848,7 +1848,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [self _didEdit]; } -#pragma mark Setting the Delegate +// MARK: Setting the Delegate - (void)setDelegate:(id )aDelegate { @@ -2008,7 +2008,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [self _setCSSStyleForInputElement]; } -#pragma mark Overrides +// MARK: Overrides /*! Sets the font of the receiver. @@ -2061,7 +2061,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); } } -#pragma mark Overrides +// MARK: Overrides /*! Sets the text color of the receiver. @@ -2130,7 +2130,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); return YES; } -#pragma mark Private +// MARK: Private - (BOOL)_isWithinUsablePlatformRect { @@ -2429,7 +2429,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", @end -#pragma mark - +// MARK: - @implementation CPTextField (TableDataView) @@ -2446,7 +2446,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", @end -#pragma mark - +// MARK: - @implementation CPTextField (Deprecated) diff --git a/AppKit/CPTextView/CPFontPanel.j b/AppKit/CPTextView/CPFontPanel.j index 701a0251e..d4806be22 100644 --- a/AppKit/CPTextView/CPFontPanel.j +++ b/AppKit/CPTextView/CPFontPanel.j @@ -86,8 +86,8 @@ var _availableTraits = [@"Normal", @"Italic", @"Bold", @"Bold Italic"], int _fontChanges; } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods /*! Check if the shared Font panel exists. @@ -113,8 +113,8 @@ var _availableTraits = [@"Normal", @"Italic", @"Bold", @"Bold Italic"], return NO; } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods /*! @ignore */ - (id)init diff --git a/AppKit/CPTextView/CPLayoutManager.j b/AppKit/CPTextView/CPLayoutManager.j index 5309fd463..e31cbafd3 100644 --- a/AppKit/CPTextView/CPLayoutManager.j +++ b/AppKit/CPTextView/CPLayoutManager.j @@ -76,8 +76,8 @@ _oncontextmenuhandler = function () { return false; }; } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)init { @@ -103,8 +103,8 @@ _oncontextmenuhandler = function () { return false; }; } -#pragma mark - -#pragma mark Text containes method +// MARK: - +// MARK: Text containes method - (void)insertTextContainer:(CPTextContainer)aContainer atIndex:(int)index { @@ -1132,8 +1132,8 @@ var _objectsInRange = function(aList, aRange) CPMutableArray _runs; } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)createDOMElementWithText:(CPString)aString andFont:(CPFont)aFont andColor:(CPColor)aColor { diff --git a/AppKit/CPTextView/CPRulerView.j b/AppKit/CPTextView/CPRulerView.j index 82ed13ab7..aaef07851 100644 --- a/AppKit/CPTextView/CPRulerView.j +++ b/AppKit/CPTextView/CPRulerView.j @@ -154,8 +154,8 @@ CPRulerOrientationVertical = 1 } } } -#pragma mark - -#pragma mark Context Menu Support +// MARK: - +// MARK: Context Menu Support - (CPMenu)menuForEvent:(CPEvent)anEvent { @@ -385,8 +385,8 @@ CPRulerOrientationVertical = 1 } -#pragma mark - -#pragma mark Interaction Handlers +// MARK: - +// MARK: Interaction Handlers - (void)mouseDown:(CPEvent)anEvent { @@ -500,8 +500,8 @@ CPRulerOrientationVertical = 1 } -#pragma mark - -#pragma mark DOM Layout Builder +// MARK: - +// MARK: DOM Layout Builder - (void)updateRuler { diff --git a/AppKit/CPTextView/CPTextContainer.j b/AppKit/CPTextView/CPTextContainer.j index e851de4dd..d343b397a 100644 --- a/AppKit/CPTextView/CPTextContainer.j +++ b/AppKit/CPTextView/CPTextContainer.j @@ -89,8 +89,8 @@ CPLineMovesUp = 4; } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)initWithContainerSize:(CGSize)aSize { @@ -118,8 +118,8 @@ CPLineMovesUp = 4; [_layoutManager addTextContainer:self]; } -#pragma mark - -#pragma mark Setter methods +// MARK: - +// MARK: Setter methods - (void)setContainerSize:(CGSize)someSize { diff --git a/AppKit/CPTextView/CPTextStorage.j b/AppKit/CPTextView/CPTextStorage.j index 074510e9a..18cc8ebcc 100644 --- a/AppKit/CPTextView/CPTextStorage.j +++ b/AppKit/CPTextView/CPTextStorage.j @@ -70,8 +70,8 @@ var CPTextStorageDelegate_textStorageWillProcessEditing_ = 1 << 1, } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)initWithString:(CPString)aString attributes:(CPDictionary)attributes { @@ -99,8 +99,8 @@ var CPTextStorageDelegate_textStorageWillProcessEditing_ = 1 << 1, } -#pragma mark - -#pragma mark Delegate methods +// MARK: - +// MARK: Delegate methods - (void)setDelegate:(id )aDelegate { @@ -121,8 +121,8 @@ var CPTextStorageDelegate_textStorageWillProcessEditing_ = 1 << 1, } -#pragma mark - -#pragma mark Layout manager methods +// MARK: - +// MARK: Layout manager methods - (void)addLayoutManager:(CPLayoutManager)aManager { @@ -148,8 +148,8 @@ var CPTextStorageDelegate_textStorageWillProcessEditing_ = 1 << 1, } -#pragma mark - -#pragma mark Editing methods +// MARK: - +// MARK: Editing methods - (void)processEditing { diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 68301d9f3..0e731080a 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -191,8 +191,8 @@ var kDelegateRespondsTo_textShouldBeginEditing return editMenu; } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods /* FIXME just a testing characterSet @@ -200,8 +200,8 @@ var kDelegateRespondsTo_textShouldBeginEditing Need some CPLocale support and maybe even a FSM... */ -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods - (id)initWithFrame:(CGRect)aFrame textContainer:(CPTextContainer)aContainer { @@ -444,8 +444,8 @@ var kDelegateRespondsTo_textShouldBeginEditing [self _becomeFirstResponder]; } -#pragma mark - -#pragma mark Copy and paste methods +// MARK: - +// MARK: Copy and paste methods - (void)copy:(id)sender { @@ -527,8 +527,8 @@ var kDelegateRespondsTo_textShouldBeginEditing [self _pasteString:[self _stringForPasting]]; } -#pragma mark - -#pragma mark Responders method +// MARK: - +// MARK: Responders method - (BOOL)acceptsFirstResponder { @@ -587,8 +587,8 @@ var kDelegateRespondsTo_textShouldBeginEditing } -#pragma mark - -#pragma mark Delegate methods +// MARK: - +// MARK: Delegate methods /*! TODO : documentation @@ -647,8 +647,8 @@ var kDelegateRespondsTo_textShouldBeginEditing } -#pragma mark - -#pragma mark Key window methods +// MARK: - +// MARK: Key window methods - (void)becomeKeyWindow { @@ -674,8 +674,8 @@ var kDelegateRespondsTo_textShouldBeginEditing } -#pragma mark - -#pragma mark Undo redo methods +// MARK: - +// MARK: Undo redo methods - (void)undo:(id)sender { @@ -690,8 +690,8 @@ var kDelegateRespondsTo_textShouldBeginEditing } -#pragma mark - -#pragma mark Accessors +// MARK: - +// MARK: Accessors - (CPString)stringValue { @@ -805,8 +805,8 @@ var kDelegateRespondsTo_textShouldBeginEditing } -#pragma mark - -#pragma mark Insert characters methods +// MARK: - +// MARK: Insert characters methods - (void)_fixupReplaceForRange:(CPRange)aRange { @@ -864,8 +864,8 @@ var kDelegateRespondsTo_textShouldBeginEditing _stickyXLocation = MAX(0, _caret._rect.origin.x - 1); } -#pragma mark - -#pragma mark Drawing methods +// MARK: - +// MARK: Drawing methods - (void)drawInsertionPointInRect:(CGRect)aRect color:(CPColor)aColor turnedOn:(BOOL)flag { @@ -928,8 +928,8 @@ var kDelegateRespondsTo_textShouldBeginEditing } -#pragma mark - -#pragma mark Select methods +// MARK: - +// MARK: Select methods - (void)selectAll:(id)sender { @@ -1060,8 +1060,8 @@ Sets the selection to a range of characters in response to user action. return [_selectionRange]; } -#pragma mark - -#pragma mark Keyboard events +// MARK: - +// MARK: Keyboard events - (void)keyDown:(CPEvent)event { @@ -1129,8 +1129,8 @@ Sets the selection to a range of characters in response to user action. [placeholderString addAttribute:_CPAttachmentInvisible value:YES range:rangeToHide]; } -#pragma mark - -#pragma mark Mouse Events +// MARK: - +// MARK: Mouse Events - (void)mouseDown:(CPEvent)event { @@ -1852,8 +1852,8 @@ Sets the selection to a range of characters in response to user action. } -#pragma mark - -#pragma mark Font methods +// MARK: - +// MARK: Font methods - (CPFont)font { @@ -1943,8 +1943,8 @@ Sets the selection to a range of characters in response to user action. } -#pragma mark - -#pragma mark Color methods +// MARK: - +// MARK: Color methods - (void)changeColor:(id)sender { @@ -1979,8 +1979,8 @@ Sets the selection to a range of characters in response to user action. [_layoutManager textStorage:_textStorage edited:0 range:CPMakeRangeCopy(range) changeInLength:0 invalidatedRange:CPMakeRangeCopy(range)]; } -#pragma mark - -#pragma mark Style & Alignment methods +// MARK: - +// MARK: Style & Alignment methods - (void)bold:(id)sender { @@ -2388,8 +2388,8 @@ Sets the selection to a range of characters in response to user action. [_caret setVisibility:YES]; } -#pragma mark - -#pragma mark Dragging operation +// MARK: - +// MARK: Dragging operation - (void)performDragOperation:(CPDraggingInfo)aSender { diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index 074c3b175..f8f00a9c1 100644 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -54,8 +54,8 @@ var CPSystemTypesetterFactory, @implementation CPTypesetter : CPObject -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods + (void)initialize { @@ -122,8 +122,8 @@ var CPSystemTypesetterFactory, } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods + (id)sharedInstance { diff --git a/AppKit/CPTextView/_CPRTFProducer.j b/AppKit/CPTextView/_CPRTFProducer.j index a0625f30b..65d6f86cf 100644 --- a/AppKit/CPTextView/_CPRTFProducer.j +++ b/AppKit/CPTextView/_CPRTFProducer.j @@ -70,8 +70,8 @@ function _points2twips(a) { return (a) * 20.0; } CPColor ulColor; } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods + (CPString)produceRTF:(CPAttributedString)aText documentAttributes:(CPDictionary)dict @@ -82,8 +82,8 @@ function _points2twips(a) { return (a) * 20.0; } } -#pragma mark - -#pragma mark init methods +// MARK: - +// MARK: init methods - (id)init { diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index fc32c34b5..9f7860f54 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -319,8 +319,8 @@ var CPThemeNameKey = @"CPThemeNameKey", @end -#pragma mark - -#pragma mark CSS Theming +// MARK: - +// MARK: CSS Theming // The code below adds support for CSS theming with 100% compatibility with current theming system. // The idea is to extend CPColor and CPImage with CSS components and adapt low level UI components to @@ -556,7 +556,7 @@ var _savedThemesByName = { }; @end -#pragma mark - +// MARK: - /*! * ThemeStates are immutable objects representing a particular ThemeState. Applications should never be creating diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index e015c0bcb..33bd5a21a 100644 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -169,8 +169,8 @@ CPTokenFieldDeleteButtonType = 1; [self addSubview:_tokenScrollView]; } -#pragma mark - -#pragma mark Delegate methods +// MARK: - +// MARK: Delegate methods /*! Set the delegate of the receiver diff --git a/AppKit/CPTrackingArea.j b/AppKit/CPTrackingArea.j index 2412927f5..3ef930774 100644 --- a/AppKit/CPTrackingArea.j +++ b/AppKit/CPTrackingArea.j @@ -69,8 +69,8 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Initializes and returns an object defining a region of a view to receive mouse-tracking events, mouse-moved events, cursor-update events, or possibly @@ -121,8 +121,8 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; } -#pragma mark - -#pragma mark Implementation +// MARK: - +// MARK: Implementation - (void)_updateWindowRect { @@ -140,8 +140,8 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; @end -#pragma mark - -#pragma mark CPCoding +// MARK: - +// MARK: CPCoding @implementation CPTrackingArea (CPCoding) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index d82947d79..4140880da 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -3375,7 +3375,7 @@ setBoundsOrigin: @implementation CPView (Theming) -#pragma mark Override +// MARK: Override - (BOOL)setThemeState:(ThemeState)aState { @@ -3412,7 +3412,7 @@ setBoundsOrigin: } -#pragma mark First responder +// MARK: First responder - (BOOL)becomeFirstResponder { @@ -3474,7 +3474,7 @@ setBoundsOrigin: [_subviews[count] _notifyWindowDidResignKey]; } -#pragma mark Theme Attributes +// MARK: Theme Attributes - (void)_setThemeIncludingDescendants:(CPTheme)aTheme { diff --git a/AppKit/CPVisualEffectView.j b/AppKit/CPVisualEffectView.j index 2618b611f..45c9e7a92 100644 --- a/AppKit/CPVisualEffectView.j +++ b/AppKit/CPVisualEffectView.j @@ -57,8 +57,8 @@ CPVisualEffectStateInactive = 2; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization - (id)initWithFrame:(CGRect)aFrame { @@ -74,8 +74,8 @@ CPVisualEffectStateInactive = 2; } -#pragma mark - -#pragma mark CPVisualEffectView API +// MARK: - +// MARK: CPVisualEffectView API /*! Sets the appearance of the CPVisualEffectView. @@ -114,8 +114,8 @@ CPVisualEffectStateInactive = 2; } -#pragma mark - -#pragma mark Utilities +// MARK: - +// MARK: Utilities - (void)_setEffectEnabled:(BOOL)shouldEnable { @@ -156,8 +156,8 @@ CPVisualEffectStateInactive = 2; } -#pragma mark - -#pragma mark CPCoding +// MARK: - +// MARK: CPCoding - (id)initWithCoder:(CPCoder)aCoder { @@ -183,4 +183,4 @@ CPVisualEffectStateInactive = 2; } -@end \ No newline at end of file +@end diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 72e1bef92..3773b3a0d 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -4462,7 +4462,7 @@ var interpolate = function(fromValue, toValue, progress) @end -#pragma mark - +// MARK: - @implementation CPWindow (CSSTheming) @@ -4473,7 +4473,7 @@ var interpolate = function(fromValue, toValue, progress) @end -#pragma mark - +// MARK: - function _CPWindowFullPlatformWindowSessionMake(aWindowView, aContentRect, hasShadow, aLevel) { diff --git a/AppKit/CPWindow/_CPToolTipWindowView.j b/AppKit/CPWindow/_CPToolTipWindowView.j index 3b465fa77..919aa481c 100644 --- a/AppKit/CPWindow/_CPToolTipWindowView.j +++ b/AppKit/CPWindow/_CPToolTipWindowView.j @@ -29,8 +29,9 @@ unsigned _gravity @accessors(property=gravity); } -#pragma mark - -#pragma mark Class methods + +// MARK: - +// MARK: Class methods + (CPString)defaultThemeClass { @@ -84,8 +85,8 @@ return aFrameRect; } -#pragma mark - -#pragma mark DOM/CSS Rendering +// MARK: - +// MARK: drawing - (void)layoutSubviews { diff --git a/AppKit/_CPObject+Theme.j b/AppKit/_CPObject+Theme.j index 30cd13a9a..0e813d74d 100644 --- a/AppKit/_CPObject+Theme.j +++ b/AppKit/_CPObject+Theme.j @@ -66,8 +66,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey", } -#pragma mark - -#pragma mark Theme State +// MARK: - +// MARK: Theme State - (unsigned)themeState { @@ -155,7 +155,7 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey", return [self unsetThemeState:aState]; } -#pragma mark Theme Attributes +// MARK: Theme Attributes + (CPString)defaultThemeClass { @@ -494,8 +494,8 @@ var NULL_THEME = {}; } } -#pragma mark - -#pragma mark CSS styling additions +// MARK: - +// MARK: CSS styling additions - (CPTheme)actualTheme { diff --git a/AppKit/_CPPopUpList.j b/AppKit/_CPPopUpList.j index 603cafcd2..104aed050 100644 --- a/AppKit/_CPPopUpList.j +++ b/AppKit/_CPPopUpList.j @@ -210,7 +210,7 @@ var ListColumnIdentifier = @"1"; CPTableColumn _tableColumn; } -#pragma mark Creating and Displaying a List +// MARK: Creating and Displaying a List /*! Creates a pop up list of choices that will display in a scrollable CPTableView. @@ -386,7 +386,7 @@ var ListColumnIdentifier = @"1"; [self scrollItemAtIndexToTop:[_tableView selectedRow]]; } -#pragma mark Setting Display Attributes +// MARK: Setting Display Attributes /*! Returns the desired width of the list. @@ -481,7 +481,7 @@ var ListColumnIdentifier = @"1"; return _panel; } -#pragma mark Setting a Data Source +// MARK: Setting a Data Source - (void)setDataSource:(_CPPopUpListDataSource)aDataSource { @@ -501,7 +501,7 @@ var ListColumnIdentifier = @"1"; return _dataSource; } -#pragma mark Manipulating the Selection +// MARK: Manipulating the Selection /*! Select the next item in the list if there one. If there is currently no selected item, @@ -589,7 +589,7 @@ var ListColumnIdentifier = @"1"; return NO; } -#pragma mark Manipulating the Displayed List +// MARK: Manipulating the Displayed List /*! Scroll the list down one page. @@ -670,7 +670,7 @@ var ListColumnIdentifier = @"1"; [[CPNotificationCenter defaultCenter] postNotificationName:_CPPopUpListItemWasClickedNotification object:self]; } -#pragma mark Handling Events +// MARK: Handling Events /*! Handles standard key equivalents for moving the selection @@ -818,7 +818,7 @@ var ListColumnIdentifier = @"1"; return YES; } -#pragma mark Internal Helpers +// MARK: Internal Helpers /*! @ignore */ - (void)listWillPopUp diff --git a/AppKit/_CPPopoverWindow.j b/AppKit/_CPPopoverWindow.j index 9d623b4f8..619c7657e 100644 --- a/AppKit/_CPPopoverWindow.j +++ b/AppKit/_CPPopoverWindow.j @@ -74,8 +74,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods /*! Overrides the default windowView class loader. @@ -89,8 +89,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Create and init a _CPPopoverWindow with given the given frame. @@ -138,8 +138,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, return self; } -#pragma mark - -#pragma mark Getters / Setters +// MARK: - +// MARK: Getters / Setters - (void)setAppearance:(int)anAppearance { @@ -177,8 +177,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, _implementedDelegateMethods |= _CPPopoverWindow_didShow_; } -#pragma mark - -#pragma mark Observer +// MARK: - +// MARK: Observer /*! @ignore @@ -236,8 +236,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, } -#pragma mark - -#pragma mark Utilities +// MARK: - +// MARK: Utilities - (CGPoint)computeOriginFromRect:(CGRect)aRect ofView:(CPView)positioningView preferredEdge:(int)anEdge { @@ -447,8 +447,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, } } -#pragma mark - -#pragma mark Actions +// MARK: - +// MARK: Actions /*! @ignore @@ -462,8 +462,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, } -#pragma mark - -#pragma mark Overrides +// MARK: - +// MARK: Overrides /*! @ignore @@ -697,8 +697,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, } -#pragma mark - -#pragma mark Private +// MARK: - +// MARK: Private - (CPString)_currentTransformMatrix { diff --git a/AppKit/_CPToolTip.j b/AppKit/_CPToolTip.j index d1e954095..f920d9e73 100644 --- a/AppKit/_CPToolTip.j +++ b/AppKit/_CPToolTip.j @@ -45,8 +45,8 @@ var _CPToolTipHeight = 24.0, } -#pragma mark - -#pragma mark Class Methods +// MARK: - +// MARK: Class Methods /*! @ignore Invalidate any scheduled tooltips, or hide any visible one @@ -169,8 +169,8 @@ var _CPToolTipHeight = 24.0, } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Returns an initialized _CPToolTip with string. @@ -223,8 +223,8 @@ var _CPToolTipHeight = 24.0, } -#pragma mark - -#pragma mark Controls +// MARK: - +// MARK: Controls /*! Show the tooltip after computing the position. diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index 7f647e8f3..c8cf8b1ce 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -239,8 +239,8 @@ var CPBundlesForURLStrings = { }; } -#pragma mark - -#pragma mark Localization +// MARK: - +// MARK: Localization - (CPArray)localizations { @@ -267,4 +267,4 @@ function CPLocalizedStringFromTable(key, table, comment) function CPCopyLocalizedStringFromTableInBundle(key, table, bundle, comment) { return CFCopyLocalizedStringFromTableInBundle(key, table, bundle._bundle, comment); -} \ No newline at end of file +} diff --git a/Foundation/CPCache.j b/Foundation/CPCache.j index 9292094a3..7a406911e 100644 --- a/Foundation/CPCache.j +++ b/Foundation/CPCache.j @@ -74,8 +74,8 @@ var CPCacheDelegate_cache_willEvictObject_ = 1 << 1; } -#pragma mark - -#pragma mark Initialization +// MARK: - +// MARK: Initialization /*! Initializes the cache with default values @@ -100,8 +100,8 @@ var CPCacheDelegate_cache_willEvictObject_ = 1 << 1; } -#pragma mark - -#pragma mark Managing cache +// MARK: - +// MARK: Managing cache /*! Returns the object which correspond to the given key @@ -182,8 +182,8 @@ var CPCacheDelegate_cache_willEvictObject_ = 1 << 1; } -#pragma mark - -#pragma mark Setters +// MARK: - +// MARK: Setters /*! Sets the count limit of the cache. @@ -224,8 +224,8 @@ var CPCacheDelegate_cache_willEvictObject_ = 1 << 1; } -#pragma mark - -#pragma mark Privates +// MARK: - +// MARK: Privates /* * This method return the number of objects in the cache diff --git a/Foundation/CPDateFormatter.j b/Foundation/CPDateFormatter.j index 896a261ac..e8eea796a 100644 --- a/Foundation/CPDateFormatter.j +++ b/Foundation/CPDateFormatter.j @@ -231,8 +231,8 @@ var _separatorsCharacterSet = nil; } -#pragma mark - -#pragma mark Setter Getter Helper +// MARK: - +// MARK: Setter Getter Helper /*! Return symbols for the given language code */ @@ -280,8 +280,8 @@ var _separatorsCharacterSet = nil; [languageSymbols setValue:aSymbol forKey:aKey]; } -#pragma mark - -#pragma mark Setter Getter +// MARK: - +// MARK: Setter Getter /*! Return AMSymbol */ @@ -536,8 +536,8 @@ var _separatorsCharacterSet = nil; } -#pragma mark - -#pragma mark StringFromDate methods +// MARK: - +// MARK: StringFromDate methods /*! Return a string representation of a given date. This method returns (if possible) a representation of the given date with the dateFormat of the CPDateFormatter, otherwise it takes the dateStyle and timeStyle @@ -1160,8 +1160,8 @@ var _separatorsCharacterSet = nil; } -#pragma mark - -#pragma mark datefromString +// MARK: - +// MARK: datefromString /*! Return a date of the given string This method returns (if possible) a representation of the given string with the dateFormat of the CPDateFormatter, otherwise it takes the dateStyle and timeStyle @@ -1922,8 +1922,8 @@ var _separatorsCharacterSet = nil; } -#pragma mark - -#pragma mark Utils +// MARK: - +// MARK: Utils - (CPString)_stringValueForValue:(id)aValue length:(int)length { diff --git a/Foundation/CPException.j b/Foundation/CPException.j index 392cbe1b0..d11efcb77 100755 --- a/Foundation/CPException.j +++ b/Foundation/CPException.j @@ -20,11 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import "CPCoder.j" @import "CPObject.j" @import "CPString.j" -@class CPString +@class CPCoder CPInvalidArgumentException = @"CPInvalidArgumentException"; CPUnsupportedMethodException = @"CPUnsupportedMethodException"; diff --git a/Foundation/CPIndexPath.j b/Foundation/CPIndexPath.j index 720d859c8..70e6929bf 100644 --- a/Foundation/CPIndexPath.j +++ b/Foundation/CPIndexPath.j @@ -70,8 +70,8 @@ return [super description] + " " + _indexes; } -#pragma mark - -#pragma mark Accessing +// MARK: - +// MARK: Accessing - (id)length { @@ -93,8 +93,8 @@ return [_indexes copy]; } -#pragma mark - -#pragma mark Modification +// MARK: - +// MARK: Modification - (CPIndexPath)indexPathByAddingIndex:(int)index { @@ -106,8 +106,8 @@ return [CPIndexPath indexPathWithIndexes:_indexes length:[self length] - 1]; } -#pragma mark - -#pragma mark Comparison +// MARK: - +// MARK: Comparison - (BOOL)isEqual:(id)anObject { diff --git a/Foundation/CPIndexSet.j b/Foundation/CPIndexSet.j index 98d8f0604..e478eaade 100644 --- a/Foundation/CPIndexSet.j +++ b/Foundation/CPIndexSet.j @@ -176,13 +176,6 @@ return YES; } -- (BOOL)isEqual:(id)anObject -{ - return self === anObject || - [anObject isKindOfClass:[self class]] && - [self isEqualToIndexSet:anObject]; -} - /*! Returns \c YES if the index set contains the specified index. @param anIndex the index to check for in the set diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index 855342d6a..d5add0a0c 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import "CPArray+KVO.j" @import "CPArray.j" @import "CPDictionary.j" @import "CPException.j" @@ -1566,6 +1567,3 @@ var _CPKVOInfoMake = function(anObserver, theOptions, aContext, aForwarder) forwarder: aForwarder }; }; - -@import "CPArray+KVO.j" -@import "CPSet+KVO.j" diff --git a/Foundation/CPMapTable.j b/Foundation/CPMapTable.j index 9399c347c..58ebbd861 100644 --- a/Foundation/CPMapTable.j +++ b/Foundation/CPMapTable.j @@ -29,8 +29,8 @@ return self; } -#pragma mark - -#pragma mark Accessing Content +// MARK: - +// MARK: Accessing Content /*! Returns the value associated with a given key. @@ -70,8 +70,8 @@ return _map.size; } -#pragma mark - -#pragma mark Manipulating Content +// MARK: - +// MARK: Manipulating Content /*! Adds a given key-value pair to the map table. @@ -101,8 +101,8 @@ _map.clear(); } -#pragma mark - -#pragma mark Creating a Dictionary Representation +// MARK: - +// MARK: Creating a Dictionary Representation /*! Returns a dictionary representation of the map table. diff --git a/Foundation/CPNotificationQueue.j b/Foundation/CPNotificationQueue.j index bd9eb594f..7800396fa 100644 --- a/Foundation/CPNotificationQueue.j +++ b/Foundation/CPNotificationQueue.j @@ -98,8 +98,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark Class methods +// MARK: - +// MARK: Class methods /*! Returns the application's notification queue. This notification queue uses the default notification center @@ -113,8 +113,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark Init methods +// MARK: - +// MARK: Init methods /*! Initializes and returns a notification queue for the specified notification center. @@ -135,8 +135,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark Enqueue methods +// MARK: - +// MARK: Enqueue methods /*! Adds a notification to the notification queue with a specified posting style. @@ -185,8 +185,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark Dequeue methods +// MARK: - +// MARK: Dequeue methods /*! Removes all notifications from the queue that match a provided notification using provided matching criteria. @@ -199,8 +199,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark RunLoop methods +// MARK: - +// MARK: RunLoop methods /*! @ignore @@ -244,8 +244,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark Posting methods +// MARK: - +// MARK: Posting methods /*! @ignore @@ -262,8 +262,8 @@ var runLoop = [CPRunLoop mainRunLoop]; } -#pragma mark - -#pragma mark Remove methods +// MARK: - +// MARK: Remove methods /*! @ignore @@ -325,4 +325,4 @@ var runLoop = [CPRunLoop mainRunLoop]; [notifications removeObjectsInArray:notificationsToRemove]; } -@end \ No newline at end of file +@end diff --git a/Foundation/CPNumberFormatter.j b/Foundation/CPNumberFormatter.j index 7645d0052..edb1e3e96 100644 --- a/Foundation/CPNumberFormatter.j +++ b/Foundation/CPNumberFormatter.j @@ -273,7 +273,7 @@ var NumberRegex = new RegExp('(-)?(\\d*)(\\.(\\d*))?'); SET_NEEDS_NUMBER_HANDLER_UPDATE(); } -#pragma mark Private +// MARK: Private - (void)_updateNumberHandlerIfNecessary { diff --git a/Foundation/CPSet+KVO.j b/Foundation/CPSet+KVO.j deleted file mode 100644 index 322828c49..000000000 --- a/Foundation/CPSet+KVO.j +++ /dev/null @@ -1,440 +0,0 @@ -/* - * CPSet+KVO.j - * Foundation - * - * Created by Daniel Stolzenberg. - * Copyright 2010, University of Rostock - * - * 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 "CPException.j" -@import "CPObject.j" -@import "CPMutableSet.j" -@import "CPNull.j" -@import "_CPCollectionKVCOperators.j" - -@implementation CPObject (CPSetKVO) - -- (id)mutableSetValueForKey:(id)aKey -{ - return [[_CPKVCSet alloc] initWithKey:aKey forProxyObject:self]; -} - -- (id)mutableSetValueForKeyPath:(id)aKeyPath -{ - var dotIndex = aKeyPath.indexOf("."); - - if (dotIndex < 0) - return [self mutableSetValueForKey:aKeyPath]; - - var firstPart = aKeyPath.substring(0, dotIndex), - lastPart = aKeyPath.substring(dotIndex + 1); - - return [[self valueForKeyPath:firstPart] mutableSetValueForKeyPath:lastPart]; -} - -@end - -@implementation _CPKVCSet : CPMutableSet -{ - id _proxyObject; - id _key; - - - SEL _accessSEL; - Function _access; - - SEL _setSEL; - Function _set; - - SEL _countSEL; - Function _count; - - SEL _enumeratorSEL; - Function _enumerator; - - SEL _memberSEL; - Function _member; - - SEL _addSEL; - Function _add; - - SEL _addManySEL; - Function _addMany; - - SEL _removeSEL; - Function _remove; - - SEL _removeManySEL; - Function _removeMany; - - SEL _intersectSEL; - Function _intersect; -} - -+ (id)alloc -{ - var set = [CPMutableSet set]; - - set.isa = self; - - var ivars = class_copyIvarList(self), - count = ivars.length; - - while (count--) - set[ivar_getName(ivars[count])] = nil; - - return set; -} - -- (id)initWithKey:(id)aKey forProxyObject:(id)anObject -{ - self = [super init]; - - _key = aKey; - _proxyObject = anObject; - - var capitalizedKey = _key.charAt(0).toUpperCase() + _key.substring(1); - - _accessSEL = sel_getName(_key); - if ([_proxyObject respondsToSelector:_accessSEL]) - _access = [_proxyObject methodForSelector:_accessSEL]; - - _setSEL = sel_getName(@"set"+capitalizedKey+":"); - if ([_proxyObject respondsToSelector:_setSEL]) - _set = [_proxyObject methodForSelector:_setSEL]; - - _countSEL = sel_getName(@"countOf"+capitalizedKey); - if ([_proxyObject respondsToSelector:_countSEL]) - _count = [_proxyObject methodForSelector:_countSEL]; - - _enumeratorSEL = sel_getName(@"enumeratorOf"+capitalizedKey); - if ([_proxyObject respondsToSelector:_enumeratorSEL]) - _enumerator = [_proxyObject methodForSelector:_enumeratorSEL]; - - _memberSEL = sel_getName(@"memberOf"+capitalizedKey+":"); - if ([_proxyObject respondsToSelector:_memberSEL]) - _member = [_proxyObject methodForSelector:_memberSEL]; - - _addSEL = sel_getName(@"add"+capitalizedKey+"Object:"); - if ([_proxyObject respondsToSelector:_addSEL]) - _add = [_proxyObject methodForSelector:_addSEL]; - - _addManySEL = sel_getName(@"add"+capitalizedKey+":"); - if ([_proxyObject respondsToSelector:_addManySEL]) - _addMany = [_proxyObject methodForSelector:_addManySEL]; - - _removeSEL = sel_getName(@"remove"+capitalizedKey+"Object:"); - if ([_proxyObject respondsToSelector:_removeSEL]) - _remove = [_proxyObject methodForSelector:_removeSEL]; - - _removeManySEL = sel_getName(@"remove"+capitalizedKey+":"); - if ([_proxyObject respondsToSelector:_removeManySEL]) - _removeMany = [_proxyObject methodForSelector:_removeManySEL]; - - _intersectSEL = sel_getName(@"intersect"+capitalizedKey+":"); - if ([_proxyObject respondsToSelector:_intersectSEL]) - _intersect = [_proxyObject methodForSelector:_intersectSEL]; - - return self; -} - -- (id)_representedObject -{ - if (_access) - return _access(_proxyObject, _accessSEL); - - return [_proxyObject valueForKey:_key]; -} - -- (void)_setRepresentedObject:(id)anObject -{ - if (_set) - return _set(_proxyObject, _setSEL, anObject); - - [_proxyObject setValue:anObject forKey:_key]; -} - -- (CPUInteger)count -{ - if (_count) - return _count(_proxyObject, _countSEL); - - return [[self _representedObject] count]; -} - -- (CPEnumerator)objectEnumerator -{ - if (_enumerator) - return _enumerator(_proxyObject, _enumeratorSEL); - - return [[self _representedObject] objectEnumerator]; -} - -- (id)member:(id)anObject -{ - if (_member) - return _member(_proxyObject, _memberSEL, anObject); - - return [[self _representedObject] member:anObject]; -} - -- (void)addObject:(id)anObject -{ - if (_add) - _add(_proxyObject, _addSEL, anObject); - else if (_addMany) - { - var objectSet = [CPSet setWithObject: anObject]; - _addMany(_proxyObject, _addManySEL, objectSet); - } - else - { - var target = [[self _representedObject] copy]; - [target addObject:anObject]; - [self _setRepresentedObject:target]; - } -} - -- (void)addObjectsFromArray:(CPArray)objects -{ - if (_addMany) - { - var objectSet = [CPSet setWithArray: objects]; - _addMany(_proxyObject, _addManySEL, objectSet); - } - else if (_add) - { - var object, - objectEnumerator = [objects objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - _add(_proxyObject, _addSEL, object); - } - else - { - var target = [[self _representedObject] copy]; - [target addObjectsFromArray:objects]; - [self _setRepresentedObject:target]; - } -} - -- (void)unionSet:(CPSet)aSet -{ - if (_addMany) - _addMany(_proxyObject, _addManySEL, aSet); - else if (_add) - { - var object, - objectEnumerator = [aSet objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - _add(_proxyObject, _addSEL, object); - } - else - { - var target = [[self _representedObject] copy]; - [target unionSet:aSet]; - [self _setRepresentedObject:target]; - } -} - -- (void)removeObject:(id)anObject -{ - if (_remove) - _remove(_proxyObject, _removeSEL, anObject); - else if (_removeMany) - { - var objectSet = [CPSet setWithObject: anObject]; - _removeMany(_proxyObject, _removeManySEL, objectSet); - } - else - { - var target = [[self _representedObject] copy]; - [target removeObject:anObject]; - [self _setRepresentedObject:target]; - } -} - -- (void)minusSet:(CPSet)aSet -{ - if (_removeMany) - _removeMany(_proxyObject, _removeManySEL, aSet); - else if (_remove) - { - var object, - objectEnumerator = [aSet objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - _remove(_proxyObject, _removeSEL, object); - } - else - { - var target = [[self _representedObject] copy]; - [target minusSet:aSet]; - [self _setRepresentedObject:target]; - } -} - -- (void)removeObjectsInArray:(CPArray)objects -{ - if (_removeMany) - { - var objectSet = [CPSet setWithArray:objects]; - _removeMany(_proxyObject, _removeManySEL, objectSet); - } - else if (_remove) - { - var object, - objectEnumerator = [objects objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - _remove(_proxyObject, _removeSEL, object); - } - else - { - var target = [[self _representedObject] copy]; - [target removeObjectsInArray:objects]; - [self _setRepresentedObject:target]; - } -} - -- (void)removeAllObjects -{ - if (_removeMany) - { - var allObjectsSet = [[self _representedObject] copy]; - _removeMany(_proxyObject, _removeManySEL, allObjectsSet); - } - else if (_remove) - { - var object, - objectEnumerator = [[[self _representedObject] copy] objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - _remove(_proxyObject, _removeSEL, object); - } - else - { - var target = [[self _representedObject] copy]; - [target removeAllObjects]; - [self _setRepresentedObject:target]; - } -} - -- (void)intersectSet:(CPSet)aSet -{ - if (_intersect) - _intersect(_proxyObject, _intersectSEL, aSet); - else - { - var target = [[self _representedObject] copy]; - [target intersectSet:aSet]; - [self _setRepresentedObject:target]; - } -} - -- (void)setSet:(CPSet)set -{ - [self _setRepresentedObject: set]; -} - -- (CPArray)allObjects -{ - return [[self _representedObject] allObjects]; -} - -- (id)anyObject -{ - return [[self _representedObject] anyObject]; -} - -- (BOOL)containsObject:(id)anObject -{ - return [[self _representedObject] containsObject: anObject]; -} - -- (BOOL)intersectsSet:(CPSet)aSet -{ - return [[self _representedObject] intersectsSet: aSet]; -} - -- (BOOL)isEqualToSet:(CPSet)aSet -{ - return [[self _representedObject] isEqualToSet: aSet]; -} - -- (id)copy -{ - return [[self _representedObject] copy]; -} - -@end - -@implementation CPSet (CPKeyValueCoding) - -- (id)valueForKeyPath:(CPString)aKeyPath -{ - if (!aKeyPath) - [self valueForUndefinedKey:@""]; - - if (aKeyPath.charAt(0) === "@") - { - var dotIndex = aKeyPath.indexOf("."), - operator, - parameter; - - if (dotIndex !== -1) - { - operator = aKeyPath.substring(1, dotIndex); - parameter = aKeyPath.substring(dotIndex + 1); - } - else - operator = aKeyPath.substring(1); - - return [_CPCollectionKVCOperator performOperation:operator withCollection:self propertyPath:parameter]; - } - else - { - var valuesForKeySet = [CPSet set], - containedObject, - containedObjectValue, - containedObjectEnumerator = [self objectEnumerator]; - - while ((containedObject = [containedObjectEnumerator nextObject]) != nil) - { - containedObjectValue = [containedObject valueForKeyPath:aKeyPath]; - - if (containedObjectValue == nil) - containedObjectValue = [CPNull null]; - - [valuesForKeySet addObject:containedObjectValue]; - } - - return valuesForKeySet; - } -} - -- (void)setValue:(id)aValue forKey:(CPString)aKey -{ - var containedObject, - containedObjectEnumerator = [self objectEnumerator]; - - while ((containedObject = [containedObjectEnumerator nextObject]) != nil) - [containedObject setValue:aValue forKey:aKey]; -} - -@end diff --git a/Foundation/CPSet/CPMutableSet.j b/Foundation/CPSet/CPMutableSet.j index f42bac3ed..850128589 100644 --- a/Foundation/CPSet/CPMutableSet.j +++ b/Foundation/CPSet/CPMutableSet.j @@ -1,149 +1,665 @@ -/*! - @class CPMutableSet - @ingroup compatability - - This class is just an empty subclass of CPSet. - CPSet already implements mutable methods and - this class only exists for source compatability. -*/ +/* + * CPMutableSet.j + * Foundation + * + * Core mutable subclass interface and Key-Value Observing proxy implementations. + */ @import "_CPSet.j" +/*! + @class CPMutableSet + @ingroup compatability + + This class is just an empty subclass of CPSet. + CPSet already implements mutable methods and + this class only exists for source compatibility. + */ @implementation CPMutableSet : CPSet /*! - Returns an initialized set with a given initial capacity. - @param aCapacity, only present for compatability -*/ + Returns an initialized set with a given initial capacity. + @param aCapacity, only present for compatibility + */ - (id)initWithCapacity:(unsigned)aCapacity { - return [self init]; + return [self init]; } /*! - Creates and returns a set with a given initial capacity. - @param aCapacity, only present for compatability -*/ + Creates and returns a set with a given initial capacity. + @param aCapacity, only present for compatibility + */ + (id)setWithCapacity:(CPUInteger)aCapacity { - return [[self alloc] initWithCapacity:aCapacity]; + return [[self alloc] initWithCapacity:aCapacity]; } /*! - Returns a set filtered using a given predicate. - @prarm aPredicate a CPPredicate object used to filter the objects in the set. -*/- (void)filterUsingPredicate:(CPPredicate)aPredicate + Returns a set filtered using a given predicate. + @prarm aPredicate a CPPredicate object used to filter the objects in the set. + */ +- (void)filterUsingPredicate:(CPPredicate)aPredicate { - var object, - objectEnumerator = [self objectEnumerator]; + var object, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - if (![aPredicate evaluateWithObject:object]) - [self removeObject:object]; + while ((object = [objectEnumerator nextObject]) != nil) + { + if (![aPredicate evaluateWithObject:object]) + { + [self removeObject:object]; + } + } } /*! - Removes an object from the set. - @param anObject the object to remove from the set. If the object is not in the set, the method will not modify the set. -*/ + Removes an object from the set. + @param anObject the object to remove from the set. If the object is not in the set, the method will not modify the set. + */ - (void)removeObject:(id)anObject { - _CPRaiseInvalidAbstractInvocation(self, _cmd); + _CPRaiseInvalidAbstractInvocation(self, _cmd); } /*! - Removes an array of objects from the set. - @param anArray an array of object to remove from the set. -*/ + Removes an array of objects from the set. + @param anArray an array of object to remove from the set. + */ - (void)removeObjectsInArray:(CPArray)anArray { - var index = 0, - count = [anArray count]; + var index = 0, + count = [anArray count]; - for (; index < count; ++index) - [self removeObject:[anArray objectAtIndex:index]]; + for (; index < count; ++index) + { + [self removeObject:[anArray objectAtIndex:index]]; + } } /*! - Removes all the objects from the set. -*/ + Removes all the objects from the set. + */ - (void)removeAllObjects { - var object, - objectEnumerator = [self objectEnumerator]; + var object, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - [self removeObject:object]; + while ((object = [objectEnumerator nextObject]) != nil) + { + [self removeObject:object]; + } } /*! - Adds to the receiver each object contained in a given array that is not already a member. - @param array An array of objects to add to the receiver. -*/ + Adds to the receiver each object contained in a given array that is not already a member. + @param array An array of objects to add to the receiver. + */ - (void)addObjectsFromArray:(CPArray)objects { - var count = [objects count]; + var count = [objects count]; - while (count--) - [self addObject:objects[count]]; + while (count--) + { + [self addObject:objects[count]]; + } } /*! - Adds to the receiver each object contained in another given set - @param set The set of objects to add to the receiver. -*/ + Adds to the receiver each object contained in another given set + @param set The set of objects to add to the receiver. + */ - (void)unionSet:(CPSet)aSet { - var object, - objectEnumerator = [aSet objectEnumerator]; + var object, + objectEnumerator = [aSet objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - [self addObject:object]; + while ((object = [objectEnumerator nextObject]) != nil) + { + [self addObject:object]; + } } /*! - Removes from the receiver each object contained in another given set that is present in the receiver. - @param set The set of objects to remove from the receiver. -*/ + Removes from the receiver each object contained in another given set that is present in the receiver. + @param set The set of objects to remove from the receiver. + */ - (void)minusSet:(CPSet)aSet { - var object, - objectEnumerator = [aSet objectEnumerator]; + var object, + objectEnumerator = [aSet objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - [self removeObject:object]; + while ((object = [objectEnumerator nextObject]) != nil) + { + [self removeObject:object]; + } } /*! - Removes from the receiver each object that isn't a member of another given set. - @param set The set with which to perform the intersection. -*/ + Removes from the receiver each object that isn't a member of another given set. + @param set The set with which to perform the intersection. + */ - (void)intersectSet:(CPSet)aSet { - var object, - objectEnumerator = [self objectEnumerator], - objectsToRemove = []; + var object, + objectEnumerator = [self objectEnumerator], + objectsToRemove = []; - while ((object = [objectEnumerator nextObject]) != nil) - if (![aSet containsObject:object]) - objectsToRemove.push(object); + while ((object = [objectEnumerator nextObject]) != nil) + { + if (![aSet containsObject:object]) + { + objectsToRemove.push(object); + } + } - var count = [objectsToRemove count]; + var count = [objectsToRemove count]; - while (count--) - [self removeObject:objectsToRemove[count]]; + while (count--) + { + [self removeObject:objectsToRemove[count]]; + } } /*! - Empties the receiver, then adds to the receiver each object contained in another given set. - @param set The set whose members replace the receiver's content. -*/ + Empties the receiver, then adds to the receiver each object contained in another given set. + @param set The set whose members replace the receiver's content. + */ - (void)setSet:(CPSet)aSet { - [self removeAllObjects]; - [self unionSet:aSet]; + [self removeAllObjects]; + [self unionSet:aSet]; } @end -//@import "_CPConcreteMutableSet.j" +// MARK: - +// MARK: Category: CPKeyValueCoding + +@implementation CPSet (CPKeyValueCoding) + +- (id)valueForKeyPath:(CPString)aKeyPath +{ + if (!aKeyPath) + { + [self valueForUndefinedKey:@""]; + } + + if (aKeyPath.charAt(0) === "@") + { + var dotIndex = aKeyPath.indexOf("."), + operator, + parameter; + + if (dotIndex !== -1) + { + operator = aKeyPath.substring(1, dotIndex); + parameter = aKeyPath.substring(dotIndex + 1); + } + else + { + operator = aKeyPath.substring(1); + } + + return [_CPCollectionKVCOperator performOperation:operator withCollection:self propertyPath:parameter]; + } + else + { + var valuesForKeySet = [CPSet set], + containedObject, + containedObjectValue, + containedObjectEnumerator = [self objectEnumerator]; + + while ((containedObject = [containedObjectEnumerator nextObject]) != nil) + { + containedObjectValue = [containedObject valueForKeyPath:aKeyPath]; + + if (containedObjectValue == nil) + { + containedObjectValue = [CPNull null]; + } + + [valuesForKeySet addObject:containedObjectValue]; + } + + return valuesForKeySet; + } +} + +- (id)valueForKey:(CPString)aKey +{ + // If the key starts with @, it is an operator path. + // If not, it is a property path that we want applied to all members. + // In either case, valueForKeyPath: handles both scenarios correctly. + return [self valueForKeyPath:aKey]; +} + +- (void)setValue:(id)aValue forKey:(CPString)aKey +{ + var containedObject, + containedObjectEnumerator = [self objectEnumerator]; + + while ((containedObject = [containedObjectEnumerator nextObject]) != nil) + { + [containedObject setValue:aValue forKey:aKey]; + } +} + +@end + +// MARK: - +// MARK: Key-Value Observing Extensions + +@implementation CPObject (CPSetKVO) + +- (id)mutableSetValueForKey:(id)aKey +{ + return [[_CPKVCSet alloc] initWithKey:aKey forProxyObject:self]; +} + +- (id)mutableSetValueForKeyPath:(id)aKeyPath +{ + var dotIndex = aKeyPath.indexOf("."); + + if (dotIndex < 0) + { + return [self mutableSetValueForKey:aKeyPath]; + } + + var firstPart = aKeyPath.substring(0, dotIndex), + lastPart = aKeyPath.substring(dotIndex + 1); + + return [[self valueForKeyPath:firstPart] mutableSetValueForKeyPath:lastPart]; +} + +@end + +// MARK: - +// MARK: Key-Value Observing Proxy Implementation + +@implementation _CPKVCSet : CPMutableSet +{ + id _proxyObject; + id _key; + + SEL _accessSEL; + Function _access; + + SEL _setSEL; + Function _set; + + SEL _countSEL; + Function _count; + + SEL _enumeratorSEL; + Function _enumerator; + + SEL _memberSEL; + Function _member; + + SEL _addSEL; + Function _add; + + SEL _addManySEL; + Function _addMany; + + SEL _removeSEL; + Function _remove; + + SEL _removeManySEL; + Function _removeMany; + + SEL _intersectSEL; + Function _intersect; +} + ++ (id)alloc +{ + var set = [CPMutableSet set]; + + set.isa = self; + + var ivars = class_copyIvarList(self), + count = ivars.length; + + while (count--) + { + set[ivar_getName(ivars[count])] = nil; + } + + return set; +} + +- (id)initWithKey:(id)aKey forProxyObject:(id)anObject +{ + self = [super init]; + + _key = aKey; + _proxyObject = anObject; + + var capitalizedKey = _key.charAt(0).toUpperCase() + _key.substring(1); + + _accessSEL = sel_getName(_key); + if ([_proxyObject respondsToSelector:_accessSEL]) + { + _access = [_proxyObject methodForSelector:_accessSEL]; + } + + _setSEL = sel_getName(@"set" + capitalizedKey + ":"); + if ([_proxyObject respondsToSelector:_setSEL]) + { + _set = [_proxyObject methodForSelector:_setSEL]; + } + + _countSEL = sel_getName(@"countOf" + capitalizedKey); + if ([_proxyObject respondsToSelector:_countSEL]) + { + _count = [_proxyObject methodForSelector:_countSEL]; + } + + _enumeratorSEL = sel_getName(@"enumeratorOf" + capitalizedKey); + if ([_proxyObject respondsToSelector:_enumeratorSEL]) + { + _enumerator = [_proxyObject methodForSelector:_enumeratorSEL]; + } + + _memberSEL = sel_getName(@"memberOf" + capitalizedKey + ":"); + if ([_proxyObject respondsToSelector:_memberSEL]) + { + _member = [_proxyObject methodForSelector:_memberSEL]; + } + + _addSEL = sel_getName(@"add" + capitalizedKey + "Object:"); + if ([_proxyObject respondsToSelector:_addSEL]) + { + _add = [_proxyObject methodForSelector:_addSEL]; + } + + _addManySEL = sel_getName(@"add" + capitalizedKey + ":"); + if ([_proxyObject respondsToSelector:_addManySEL]) + { + _addMany = [_proxyObject methodForSelector:_addManySEL]; + } + + _removeSEL = sel_getName(@"remove" + capitalizedKey + "Object:"); + if ([_proxyObject respondsToSelector:_removeSEL]) + { + _remove = [_proxyObject methodForSelector:_removeSEL]; + } + + _removeManySEL = sel_getName(@"remove" + capitalizedKey + ":"); + if ([_proxyObject respondsToSelector:_removeManySEL]) + { + _removeMany = [_proxyObject methodForSelector:_removeManySEL]; + } + + _intersectSEL = sel_getName(@"intersect" + capitalizedKey + ":"); + if ([_proxyObject respondsToSelector:_intersectSEL]) + { + _intersect = [_proxyObject methodForSelector:_intersectSEL]; + } + + return self; +} + +- (id)_representedObject +{ + if (_access) + { + return _access(_proxyObject, _accessSEL); + } + + return [_proxyObject valueForKey:_key]; +} + +- (void)_setRepresentedObject:(id)anObject +{ + if (_set) + { + return _set(_proxyObject, _setSEL, anObject); + } + + [_proxyObject setValue:anObject forKey:_key]; +} + +- (CPUInteger)count +{ + if (_count) + { + return _count(_proxyObject, _countSEL); + } + + return [[self _representedObject] count]; +} + +- (CPEnumerator)objectEnumerator +{ + if (_enumerator) + { + return _enumerator(_proxyObject, _enumeratorSEL); + } + + return [[self _representedObject] objectEnumerator]; +} + +- (id)member:(id)anObject +{ + if (_member) + { + return _member(_proxyObject, _memberSEL, anObject); + } + + return [[self _representedObject] member:anObject]; +} + +- (void)addObject:(id)anObject +{ + if (_add) + { + _add(_proxyObject, _addSEL, anObject); + } + else if (_addMany) + { + var objectSet = [CPSet setWithObject:anObject]; + _addMany(_proxyObject, _addManySEL, objectSet); + } + else + { + var target = [[self _representedObject] copy]; + [target addObject:anObject]; + [self _setRepresentedObject:target]; + } +} + +- (void)addObjectsFromArray:(CPArray)objects +{ + if (_addMany) + { + var objectSet = [CPSet setWithArray:objects]; + _addMany(_proxyObject, _addManySEL, objectSet); + } + else if (_add) + { + var object, + objectEnumerator = [objects objectEnumerator]; + + while ((object = [objectEnumerator nextObject]) != nil) + { + _add(_proxyObject, _addSEL, object); + } + } + else + { + var target = [[self _representedObject] copy]; + [target addObjectsFromArray:objects]; + [self _setRepresentedObject:target]; + } +} + +- (void)unionSet:(CPSet)aSet +{ + if (_addMany) + { + _addMany(_proxyObject, _addManySEL, aSet); + } + else if (_add) + { + var object, + objectEnumerator = [aSet objectEnumerator]; + + while ((object = [objectEnumerator nextObject]) != nil) + { + _add(_proxyObject, _addSEL, object); + } + } + else + { + var target = [[self _representedObject] copy]; + [target unionSet:aSet]; + [self _setRepresentedObject:target]; + } +} + +- (void)removeObject:(id)anObject +{ + if (_remove) + { + _remove(_proxyObject, _removeSEL, anObject); + } + else if (_removeMany) + { + var objectSet = [CPSet setWithObject:anObject]; + _removeMany(_proxyObject, _removeManySEL, objectSet); + } + else + { + var target = [[self _representedObject] copy]; + [target removeObject:anObject]; + [self _setRepresentedObject:target]; + } +} + +- (void)minusSet:(CPSet)aSet +{ + if (_removeMany) + { + _removeMany(_proxyObject, _removeManySEL, aSet); + } + else if (_remove) + { + var object, + objectEnumerator = [aSet objectEnumerator]; + + while ((object = [objectEnumerator nextObject]) != nil) + { + _remove(_proxyObject, _removeSEL, object); + } + } + else + { + var target = [[self _representedObject] copy]; + [target minusSet:aSet]; + [self _setRepresentedObject:target]; + } +} + +- (void)removeObjectsInArray:(CPArray)objects +{ + if (_removeMany) + { + var objectSet = [CPSet setWithArray:objects]; + _removeMany(_proxyObject, _removeManySEL, objectSet); + } + else if (_remove) + { + var object, + objectEnumerator = [objects objectEnumerator]; + + while ((object = [objectEnumerator nextObject]) != nil) + { + _remove(_proxyObject, _removeSEL, object); + } + } + else + { + var target = [[self _representedObject] copy]; + [target removeObjectsInArray:objects]; + [self _setRepresentedObject:target]; + } +} + +- (void)removeAllObjects +{ + if (_removeMany) + { + var allObjectsSet = [[self _representedObject] copy]; + _removeMany(_proxyObject, _removeManySEL, allObjectsSet); + } + else if (_remove) + { + var object, + objectEnumerator = [[[self _representedObject] copy] objectEnumerator]; + + while ((object = [objectEnumerator nextObject]) != nil) + { + _remove(_proxyObject, _removeSEL, object); + } + } + else + { + var target = [[self _representedObject] copy]; + [target removeAllObjects]; + [self _setRepresentedObject:target]; + } +} + +- (void)intersectSet:(CPSet)aSet +{ + if (_intersect) + { + _intersect(_proxyObject, _intersectSEL, aSet); + } + else + { + var target = [[self _representedObject] copy]; + [target intersectSet:aSet]; + [self _setRepresentedObject:target]; + } +} + +- (void)setSet:(CPSet)set +{ + [self _setRepresentedObject:set]; +} + +- (CPArray)allObjects +{ + return [[self _representedObject] allObjects]; +} + +- (id)anyObject +{ + return [[self _representedObject] anyObject]; +} + +- (BOOL)containsObject:(id)anObject +{ + return [[self _representedObject] containsObject:anObject]; +} + +- (BOOL)intersectsSet:(CPSet)aSet +{ + return [[self _representedObject] intersectsSet:aSet]; +} + +- (BOOL)isEqualToSet:(CPSet)aSet +{ + return [[self _representedObject] isEqualToSet:aSet]; +} + +- (id)copy +{ + return [[self _representedObject] copy]; +} + +@end diff --git a/Foundation/CPSet/_CPSet.j b/Foundation/CPSet/_CPSet.j index 92cb37f7f..64849c35d 100644 --- a/Foundation/CPSet/_CPSet.j +++ b/Foundation/CPSet/_CPSet.j @@ -12,493 +12,329 @@ * 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 "CPArray.j" @import "CPEnumerator.j" +@import "CPException.j" +@import "CPNull.j" @import "CPNumber.j" @import "CPObject.j" +@import "_CPCollectionKVCOperators.j" @class _CPConcreteMutableSet /*! - @class CPMutableSet - @ingroup Foundation - - CPSet is a data structure for storing an an unordered collection of unique objects. - Sets have O(1) insertion/lookup/deletion time complexity. -*/ - + @class CPSet + @ingroup Foundation + */ @implementation CPSet : CPObject { } + (id)alloc { - if (self === [CPSet class] || self === [CPMutableSet class]) - return [_CPPlaceholderSet alloc]; + if (self === [CPSet class] || self === [CPMutableSet class]) + return [_CPPlaceholderSet alloc]; - return [super alloc]; + return [super alloc]; } -/*! - Creates and returns an empty set. -*/ + (id)set { - return [[self alloc] init]; + return [[self alloc] init]; } -/*! - Creates and returns a set containing a uniqued collection of those objects contained in a given array. - @param anArray array containing the objects to add to the new set. If the same object appears more than once objects, it is added only once to the returned set. -*/ + (id)setWithArray:(CPArray)anArray { - return [[self alloc] initWithArray:anArray]; + return [[self alloc] initWithArray:anArray]; } -/*! - Creates and returns a set that contains a single given object. - @param anObject The object to add to the new set. -*/ + (id)setWithObject:(id)anObject { - return [[self alloc] initWithObjects:anObject]; + return [[self alloc] initWithObjects:anObject]; } -/*! - Creates and returns a set containing a specified number of objects from a given array of objects. - @param objects A array of objects to add to the new set. If the same object appears more than once objects, it is added only once to the returned set. - @param count The number of objects from objects to add to the new set. -*/ + (id)setWithObjects:(id)objects count:(CPUInteger)count { - return [[self alloc] initWithObjects:objects count:count]; + return [[self alloc] initWithObjects:objects count:count]; } -/*! - Creates and returns a set containing the objects in a given argument list. - @param anObject The first object to add to the new set. - @param ... A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once objects, it is added only once to the returned set. -*/ + (id)setWithObjects:(id)anObject, ... { - var argumentsArray = Array.prototype.slice.apply(arguments); + var argumentsArray = Array.prototype.slice.apply(arguments); - argumentsArray[0] = [self alloc]; - argumentsArray[1] = @selector(initWithObjects:); + argumentsArray[0] = [self alloc]; + argumentsArray[1] = @selector(initWithObjects:); - return objj_msgSend.apply(this, argumentsArray); + return objj_msgSend.apply(this, argumentsArray); } -/*! - Creates and returns a set containing the objects from another set. - @param aSet A set containing the objects to add to the new set. -*/ + (id)setWithSet:(CPSet)set { - return [[self alloc] initWithSet:set]; + return [[self alloc] initWithSet:set]; } -/*! - Creates and returns a set by adding anObject. - @param anObject to add to the new set. -*/ - (id)setByAddingObject:(id)anObject { - return [[self class] setWithArray:[[self allObjects] arrayByAddingObject:anObject]]; + return [[self class] setWithArray:[[self allObjects] arrayByAddingObject:anObject]]; } -/*! - Creates and returns a set by adding the objects from another set. - @param aSet to add objects to add to the new set. -*/ - (id)setByAddingObjectsFromSet:(CPSet)aSet { - return [self setByAddingObjectsFromArray:[aSet allObjects]]; + return [self setByAddingObjectsFromArray:[aSet allObjects]]; } -/*! - Creates and returns a set by adding the objects from an array. - @param anArray with objects to add to a new set. -*/ - (id)setByAddingObjectsFromArray:(CPArray)anArray { - return [[self class] setWithArray:[[self allObjects] arrayByAddingObjectsFromArray:anArray]]; + return [[self class] setWithArray:[[self allObjects] arrayByAddingObjectsFromArray:anArray]]; } -/*! - Basic initializer, returns an empty set. -*/ - (id)init { - return [self initWithObjects:nil count:0]; + return [self initWithObjects:nil count:0]; } -/*! - Initializes a newly allocated set with the objects that are contained in a given array. - @param array An array of objects to add to the new set. If the same object appears more than once in array, it is represented only once in the returned set. -*/ - (id)initWithArray:(CPArray)anArray { - return [self initWithObjects:anArray count:[anArray count]]; + return [self initWithObjects:anArray count:[anArray count]]; } -/*! - Initializes a newly allocated set with members taken from the specified list of objects. - @param anObject The first object to add to the new set. - @param ... A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once in the list, it is represented only once in the returned set. -*/ - (id)initWithObjects:(id)anObject, ... { - var index = 2, - count = arguments.length; + var index = 2, + count = arguments.length; - for (; index < count; ++index) - if (arguments[index] === nil) - break; + for (; index < count; ++index) + if (arguments[index] === nil) + break; - return [self initWithObjects:Array.prototype.slice.call(arguments, 2, index) count:index - 2]; + return [self initWithObjects:Array.prototype.slice.call(arguments, 2, index) count:index - 2]; } -/*! - Creates and returns a set containing the objects from an array. - @param anArray An array containing the objects to add to the new set. - @param aCount the number of objects in anArray. -*/ - (id)initWithObjects:(CPArray)objects count:(CPUInteger)aCount { - if (self === _CPSharedPlaceholderSet) - return [[_CPConcreteMutableSet alloc] initWithObjects:objects count:aCount]; + if (self === _CPSharedPlaceholderSet) + return [[_CPConcreteMutableSet alloc] initWithObjects:objects count:aCount]; - return [super init]; + return [super init]; } -/*! - Initializes a newly allocated set and adds to it objects from another given set. - @param aSet a set containing objects to add to the new set. -*/ - (id)initWithSet:(CPSet)aSet { - return [self initWithArray:[aSet allObjects]]; + return [self initWithArray:[aSet allObjects]]; } -/*! - Initializes a newly allocated set and adds to it members of another given set. Only included for compatability. - @param aSet a set of objects to add to the new set. - @param shouldCopyItems a boolean value. If YES the objects would be copied, if NO the objects will not be copied. -*/ - (id)initWithSet:(CPSet)aSet copyItems:(BOOL)shouldCopyItems { - if (shouldCopyItems) - return [aSet valueForKey:@"copy"]; + if (shouldCopyItems) + return [aSet valueForKey:@"copy"]; - return [self initWithSet:aSet]; + return [self initWithSet:aSet]; } -/*! - Returns the number of members in the receiver. -*/ - (CPUInteger)count { - _CPRaiseInvalidAbstractInvocation(self, _cmd); + _CPRaiseInvalidAbstractInvocation(self, _cmd); } -/*! - Returns an array containing the receiver’s members, or an empty array if the receiver has no members. -*/ - (CPArray)allObjects { - var objects = [], - object, - objectEnumerator = [self objectEnumerator]; + var objects = [], + object, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - objects.push(object); + while ((object = [objectEnumerator nextObject]) != nil) + objects.push(object); - return objects; + return objects; } -/*! - Returns one of the objects in the receiver, or nil if the receiver contains no objects. -*/ - (id)anyObject { - return [[self objectEnumerator] nextObject]; + return [[self objectEnumerator] nextObject]; } -/*! - Returns a Boolean value that indicates whether a given object is present in the receiver. - @param anObject The object for which to test membership of the receiver. -*/ - (BOOL)containsObject:(id)anObject { - return [self member:anObject] != nil; + return [self member:anObject] != nil; } -/*! - Returns a set filtered using a given predicate. - @prarm aPredicate a CPPredicate object used to filter the objects in the set. -*/ - (CPSet)filteredSetUsingPredicate:(CPPredicate)aPredicate { - var objects = [], - object, - objectEnumerator = [self objectEnumerator]; + var objects = [], + object, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - if ([aPredicate evaluateWithObject:object]) - objects.push(object); + while ((object = [objectEnumerator nextObject]) != nil) + if ([aPredicate evaluateWithObject:object]) + objects.push(object); - return [[[self class] alloc] initWithArray:objects]; + return [[[self class] alloc] initWithArray:objects]; } -/*! - Sends to each object in the receiver a message specified by a given selector. - @param aSelector A selector that specifies the message to send to the members of the receiver. The method must not take any arguments. It should not have the side effect of modifying the receiver. This value must not be NULL. -*/ - (void)makeObjectsPerformSelector:(SEL)aSelector { - [self makeObjectsPerformSelector:aSelector withObjects:nil]; + [self makeObjectsPerformSelector:aSelector withObjects:nil]; } -/*! - Sends to each object in the receiver a message specified by a given selector. - @param aSelector A selector that specifies the message to send to the receiver's members. The method must take a single argument of type id. The method should not, as a side effect, modify the receiver. The value must not be NULL. - @param anObject The object to pass as an argument to the method specified by aSelector. -*/ - (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject { - [self makeObjectsPerformSelector:aSelector withObjects:[anObject]]; + [self makeObjectsPerformSelector:aSelector withObjects:[anObject]]; } -/*! - Sends to each object in the receiver a message specified by a given selector. - @param aSelector A selector that specifies the message to send to the receiver's members. The method must take a single argument of type id. The method should not, as a side effect, modify the receiver. The value must not be NULL. - @param objects The objects to pass as an argument to the method specified by aSelector. -*/ - (void)makeObjectsPerformSelector:(SEL)aSelector withObjects:(CPArray)objects { - var object, - objectEnumerator = [self objectEnumerator], - argumentsArray = [nil, aSelector].concat(objects || []); + var object, + objectEnumerator = [self objectEnumerator], + argumentsArray = [nil, aSelector].concat(objects || []); - while ((object = [objectEnumerator nextObject]) != nil) - { - argumentsArray[0] = object; - objj_msgSend.apply(this, argumentsArray); - } + while ((object = [objectEnumerator nextObject]) != nil) + { + argumentsArray[0] = object; + objj_msgSend.apply(this, argumentsArray); + } } -/*! - Determines whether the receiver contains an object equal to a given object, and returns that object if it is present. - @param anObject The object for which to test for membership of the receiver. -*/ - (id)member:(id)anObject { - _CPRaiseInvalidAbstractInvocation(self, _cmd); + _CPRaiseInvalidAbstractInvocation(self, _cmd); } -/*! - Returns an object enumerator (CPEnumerator) for the receiver. -*/ - (CPEnumerator)objectEnumerator { - _CPRaiseInvalidAbstractInvocation(self, _cmd); + _CPRaiseInvalidAbstractInvocation(self, _cmd); } -/*! - Enumberates over the objects in a set using a given function. - @param aFunction a callback for each itteration, should be of the format: function(anObject, stop). -*/ -- (void)enumerateObjectsUsingBlock:(Function /*(id anObject, @ref BOOL stop)*/)aFunction +- (void)enumerateObjectsUsingBlock:(Function)aFunction { - var object, - objectEnumerator = [self objectEnumerator], - shouldStop = NO; + var object, + objectEnumerator = [self objectEnumerator], + shouldStop = NO; - while (!shouldStop && (object = [objectEnumerator nextObject]) != nil) { - if (aFunction(object, @ref(shouldStop)) !== undefined) { - throw "DEPRECATED: The method enumerateObjectsUsingBlock: does not support returning a value in the block to stop the iteration. Please use the stop variable"; - } - } + while (!shouldStop && (object = [objectEnumerator nextObject]) != nil) { + if (aFunction(object, @ref(shouldStop)) !== undefined) { + throw "DEPRECATED: The method enumerateObjectsUsingBlock: does not support returning a value in the block to stop the iteration."; + } + } } -// FIXME: stop is broken. - (CPSet)objectsPassingTest:(Function)aFunction { - var objects = [], - object = nil, - objectEnumerator = [self objectEnumerator]; + var objects = [], + object = nil, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - if (aFunction(object)) - objects.push(object); + while ((object = [objectEnumerator nextObject]) != nil) + if (aFunction(object)) + objects.push(object); - return [[[self class] alloc] initWithArray:objects]; + return [[[self class] alloc] initWithArray:objects]; } -/*! - Returns a Boolean value that indicates whether every object in the receiver is also present in another given set. - @param set The set with which to compare the receiver. -*/ - (BOOL)isSubsetOfSet:(CPSet)aSet { - var object = nil, - objectEnumerator = [self objectEnumerator]; + var object = nil, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - if (![aSet containsObject:object]) - return NO; + while ((object = [objectEnumerator nextObject]) != nil) + if (![aSet containsObject:object]) + return NO; - return YES; + return YES; } -/*! - Returns a Boolean value that indicates whether at least one object in the receiver is also present in another given set. - @param set The set with which to compare the receiver. -*/ - (BOOL)intersectsSet:(CPSet)aSet { - if (self === aSet) - // The empty set intersects nothing - return [self count] > 0; + if (self === aSet) + return [self count] > 0; - var object = nil, - objectEnumerator = [self objectEnumerator]; + var object = nil, + objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) != nil) - if ([aSet containsObject:object]) - return YES; + while ((object = [objectEnumerator nextObject]) != nil) + if ([aSet containsObject:object]) + return YES; - return NO; + return NO; } -/*! - Returns an array of the set's content sorted as specified by a given array of sort descriptors. - - @param sortDescriptors an array of CPSortDescriptor objects. -*/ - (CPArray)sortedArrayUsingDescriptors:(CPArray)someSortDescriptors { - return [[self allObjects] sortedArrayUsingDescriptors:someSortDescriptors]; + return [[self allObjects] sortedArrayUsingDescriptors:someSortDescriptors]; } -/*! - Compares the receiver to another set. - @param set The set with which to compare the receiver. -*/ - (BOOL)isEqualToSet:(CPSet)aSet { - return [self isEqual:aSet]; + return [self isEqual:aSet]; } -/*! - Returns YES if BOTH sets are a subset of the other. - @param aSet a set of objects -*/ - (BOOL)isEqual:(CPSet)aSet { - // If both are subsets of each other, they are equal - return self === aSet || - [aSet isKindOfClass:[CPSet class]] && - ([self count] === [aSet count] && - [aSet isSubsetOfSet:self]); + return self === aSet || + [aSet isKindOfClass:[CPSet class]] && + ([self count] === [aSet count] && + [aSet isSubsetOfSet:self]); } - (CPString)description { - var string = "{(\n", - objects = [self allObjects], - index = 0, - count = [objects count]; + var string = "{(\n", + objects = [self allObjects], + index = 0, + count = [objects count]; - for (; index < count; ++index) - { - var object = objects[index]; + for (; index < count; ++index) + { + var object = objects[index]; + string += "\t" + String(object).split('\n').join("\n\t") + "\n"; + } - string += "\t" + String(object).split('\n').join("\n\t") + "\n"; - } - - return string + ")}"; + return string + ")}"; } @end +// MARK: - +// MARK: Category: CPCopying + @implementation CPSet (CPCopying) - (id)copy { - return [[self class] setWithSet:self]; + return [[self class] setWithSet:self]; } - (id)mutableCopy { - return [self copy]; + return [self copy]; } @end +// MARK: - +// MARK: Category: CPCoding + var CPSetObjectsKey = @"CPSetObjectsKey"; @implementation CPSet (CPCoding) - (id)initWithCoder:(CPCoder)aCoder { - return [self initWithArray:[aCoder decodeObjectForKey:CPSetObjectsKey]]; + return [self initWithArray:[aCoder decodeObjectForKey:CPSetObjectsKey]]; } - (void)encodeWithCoder:(CPCoder)aCoder { - [aCoder encodeObject:[self allObjects] forKey:CPSetObjectsKey]; + [aCoder encodeObject:[self allObjects] forKey:CPSetObjectsKey]; } @end -@implementation CPSet (CPKeyValueCoding) +// MARK: - +// MARK: Private Allocation Placeholder -- (id)valueForKey:(CPString)aKey -{ - if (aKey === "@count") - return [self count]; - - var valueSet = [CPSet set], - object, - objectEnumerator = [self objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - { - var value = [object valueForKey:aKey]; - - [valueSet addObject:value]; - } - - return valueSet; -} - -- (void)setValue:(id)aValue forKey:(CPString)aKey -{ - var object, - objectEnumerator = [self objectEnumerator]; - - while ((object = [objectEnumerator nextObject]) != nil) - [object setValue:aValue forKey:aKey]; -} - -@end - -var _CPSharedPlaceholderSet = nil; +var _CPSharedPlaceholderSet = nil; @implementation _CPPlaceholderSet : CPSet { @@ -506,14 +342,10 @@ var _CPSharedPlaceholderSet = nil; + (id)alloc { - if (!_CPSharedPlaceholderSet) - _CPSharedPlaceholderSet = [super alloc]; + if (!_CPSharedPlaceholderSet) + _CPSharedPlaceholderSet = [super alloc]; - return _CPSharedPlaceholderSet; + return _CPSharedPlaceholderSet; } @end - -// We actually want _CPConcreteMutableSet, but this introduces the possibility of an invalid @import loop. -// This will be correctly solved when we move to true immutable/mutable pairs. -//@import "CPMutableSet.j" diff --git a/Foundation/CPString.j b/Foundation/CPString.j index e642bab49..b4413ddaf 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -20,17 +20,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import "CPException.j" @import "CPObject.j" @import "CPObjJRuntime.j" @import "CPRange.j" -@import "CPSortDescriptor.j" -@import "CPURL.j" @import "CPValue.j" @import "CPNull.j" @class CPException @class CPURL +@class CPSortDescriptor @global CPInvalidArgumentException @global CPRangeException diff --git a/Foundation/CPTimeZone.j b/Foundation/CPTimeZone.j index add2aace3..9521012ca 100644 --- a/Foundation/CPTimeZone.j +++ b/Foundation/CPTimeZone.j @@ -377,8 +377,8 @@ function _abbreviationForNameAndDate(tzName, date) } -#pragma mark - -#pragma mark Class constructor +// MARK: - +// MARK: Class constructor /*! Returns a time zone from the given abbreviation. Returns nil if the given abbreviation doesn't match with any abbreviations @@ -482,8 +482,8 @@ function _abbreviationForNameAndDate(tzName, date) return array; } -#pragma mark - -#pragma mark Class accessors +// MARK: - +// MARK: Class accessors /*! Return the timeZoneDataVersion (not yet implemented) */ @@ -558,8 +558,8 @@ function _abbreviationForNameAndDate(tzName, date) } -#pragma mark - -#pragma mark Consructors +// MARK: - +// MARK: Consructors /*! Init a new time zone with the given time zone name and abbreviation Returns nil if tzName doesn't match with any timeZoneNames or if abbreviation is nil @@ -658,8 +658,8 @@ function _abbreviationForNameAndDate(tzName, date) } -#pragma mark - -#pragma mark Methods for CPDate +// MARK: - +// MARK: Methods for CPDate /*! Returns the abbreviation from a date Returns nil if the date is nil @@ -697,8 +697,8 @@ function _abbreviationForNameAndDate(tzName, date) } -#pragma mark - -#pragma mark Compars methods +// MARK: - +// MARK: Compars methods /*! Returns a bool to compare tow timeZones. This is made by the compare of the name and the data of the timeZones @@ -710,8 +710,8 @@ function _abbreviationForNameAndDate(tzName, date) } -#pragma mark - -#pragma mark Description +// MARK: - +// MARK: Description /*! Returns the description of the timeZone The pattern of the description is : 'name of the timeZone' ('abbreviation of the timeZone') offset 'the timeDifferenceFromGMT' @@ -723,8 +723,8 @@ function _abbreviationForNameAndDate(tzName, date) } -#pragma mark - -#pragma mark Localized methods +// MARK: - +// MARK: Localized methods /*! Return a localized string from the given style and locale @param style the style diff --git a/Foundation/CPUserDefaults.j b/Foundation/CPUserDefaults.j index 8bc23bcf3..6751183d8 100644 --- a/Foundation/CPUserDefaults.j +++ b/Foundation/CPUserDefaults.j @@ -381,7 +381,7 @@ var StandardUserDefaults; } } -#pragma mark Getting Default Values +// MARK: Getting Default Values /*! Returns the array value associated with the specified key. @@ -517,7 +517,7 @@ var StandardUserDefaults; return nil; } -#pragma mark Setting Default Values +// MARK: Setting Default Values /*! Sets the value of the specified default key to the specified Boolean value. diff --git a/Foundation/CPUserNotification.j b/Foundation/CPUserNotification.j index 4b3588ac6..80d6deb5c 100644 --- a/Foundation/CPUserNotification.j +++ b/Foundation/CPUserNotification.j @@ -91,8 +91,8 @@ CPUserNotificationActivationTypeAdditionalActionClicked = 4; } -#pragma mark - -#pragma mark Creating an user notification +// MARK: - +// MARK: Creating an user notification - (id)init { @@ -106,4 +106,4 @@ CPUserNotificationActivationTypeAdditionalActionClicked = 4; return self } -@end \ No newline at end of file +@end diff --git a/Foundation/CPUserNotificationCenter.j b/Foundation/CPUserNotificationCenter.j index 34800d940..be76ef7da 100644 --- a/Foundation/CPUserNotificationCenter.j +++ b/Foundation/CPUserNotificationCenter.j @@ -62,8 +62,8 @@ var CPUserNotificationDefaultCenter = nil; } -#pragma mark - -#pragma mark Creating Default User Notification Center +// MARK: - +// MARK: Creating Default User Notification Center /*! Returns the user's notification center @@ -91,8 +91,8 @@ var CPUserNotificationDefaultCenter = nil; } -#pragma mark - -#pragma mark Getting and Setting the Delegate +// MARK: - +// MARK: Getting and Setting the Delegate - (void)setDelegate:(id )aDelegate { @@ -113,8 +113,8 @@ var CPUserNotificationDefaultCenter = nil; } -#pragma mark - -#pragma mark Managing the Scheduled Notification Queue +// MARK: - +// MARK: Managing the Scheduled Notification Queue /*! Schedules the given user notification @@ -158,8 +158,8 @@ var CPUserNotificationDefaultCenter = nil; } -#pragma mark - -#pragma mark Managing the Delivered Notifications +// MARK: - +// MARK: Managing the Delivered Notifications /*! Deliver the given user notification @@ -188,8 +188,8 @@ var CPUserNotificationDefaultCenter = nil; } -#pragma mark - -#pragma mark Permission Utilities +// MARK: - +// MARK: Permission Utilities - (void)_askPermissionForUserNotification:(CPUserNotification)anUserNotification { @@ -201,8 +201,8 @@ var CPUserNotificationDefaultCenter = nil; } -#pragma mark - -#pragma mark Notification Utilities +// MARK: - +// MARK: Notification Utilities - (void)_launchUserNotification:(CPUserNotification)anUserNotification { @@ -290,4 +290,4 @@ var CPUserNotificationDefaultCenter = nil; [_delegate userNotificationCenter:self didDeliverNotification:aNotification]; } -@end \ No newline at end of file +@end diff --git a/Foundation/CPValue.j b/Foundation/CPValue.j index e19f5baa3..40d0aedc2 100644 --- a/Foundation/CPValue.j +++ b/Foundation/CPValue.j @@ -20,9 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@import "CPCoder.j" @import "CPObject.j" +@class CPCoder + /*! @class CPValue @ingroup foundation diff --git a/Objective-J/Preprocessor.js b/Objective-J/Preprocessor.js index 00c6f3326..8436fa787 100644 --- a/Objective-J/Preprocessor.js +++ b/Objective-J/Preprocessor.js @@ -377,7 +377,7 @@ Preprocessor.prototype.hash = function(tokens, aStringBuffer) { token = tokens.skip_whitespace(); - // '#pragma mark' directive is used in Xcode editor for creating labels, + // '// MARK:' directive is used in Xcode editor for creating labels, // which is irrelevant to Cappuccino - just swallow this line if (token === TOKEN_MARK) { diff --git a/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j b/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j index 67cc534b8..5279c9bc2 100644 --- a/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j +++ b/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j @@ -140,7 +140,7 @@ [self assert:[track volume] equals:[slider floatValue]]; } -#pragma mark ----- actions used by implementation 01 ----- +// MARK: ----- actions used by implementation 01 ----- - (void)updateVolumeFrom:(id)sender { @@ -161,7 +161,7 @@ [self updateUserInterface]; } -#pragma mark ----- actions used by implementation 02 and 03 ----- +// MARK: ----- actions used by implementation 02 and 03 ----- - (void)muteTrack:(id)sender { diff --git a/Tests/AppKit/CPTokenFieldTest.j b/Tests/AppKit/CPTokenFieldTest.j index 7b9be7051..49a32d9c4 100644 --- a/Tests/AppKit/CPTokenFieldTest.j +++ b/Tests/AppKit/CPTokenFieldTest.j @@ -31,8 +31,8 @@ } -#pragma mark - -#pragma mark Test creation +// MARK: - +// MARK: Test creation - (void)testArchiving { @@ -57,8 +57,8 @@ } -#pragma mark - -#pragma mark Test objectValue and stringValue +// MARK: - +// MARK: Test objectValue and stringValue /*! This is totally different than cocoa @@ -82,8 +82,8 @@ } -#pragma mark - -#pragma mark Delegate methods +// MARK: - +// MARK: Delegate methods - (void)testDelegateDisplayStringForRepresentedObject { diff --git a/Tests/Foundation/CPDateFormatterTest.j b/Tests/Foundation/CPDateFormatterTest.j index 863ec5054..2f88d1c96 100644 --- a/Tests/Foundation/CPDateFormatterTest.j +++ b/Tests/Foundation/CPDateFormatterTest.j @@ -52,8 +52,8 @@ } -#pragma mark - -#pragma mark Setter +// MARK: - +// MARK: Setter - (void)testSetterAMSymbol { @@ -163,8 +163,8 @@ [self assert:[_dateFormatter shortStandaloneQuarterSymbols] equals:[@"Hej hej"]]; } -#pragma mark - -#pragma mark string from date +// MARK: - +// MARK: string from date - (void)testLocalizedStringFromDate { @@ -446,8 +446,8 @@ } -#pragma mark - -#pragma mark Date From string +// MARK: - +// MARK: Date From string - (void)testDateFromStringToken { @@ -1328,8 +1328,8 @@ [self assert:error equals:@"The value \"ezr 12\" is invalid."]; } -#pragma mark - -#pragma mark non-en locales +// MARK: - +// MARK: non-en locales // Unless we have full locale support any non-supported locale should return the english values as they are the only defined ones at the moment. diff --git a/Tests/Manual/CPMarkdownParser/AppController.j b/Tests/Manual/CPMarkdownParser/AppController.j new file mode 100755 index 000000000..7edd61d6e --- /dev/null +++ b/Tests/Manual/CPMarkdownParser/AppController.j @@ -0,0 +1,178 @@ +/* + * AppController.j + * + * Markdown Live Viewer mit kollabiertem Rahmen-Layout und adaptiver Spalten-Projektion + */ + +@import +@import + +// --- MAIN CONTROLLER --- +@implementation AppController : CPObject +{ + CPTextView _markdownInputTextView; + CPTextView _markdownRenderTextView; + CPScrollView _inputScrollView; + CPScrollView _renderScrollView; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + [contentView setBackgroundColor:[CPColor colorWithWhite:0.95 alpha:1.0]]; + + // 1. Tool-Bar + var toolbarView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), 60)]; + [toolbarView setAutoresizingMask:CPViewWidthSizable]; + [toolbarView setBackgroundColor:[CPColor colorWithWhite:0.88 alpha:1.0]]; + [contentView addSubview:toolbarView]; + + var currentX = 15; + + var renderButton = [[CPButton alloc] initWithFrame:CGRectMake(currentX, 15, 140, 30)]; + [renderButton setTitle:@"Force Render"]; + [renderButton setTarget:self]; + [renderButton setAction:@selector(renderMarkdownAction:)]; + [toolbarView addSubview:renderButton]; + currentX += 150; + + var clearButton = [[CPButton alloc] initWithFrame:CGRectMake(currentX, 15, 100, 30)]; + [clearButton setTitle:@"Clear All"]; + [clearButton setTarget:self]; + [clearButton setAction:@selector(clearAction:)]; + [toolbarView addSubview:clearButton]; + + // 2. Workspace Split-View Layout + var splitView = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 60, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) - 60)]; + [splitView setVertical:YES]; + [splitView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + + var leftContainer = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([splitView bounds]) / 2, CGRectGetHeight([splitView bounds]))]; + [leftContainer setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + + var rightContainer = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([splitView bounds]) / 2, CGRectGetHeight([splitView bounds]))]; + [rightContainer setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + + [splitView addSubview:leftContainer]; + [splitView addSubview:rightContainer]; + [contentView addSubview:splitView]; + + // Split-Pane Größenänderung überwachen + [[CPNotificationCenter defaultCenter] addObserver:self + selector:@selector(splitViewDidResizeSubviews:) + name:CPSplitViewDidResizeSubviewsNotification + object:splitView]; + + // Linke Seite: Plain-Text Editor + var leftLabel = [[CPTextField alloc] initWithFrame:CGRectMake(15, 10, CGRectGetWidth([leftContainer bounds]) - 30, 20)]; + [leftLabel setStringValue:@"Markdown Editor (Plain Text)"]; + [leftLabel setFont:[CPFont boldSystemFontOfSize:14]]; + [leftLabel setAutoresizingMask:CPViewWidthSizable]; + [leftContainer addSubview:leftLabel]; + + _markdownInputTextView = [[CPTextView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([leftContainer bounds]) - 30, CGRectGetHeight([leftContainer bounds]) - 70)]; + [_markdownInputTextView setRichText:NO]; + [_markdownInputTextView setBackgroundColor:[CPColor whiteColor]]; + [_markdownInputTextView setDelegate:self]; + + [_markdownInputTextView setVerticallyResizable:YES]; + [_markdownInputTextView setHorizontallyResizable:NO]; + [_markdownInputTextView setAutoresizingMask:CPViewWidthSizable]; + [[_markdownInputTextView textContainer] setWidthTracksTextView:YES]; + + _inputScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(15, 40, CGRectGetWidth([leftContainer bounds]) - 30, CGRectGetHeight([leftContainer bounds]) - 65)]; + [_inputScrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + [_inputScrollView setDocumentView:_markdownInputTextView]; + [leftContainer addSubview:_inputScrollView]; + + // Rechte Seite: Formatted Rich-Text Viewer + var rightLabel = [[CPTextField alloc] initWithFrame:CGRectMake(15, 10, CGRectGetWidth([rightContainer bounds]) - 30, 20)]; + [rightLabel setStringValue:@"Formatted Output (Rich Text View)"]; + [rightLabel setFont:[CPFont boldSystemFontOfSize:14]]; + [rightLabel setAutoresizingMask:CPViewWidthSizable]; + [rightContainer addSubview:rightLabel]; + + _markdownRenderTextView = [[CPTextView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([rightContainer bounds]) - 30, CGRectGetHeight([rightContainer bounds]) - 70)]; + [_markdownRenderTextView setRichText:YES]; + [_markdownRenderTextView setEditable:YES]; + [_markdownRenderTextView setBackgroundColor:[CPColor whiteColor]]; + + [_markdownRenderTextView setVerticallyResizable:YES]; + [_markdownRenderTextView setHorizontallyResizable:NO]; + [_markdownRenderTextView setAutoresizingMask:CPViewWidthSizable]; + [[_markdownRenderTextView textContainer] setWidthTracksTextView:YES]; + + _renderScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(15, 40, CGRectGetWidth([rightContainer bounds]) - 30, CGRectGetHeight([rightContainer bounds]) - 65)]; + [_renderScrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + [_renderScrollView setDocumentView:_markdownRenderTextView]; + [rightContainer addSubview:_renderScrollView]; + + // 3. System Menü aufbauen + var mainMenu = [CPApp mainMenu]; + while ([mainMenu numberOfItems] > 0) + [mainMenu removeItemAtIndex:0]; + + var item = [mainMenu insertItemWithTitle:@"Edit" action:nil keyEquivalent:nil atIndex:0], + editMenu = [[CPMenu alloc] initWithTitle:@"Edit Menu"]; + + [editMenu addItemWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"]; + [editMenu addItemWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"]; + [editMenu addItemWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"]; + [editMenu addItemWithTitle:@"Select All" action:@selector(selectAll:) keyEquivalent:@"a"]; + [mainMenu setSubmenu:editMenu forItem:item]; + + [theWindow orderFront:self]; + [CPMenu setMenuBarVisible:YES]; + + // 4. Default-Startup-Markdown mit Ihrem Buchungsbeispiel (inkl. geschützten Trennzeichen und Emojis) + var startupMarkdown = @"**Aufenthalts\u2011Daten Ihrer Pierre\u202f&\u202fVacances\u2011Reservation (Rechnungs\u2011Nr\u202f23651325)** \n\n" + + @"| \uD83D\uDCC5\u202fCheck\u2011in\u2011Datum | \uD83D\uDCC5\u202fCheck\u2011out\u2011Datum | \uD83D\uDD22\u202fN\u00e4chte | \uD83C\uDFE0\u202fUnterkunft | \uD83D\uDCCD\u202fAdresse | \uD83D\uDC65\u202fG\u00e4ste (Erwachsene\u202f/\u202fKinder) | \u23f0\u202fAnkunftszeit | \u23f0\u202fAbreisezeit | \uD83D\uDCDD\u202fBemerkung |\n" + + @"|-------------------|--------------------|-----------|--------------|------------|-------------------------------|----------------|----------------|-------------|\n" + + @"| 27.\u202fMai\u202f2026 | 03.\u202fJuni\u202f2026 | 7 | **Les\u202fVillas\u202fd\u2019Olonne** \u2013 Premium\u2011Villas | 19\u202fRoute\u202fdes\u202fAmis\u202fde\u202fla\u202fNature, 85340\u202fLes\u202fSables\u2011de\u2011L\u2011Olonne | 2\u202fErwachsene\u202f/\u202f1\u202fKind | 17:00\u202f\u2013\u202f17:30 (je nach Vereinbarung) | 10:00\u202f\u2013\u202f10:30 (Fr\u00fchst\u00fcck inklusive) | Hotel\u2011Check\u2011in erfolgt in der Rezeption; Schl\u00fcssel werden bei Ankunft \u00fcbergeben. |\n" + + @"| | | | **Haus\u2011und\u2011Sammelbecken** | | | | | |\n" + + @"| **Hinweis** | | | | | | | | |\n\n" + + @"> **Kurz\u00fcbersicht** \n" + + @"> \u2022 7\u202fN\u00e4chte von 27\u202fMai bis 3\u202fJuni 2026 \n" + + @"> \u2022 2\u202fErwachsene und 1\u202fKind \n" + + @"> \u2022 Check\u2011in um 17:00\u202f\u2013\u202f17:30 Uhr, Check\u2011out um 10:00\u202f\u2013\u202f10:30 Uhr \n" + + @"> \u2022 Unterkunft: Premium\u2011Villas \u201eLes\u202fVillas\u202fd\u2019Olonne\u201c an der Adresse 19\u202fRoute\u202fdes\u202fAmis\u202fde\u202fla\u202fNature, 85340\u202fLes\u202fSables\u2011de\u2011L\u2011Olonne \n\n" + + @"Falls Sie noch weitere Details ben\u00f6tigen (z.\u202fB.\u202fZahlungsbedingungen, Rezeption\u2011Kontaktdaten, Reiseziel\u2011Informationen), lassen Sie es mich einfach wissen!"; + + [_markdownInputTextView setString:startupMarkdown]; + [self renderMarkdown]; +} + +- (void)textDidChange:(CPNotification)aNotification +{ + [self renderMarkdown]; +} + +- (void)splitViewDidResizeSubviews:(CPNotification)aNotification +{ + [self renderMarkdown]; +} + +- (void)renderMarkdownAction:(id)sender +{ + [self renderMarkdown]; +} + +- (void)clearAction:(id)sender +{ + [_markdownInputTextView setString:@""]; + [self renderMarkdown]; +} + +- (void)renderMarkdown +{ + var rawText = [_markdownInputTextView string]; + + if (!rawText) rawText = @""; + + var parsedAttrStr = [CPMarkdownParser attributedStringFromMarkdown:rawText]; + [_markdownRenderTextView setString:parsedAttrStr]; +} + +@end diff --git a/Tests/Manual/CPMarkdownParser/Info.plist b/Tests/Manual/CPMarkdownParser/Info.plist new file mode 100644 index 000000000..68f9e7d32 --- /dev/null +++ b/Tests/Manual/CPMarkdownParser/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + CPTextViewTest + CPPrincipalClass + CPApplication + + diff --git a/Tests/Manual/CPMarkdownParser/Jakefile b/Tests/Manual/CPMarkdownParser/Jakefile new file mode 100644 index 000000000..bd57b7a0d --- /dev/null +++ b/Tests/Manual/CPMarkdownParser/Jakefile @@ -0,0 +1,94 @@ +/* + * Jakefile + * CPLevelIndicator + * + * Created by Alexander Ljungberg on May 28, 2011. + * Copyright 2011, WireLoad All rights reserved. + */ + +var ENV = require("system").env, + FILE = require("file"), + JAKE = require("jake"), + task = JAKE.task, + FileList = JAKE.FileList, + app = require("cappuccino/jake").app, + configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", + OS = require("os"); + +app ("CPLevelIndicator", function(task) +{ + task.setBuildIntermediatesPath(FILE.join("Build", "CPLevelIndicator.build", configuration)); + task.setBuildPath(FILE.join("Build", configuration)); + + task.setProductName("CPLevelIndicator"); + task.setIdentifier("com.yourcompany.CPLevelIndicator"); + task.setVersion("1.0"); + task.setAuthor("WireLoad"); + task.setEmail("feedback @nospam@ yourcompany.com"); + task.setSummary("CPLevelIndicator"); + task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**"))); + task.setResources(new FileList("Resources/**")); + task.setIndexFilePath("index.html"); + task.setInfoPlistPath("Info.plist"); + task.setNib2CibFlags("-R Resources/"); + + if (configuration === "Debug") + task.setCompilerFlags("-DDEBUG -g"); + else + task.setCompilerFlags("-O"); +}); + +task ("default", ["CPLevelIndicator"], function() +{ + printResults(configuration); +}); + +task ("build", ["default"]); + +task ("debug", function() +{ + ENV["CONFIGURATION"] = "Debug"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("release", function() +{ + ENV["CONFIGURATION"] = "Release"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("run", ["debug"], function() +{ + OS.system(["open", FILE.join("Build", "Debug", "CPLevelIndicator", "index.html")]); +}); + +task ("run-release", ["release"], function() +{ + OS.system(["open", FILE.join("Build", "Release", "CPLevelIndicator", "index.html")]); +}); + +task ("deploy", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Deployment", "CPLevelIndicator")); + OS.system(["press", "-f", FILE.join("Build", "Release", "CPLevelIndicator"), FILE.join("Build", "Deployment", "CPLevelIndicator")]); + printResults("Deployment") +}); + +task ("desktop", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Desktop", "CPLevelIndicator")); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPLevelIndicator"), FILE.join("Build", "Desktop", "CPLevelIndicator", "CPLevelIndicator.app")); + printResults("Desktop") +}); + +task ("run-desktop", ["desktop"], function() +{ + OS.system([FILE.join("Build", "Desktop", "CPLevelIndicator", "CPLevelIndicator.app", "Contents", "MacOS", "NativeHost"), "-i"]); +}); + +function printResults(configuration) +{ + print("----------------------------"); + print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPLevelIndicator")); + print("----------------------------"); +} diff --git a/Tests/Manual/CPMarkdownParser/Resources/spinner.gif b/Tests/Manual/CPMarkdownParser/Resources/spinner.gif new file mode 100644 index 000000000..a5e705f6c Binary files /dev/null and b/Tests/Manual/CPMarkdownParser/Resources/spinner.gif differ diff --git a/Tests/Manual/CPMarkdownParser/index-debug.html b/Tests/Manual/CPMarkdownParser/index-debug.html new file mode 100644 index 000000000..1097bcf1b --- /dev/null +++ b/Tests/Manual/CPMarkdownParser/index-debug.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + CPLevelIndicator + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + diff --git a/Tests/Manual/CPMarkdownParser/index.html b/Tests/Manual/CPMarkdownParser/index.html new file mode 100644 index 000000000..5a58b20d8 --- /dev/null +++ b/Tests/Manual/CPMarkdownParser/index.html @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + __project.name__ + + + + + + + + + + + + +
+
+
+ +
+
+ +
+ + diff --git a/Tests/Manual/CPMarkdownParser/main.j b/Tests/Manual/CPMarkdownParser/main.j new file mode 100644 index 000000000..7c4ea4fe9 --- /dev/null +++ b/Tests/Manual/CPMarkdownParser/main.j @@ -0,0 +1,16 @@ +/* + * AppController.j + * CPLevelIndicator + * + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +} diff --git a/Tests/Manual/CPPlatformWindow/AppController.j b/Tests/Manual/CPPlatformWindow/AppController.j index 367d498bc..9f68ad5d5 100644 --- a/Tests/Manual/CPPlatformWindow/AppController.j +++ b/Tests/Manual/CPPlatformWindow/AppController.j @@ -76,8 +76,8 @@ } -#pragma mark - -#pragma mark Delegate +// MARK: - +// MARK: Delegate - (void)windowDidBecomeKey:(CPNotification)aNotification { diff --git a/Tests/Manual/CPPopover/AppController.j b/Tests/Manual/CPPopover/AppController.j index b96998380..18d7151c9 100644 --- a/Tests/Manual/CPPopover/AppController.j +++ b/Tests/Manual/CPPopover/AppController.j @@ -226,8 +226,8 @@ [aPopover setAppearance:appearance]; } -#pragma mark - -#pragma mark CPPopover Delegate +// MARK: - +// MARK: CPPopover Delegate - (void)popoverWillShow:(CPPopover)aPopover { diff --git a/Tests/Manual/CPStackViewTest/AppController.j b/Tests/Manual/CPStackViewTest/AppController.j index 05db03974..a455705e5 100644 --- a/Tests/Manual/CPStackViewTest/AppController.j +++ b/Tests/Manual/CPStackViewTest/AppController.j @@ -141,8 +141,8 @@ // If we were using a Cib, initialization would happen here. } -#pragma mark - -#pragma mark Actions +// MARK: - +// MARK: Actions - (@action)toggleHidden:(id)sender { @@ -183,8 +183,8 @@ [stackViewHorizontal setSpacing:(current >= 20.0 ? 8.0 : current + 4.0)]; } -#pragma mark - -#pragma mark Helpers +// MARK: - +// MARK: Helpers - (CPView)_createBoxColor:(CPColor)aColor size:(CGSize)aSize label:(CPString)text { diff --git a/Tests/Manual/ScalingTest2/AppController.j b/Tests/Manual/ScalingTest2/AppController.j index 39e67cfef..6278aa2c2 100644 --- a/Tests/Manual/ScalingTest2/AppController.j +++ b/Tests/Manual/ScalingTest2/AppController.j @@ -33,7 +33,7 @@ [[self scrollView] setDocumentView:pagePreview]; } -#pragma mark - Window delegate methods +// MARK: - Window delegate methods - (CGSize)windowWillResize:(CPWindow)theWindow toSize:(CPSize)frameSize { if (![self pagePreviewBox])