Merge remote-tracking branch 'upstream/master' into CPImageView-bindings

This commit is contained in:
cacaodev
2012-04-10 22:26:23 +02:00
25 changed files with 567 additions and 380 deletions
+2
View File
@@ -21,6 +21,7 @@
*/
@import "CALayer.j"
@import "CPAccordionView.j"
@import "CPAlert.j"
@import "CPAnimation.j"
@import "CPApplication.j"
@@ -46,6 +47,7 @@
@import "CPColorWell.j"
@import "CPCompatibility.j"
@import "CPControl.j"
@import "CPController.j"
@import "CPCookie.j"
@import "CPCursor.j"
@import "CPDocument.j"
+7 -32
View File
@@ -110,40 +110,15 @@ CPCheckBoxImageOffset = 4.0;
[self _setPlaceholder:CPOffState forMarker:CPNullMarker isDefault:YES];
}
- (void)setValueFor:(CPString)theBinding
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
{
var destination = [_info objectForKey:CPObservedObjectKey],
keyPath = [_info objectForKey:CPObservedKeyPathKey],
options = [_info objectForKey:CPOptionsKey],
newValue = [destination valueForKeyPath:keyPath],
isPlaceholder = CPIsControllerMarker(newValue);
[_source setAllowsMixedState:(aValue === CPMixedState)];
[_source setState:aValue];
}
if (isPlaceholder)
{
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
{
[CPException raise:CPGenericException
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
}
newValue = [self _placeholderForMarker:newValue];
if (newValue === CPMixedState)
{
[_source setAllowsMixedState:YES];
}
else
{
// Cocoa will always set allowsMixedState to NO
// This behavior will be fine for Cappuccino as well if we (like Cocoa)
// default the CPConditionallySetsEnabledBindingOption to YES
[_source setAllowsMixedState:NO];
}
}
else
newValue = [self transformValue:newValue withOptions:options];
[_source setState:newValue];
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
[_source setState:aValue];
}
@end
+29 -4
View File
@@ -149,15 +149,40 @@ var CPBindingOperationAnd = 0,
return self;
}
- (void)setValueFor:(CPString)aBinding
- (void)setValueFor:(CPString)theBinding
{
var destination = [_info objectForKey:CPObservedObjectKey],
keyPath = [_info objectForKey:CPObservedKeyPathKey],
options = [_info objectForKey:CPOptionsKey],
newValue = [destination valueForKeyPath:keyPath];
newValue = [destination valueForKeyPath:keyPath],
isPlaceholder = CPIsControllerMarker(newValue);
newValue = [self transformValue:newValue withOptions:options];
[_source setValue:newValue forKey:aBinding];
if (isPlaceholder)
{
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
{
[CPException raise:CPGenericException
reason:@"Cannot transform non-applicable key on: " + _source + " key path: " + keyPath + " value: " + newValue];
}
var value = [self _placeholderForMarker:newValue];
[self setPlaceholderValue:value withMarker:newValue forBinding:theBinding];
}
else
{
var value = [self transformValue:newValue withOptions:options];
[self setValue:value forBinding:theBinding];
}
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
{
[_source setValue:aValue forKey:aBinding];
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
[_source setValue:aValue forKey:aBinding];
}
- (void)reverseSetValueFor:(CPString)aBinding
+2 -2
View File
@@ -88,9 +88,9 @@ var CPProgressIndicatorSpinningStyleColors = nil,
CPProgressIndicatorSpinningStyleColors = [];
CPProgressIndicatorSpinningStyleColors[CPMiniControlSize] = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(64.0, 64.0)]];
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleMini.gif"] size:CGSizeMake(16.0, 16.0)]];
CPProgressIndicatorSpinningStyleColors[CPSmallControlSize] = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(64.0, 64.0)]];
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleSmall.gif"] size:CGSizeMake(32.0, 32.0)]];
CPProgressIndicatorSpinningStyleColors[CPRegularControlSize] = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(64.0, 64.0)]];
+137 -116
View File
@@ -140,7 +140,7 @@ var itemsContext = "items",
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
if (self !== nil)
{
_slices = [[CPMutableArray alloc] init];
@@ -187,7 +187,7 @@ var itemsContext = "items",
[_slicesHolder addSubview:_dropLineView];
[self registerForDraggedTypes:[CPArray arrayWithObjects:CPRuleEditorItemPBoardType,nil]];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew context:boundArrayContext];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:boundArrayContext];
}
/*! @endcond */
@@ -244,7 +244,7 @@ var itemsContext = "items",
*/
- (void)setEditable:(BOOL)editable
{
if (editable == _editable)
if (editable === _editable)
return;
_editable = editable;
@@ -274,7 +274,7 @@ var itemsContext = "items",
*/
- (void)setNestingMode:(CPRuleEditorNestingMode)mode
{
if (mode != _nestingMode)
if (mode !== _nestingMode)
{
_nestingMode = mode;
if ([self numberOfRows] > 0)
@@ -341,7 +341,7 @@ var itemsContext = "items",
*/
- (void)setRowHeight:(float)height
{
if (height == _sliceHeight)
if (height === _sliceHeight)
return;
_sliceHeight = MAX([self _minimumFrameHeight], height);
@@ -396,10 +396,10 @@ var itemsContext = "items",
- (void)setFormattingStringsFilename:(CPString)stringsFilename
{
// Can we set _stringsFilename to nil in cocoa ?
if (_standardLocalizer == nil)
if (_standardLocalizer === nil)
_standardLocalizer = [_CPRuleEditorLocalizer new];
if (_stringsFilename != stringsFilename)
if (_stringsFilename !== stringsFilename)
{
_stringsFilename = stringsFilename;
@@ -408,7 +408,7 @@ var itemsContext = "items",
if (![stringsFilename hasSuffix:@".strings"])
stringsFilename = stringsFilename + @".strings";
var path = [[CPBundle mainBundle] pathForResource:stringsFilename];
if (path !=nil)
if (path !== nil)
[_standardLocalizer loadContentOfURL:[CPURL URLWithString:path]];
}
}
@@ -440,7 +440,7 @@ var itemsContext = "items",
- (void)setCriteria:(CPArray)criteria andDisplayValues:(CPArray)values forRowAtIndex:(int)rowIndex
{
// TODO: reload from the delegate if criteria is an empty array.
if (criteria == nil || values == nil)
if (criteria === nil || values === nil)
[CPException raise:CPInvalidArgumentException reason:_cmd + @". criteria and values parameters must not be nil."];
if (rowIndex < 0 || rowIndex >= [self numberOfRows])
@@ -510,12 +510,12 @@ var itemsContext = "items",
for (var current_index = 0; current_index < rowIndex; current_index++)
{
if ([self rowTypeForRow:current_index] == CPRuleEditorRowTypeCompound)
if ([self rowTypeForRow:current_index] === CPRuleEditorRowTypeCompound)
{
var candidate = [[self _rowCacheForIndex:current_index] rowObject],
subObjects = [[self _subrowObjectsOfObject:candidate] _representedObject];
if ([subObjects indexOfObjectIdenticalTo:targetObject] != CPNotFound)
if ([subObjects indexOfObjectIdenticalTo:targetObject] !== CPNotFound)
return current_index;
}
}
@@ -566,7 +566,8 @@ TODO: implement
- (CPIndexSet)subrowIndexesForRow:(int)rowIndex
{
var object;
if (rowIndex == -1)
if (rowIndex === -1)
object = _boundArrayOwner;
else
object = [[self _rowCacheForIndex:rowIndex] rowObject];
@@ -581,16 +582,16 @@ TODO: implement
var candidate = [[self _rowCacheForIndex:i] rowObject],
indexInSubrows = [[subobjects _representedObject] indexOfObjectIdenticalTo:candidate];
if (indexInSubrows != CPNotFound)
if (indexInSubrows !== CPNotFound)
{
[indexes addIndex:i];
objectsCount --;
// [buffer removeObjectAtIndex:indexInSubrows];
if ([self rowTypeForRow:i] == CPRuleEditorRowTypeCompound)
if ([self rowTypeForRow:i] === CPRuleEditorRowTypeCompound)
i += [[self subrowIndexesForRow:i] count];
}
if (objectsCount == 0)
if (objectsCount === 0)
break;
}
@@ -626,12 +627,12 @@ TODO: implement
{
var slice = _slices[count],
rowIndex = [slice rowIndex],
contains = [indexes containsIndex:rowIndex];
contains = [indexes containsIndex:rowIndex],
shouldSelect = (contains && !(extend && [slice _isSelected]));
if (contains)
[slice _setSelected:shouldSelect];
[slice _setLastSelected:(rowIndex == lastSelected)];
[slice _setLastSelected:(rowIndex === lastSelected)];
[slice setNeedsDisplay:YES];
}
}
@@ -673,7 +674,7 @@ TODO: implement
break;
default:
[CPException raise:CPInvalidArgumentException reason:@"Not supported CPRuleEditorNestingMode " + nestingMode];
// Compound mode: parentRowIndex=(lastRowType == CPRuleEditorRowTypeCompound)?lastRow :[self parentRowForRow:lastRow]; break;
// Compound mode: parentRowIndex=(lastRowType === CPRuleEditorRowTypeCompound)?lastRow :[self parentRowForRow:lastRow]; break;
}
[self insertRowAtIndex:numberOfRows withType:rowtype asSubrowOfRow:parentRowIndex animate:YES];
@@ -695,7 +696,7 @@ TODO: implement
*/
var newObject = [self _insertNewRowAtIndex:rowIndex ofType:rowType withParentRow:parentRow];
if (rowType == CPRuleEditorRowTypeCompound && !_allowsEmptyCompoundRows)
if (rowType === CPRuleEditorRowTypeCompound && !_allowsEmptyCompoundRows)
{
var subrow = [self _insertNewRowAtIndex:(rowIndex + 1) ofType:CPRuleEditorRowTypeSimple withParentRow:rowIndex];
}
@@ -726,7 +727,7 @@ TODO: implement
*/
- (void)removeRowsAtIndexes:(CPIndexSet)rowIndexes includeSubrows:(BOOL)includeSubrows
{
if ([rowIndexes count] == 0)
if ([rowIndexes count] === 0)
return;
if ([rowIndexes lastIndex] >= [self numberOfRows])
@@ -737,7 +738,7 @@ TODO: implement
childsIndexes = [CPMutableIndexSet indexSet],
subrows;
if (parentRowIndex == -1)
if (parentRowIndex === -1)
subrows = [self _rootRowsArray];
else
{
@@ -745,15 +746,15 @@ TODO: implement
subrows = [self _subrowObjectsOfObject:parentRowObject];
}
while (current_index != CPNotFound)
while (current_index !== CPNotFound)
{
var rowObject = [[self _rowCacheForIndex:current_index] rowObject],
relativeChildIndex = [[subrows _representedObject] indexOfObjectIdenticalTo:rowObject];
if (relativeChildIndex != CPNotFound)
if (relativeChildIndex !== CPNotFound)
[childsIndexes addIndex:relativeChildIndex];
if (includeSubrows && [self rowTypeForRow:current_index] == CPRuleEditorRowTypeCompound)
if (includeSubrows && [self rowTypeForRow:current_index] === CPRuleEditorRowTypeCompound)
{
var more_childs = [self subrowIndexesForRow:current_index];
[self removeRowsAtIndexes:more_childs includeSubrows:includeSubrows];
@@ -813,20 +814,20 @@ TODO: implement
[predicateParts addEntriesFromDictionary:predpart];
}
if ([self rowTypeForRow:aRow] == CPRuleEditorRowTypeCompound)
if ([self rowTypeForRow:aRow] === CPRuleEditorRowTypeCompound)
{
var compoundPredicate,
subpredicates = [CPMutableArray array],
subrowsIndexes = [self subrowIndexesForRow:aRow];
if ([subrowsIndexes count] == 0)
if ([subrowsIndexes count] === 0)
return nil;
var current_index = [subrowsIndexes firstIndex];
while (current_index != CPNotFound)
while (current_index !== CPNotFound)
{
var subpredicate = [self predicateForRow:current_index];
if (subpredicate != nil)
if (subpredicate !== nil)
[subpredicates addObject:subpredicate];
current_index = [subrowsIndexes indexGreaterThanIndex:current_index];
@@ -834,7 +835,7 @@ TODO: implement
var compoundType = [predicateParts objectForKey:CPRuleEditorPredicateCompoundType];
if ([subpredicates count] == 0)
if ([subpredicates count] === 0)
return nil;
else
{
@@ -862,16 +863,33 @@ TODO: implement
modifier = [predicateParts objectForKey:CPRuleEditorPredicateComparisonModifier],
selector = CPSelectorFromString([predicateParts objectForKey:CPRuleEditorPredicateCustomSelector]);
if (lhs == nil){ CPLogConsole(@"missing left expression in predicate parts dictionary"); return NULL;}
if (rhs == nil){ CPLogConsole(@"missing right expression in predicate parts dictionary"); return NULL;}
if (selector == nil && operator == nil){ CPLogConsole(@"missing operator and selector in predicate parts dictionary"); return NULL;}
if (lhs === nil)
{
CPLogConsole(@"missing left expression in predicate parts dictionary");
return NULL;
}
if (modifier == nil) CPLogConsole(@"missing modifier in predicate parts dictionary. Setting default: CPDirectPredicateModifier");
if (options == nil) CPLogConsole(@"missing options in predicate parts dictionary. Setting default: CPCaseInsensitivePredicateOption");
if (rhs === nil)
{
CPLogConsole(@"missing right expression in predicate parts dictionary");
return NULL;
}
if (selector === nil && operator === nil)
{
CPLogConsole(@"missing operator and selector in predicate parts dictionary");
return NULL;
}
if (modifier === nil)
CPLogConsole(@"missing modifier in predicate parts dictionary. Setting default: CPDirectPredicateModifier");
if (options === nil)
CPLogConsole(@"missing options in predicate parts dictionary. Setting default: CPCaseInsensitivePredicateOption");
try
{
if (selector != nil)
if (selector !== nil)
predicate = [CPComparisonPredicate
predicateWithLeftExpression:lhs
rightExpression:rhs
@@ -918,7 +936,7 @@ TODO: implement
*/
- (void)setRowClass:(Class)rowClass
{
if (rowClass == [CPMutableDictionary class])
if (rowClass === [CPMutableDictionary class])
rowClass = [RowObject class];
_rowClass = rowClass;
@@ -1095,7 +1113,7 @@ TODO: implement
- (void)keyDown:(CPEvent)event
{
if (!_suppressKeyDownHandling && [self _applicableNestingMode] == CPRuleEditorNestingModeCompound && !_isKeyDown && ([event modifierFlags] & CPAlternateKeyMask))
if (!_suppressKeyDownHandling && [self _applicableNestingMode] === CPRuleEditorNestingModeCompound && !_isKeyDown && ([event modifierFlags] & CPAlternateKeyMask))
{
[_slices makeObjectsPerformSelector:@selector(_configurePlusButtonByRowType:) withObject:CPRuleEditorRowTypeCompound];
}
@@ -1130,7 +1148,7 @@ TODO: implement
- (BOOL)_wantsRowAnimations
{
return (_currentAnimation != nil);
return (_currentAnimation !== nil);
}
- (void)_updateButtonVisibilities
@@ -1153,10 +1171,10 @@ TODO: implement
if (!_nestingModeDidChange)
return _nestingMode;
var a = (_nestingMode == CPRuleEditorNestingModeCompound || _nestingMode == CPRuleEditorNestingModeSimple);
var b = ([self rowTypeForRow:0] == CPRuleEditorRowTypeCompound);
var a = (_nestingMode === CPRuleEditorNestingModeCompound || _nestingMode === CPRuleEditorNestingModeSimple),
b = ([self rowTypeForRow:0] === CPRuleEditorRowTypeCompound);
if (a == b)
if (a === b)
return _nestingMode;
return a ? CPRuleEditorNestingModeList : CPRuleEditorNestingModeSimple;
@@ -1164,7 +1182,7 @@ TODO: implement
- (BOOL)_shouldHideAddButtonForSlice:(id)slice
{
return (!_editable || [self _applicableNestingMode] == CPRuleEditorNestingModeSingle);
return (!_editable || [self _applicableNestingMode] === CPRuleEditorNestingModeSingle);
}
- (BOOL)_shouldHideSubtractButtonForSlice:(id)slice
@@ -1184,9 +1202,9 @@ TODO: implement
switch (nestingMode)
{
case CPRuleEditorNestingModeCompound:
case CPRuleEditorNestingModeSimple: shouldHide = ([subrowsIndexes count] == 1 && !_allowsEmptyCompoundRows) || parentIndex == -1;
case CPRuleEditorNestingModeSimple: shouldHide = ([subrowsIndexes count] === 1 && !_allowsEmptyCompoundRows) || parentIndex === -1;
break;
case CPRuleEditorNestingModeList: shouldHide = ([self numberOfRows] == 1);
case CPRuleEditorNestingModeList: shouldHide = ([self numberOfRows] === 1);
break;
case CPRuleEditorNestingModeSingle: shouldHide = YES;
break;
@@ -1220,7 +1238,7 @@ TODO: implement
- (int)_rowIndexForRowObject:(id)rowobject
{
if (rowobject == _boundArrayOwner)
if (rowobject === _boundArrayOwner)
return -1;
return [[self _searchCacheForRowObject:rowobject] rowIndex]; // Pas bon car le rowIndex du row cache n'est pas synchro avec la position dans _rowCache.
@@ -1239,14 +1257,14 @@ TODO: implement
var childlessParents = [CPIndexSet indexSet],
current_index = [indexes firstIndex];
while (current_index != CPNotFound)
while (current_index !== CPNotFound)
{
var parentIndex = [self parentRowForRow:current_index];
var parentIndex = [self parentRowForRow:current_index],
subrowsIndexes = [self subrowIndexesForRow:parentIndex];
var subrowsIndexes = [self subrowIndexesForRow:parentIndex];
if ([subrowsIndexes count]==1)
if ([subrowsIndexes count] === 1)
{
if (parentIndex != -1)
if (parentIndex !== -1)
return [CPIndexSet indexSetWithIndex:0];
var childlessGranPa = [self _childlessParentsIfSlicesWereDeletedAtIndexes:[CPIndexSet indexSetWithIndex:parentIndex]];
@@ -1265,7 +1283,7 @@ TODO: implement
var subindexes = [indexes copy],
current_index = [indexes firstIndex];
while (current_index != CPNotFound)
while (current_index !== CPNotFound)
{
var sub = [self subrowIndexesForRow:current_index];
[subindexes addIndexes:[self _includeSubslicesForSlicesAtIndexes:sub]];
@@ -1301,7 +1319,7 @@ TODO: implement
childrenCount = [self _queryNumberOfChildrenOfItem:parentItem withRowType:type],
foundIndex = CPNotFound;
if (childrenCount == 0)
if (childrenCount === 0)
return NO;
var current_criterions = [CPMutableArray array],
@@ -1313,34 +1331,34 @@ TODO: implement
var aCriteria = [self criteriaForRow:row],
itemIndex = [items count];
if ([self rowTypeForRow:row] == type && itemIndex < [aCriteria count])
if ([self rowTypeForRow:row] === type && itemIndex < [aCriteria count])
{
var crit = [aCriteria objectAtIndex:itemIndex];
[current_criterions addObject:crit];
}
}
while (foundIndex == CPNotFound)
while (foundIndex === CPNotFound)
{
var buffer = [CPMutableArray arrayWithArray:current_criterions],
i;
for (i = 0; i < childrenCount; i++)
{
var child = [self _queryChild:i ofItem:parentItem withRowType:type];
if ([current_criterions indexOfObject:child] == CPNotFound)
if ([current_criterions indexOfObject:child] === CPNotFound)
{
foundIndex = i;
break;
}
}
if (foundIndex == CPNotFound)
if (foundIndex === CPNotFound)
{
for (var k = 0; k < childrenCount; k++)
{
var anobject = [self _queryChild:k ofItem:parentItem withRowType:type],
index = [buffer indexOfObject:anobject];
if (index != CPNotFound)
if (index !== CPNotFound)
[buffer removeObjectAtIndex:index];
}
@@ -1392,7 +1410,7 @@ TODO: implement
var rowIndexEvent = [slice rowIndex],
rowTypeEvent = [self rowTypeForRow:rowIndexEvent];
var parentRowIndex = (rowTypeEvent == CPRuleEditorRowTypeCompound) ? rowIndexEvent:[self parentRowForRow:rowIndexEvent];
var parentRowIndex = (rowTypeEvent === CPRuleEditorRowTypeCompound) ? rowIndexEvent:[self parentRowForRow:rowIndexEvent];
[self insertRowAtIndex:rowIndexEvent + 1 withType:type asSubrowOfRow:parentRowIndex animate:YES];
@@ -1414,7 +1432,7 @@ TODO: implement
[row setValue:[CPMutableArray array] forKey:_subrowsArrayKeyPath];
var subrowsObjects;
if (parentRowIndex == -1 || [self _applicableNestingMode] == CPRuleEditorNestingModeList)
if (parentRowIndex === -1 || [self _applicableNestingMode] === CPRuleEditorNestingModeList)
subrowsObjects = [self _rootRowsArray];
else
{
@@ -1432,7 +1450,7 @@ TODO: implement
- (void)_startObservingRowObjectsRecursively:(CPArray)rowObjects
{
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew context:boundArrayContext];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:boundArrayContext];
var count = [rowObjects count];
@@ -1440,9 +1458,9 @@ TODO: implement
{
var rowObject = [rowObjects objectAtIndex:i];
[rowObject addObserver:self forKeyPath:_itemsKeyPath options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew context:itemsContext];
[rowObject addObserver:self forKeyPath:_valuesKeyPath options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew context:valuesContext];
[rowObject addObserver:self forKeyPath:_subrowsArrayKeyPath options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew context:subrowsContext];
[rowObject addObserver:self forKeyPath:_itemsKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:itemsContext];
[rowObject addObserver:self forKeyPath:_valuesKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:valuesContext];
[rowObject addObserver:self forKeyPath:_subrowsArrayKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:subrowsContext];
var subrows = [self _subrowObjectsOfObject:rowObject];
if ([subrows count] > 0)
@@ -1478,21 +1496,21 @@ TODO: implement
newRows,
oldRows;
if (context == boundArrayContext || context == subrowsContext)
if (context === boundArrayContext || context === subrowsContext)
{
if (changeKind == CPKeyValueChangeSetting)
if (changeKind === CPKeyValueChangeSetting)
{
newRows = changeNewValue;
oldRows = changeOldValue;
}
else if (changeKind == CPKeyValueChangeInsertion)
else if (changeKind === CPKeyValueChangeInsertion)
{
newRows = [self _subrowObjectsOfObject:object];
oldRows = [CPArray arrayWithArray:newRows];
[oldRows removeObjectsInArray:changeNewValue];
}
else if (changeKind == CPKeyValueChangeRemoval)
else if (changeKind === CPKeyValueChangeRemoval)
{
newRows = [self _subrowObjectsOfObject:object];
oldRows = [CPArray arrayWithArray:newRows];
@@ -1506,10 +1524,10 @@ TODO: implement
[self _postRowCountChangedNotificationOfType:CPRuleEditorRowsDidChangeNotification indexes:[change objectForKey:CPKeyValueChangeIndexesKey]];
}
else if (context == itemsContext)
else if (context === itemsContext)
{
}
else if (context == valuesContext)
else if (context === valuesContext)
{
}
}
@@ -1571,7 +1589,7 @@ TODO: implement
//var gindexes = [self _globalIndexesForSubrowIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,oldRowCount)] ofParentObject:parentRowObject];
if (parentCacheIndex == -1)
if (parentCacheIndex === -1)
parentCacheIndentation = -1;
else
parentCacheIndentation = [[self _rowCacheForIndex:parentCacheIndex] indentation];
@@ -1600,17 +1618,18 @@ TODO: implement
var oldrow = [oldRows objectAtIndex:changeStartIndex],
newrow = [newRows objectAtIndex:changeStartIndex];
if (newrow != oldrow)
if (newrow !== oldrow)
break;
}
var replaceCount = (deltaCount == 0) ? maxCount : maxCount - minusCount;
var startIndex = parentCacheIndex + changeStartIndex + 1;
var replaceCount = (deltaCount === 0) ? maxCount : maxCount - minusCount,
startIndex = parentCacheIndex + changeStartIndex + 1;
if (deltaCount <= 0)
{
var removeIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(startIndex, replaceCount)];
var removeSlices = [_slices objectsAtIndexes:removeIndexes];
var removeIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(startIndex, replaceCount)],
removeSlices = [_slices objectsAtIndexes:removeIndexes];
[removeSlices makeObjectsPerformSelector:@selector(removeFromSuperview)];
[_slices removeObjectsAtIndexes:removeIndexes];
}
@@ -1659,7 +1678,7 @@ TODO: implement
- (void)bind:(CPString)binding toObject:(id)observableController withKeyPath:(CPString)keyPath options:(CPDictionary)options
{
if (keyPath == nil || [observableController valueForKey:keyPath] == nil)
if (keyPath === nil || [observableController valueForKey:keyPath] === nil)
{
[CPException raise:CPInvalidArgumentException reason:"Keypath or bound object cannot be nil"];
return;
@@ -1686,7 +1705,7 @@ TODO: implement
- (void)_setBoundDataSource:(id)datasource withKeyPath:(CPString)keyPath options:(CPDictionary)options
{
if (_boundArrayOwner != nil)
if (_boundArrayOwner !== nil)
[_boundArrayOwner removeObserver:self forKeyPath:_boundArrayKeyPath];
_boundArrayKeyPath = keyPath;
@@ -1694,7 +1713,7 @@ TODO: implement
var boundRows = [_boundArrayOwner valueForKey:_boundArrayKeyPath];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew context:boundArrayContext];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:boundArrayContext];
if ([boundRows isKindOfClass:[CPArray class]] && [boundRows count] > 0)
[_boundArrayOwner setValue:boundRows forKey:_boundArrayKeyPath];
@@ -1721,11 +1740,11 @@ TODO: implement
subindexes = [self subrowIndexesForRow:-1],
current_index = [subindexes firstIndex];
while (current_index != CPNotFound)
while (current_index !== CPNotFound)
{
var subpredicate = [self predicateForRow:current_index];
if (subpredicate != nil)
if (subpredicate !== nil)
[subpredicates addObject:subpredicate];
current_index = [subindexes indexGreaterThanIndex:current_index];
@@ -1764,7 +1783,7 @@ TODO: implement
startRect = [aslice frame],
startIndex = [aslice rowIndex] - 1;
if ([aslice superview] == nil)
if ([aslice superview] === nil)
{
startRect = CGRectMake(0, startIndex * _sliceHeight, CGRectGetWidth(startRect), _sliceHeight);
[aslice _reconfigureSubviews];
@@ -1796,7 +1815,7 @@ TODO: implement
_lastRow = [self numberOfRows] - 1;
if (_lastRow == -1)
if (_lastRow === -1)
_nestingModeDidChange = NO;
[self setNeedsDisplay:YES];
@@ -1890,7 +1909,7 @@ TODO: implement
{
var current_index = [indexes firstIndex];
while (current_index !=CPNotFound)
while (current_index !== CPNotFound)
{
var subindexes = [self subrowIndexesForRow:index];
[self _updateSliceIndentationAtIndex:current_index toIndentation:indentation + 1 withIndexSet:subindexes];
@@ -1934,7 +1953,7 @@ TODO: implement
- (void)_mouseUpOnSlice:(id)slice withEvent:(CPEvent)event
{
if ([slice _rowType] != CPRuleEditorRowTypeSimple)
if ([slice _rowType] !== CPRuleEditorRowTypeSimple)
return;
var modifierFlags = [event modifierFlags],
@@ -2042,7 +2061,7 @@ TODO: implement
{
[self setNeedsDisplay:YES];
if (CGRectGetWidth([self frame]) != size.width)
if (CGRectGetWidth([self frame]) !== size.width)
[_slices makeObjectsPerformSelector:@selector(setNeedsLayout)];
[super setFrameSize:size];
@@ -2078,7 +2097,7 @@ TODO: implement
- (BOOL)_dragShouldBeginFromMouseDown:(CPView)view
{
return (([self nestingMode] == CPRuleEditorNestingModeList || [view rowIndex] != 0) && _editable && [view isKindOfClass:[_CPRuleEditorViewSliceRow class]] && _draggingRows == nil);
return (([self nestingMode] === CPRuleEditorNestingModeList || [view rowIndex] !== 0) && _editable && [view isKindOfClass:[_CPRuleEditorViewSliceRow class]] && _draggingRows === nil);
}
- (BOOL)_performDragForSlice:(id)slice withEvent:(CPEvent)event
@@ -2121,7 +2140,7 @@ TODO: implement
- (CPDragOperation)draggingEntered:(id < CPDraggingInfo >)sender
{
if ([sender draggingSource] == self)
if ([sender draggingSource] === self)
{
[self _clearDropLine];
return CPDragOperationMove;
@@ -2140,7 +2159,7 @@ TODO: implement
{
[_dropLineView setAlphaValue:0];
if (_subviewIndexOfDropLine != CPNotFound && _subviewIndexOfDropLine < _lastRow)
if (_subviewIndexOfDropLine !== CPNotFound && _subviewIndexOfDropLine < _lastRow)
{
var previousBelowSlice = [_slices objectAtIndex:_subviewIndexOfDropLine];
[previousBelowSlice setFrameOrigin:CGPointMake(0, [previousBelowSlice rowIndex] * _sliceHeight)];
@@ -2152,20 +2171,20 @@ TODO: implement
- (CPDragOperation)draggingUpdated:(id <CPDraggingInfo>)sender
{
var point = [self convertPoint:[sender draggingLocation] fromView:nil],
y = point.y + _sliceHeight /2,
y = point.y + _sliceHeight / 2,
indexOfDropLine = FLOOR(y / _sliceHeight),
numberOfRows = [self numberOfRows];
if (indexOfDropLine < 0 || indexOfDropLine > numberOfRows || (indexOfDropLine >= [_draggingRows firstIndex] && indexOfDropLine <= [_draggingRows lastIndex] + 1))
{
if (_subviewIndexOfDropLine != CPNotFound && indexOfDropLine != _subviewIndexOfDropLine)
if (_subviewIndexOfDropLine !== CPNotFound && indexOfDropLine !== _subviewIndexOfDropLine)
[self _clearDropLine];
return CPDragOperationNone;
}
if (_subviewIndexOfDropLine != indexOfDropLine)
if (_subviewIndexOfDropLine !== indexOfDropLine)
{
if (_subviewIndexOfDropLine != CPNotFound && _subviewIndexOfDropLine < numberOfRows)
if (_subviewIndexOfDropLine !== CPNotFound && _subviewIndexOfDropLine < numberOfRows)
{
var previousBelowSlice = [_slices objectAtIndex:_subviewIndexOfDropLine];
[previousBelowSlice setFrameOrigin:CPMakePoint(0, [previousBelowSlice rowIndex] * _sliceHeight)];
@@ -2188,7 +2207,7 @@ TODO: implement
- (BOOL)prepareForDragOperation:(id < CPDraggingInfo >)sender
{
return (_subviewIndexOfDropLine != CPNotFound);
return (_subviewIndexOfDropLine !== CPNotFound);
}
- (BOOL)performDragOperation:(id < CPDraggingInfo >)info
@@ -2200,11 +2219,11 @@ TODO: implement
var rowObjects = [_rowCache valueForKey:@"rowObject"],
index = [_draggingRows lastIndex];
var parentRowIndex = [self parentRowForRow:index]; // first index of draggingrows
var parentRowObject = (parentRowIndex == -1) ? _boundArrayOwner : [[self _rowCacheForIndex:parentRowIndex] rowObject];
var insertIndex = _subviewIndexOfDropLine;
var parentRowIndex = [self parentRowForRow:index], // first index of draggingrows
parentRowObject = (parentRowIndex === -1) ? _boundArrayOwner : [[self _rowCacheForIndex:parentRowIndex] rowObject],
insertIndex = _subviewIndexOfDropLine;
while (index != CPNotFound)
while (index !== CPNotFound)
{
if (index >= insertIndex)
{
@@ -2281,12 +2300,12 @@ TODO: implement
current_index = [indexes firstIndex],
numberOfChildrenOfPreviousBrother = 0;
while (current_index != CPNotFound)
while (current_index !== CPNotFound)
{
var globalChildIndex = current_index + parentRowIndex + 1 + numberOfChildrenOfPreviousBrother;
[globalIndexes addIndex:globalChildIndex];
if ([self rowTypeForRow:globalChildIndex] == CPRuleEditorRowTypeCompound)
if ([self rowTypeForRow:globalChildIndex] === CPRuleEditorRowTypeCompound)
{
var rowObject = [[self _rowCacheForIndex:current_index] rowObject],
subrows = [self _subrowObjectsOfObject:rowObject];
@@ -2334,8 +2353,8 @@ TODO: implement
var criteria = [self criteriaForRow:aRow];
indexofCriterion = [criteria indexOfObject:criterion];
if (parentItem != nil
&& indexofCriterion != CPNotFound
if (parentItem !== nil
&& indexofCriterion !== CPNotFound
&& indexofCriterion < [criteria count] - 1)
{
var next = indexofCriterion + 1;
@@ -2351,10 +2370,10 @@ TODO: implement
var availChild = aChild,
availValue = value;
if ( criterion != aChild )
if (criterion !== aChild)
availValue = [self _queryValueForItem:aChild inRow:aRow];
if ( !availValue )
if (!availValue)
availValue = [self _queryValueForItem:availChild inRow:aRow];
[availItems addObject:availChild];
@@ -2390,7 +2409,7 @@ var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth",
- (id)initWithCoder:(CPCoder)coder
{
self = [super initWithCoder:coder];
if (self != nil)
if (self !== nil)
{
[self setFormattingStringsFilename:[coder decodeObjectForKey:CPRuleEditorStringsFilenameKey]];
_alignmentGridWidth = [coder decodeFloatForKey:CPRuleEditorAlignmentGridWidthKey];
@@ -2474,7 +2493,7 @@ var CriteriaKey = @"criteria",
- (id)initWithCoder:(id)coder
{
self = [super init];
if (self != nil)
if (self !== nil)
{
subrows = [coder decodeObjectForKey:SubrowsKey];
criteria = [coder decodeObjectForKey:CriteriaKey];
@@ -2504,7 +2523,7 @@ var CriteriaKey = @"criteria",
- (CPString)description
{
return [CPString stringWithFormat:@"<%d object:%d rowIndex:%d indentation:%d>",[self hash], [rowObject hash], rowIndex, indentation];
return [CPString stringWithFormat:@"<%d object:%d rowIndex:%d indentation:%d>", [self hash], [rowObject hash], rowIndex, indentation];
}
@end
@@ -2570,21 +2589,23 @@ var dropSeparatorColor = [CPColor colorWithHexString:@"4886ca"];
- (int)valueType
{
var result = 0;
var result = 0,
isString = [self isKindOfClass:CPString];
var isString = [self isKindOfClass:[CPString class]];
if ( !isString )
if (!isString)
{
var isView = [self isKindOfClass:[CPView class]];
var isView = [self isKindOfClass:CPView];
result = 1;
if ( !isView )
if (!isView)
{
var ismenuItem = [self isKindOfClass:[CPMenuItem class]];
var ismenuItem = [self isKindOfClass:CPMenuItem];
result = 2;
if ( !ismenuItem )
if (!ismenuItem)
{
[CPException raise:CPGenericException reason:@"Unknown Type For " + self];
result = -1;
[CPException raise:CPGenericException reason:@"Unknown type for " + self];
result = -1;
}
}
}
@@ -2593,4 +2614,4 @@ var dropSeparatorColor = [CPColor colorWithHexString:@"4886ca"];
}
@end
/*! @endcond */
/*! @endcond */
@@ -28,11 +28,10 @@
node.tree = aTree;
var template = [aTree template],
uuid = [template UID];
uuid = [template UID],
cachedNode = templateTable[uuid];
var cachedNode = templateTable[uuid];
if (cachedNode == nil)
if (cachedNode === nil)
{
views = [CPMutableArray array];
copiedContainer = [CPMutableArray array];
@@ -67,6 +66,7 @@
- (BOOL)applyTemplate:(id)template withViews:(id)views forOriginalTemplate:(id)originalTemplate
{
var t = [tree template];
if (t !== template)
{
[templateViews setArray:views];
@@ -75,6 +75,7 @@
}
var count = [children count];
for (var i; i < count; i++)
[children[i] applyTemplate:template withViews:views forOriginalTemplate:originalTemplate];
}
@@ -89,7 +90,7 @@
- (void)copyTemplateIfNecessary
{
if ([copiedTemplateContainer count] == 0)
if ([copiedTemplateContainer count] === 0)
{
CPLogConsole("COPYING TEMPLATE");
var copy = [[tree template] copy];
@@ -118,7 +119,8 @@
- (id)displayValue
{
var title = [self title];
if (title != nil)
if (title !== nil)
return title;
return [self templateView];
@@ -129,4 +131,4 @@
return [CPString stringWithFormat:@"<%@ %@ %@ tree:%@ tviews:%@", [self className],[self UID], [self title], [tree UID], [templateViews description]];
}
@end
@end
+5 -6
View File
@@ -273,7 +273,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
Selects the item at the specified index.
@param anIndex the index of the item to display.
*/
- (void)selectTabViewItemAtIndex:(unsigned)anIndex
- (BOOL)selectTabViewItemAtIndex:(unsigned)anIndex
{
if (anIndex === _selectedIndex)
return;
@@ -281,7 +281,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
var aTabViewItem = [self tabViewItemAtIndex:anIndex];
if ((_delegateSelectors & CPTabViewShouldSelectTabViewItemSelector) && ![_delegate tabView:self shouldSelectTabViewItem:aTabViewItem])
return;
return NO;
if (_delegateSelectors & CPTabViewWillSelectTabViewItemSelector)
[_delegate tabView:self willSelectTabViewItem:aTabViewItem];
@@ -291,6 +291,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
if (_delegateSelectors & CPTabViewDidSelectTabViewItemSelector)
[_delegate tabView:self didSelectTabViewItem:aTabViewItem];
return YES;
}
/*!
@@ -431,11 +433,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
{
var segmentIndex = [_tabs testSegment:[_tabs convertPoint:[anEvent locationInWindow] fromView:nil]];
if (segmentIndex != CPNotFound)
{
[self selectTabViewItemAtIndex:segmentIndex];
if (segmentIndex != CPNotFound && [self selectTabViewItemAtIndex:segmentIndex])
[_tabs trackSegment:anEvent];
}
}
- (void)_repositionTabs
+27 -32
View File
@@ -540,7 +540,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
// Select the text if the textfield became first responder through keyboard interaction
if (!_willBecomeFirstResponderByClick)
[self selectText:self];
[self _selectText:self immediately:YES];
_willBecomeFirstResponderByClick = NO;
@@ -1071,24 +1071,36 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
*/
- (void)selectText:(id)sender
{
// FIXME Should this really make the text field the first responder?
[self _selectText:sender immediately:NO];
}
- (void)_selectText:(id)sender immediately:(BOOL)immediately
{
// Selecting the text in a field makes it the first responder
if (([self isEditable] || [self isSelectable]))
{
var wind = [self window];
#if PLATFORM(DOM)
var element = [self _inputElement];
if ([[self window] firstResponder] === self)
window.setTimeout(function() { element.select(); }, 0);
else if ([self window] !== nil && [[self window] makeFirstResponder:self])
window.setTimeout(function() {[self selectText:sender];}, 0);
if ([wind firstResponder] === self)
{
if (immediately)
element.select();
else
window.setTimeout(function() { element.select(); }, 0);
}
else if (wind !== nil && [wind makeFirstResponder:self])
[self _selectText:sender immediately:immediately];
#else
// Even if we can't actually select the text we need to preserve the first
// responder side effect.
if ([self window] !== nil && [[self window] firstResponder] !== self)
[[self window] makeFirstResponder:self];
if (wind !== nil && [wind firstResponder] !== self)
[wind makeFirstResponder:self];
#endif
}
}
- (void)copy:(id)sender
@@ -1509,32 +1521,15 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
[self _setPlaceholder:@"" forMarker:CPNullMarker isDefault:YES];
}
- (void)setValueFor:(CPString)theBinding
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
{
var destination = [_info objectForKey:CPObservedObjectKey],
keyPath = [_info objectForKey:CPObservedKeyPathKey],
options = [_info objectForKey:CPOptionsKey],
newValue = [destination valueForKeyPath:keyPath],
isPlaceholder = CPIsControllerMarker(newValue);
[_source setPlaceholderString:aValue];
[_source setObjectValue:nil];
}
if (isPlaceholder)
{
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
{
[CPException raise:CPGenericException
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
}
newValue = [self _placeholderForMarker:newValue];
[_source setPlaceholderString:newValue];
[_source setObjectValue:nil];
}
else
{
newValue = [self transformValue:newValue withOptions:options];
[_source setObjectValue:newValue];
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
[_source setObjectValue:aValue];
}
@end
+33 -6
View File
@@ -516,6 +516,7 @@ CPTexturedBackgroundWindowMask
- (void)awakeFromCib
{
_keyViewLoopIsDirty = ![self _hasKeyViewLoop];
// If no key view loop has been specified by hand, and we are not intending to auto recalculate,
// set up a default key view loop.
if (_keyViewLoopIsDirty && ![self autorecalculatesKeyViewLoop])
@@ -1301,6 +1302,34 @@ CPTexturedBackgroundWindowMask
_initialFirstResponder = aView;
}
- (void)_setupFirstResponder
{
/*
If:
- The key loop is dirty
- The key loop does not auto-recalculate
- The first responder is the window
- The initial first responder is the content view
Then calculate the key view loop and set the first responder
to the first view in the loop, since we should
always have an initial first responder and a key loop by default.
*/
if (_keyViewLoopIsDirty &&
!_autorecalculatesKeyViewLoop &&
_firstResponder === self &&
_initialFirstResponder === [self contentView])
{
[self recalculateKeyViewLoop];
// Make the first key view of the content view the first responder
var firstKeyView = [[self contentView] nextValidKeyView];
[self makeFirstResponder:firstKeyView];
}
}
/*!
Attempts to make the \c aResponder the first responder. Before trying
to make it the first responder, the receiver will ask the current first responder
@@ -1655,6 +1684,8 @@ CPTexturedBackgroundWindowMask
if (_firstResponder !== self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
[_firstResponder becomeKeyWindow];
[self _setupFirstResponder];
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidBecomeKeyNotification
object:self];
@@ -2489,10 +2520,7 @@ CPTexturedBackgroundWindowMask
[views sortUsingFunction:keyViewComparator context:nil];
var index = 0,
count = [views count];
for (; index < count; ++index)
for (var index = 0, count = [views count]; index < count; ++index)
[views[index] setNextKeyView:views[(index + 1) % count]];
_keyViewLoopIsDirty = NO;
@@ -2671,8 +2699,7 @@ var allViews = function(aWindow)
[views addObjectsFromArray:[[aWindow contentView] subviews]];
var index = 0;
for (; index < views.length; ++index)
for (var index = 0; index < views.length; ++index)
views = views.concat([views[index] subviews]);
return views;
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

+1 -1
View File
@@ -186,7 +186,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
// TODO: don't recompute everything, just compute the move offset
var edge = [_windowView preferredEdge];
[self positionRelativeToView:_targetView preferredEdge:edge];
[self positionRelativeToRect:nil ofView:_targetView preferredEdge:edge];
}
}
+22
View File
@@ -288,6 +288,28 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
return _textShadowOffset;
}
- (CGRect)textFrame
{
[self layoutIfNeeded];
var textFrame = CGRectMakeZero();
if (_DOMTextElement)
{
var textStyle = _DOMTextElement.style;
textFrame.origin.y = parseInt(textStyle.top.substr(0, textStyle.top.length - 2), 10),
textFrame.origin.x = parseInt(textStyle.left.substr(0, textStyle.left.length - 2), 10),
textFrame.size.width = parseInt(textStyle.width.substr(0, textStyle.width.length - 2), 10),
textFrame.size.height = parseInt(textStyle.height.substr(0, textStyle.height.length - 2), 10);
textFrame.size.width += _textShadowOffset.width;
textFrame.size.height += _textShadowOffset.height;
}
return textFrame;
}
- (void)setImage:(CPImage)anImage
{
if (_image == anImage)
+1 -1
View File
@@ -424,7 +424,7 @@
if (aKey.indexOf("@") === 0)
{
if (aKey.indexOf(".") !== -1)
[CPException raise:CPInvalidArgumentException reason:"called valueForKey: on an array with a complex key ("+aKey+"). use valueForKeyPath:"];
[CPException raise:CPInvalidArgumentException reason:"called valueForKey: on an array with a complex key (" + aKey + "). use valueForKeyPath:"];
if (aKey === "@count")
return length;
+4 -6
View File
@@ -119,7 +119,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0));
date.setMinutes(d[5]);
date.setSeconds(d[6]);
self = new Date(date.getTime() + (timeZoneOffset - date.getTimezoneOffset()) * 60 * 1000);
self = new Date(date.getTime() + (timeZoneOffset - date.getTimezoneOffset()) * 60 * 1000);
return self;
}
@@ -236,7 +236,9 @@ var numericKeys = [1, 4, 5, 6, 7, 10, 11];
Date.parseISO8601 = function (date)
{
var timestamp, struct, minutesOffset = 0;
var timestamp,
struct,
minutesOffset = 0;
// First, check for native parsing.
timestamp = Date.parse(date);
@@ -245,9 +247,7 @@ Date.parseISO8601 = function (date)
{
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
for (var i = 0, k; (k = numericKeys[i]); ++i)
{
struct[k] = +struct[k] || 0;
}
// allow undefined days and months
struct[2] = (+struct[2] || 1) - 1;
@@ -258,9 +258,7 @@ Date.parseISO8601 = function (date)
minutesOffset = struct[10] * 60 + struct[11];
if (struct[9] === '+')
{
minutesOffset = 0 - minutesOffset;
}
}
return Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);
+26 -20
View File
@@ -52,7 +52,10 @@ function Asynchronous(/*Function*/ aFunction)
if (asynchronousTimeoutCount > currentAsynchronousTimeoutCount)
aFunction.apply(this, args);
else
asynchronousFunctionQueue.push(function() { aFunction.apply(this, args) });
asynchronousFunctionQueue.push(function()
{
aFunction.apply(this, args);
});
};
}
@@ -77,7 +80,7 @@ if (window.ActiveXObject !== undefined)
NativeRequest = function()
{
return new ActiveXObject(MSXML_XMLHTTP);
}
};
break;
}
@@ -103,12 +106,15 @@ GLOBAL(CFHTTPRequest) = function()
this._stateChangeHandler = function()
{
determineAndDispatchHTTPRequestEvents(self);
}
};
this._nativeRequest.onreadystatechange = this._stateChangeHandler;
if (CFHTTPRequest.AuthenticationDelegate !== nil)
this._eventDispatcher.addEventListener("HTTP403", function(){CFHTTPRequest.AuthenticationDelegate(self)});
this._eventDispatcher.addEventListener("HTTP403", function()
{
CFHTTPRequest.AuthenticationDelegate(self);
});
}
CFHTTPRequest.UninitializedState = 0;
@@ -130,7 +136,7 @@ CFHTTPRequest.prototype.status = function()
{
return 0;
}
}
};
CFHTTPRequest.prototype.statusText = function()
{
@@ -142,12 +148,12 @@ CFHTTPRequest.prototype.statusText = function()
{
return "";
}
}
};
CFHTTPRequest.prototype.readyState = function()
{
return this._nativeRequest.readyState;
}
};
CFHTTPRequest.prototype.success = function()
{
@@ -159,7 +165,7 @@ CFHTTPRequest.prototype.success = function()
// file:// requests return with status 0, to know if they succeeded, we
// need to know if there was any content.
return status === 0 && this.responseText() && this.responseText().length;
}
};
CFHTTPRequest.prototype.responseXML = function()
{
@@ -169,7 +175,7 @@ CFHTTPRequest.prototype.responseXML = function()
return responseXML;
return parseXML(this.responseText());
}
};
CFHTTPRequest.prototype.responsePropertyList = function()
{
@@ -179,32 +185,32 @@ CFHTTPRequest.prototype.responsePropertyList = function()
return CFPropertyList.propertyListFromXML(this.responseXML());
return CFPropertyList.propertyListFromString(responseText);
}
};
CFHTTPRequest.prototype.responseText = function()
{
return this._nativeRequest.responseText;
}
};
CFHTTPRequest.prototype.setRequestHeader = function(/*String*/ aHeader, /*Object*/ aValue)
{
this._requestHeaders[aHeader] = aValue;
}
};
CFHTTPRequest.prototype.getResponseHeader = function(/*String*/ aHeader)
{
return this._nativeRequest.getResponseHeader(aHeader);
}
};
CFHTTPRequest.prototype.getAllResponseHeaders = function()
{
return this._nativeRequest.getAllResponseHeaders();
}
};
CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
{
this._mimeType = aMimeType;
}
};
CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword)
{
@@ -215,7 +221,7 @@ CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*B
this._user = aUser;
this._password = aPassword;
return this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword);
}
};
CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
{
@@ -246,23 +252,23 @@ CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
// FIXME: Do something more complex, with 404's?
this._eventDispatcher.dispatchEvent({ type:"failure", request:this });
}
}
};
CFHTTPRequest.prototype.abort = function()
{
this._isOpen = false;
return this._nativeRequest.abort();
}
};
CFHTTPRequest.prototype.addEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
{
this._eventDispatcher.addEventListener(anEventName, anEventListener);
}
};
CFHTTPRequest.prototype.removeEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
{
this._eventDispatcher.removeEventListener(anEventName, anEventListener);
}
};
function determineAndDispatchHTTPRequestEvents(/*CFHTTPRequest*/ aRequest)
{
+36 -36
View File
@@ -124,18 +124,18 @@ function CFURLGetParts(/*CFURL*/ aURL)
pathComponents = parts.pathComponents,
index = 0,
count = split.length;
for (; index < count; ++index)
{
var component = split[index];
if (component)
pathComponents.push(component);
else if (index === 0)
pathComponents.push("/");
}
parts.pathComponents = pathComponents;
}
@@ -209,7 +209,7 @@ DISPLAY_NAME(CFURL);
CFURL.prototype.UID = function()
{
return this._UID;
}
};
DISPLAY_NAME(CFURL.prototype.UID);
@@ -218,14 +218,14 @@ var URLMap = { };
CFURL.prototype.mappedURL = function()
{
return URLMap[this.absoluteString()] || this;
}
};
DISPLAY_NAME(CFURL.prototype.mappedURL);
CFURL.setMappedURLForURL = function(/*CFURL*/ fromURL, /*CFURL*/ toURL)
{
URLMap[fromURL.absoluteString()] = toURL;
}
};
DISPLAY_NAME(CFURL.setMappedURLForURL);
@@ -243,7 +243,7 @@ CFURL.prototype.schemeAndAuthority = function()
string += "//" + authority;
return string;
}
};
DISPLAY_NAME(CFURL.prototype.schemeAndAuthority);
@@ -253,14 +253,14 @@ CFURL.prototype.absoluteString = function()
this._absoluteString = this.absoluteURL().string();
return this._absoluteString;
}
};
DISPLAY_NAME(CFURL.prototype.absoluteString);
CFURL.prototype.toString = function()
{
return this.absoluteString();
}
};
DISPLAY_NAME(CFURL.prototype.toString);
@@ -280,7 +280,7 @@ function resolveURL(aURL)
if (parts.scheme || parts.authority)
resolvedParts = parts;
else
{
resolvedParts = { };
@@ -296,14 +296,14 @@ function resolveURL(aURL)
resolvedParts.queryString = parts.queryString;
resolvedParts.fragment = parts.fragment;
var pathComponents = parts.pathComponents
var pathComponents = parts.pathComponents;
if (pathComponents.length && pathComponents[0] === "/")
{
resolvedParts.path = parts.path;
resolvedParts.pathComponents = pathComponents;
}
else
{
var basePathComponents = baseParts.pathComponents,
@@ -424,7 +424,7 @@ CFURL.prototype.absoluteURL = function()
this._absoluteURL = resolveURL(this);
return this._absoluteURL;
}
};
DISPLAY_NAME(CFURL.prototype.absoluteURL);
@@ -458,7 +458,7 @@ CFURL.prototype.standardizedURL = function()
}
return this._standardizedURL;
}
};
DISPLAY_NAME(CFURL.prototype.standardizedURL);
@@ -466,7 +466,7 @@ function CFURLPartsCreateCopy(parts)
{
var copiedParts = { },
count = URI_KEYS.length;
while (count--)
{
var partName = URI_KEYS[count];
@@ -480,7 +480,7 @@ function CFURLPartsCreateCopy(parts)
CFURL.prototype.string = function()
{
return this._string;
}
};
DISPLAY_NAME(CFURL.prototype.string);
@@ -494,7 +494,7 @@ CFURL.prototype.authority = function()
var baseURL = this.baseURL();
return baseURL && baseURL.authority() || "";
}
};
DISPLAY_NAME(CFURL.prototype.authority);
@@ -520,21 +520,21 @@ CFURL.prototype.hasDirectoryPath = function()
}
return hasDirectoryPath;
}
};
DISPLAY_NAME(CFURL.prototype.hasDirectoryPath);
CFURL.prototype.hostName = function()
{
return this.authority();
}
};
DISPLAY_NAME(CFURL.prototype.hostName);
CFURL.prototype.fragment = function()
{
return PARTS(this).fragment;
}
};
DISPLAY_NAME(CFURL.prototype.fragment);
@@ -553,21 +553,21 @@ CFURL.prototype.lastPathComponent = function()
}
return this._lastPathComponent;
}
};
DISPLAY_NAME(CFURL.prototype.lastPathComponent);
CFURL.prototype.path = function()
{
return PARTS(this).path;
}
};
DISPLAY_NAME(CFURL.prototype.path);
CFURL.prototype.pathComponents = function()
{
return PARTS(this).pathComponents;
}
};
DISPLAY_NAME(CFURL.prototype.pathComponents);
@@ -583,14 +583,14 @@ CFURL.prototype.pathExtension = function()
var index = lastPathComponent.lastIndexOf(".");
return index <= 0 ? "" : lastPathComponent.substring(index + 1);
}
};
DISPLAY_NAME(CFURL.prototype.pathExtension);
CFURL.prototype.queryString = function()
{
return PARTS(this).queryString;
}
};
DISPLAY_NAME(CFURL.prototype.queryString);
@@ -613,42 +613,42 @@ CFURL.prototype.scheme = function()
}
return scheme;
}
};
DISPLAY_NAME(CFURL.prototype.scheme);
CFURL.prototype.user = function()
{
return PARTS(this).user;
}
};
DISPLAY_NAME(CFURL.prototype.user);
CFURL.prototype.password = function()
{
return PARTS(this).password;
}
};
DISPLAY_NAME(CFURL.prototype.password);
CFURL.prototype.portNumber = function()
{
return PARTS(this).portNumber;
}
};
DISPLAY_NAME(CFURL.prototype.portNumber);
CFURL.prototype.domain = function()
{
return PARTS(this).domain;
}
};
DISPLAY_NAME(CFURL.prototype.domain);
CFURL.prototype.baseURL = function()
{
return this._baseURL;
}
};
DISPLAY_NAME(CFURL.prototype.baseURL);
@@ -665,7 +665,7 @@ CFURL.prototype.asDirectoryPathURL = function()
lastPathComponent = "./" + lastPathComponent;
return new CFURL(lastPathComponent + "/", this);
}
};
DISPLAY_NAME(CFURL.prototype.asDirectoryPathURL);
@@ -680,14 +680,14 @@ function CFURLGetResourcePropertiesForKeys(/*CFURL*/ aURL)
CFURL.prototype.resourcePropertyForKey = function(/*String*/ aKey)
{
return CFURLGetResourcePropertiesForKeys(this).valueForKey(aKey);
}
};
DISPLAY_NAME(CFURL.prototype.resourcePropertyForKey);
CFURL.prototype.setResourcePropertyForKey = function(/*String*/ aKey, /*id*/ aValue)
{
CFURLGetResourcePropertiesForKeys(this).setValueForKey(aKey, aValue);
}
};
DISPLAY_NAME(CFURL.prototype.setResourcePropertyForKey);
@@ -698,6 +698,6 @@ CFURL.prototype.staticResourceData = function()
data.setRawString(StaticResource.resourceAtURL(this).contents());
return data;
}
};
DISPLAY_NAME(CFURL.prototype.staticResourceData);
+32 -15
View File
@@ -106,16 +106,34 @@ for (var i = 0; i < CPLogLevels.length; i++)
var _CPFormatLogMessage = function(aString, aLevel, aTitle)
{
var now = new Date();
aLevel = ( aLevel == null ? '' : ' [' + CPLogColorize(aLevel, aLevel) + ']' );
var now = new Date(),
titleAndLevel;
if (aLevel === null)
aLevel = "";
else
{
aLevel = aLevel || "info";
aLevel = "[" + CPLogColorize(aLevel, aLevel) + "]";
}
aTitle = aTitle || "";
if (aTitle && aLevel)
aTitle += " ";
titleAndLevel = aTitle + aLevel;
if (titleAndLevel)
titleAndLevel += ": ";
if (typeof exports.sprintf == "function")
return exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s",
return exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s",
now.getFullYear(), now.getMonth() + 1, now.getDate(),
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
aTitle, aLevel, aString);
titleAndLevel, aString);
else
return now + " " + aTitle + aLevel + ": " + aString;
return now + " " + titleAndLevel + ": " + aString;
}
// Loggers:
@@ -125,16 +143,15 @@ GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle, aFormatter)
{
if (typeof console != "undefined")
{
var message = (aFormatter || _CPFormatLogMessage)(aString, aLevel, aTitle);
var logger = {
"fatal": "error",
"error": "error",
"warn": "warn",
"info": "info",
"debug": "debug",
"trace": "debug"
}[aLevel];
var message = (aFormatter || _CPFormatLogMessage)(aString, aLevel, aTitle),
logger = {
"fatal": "error",
"error": "error",
"warn": "warn",
"info": "info",
"debug": "debug",
"trace": "debug"
}[aLevel];
if (logger && console[logger])
console[logger](message);
@@ -42,4 +42,9 @@
CPLogConsole(_cmd + [tabViewItem label]);
}
- (void)tabView:(CPTabView)aTabView shouldSelectTabViewItem:(CPTabViewItem)tabViewItem
{
return [tabViewItem identifier] != @"unselectable";
}
@end
File diff suppressed because one or more lines are too long
@@ -63,6 +63,7 @@
<string key="NSFrame">{{13, 40}, {454, 344}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="18873805"/>
<object class="NSMutableArray" key="NSTabViewItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTabViewItem" id="488469955">
@@ -77,6 +78,7 @@
<int key="NSvFlags">301</int>
<string key="NSFrame">{{164, 243}, {96, 21}}</string>
<reference key="NSSuperview" ref="378428221"/>
<reference key="NSNextKeyView" ref="979039271"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSliderCell" key="NSCell" id="600801425">
<int key="NSCellFlags">-2080244224</int>
@@ -100,6 +102,7 @@
</object>
</object>
<string key="NSFrame">{{10, 33}, {434, 298}}</string>
<reference key="NSNextKeyView" ref="974764906"/>
</object>
<string key="NSLabel">Tab</string>
<object class="NSColor" key="NSColor" id="199260378">
@@ -113,11 +116,24 @@
</object>
<reference key="NSTabView" ref="979039271"/>
</object>
<object class="NSTabViewItem" id="767904222">
<string key="NSIdentifier">2</string>
<object class="NSView" key="NSView" id="802661891">
<object class="NSTabViewItem" id="256931374">
<object class="NSView" key="NSView" id="18873805">
<reference key="NSNextResponder" ref="979039271"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{10, 33}, {434, 298}}</string>
<reference key="NSSuperview" ref="979039271"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="513383460"/>
</object>
<string key="NSLabel">View</string>
<reference key="NSColor" ref="199260378"/>
<reference key="NSTabView" ref="979039271"/>
</object>
<object class="NSTabViewItem" id="767904222">
<string key="NSIdentifier">unselectable</string>
<object class="NSView" key="NSView" id="802661891">
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTextField" id="160623561">
@@ -125,8 +141,6 @@
<int key="NSvFlags">301</int>
<string key="NSFrame">{{169, 246}, {96, 22}}</string>
<reference key="NSSuperview" ref="802661891"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="513383460"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="46991665">
<int key="NSCellFlags">-1804468671</int>
@@ -161,23 +175,21 @@
</object>
</object>
<string key="NSFrame">{{10, 33}, {434, 298}}</string>
<reference key="NSSuperview" ref="979039271"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="160623561"/>
</object>
<string key="NSLabel">View</string>
<string key="NSLabel">Not Selectable</string>
<reference key="NSColor" ref="199260378"/>
<reference key="NSTabView" ref="979039271"/>
</object>
</object>
<reference key="NSSelectedTabViewItem" ref="767904222"/>
<reference key="NSSelectedTabViewItem" ref="256931374"/>
<reference key="NSFont" ref="447530061"/>
<int key="NSTvFlags">0</int>
<bool key="NSAllowTruncatedLabels">YES</bool>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="802661891"/>
<reference ref="18873805"/>
</object>
</object>
<object class="NSTabView" id="513383460">
@@ -200,7 +212,7 @@
<string key="NSFrame">{{594, 14}, {222, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1045251964"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:3944</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="822028531">
@@ -225,6 +237,7 @@
<string key="NSFrame">{{153, 4}, {174, 32}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="405808750"/>
<string key="NSReuseIdentifierKey">_NS:687</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="299997884">
@@ -360,9 +373,9 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="513383460"/>
<reference ref="979039271"/>
<reference ref="405808750"/>
<reference ref="1045251964"/>
<reference ref="979039271"/>
</object>
<reference key="parent" ref="972006081"/>
</object>
@@ -378,6 +391,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="488469955"/>
<reference ref="767904222"/>
<reference ref="256931374"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
@@ -481,6 +495,20 @@
<reference key="object" ref="299997884"/>
<reference key="parent" ref="1045251964"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">488</int>
<reference key="object" ref="256931374"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="18873805"/>
</object>
<reference key="parent" ref="979039271"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">489</int>
<reference key="object" ref="18873805"/>
<reference key="parent" ref="256931374"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -509,6 +537,8 @@
<string>476.IBPluginDependency</string>
<string>479.IBPluginDependency</string>
<string>480.IBPluginDependency</string>
<string>488.IBPluginDependency</string>
<string>489.IBPluginDependency</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -534,6 +564,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -548,7 +580,7 @@
<reference key="dict.values" ref="1049"/>
</object>
<nil key="sourceID"/>
<int key="maxID">487</int>
<int key="maxID">489</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
+20 -2
View File
@@ -125,8 +125,8 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
return;
[self stopEventStream];
NSArray *pathsToWatch = [NSArray arrayWithObject:aPath];
NSMutableArray *pathsToWatch = [NSMutableArray arrayWithObject:aPath];
void *appPointer = (void *)self;
FSEventStreamContext context = {0, appPointer, NULL, NULL, NULL};
CFTimeInterval latency = 2.0;
@@ -143,6 +143,24 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
flags = kFSEventStreamCreateFlagUseCFTypes;
}
// add symlinked directories
NSArray *fileList = [fm contentsOfDirectoryAtPath:aPath error:nil];
for (NSString *node in fileList)
{
NSDictionary *attributes = [fm attributesOfItemAtPath:aPath error:nil];
if ([[attributes objectForKey:@"NSFileType"] isEqualTo:NSFileTypeDirectory])
{
NSString *subDirectoryPath = [aPath stringByAppendingPathComponent:node];
NSString *symlinkDestination = [fm destinationOfSymbolicLinkAtPath:subDirectoryPath error:nil];
if (symlinkDestination)
{
[pathsToWatch addObject:subDirectoryPath];
}
}
}
stream = FSEventStreamCreate(NULL, &fsevents_callback, &context, (CFArrayRef) pathsToWatch,
[lastEventId unsignedLongLongValue], latency, flags);
+2 -3
View File
@@ -5,7 +5,6 @@ var FILE = require("file"),
SYSTEM = require("system"),
path = FILE.Path(FILE.join(SYSTEM.prefix, "bin", "dump_theme"));
FILE.copy("dump_theme", path);
path.chmod(0755);
sudo(["cp", "-f", "dump_theme", path]);
sudo(["chmod", "755", path]);
copyManPage("dump_theme", 1);
+2 -2
View File
@@ -116,13 +116,13 @@ ConverterConversionException = @"ConverterConversionException";
try
{
// Compile xib or nib to make sure we have a non-new format nib.
temporaryNibFilePath = FILE.join("/var/tmp", FILE.basename(aFilePath) + ".tmp.nib");
temporaryNibFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.nib");
if (OS.popen(["/usr/bin/ibtool", aFilePath, "--compile", temporaryNibFilePath]).wait() === 1)
[CPException raise:ConverterConversionException reason:@"Could not compile file: " + aFilePath];
// Convert from binary plist to XML plist
var temporaryPlistFilePath = FILE.join("/var/tmp", FILE.basename(aFilePath) + ".tmp.plist");
var temporaryPlistFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.plist");
if (OS.popen(["/usr/bin/plutil", "-convert", "xml1", temporaryNibFilePath, "-o", temporaryPlistFilePath]).wait() === 1)
[CPException raise:ConverterConversionException reason:@"Could not convert to xml plist for file: " + aFilePath];
+119 -75
View File
@@ -1,12 +1,34 @@
var SYSTEM = require("system");
var FILE = require("file");
var OS = require("os");
var UTIL = require("narwhal/util");
var stream = require("narwhal/term").stream;
/*
* command.jake
* toolchain
*
* Copyright 2012 The Cappuccino Foundation
*
* 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
*/
var requiresSudo = false;
var SYSTEM = require("system"),
FILE = require("file"),
OS = require("os"),
UTIL = require("narwhal/util"),
stream = require("narwhal/term").stream,
SYSTEM.args.slice(1).forEach(function(arg){
requiresSudo = false;
SYSTEM.args.slice(1).forEach(function(arg)
{
if (arg === "sudo-install")
requiresSudo = true;
});
@@ -21,7 +43,7 @@ function ensurePackageUpToDate(packageName, requiredVersion, options)
if (options.optional)
return;
print("You are missing package \"" + packageName + "\", version " + requiredVersion + " or later. Please install using \"tusk install "+packageName+"\" and re-run jake");
print("You are missing package \"" + packageName + "\", version " + requiredVersion + " or later. Please install using \"tusk install "+ packageName +"\" and re-run jake");
OS.exit(1);
}
@@ -35,11 +57,12 @@ function ensurePackageUpToDate(packageName, requiredVersion, options)
if (version && UTIL.compare(version, requiredVersion) !== -1)
return;
print("Your copy of " + packageName + " is out of date (" + (version||["0"]).join(".") + " installed, " + requiredVersion.join(".") + " required).");
print("Your copy of " + packageName + " is out of date (" + (version || ["0"]).join(".") + " installed, " + requiredVersion.join(".") + " required).");
if (!options.noupdate)
{
print("Update? Existing package will be overwritten. yes or no:");
if (!SYSTEM.env["CAPP_AUTO_UPGRADE"] && system.stdin.readLine() !== "yes\n")
{
print("Jake aborted.");
@@ -51,7 +74,7 @@ function ensurePackageUpToDate(packageName, requiredVersion, options)
if (OS.system(["sudo", "tusk", "install", "--force", packageName]))
{
// Attempt a hackish work-around for sudo compiled with the --with-secure-path option
if (OS.system("sudo bash -c 'source " + getShellConfigFile() + "; tusk install --force "+packageName))
if (OS.system("sudo bash -c 'source " + getShellConfigFile() + "; tusk install --force "+ packageName))
OS.exit(1); //rake abort if ($? != 0)
}
}
@@ -110,7 +133,7 @@ if (!SYSTEM.env["CONFIG"])
SYSTEM.env["CONFIG"] = "Release";
global.ENV = SYSTEM.env;
global.ARGV = SYSTEM.args
global.ARGV = SYSTEM.args;
global.FILE = FILE;
global.OS = OS;
@@ -141,7 +164,8 @@ global.$LICENSE_FILE = FILE.absolute(FILE.join(FILE.dirname(module.path), 'LI
global.FIXME_fileDependency = function(destinationPath, sourcePath)
{
file(destinationPath, [sourcePath], function(){
file(destinationPath, [sourcePath], function()
{
FILE.touch(destinationPath);
});
};
@@ -185,22 +209,26 @@ serializedENV = function()
var envNew = {};
// add changed keys to the new ENV
Object.keys(SYSTEM.env).forEach(function(key) {
Object.keys(SYSTEM.env).forEach(function(key)
{
if (SYSTEM.env[key] !== envInitial[key])
envNew[key] = SYSTEM.env[key];
});
// pseudo-HACK: add NARWHALOPT with packages we should ensure are loaded
var packages = additionalPackages();
if (packages.length) {
if (packages.length)
{
envNew["NARWHALOPT"] = packages.map(function(p) { return "-p " + OS.enquote(p); }).join(" ");
envNew["PATH"] = packages.map(function(p) { return FILE.join(p, "bin"); }).concat(SYSTEM.env["PATH"]).join(":");
}
return Object.keys(envNew).map(function(key) {
return Object.keys(envNew).map(function(key)
{
return key + "=" + OS.enquote(envNew[key]);
}).join(" ");
}
};
function getShellConfigFile()
{
@@ -220,7 +248,8 @@ function getShellConfigFile()
function reforkWithPackages()
{
if (additionalPackages().length > 0) {
if (additionalPackages().length > 0)
{
var cmd = serializedENV() + " " + system.args.map(OS.enquote).join(" ");
//print("REFORKING: " + cmd);
OS.exit(OS.system(cmd));
@@ -229,8 +258,10 @@ function reforkWithPackages()
reforkWithPackages();
function handleSetupEnvironmentError(e) {
if (String(e).indexOf("require error")==-1) {
function handleSetupEnvironmentError(e)
{
if (String(e).indexOf("require error") == -1)
{
print("setupEnvironment warning: " + e);
//throw e;
}
@@ -238,9 +269,12 @@ function handleSetupEnvironmentError(e) {
function setupEnvironment()
{
try {
try
{
require("objective-j").OBJJ_INCLUDE_PATHS.push(FILE.join($BUILD_CONFIGURATION_DIR, "CommonJS", "cappuccino", "Frameworks"));
} catch (e) {
}
catch (e)
{
handleSetupEnvironmentError(e);
}
}
@@ -251,7 +285,7 @@ global.rm_rf = function(/*String*/ aFilename)
{
try { FILE.rmtree(aFilename); }
catch (anException) { }
}
};
global.cp_r = function(/*String*/ from, /*String*/ to)
{
@@ -260,20 +294,29 @@ global.cp_r = function(/*String*/ from, /*String*/ to)
if (FILE.isDirectory(from))
FILE.copyTree(from, to);
else{try{
FILE.copy(from, to);}catch(e) { print(e + FILE.exists(from) + " " + FILE.exists(FILE.dirname(to))); }}
}
else
{
try
{
FILE.copy(from, to);
}
catch (e)
{
print(e + FILE.exists(from) + " " + FILE.exists(FILE.dirname(to)));
}
}
};
global.cp = function(/*String*/ from, /*String*/ to)
{
FILE.copy(from, to);
// FILE.chmod(to, FILE.mod(from));
}
};
global.mv = function(/*String*/ from, /*String*/ to)
{
FILE.move(from, to);
}
};
global.subjake = function(/*Array<String>*/ directories, /*String*/ aTaskName)
{
@@ -284,15 +327,16 @@ global.subjake = function(/*Array<String>*/ directories, /*String*/ aTaskName)
{
if (FILE.isDirectory(aDirectory) && FILE.isFile(FILE.join(aDirectory, "Jakefile")))
{
var cmd = "cd " + OS.enquote(aDirectory) + " && " + serializedENV() + " " + OS.enquote(SYSTEM.args[0]) + " " + OS.enquote(aTaskName);
var returnCode = OS.system(cmd);
var cmd = "cd " + OS.enquote(aDirectory) + " && " + serializedENV() + " " + OS.enquote(SYSTEM.args[0]) + " " + OS.enquote(aTaskName),
returnCode = OS.system(cmd);
if (returnCode)
OS.exit(returnCode);
}
else
print("warning: subjake missing: " + aDirectory + " (this is not necessarily an error, " + aDirectory + " may be optional)");
});
}
};
global.executableExists = function(/*String*/ executableName)
{
@@ -303,7 +347,7 @@ global.executableExists = function(/*String*/ executableName)
return path;
}
return null;
}
};
$OBJJ_TEMPLATE_EXECUTABLE = FILE.join($HOME_DIR, "Objective-J", "CommonJS", "objj-executable");
@@ -311,21 +355,23 @@ global.make_objj_executable = function(aPath)
{
cp($OBJJ_TEMPLATE_EXECUTABLE, aPath);
FILE.chmod(aPath, 0755);
}
};
global.symlink_executable = function(source)
{
relative = FILE.relative($ENVIRONMENT_NARWHAL_BIN_DIR, source);
destination = FILE.join($ENVIRONMENT_NARWHAL_BIN_DIR, FILE.basename(source));
FILE.symlink(relative, destination);
}
};
global.getCappuccinoVersion = function() {
global.getCappuccinoVersion = function()
{
var versionFile = FILE.path(module.path).dirname().join("version.json");
return JSON.parse(versionFile.read({ charset : "UTF-8" })).version;
}
};
global.setPackageMetadata = function(packagePath) {
global.setPackageMetadata = function(packagePath)
{
var pkg = JSON.parse(FILE.read(packagePath, { charset : "UTF-8" }));
var p = OS.popen(["git", "rev-parse", "--verify", "HEAD"]);
@@ -343,7 +389,7 @@ global.setPackageMetadata = function(packagePath) {
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
FILE.write(packagePath, JSON.stringify(pkg, null, 4), { charset : "UTF-8" });
}
};
global.subtasks = function(subprojects, taskNames)
{
@@ -358,7 +404,7 @@ global.subtasks = function(subprojects, taskNames)
subjake(subprojects, aTaskName);
});
});
}
};
global.installSymlink = function(sourcePath)
{
@@ -396,21 +442,41 @@ global.installSymlink = function(sourcePath)
FILE.symlink(relative, target);
});
}
}
};
global.spawnJake = function(/*String*/ aTaskName)
{
if (OS.system(serializedENV() + " " + SYSTEM.args[0] + " " + aTaskName))
OS.exit(1);//rake abort if ($? != 0)
}
};
global.sudo = function(/*String*/ aTaskName)
var normalizeCommand = function(/*Array or String*/ command)
{
var cmd = "sudo bash -c 'source " + getShellConfigFile() + "; " + aTaskName + "'";
if (Array.isArray(command))
return command.map(function (arg)
{
return OS.enquote(arg);
}).join(" ");
else
return command;
};
if (OS.system(cmd))
OS.exit(1); //rake abort if ($? != 0)
}
global.sudo = function(/*Array or String*/ command)
{
// First try without sudo
command = normalizeCommand(command);
if (OS.system(command + " >/dev/null 2>&1"))
return OS.system("sudo -p '\nEnter your admin password: ' " + command);
return 0;
};
global.exec = function(/*Array or String*/ command, quiet)
{
command = normalizeCommand(command) + (quiet === true ? " >/dev/null 2>&1" : "");
return OS.system(command);
};
global.copyManPage = function(/*String*/ name, /*int*/ section)
{
@@ -420,54 +486,32 @@ global.copyManPage = function(/*String*/ name, /*int*/ section)
if (!FILE.exists(manPagePath) || FILE.mtime(pageFile) > FILE.mtime(manPagePath))
{
var sudo = ["sudo", "-p", "\nEnter your admin password: "],
useSudo = false,
success = true,
cmd;
if (!FILE.isDirectory(manDir))
{
cmd = ["mkdir", "-p", "-m", "0755", manDir];
if (FILE.isWritable(FILE.dirname(manDir)))
success = OS.system(cmd) === 0;
else
{
useSudo = true;
success = OS.system(sudo.concat(cmd)) === 0;
}
if (!success)
if (!sudo(["mkdir", "-p", "-m", "0755", manDir]))
{
stream.print("\0red(Unable to create the man directory.\0)");
OS.exit(1);
}
}
cmd = ["cp", "-f", pageFile, manDir];
if (FILE.isWritable(manDir))
success = OS.system(cmd) === 0;
else
success = OS.system(sudo.concat(cmd)) === 0;
if (!success)
if (!sudo(["cp", "-f", pageFile, manDir]))
stream.print("\0red(Unable to copy the man file.\0)");
}
}
global.xcodebuildCanListSDKs = function()
{
return OS.system("xcodebuild -showsdks > /dev/null 2>&1") == 0;
}
return global.exec("xcodebuild -showsdks", true) === 0;
};
global.xcodebuildHasTenPointFiveSDK = function()
{
if (xcodebuildCanListSDKs())
return OS.system("xcodebuild -showsdks | grep 'macosx10.5' > /dev/null 2>&1") == 0;
return global.exec("xcodebuild -showsdks | grep 'macosx10.5'", true) === 0;
return FILE.exists(FILE.join("/", "Developer", "SDKs", "MacOSX10.5.sdk"));
}
};
global.colorize = function(/* String */ message, /* String */ color)
{
@@ -482,12 +526,12 @@ global.colorize = function(/* String */ message, /* String */ color)
message = "\0bold(" + message + "\0)";
return message;
}
};
global.colorPrint = function(/* String */ message, /* String */ color)
{
stream.print(colorize(message, color));
}
};
// built in tasks