Merge pull request #2266 from zittix/patch-2

Docs: fixed bootstrap.sh URL due to github URL change
This commit is contained in:
Alexander Ljungberg
2014-11-28 23:20:59 +00:00
108 changed files with 999 additions and 299 deletions
+49 -48
View File
@@ -44,6 +44,7 @@
var CPAlertDelegate_alertShowHelp_ = 1 << 0,
CPAlertDelegate_alertDidEnd_returnCode_ = 1 << 1;
@typedef CPAlertStyle
/*
@global
@group CPAlertStyle
@@ -70,6 +71,54 @@ var bottomHeight = 71;
@end
@implementation _CPAlertThemeView : CPView
+ (CPString)defaultThemeClass
{
return @"alert";
}
+ (CPDictionary)themeAttributes
{
return @{
@"size": CGSizeMake(400.0, 110.0),
@"content-inset": CGInsetMake(15, 15, 15, 50),
@"informative-offset": 6,
@"button-offset": 10,
@"message-text-alignment": CPJustifiedTextAlignment,
@"message-text-color": [CPColor blackColor],
@"message-text-font": [CPFont boldSystemFontOfSize:13.0],
@"message-text-shadow-color": [CPNull null],
@"message-text-shadow-offset": CGSizeMakeZero(),
@"informative-text-alignment": CPJustifiedTextAlignment,
@"informative-text-color": [CPColor blackColor],
@"informative-text-font": [CPFont systemFontOfSize:12.0],
@"informative-text-shadow-color": [CPNull null],
@"informative-text-shadow-offset": CGSizeMakeZero(),
@"image-offset": CGPointMake(15, 12),
@"information-image": [CPNull null],
@"warning-image": [CPNull null],
@"error-image": [CPNull null],
@"help-image": [CPNull null],
@"help-image-left-offset": 15,
@"help-image-pressed": [CPNull null],
@"suppression-button-y-offset": 0.0,
@"suppression-button-x-offset": 0.0,
@"default-elements-margin": 3.0,
@"suppression-button-text-color": [CPColor blackColor],
@"suppression-button-text-font": [CPFont systemFontOfSize:12.0],
@"suppression-button-text-shadow-color": [CPNull null],
@"suppression-button-text-shadow-offset": 0.0,
@"modal-window-button-margin-y": 0.0,
@"modal-window-button-margin-x": 0.0,
@"standard-window-button-margin-y": 0.0,
@"standard-window-button-margin-x": 0.0,
};
}
@end
/*!
@ingroup appkit
@@ -813,51 +862,3 @@ var bottomHeight = 71;
}
@end
@implementation _CPAlertThemeView : CPView
+ (CPString)defaultThemeClass
{
return @"alert";
}
+ (CPDictionary)themeAttributes
{
return @{
@"size": CGSizeMake(400.0, 110.0),
@"content-inset": CGInsetMake(15, 15, 15, 50),
@"informative-offset": 6,
@"button-offset": 10,
@"message-text-alignment": CPJustifiedTextAlignment,
@"message-text-color": [CPColor blackColor],
@"message-text-font": [CPFont boldSystemFontOfSize:13.0],
@"message-text-shadow-color": [CPNull null],
@"message-text-shadow-offset": CGSizeMakeZero(),
@"informative-text-alignment": CPJustifiedTextAlignment,
@"informative-text-color": [CPColor blackColor],
@"informative-text-font": [CPFont systemFontOfSize:12.0],
@"informative-text-shadow-color": [CPNull null],
@"informative-text-shadow-offset": CGSizeMakeZero(),
@"image-offset": CGPointMake(15, 12),
@"information-image": [CPNull null],
@"warning-image": [CPNull null],
@"error-image": [CPNull null],
@"help-image": [CPNull null],
@"help-image-left-offset": 15,
@"help-image-pressed": [CPNull null],
@"suppression-button-y-offset": 0.0,
@"suppression-button-x-offset": 0.0,
@"default-elements-margin": 3.0,
@"suppression-button-text-color": [CPColor blackColor],
@"suppression-button-text-font": [CPFont systemFontOfSize:12.0],
@"suppression-button-text-shadow-color": [CPNull null],
@"suppression-button-text-shadow-offset": 0.0,
@"modal-window-button-margin-y": 0.0,
@"modal-window-button-margin-x": 0.0,
@"standard-window-button-margin-y": 0.0,
@"standard-window-button-margin-x": 0.0,
};
}
@end
+1 -16
View File
@@ -42,25 +42,10 @@ var CPAnimationDelegate_animationShouldStart_ = 1 << 1,
CPAnimationDelegate_animationDidEnd_ = 1 << 3,
CPAnimationDelegate_animationDidStop_ = 1 << 4;
/*
@global
@group CPAnimationCurve
*/
@typedef CPAnimationCurve
CPAnimationEaseInOut = 0;
/*
@global
@group CPAnimationCurve
*/
CPAnimationEaseIn = 1;
/*
@global
@group CPAnimationCurve
*/
CPAnimationEaseOut = 2;
/*
@global
@group CPAnimationCurve
*/
CPAnimationLinear = 3;
ACTUAL_FRAME_RATE = 0;
+2
View File
@@ -37,6 +37,8 @@
@import "CPWindowController.j"
@import "_CPPopoverWindow.j"
@typedef CPModalSession
var CPMainCibFile = @"CPMainCibFile",
CPMainCibFileHumanFriendly = @"Main cib file base name",
CPEventModifierFlags = 0;
+1 -1
View File
@@ -23,7 +23,7 @@
*/
@import <Foundation/CPIndexSet.j>
@import <Foundation/CPPredicate.j>
@import "CPObjectController.j"
@import "CPKeyValueBinding.j"
+3
View File
@@ -24,6 +24,7 @@
@import "CPView.j"
// CPBoxType
@typedef CPBoxType
CPBoxPrimary = 0;
CPBoxSecondary = 1;
CPBoxSeparator = 2;
@@ -31,12 +32,14 @@ CPBoxOldStyle = 3;
CPBoxCustom = 4;
// CPBorderType
@typedef CPBorderType
CPNoBorder = 0;
CPLineBorder = 1;
CPBezelBorder = 2;
CPGrooveBorder = 3;
// CPTitlePosition
@typedef CPTitlePosition
CPNoTitle = 0;
CPAboveTop = 1;
CPAtTop = 2;
+2 -2
View File
@@ -29,8 +29,7 @@
@import "CPWindow_Constants.j"
/* @group CPBezelStyle */
// IB style
@typedef CPBezelStyle
CPRoundedBezelStyle = 1; // Push
CPRegularSquareBezelStyle = 2; // Bevel
CPThickSquareBezelStyle = 3;
@@ -49,6 +48,7 @@ CPHUDBezelStyle = -1;
/* @group CPButtonType */
@typedef CPButtonType
CPMomentaryLightButton = 0;
CPPushOnPushOffButton = 1;
CPToggleButton = 2;
+1
View File
@@ -32,6 +32,7 @@
@import "CPPasteboard.j"
@import "CPView.j"
@class _CPCollectionViewDropIndicator
var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_ = 1 << 0,
CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_ = 1 << 1,
+3
View File
@@ -27,6 +27,9 @@
@import "CPView.j"
@class CPSlider
@class _CPColorPanelToolbar
@class _CPColorPanelSwatches
@class _CPColorPanelPreview
@global CPApp
+2
View File
@@ -25,6 +25,8 @@
@import "CPView.j"
@class CPSlider
@class CPColorPanel
@class __CPColorWheel
@global CPColorPickerViewWidth
@global CPColorPickerViewHeight
+13 -13
View File
@@ -61,19 +61,19 @@ var CPComboBoxTextSubview = @"text",
@implementation CPComboBox : CPTextField
{
CPArray _items;
_CPPopUpList _listDelegate;
CPComboBoxDataSource _dataSource;
BOOL _usesDataSource;
BOOL _completes;
BOOL _canComplete;
int _numberOfVisibleItems;
BOOL _forceSelection;
BOOL _hasVerticalScroller;
CPString _selectedStringValue;
CGSize _intercellSpacing;
float _itemHeight;
BOOL _popUpButtonCausedResign;
CPArray _items;
_CPPopUpList _listDelegate;
id<CPComboBoxDataSource> _dataSource;
BOOL _usesDataSource;
BOOL _completes;
BOOL _canComplete;
int _numberOfVisibleItems;
BOOL _forceSelection;
BOOL _hasVerticalScroller;
CPString _selectedStringValue;
CGSize _intercellSpacing;
float _itemHeight;
BOOL _popUpButtonCausedResign;
}
+ (CPString)defaultThemeClass
+6
View File
@@ -42,16 +42,19 @@
@end
@typedef CPTextAlignment
CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
CPJustifiedTextAlignment = 3;
CPNaturalTextAlignment = 4;
@typedef CPControlSize
CPRegularControlSize = 0;
CPSmallControlSize = 1;
CPMiniControlSize = 2;
@typedef CPLineBreakMode
CPLineBreakByWordWrapping = 0;
CPLineBreakByCharWrapping = 1;
CPLineBreakByClipping = 2;
@@ -59,11 +62,13 @@ CPLineBreakByTruncatingHead = 3;
CPLineBreakByTruncatingTail = 4;
CPLineBreakByTruncatingMiddle = 5;
@typedef CPVerticalTextAlignment
CPTopVerticalTextAlignment = 1;
CPCenterVerticalTextAlignment = 2;
CPBottomVerticalTextAlignment = 3;
// Deprecated for use with images, use the CPImageScale constants
@typedef CPImageScaling
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
@@ -73,6 +78,7 @@ CPImageScaleAxesIndependently = 1;
CPImageScaleNone = 2;
CPImageScaleProportionallyUpOrDown = 3;
@typedef CPCellImagePosition
CPNoImage = 0;
CPImageOnly = 1;
CPImageLeft = 2;
+6 -3
View File
@@ -29,6 +29,9 @@
@import <Foundation/Foundation.j>
@class CPDatePicker
@class _CPDatePickerMonthView
@class _CPDatePickerHeaderView
@class _CPDatePickerBox
@global CPApp
@global CPSingleDateMode
@@ -63,7 +66,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_CPDatePickerMonthView _monthView;
_CPDatePickerHeaderView _headerView;
_CPDatePickerClock _datePickerClock;
CPBox _box;
_CPDatePickerBox _box;
CPDatePicker _datePicker;
CPInteger _startSelectionIndex;
CPInteger _currentSelectionIndex;
@@ -97,7 +100,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
sizeCalendar = [_datePicker valueForThemeAttribute:@"size-calendar"],
sizeClock = [_datePicker valueForThemeAttribute:@"size-clock"];
_box = [[_DatePickerBox alloc] initWithFrame:CGRectMake(0, 0, sizeCalendar.width, sizeHeader.height + sizeCalendar.height)];
_box = [[_CPDatePickerBox alloc] initWithFrame:CGRectMake(0, 0, sizeCalendar.width, sizeHeader.height + sizeCalendar.height)];
[_box setDatePicker:_datePicker];
_headerView = [[_CPDatePickerHeaderView alloc] initWithFrame:CGRectMake(0, 0, sizeHeader.width, sizeHeader.height) datePicker:_datePicker delegate:self];
@@ -1266,7 +1269,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
@end
@implementation _DatePickerBox : CPView
@implementation _CPDatePickerBox : CPView
{
CPDatePicker _datePicker @accessors(property=datePicker);
}
+5 -1
View File
@@ -31,6 +31,10 @@
@import <Foundation/CPLocale.j>
@class CPDatePicker
@class _CPDatePickerElementTextField
@class _CPDatePickerElementView
@class _CPDatePickerMonthView
@class _CPDatePickerHeaderView
@global CPSingleDateMode
@global CPRangeDateMode
@@ -1847,4 +1851,4 @@ var CPMonthDateType = 0,
return CGRectMakeCopy(bounds);
}
@end
@end
+1
View File
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@typedef CPDragOperation
CPDragOperationNone = 0;
CPDragOperationCopy = 1 << 1;
CPDragOperationLink = 1 << 1;
+5
View File
@@ -31,9 +31,14 @@
@import "CPText.j"
@class CPTextField
@class CPWindow
@global CPApp
@typedef DOMEvent
@typedef CPEventType
var _CPEventPeriodicEventPeriod = 0,
_CPEventPeriodicEventTimer = nil,
_CPEventUpperCaseRegex = new RegExp("[A-Z]"),
+1
View File
@@ -29,6 +29,7 @@
@global CPImagesPboardType
@global appkit_tag_dom_elements
@typedef CPImageAlignment
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
CPImageAlignTopLeft = 2;
+1
View File
@@ -35,6 +35,7 @@
var exposedBindingsMap = @{},
bindingsMap = @{};
@typedef CPBindingOperationKind
var CPBindingOperationAnd = 0,
CPBindingOperationOr = 1;
+2
View File
@@ -25,11 +25,13 @@
@global CPApp
@typedef CPTickMarkPosition
CPTickMarkBelow = 0;
CPTickMarkAbove = 1;
CPTickMarkLeft = CPTickMarkAbove;
CPTickMarkRight = CPTickMarkBelow;
@typedef CPLevelIndicatorStyle
CPRelevancyLevelIndicatorStyle = 0;
CPContinuousCapacityLevelIndicatorStyle = 1;
CPDiscreteCapacityLevelIndicatorStyle = 2;
+1
View File
@@ -24,6 +24,7 @@
@import "_CPMenuManager.j"
@class _CPMenuView
@class CPMenu
@global CPMenuDidAddItemNotification
@global CPMenuDidChangeItemNotification
+2
View File
@@ -25,6 +25,8 @@
@import "CPWindow.j"
@import "_CPMenuManager.j"
@class _CPMenuView
var _CPMenuWindowPool = [],
_CPMenuWindowPoolCapacity = 5,
@@ -25,6 +25,7 @@
@class _CPMenuBarWindow
@class _CPMenuView
@class CPMenuItem
@implementation _CPMenuItemMenuBarView : CPView
{
@@ -24,6 +24,9 @@
@import "CPImageView.j"
@import "_CPImageAndTextView.j"
@class CPMenuItem
@implementation _CPMenuItemStandardView : CPView
{
CPMenuItem _menuItem @accessors(property=menuItem);
+1
View File
@@ -26,6 +26,7 @@
@import "_CPMenuItemStandardView.j"
@import "_CPMenuItemMenuBarView.j"
@class CPMenuItem
@global CPApp
/*
+2 -1
View File
@@ -26,6 +26,7 @@
@import <Foundation/CPDictionary.j>
@import <Foundation/CPPropertyListSerialization.j>
@class CPWebScriptObject
CPGeneralPboard = @"CPGeneralPboard";
CPFontPboard = @"CPFontPboard";
@@ -66,7 +67,7 @@ var CPPasteboards = nil,
unsigned _changeCount;
CPString _stateUID;
WebScriptObject _nativePasteboard;
CPWebScriptObject _nativePasteboard;
}
/*
+1
View File
@@ -26,6 +26,7 @@
@import "CPWindow_Constants.j"
@typedef CPProgressIndicatorStyle
/*
@global
@group CPProgressIndicatorStyle
+2
View File
@@ -25,6 +25,8 @@
@import "CPButton.j"
@class CPRadioGroup
@global CPApp
+1
View File
@@ -26,6 +26,7 @@
@import "CPEvent.j"
@class CPKeyBinding
@class CPMenu
CPDeleteKeyCode = 8;
CPTabKeyCode = 9;
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
CPRuleEditorPredicateLeftExpression = "CPRuleEditorPredicateLeftExpression";
CPRuleEditorPredicateRightExpression = "CPRuleEditorPredicateRightExpression";
CPRuleEditorPredicateComparisonModifier = "CPRuleEditorPredicateComparisonModifier";
@@ -36,5 +37,6 @@ CPRuleEditorNestingModeList = 1; // Allows a single list, with no nes
CPRuleEditorNestingModeCompound = 2; // Unlimited nesting and compound rows; this is the default
CPRuleEditorNestingModeSimple = 3; // One compound row at the top with subrows beneath it, and no further nesting allowed
@typedef CPRuleEditorRowType
CPRuleEditorRowTypeSimple = 0;
CPRuleEditorRowTypeCompound = 1;
@@ -20,6 +20,8 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@class CPPredicateEditorRowTemplate
@implementation _CPPredicateEditorTree : CPObject
{
CPPredicateEditorRowTemplate template @accessors;
@@ -19,6 +19,8 @@
@import "CPView.j"
@class CPRuleEditor
@implementation _CPRuleEditorViewSlice : CPView
{
CPRuleEditor _ruleEditor;
+2
View File
@@ -33,6 +33,7 @@
@global CPApp
// CPScroller Constants
@typedef CPScrollerPart
CPScrollerNoPart = 0;
CPScrollerDecrementPage = 1;
CPScrollerKnob = 2;
@@ -44,6 +45,7 @@ CPScrollerKnobSlot = 6;
CPScrollerIncrementArrow = 0;
CPScrollerDecrementArrow = 1;
@typedef CPUsableScrollerParts
CPNoScrollerParts = 0;
CPOnlyScrollerArrows = 1;
CPAllScrollerParts = 2;
+1
View File
@@ -28,6 +28,7 @@
@global CPApp
@typedef CPSegmentSwitchTracking
CPSegmentSwitchTrackingSelectOne = 0;
CPSegmentSwitchTrackingSelectAny = 1;
CPSegmentSwitchTrackingMomentary = 2;
+1 -1
View File
@@ -26,7 +26,7 @@
@import "CPImage.j"
@import "CPView.j"
@typedef CPShadowWeight
CPLightShadow = 0;
CPHeavyShadow = 1;
+1
View File
@@ -25,6 +25,7 @@
@import "CPTabViewItem.j"
@import "CPView.j"
@typedef CPTabViewType
CPTopTabsBezelBorder = 0;
//CPLeftTabsBezelBorder = 1;
CPBottomTabsBezelBorder = 2;
+1 -1
View File
@@ -23,7 +23,7 @@
@import <Foundation/CPObject.j>
@import "CPView.j"
@class CPTabView
/*
The tab is currently selected.
+1
View File
@@ -31,6 +31,7 @@
@global CPTableViewColumnDidResizeNotification
@class _CPTableColumnHeaderView
@class CPTableView
CPTableColumnNoResizing = 0;
CPTableColumnAutoresizingMask = 1 << 0;
+2 -1
View File
@@ -42,6 +42,7 @@
@class CPTableHeaderView
@class CPClipView
@class CPButton
@class _CPDropOperationDrawingView
@global CPApp
@@ -170,7 +171,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
@implementation _CPTableDrawView : CPView
{
CPTableView _tableView;
id _tableView;
}
- (id)initWithTableView:(CPTableView)aTableView
+1
View File
@@ -41,6 +41,7 @@
var CPTextFieldDelegate_control_didFailToFormatString_errorDescription_ = 1 << 1;
@typedef CPTextFieldBezelStyle
CPTextFieldSquareBezel = 0; /*! A textfield bezel with squared corners. */
CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */
+1
View File
@@ -26,6 +26,7 @@
@import <Foundation/CPKeyedUnarchiver.j>
@class CPView
@class _CPThemeAttribute
var CPThemesByName = { },
CPThemeDefaultTheme = nil,
+3
View File
@@ -33,6 +33,9 @@
@import "CPTextField.j"
@import "CPWindow_Constants.j"
@class _CPTokenFieldTokenCloseButton
@class _CPTokenFieldTokenDisclosureButton
@global CPApp
@global CPTextFieldDidFocusNotification
@global CPTextFieldDidBlurNotification
+3 -1
View File
@@ -37,6 +37,8 @@ var CPToolbarDelegate_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_
CPToolbarDelegate_toolbarSelectableItemIdentifiers_ = 1 << 4,
CPToolbarDelegate_toolbarWillAddItem_ = 1 << 5;
@typedef CPToolbarDisplayMode
/*
@global
@group CPToolbarDisplayMode
@@ -58,7 +60,7 @@ CPToolbarDisplayModeIconOnly = 2;
*/
CPToolbarDisplayModeLabelOnly = 3;
@typedef CPToolbarSizeMode
CPToolbarSizeModeDefault = 0;
CPToolbarSizeModeRegular = 1;
CPToolbarSizeModeSmall = 2;
+3
View File
@@ -40,9 +40,12 @@
@class CPMenu
@class CPClipView
@class CPScrollView
@class CALayer
@global appkit_tag_dom_elements
@typedef _CPViewFullScreenModeState
#if PLATFORM(DOM)
if (typeof(appkit_tag_dom_elements) !== "undefined" && appkit_tag_dom_elements)
+2 -1
View File
@@ -23,6 +23,7 @@
@import "CPView.j"
@import "CPScrollView.j"
@class CPWebScriptObject
// FIXME: implement these where possible:
/*
@@ -93,7 +94,7 @@ CPWebViewAppKitScrollMaxPollCount = 3;
CPScrollView _scrollView;
CPView _frameView;
IFrame _iframe;
DOMElement _iframe;
CPString _mainFrameURL;
CPArray _backwardStack;
CPArray _forwardStack;
+6
View File
@@ -50,9 +50,15 @@
@class CPMenu
@class CPProgressIndicator
@class CPToolbar
@class CPWindowController
@class _CPWindowFrameAnimation
@global CPApp
@typedef _CPWindowFullPlatformWindowSession
@protocol CPWindowDelegate <CPObject>
@optional
+2
View File
@@ -81,6 +81,7 @@ CPWindowMinYMargin = 8;
CPWindowHeightSizable = 16;
CPWindowMaxYMargin = 32;
@typedef CPWindowLevel
CPBackgroundWindowLevel = -1;
/*
Default level for windows
@@ -143,6 +144,7 @@ CPDraggingWindowLevel = 500;
*/
CPScreenSaverWindowLevel = 1000;
@typedef CPWindowOrderingMode
/*
The receiver is placed directly in front of the window specified.
@global
+2
View File
@@ -22,6 +22,8 @@
@import "CGGeometry.j"
@typedef CGAffineTransform
function CGAffineTransformMake(a, b, c, d, tx, ty)
{
+2
View File
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@typedef CGColorSpace
kCGColorSpaceModelUnknown = -1;
kCGColorSpaceModelMonochrome = 0;
kCGColorSpaceModelRGB = 1;
+1
View File
@@ -25,6 +25,7 @@
@import "CGGeometry.j"
@import "CGPath.j"
@typedef CGContext
kCGLineCapButt = 0;
kCGLineCapRound = 1;
+1
View File
@@ -23,6 +23,7 @@
@import "CGColor.j"
@import "CGColorSpace.j"
@typedef CGGradient
kCGGradientDrawsBeforeStartLocation = 1 << 0;
kCGGradientDrawsAfterEndLocation = 1 << 1;
+2 -1
View File
@@ -23,6 +23,7 @@
@import "CGAffineTransform.j"
@import "CGGeometry.j"
@typedef CGPath
kCGPathElementMoveToPoint = 0;
kCGPathElementAddLineToPoint = 1;
@@ -629,4 +630,4 @@ function CGPathContainsPoint(aPath, aTransform, point, eoFill)
/*!
@}
*/
*/
+3
View File
@@ -27,9 +27,12 @@
@class CPMenu
@class CPPlatformPasteboard
@class CPWindow
@global CPApp
@typedef DOMWindow
var PrimaryPlatformWindow = NULL;
@implementation CPPlatformWindow : CPObject
+1 -1
View File
@@ -71,7 +71,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
#if PLATFORM(DOM)
DOMElement _DOMImageElement;
DOMELement _DOMTextElement;
DOMElement _DOMTextElement;
DOMElement _DOMTextShadowElement;
#endif
}
+107 -107
View File
@@ -65,6 +65,113 @@ var ListMinimumItems = 3;
var ListColumnIdentifier = @"1";
@implementation _CPPopUpPanel : CPPanel
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
{
if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask])
_constrainsToUsableScreen = NO;
[self _trapNextMouseDown];
return self;
}
/*!
Returns \c YES if the receiver is able to receive input events
even when a modal session is active.
*/
- (BOOL)worksWhenModal
{
return YES;
}
- (void)sendEvent:(CPEvent)anEvent
{
var type = [anEvent type];
if (type === CPLeftMouseDown || type === CPRightMouseDown)
[[self delegate] setListWasClicked:YES];
return [super sendEvent:anEvent];
}
- (void)orderFront:(id)sender
{
[self _trapNextMouseDown];
[super orderFront:sender];
}
- (void)_mouseWasClicked:(CPEvent)anEvent
{
var mouseWindow = [anEvent window],
rect = [[[self delegate] dataSource] bounds],
point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil];
if (mouseWindow != self && !CGRectContainsPoint(rect, point))
[[self delegate] close];
else
[self _trapNextMouseDown];
}
- (void)_trapNextMouseDown
{
// Don't dequeue the event so clicks in controls will work
[CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:NO];
}
@end
@implementation _CPPopUpTableView : CPTableView
{
BOOL _acceptFirstResponder;
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
// We want the autocomplete to remain first responder until we are clicked.
_acceptFirstResponder = NO;
}
return self;
}
- (void)trackMouse:(CPEvent)anEvent
{
if (![self isEnabled])
return;
[[self delegate] setItemWasClicked:YES];
// CPTableView will not track the click if it is not first responder
_acceptFirstResponder = YES;
[[self window] makeFirstResponder:self];
[super trackMouse:anEvent];
}
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_acceptFirstResponder = NO;
[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];
}
- (BOOL)acceptsFirstResponder
{
return _acceptFirstResponder;
}
/*!
Return the column used for the list.
*/
- (CPTableColumn)listColumn
{
return _tableColumns[0];
}
@end
/*!
This class is a controller for a panel that can pop up and display a scrollable list of items in a CPTableView.
It is used by CPComboBox to display the list of choices.
@@ -800,110 +907,3 @@ var _CPPopUpListDataSourceKey = @"_CPPopUpListDataSourceKey",
}
@end
@implementation _CPPopUpTableView : CPTableView
{
BOOL _acceptFirstResponder;
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
// We want the autocomplete to remain first responder until we are clicked.
_acceptFirstResponder = NO;
}
return self;
}
- (void)trackMouse:(CPEvent)anEvent
{
if (![self isEnabled])
return;
[[self delegate] setItemWasClicked:YES];
// CPTableView will not track the click if it is not first responder
_acceptFirstResponder = YES;
[[self window] makeFirstResponder:self];
[super trackMouse:anEvent];
}
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_acceptFirstResponder = NO;
[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];
}
- (BOOL)acceptsFirstResponder
{
return _acceptFirstResponder;
}
/*!
Return the column used for the list.
*/
- (CPTableColumn)listColumn
{
return _tableColumns[0];
}
@end
@implementation _CPPopUpPanel : CPPanel
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
{
if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask])
_constrainsToUsableScreen = NO;
[self _trapNextMouseDown];
return self;
}
/*!
Returns \c YES if the receiver is able to receive input events
even when a modal session is active.
*/
- (BOOL)worksWhenModal
{
return YES;
}
- (void)sendEvent:(CPEvent)anEvent
{
var type = [anEvent type];
if (type === CPLeftMouseDown || type === CPRightMouseDown)
[[self delegate] setListWasClicked:YES];
return [super sendEvent:anEvent];
}
- (void)orderFront:(id)sender
{
[self _trapNextMouseDown];
[super orderFront:sender];
}
- (void)_mouseWasClicked:(CPEvent)anEvent
{
var mouseWindow = [anEvent window],
rect = [[[self delegate] dataSource] bounds],
point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil];
if (mouseWindow != self && !CGRectContainsPoint(rect, point))
[[self delegate] close];
else
[self _trapNextMouseDown];
}
- (void)_trapNextMouseDown
{
// Don't dequeue the event so clicks in controls will work
[CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:NO];
}
@end
+1
View File
@@ -26,6 +26,7 @@
@import "CPImage.j"
@import "CPView.j"
@class CPToolbar
@global CPApp
CPToolbarItemVisibilityPriorityStandard = 0;
+3
View File
@@ -28,16 +28,19 @@
@import "CPLocale.j"
@class CPNull
@class CPDictionary
@global CPLocaleLanguageCode
@global CPLocaleCountryCode
@typedef CPDateFormatterStyle
CPDateFormatterNoStyle = 0;
CPDateFormatterShortStyle = 1;
CPDateFormatterMediumStyle = 2;
CPDateFormatterLongStyle = 3;
CPDateFormatterFullStyle = 4;
@typedef CPDateFormatterBehavior
CPDateFormatterBehaviorDefault = 0;
CPDateFormatterBehavior10_0 = 1000;
CPDateFormatterBehavior10_4 = 1040;
+3
View File
@@ -52,6 +52,8 @@
@import "CPArray.j"
@import "CPNumber.j"
@typedef CPDecimal
// Decimal size limits
CPDecimalMaxDigits = 38;
CPDecimalMaxExponent = 127;
@@ -68,6 +70,7 @@ CPCalculationUnderflow = 3;
CPCalculationDivideByZero = 4;
//CPRoundingMode Enum
@typedef CPRoundingMode
CPRoundPlain = 1;
CPRoundDown = 2;
CPRoundUp = 3;
+34 -32
View File
@@ -31,38 +31,6 @@ var CPDictionaryShowNilDeprecationMessage = YES,
CPDictionaryMaxDescriptionRecursion = 10;
/* @ignore */
@implementation _CPDictionaryValueEnumerator : CPEnumerator
{
CPEnumerator _keyEnumerator;
CPDictionary _dictionary;
}
- (id)initWithDictionary:(CPDictionary)aDictionary
{
self = [super init];
if (self)
{
_keyEnumerator = [aDictionary keyEnumerator];
_dictionary = aDictionary;
}
return self;
}
- (id)nextObject
{
var key = [_keyEnumerator nextObject];
if (key === nil)
return nil;
return [_dictionary objectForKey:key];
}
@end
/*!
@class CPDictionary
@ingroup foundation
@@ -801,6 +769,40 @@ var CPDictionaryShowNilDeprecationMessage = YES,
@end
/* @ignore */
@implementation _CPDictionaryValueEnumerator : CPEnumerator
{
CPEnumerator _keyEnumerator;
CPDictionary _dictionary;
}
- (id)initWithDictionary:(CPDictionary)aDictionary
{
self = [super init];
if (self)
{
_keyEnumerator = [aDictionary keyEnumerator];
_dictionary = aDictionary;
}
return self;
}
- (id)nextObject
{
var key = [_keyEnumerator nextObject];
if (key === nil)
return nil;
return [_dictionary objectForKey:key];
}
@end
/*!
@class CPMutableDictionary
@ingroup compatibility
+1
View File
@@ -22,6 +22,7 @@
@import "_CGGeometry.j"
@typedef CPRectEdge
CPMinXEdge = 0;
CPMinYEdge = 1;
CPMaxXEdge = 2;
+1
View File
@@ -23,6 +23,7 @@
@import "CPException.j"
@import "CPObject.j"
@import "CPRunLoop.j"
@import "CPURLRequest.j"
CPJSONPConnectionCallbacks = {};
+61 -7
View File
@@ -27,6 +27,8 @@
@import "CPNull.j"
@import "CPSet.j"
@class _CPNotificationRegistry
var CPNotificationDefaultCenter = nil;
/*!
@@ -68,7 +70,8 @@ var CPNotificationDefaultCenter = nil;
_namedRegistries = @{};
_unnamedRegistry = [[_CPNotificationRegistry alloc] init];
}
return self;
return self;
}
/*!
@@ -81,9 +84,36 @@ var CPNotificationDefaultCenter = nil;
*/
- (void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject
{
var registry,
var registry = [self _registryForNotificationName:aNotificationName],
observer = [[_CPNotificationObserver alloc] initWithObserver:anObserver selector:aSelector];
[registry addObserver:observer object:anObject];
}
/*!
Adds an entry to the receivers dispatch table with a block, and optional criteria: notification name and sender.
@param aNotificationName the name of the notification the observer wants to watch
@param anObject the object in the notification the observer wants to watch
@param queue is ignored for the moment
@param block the block to be executed when the notification is received.
*/
- (id <CPObject>)addObserverForName:(CPString)aNotificationName object:(id)anObject queue:(id)queue usingBlock:(Function)block
{
var registry = [self _registryForNotificationName:aNotificationName],
observer = [[_CPNotificationObserver alloc] initWithBlock:block];
[registry addObserver:observer object:anObject];
return observer;
}
/*!
@ignore
*/
- (_CPNotificationRegistry)_registryForNotificationName:(CPString)aNotificationName
{
var registry;
if (aNotificationName == nil)
registry = _unnamedRegistry;
else if (!(registry = [_namedRegistries objectForKey:aNotificationName]))
@@ -92,7 +122,7 @@ var CPNotificationDefaultCenter = nil;
[_namedRegistries setObject:registry forKey:aNotificationName];
}
[registry addObserver:observer object:anObject];
return registry;
}
/*!
@@ -233,7 +263,8 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
observersEnumerator = [observers objectEnumerator];
while ((observer = [observersEnumerator nextObject]) !== nil)
if ([observer observer] == anObserver)
if ([observer observer] == anObserver ||
([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block]))
[observers removeObject:observer];
if (![observers count])
@@ -248,7 +279,8 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
observersEnumerator = [observers objectEnumerator];
while ((observer = [observersEnumerator nextObject]) !== nil)
if ([observer observer] == anObserver)
if ([observer observer] == anObserver ||
([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block]))
[observers removeObject:observer];
if (![observers count])
@@ -312,8 +344,9 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
/* @ignore */
@implementation _CPNotificationObserver : CPObject
{
id _observer;
SEL _selector;
id _observer;
Function _block;
SEL _selector;
}
- (id)initWithObserver:(id)anObserver selector:(SEL)aSelector
@@ -327,13 +360,34 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
return self;
}
- (id)initWithBlock:(Function)aBlock
{
if (self)
{
_block = aBlock;
}
return self;
}
- (id)observer
{
return _observer;
}
- (id)block
{
return _block;
}
- (void)postNotification:(CPNotification)aNotification
{
if (_block)
{
_block(aNotification);
return;
}
[_observer performSelector:_selector withObject:aNotification];
}
+2 -1
View File
@@ -24,7 +24,7 @@
@import "CPFormatter.j"
@import "CPDecimalNumber.j"
@typedef CPNumberFormatterStyle
CPNumberFormatterNoStyle = 0;
CPNumberFormatterDecimalStyle = 1;
CPNumberFormatterCurrencyStyle = 2;
@@ -32,6 +32,7 @@ CPNumberFormatterPercentStyle = 3;
CPNumberFormatterScientificStyle = 4;
CPNumberFormatterSpellOutStyle = 5;
@typedef CPNumberFormatterRoundingMode
CPNumberFormatterRoundCeiling = CPRoundUp;
CPNumberFormatterRoundFloor = CPRoundDown;
CPNumberFormatterRoundDown = CPRoundDown;
+3 -1
View File
@@ -62,6 +62,8 @@ CPLog(@"Got some class: %@", inst);
@todo document KVC usage.
*/
@import "_CPTypeDefinitions.j"
@class CPString
@class CPException
@@ -104,7 +106,7 @@ CPLog(@"Got some class: %@", inst);
@implementation CPObject <CPObject>
{
Class isa;
id isa;
}
+ (void)load
@@ -32,8 +32,8 @@
@import "_CPPredicate.j"
var CPComparisonPredicateModifier,
CPPredicateOperatorType;
@typedef CPComparisonPredicateModifier
@typedef CPPredicateOperatorType
/*!
@ingroup foundation
+1 -1
View File
@@ -26,7 +26,7 @@
@import "CPArray.j"
@import "_CPPredicate.j"
var CPCompoundPredicateType;
@typedef CPCompoundPredicateType
/*!
@class CPCompoundPredicate
+2
View File
@@ -25,6 +25,8 @@
@{
*/
@typedef CPRange
/*!
Makes a CPRange.
@param location the location for new range
+2
View File
@@ -24,6 +24,8 @@
@import "CPDate.j"
@import "CPLocale.j"
@class CPData
CPTimeZoneNameStyleStandard = 0;
CPTimeZoneNameStyleShortStandard = 1;
CPTimeZoneNameStyleDaylightSaving = 2;
+2
View File
@@ -26,6 +26,8 @@
@import "CPURLRequest.j"
@import "CPURLResponse.j"
@typedef HTTPRequest
var CPURLConnectionDelegate = nil;
/*!
+1 -1
View File
@@ -50,7 +50,7 @@ var _CPUndoGroupingPool = [],
/* @ignore */
@implementation _CPUndoGrouping : CPObject
{
_CPUndoGrouping _parent;
id _parent;
CPMutableArray _invocations;
CPString _actionName;
}
+1
View File
@@ -24,6 +24,7 @@
@import "CPObject.j"
@import "CPString.j"
@typedef CPUserSessionStatus
CPUserSessionUndeterminedStatus = 0;
CPUserSessionLoggedInStatus = 1;
CPUserSessionLoggedOutStatus = 2;
+6
View File
@@ -26,6 +26,12 @@ CGGeometry is not a part of Foundation. The reason _CGGeometry.j exists, and is
*/
@typedef CGPoint
@typedef CGSize
@typedef CGRect
@typedef CGInset
function CGPointMake(x, y)
{
return { x:x, y:y };
+30
View File
@@ -0,0 +1,30 @@
/*
* _CPTypeDefintions.j
* Foundation
*
* Created by Antoine Mercadal.
* Copyright 2014, Antoine Mercadal.
*
* 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
*/
@typedef Class
@typedef CPInteger
@typedef CPUInteger
@typedef DOMElement
@typedef JSObject
@typedef CPMethodSignature
@typedef CPPropertyListFormat
@typedef CPTimeInterval
+87 -5
View File
@@ -353,6 +353,11 @@ ProtocolDef.prototype.getClassMethod = function(name) {
return null;
}
var TypeDef = function(name)
{
this.name = name;
}
// methodDef = {"types": types, "name": selector}
var MethodDef = function(name, types)
{
@@ -369,7 +374,7 @@ var wordPrefixOperators = exports.acorn.makePredicate("delete in instanceof new
var isLogicalBinary = exports.acorn.makePredicate("LogicalExpression BinaryExpression");
var isInInstanceof = exports.acorn.makePredicate("in instanceof");
var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, /*unsigned*/ pass, /* Dictionary */ classDefs, /* Dictionary */ protocolDefs)
var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, /*unsigned*/ pass, /* Dictionary */ classDefs, /* Dictionary */ protocolDefs, /* Dictionary */ typeDefs)
{
this.source = aString;
this.URL = new CFURL(aURL);
@@ -399,6 +404,7 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*
this.flags = flags | ObjJAcornCompiler.Flags.IncludeDebugSymbols;
this.classDefs = classDefs ? classDefs : Object.create(null);
this.protocolDefs = protocolDefs ? protocolDefs : Object.create(null);
this.typeDefs = typeDefs ? typeDefs : Object.create(null);
this.lastPos = 0;
if (currentCompilerFlags & ObjJAcornCompiler.Flags.Generate)
this.generate = true;
@@ -415,9 +421,9 @@ exports.ObjJAcornCompiler.compileToExecutable = function(/*String*/ aString, /*C
return new ObjJAcornCompiler(aString, aURL, flags, 2).executable();
}
exports.ObjJAcornCompiler.compileToIMBuffer = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, classDefs, protocolDefs)
exports.ObjJAcornCompiler.compileToIMBuffer = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, classDefs, protocolDefs, typeDefs)
{
return new ObjJAcornCompiler(aString, aURL, flags, 2, classDefs, protocolDefs).IMBuffer();
return new ObjJAcornCompiler(aString, aURL, flags, 2, classDefs, protocolDefs, typeDefs).IMBuffer();
}
exports.ObjJAcornCompiler.compileFileDependencies = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags)
@@ -581,6 +587,31 @@ ObjJAcornCompiler.prototype.getProtocolDef = function(/* String */ aProtocolName
// protocolDef = {"name": protocolName, "protocols": Object.create(null), "required": Object.create(null), "optional": Object.create(null)};
}
ObjJAcornCompiler.prototype.getTypeDef = function(/* String */ aTypeDefName)
{
if (!aTypeDefName)
return null;
var t = this.typeDefs[aTypeDefName];
if (t)
return t;
if (typeof objj_getTypeDef === 'function')
{
var aTypeDef = objj_getTypeDef(aTypeDefName);
if (aTypeDef)
{
var typeDefName = typeDef_getName(aTypeDef)
t = new TypeDef(typeDefName);
this.typeDefs[typeDefName] = t;
return t;
}
}
return null;
}
ObjJAcornCompiler.methodDefsFromMethodList = function(/* Array */ methodList)
{
var methodSize = methodList.length,
@@ -1643,6 +1674,9 @@ ClassDeclarationStatement: function(node, st, c) {
compiler.cmBuffer = new StringBuffer();
compiler.classBodyBuffer = new StringBuffer(); // TODO: Check if this is needed
if (compiler.getTypeDef(className))
throw compiler.error_message(className + " is already declared as a type", node.classname);
if (!generate) saveJSBuffer.concat(compiler.source.substring(compiler.lastPos, node.start));
// First we declare the class
@@ -1715,12 +1749,19 @@ ClassDeclarationStatement: function(node, st, c) {
{
var ivarDecl = node.ivardeclarations[i],
ivarType = ivarDecl.ivartype ? ivarDecl.ivartype.name : null,
ivarTypeIsClass = ivarDecl.ivartype ? ivarDecl.ivartype.typeisclass : false,
ivarName = ivarDecl.id.name,
ivar = {"type": ivarType, "name": ivarName},
accessors = ivarDecl.accessors;
if (ivars[ivarName])
throw compiler.error_message("Instance variable '" + ivarName + "'is already declared for class " + className, ivarDecl.id);
throw compiler.error_message("Instance variable '" + ivarName + "' is already declared for class " + className, ivarDecl.id);
var isTypeDefined = !ivarTypeIsClass || typeof global[ivarType] !== "undefined" || typeof window[ivarType] !== "undefined"
|| compiler.getClassDef(ivarType) || compiler.getTypeDef(ivarType) || ivarType == classDef.name;
if (!isTypeDefined)
compiler.addWarning(createMessage("Unknown type '" + ivarType + "' for ivar '" + ivarName + "'", ivarDecl.id, compiler.source));
if (firstIvarDeclaration)
{
@@ -1824,7 +1865,7 @@ ClassDeclarationStatement: function(node, st, c) {
// Remove all @accessors or we will get a recursive loop in infinity
var b = getterSetterBuffer.toString().replace(/@accessors(\(.*\))?/g, "");
var imBuffer = ObjJAcornCompiler.compileToIMBuffer(b, "Accessors", compiler.flags, compiler.classDefs, compiler.protocolDefs);
var imBuffer = ObjJAcornCompiler.compileToIMBuffer(b, "Accessors", compiler.flags, compiler.classDefs, compiler.protocolDefs, compiler.typeDefs);
// Add the accessors methods first to instance method buffer.
// This will allow manually added set and get methods to override the compiler generated
@@ -2371,6 +2412,10 @@ ClassStatement: function(node, st, c) {
compiler.jsBuffer.concat("//");
}
var className = node.id.name;
if (compiler.getTypeDef(className))
throw compiler.error_message(className + " is already declared as a type", node.id);
if (!compiler.getClassDef(className)) {
classDef = new ClassDef(false, className);
compiler.classDefs[className] = classDef;
@@ -2393,5 +2438,42 @@ PreprocessStatement: function(node, st, c) {
compiler.lastPos = node.start;
compiler.jsBuffer.concat("//");
}
},
TypeDefStatement: function(node, st, c) {
var compiler = st.compiler,
generate = compiler.generate,
buffer = compiler.jsBuffer,
typeDefName = node.typedefname.name,
typeDef = compiler.getTypeDef(typeDefName),
typeDefScope = new Scope(st);
if (typeDef)
throw compiler.error_message("Duplicate type definition " + typeDefName, node.typedefname);
if (compiler.getClassDef(typeDefName))
throw compiler.error_message(typeDefName + " is already declared as class", node.typedefname);
compiler.imBuffer = new StringBuffer();
compiler.cmBuffer = new StringBuffer();
if (!generate)
buffer.concat(compiler.source.substring(compiler.lastPos, node.start));
buffer.concat("{var the_typedef = objj_allocateTypeDef(\"" + typeDefName + "\");");
typeDef = new TypeDef(typeDefName);
compiler.typeDefs[typeDefName] = typeDef;
typeDefScope.typeDef = typeDef;
buffer.concat("\nobjj_registerTypeDef(the_typedef);\n");
buffer.concat("}");
compiler.jsBuffer = buffer;
// Skip the "@end"
if (!generate)
compiler.lastPos = node.end;
}
});
+33
View File
@@ -100,6 +100,11 @@ GLOBAL(objj_object) = function()
this._UID = -1;
}
GLOBAL(objj_typeDef) = function(/*String*/ aName)
{
this.name = aName;
}
// Working with Classes
GLOBAL(class_getName) = function(/*Class*/ aClass)
@@ -440,6 +445,26 @@ GLOBAL(protocol_addProtocol) = function(/*Protocol*/ proto, /*Protocol*/ additio
(proto.protocol_list || (proto.protocol_list = [])).push(addition);
}
var REGISTERED_TYPEDEFS = Object.create(null);
GLOBAL(objj_allocateTypeDef) = function(/*String*/ aName)
{
var typeDef = new objj_typeDef(aName);
return typeDef;
}
GLOBAL(objj_registerTypeDef) = function(/*TypeDef*/ typeDef)
{
REGISTERED_TYPEDEFS[typeDef.name] = typeDef;
}
GLOBAL(typeDef_getName) = function(/*TypeDef*/ typeDef)
{
return typeDef.name;
}
var _class_initialize = function(/*Class*/ aClass)
{
var meta = GETMETA(aClass);
@@ -619,6 +644,7 @@ GLOBAL(objj_resetRegisterClasses) = function()
REGISTERED_CLASSES = Object.create(null);
REGISTERED_PROTOCOLS = Object.create(null);
REGISTERED_TYPEDEFS = Object.create(null);
resetBundle();
}
@@ -751,6 +777,13 @@ GLOBAL(objj_getProtocol) = function(/*String*/ aName)
return REGISTERED_PROTOCOLS[aName];
}
// Working with typeDef
GLOBAL(objj_getTypeDef) = function(/*String*/ aName)
{
return REGISTERED_TYPEDEFS[aName];
}
// Working with Instance Variables
GLOBAL(ivar_getName) = function(anIvar)
+49 -29
View File
@@ -375,12 +375,15 @@ if (typeof exports != "undefined" && !exports.acorn) {
var _ref = {keyword: "ref"}, _deref = {keyword: "deref"};
var _protocol = {keyword: "protocol"}, _optional = {keyword: "optional"}, _required = {keyword: "required"};
var _interface = {keyword: "interface"};
var _typedef = {keyword: "typedef"};
// Objective-J keywords
var _filename = {keyword: "filename"}, _unsigned = {keyword: "unsigned", okAsIdent: true}, _signed = {keyword: "signed", okAsIdent: true};
var _byte = {keyword: "byte", okAsIdent: true}, _char = {keyword: "char", okAsIdent: true}, _short = {keyword: "short", okAsIdent: true};
var _int = {keyword: "int", okAsIdent: true}, _long = {keyword: "long", okAsIdent: true}, _id = {keyword: "id", okAsIdent: true};
var _boolean = {keyword: "BOOL", okAsIdent: true}, _SEL = {keyword: "SEL", okAsIdent: true}, _float = {keyword: "float", okAsIdent: true};
var _double = {keyword: "double", okAsIdent: true};
var _preprocess = {keyword: "#"};
// Preprocessor keywords
@@ -415,14 +418,15 @@ if (typeof exports != "undefined" && !exports.acorn) {
// Map Objective-J keyword names to token types.
var keywordTypesObjJ = {"IBAction": _action, "IBOutlet": _outlet, "unsigned": _unsigned, "signed": _signed, "byte": _byte, "char": _char,
"short": _short, "int": _int, "long": _long, "id": _id };
"short": _short, "int": _int, "long": _long, "id": _id, "float": _float, "BOOL": _boolean, "SEL": _SEL,
"double": _double};
// Map Objective-J "@" keyword names to token types.
var objJAtKeywordTypes = {"implementation": _implementation, "outlet": _outlet, "accessors": _accessors, "end": _end,
"import": _import, "action": _action, "selector": _selector, "class": _class, "global": _global,
"ref": _ref, "deref": _deref, "protocol": _protocol, "optional": _optional, "required": _required,
"interface": _interface};
"interface": _interface, "typedef": _typedef};
// Map Preprocessor keyword names to token types.
@@ -547,7 +551,7 @@ if (typeof exports != "undefined" && !exports.acorn) {
// The Objective-J keywords.
var isKeywordObjJ = makePredicate("IBAction IBOutlet byte char short int long unsigned signed id");
var isKeywordObjJ = makePredicate("IBAction IBOutlet byte char short int long float unsigned signed id BOOL SEL double");
// The preprocessor keywords.
@@ -662,6 +666,7 @@ var preprocessTokens = [_preIf, _preIfdef, _preIfndef, _preElse, _preElseIf, _pr
}
}
}
tokVal = val;
lastTokCommentsAfter = tokCommentsAfter;
lastTokSpacesAfter = tokSpacesAfter;
@@ -2277,6 +2282,15 @@ var preIfLevel = 0;
}
break;
// This is a Objective-J statement
case _typedef:
if (options.objj) {
next();
node.typedefname = parseIdent(true);
return finishNode(node, "TypeDefStatement");
}
break;
}
// The indentation is one step to the right here to make sure it
@@ -2317,6 +2331,7 @@ var preIfLevel = 0;
if (outlet)
decl.outlet = outlet;
decl.ivartype = type;
// print("keyword: " + type.name + " is class " + type.typeisclass)
decl.id = parseIdent();
if (strict && isStrictBadIdWord(decl.id.name))
raise(decl.id.start, "Binding " + decl.id.name + " in strict mode");
@@ -3021,6 +3036,7 @@ var preIfLevel = 0;
node.typeisclass = true;
next();
} else {
node.typeisclass = false;
node.name = tokType.keyword;
// Do nothing more if it is 'void'
if (!eat(_void)) {
@@ -3043,32 +3059,36 @@ var preIfLevel = 0;
} else {
// Now check if it is some basic type or an approved combination of basic types
var nextKeyWord;
if (eat(_signed) || eat(_unsigned))
nextKeyWord = tokType.keyword || true;
if (eat(_char) || eat(_byte) || eat(_short)) {
if (nextKeyWord)
node.name += " " + nextKeyWord;
nextKeyWord = tokType.keyword || true;
} else {
if (eat(_int)) {
if (nextKeyWord)
node.name += " " + nextKeyWord;
nextKeyWord = tokType.keyword || true;
}
if (eat(_long)) {
if (nextKeyWord)
node.name += " " + nextKeyWord;
nextKeyWord = tokType.keyword || true;
if (eat(_long)) {
node.name += " " + nextKeyWord;
}
}
}
if (!nextKeyWord) {
// It must be a class name if it was not a basic type. // FIXME: This is not true
node.name = (!options.forbidReserved && tokType.keyword) || unexpected();
node.typeisclass = true;
next();
if (eat(_float) || eat(_boolean) || eat(_SEL) || eat(_double))
nextKeyWord = tokType.keyword;
else {
if (eat(_signed) || eat(_unsigned))
nextKeyWord = tokType.keyword || true;
if (eat(_char) || eat(_byte) || eat(_short)) {
if (nextKeyWord)
node.name += " " + nextKeyWord;
nextKeyWord = tokType.keyword || true;
} else {
if (eat(_int)) {
if (nextKeyWord)
node.name += " " + nextKeyWord;
nextKeyWord = tokType.keyword || true;
}
if (eat(_long)) {
if (nextKeyWord)
node.name += " " + nextKeyWord;
nextKeyWord = tokType.keyword || true;
if (eat(_long)) {
node.name += " " + nextKeyWord;
}
}
}
if (!nextKeyWord) {
// It must be a class name if it was not a basic type. // FIXME: This is not true
node.name = (!options.forbidReserved && tokType.keyword) || unexpected();
node.typeisclass = true;
next();
}
}
}
}
+2
View File
@@ -221,6 +221,8 @@ if (!exports.acorn) {
}
}
exports.TypeDefStatement = ignore;
exports.MethodDeclarationStatement = function(node, st, c) {
var body = node.body;
if (body)
+1 -1
View File
@@ -33,7 +33,7 @@ Getting Started
---------------
To get started, download and install the current release version of Cappuccino:
$ curl https://raw.github.com/cappuccino/cappuccino/v0.9.7/bootstrap.sh >/tmp/cappuccino_bootstrap.sh && bash /tmp/cappuccino_bootstrap.sh
$ curl https://raw.githubusercontent.com/cappuccino/cappuccino/v0.9.7-1/bootstrap.sh >/tmp/cappuccino_bootstrap.sh && bash /tmp/cappuccino_bootstrap.sh
If you'd just like to get started using Cappuccino for your web apps, you are done.
+3
View File
@@ -3,6 +3,9 @@
@import <AppKit/CPArrayController.j>
@import <AppKit/CPTextField.j>
@class Department
@class Employee
@implementation CPArrayControllerTest : OJTestCase
{
CPArrayController _arrayController @accessors(property=arrayController);
+3
View File
@@ -1,5 +1,8 @@
@import <AppKit/AppKit.j>
@class CPBrowserDelegate
@implementation CPBrowserTest : OJTestCase
{
CPBrowser browser;
@@ -1,6 +1,8 @@
@import <AppKit/AppKit.j>
@class Track
/*!
Bindings tests exercising the functionality seen in the Cocoa example "SimpleBindingsAdoption".
*/
@@ -1,5 +1,7 @@
var CPMenuValidatedUserInterfaceItemTestValidatedItems = [];
@class MenuTarget
@implementation CPMenuValidatedUserInterfaceItemTest : OJTestCase
{
CPMenu _menu @accessors(property=menu);
@@ -83,4 +85,4 @@ var CPMenuValidatedUserInterfaceItemTestValidatedItems = [];
}
@end
@end
+3
View File
@@ -1,5 +1,8 @@
@import <AppKit/AppKit.j>
@class TestOutlineDataSource
@implementation CPOutlineViewTest : OJTestCase
{
CPOutlineView outlineView;
+2
View File
@@ -1,5 +1,7 @@
@import <AppKit/AppKit.j>
@class TestDelegateTokenField
[CPApplication sharedApplication];
@implementation CPTokenFieldTest : OJTestCase
+3
View File
@@ -1,5 +1,8 @@
var COUNTER;
@class TestObject
@class ImplementedTestObject
@implementation CPKVCArrayTest : OJTestCase
{
TestObject _object @accessors(property=object);
+3
View File
@@ -1,6 +1,9 @@
@import <Foundation/CPKeyValueCoding.j>
@import <Foundation/CPKeyValueObserving.j>
@class CarTester
@class ToManyTester
@implementation CPKVOTest : OJTestCase
{
BOOL _sawInitialObservation;
+3
View File
@@ -22,6 +22,9 @@
@import <Foundation/CPObject.j>
@class Department2
@class Employee2
var accessIVARS = YES;
@implementation KVCTestClass : CPObject
@@ -52,6 +52,51 @@ var TestNotification = @"TestNotification";
[self assert:8 equals:notificationCount message:@"observer should not be notified"];
}
- (void)testNotifyWithBlocks
{
var center = [CPNotificationCenter defaultCenter];
notificationCount = 0;
var notificationBlock = function(notification){
notificationCount += 1;
};
var observer2 = [center addObserverForName:TestNotification object:2 queue:nil usingBlock:notificationBlock],
observer25 = [center addObserverForName:TestNotification object:25 queue:nil usingBlock:notificationBlock];
[center postNotificationName:TestNotification object:self];
[self assert:0 equals:notificationCount message:@"observer should only be notified for object '2'"];
[center postNotificationName:TestNotification object:2];
[self assert:1 equals:notificationCount message:@"observer should be notified for object '2'"];
var observerNil = [center addObserverForName:TestNotification object:nil queue:nil usingBlock:notificationBlock];
[center postNotificationName:TestNotification object:2];
[self assert:3 equals:notificationCount message:@"observer should be notified for object '2' and for any object"];
[center removeObserver:observer2 name:TestNotification object:2];
[center postNotificationName:TestNotification object:2];
[self assert:4 equals:notificationCount message:@"observer should be notified only for any object"];
// At this point we have TestNofication:nil observer and a TestNotification:25 observer.
observer2 = [center addObserverForName:nil object:2 queue:nil usingBlock:notificationBlock];
[center postNotificationName:TestNotification object:2];
[self assert:6 equals:notificationCount message:@"observer should be notified for TestNofication and for object '2' (TestNotification)"];
[center postNotificationName:@"RandomNotification" object:2];
[self assert:7 equals:notificationCount message:@"observer should be notified for object '2' (RandomNotification)"];
[center removeObserver:observer2];
[center removeObserver:observer25];
[center removeObserver:observerNil];
[center postNotificationName:TestNotification object:nil];
[center postNotificationName:TestNotification object:2];
[center postNotificationName:TestNotification object:25];
[self assert:7 equals:notificationCount message:@"observer should not be notified"];
}
- (void)testAddObserversDuringNotification
{
var center = [CPNotificationCenter defaultCenter];
+46
View File
@@ -0,0 +1,46 @@
## Run tests
./run.py
## Create a test case
create a `.j` file in `TestCases` folder:
-First line MUST be:
// Expected output: [OBJJ_STATUS_CODE]
Then after that add a block comment that contains:
/*
START_EXPECTED
[CONSOLE_OUTPUT_OF_OBJJ]
END_EXPECTED
*/
Be sure to replace the file path by the token `[__PATH__]` After that, add the code you want to test.
If your test doesn't expect any output, don't put any `START_EXPECTED` and `END_EXPECTED`
For instance:
/*
START_EXPECTED
Error on line 10771 of file [unknown]
SyntaxError:
@typedef MyType
^
ERROR line 2 in file:[__PATH__]: Duplicate type definition MyType
END_EXPECTED
*/
@import <Foundation/Foundation.j>
@implementation MyCall : CPObject
{
CPString property1;
}
@end
@@ -0,0 +1,13 @@
// Expected output: 0
/*
*/
@import <Foundation/Foundation.j>
@implementation MyCall : CPObject
{
CPString property1;
}
@end
@@ -0,0 +1,18 @@
// Expected output: 256
/*
START_EXPECTED
Error on line 10778 of file [unknown]
SyntaxError:
@typedef mytype
^
ERROR line 4 in file:[__PATH__]: mytype is already declared as class
END_EXPECTED
*/
@import <Foundation/Foundation.j>
@class mytype
@typedef mytype
@@ -0,0 +1,20 @@
// Expected output: 0
/*
START_EXPECTED
MyType property1;
^
WARNING line 5 in file:[__PATH__]: Unknown type 'MyType' for ivar 'property1'
END_EXPECTED
*/
@import <Foundation/CPObject.j>
@implementation MyCall : CPObject
{
MyType property1;
}
@end
@@ -0,0 +1,15 @@
// Expected output: 0
/*
*/
@import <Foundation/CPObject.j>
@typedef MyType
@implementation MyCall : CPObject
{
MyType property1;
}
@end
@@ -0,0 +1,15 @@
// Expected output: 0
/*
*/
@import <Foundation/CPObject.j>
@class MyType
@implementation MyCall : CPObject
{
MyType property1;
}
@end
@@ -0,0 +1,22 @@
// Expected output: 0
/*
START_EXPECTED
MyType property1;
^
WARNING line 7 in file:[__PATH__]: Unknown type 'MyType' for ivar 'property1'
END_EXPECTED
*/
@import <Foundation/CPObject.j>
@global MyType
@implementation MyCall : CPObject
{
MyType property1;
}
@end
@@ -0,0 +1,16 @@
// Expected output: 256
/*
START_EXPECTED
Error on line 10775 of file [unknown]
SyntaxError:
@typedef MyType
^
ERROR line 2 in file:[__PATH__]: Duplicate type definition MyType
END_EXPECTED
*/
@typedef MyType
@typedef MyType
@@ -0,0 +1,20 @@
// Expected output: 256
/*
START_EXPECTED
Error on line 10001 of file [unknown]
SyntaxError:
@implementation MyType : CPObject
^
ERROR line 5 in file:[__PATH__]: MyType is already declared as type
END_EXPECTED
*/
@import <Foundation/Foundation.j>
@typedef MyType
@implementation MyType : CPObject
@end
@@ -0,0 +1,20 @@
// Expected output: 256
/*
START_EXPECTED
Error on line 10778 of file [unknown]
SyntaxError:
@typedef MyType
^
ERROR line 6 in file:[__PATH__]: MyType is already declared as class
END_EXPECTED
*/
@import <Foundation/Foundation.j>
@implementation MyType : CPObject
@end
@typedef MyType
@@ -0,0 +1,22 @@
// Expected output: 256
/*
START_EXPECTED
Error on line 10014 of file [unknown]
SyntaxError:
@implementation MyType : CPObject
^
ERROR line 6 in file:[__PATH__]: Duplicate class MyType
END_EXPECTED
*/
@import <Foundation/Foundation.j>
@implementation MyType : CPObject
@end
@implementation MyType : CPObject
@end
+82
View File
@@ -0,0 +1,82 @@
#!/usr/bin/env python
import os
import commands
import re
PATH = os.path.abspath(os.path.join(os.path.dirname(__file__)))
def get_tests_cases():
ret = []
for filename in os.listdir("TestCases"):
ret.append("TestCases/%s" % filename)
return ret
# return ["TestCases/2.j"]
def get_expected_output(test_case):
f = open(test_case)
content = f.readlines();
f.close()
status = int(content[0].replace("// Expected output: ", ""))
recording = False
output = []
for line in content:
if "END_EXPECTED" in line:
recording = False
break;
if "START_EXPECTED" in line:
recording = True
continue
if recording:
output.append(line)
output = "".join(output);
output = output.replace("[__PATH__]", "%s/%s" % (PATH, test_case))
output = cleanup_output(output)
return (status, output)
def get_actual_output(test_case):
status, output = commands.getstatusoutput("objj %s" % test_case)
output = cleanup_output(output)
return (status, output)
def cleanup_output(output):
if not output:
return ""
output = output.replace(" ", "")
output = output.replace("\n", "")
output = output.replace("[0m", "")
return re.sub('[^\s!-~]', '', output)
if __name__ == "__main__":
for test in get_tests_cases():
expected_status, expected_output = get_expected_output(test)
actual_status, actual_output = get_actual_output(test)
print "########################################"
print "Testing %s" % test
errored = False
if expected_status != actual_status:
errored = True
print " Error in %s: Status code is different: expected %d, actual %d" % (test, expected_status, actual_status)
if expected_output != actual_output:
errored = True
print " Error in %s. Outputs are different" % test
print " EXPECTED: %s" % expected_output
print " ACTUAL: %s" % actual_output
if not errored:
print " OK"
@@ -1,10 +1,10 @@
@implementation Class
@implementation TestClass
{
}
@end
@implementation Class (Accessors)
@implementation TestClass (Accessors)
{
Type ivar @accessors;
}
@@ -1,13 +1,14 @@
var the_class=objj_allocateClassPair(Nil,"Class"),meta_class=the_class.isa;
var the_class=objj_allocateClassPair(Nil,"TestClass"),meta_class=the_class.isa;
objj_registerClassPair(the_class);
var the_class=objj_getClass("Class");
var the_class=objj_getClass("TestClass");
if(!the_class){
throw new SyntaxError("*** Could not find definition for class \"Class\"");
throw new SyntaxError("*** Could not find definition for class \"TestClass\"");
}
var meta_class=the_class.isa;
class_addIvars(the_class,[new objj_ivar("ivar")]);
class_addMethods(the_class,[new objj_method(sel_getUid("ivar"),function $Class__ivar(_1,_2){
class_addMethods(the_class,[new objj_method(sel_getUid("ivar"),function $TestClass__ivar(_1,_2){
return _1.ivar;
},["Type"]),new objj_method(sel_getUid("setIvar:"),function $Class__setIvar_(_3,_4,_5){
},["Type"]),new objj_method(sel_getUid("setIvar:"),function $TestClass__setIvar_(_3,_4,_5){
_3.ivar=_5;
},["void","Type"])]);
},["void","Type"])]);

Some files were not shown because too many files have changed in this diff Show More