mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-13 20:17:07 +00:00
Fixed a lot of small bugs found by new warning message from compiler
This commit is contained in:
1 parent
ff20822b47
commit
458fa9d02e
92 files changed
+1326
-1005
No files matched your search
@@ -227,7 +227,7 @@ var secondItem = [[CPAccordionViewItem alloc] initWithIdentifier:@"secondSection
|
||||
{
|
||||
var indexSet = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, _items.length)];
|
||||
|
||||
[indexSet removeIndexes:_expandedIndexes];
|
||||
[indexSet removeIndexes:_expandedItemIndexes];
|
||||
|
||||
return indexSet;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
@import "CPPanel.j"
|
||||
@import "CPTextField.j"
|
||||
|
||||
@class CPCheckBox
|
||||
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPAlertStyle
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
@import "CPCibLoading.j"
|
||||
@import "CPPlatform.j"
|
||||
|
||||
@class CPCursor
|
||||
@class CPColorPanel
|
||||
|
||||
|
||||
var CPMainCibFile = @"CPMainCibFile",
|
||||
CPMainCibFileHumanFriendly = @"Main cib file base name",
|
||||
|
||||
@@ -964,7 +964,7 @@
|
||||
// be the 'wrong' one - as in not the one the user selected - but the wrong
|
||||
// one is still just another pointer to the same object, so the user will not
|
||||
// be able to see any difference.
|
||||
contentIndex = [_contentObject indexOfObjectIdenticalTo:object];
|
||||
var contentIndex = [_contentObject indexOfObjectIdenticalTo:object];
|
||||
[_contentObject removeObjectAtIndex:contentIndex];
|
||||
}
|
||||
[arrangedObjects removeObjectAtIndex:anIndex];
|
||||
@@ -1093,7 +1093,8 @@
|
||||
isCompound = [self handlesContentAsCompoundValue],
|
||||
dotIndex = keyPath.lastIndexOf("."),
|
||||
firstPart = dotIndex !== CPNotFound ? keyPath.substring(0, dotIndex) : nil,
|
||||
isSelectionProxy = firstPart && [[destination valueForKeyPath:firstPart] isKindOfClass:CPControllerSelectionProxy];
|
||||
isSelectionProxy = firstPart && [[destination valueForKeyPath:firstPart] isKindOfClass:CPControllerSelectionProxy],
|
||||
newValue;
|
||||
|
||||
if (!isCompound && !isSelectionProxy)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
@import "CPControl.j"
|
||||
@import "CPStringDrawing.j"
|
||||
|
||||
@global CPWindowAbove
|
||||
@global CPWindowBelow
|
||||
|
||||
/* @group CPBezelStyle */
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPSplitView
|
||||
|
||||
@global CPPopUpButtonStatePullsDown
|
||||
|
||||
|
||||
@implementation CPButtonBar : CPView
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPScrollView
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "CPGraphicsContext.j"
|
||||
|
||||
@import "CGColor.j"
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
@import "CPPanel.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPSlider
|
||||
|
||||
|
||||
CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification";
|
||||
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPSlider
|
||||
|
||||
@global CPColorPickerViewWidth
|
||||
@global CPColorPickerViewHeight
|
||||
@global CPWheelColorPickerMode
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
- (void)_initComboBox
|
||||
{
|
||||
_items = [CPArray array];
|
||||
_listClass = [_CPPopUpList class];
|
||||
// _listClass = [_CPPopUpList class];
|
||||
_usesDataSource = NO;
|
||||
_completes = NO;
|
||||
_canComplete = NO;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
@import "CPEvent.j"
|
||||
@import "CPPlatform.j"
|
||||
//@import "CPPlatform.j"
|
||||
|
||||
|
||||
// Browser Engines
|
||||
|
||||
@@ -23,11 +23,14 @@
|
||||
#import "../Foundation/Ref.h"
|
||||
|
||||
@import <Foundation/CPFormatter.j>
|
||||
@import <Foundation/CPTimer.j>
|
||||
@import "CPFont.j"
|
||||
@import "CPShadow.j"
|
||||
@import "CPView.j"
|
||||
@import "CPKeyValueBinding.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
CPLeftTextAlignment = 0;
|
||||
CPRightTextAlignment = 1;
|
||||
CPCenterTextAlignment = 2;
|
||||
|
||||
@@ -64,7 +64,7 @@ var CPControllerDeclaredKeysKey = @"CPControllerDeclaredKeysKey";
|
||||
count = _editors.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
if (![[_editors objectAtIndex:i] commitEditing])
|
||||
if (![[_editors objectAtIndex:index] commitEditing])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ var currentCursor = nil,
|
||||
*/
|
||||
- (id)initWithImage:(CPImage)image foregroundColorHint:(CPColor)foregroundColor backgroundColorHint:(CPColor)backgroundColor hotSpot:(CGPoint)aHotSpot
|
||||
{
|
||||
return [self initWithImage:image hotSpot:hotSpot];
|
||||
return [self initWithImage:image hotSpot:aHotSpot];
|
||||
}
|
||||
|
||||
+ (void)hide
|
||||
|
||||
@@ -29,6 +29,12 @@
|
||||
@import "CPViewController.j"
|
||||
@import "CPWindowController.j"
|
||||
|
||||
@class CPDocumentController
|
||||
@class CPAlert
|
||||
|
||||
@global CPApp
|
||||
@global CPWarningAlertStyle
|
||||
|
||||
|
||||
/*
|
||||
@global
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
@import "CPDocument.j"
|
||||
@import "CPOpenPanel.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
var CPSharedDocumentController = nil;
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
@import "CPView.j"
|
||||
@import "CPWindow.j"
|
||||
|
||||
@class _CPDOMDataTransferPasteboard
|
||||
|
||||
|
||||
CPDragOperationNone = 0;
|
||||
CPDragOperationCopy = 1 << 1;
|
||||
|
||||
@@ -21,8 +21,14 @@
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPGeometry.j>
|
||||
@import "CPText.j"
|
||||
|
||||
@class CPTextField
|
||||
|
||||
@global CPApp
|
||||
@global CPBrowserIsOperatingSystem
|
||||
@global CPMacOperatingSystem
|
||||
|
||||
CPLeftMouseDown = 1;
|
||||
CPLeftMouseUp = 2;
|
||||
@@ -206,6 +212,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
DOMEvent _DOMEvent;
|
||||
int _data1;
|
||||
int _data2;
|
||||
short _subtype;
|
||||
|
||||
float _deltaX;
|
||||
float _deltaY;
|
||||
|
||||
@@ -54,7 +54,7 @@ var CPSharedFontManager = nil,
|
||||
id _delegate @accessors(property=delegate);
|
||||
|
||||
CPFont _selectedFont;
|
||||
BOOL _multiple @accessors;
|
||||
BOOL _multiple @accessors(getter=isMultiple, setter=setMultiple:);
|
||||
|
||||
CPDictionary _activeChange;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ var CPSharedFontManager = nil,
|
||||
- (void)setSelectedFont:(CPFont)aFont isMultiple:(BOOL)aFlag
|
||||
{
|
||||
_selectedFont = aFont;
|
||||
_isMultiple = aFlag;
|
||||
_multiple = aFlag;
|
||||
|
||||
// TODO Notify CPFontPanel when it exists.
|
||||
}
|
||||
@@ -149,11 +149,6 @@ var CPSharedFontManager = nil,
|
||||
return _selectedFont;
|
||||
}
|
||||
|
||||
- (BOOL)isMultiple
|
||||
{
|
||||
return _isMultiple;
|
||||
}
|
||||
|
||||
- (int)weightOfFont:(CPFont)aFont
|
||||
{
|
||||
// TODO Weight 5 is a normal of book weight and 9 and above is bold, but it would be nice to be more
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPRunLoop.j>
|
||||
@import <Foundation/CPString.j>
|
||||
@import <Foundation/CPData.j>
|
||||
|
||||
|
||||
CPImageLoadStatusInitialized = 0;
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
@import "CPImage.j"
|
||||
@import "CPShadowView.j"
|
||||
|
||||
@global CPImagesPboardType
|
||||
@global appkit_tag_dom_elements
|
||||
|
||||
CPImageAlignCenter = 0;
|
||||
CPImageAlignTop = 1;
|
||||
CPImageAlignTopLeft = 2;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPDictionary.j>
|
||||
@import <Foundation/CPValueTransformer.j>
|
||||
@import <Foundation/CPKeyValueObserving.j>
|
||||
|
||||
|
||||
var exposedBindingsMap = [CPDictionary new],
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
@import "CPMenuItem.j"
|
||||
@import "CPPanel.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
CPMenuDidAddItemNotification = @"CPMenuDidAddItemNotification";
|
||||
CPMenuDidChangeItemNotification = @"CPMenuDidChangeItemNotification";
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
@import "CPPanel.j"
|
||||
@import "_CPMenuWindow.j"
|
||||
|
||||
@global CPMenuDidAddItemNotification
|
||||
@global CPMenuDidChangeItemNotification
|
||||
@global CPMenuDidRemoveItemNotification
|
||||
|
||||
@implementation _CPMenuBarWindow : CPPanel
|
||||
{
|
||||
CPMenu _menu;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@class _CPMenuWindow
|
||||
|
||||
@global CPApp
|
||||
@global CPMenuDidEndTrackingNotification
|
||||
@global _CPMenuWindowMenuBarBackgroundStyle
|
||||
@global _CPMenuWindowPopUpBackgroundStyle
|
||||
|
||||
_CPMenuManagerScrollingStateUp = -1;
|
||||
_CPMenuManagerScrollingStateDown = 1;
|
||||
@@ -26,6 +32,8 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
|
||||
CPMenuItem _previousActiveItem;
|
||||
int _showTimerID;
|
||||
|
||||
int _menuBarButtonItemIndex;
|
||||
}
|
||||
|
||||
+ (_CPMenuManager)sharedMenuManager
|
||||
@@ -85,7 +93,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
activeItem = activeItemIndex !== CPNotFound ? [menu itemAtIndex:activeItemIndex] : nil;
|
||||
|
||||
_menuBarButtonItemIndex = activeItemIndex;
|
||||
_menuBarButtonMenuContainer = aMenuContainer;
|
||||
// _menuBarButtonMenuContainer = aMenuContainer;
|
||||
|
||||
if ([activeItem _isMenuBarButton])
|
||||
return [self trackMenuBarButtonEvent:anEvent];
|
||||
@@ -556,7 +564,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
return;
|
||||
}
|
||||
|
||||
next = current + (last - first);
|
||||
var next = current + (last - first);
|
||||
|
||||
if (next < [menu numberOfItems])
|
||||
[menu _highlightItemAtIndex:next];
|
||||
@@ -584,7 +592,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
return;
|
||||
}
|
||||
|
||||
next = current - (last - first);
|
||||
var next = current - (last - first);
|
||||
|
||||
if (next < 0)
|
||||
[menu _highlightItemAtIndex:0];
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
@import "CPView.j"
|
||||
@import "_CPMenuItemView.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
var CPMenuItemStringRepresentationDictionary = [CPDictionary dictionary];
|
||||
[CPMenuItemStringRepresentationDictionary setObject:"\u238B" forKey:CPEscapeFunctionKey];
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
@import "CPView.j"
|
||||
|
||||
@class _CPMenuBarWindow
|
||||
@class _CPMenuView
|
||||
|
||||
@implementation _CPMenuItemMenuBarView : CPView
|
||||
{
|
||||
CPMenuItem _menuItem @accessors(property=menuItem);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@import "_CPMenuItemStandardView.j"
|
||||
@import "_CPMenuItemMenuBarView.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
// var LEFT_MARGIN = 3.0,
|
||||
// RIGHT_MARGIN = 16.0,
|
||||
|
||||
@@ -798,7 +798,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
[_observationProxies removeObjectAtIndex:index];
|
||||
|
||||
_observedObjects = nil;
|
||||
_observedObjectsByKeyPath[aKeyPath] = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -117,7 +117,7 @@ var CPPasteboards = nil,
|
||||
|
||||
if (self)
|
||||
{
|
||||
_name = aName;
|
||||
// _name = aName;
|
||||
_types = [];
|
||||
|
||||
_owners = [CPDictionary dictionary];
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@class CPKeyBinding
|
||||
|
||||
CPDeleteKeyCode = 8;
|
||||
CPTabKeyCode = 9;
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
var children = [CPArray array],
|
||||
itemsCount = 0,
|
||||
menuIndex = -1,
|
||||
itemsArray,
|
||||
itemArray,
|
||||
|
||||
templateView = [templateViews objectAtIndex:count],
|
||||
isPopup = [templateView isKindOfClass:[CPPopUpButton class]];
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/CPPredicate.j>
|
||||
|
||||
@class CPDatePicker
|
||||
|
||||
|
||||
CPUndefinedAttributeType = 0;
|
||||
CPInteger16AttributeType = 100;
|
||||
CPInteger32AttributeType = 200;
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
@import "_CPRuleEditorViewSliceRow.j"
|
||||
@import "_CPRuleEditorLocalizer.j"
|
||||
|
||||
@class CPCompoundPredicate
|
||||
@class CPComparisonPredicate
|
||||
|
||||
@global CPDirectPredicateModifier
|
||||
@global CPCaseInsensitivePredicateOption
|
||||
@global CPOrPredicateType
|
||||
|
||||
|
||||
CPRuleEditorPredicateLeftExpression = "CPRuleEditorPredicateLeftExpression";
|
||||
CPRuleEditorPredicateRightExpression = "CPRuleEditorPredicateRightExpression";
|
||||
CPRuleEditorPredicateComparisonModifier = "CPRuleEditorPredicateComparisonModifier";
|
||||
@@ -1703,8 +1711,8 @@ TODO: implement
|
||||
|
||||
- (void)_setBoundDataSource:(id)datasource withKeyPath:(CPString)keyPath options:(CPDictionary)options
|
||||
{
|
||||
if ([observableController respondsToSelector:@selector(objectClass)])
|
||||
_rowClass = [observableController objectClass];
|
||||
if ([datasource respondsToSelector:@selector(objectClass)])
|
||||
_rowClass = [datasource objectClass];
|
||||
|
||||
_boundArrayKeyPath = keyPath;
|
||||
_boundArrayOwner = datasource;
|
||||
|
||||
@@ -13,7 +13,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
|
||||
{
|
||||
CPDictionary _dictionary @accessors(property=dictionary);
|
||||
CPURLConnection connection;
|
||||
CPURLRequest resquest;
|
||||
CPURLRequest request;
|
||||
}
|
||||
|
||||
- (void)loadContentOfURL:(CPURL)aURL
|
||||
|
||||
@@ -46,9 +46,11 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
{
|
||||
[self setBordered:NO];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var style = _DOMElement.style;
|
||||
style.border = "1px solid " + BORDER_COLOR;
|
||||
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -100,11 +102,13 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
|
||||
var style = _DOMElement.style,
|
||||
radiusCSS = radius + "px";
|
||||
|
||||
style.borderRadius = radiusCSS;
|
||||
#endif
|
||||
|
||||
[super layoutSubviews];
|
||||
}
|
||||
@@ -141,9 +145,11 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
{
|
||||
[self setBordered:NO];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var style = _DOMElement.style;
|
||||
style.border = "1px solid " + BORDER_COLOR;
|
||||
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -164,6 +170,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
|
||||
|
||||
var style = _DOMElement.style,
|
||||
@@ -171,6 +178,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
|
||||
style.borderRadius = radiusCSS;
|
||||
style[GRADIENT_PROPERTY] = ([self isHighlighted]) ? GRADIENT_HIGHLIGHTED : GRADIENT_NORMAL;
|
||||
#endif
|
||||
|
||||
[super layoutSubviews];
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
@import "_CPRuleEditorPopUpButton.j"
|
||||
@import "CPRuleEditor.j"
|
||||
|
||||
@global CPRuleEditorNestingModeCompound
|
||||
@global CPRuleEditorRowTypeCompound
|
||||
@global CPRuleEditorNestingModeSingle
|
||||
|
||||
|
||||
var CONTROL_HEIGHT = 16.,
|
||||
BUTTON_HEIGHT = 16.;
|
||||
|
||||
|
||||
@@ -27,6 +27,13 @@
|
||||
|
||||
@import "CPControl.j"
|
||||
|
||||
@class CPViewAnimation
|
||||
|
||||
@global CPViewAnimationFadeOutEffect
|
||||
@global CPViewAnimationTargetKey
|
||||
@global CPViewAnimationEffectKey
|
||||
|
||||
|
||||
// CPScroller Constants
|
||||
CPScrollerNoPart = 0;
|
||||
CPScrollerDecrementPage = 1;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
@import "CPButton.j"
|
||||
@import "CPTextField.j"
|
||||
|
||||
@class CPUserDefaults
|
||||
|
||||
|
||||
CPSearchFieldRecentsTitleMenuItemTag = 1000;
|
||||
CPSearchFieldRecentsMenuItemTag = 1001;
|
||||
CPSearchFieldClearRecentsMenuItemTag = 1002;
|
||||
|
||||
@@ -39,6 +39,8 @@ CPCircularSlider = 1;
|
||||
double _altIncrementValue;
|
||||
|
||||
BOOL _isVertical;
|
||||
|
||||
CGSize _dragOffset;
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
@import "CPView.j"
|
||||
@import "CPColorPicker.j"
|
||||
|
||||
@class CPSlider
|
||||
|
||||
@global CPColorPickerViewWidth
|
||||
@global CPColorPickerViewHeight
|
||||
@global CPSliderColorPickerMode
|
||||
|
||||
|
||||
/*
|
||||
@ignore
|
||||
@@ -65,7 +71,7 @@
|
||||
|
||||
- (id)initView
|
||||
{
|
||||
aFrame = CGRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
|
||||
var aFrame = CGRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
|
||||
|
||||
_contentView = [[CPView alloc] initWithFrame:aFrame];
|
||||
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ CPSoundPlayBackStatePause = 2;
|
||||
if (self = [super init])
|
||||
{
|
||||
_loadStatus = CPSoundLoadStateEmpty;
|
||||
_loops = NO;
|
||||
// _loops = NO;
|
||||
_audioTag = document.createElement("audio");
|
||||
_audioTag.preload = YES;
|
||||
_playRequestBeforeLoad = NO;
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
@import "CPImage.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPUserDefaults
|
||||
|
||||
|
||||
#define SPLIT_VIEW_MAYBE_POST_WILL_RESIZE() \
|
||||
if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0) \
|
||||
{ \
|
||||
|
||||
@@ -60,6 +60,7 @@ CPPressedTab = 2;
|
||||
CPView _auxiliaryView;
|
||||
|
||||
CPTabView _tabView;
|
||||
unsigned _tabState; // Looks like it is not yet implemented
|
||||
}
|
||||
|
||||
- (id)init
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
@import "CPTableHeaderView.j"
|
||||
@import "CPKeyValueBinding.j"
|
||||
|
||||
@global CPTableViewColumnDidResizeNotification
|
||||
|
||||
|
||||
CPTableColumnNoResizing = 0;
|
||||
CPTableColumnAutoresizingMask = 1 << 0;
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
@import "CPTableView.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPCursor
|
||||
|
||||
@global CPTableColumnUserResizingMask
|
||||
|
||||
|
||||
@implementation _CPTableColumnHeaderView : CPView
|
||||
{
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
@import "CPScroller.j"
|
||||
@import "CPCompatibility.j"
|
||||
|
||||
@class CPScrollView
|
||||
@class CPUserDefaults
|
||||
|
||||
|
||||
CPTableViewColumnDidMoveNotification = @"CPTableViewColumnDidMoveNotification";
|
||||
CPTableViewColumnDidResizeNotification = @"CPTableViewColumnDidResizeNotification";
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
@import "CPCompatibility.j"
|
||||
@import "_CPImageAndTextView.j"
|
||||
|
||||
@class CPPasteboard
|
||||
|
||||
@global CPApp
|
||||
@global CPStringPboardType
|
||||
|
||||
CPTextFieldSquareBezel = 0; /*! A textfield bezel with squared corners. */
|
||||
CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */
|
||||
@@ -34,8 +38,6 @@ CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corne
|
||||
CPTextFieldDidFocusNotification = @"CPTextFieldDidFocusNotification";
|
||||
CPTextFieldDidBlurNotification = @"CPTextFieldDidBlurNotification";
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var CPTextFieldDOMInputElement = nil,
|
||||
CPTextFieldDOMPasswordInputElement = nil,
|
||||
CPTextFieldDOMStandardInputElement = nil,
|
||||
@@ -49,8 +51,6 @@ var CPTextFieldDOMInputElement = nil,
|
||||
CPTextFieldBlurHandler = nil,
|
||||
CPTextFieldInputFunction = nil;
|
||||
|
||||
#endif
|
||||
|
||||
var CPSecureTextFieldCharacter = "\u2022";
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@
|
||||
@import <Foundation/CPString.j>
|
||||
@import <Foundation/CPKeyedUnarchiver.j>
|
||||
|
||||
@class CPView
|
||||
|
||||
var CPThemesByName = { },
|
||||
CPThemeDefaultTheme = nil,
|
||||
@@ -146,7 +147,7 @@ var CPThemesByName = { },
|
||||
className = [aClass defaultThemeClass];
|
||||
else if ([aClass respondsToSelector:@selector(themeClass)])
|
||||
{
|
||||
CPLog.warn(@"%@ themeClass is deprecated in favor of defaultThemeClass",CPStringFromClass([anObject class]));
|
||||
CPLog.warn(@"%@ themeClass is deprecated in favor of defaultThemeClass",CPStringFromClass(aClass));
|
||||
className = [aClass themeClass];
|
||||
}
|
||||
else
|
||||
|
||||
@@ -911,7 +911,9 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
CPTokenFieldTextDidChangeValue = [self stringValue];
|
||||
#endif
|
||||
|
||||
// Leave the default _propagateCurrentDOMEvent setting in place. This might be YES or NO depending
|
||||
// on if something that could be a browser shortcut was pressed or not, such as Cmd-R to reload.
|
||||
@@ -925,10 +927,12 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (void)keyUp:(CPEvent)anEvent
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if ([self stringValue] !== CPTokenFieldTextDidChangeValue)
|
||||
{
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
#endif
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
@import <Foundation/CPString.j>
|
||||
@import "CPController.j"
|
||||
|
||||
@class CPUserDefaults
|
||||
|
||||
@global CPUserDefaultsDidChangeNotification
|
||||
|
||||
|
||||
var SharedUserDefaultsController = nil;
|
||||
|
||||
@implementation CPUserDefaultsController : CPController
|
||||
@@ -34,6 +39,7 @@ var SharedUserDefaultsController = nil;
|
||||
CPUserDefaults _defaults @accessors(readonly, property=defaults);
|
||||
CPDictionary _initialValues @accessors(property=initialValues);
|
||||
BOOL _appliesImmediately @accessors(property=appliesImmediately);
|
||||
id _valueProxy;
|
||||
}
|
||||
|
||||
+ (id)sharedUserDefaultsController
|
||||
|
||||
+13
-1
@@ -34,6 +34,18 @@
|
||||
@import "CPTheme.j"
|
||||
@import "_CPDisplayServer.j"
|
||||
|
||||
@class _CPToolTip
|
||||
@class CPWindow
|
||||
@class _CPMenuItemView
|
||||
@class CPPlatformWindow
|
||||
@class CPMenu
|
||||
@class CPClipView
|
||||
@class CPScrollView
|
||||
|
||||
@global appkit_tag_dom_elements
|
||||
@global CPWindowAbove
|
||||
@global CPBorderlessWindowMask
|
||||
@global CPScreenSaverWindowLevel
|
||||
|
||||
/*
|
||||
@global
|
||||
@@ -2192,6 +2204,7 @@ setBoundsOrigin:
|
||||
{
|
||||
var graphicsPort = CGBitmapGraphicsContextCreate();
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMContentsElement = graphicsPort.DOMElement;
|
||||
|
||||
_DOMContentsElement.style.zIndex = -100;
|
||||
@@ -2208,7 +2221,6 @@ setBoundsOrigin:
|
||||
_DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_frame)) + "px";
|
||||
_DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_frame)) + "px";
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// The performance implications of this aren't clear, but without this subviews might not be redrawn when this
|
||||
// view moves.
|
||||
if (CPPlatformHasBug(CPCanvasParentDrawErrorsOnMovementBug))
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
@import "CPCib.j"
|
||||
@import "CPResponder.j"
|
||||
|
||||
@class CPDocument
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
var CPViewControllerCachedCibs;
|
||||
|
||||
@@ -222,7 +226,7 @@ var CPViewControllerCachedCibs;
|
||||
{
|
||||
[self willChangeValueForKey:"isViewLoaded"];
|
||||
[self viewDidLoad];
|
||||
isViewLoaded = YES;
|
||||
_isViewLoaded = YES;
|
||||
[self didChangeValueForKey:"isViewLoaded"];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
*/
|
||||
|
||||
@import "_CPWindowView.j"
|
||||
@import "CGGradient.j"
|
||||
|
||||
@global CPPopoverAppearanceMinimal
|
||||
|
||||
#define ALIGN_STROKE(point) (FLOOR(point) === (point) ? (point) + halfStrokeWidth : (point))
|
||||
#define ALIGN_COORD(point) (FLOOR(point))
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
@import "CPTextField.j"
|
||||
@import "_CPTitleableWindowView.j"
|
||||
|
||||
@class _CPDocModalWindowView
|
||||
|
||||
@implementation _CPTexturedWindowHeadView : CPView
|
||||
{
|
||||
CPView _gradientView;
|
||||
|
||||
@@ -34,6 +34,17 @@
|
||||
@import "CPPlatformWindow+DOM.j"
|
||||
#endif
|
||||
|
||||
@class _CPShadowWindowView
|
||||
@class CPCursor
|
||||
@class CPDragServer
|
||||
@class CPMenu
|
||||
@class CPProgressIndicator
|
||||
|
||||
@global CPApp
|
||||
@global CPWindowPositionFlexibleLeft
|
||||
@global CPWindowPositionFlexibleRight
|
||||
@global CPWindowPositionFlexibleTop
|
||||
@global CPWindowPositionFlexibleBottom
|
||||
|
||||
/*
|
||||
Borderless window mask option.
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
@import "CPImageView.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPCursor
|
||||
@class CPMenu
|
||||
|
||||
@global CPApp
|
||||
|
||||
var _CPWindowViewCornerResizeRectWidth = 10,
|
||||
_CPWindowViewResizeRegionNone = -1,
|
||||
|
||||
@@ -27,6 +27,13 @@
|
||||
@import "CPWindow.j"
|
||||
@import "CPDocument.j"
|
||||
|
||||
@class CPDocument
|
||||
|
||||
@global CPApp
|
||||
@global CPDocumentWillSaveNotification
|
||||
@global CPDocumentDidSaveNotification
|
||||
@global CPDocumentDidFailToSaveNotification
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@class CPApplication
|
||||
|
||||
|
||||
var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPString.j>
|
||||
|
||||
@class CPButtonBar
|
||||
|
||||
|
||||
var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
_CPCibCustomResourceResourceNameKey = @"_CPCibCustomResourceResourceNameKey",
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
@import "CPCibRuntimeAttributesConnector.j"
|
||||
@import "CPCibHelpConnector.j"
|
||||
|
||||
@class CPScrollView
|
||||
|
||||
|
||||
@implementation _CPCibObjectData : CPObject
|
||||
{
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
@import "CGGeometry.j"
|
||||
@import "CPWindow.j"
|
||||
|
||||
@class CPToolbar
|
||||
|
||||
@global CPPositionProportionalHorizontal
|
||||
@global CPPositionProportionalVertical
|
||||
|
||||
CPWindowPositionFlexibleRight = 1 << 19;
|
||||
CPWindowPositionFlexibleLeft = 1 << 20;
|
||||
CPWindowPositionFlexibleBottom = 1 << 21;
|
||||
|
||||
@@ -85,6 +85,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
|
||||
|
||||
float _opacity;
|
||||
BOOL _isHidden;
|
||||
BOOL _masksToBounds;
|
||||
CPColor _backgroundColor;
|
||||
|
||||
// Managing Layer Hierarchy
|
||||
@@ -856,7 +857,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
|
||||
*/
|
||||
- (void)setNeedsDisplayInRect:(CGRect)aRect
|
||||
{
|
||||
_dirtyRect = aRect;
|
||||
// _dirtyRect = aRect;
|
||||
[self display];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,14 @@
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "CPKeyBinding.j"
|
||||
//@import "CPMenu.j"
|
||||
@import "CPPlatform.j"
|
||||
//@import "CPEvent.j"
|
||||
|
||||
@class CPMenu
|
||||
|
||||
@global CPApp
|
||||
|
||||
var PrimaryPlatformWindow = NULL;
|
||||
|
||||
|
||||
@@ -119,6 +119,25 @@
|
||||
@import "CPPlatformWindow.j"
|
||||
@import "CPPlatformWindow+DOMKeys.j"
|
||||
|
||||
@class CPCursor
|
||||
@class CPDragServer
|
||||
@class CPPasteboard
|
||||
@class _CPDOMDataTransferPasteboard
|
||||
@class _CPToolTip
|
||||
|
||||
@global CPDragOperationNone
|
||||
@global CPDragOperationMove
|
||||
@global CPDragOperationCopy
|
||||
@global CPDragOperationLink
|
||||
@global CPDragOperationPrivate
|
||||
@global CPDragOperationGeneric
|
||||
@global CPApp
|
||||
@global CPStringPboardType
|
||||
@global CPWindowOut
|
||||
@global _CPRunModalLoop
|
||||
@global CPDraggingWindowLevel
|
||||
@global CPWindowAbove
|
||||
|
||||
// List of all open native windows
|
||||
var PlatformWindows = [CPSet set];
|
||||
|
||||
@@ -192,6 +211,7 @@ var ModifierKeyCodes = [
|
||||
|
||||
var resizeTimer = nil;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
@implementation CPPlatformWindow (DOM)
|
||||
|
||||
- (id)_init
|
||||
@@ -795,7 +815,7 @@ var resizeTimer = nil;
|
||||
if (!characters)
|
||||
characters = String.fromCharCode(charCode);
|
||||
|
||||
charactersIgnoringModifiers = characters.toLowerCase(); // FIXME: This isn't correct. It SHOULD include Shift.
|
||||
var charactersIgnoringModifiers = characters.toLowerCase(); // FIXME: This isn't correct. It SHOULD include Shift.
|
||||
|
||||
// Safari won't send proper capitalization during cmd-key events
|
||||
if (!overrideCharacters && (modifierFlags & CPCommandKeyMask) && ((modifierFlags & CPShiftKeyMask) || _capsLockActive))
|
||||
@@ -879,7 +899,7 @@ var resizeTimer = nil;
|
||||
windowNumber = [[CPApp keyWindow] windowNumber],
|
||||
modifierFlags = CPPlatformActionKeyMask;
|
||||
|
||||
event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
|
||||
var event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
|
||||
timestamp:timestamp windowNumber:windowNumber context:nil
|
||||
characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode];
|
||||
|
||||
@@ -1581,6 +1601,7 @@ var resizeTimer = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
var CPEventClass = [CPEvent class];
|
||||
|
||||
|
||||
@@ -354,8 +354,10 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
{
|
||||
var browserProperty = CPBrowserStyleProperty(aProperty);
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (browserProperty)
|
||||
_DOMElement.style[browserProperty] = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
@@ -430,7 +432,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
var transformOrigin = "50% 100%",
|
||||
frame = [self frame],
|
||||
preferredEdge = [_windowView preferredEdge],
|
||||
posX;
|
||||
posX, posY;
|
||||
|
||||
switch (preferredEdge)
|
||||
{
|
||||
@@ -455,9 +457,11 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
window.setTimeout(function()
|
||||
{
|
||||
// We are watching opacity, so this triggers the next transition
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.style.opacity = 1;
|
||||
_DOMElement.style.height = frame.size.height + @"px";
|
||||
_DOMElement.style.width = frame.size.width + @"px";
|
||||
#endif
|
||||
|
||||
// Set up the pop-out transition
|
||||
[self setCSS3Property:@"Transform" value:@"scale(1.1)"];
|
||||
@@ -465,7 +469,9 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
|
||||
var transitionEndFunction = function()
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), transitionEndFunction, YES);
|
||||
#endif
|
||||
|
||||
// Now set up the pop-in to normal size transition.
|
||||
// Because we are watching the -webkit-transform, it will occur now.
|
||||
@@ -474,21 +480,29 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
|
||||
var transitionCompleteFunction = function()
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), transitionCompleteFunction, YES);
|
||||
#endif
|
||||
if (_implementedDelegateMethods & _CPAttachedWindow_attachedWindowDidShow_)
|
||||
[_delegate attachedWindowDidShow:self];
|
||||
}
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), transitionCompleteFunction, YES);
|
||||
#endif
|
||||
};
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), transitionEndFunction, YES);
|
||||
#endif
|
||||
}, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setCSS3Property:@"Transition" value:@""];
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.style.opacity = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,15 +525,21 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
{
|
||||
// Tell the element to fade out when the opacity changes
|
||||
[self setCSS3Property:@"Transition" value:@"opacity 250ms linear"];
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.style.opacity = 0;
|
||||
#endif
|
||||
|
||||
var transitionEndFunction = function()
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.removeEventListener(CPBrowserStyleProperty("transitionend"), transitionEndFunction, YES);
|
||||
#endif
|
||||
[self _close];
|
||||
};
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.addEventListener(CPBrowserStyleProperty("transitionend"), transitionEndFunction, YES);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
@import "CPTableView.j"
|
||||
@import "_CPMenuWindow.j"
|
||||
|
||||
@class CPScrollView
|
||||
|
||||
|
||||
// TODO Make themable.
|
||||
var _CPAutocompleteMenuMaximumHeight = 307;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
@import "CPImage.j"
|
||||
@import "CPView.j"
|
||||
@import "CPControl.j"
|
||||
@import "CPPlatform.j"
|
||||
|
||||
|
||||
var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
@@ -294,6 +295,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
|
||||
var textFrame = _CGRectMakeZero();
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (_DOMTextElement)
|
||||
{
|
||||
var textStyle = _DOMTextElement.style;
|
||||
@@ -306,6 +308,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
textFrame.size.width += _textShadowOffset.width;
|
||||
textFrame.size.height += _textShadowOffset.height;
|
||||
}
|
||||
#endif
|
||||
|
||||
return textFrame;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
@import "CPPanel.j"
|
||||
@import "_CPPopUpListDataSource.j"
|
||||
|
||||
@class CPScrollView
|
||||
|
||||
@global CPLineBorder
|
||||
|
||||
|
||||
/*!
|
||||
Notification sent when the list is about to pop up. \c object is the _CPPopUpList.
|
||||
@@ -840,7 +844,7 @@ var _CPPopUpListDataSourceKey = @"_CPPopUpListDataSourceKey",
|
||||
*/
|
||||
- (CPTableColumn)listColumn
|
||||
{
|
||||
return _tableColumn;
|
||||
return _tableColumns[0];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
@import "CPNull.j"
|
||||
@import "_CPCollectionKVCOperators.j"
|
||||
|
||||
@class CPIndexSet
|
||||
|
||||
@implementation CPObject (CPArrayKVO)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
@import "_CPArray.j"
|
||||
|
||||
@class CPIndexSet
|
||||
|
||||
/*!
|
||||
@class CPMutableArray
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
@import "CPRange.j"
|
||||
@import "CPSortDescriptor.j"
|
||||
|
||||
@class _CPJavaScriptArray
|
||||
@class CPIndexSet
|
||||
|
||||
CPEnumerationNormal = 0;
|
||||
CPEnumerationConcurrent = 1 << 0;
|
||||
|
||||
@@ -237,8 +237,8 @@ var CPCharacterSetInvertedKey = @"CPCharacterSetInvertedKey";
|
||||
|
||||
- (BOOL)characterIsMember:(CPString)aCharacter
|
||||
{
|
||||
c = aCharacter.charCodeAt(0);
|
||||
var enu = [_ranges objectEnumerator],
|
||||
var c = aCharacter.charCodeAt(0),
|
||||
enu = [_ranges objectEnumerator],
|
||||
range;
|
||||
|
||||
while ((range = [enu nextObject]) !== nil)
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
@import "CPException.j"
|
||||
@import "CPObject.j"
|
||||
|
||||
@global _CPRaiseInvalidAbstractInvocation;
|
||||
|
||||
/*!
|
||||
@class CPCoder
|
||||
@ingroup foundation
|
||||
|
||||
@@ -78,9 +78,9 @@ CPDateFormatterFullStyle = 4;
|
||||
{
|
||||
case CPDateFormatterShortStyle:
|
||||
var format = "d/m/Y";
|
||||
return Date.parseDate(string, format);
|
||||
return Date.parseDate(aString, format);
|
||||
default:
|
||||
return Date.parseDate(string);
|
||||
return Date.parseDate(aString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ CPInvalidArgumentException = @"CPInvalidArgumentException";
|
||||
CPUnsupportedMethodException = @"CPUnsupportedMethodException";
|
||||
CPRangeException = @"CPRangeException";
|
||||
CPInternalInconsistencyException = @"CPInternalInconsistencyException";
|
||||
CPGenericException = @"CPGenericException";
|
||||
|
||||
/*!
|
||||
@class CPException
|
||||
|
||||
@@ -33,8 +33,8 @@ var CPArchiverReplacementClassNames = nil;
|
||||
var _CPKeyedArchiverDidEncodeObjectSelector = 1,
|
||||
_CPKeyedArchiverWillEncodeObjectSelector = 2,
|
||||
_CPKeyedArchiverWillReplaceObjectWithObjectSelector = 4,
|
||||
_CPKeyedArchiverDidFinishSelector = 8,
|
||||
_CPKeyedArchiverWillFinishSelector = 16;
|
||||
_CPKeyedArchiverDidFinishEncodingSelector = 8,
|
||||
_CPKeyedArchiverWillFinishEncodingSelector = 16;
|
||||
|
||||
var _CPKeyedArchiverNullString = "$null",
|
||||
_CPKeyedArchiverNullReference = nil,
|
||||
@@ -190,7 +190,7 @@ var _CPKeyedArchiverStringClass = Nil,
|
||||
*/
|
||||
- (void)finishEncoding
|
||||
{
|
||||
if (_delegate && _delegateSelectors & _CPKeyedArchiverWillFinishSelector)
|
||||
if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishEncodingSelector)
|
||||
[_delegate archiverWillFinish:self];
|
||||
|
||||
var i = 0,
|
||||
@@ -220,7 +220,7 @@ var _CPKeyedArchiverStringClass = Nil,
|
||||
|
||||
[_data setPlistObject:_plistObject];
|
||||
|
||||
if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishSelector)
|
||||
if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishEncodingSelector)
|
||||
[_delegate archiverDidFinish:self];
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ var _CPKeyedArchiverStringClass = Nil,
|
||||
if (!_replacementClassNames)
|
||||
return aClass.name;
|
||||
|
||||
var className = [_replacementClassNames objectForKey:CPStringFromClass(aClassName)];
|
||||
var className = [_replacementClassNames objectForKey:CPStringFromClass(aClass)];
|
||||
|
||||
return className ? className : aClass.name;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ var CPArrayClass = Ni
|
||||
_delegateSelectors |= _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(unarchiverWillFinish:)])
|
||||
_delegateSelectors |= _CPKeyedUnarchiverWilFinishSelector;
|
||||
_delegateSelectors |= _CPKeyedUnarchiverWillFinishSelector;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(unarchiverDidFinish:)])
|
||||
_delegateSelectors |= _CPKeyedUnarchiverDidFinishSelector;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
@import "CPException.j"
|
||||
@import "CPNotification.j"
|
||||
@import "CPNull.j"
|
||||
@import "CPSet.j"
|
||||
|
||||
var CPNotificationDefaultCenter = nil;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
@import "CPArray.j"
|
||||
@import "CPObject.j"
|
||||
|
||||
@global CPKeyValueObservingOptionNew
|
||||
|
||||
/*!
|
||||
Operations receive very low priority for execution.
|
||||
@global
|
||||
|
||||
@@ -50,7 +50,7 @@ var cpOperationMainQueue = nil;
|
||||
{
|
||||
_operations = [[CPArray alloc] init];
|
||||
_suspended = NO;
|
||||
_currentlyModifyingOps = NO;
|
||||
// _currentlyModifyingOps = NO;
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:0.01
|
||||
target:self
|
||||
selector:@selector(_runNextOpsInQueue)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
@import "CPEnumerator.j"
|
||||
@import "CPExpression.j"
|
||||
@import "CPNull.j"
|
||||
@import "CPPredicate.j"
|
||||
@import "_CPPredicate.j"
|
||||
@import "CPString.j"
|
||||
|
||||
/*!
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
@import "CPArray.j"
|
||||
@import "CPPredicate.j"
|
||||
@import "_CPPredicate.j"
|
||||
|
||||
/*!
|
||||
A predicate to directly compare the left and right hand sides.
|
||||
|
||||
@@ -22,954 +22,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CPArray.j"
|
||||
@import "CPException.j"
|
||||
@import "CPNull.j"
|
||||
@import "CPObject.j"
|
||||
@import "CPScanner.j"
|
||||
@import "CPSet.j"
|
||||
@import "CPValue.j"
|
||||
@import "CPCharacterSet.j"
|
||||
|
||||
/*!
|
||||
@ingroup foundation
|
||||
@class CPPredicate
|
||||
@brief The CPPredicate class is used to define logical conditions used to constrain a search either for a fetch or for in-memory filtering.
|
||||
|
||||
You use predicates to represent logical conditions, used for describing objects in persistent stores
|
||||
and in-memory filtering of objects. Although it is common to create predicates directly from instances
|
||||
of CPComparisonPredicate, CPCompoundPredicate, and CPExpression, you often create predicates from a
|
||||
format string which is parsed by the class methods on CPPredicate. Examples of predicate format strings include:
|
||||
|
||||
- Simple comparisons, such as <code>grade == "7"</code> or <code>firstName like "Shaffiq"</code>
|
||||
- Case/diacritic insensitive lookups, such as <code>name contains[cd] "itroen"</code>
|
||||
- Logical operations, such as <code>(firstName like "Mark") OR (lastName like "Adderley")</code>
|
||||
- “Between” predicates such as <code>date between {$YESTERDAY, $TOMORROW}</code>.
|
||||
|
||||
You can create predicates for relationships, such as:
|
||||
|
||||
- <code>group.name like "work*"</code>
|
||||
- <code>ALL children.age > 12</code>
|
||||
- <code>ANY children.age > 12</code>
|
||||
|
||||
You can create predicates for operations, such as <code>\@sum.items.price < 1000</code>.
|
||||
|
||||
You can also create predicates that include variables, so that the predicate can be pre-defined before
|
||||
substituting concrete values at runtime with the \c evaluateWithObject:substitutionVariables: method.
|
||||
*/
|
||||
|
||||
@implementation CPPredicate : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a new predicate formed by creating a new string with a given format and parsing the result.
|
||||
@param format The format string for the new predicate.
|
||||
@param … A comma-separated list of arguments to substitute into format.
|
||||
@return A new predicate formed by creating a new string with format and parsing the result.
|
||||
*/
|
||||
+ (CPPredicate)predicateWithFormat:(CPString)format, ...
|
||||
{
|
||||
if (!format)
|
||||
[CPException raise:CPInvalidArgumentException reason:_cmd + " the format can't be 'nil'"];
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 3);
|
||||
return [self predicateWithFormat:arguments[2] argumentArray:args];
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a new predicate by substituting the values in a given array into a format string and parsing the result.
|
||||
@param format The format string for the new predicate.
|
||||
@param arguments The arguments to substitute into predicateFormat. Values are substituted into predicateFormat in the order they appear in the array.
|
||||
@return A new predicate by substituting the values in arguments into predicateFormat, and parsing the result.
|
||||
*/
|
||||
+ (CPPredicate)predicateWithFormat:(CPString)format argumentArray:(CPArray)args
|
||||
{
|
||||
if (!format)
|
||||
[CPException raise:CPInvalidArgumentException reason:_cmd + " the format can't be 'nil'"];
|
||||
|
||||
var s = [[CPPredicateScanner alloc] initWithString:format args:args],
|
||||
p = [s parse];
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a new predicate by substituting the values in an argument list into a format string and parsing the result.
|
||||
@param format The format string for the new predicate.
|
||||
@param argList The arguments to substitute into predicateFormat. Values are substituted into predicateFormat in the order they appear in the argument list.
|
||||
@return A new predicate by substituting the values in argList into predicateFormat and parsing the result.
|
||||
*/
|
||||
+ (CPPredicate)predicateWithFormat:(CPString)format arguments:(va_list)argList
|
||||
{
|
||||
// UNIMPLEMENTED
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a copy of the receiver with the receiver’s variables substituted by values specified in a given substitution variables dictionary.
|
||||
@param variables The substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver.
|
||||
@return A copy of the receiver with the receiver’s variables substituted by values specified in variables.
|
||||
*/
|
||||
- (CPPredicate)predicateWithSubstitutionVariables:(CPDictionary)variables
|
||||
{
|
||||
// IMPLEMENTED BY SUBCLASSES
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a predicate that always evaluates to a given value.
|
||||
@param value The value to which the new predicate should evaluate.
|
||||
@return A predicate that always evaluates to value.
|
||||
*/
|
||||
+ (CPPredicate)predicateWithValue:(BOOL)value
|
||||
{
|
||||
return [[CPPredicate_BOOL alloc] initWithBool:value];
|
||||
}
|
||||
|
||||
// Evaluating a Predicate
|
||||
/*!
|
||||
Returns a Boolean value that indicates whether a given object matches the conditions specified by the receiver.
|
||||
@param object The object against which to evaluate the receiver.
|
||||
@return YES if object matches the conditions specified by the receiver, otherwise NO.
|
||||
*/
|
||||
- (BOOL)evaluateWithObject:(id)object
|
||||
{
|
||||
// IMPLEMENTED BY SUBCLASSES
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a Boolean value that indicates whether a given object matches the conditions specified by the receiver after substituting in the values in a given variables dictionary.
|
||||
@param object The object against which to evaluate the receiver.
|
||||
@param variables The substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver.
|
||||
@return YES if object matches the conditions specified by the receiver after substituting in the values in variables for any replacement tokens, otherwise NO.
|
||||
*/
|
||||
- (BOOL)evaluateWithObject:(id)object substitutionVariables:(CPDictionary)variables
|
||||
{
|
||||
// IMPLEMENTED BY SUBCLASSES
|
||||
}
|
||||
|
||||
// Getting Format Information
|
||||
/*!
|
||||
Returns the receiver’s format string.
|
||||
@return The receiver’s format string.
|
||||
*/
|
||||
- (CPString)predicateFormat
|
||||
{
|
||||
// IMPLEMENTED BY SUBCLASSES
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [self predicateFormat];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPPredicate_BOOL : CPPredicate
|
||||
{
|
||||
BOOL _value;
|
||||
}
|
||||
|
||||
- (id)initWithBool:(BOOL)value
|
||||
{
|
||||
_value = value;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
if (self === anObject)
|
||||
return YES;
|
||||
|
||||
if (self.isa !== anObject.isa || _value !== [anObject evaluateObject:nil])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)evaluateObject:(id)object
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
- (CPString)predicateFormat
|
||||
{
|
||||
return (_value) ? @"TRUEPREDICATE" : @"FALSEPREDICATE";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPArray (CPPredicate)
|
||||
|
||||
- (CPArray)filteredArrayUsingPredicate:(CPPredicate)predicate
|
||||
{
|
||||
var count = [self count],
|
||||
result = [CPArray array],
|
||||
i = 0;
|
||||
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var object = [self objectAtIndex:i];
|
||||
if ([predicate evaluateWithObject:object])
|
||||
result.push(object);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)filterUsingPredicate:(CPPredicate)predicate
|
||||
{
|
||||
var count = [self count];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
if (![predicate evaluateWithObject:[self objectAtIndex:count]])
|
||||
self.splice(count, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPSet (CPPredicate)
|
||||
|
||||
- (CPSet)filteredSetUsingPredicate:(CPPredicate)predicate
|
||||
{
|
||||
var count = [self count],
|
||||
result = [CPSet set],
|
||||
i = 0;
|
||||
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var object = [self objectAtIndex:i];
|
||||
|
||||
if ([predicate evaluateWithObject:object])
|
||||
[result addObject:object];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)filterUsingPredicate:(CPPredicate)predicate
|
||||
{
|
||||
var count = [self count];
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
var object = [self objectAtIndex:count];
|
||||
|
||||
if (![predicate evaluateWithObject:object])
|
||||
[self removeObjectAtIndex:count];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#define REFERENCE(variable) \
|
||||
function(newValue)\
|
||||
{\
|
||||
var oldValue = variable;\
|
||||
if (typeof newValue != 'undefined')\
|
||||
variable = newValue;\
|
||||
return oldValue;\
|
||||
}
|
||||
|
||||
@implementation CPPredicateScanner : CPScanner
|
||||
{
|
||||
CPEnumerator _args;
|
||||
unsigned _retrieved;
|
||||
}
|
||||
|
||||
- (id)initWithString:(CPString)format args:(CPArray)args
|
||||
{
|
||||
self = [super initWithString:format]
|
||||
|
||||
if (self)
|
||||
{
|
||||
_args = [args objectEnumerator];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)nextArg
|
||||
{
|
||||
return [_args nextObject];
|
||||
}
|
||||
|
||||
- (BOOL)scanPredicateKeyword:(CPString)key
|
||||
{
|
||||
var loc = [self scanLocation];
|
||||
|
||||
[self setCaseSensitive:NO];
|
||||
if (![self scanString:key intoString:NULL])
|
||||
return NO;
|
||||
|
||||
if ([self isAtEnd])
|
||||
return YES;
|
||||
|
||||
var c = [[self string] characterAtIndex:[self scanLocation]];
|
||||
if (![[CPCharacterSet alphanumericCharacterSet] characterIsMember:c])
|
||||
return YES;
|
||||
|
||||
[self setScanLocation:loc];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPPredicate)parse
|
||||
{
|
||||
var r = nil;
|
||||
|
||||
try
|
||||
{
|
||||
[self setCharactersToBeSkipped:[CPCharacterSet whitespaceCharacterSet]];
|
||||
r = [self parsePredicate];
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
CPLogConsole(@"Unable to parse predicate '" + [self string] + "' with " + error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (![self isAtEnd])
|
||||
{
|
||||
var pstr = [self string],
|
||||
loc = [self scanLocation];
|
||||
CPLogConsole(@"Format string contains extra characters: '" + [pstr substringToIndex:loc] + "**" + [pstr substringFromIndex:loc] + "**'");
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
- (CPPredicate)parsePredicate
|
||||
{
|
||||
return [self parseAnd];
|
||||
}
|
||||
|
||||
- (CPPredicate)parseAnd
|
||||
{
|
||||
var l = [self parseOr];
|
||||
|
||||
while ([self scanPredicateKeyword:@"AND"] || [self scanPredicateKeyword:@"&&"])
|
||||
{
|
||||
var r = [self parseOr];
|
||||
|
||||
if ([r isKindOfClass:[CPCompoundPredicate class]] && [r compoundPredicateType] == CPAndPredicateType)
|
||||
{
|
||||
if ([l isKindOfClass:[CPCompoundPredicate class]] && [l compoundPredicateType] == CPAndPredicateType)
|
||||
{
|
||||
[[l subpredicates] addObjectsFromArray:[r subpredicates]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[r subpredicates] insertObject:l atIndex:0];
|
||||
l = r;
|
||||
}
|
||||
}
|
||||
else if ([l isKindOfClass:[CPCompoundPredicate class]] && [l compoundPredicateType] == CPAndPredicateType)
|
||||
{
|
||||
[[l subpredicates] addObject:r];
|
||||
}
|
||||
else
|
||||
{
|
||||
l = [CPCompoundPredicate andPredicateWithSubpredicates:[CPArray arrayWithObjects:l, r]];
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
- (CPPredicate)parseNot
|
||||
{
|
||||
if ([self scanString:@"(" intoString:NULL])
|
||||
{
|
||||
var r = [self parsePredicate];
|
||||
|
||||
if (![self scanString:@")" intoString:NULL])
|
||||
CPRaiseParseError(self, @"predicate");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
if ([self scanPredicateKeyword:@"NOT"] || [self scanPredicateKeyword:@"!"])
|
||||
{
|
||||
return [CPCompoundPredicate notPredicateWithSubpredicate:[self parseNot]];
|
||||
}
|
||||
if ([self scanPredicateKeyword:@"TRUEPREDICATE"])
|
||||
{
|
||||
return [CPPredicate predicateWithValue:YES];
|
||||
}
|
||||
if ([self scanPredicateKeyword:@"FALSEPREDICATE"])
|
||||
{
|
||||
return [CPPredicate predicateWithValue:NO];
|
||||
}
|
||||
|
||||
return [self parseComparison];
|
||||
}
|
||||
|
||||
- (CPPredicate)parseOr
|
||||
{
|
||||
var l = [self parseNot];
|
||||
while ([self scanPredicateKeyword:@"OR"] || [self scanPredicateKeyword:@"||"])
|
||||
{
|
||||
var r = [self parseNot];
|
||||
|
||||
if ([r isKindOfClass:[CPCompoundPredicate class]] && [r compoundPredicateType] == CPOrPredicateType)
|
||||
{
|
||||
if ([l isKindOfClass:[CPCompoundPredicate class]] && [l compoundPredicateType] == CPOrPredicateType)
|
||||
{
|
||||
[[l subpredicates] addObjectsFromArray:[r subpredicates]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[r subpredicates] insertObject:l atIndex:0];
|
||||
l = r;
|
||||
}
|
||||
}
|
||||
else if ([l isKindOfClass:[CPCompoundPredicate class]] && [l compoundPredicateType] == CPOrPredicateType)
|
||||
{
|
||||
[[l subpredicates] addObject:r];
|
||||
}
|
||||
else
|
||||
{
|
||||
l = [CPCompoundPredicate orPredicateWithSubpredicates:[CPArray arrayWithObjects:l, r]];
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
- (CPPredicate)parseComparison
|
||||
{
|
||||
var modifier = CPDirectPredicateModifier,
|
||||
type = 0,
|
||||
opts = 0,
|
||||
left,
|
||||
right,
|
||||
p,
|
||||
negate = NO;
|
||||
|
||||
if ([self scanPredicateKeyword:@"ANY"])
|
||||
{
|
||||
modifier = CPAnyPredicateModifier;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"ALL"])
|
||||
{
|
||||
modifier = CPAllPredicateModifier;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"NONE"])
|
||||
{
|
||||
modifier = CPAnyPredicateModifier;
|
||||
negate = YES;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"SOME"])
|
||||
{
|
||||
modifier = CPAllPredicateModifier;
|
||||
negate = YES;
|
||||
}
|
||||
|
||||
left = [self parseExpression];
|
||||
if ([self scanString:@"!=" intoString:NULL] || [self scanString:@"<>" intoString:NULL])
|
||||
{
|
||||
type = CPNotEqualToPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanString:@"<=" intoString:NULL] || [self scanString:@"=<" intoString:NULL])
|
||||
{
|
||||
type = CPLessThanOrEqualToPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanString:@">=" intoString:NULL] || [self scanString:@"=>" intoString:NULL])
|
||||
{
|
||||
type = CPGreaterThanOrEqualToPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanString:@"<" intoString:NULL])
|
||||
{
|
||||
type = CPLessThanPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanString:@">" intoString:NULL])
|
||||
{
|
||||
type = CPGreaterThanPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanString:@"==" intoString:NULL] || [self scanString:@"=" intoString:NULL])
|
||||
{
|
||||
type = CPEqualToPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"MATCHES"])
|
||||
{
|
||||
type = CPMatchesPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"LIKE"])
|
||||
{
|
||||
type = CPLikePredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"BEGINSWITH"])
|
||||
{
|
||||
type = CPBeginsWithPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"ENDSWITH"])
|
||||
{
|
||||
type = CPEndsWithPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"IN"])
|
||||
{
|
||||
type = CPInPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"CONTAINS"])
|
||||
{
|
||||
type = CPContainsPredicateOperatorType;
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"BETWEEN"])
|
||||
{
|
||||
type = CPBetweenPredicateOperatorType;
|
||||
}
|
||||
else
|
||||
CPRaiseParseError(self, @"comparison predicate");
|
||||
|
||||
if ([self scanString:@"[cd]" intoString:NULL])
|
||||
{
|
||||
opts = CPCaseInsensitivePredicateOption | CPDiacriticInsensitivePredicateOption;
|
||||
}
|
||||
else if ([self scanString:@"[c]" intoString:NULL])
|
||||
{
|
||||
opts = CPCaseInsensitivePredicateOption;
|
||||
}
|
||||
else if ([self scanString:@"[d]" intoString:NULL])
|
||||
{
|
||||
opts = CPDiacriticInsensitivePredicateOption;
|
||||
}
|
||||
|
||||
right = [self parseExpression];
|
||||
|
||||
p = [CPComparisonPredicate predicateWithLeftExpression:left
|
||||
rightExpression:right
|
||||
modifier:modifier
|
||||
type:type
|
||||
options:opts];
|
||||
|
||||
return negate ? [CPCompoundPredicate notPredicateWithSubpredicate:p]:p;
|
||||
}
|
||||
|
||||
- (CPExpression)parseExpression
|
||||
{
|
||||
return [self parseBinaryExpression];
|
||||
}
|
||||
|
||||
- (CPExpression)parseSimpleExpression
|
||||
{
|
||||
var identifier,
|
||||
location,
|
||||
ident,
|
||||
dbl;
|
||||
|
||||
if ([self scanDouble:REFERENCE(dbl)])
|
||||
return [CPExpression expressionForConstantValue:dbl];
|
||||
|
||||
// FIXME: handle integer, hex constants, 0x 0o 0b
|
||||
if ([self scanString:@"-" intoString:NULL])
|
||||
return [CPExpression expressionForFunction:@"chs:" arguments:[CPArray arrayWithObject:[self parseExpression]]];
|
||||
|
||||
if ([self scanString:@"(" intoString:NULL])
|
||||
{
|
||||
var arg = [self parseExpression];
|
||||
|
||||
if (![self scanString:@")" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
if ([self scanString:@"{" intoString:NULL])
|
||||
{
|
||||
if ([self scanString:@"}" intoString:NULL])
|
||||
return [CPExpression expressionForConstantValue:a];
|
||||
|
||||
var a = [];
|
||||
|
||||
[a addObject:[self parseExpression]];
|
||||
|
||||
while ([self scanString:@"," intoString:NULL])
|
||||
[a addObject:[self parseExpression]];
|
||||
|
||||
if (![self scanString:@"}" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [CPExpression expressionForAggregate:a];
|
||||
}
|
||||
|
||||
if ([self scanPredicateKeyword:@"NULL"] || [self scanPredicateKeyword:@"NIL"])
|
||||
{
|
||||
return [CPExpression expressionForConstantValue:[CPNull null]];
|
||||
}
|
||||
if ([self scanPredicateKeyword:@"TRUE"] || [self scanPredicateKeyword:@"YES"])
|
||||
{
|
||||
return [CPExpression expressionForConstantValue:[CPNumber numberWithBool:YES]];
|
||||
}
|
||||
if ([self scanPredicateKeyword:@"FALSE"] || [self scanPredicateKeyword:@"NO"])
|
||||
{
|
||||
return [CPExpression expressionForConstantValue:[CPNumber numberWithBool:NO]];
|
||||
}
|
||||
if ([self scanPredicateKeyword:@"SELF"])
|
||||
{
|
||||
return [CPExpression expressionForEvaluatedObject];
|
||||
}
|
||||
|
||||
if ([self scanString:@"$" intoString:NULL])
|
||||
{
|
||||
var variable = [self parseSimpleExpression];
|
||||
|
||||
if (![variable keyPath])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [CPExpression expressionForVariable:variable];
|
||||
}
|
||||
|
||||
location = [self scanLocation];
|
||||
|
||||
if ([self scanString:@"%" intoString:NULL])
|
||||
{
|
||||
if ([self isAtEnd] == NO)
|
||||
{
|
||||
var c = [[self string] characterAtIndex:[self scanLocation]];
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '%':// '%%' is treated as '%'
|
||||
location = [self scanLocation];
|
||||
break;
|
||||
case 'K':
|
||||
[self setScanLocation:[self scanLocation] + 1];
|
||||
return [CPExpression expressionForKeyPath:[self nextArg]];
|
||||
case '@':
|
||||
case 'c':
|
||||
case 'C':
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'O':
|
||||
case 'u':
|
||||
case 'U':
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
[self setScanLocation:[self scanLocation] + 1];
|
||||
return [CPExpression expressionForConstantValue:[self nextArg]];
|
||||
case 'h':
|
||||
[self scanString:@"h" intoString:NULL];
|
||||
if ([self isAtEnd] == NO)
|
||||
{
|
||||
c = [[self string] characterAtIndex:[self scanLocation]];
|
||||
if (c == 'i' || c == 'u')
|
||||
{
|
||||
[self setScanLocation:[self scanLocation] + 1];
|
||||
return [CPExpression expressionForConstantValue:[self nextArg]];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
[self scanString:@"q" intoString:NULL];
|
||||
if ([self isAtEnd] == NO)
|
||||
{
|
||||
c = [[self string] characterAtIndex:[self scanLocation]];
|
||||
if (c == 'i' || c == 'u' || c == 'x' || c == 'X')
|
||||
{
|
||||
[self setScanLocation:[self scanLocation] + 1];
|
||||
return [CPExpression expressionForConstantValue:[self nextArg]];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self setScanLocation:location];
|
||||
}
|
||||
|
||||
if ([self scanString:@"\"" intoString:NULL])
|
||||
{
|
||||
var skip = [self charactersToBeSkipped],
|
||||
str = @"";
|
||||
|
||||
[self setCharactersToBeSkipped:nil];
|
||||
[self scanUpToString:@"\"" intoString:REFERENCE(str)];
|
||||
|
||||
if ([self scanString:@"\"" intoString:NULL] == NO)
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
[self setCharactersToBeSkipped:skip];
|
||||
|
||||
return [CPExpression expressionForConstantValue:str];
|
||||
}
|
||||
|
||||
if ([self scanString:@"'" intoString:NULL])
|
||||
{
|
||||
var skip = [self charactersToBeSkipped],
|
||||
str = @"";
|
||||
|
||||
[self setCharactersToBeSkipped:nil];
|
||||
[self scanUpToString:@"'" intoString:REFERENCE(str)];
|
||||
|
||||
if ([self scanString:@"'" intoString:NULL] == NO)
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
[self setCharactersToBeSkipped:skip];
|
||||
|
||||
return [CPExpression expressionForConstantValue:str];
|
||||
}
|
||||
|
||||
if ([self scanString:@"@" intoString:NULL])
|
||||
{
|
||||
var e = [self parseExpression];
|
||||
|
||||
if (![e keyPath])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [CPExpression expressionForKeyPath:[e keyPath] + "@"];
|
||||
}
|
||||
|
||||
if ([self scanString:@"SUBQUERY" intoString:NULL])
|
||||
{
|
||||
if (![self scanString:@"(" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
var collection = [self parseExpression],
|
||||
variableExpression,
|
||||
subpredicate;
|
||||
|
||||
if (![self scanString:@"," intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
variableExpression = [self parseExpression];
|
||||
|
||||
if (![self scanString:@"," intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
subpredicate = [self parsePredicate];
|
||||
|
||||
if (![self scanString:@")" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [[_CPSubqueryExpression alloc] initWithExpression:collection usingIteratorExpression:variableExpression predicate:subpredicate];
|
||||
}
|
||||
|
||||
if ([self scanString:@"FUNCTION" intoString:NULL])
|
||||
{
|
||||
if (![self scanString:@"(" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
var args = [CPArray arrayWithObject:[self parseExpression]];
|
||||
while ([self scanString:@"," intoString:NULL])
|
||||
[args addObject:[self parseExpression]];
|
||||
|
||||
if (![self scanString:@")" intoString:NULL] || [args count] < 2 || [args[1] expressionType] != CPConstantValueExpressionType)
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [CPExpression expressionForFunction:args[0] selectorName:[args[1] constantValue] arguments:args.slice(2)];
|
||||
}
|
||||
|
||||
[self scanString:@"#" intoString:NULL];
|
||||
if (!identifier)
|
||||
identifier = [CPCharacterSet characterSetWithCharactersInString:@"_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"];
|
||||
|
||||
if (![self scanCharactersFromSet:identifier intoString:REFERENCE(ident)])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [CPExpression expressionForKeyPath:ident];
|
||||
}
|
||||
|
||||
- (CPExpression)parseFunctionalExpression
|
||||
{
|
||||
var left = [self parseSimpleExpression];
|
||||
|
||||
while (YES)
|
||||
{
|
||||
if ([self scanString:@"." intoString:NULL])
|
||||
{
|
||||
var right = [self parseSimpleExpression],
|
||||
expressionType = [right expressionType];
|
||||
|
||||
if (expressionType == CPKeyPathExpressionType)
|
||||
left = [[_CPKeyPathExpression alloc] initWithOperand:left andKeyPath:[right keyPath]];
|
||||
else if (expressionType == CPVariableExpressionType)
|
||||
left = [CPExpression expressionForFunction:left selectorName:@"valueForKey:" arguments:[right]];
|
||||
else
|
||||
CPRaiseParseError(self, @"expression");
|
||||
}
|
||||
else if ([self scanString:@"[" intoString:NULL])
|
||||
{
|
||||
// index expression
|
||||
if ([self scanPredicateKeyword:@"FIRST"])
|
||||
{
|
||||
left = [CPExpression expressionForFunction:@"first:" arguments:[CPArray arrayWithObject:left]];
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"LAST"])
|
||||
{
|
||||
left = [CPExpression expressionForFunction:@"last:" arguments:[CPArray arrayWithObject:left]];
|
||||
}
|
||||
else if ([self scanPredicateKeyword:@"SIZE"])
|
||||
{
|
||||
left = [CPExpression expressionForFunction:@"count:" arguments:[CPArray arrayWithObject:left]];
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = [self parseExpression];
|
||||
left = [CPExpression expressionForFunction:@"fromObject:index:" arguments:[CPArray arrayWithObjects:left, index]];
|
||||
}
|
||||
|
||||
if (![self scanString:@"]" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
}
|
||||
else if ([self scanString:@":" intoString:NULL])
|
||||
{
|
||||
// function - this parser allows for (max)(a, b, c) to be properly
|
||||
// recognized and even (%K)(a, b, c) if %K evaluates to "max"
|
||||
|
||||
if (![left keyPath])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
var selector = [left keyPath] + @":",
|
||||
args = [];
|
||||
|
||||
if (![self scanString:@"(" intoString:NULL])
|
||||
{
|
||||
var str;
|
||||
[self scanCharactersFromSet:[CPCharacterSet lowercaseLetterCharacterSet] intoString:REFERENCE(str)];
|
||||
|
||||
if (![self scanString:@":(" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
selector += str + @":";
|
||||
}
|
||||
|
||||
if (![self scanString:@")" intoString:NULL])
|
||||
{
|
||||
[args addObject:[self parseExpression]];
|
||||
while ([self scanString:@"," intoString:NULL])
|
||||
[args addObject:[self parseExpression]];
|
||||
|
||||
if (![self scanString:@")" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
}
|
||||
|
||||
left = [CPExpression expressionForFunction:selector arguments:args];
|
||||
}
|
||||
else if ([self scanString:@"UNION" intoString:NULL])
|
||||
{
|
||||
left = [CPExpression expressionForUnionSet:left with:[self parseExpression]];
|
||||
}
|
||||
else if ([self scanString:@"INTERSECT" intoString:NULL])
|
||||
{
|
||||
left = [CPExpression expressionForIntersectSet:left with:[self parseExpression]];
|
||||
}
|
||||
else if ([self scanString:@"MINUS" intoString:NULL])
|
||||
{
|
||||
left = [CPExpression expressionForMinusSet:left with:[self parseExpression]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// done with suffixes
|
||||
return left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CPExpression)parsePowerExpression
|
||||
{
|
||||
var left = [self parseFunctionalExpression];
|
||||
|
||||
while (YES)
|
||||
{
|
||||
var right;
|
||||
|
||||
if ([self scanString:@"**" intoString:NULL])
|
||||
{
|
||||
right = [self parseFunctionalExpression];
|
||||
left = [CPExpression expressionForFunction:@"raise:to:" arguments:[CPArray arrayWithObjects:left, right]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CPExpression)parseMultiplicationExpression
|
||||
{
|
||||
var left = [self parsePowerExpression];
|
||||
|
||||
while (YES)
|
||||
{
|
||||
var right;
|
||||
|
||||
if ([self scanString:@"*" intoString:NULL])
|
||||
{
|
||||
right = [self parsePowerExpression];
|
||||
left = [CPExpression expressionForFunction:@"multiply:by:" arguments:[CPArray arrayWithObjects:left, right]];
|
||||
}
|
||||
else if ([self scanString:@"/" intoString:NULL])
|
||||
{
|
||||
right = [self parsePowerExpression];
|
||||
left = [CPExpression expressionForFunction:@"divide:by:" arguments:[CPArray arrayWithObjects:left, right]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CPExpression)parseAdditionExpression
|
||||
{
|
||||
var left = [self parseMultiplicationExpression];
|
||||
|
||||
while (YES)
|
||||
{
|
||||
var right;
|
||||
|
||||
if ([self scanString:@"+" intoString:NULL])
|
||||
{
|
||||
right = [self parseMultiplicationExpression];
|
||||
left = [CPExpression expressionForFunction:@"add:to:" arguments:[CPArray arrayWithObjects:left, right]];
|
||||
}
|
||||
else if ([self scanString:@"-" intoString:NULL])
|
||||
{
|
||||
right = [self parseMultiplicationExpression];
|
||||
left = [CPExpression expressionForFunction:@"from:substract:" arguments:[CPArray arrayWithObjects:left, right]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CPExpression)parseBinaryExpression
|
||||
{
|
||||
var left = [self parseAdditionExpression];
|
||||
|
||||
while (YES)
|
||||
{
|
||||
var right;
|
||||
|
||||
if ([self scanString:@":=" intoString:NULL]) // assignment
|
||||
{
|
||||
// check left to be a variable?
|
||||
right = [self parseAdditionExpression];
|
||||
// FIXME
|
||||
}
|
||||
else
|
||||
{
|
||||
return left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPRaiseParseError = function CPRaiseParseError(aScanner, target)
|
||||
{
|
||||
[CPException raise:CPInvalidArgumentException reason:@"unable to parse " + target + " at index " + [aScanner scanLocation]];
|
||||
};
|
||||
|
||||
//@import "CPCompoundPredicate.j"
|
||||
//@import "CPComparisonPredicate.j"
|
||||
//@import "CPExpression.j"
|
||||
@import "_CPPredicate.j"
|
||||
@import "CPCompoundPredicate.j"
|
||||
@import "CPComparisonPredicate.j"
|
||||
@import "CPExpression.j"
|
||||
File diff suppressed because it is too large.
Load diff
@@ -86,7 +86,7 @@
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
return self === object;
|
||||
return self === anObject;
|
||||
}
|
||||
|
||||
- (id)self
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
@import "CPNumber.j"
|
||||
@import "CPObject.j"
|
||||
|
||||
@class _CPConcreteMutableSet
|
||||
|
||||
/*!
|
||||
@class CPMutableSet
|
||||
@ingroup Foundation
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
@import "CPObjJRuntime.j"
|
||||
@import "CPString.j"
|
||||
|
||||
@class CPString
|
||||
|
||||
/*!
|
||||
@class CPSortDescriptor
|
||||
@ingroup foundation
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
@import "CPURL.j"
|
||||
@import "CPValue.j"
|
||||
|
||||
@class CPException
|
||||
|
||||
@global CPInvalidArgumentException
|
||||
@global CPRangeException
|
||||
|
||||
#define _CPMaxRange(aRange) ((aRange).location + (aRange).length)
|
||||
|
||||
/*!
|
||||
@@ -250,7 +255,7 @@ var CPStringUIDs = new CFMutableDictionary(),
|
||||
return self;
|
||||
|
||||
if (aLength < self.length)
|
||||
return substr(0, aLength);
|
||||
return self.substr(0, aLength);
|
||||
|
||||
var string = self,
|
||||
substring = aString.substring(anIndex),
|
||||
|
||||
@@ -858,7 +858,7 @@ var CPUndoManagerRedoStackKey = @"CPUndoManagerRedoStackKey",
|
||||
_undoStack = [aCoder decodeObjectForKey:CPUndoManagerUndoStackKey];
|
||||
|
||||
_levelsOfUndo = [aCoder decodeObjectForKey:CPUndoManagerLevelsOfUndoKey];
|
||||
_actionName = [aCoder decodeObjectForKey:CPUndoManagerActionNameKey];
|
||||
// _actionName = [aCoder decodeObjectForKey:CPUndoManagerActionNameKey];
|
||||
_currentGrouping = [aCoder decodeObjectForKey:CPUndoManagerCurrentGroupingKey];
|
||||
|
||||
_state = CPUndoManagerNormal;
|
||||
@@ -876,7 +876,7 @@ var CPUndoManagerRedoStackKey = @"CPUndoManagerRedoStackKey",
|
||||
[aCoder encodeObject:_undoStack forKey:CPUndoManagerUndoStackKey];
|
||||
|
||||
[aCoder encodeInt:_levelsOfUndo forKey:CPUndoManagerLevelsOfUndoKey];
|
||||
[aCoder encodeObject:_actionName forKey:CPUndoManagerActionNameKey];
|
||||
// [aCoder encodeObject:_actionName forKey:CPUndoManagerActionNameKey];
|
||||
|
||||
[aCoder encodeObject:_currentGrouping forKey:CPUndoManagerCurrentGroupingKey];
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
@import "CPURLConnection.j"
|
||||
@import "CPURLRequest.j"
|
||||
|
||||
@class CPCookie
|
||||
|
||||
@global CPApp
|
||||
|
||||
CPArgumentDomain = @"CPArgumentDomain";
|
||||
CPApplicationDomain = [[[CPBundle mainBundle] infoDictionary] objectForKey:@"CPBundleIdentifier"] || @"CPApplicationDomain";
|
||||
|
||||
Reference in new issue
Block a user