Compare commits

..
1 Commits
Author SHA1 Message Date
Tom Robinson 182f6a0030 CPLog refactor 2010-03-08 01:14:39 -08:00
87 changed files with 1180 additions and 1582 deletions
+38 -24
View File
@@ -860,11 +860,12 @@ CPRunContinuesResponse = -1002;
if ([windowController respondsToSelector:anAction])
return windowController;
var theDocument = [windowController document];
if (theDocument !== delegate && [theDocument respondsToSelector:anAction])
if (theDocument != delegate && [theDocument respondsToSelector:anAction])
return theDocument;
return nil;
}
@@ -873,7 +874,7 @@ CPRunContinuesResponse = -1002;
Checks for a target in the following order:
<ol>
<li>a responder from the key window</li>
<li>a responder from the main window</li>
<li>a responder frmo the main window</li>
<li>the CPApplication instance</li>
<li>the application delegate</li>
<li>the document controller</li>
@@ -912,6 +913,8 @@ CPRunContinuesResponse = -1002;
- (void)setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
{
_eventListeners.push(_CPEventListenerMake(aMask, aCallback));
if (_eventListeners.length == 3) objj_debug_print_backtrace();
}
- (CPEvent)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
@@ -970,9 +973,10 @@ CPRunContinuesResponse = -1002;
[self endSheet:sheet returnCode:0];
}
- (CPArray)arguments
{
if(_fullArgsString !== window.location.hash)
if(_fullArgsString != window.location.hash)
[self _reloadArguments];
return _args;
@@ -1005,18 +1009,12 @@ CPRunContinuesResponse = -1002;
- (void)_reloadArguments
{
_fullArgsString = window.location.hash;
var args = _fullArgsString.replace("#", "").split("/").slice(0);
if (_fullArgsString.length)
{
var args = _fullArgsString.substring(1).split("/");
for (var i = 0, count = args.length; i < count; i++)
args[i] = decodeURIComponent(args[i]);
_args = args;
}
else
_args = [];
for(var i=0, count = args.length; i<count; i++)
args[i] = decodeURIComponent(args[i]);
_args = args;
}
- (CPDictionary)namedArguments
@@ -1060,7 +1058,7 @@ CPRunContinuesResponse = -1002;
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
[[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
[[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
_previousMainWindow = nil;
@@ -1145,8 +1143,29 @@ function CPApplicationMain(args, namedArgs)
[principalClass sharedApplication];
if ([args containsObject:"debug"])
CPLogRegister(CPLogPopup);
//FIXME?
if (!args)
{
var args = [CPApp arguments];
if([args containsObject:"debug"])
CPLogRegister(CPLogPopup);
}
if (!namedArgs)
{
var searchParams = window.location.search.substring(1).split("&");
namedArgs = [CPDictionary dictionary];
for(var i=0; i<searchParams.length; i++)
{
var index = searchParams[i].indexOf('=');
if(index == -1)
[namedArgs setObject: "" forKey:searchParams[i]];
else
[namedArgs setObject: searchParams[i].substring(index+1) forKey: searchParams[i].substring(0, index)];
}
}
CPApp._args = args;
CPApp._namedArgs = namedArgs;
@@ -1224,11 +1243,6 @@ var _CPAppBootstrapperActions = nil;
[self performActions];
}
+ (void)cibDidFailToLoad:(CPCib)aCib
{
throw new Error("Could not load main cib file (Did you forget to nib2cib it?).");
}
+ (void)reset
{
_CPAppBootstrapperActions = nil;
-1
View File
@@ -162,7 +162,6 @@ CPGrooveBorder = 3;
[aView setFrame:CGRectInset([self bounds], _contentMargin.width + _borderWidth, _contentMargin.height + _borderWidth)];
[self replaceSubview:_contentView with:aView];
[aView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
_contentView = aView;
}
+5 -2
View File
@@ -502,6 +502,8 @@ CPButtonStateMixed = CPThemeState("mixed");
}
else
return [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
return [super createEphemeralSubviewNamed:aName];
}
- (void)layoutSubviews
@@ -509,8 +511,9 @@ CPButtonStateMixed = CPThemeState("mixed");
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:@"content-view"];
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
if (bezelView)
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove
+6 -14
View File
@@ -120,13 +120,9 @@
[super setBoundsOrigin:aPoint];
var superview = [self superview],
// This is hack to avoid having to import CPScrollView.
// FIXME: Should CPScrollView be finding out about this on its own somehow?
scrollViewClass = objj_getClass("CPScrollView");
if([superview isKindOfClass:scrollViewClass])
var superview = [self superview];
if([superview isKindOfClass:[CPScrollView class]])
[superview reflectScrolledClipView:self];
}
@@ -177,13 +173,9 @@
return;
// ... and we're in a scroll view of course.
var superview = [self superview],
// This is hack to avoid having to import CPScrollView.
// FIXME: Should CPScrollView be finding out about this on its own somehow?
scrollViewClass = objj_getClass("CPScrollView");
if ([superview isKindOfClass:scrollViewClass])
var superview = [self superview];
if ([superview isKindOfClass:[CPScrollView class]])
[superview reflectScrolledClipView:self];
}
+30 -55
View File
@@ -597,10 +597,6 @@
if (![_selectionIndexes count])
return;
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)] &&
![_delegate collectionView:self canDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
return;
// Set up the pasteboard
var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes];
@@ -680,42 +676,41 @@
return _delegate;
}
- (CPCollectionViewItem)itemAtIndex:(unsigned)anIndex
{
return [_items objectAtIndex:anIndex];
}
- (CGRect)frameForItemAtIndex:(unsigned)anIndex
{
return [[[self itemAtIndex:anIndex] view] frame];
}
- (CGRect)frameForItemsAtIndexes:(CPIndexSet)anIndexSet
{
var indexArray = [],
frame = CGRectNull;
[anIndexSet getIndexes:indexArray maxCount:-1 inIndexRange:nil];
var index = 0,
count = [indexArray count];
for (; index < count; ++index)
frame = CGRectUnion(frame, [self rectForItemAtIndex:indexArray[index]]);
return frame;
}
@end
@implementation CPCollectionView (KeyboardInteraction)
- (CGRect)rectForItemAtIndex:(int)index
{
// Don't re-compute anything just grab the current frame
// This allows subclasses to override tile without messing this up.
return [[_items[index] view] frame];
}
- (CGRect)rectForItemsAtIndexes:(CPIndexSet)indexSet
{
var indexArray = [],
rect = nil;
[indexSet getIndexes:indexArray maxCount:-1 inIndexRange:nil];
for (var i = 0, count = indexArray.length; i < count; ++i)
{
var index = indexArray[i];
if (rect == nil)
rect = [self rectForItemAtIndex:index];
else
rect = CGRectUnion(rect, [self rectForItemAtIndex:index]);
}
return rect;
}
- (void)_scrollToSelection
{
var frame = [self frameForItemsAtIndexes:[self selectionIndexes]];
if (!CGRectIsNull(frame))
[self scrollRectToVisible:frame];
var rect = [self rectForItemsAtIndexes:[self selectionIndexes]];
if (rect)
[self scrollRectToVisible:rect];
}
- (void)moveLeft:(id)sender
@@ -758,7 +753,7 @@
[self _scrollToSelection];
}
- (void)deleteBackward:(id)sender
- (void)deleteBackwards:(id)sender
{
if ([[self delegate] respondsToSelector:@selector(collectionView:shouldDeleteItemsAtIndexes:)])
{
@@ -780,26 +775,6 @@
@end
@implementation CPCollectionView (Deprecated)
- (CGRect)rectForItemAtIndex:(int)anIndex
{
_CPReportLenientDeprecation([self class], _cmd, @selector(frameForItemAtIndex:));
// Don't re-compute anything just grab the current frame
// This allows subclasses to override tile without messing this up.
return [self frameForItemAtIndex:anIndex];
}
- (CGRect)rectForItemsAtIndexes:(CPIndexSet)anIndexSet
{
_CPReportLenientDeprecation([self class], _cmd, @selector(frameForItemsAtIndexes:));
return [self frameForItemsAtIndexes:anIndexSet];
}
@end
var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey",
CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey",
+1 -1
View File
@@ -51,7 +51,7 @@ var CPSharedFontManager = nil,
// Changing the Default Font Conversion Classes
/*!
Sets the class that will be used to create the application's
Sets the class that will be used to create the applcation's
font manager.
*/
+ (void)setFontManagerFactory:(Class)aClass
+2 -2
View File
@@ -227,8 +227,8 @@ var SelectionColor = nil,
CGContextClosePath(context);
CGContextSetShadowWithColor(context, CGSizeMake(0.0, 1.0), 1.1, _shadowColor || [CPColor whiteColor]);
CGContextSetFillColor(context, _color || [CPColor blackColor]);
CGContextSetShadowWithColor(context, CGSizeMake(0.0, 1.0), 1.1, _shadowColor);
CGContextSetFillColor(context, _color);
CGContextFillPath(context);
}
+3 -13
View File
@@ -52,10 +52,9 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_ = 1 << 1,
CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 2,
CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 2;
CPOutlineViewDelegate_outlineView_heightOfRowByItem_ = 1 << 3,
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 4,
CPOutlineViewDelegate_outlineView_isGroupItem_ = 1 << 5;
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 4;
CPOutlineViewDropOnItemIndex = -1;
@@ -469,10 +468,7 @@ CPOutlineViewDropOnItemIndex = -1;
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:willDisplayView:forTableColumn:item:)])
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_;
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:isGroupItem:)])
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_isGroupItem_;
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewColumnDidMove:)])
[defaultCenter
addObserver:_outlineViewDelegate
@@ -1024,13 +1020,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
}
}
- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(int)row
{
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_isGroupItem_))
return [_outlineView._outlineViewDelegate outlineView:_outlineView isGroupItem:[_outlineView itemAtRow:theRow]];
return NO;
}
@end
+3 -2
View File
@@ -235,7 +235,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
*/
- (void)checkSpaceForParts
{
var bounds = [self bounds];
var bounds = [self bounds];
// Assume we won't be needing the arrows.
if (_knobProportion === 1.0)
@@ -290,7 +290,8 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
_partRects[CPScrollerDecrementLine] = _CGRectMakeZero();
_partRects[CPScrollerKnobSlot] = _CGRectMake(trackInset.left, 0, width - trackInset.left - trackInset.right, height);
}
}
}
else
{
var decrementLineSize = [self currentValueForThemeAttribute:"decrement-line-size"],
+69 -41
View File
@@ -24,10 +24,26 @@
#include "Platform/Platform.h"
CPSearchFieldRecentsTitleMenuItemTag = 1000;
CPSearchFieldRecentsMenuItemTag = 1001;
CPSearchFieldClearRecentsMenuItemTag = 1002;
CPSearchFieldNoRecentsMenuItemTag = 1003;
/*!
@global
@group Menu tags
*/
CPSearchFieldRecentsTitleMenuItemTag = 1000;
/*!
@global
@group Menu tags
*/
CPSearchFieldRecentsMenuItemTag = 1001;
/*!
@global
@group Menu tags
*/
CPSearchFieldClearRecentsMenuItemTag = 1002;
/*!
@global
@group Menu tags
*/
CPSearchFieldNoRecentsMenuItemTag = 1003;
var CPSearchFieldSearchImage = nil,
CPSearchFieldFindImage = nil,
@@ -69,43 +85,58 @@ var CPSearchFieldSearchImage = nil,
CPSearchFieldCancelPressedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancelPressed.png"]];
}
- (id)initWithFrame:(CGRect)frame
- (id)initWithFrame:(CPRect)frame
{
if (self = [super initWithFrame:frame])
self = [super initWithFrame:frame];
if (self != nil)
{
_recentSearches = [CPArray array];
_maximumRecents = 10;
_sendsWholeSearchString = NO;
_sendsSearchStringImmediately = NO;
_recentsAutosaveName = nil;
[self setBezeled:YES];
[self setBezelStyle:CPTextFieldRoundedBezel];
[self setBordered:YES];
[self setEditable:YES];
[self setDelegate:self];
_cancelButton = [[CPButton alloc] initWithFrame:CPMakeRect(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
[self resetCancelButton];
[_cancelButton setHidden:YES];
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_cancelButton];
_searchButton = [[CPButton alloc] initWithFrame:CPMakeRect(5,(frame.size.height-25)/2,25,25)];
[self resetSearchButton];
[self addSubview:_searchButton];
[self _initWithFrame:frame];
#if PLATFORM(DOM)
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
}
return self;
}
- (void)_initWithFrame:(CGRect)frame
- (id)copy
{
[self setBezeled:YES];
[self setBezelStyle:CPTextFieldRoundedBezel];
[self setBordered:YES];
[self setEditable:YES];
[self setDelegate:self];
var copy = [super copy];
_cancelButton = [[CPButton alloc] initWithFrame:CPMakeRect(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
[self resetCancelButton];
[_cancelButton setHidden:YES];
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_cancelButton];
[copy setCancelButton:[_cancelButton copy]];
[copy setSearchButton:[_searchButton copy]];
[copy setSendsWholeSearchString:[_sendsWholeSearchString copy]];
[copy setSendsSearchStringImmediately:[_sendsSearchStringImmediately copy]];
[copy setMaximumRecents:_maximumRecents];
if (_recentsAutosaveName)
[copy setrecentsAutosaveName:[_recentsAutosaveName copy]];
if (_searchMenuTemplate)
[copy setSearchMenutemplate:[_searchMenuTemplate copy]];
_searchButton = [[CPButton alloc] initWithFrame:CPMakeRect(5,(frame.size.height-25)/2,25,25)];
[self resetSearchButton];
[self addSubview:_searchButton];
return copy;
}
// Managing Buttons
@@ -683,7 +714,6 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
[coder encodeBool:_sendsWholeSearchString forKey:CPSendsWholeSearchStringKey];
[coder encodeBool:_sendsSearchStringImmediately forKey:CPSendsSearchStringImmediatelyKey];
[coder encodeInt:_maximumRecents forKey:CPMaximumRecentsKey];
if (_recentsAutosaveName)
[coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
if (_searchMenuTemplate)
@@ -692,23 +722,21 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
- (id)initWithCoder:(CPCoder)coder
{
if (self = [super initWithCoder:coder])
{
_searchButton = [coder decodeObjectForKey:CPSearchButtonKey];
_cancelButton = [coder decodeObjectForKey:CPCancelButtonKey];
_recentsAutosaveName = [coder decodeObjectForKey:CPRecentsAutosaveNameKey];
_sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
_sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
_maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
if (template)
[self setSearchMenuTemplate:template];
[self setDelegate:self];
}
self = [super initWithCoder:coder];
_searchButton = [coder decodeObjectForKey:CPSearchButtonKey];
_cancelButton = [coder decodeObjectForKey:CPCancelButtonKey];
_recentsAutosaveName = [coder decodeObjectForKey:CPRecentsAutosaveNameKey];
_sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
_sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
_maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
if (template)
[self setSearchMenuTemplate:template];
[self setDelegate:self];
return self;
}
@end
@end
+2 -2
View File
@@ -81,8 +81,8 @@ CPTableColumnUserResizingMask = 1 << 1;
var textDataView = [CPTextField new];
[textDataView setLineBreakMode:CPLineBreakByTruncatingTail];
[textDataView setValue:[CPColor colorWithHexString:@"333333"] forThemeAttribute:@"text-color"];
[textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[textDataView setValue:[CPFont boldSystemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];
[textDataView setValue:[CPFont boldSystemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateHighlighted];
[textDataView setValue:CPCenterVerticalTextAlignment forThemeAttribute:@"vertical-alignment"];
[self setDataView:textDataView];
}
+24 -20
View File
@@ -24,6 +24,8 @@
@import "CPTableView.j"
@import "CPView.j"
var CPThemeStatePressed = CPThemeState("pressed");
@implementation _CPTableColumnHeaderView : CPView
{
_CPImageAndTextView _textField;
@@ -60,11 +62,11 @@
{
var themeState = [self themeState];
if(themeState & CPThemeStateSelected && themeState & CPThemeStateHighlighted)
if(themeState & CPThemeStateHighlighted && themeState & CPThemeStatePressed)
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted-pressed.png", CGSizeMake(1.0, 22.0))]];
else if (themeState & CPThemeStateSelected)
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted.png", CGSizeMake(1.0, 22.0))]];
else if (themeState & CPThemeStateHighlighted)
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted.png", CGSizeMake(1.0, 22.0))]];
else if (themeState & CPThemeStatePressed)
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-pressed.png", CGSizeMake(1.0, 22.0))]];
else
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
@@ -158,24 +160,21 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
CPTableView _tableView @accessors(property=tableView);
}
- (void)_init
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
- (id)initWithFrame:(CGRect)aFrame
- (void)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
[self _init];
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
return self;
}
@@ -222,13 +221,13 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
if (_pressedColumn != -1)
{
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
[headerView unsetThemeState:CPThemeStateHighlighted];
[headerView unsetThemeState:CPThemeStatePressed];
}
if (column != -1)
{
var headerView = [_tableView._tableColumns[column] headerView];
[headerView setThemeState:CPThemeStateHighlighted];
[headerView setThemeState:CPThemeStatePressed];
}
_pressedColumn = column;
@@ -482,7 +481,12 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
{
if (self = [super initWithCoder:aCoder])
{
[self _init];
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
_tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey];
}
+57 -58
View File
@@ -67,29 +67,29 @@ var CPTableViewDelegate_selectionShouldChangeInTableView_
CPTableViewDelegate_tableViewSelectionIsChanging_ = 1 << 19;
//CPTableViewDraggingDestinationFeedbackStyles
CPTableViewDraggingDestinationFeedbackStyleNone = -1;
CPTableViewDraggingDestinationFeedbackStyleRegular = 0;
CPTableViewDraggingDestinationFeedbackStyleNone = -1,
CPTableViewDraggingDestinationFeedbackStyleRegular = 0,
CPTableViewDraggingDestinationFeedbackStyleSourceList = 1;
//CPTableViewDropOperations
CPTableViewDropOn = 0;
CPTableViewDropOn = 0,
CPTableViewDropAbove = 1;
// TODO: add docs
CPTableViewSelectionHighlightStyleNone = -1;
CPTableViewSelectionHighlightStyleRegular = 0;
CPTableViewSelectionHighlightStyleNone = -1,
CPTableViewSelectionHighlightStyleRegular = 0,
CPTableViewSelectionHighlightStyleSourceList = 1;
CPTableViewGridNone = 0;
CPTableViewSolidVerticalGridLineMask = 1 << 0;
CPTableViewSolidHorizontalGridLineMask = 1 << 1;
CPTableViewNoColumnAutoresizing = 0;
CPTableViewUniformColumnAutoresizingStyle = 1;
CPTableViewSequentialColumnAutoresizingStyle = 2;
CPTableViewReverseSequentialColumnAutoresizingStyle = 3;
CPTableViewLastColumnOnlyAutoresizingStyle = 4;
CPTableViewNoColumnAutoresizing = 0,
CPTableViewUniformColumnAutoresizingStyle = 1,
CPTableViewSequentialColumnAutoresizingStyle = 2,
CPTableViewReverseSequentialColumnAutoresizingStyle = 3,
CPTableViewLastColumnOnlyAutoresizingStyle = 4,
CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
@@ -261,14 +261,14 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
[_headerView setTableView:self];
_cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))];
_lastSelectedRow = -1;
_selectedColumnIndexes = [CPIndexSet indexSet];
_selectedRowIndexes = [CPIndexSet indexSet];
_currentHighlightedTableColumn = nil;
_sortDescriptors = [CPArray array];
_draggedRowIndexes = [CPIndexSet indexSet];
_verticalMotionCanDrag = YES;
_isSelectingSession = NO;
@@ -276,6 +276,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
_retargetedDropOperation = nil;
_dragOperationDefaultMask = nil;
_destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular;
_dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()];
[self addSubview:_dropOperationFeedbackView];
[_dropOperationFeedbackView setHidden:YES];
[_dropOperationFeedbackView setTableView:self];
_tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self];
[_tableDrawView setBackgroundColor:[CPColor clearColor]];
@@ -290,9 +294,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
// FIX ME: we have a lot of redundent init stuff in initWithFrame: and initWithCoder: we should move it all into here.
- (void)_init
{
_dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()];
[_dropOperationFeedbackView setTableView:self];
_lastColumnShouldSnap = NO;
_backgroundColor = [CPColor whiteColor];
@@ -806,7 +807,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
{
var rowIndex = deselectRows[count];
var view = dataViewsInTableColumn[rowIndex];
[view unsetThemeState:CPThemeStateSelected];
[view unsetThemeState:CPThemeStateHighlighted];
}
count = selectRows.length;
@@ -814,7 +815,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
{
var rowIndex = selectRows[count];
var view = dataViewsInTableColumn[rowIndex];
[view setThemeState:CPThemeStateSelected];
[view setThemeState:CPThemeStateHighlighted];
}
}
}
@@ -846,13 +847,13 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
{
var rowIndex = selectRows[i],
dataView = dataViewsInTableColumn[rowIndex];
[dataView unsetThemeState:CPThemeStateSelected];
[dataView unsetThemeState:CPThemeStateHighlighted];
}
if (_headerView)
{
var headerView = [_tableColumns[columnIndex] headerView];
[headerView unsetThemeState:CPThemeStateSelected];
[headerView unsetThemeState:CPThemeStateHighlighted];
}
}
@@ -867,21 +868,16 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
{
var rowIndex = selectRows[i],
dataView = dataViewsInTableColumn[rowIndex];
[dataView setThemeState:CPThemeStateSelected];
[dataView setThemeState:CPThemeStateHighlighted];
}
if (_headerView)
{
var headerView = [_tableColumns[columnIndex] headerView];
[headerView setThemeState:CPThemeStateSelected];
[headerView setThemeState:CPThemeStateHighlighted];
}
}
}
- (int)selectedColumn
{
[_selectedColumnIndexes lastIndex];
}
- (CPIndexSet)selectedColumnIndexes
{
return _selectedColumnIndexes;
@@ -1742,10 +1738,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (_headerView)
{
if (_currentHighlightedTableColumn != nil)
[[_currentHighlightedTableColumn headerView] unsetThemeState:CPThemeStateSelected];
[[_currentHighlightedTableColumn headerView] unsetThemeState:CPThemeStateHighlighted];
if (aTableColumn != nil)
[[aTableColumn headerView] setThemeState:CPThemeStateSelected];
[[aTableColumn headerView] setThemeState:CPThemeStateHighlighted];
}
_currentHighlightedTableColumn = aTableColumn;
@@ -1761,18 +1757,25 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
return YES;
}
- (CPImage)dragImageForRowsWithIndexes:(CPIndexSet)dragRows tableColumns:(CPArray)theTableColumns event:(CPEvent)dragEvent offset:(CPPointPointer)dragImageOffset
- (CPImage)dragImageForRowsWithIndexes:(CPIndexSet)dragRows
tableColumns:(CPArray)theTableColumns
event:(CPEvent)dragEvent
offset:(CPPointPointer)dragImageOffset
{
return [[CPImage alloc] initWithContentsOfFile:@"Frameworks/AppKit/Resources/GenericFile.png" size:CGSizeMake(32,32)];
}
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows tableColumns:(CPArray)theTableColumns event:(CPEvent)theDragEvent offset:(CPPoint)dragViewOffset
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows
tableColumns:(CPArray)theTableColumns
event:(CPEvent)theDragEvent
offset:(CPPoint)dragViewOffset
{
var bounds = [self bounds],
view = [[CPView alloc] initWithFrame:bounds];
[view setBackgroundColor:[CPColor clearColor]];
[view setAlphaValue:0.7];
// We have to fetch all the data views for the selected rows and columns
// After that we can copy these add them to a transparent drag view and use that drag view
// to make it appear we are dragging images of those rows (as you would do in regular Cocoa)
@@ -1782,34 +1785,35 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
exposedRowsLength = [_exposedRows lastIndex] - firstExposedRow + 1,
columns = [],
rows = [];
[_exposedColumns getIndexes:columns maxCount:-1 inIndexRange:CPMakeRange(firstExposedColumn, exposedColumnsLength)];
[theDraggedRows getIndexes:rows maxCount:-1 inIndexRange:CPMakeRange(firstExposedRow, exposedRowsLength)];
var columnIndex = [columns count];
while (columnIndex--)
{
var column = columns[columnIndex],
tableColumn = [_tableColumns objectAtIndex:column],
rowIndex = [rows count];
while (rowIndex--)
{
var row = rows[rowIndex];
var dataView = [self _newDataViewForRow:row tableColumn:tableColumn];
[dataView setBackgroundColor:[CPColor clearColor]];
[dataView setFrame:[self frameOfDataViewAtColumn:column row:row]];
[dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]];
[view addSubview:dataView];
}
}
var dragPoint = [self convertPoint:[theDragEvent locationInWindow] fromView:nil];
dragViewOffset.x = CGRectGetWidth(bounds)/2 - dragPoint.x;
dragViewOffset.y = CGRectGetHeight(bounds)/2 - dragPoint.y;
return view;
}
@@ -1831,7 +1835,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
var numberOfRows = [self numberOfRows] + 1;
var reason = @"Attempt to set dropRow=" + row +
" dropOperation=CPTableViewDropOn when [0 - " + numberOfRows + "] is valid range of rows."
[[CPException exceptionWithName:@"Error" reason:reason userInfo:nil] raise];
}
@@ -1887,7 +1891,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
return;
_sortDescriptors = newSortDescriptors;
[self _sendDataSourceSortDescriptorsDidChange:oldSortDescriptors];
}
@@ -1987,7 +1991,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
// Now clear all the leftovers
// FIXME: this could be faster!
for (var identifier in _cachedDataViews)
for (identifier in _cachedDataViews)
{
var dataViews = _cachedDataViews[identifier],
count = dataViews.length;
@@ -2074,9 +2078,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
[dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]];
if (isColumnSelected || [self isRowSelected:row])
[dataView setThemeState:CPThemeStateSelected];
[dataView setThemeState:CPThemeStateHighlighted];
else
[dataView unsetThemeState:CPThemeStateSelected];
[dataView unsetThemeState:CPThemeStateHighlighted];
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_willDisplayView_forTableColumn_row_)
[_delegate tableView:self willDisplayView:dataView forTableColumn:tableColumn row:row];
@@ -2145,12 +2149,12 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
}
}
- (void)_commitDataViewObjectValue:(id)sender
- (void)_commitDataViewObjectValue:(CPTextView)sender
{
[_dataSource tableView:self setObjectValue:[sender objectValue] forTableColumn:sender.tableViewEditedColumnObj row:sender.tableViewEditedRowIndex];
if ([sender respondsToSelector:@selector(setEditable:)])
[sender setEditable:NO];
[_dataSource tableView:self
setObjectValue:[sender objectValue]
forTableColumn:sender.tableViewEditedColumnObj
row:sender.tableViewEditedRowIndex];
}
- (CPView)_newDataViewForRow:(CPInteger)aRow tableColumn:(CPTableColumn)aTableColumn
@@ -2756,7 +2760,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/
- (void)draggingExited:(id)sender
{
[_dropOperationFeedbackView removeFromSuperview];
[_dropOperationFeedbackView setHidden:YES];
}
/*
@@ -2772,7 +2776,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
_retargetedDropOperation = nil;
_retargetedDropRow = nil;
_draggedRowIndexes = [CPIndexSet indexSet];
[_dropOperationFeedbackView removeFromSuperview];
[_dropOperationFeedbackView setHidden:YES];
}
/*
@ignore
@@ -2905,7 +2909,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
{
// FIX ME: is there anything else that needs to happen here?
// actual validation is called in dragginUpdated:
[_dropOperationFeedbackView removeFromSuperview];
[_dropOperationFeedbackView setHidden:YES];
return (_implementedDataSourceMethods & CPTableViewDataSource_tableView_validateDrop_proposedRow_proposedDropOperation_);
}
@@ -3181,7 +3185,6 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
CPTableViewGridColorKey = @"CPTableViewGridColorKey",
CPTableViewGridStyleMaskKey = @"CPTableViewGridStyleMaskKey",
CPTableViewUsesAlternatingBackgroundKey = @"CPTableViewUsesAlternatingBackgroundKey",
CPTableViewAlternatingRowColorsKey = @"CPTableViewAlternatingRowColorsKey",
CPTableViewHeaderViewKey = @"CPTableViewHeaderViewKey",
CPTableViewCornerViewKey = @"CPTableViewCornerViewKey";
@@ -3231,9 +3234,6 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
_gridColor = [aCoder decodeObjectForKey:CPTableViewGridColorKey] || [CPColor grayColor];
_gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone;
_alternatingRowBackgroundColors = [aCoder decodeObjectForKey:CPTableViewAlternatingRowColorsKey];
_usesAlternatingRowBackgroundColors = [aCoder decodeObjectForKey:CPTableViewUsesAlternatingBackgroundKey]
_headerView = [aCoder decodeObjectForKey:CPTableViewHeaderViewKey];
_cornerView = [aCoder decodeObjectForKey:CPTableViewCornerViewKey];
@@ -3277,7 +3277,6 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
[aCoder encodeInt:_gridStyleMask forKey:CPTableViewGridStyleMaskKey];
[aCoder encodeBool:_usesAlternatingRowBackgroundColors forKey:CPTableViewUsesAlternatingBackgroundKey];
[aCoder encodeObject:_alternatingRowBackgroundColors forKey:CPTableViewAlternatingRowColorsKey]
[aCoder encodeObject:_cornerView forKey:CPTableViewCornerViewKey];
[aCoder encodeObject:_headerView forKey:CPTableViewHeaderViewKey];
+3 -3
View File
@@ -813,7 +813,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (![CPPlatform isBrowser])
{
[self copy:sender];
[self deleteBackward:sender];
[self deleteBackwards:sender];
}
}
@@ -826,7 +826,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (![[pasteboard types] containsObject:CPStringPboardType])
return;
[self deleteBackward:sender];
[self deleteBackwards:sender];
var selectedRange = [self selectedRange],
stringValue = [self stringValue],
@@ -912,7 +912,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[self selectText:sender];
}
- (void)deleteBackward:(id)sender
- (void)deleteBackwards:(id)sender
{
var selectedRange = [self selectedRange],
stringValue = [self stringValue],
+1 -1
View File
@@ -668,7 +668,7 @@ var CPViewFlags = { },
return _tag;
}
- (CPView)viewWithTag:(CPInteger)aTag
- (void)viewWithTag:(CPInteger)aTag
{
if ([self tag] == aTag)
return self;
+7 -5
View File
@@ -1497,8 +1497,7 @@ CPTexturedBackgroundWindowMask
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
if (CPApp._keyWindow === self)
CPApp._keyWindow = nil;
CPApp._keyWindow = nil;
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidResignKeyNotification
@@ -1859,8 +1858,7 @@ CPTexturedBackgroundWindowMask
postNotificationName:CPWindowDidResignMainNotification
object:self];
if (CPApp._mainWindow === self)
CPApp._mainWindow = nil;
CPApp._mainWindow = nil;
}
- (void)_updateMainAndKeyWindows
@@ -1868,6 +1866,9 @@ CPTexturedBackgroundWindowMask
var allWindows = [CPApp orderedWindows],
windowCount = [allWindows count];
if (!windowCount)
return;
if ([self isKeyWindow])
{
var keyWindow = [CPApp keyWindow];
@@ -1892,10 +1893,11 @@ CPTexturedBackgroundWindowMask
}
if (![CPApp keyWindow])
[menuWindow makeKeyWindow];
[keyWindow makeKeyWindow];
}
}
if ([self isMainWindow])
{
var mainWindow = [CPApp mainWindow];
+19
View File
@@ -322,6 +322,25 @@
return _documents;
}
- (void)setViewController:(CPViewController)aViewController
{
var containerView = [self viewControllerContainerView] || [[self window] contentView],
view = [_viewController view],
frame = view ? [view frame] : [containerView bounds];
[view removeFromSuperview];
_viewController = aViewController;
view = [_viewController view];
if (view)
{
[view setFrame:frame];
[containerView addSubview:view];
}
}
- (void)setViewControllerContainerView:(CPView)aView
{
_viewControllerContainerView = aView;
+1 -6
View File
@@ -171,17 +171,12 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
{
// FIXME: Why aren't we getting connection:didFailWithError:
if (!data)
return [self connection:aConnection didFailWithError:nil];
_data = [CPData dataWithRawString:data];
}
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
{
if ([_loadDelegate respondsToSelector:@selector(cibDidFailToLoad:)])
[_loadDelegate cibDidFailToLoad:self];
alert("cib: connection failed.");
_loadDelegate = nil;
}
-5
View File
@@ -118,9 +118,4 @@ var CPCibOwner = @"CPCibOwner";
[_loadDelegate cibDidFinishLoading:aCib];
}
- (void)cibDidFailToLoad:(CPCib)aCib
{
[_loadDelegate cibDidFailToLoad:aCib];
}
@end
+2 -1
View File
@@ -777,7 +777,8 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
@ignore
*/
+ (void)runLoopUpdateLayers
{
{if (window.oops) {alert(window.latest); objj_debug_print_backtrace();}
window.loop = true;
for (UID in CALayerRegisteredRunLoopUpdates)
{
var layer = CALayerRegisteredRunLoopUpdates[UID],
+1 -1
View File
@@ -210,7 +210,7 @@ function CGPathAddQuadCurveToPoint(aPath, aTransform, cpx, cpy, x, y)
if (aTransform)
{
cp = _CGPointApplyAffineTransform(cp, aTransform);
cp = _CGPointApplyAffineTransform(control, aTransform);
end = _CGPointApplyAffineTransform(end, aTransform);
}
+1 -1
View File
@@ -20,7 +20,7 @@ appKitTask = framework ("AppKit", function(appKitTask)
appKitTask.setEmail("feedback @nospam@ 280north.com");
appKitTask.setSummary("AppKit classes for Cappuccino");
appKitTask.setIdentifier("com.280n.AppKit");
appKitTask.setVersion(getCappuccinoVersion());
appKitTask.setVersion("0.8.0");
appKitTask.setLicense(BundleTask.License.LGPL_v2_1);
appKitTask.setSources(AppKitFiles);
appKitTask.setResources(new FileList("Resources/**/*"));
+3 -4
View File
@@ -40,10 +40,6 @@ var screenNeedsInitialization = NO,
return;
screenNeedsInitialization = [CPPlatform isBrowser];
// We do this here because doing it later breaks IE.
if (document.documentElement)
document.documentElement.style.overflow = "hidden";
}
+ (BOOL)isBrowser
@@ -125,6 +121,9 @@ var screenNeedsInitialization = NO,
bodyElement.style.overflow = "hidden";
if (document.documentElement)
document.documentElement.style.overflow = "hidden";
[[CPNotificationCenter defaultCenter]
postNotificationName:CPPlatformDidClearBodyElementNotification
object:self];
+35 -58
View File
@@ -22,10 +22,9 @@
#include "../CoreGraphics/CGGeometry.h"
var DOMFixedWidthSpanElement = nil,
DOMFlexibleWidthSpanElement = nil,
DOMIFrameElement = nil,
DefaultFont = nil;
var DOMSpanElement = nil,
DOMIFrameElement = nil,
DefaultFont = nil;
@implementation CPPlatformString : CPBasePlatformString
{
@@ -38,30 +37,25 @@ var DOMFixedWidthSpanElement = nil,
+ (void)createDOMElements
{
var style;
DOMIFrameElement = document.createElement("iframe");
// necessary for Safari caching bug:
DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000);
DOMIFrameElement.style.position = "absolute";
DOMIFrameElement.style.left = "-100px";
DOMIFrameElement.style.top = "-100px";
DOMIFrameElement.style.width = "1px";
DOMIFrameElement.style.height = "1px";
DOMIFrameElement.style.borderWidth = "0px";
DOMIFrameElement.style.overflow = "hidden";
DOMIFrameElement.style.zIndex = 100000000000;
DOMIFrameElement.className = "cpdontremove";
style = DOMIFrameElement.style;
style.position = "absolute";
style.left = "-100px";
style.top = "-100px";
style.width = "1px";
style.height = "1px";
style.borderWidth = "0px";
style.overflow = "hidden";
style.zIndex = 100000000000;
var bodyElement = [CPPlatform mainBodyElement];
bodyElement.appendChild(DOMIFrameElement);
var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document);
DOMIFrameDocument.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head></head><body></body></html>');
DOMIFrameDocument.write("<html><head></head><body></body></html>");
DOMIFrameDocument.close();
// IE needs this wide <div> to prevent unwanted text wrapping:
@@ -71,39 +65,14 @@ var DOMFixedWidthSpanElement = nil,
DOMIFrameDocument.body.appendChild(DOMDivElement);
DOMFlexibleWidthSpanElement = DOMIFrameDocument.createElement("span");
style = DOMFlexibleWidthSpanElement.style;
style.position = "absolute";
style.visibility = "visible";
style.padding = "0px";
style.margin = "0px";
style.whiteSpace = "pre";
DOMSpanElement = DOMIFrameDocument.createElement("span");
DOMSpanElement.style.position = "absolute";
DOMSpanElement.style.whiteSpace = "pre";
DOMSpanElement.style.visibility = "visible";
DOMSpanElement.style.padding = "0px";
DOMSpanElement.style.margin = "0px";
DOMFixedWidthSpanElement = DOMIFrameDocument.createElement("span");
style = DOMFixedWidthSpanElement.style;
style.display = "block";
style.position = "absolute";
style.visibility = "visible";
style.padding = "0px";
style.margin = "0px";
style.width = "1px";
style.wordWrap = "break-word";
try
{
style.whiteSpace = "pre";
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
}
catch(e)
{
//some versions of IE throw exceptions for unsupported properties.
style.whiteSpace = "pre";
}
DOMDivElement.appendChild(DOMFlexibleWidthSpanElement);
DOMDivElement.appendChild(DOMFixedWidthSpanElement);
DOMDivElement.appendChild(DOMSpanElement);
}
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
@@ -119,23 +88,31 @@ var DOMFixedWidthSpanElement = nil,
if (!DOMIFrameElement)
[self createDOMElements];
var span;
var style = DOMSpanElement.style;
if (!aWidth)
span = DOMFlexibleWidthSpanElement;
{
style.width = "";
style.whiteSpace = "pre";
}
else
{
span = DOMFixedWidthSpanElement;
span.style.width = ROUND(aWidth) + "px";
style.width = ROUND(aWidth) + "px";
style.wordWrap = "break-word";
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
}
span.style.font = [aFont cssString];
style.font = [aFont cssString];
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
span.innerText = aString;
DOMSpanElement.innerText = aString;
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
span.textContent = aString;
DOMSpanElement.textContent = aString;
return _CGSizeMake(span.clientWidth, span.clientHeight);
return _CGSizeMake(DOMSpanElement.clientWidth, DOMSpanElement.clientHeight);
}
@end
+2 -1
View File
@@ -789,6 +789,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
}
}
- (void)_checkPasteboardElement
{
var value = _DOMPasteboardElement.value;
@@ -1104,7 +1105,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
- (CPArray)orderedWindowsAtLevel:(int)aLevel
(CPArray)orderedWindowsAtLevel:(int)aLevel
{
var layer = [self layerAtLevel:aLevel create:NO];
+1 -1
View File
@@ -10,7 +10,7 @@ blendKitTask = framework ("BlendKit", function(blendKitTask)
blendKitTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
blendKitTask.setIdentifier("com.280n.BlendKit");
blendKitTask.setVersion(getCappuccinoVersion());
blendKitTask.setVersion("0.8.0");
blendKitTask.setAuthor("280 North, Inc.");
blendKitTask.setEmail("feedback @nospam@ 280north.com");
blendKitTask.setSummary("BlendKit classes for Cappuccino");
+8 -20
View File
@@ -5,18 +5,13 @@
{
}
- (void)_init
{
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 23.0))]];
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
[self _init];
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 23.0))]];
}
return self;
}
@@ -25,23 +20,16 @@
var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"dce0e2"]);
var points = [
var points = [
CGPointMake(aRect.origin.x, aRect.origin.y),
CGPointMake(aRect.origin.x + aRect.size.width, aRect.origin.y),
CGPointMake(aRect.origin.x, aRect.origin.y + 0.5),
CGPointMake(aRect.origin.x, aRect.origin.y + aRect.size.height)
];
CGContextStrokeLineSegments(context, points, 2);
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
{
[self _init];
}
return self;
}
@end
+38 -25
View File
@@ -332,8 +332,7 @@ var HORIZONTAL_MARGIN = 3.0,
hasDOMTextElement = !!_DOMTextElement;
// Create or destroy the DOM Text Element as necessary
if (needsDOMTextElement !== hasDOMTextElement)
{
if (needsDOMTextElement !== hasDOMTextElement)
if (hasDOMTextElement)
{
_DOMElement.removeChild(_DOMTextElement);
@@ -362,7 +361,6 @@ var HORIZONTAL_MARGIN = 3.0,
// We have to set all these values now.
_flags |= _CPImageAndTextViewTextChangedFlag | _CPImageAndTextViewFontChangedFlag | _CPImageAndTextViewLineBreakModeChangedFlag;
}
}
var textStyle = hasDOMTextElement ? _DOMTextElement.style : nil;
@@ -371,7 +369,6 @@ var HORIZONTAL_MARGIN = 3.0,
hasDOMTextShadowElement = !!_DOMTextShadowElement;
if (needsDOMTextShadowElement !== hasDOMTextShadowElement)
{
if (hasDOMTextShadowElement)
{
_DOMElement.removeChild(_DOMTextShadowElement);
@@ -389,7 +386,6 @@ var HORIZONTAL_MARGIN = 3.0,
shadowStyle.font = [_font ? _font : [CPFont systemFontOfSize:12.0] cssString];
shadowStyle.position = "absolute";
shadowStyle.whiteSpace = textStyle.whiteSpace;
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.color = [_textShadowColor cssString];
shadowStyle.zIndex = 150;
@@ -398,6 +394,7 @@ var HORIZONTAL_MARGIN = 3.0,
if (document.attachEvent)
{
shadowStyle.overflow = textStyle.overflow;
shadowStyle.wordWrap = textStyle.wordWrap;
}
else
{
@@ -411,7 +408,6 @@ var HORIZONTAL_MARGIN = 3.0,
_flags |= _CPImageAndTextViewTextChangedFlag; //sigh...
}
}
var shadowStyle = hasDOMTextShadowElement ? _DOMTextShadowElement.style : nil;
@@ -451,7 +447,9 @@ var HORIZONTAL_MARGIN = 3.0,
case CPLineBreakByClipping: textStyle.overflow = "hidden";
textStyle.textOverflow = "clip";
textStyle.whiteSpace = "pre";
textStyle.wordWrap = "normal";
if (document.attachEvent)
textStyle.wordWrap = "normal";
break;
@@ -461,23 +459,26 @@ var HORIZONTAL_MARGIN = 3.0,
case CPLineBreakByTruncatingTail: textStyle.textOverflow = "ellipsis";
textStyle.whiteSpace = "nowrap";
textStyle.overflow = "hidden";
textStyle.wordWrap = "normal";
if (document.attachEvent)
textStyle.wordWrap = "normal";
break;
case CPLineBreakByCharWrapping:
case CPLineBreakByWordWrapping: textStyle.wordWrap = "break-word";
try {
case CPLineBreakByWordWrapping: if (document.attachEvent)
{
textStyle.whiteSpace = "pre";
textStyle.wordWrap = "break-word";
}
else
{
textStyle.whiteSpace = "-o-pre-wrap";
textStyle.whiteSpace = "-pre-wrap";
textStyle.whiteSpace = "-moz-pre-wrap";
textStyle.whiteSpace = "pre-wrap";
}
catch (e) {
//internet explorer doesn't like these properties
textStyle.whiteSpace = "pre";
}
textStyle.overflow = "hidden";
textStyle.textOverflow = "clip";
@@ -489,6 +490,7 @@ var HORIZONTAL_MARGIN = 3.0,
{
if (document.attachEvent)
{
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.overflow = textStyle.overflow;
}
else
@@ -497,7 +499,6 @@ var HORIZONTAL_MARGIN = 3.0,
shadowStyle.overflowY = textStyle.overflowY;
}
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.whiteSpace = textStyle.whiteSpace;
shadowStyle.textOverflow = textStyle.textOverflow;
}
@@ -509,7 +510,6 @@ var HORIZONTAL_MARGIN = 3.0,
// Create or destroy DOM Image element
if (needsDOMImageElement !== hasDOMImageElement)
{
if (hasDOMImageElement)
{
_DOMElement.removeChild(_DOMImageElement);
@@ -539,8 +539,8 @@ var HORIZONTAL_MARGIN = 3.0,
_DOMElement.appendChild(_DOMImageElement);
hasDOMImageElement = YES;
}
}
}
#endif
var size = [self bounds].size,
textRect = _CGRectMake(0.0, 0.0, size.width, size.height);
@@ -572,54 +572,67 @@ var HORIZONTAL_MARGIN = 3.0,
imageHeight *= scale;
}
#if PLATFORM(DOM)
_DOMImageElement.width = imageWidth;
_DOMImageElement.height = imageHeight;
imageStyle.width = MAX(imageWidth, 0) + "px";
imageStyle.height = MAX(imageHeight, 0) + "px";
imageStyle.width = imageWidth + "px";
imageStyle.height = imageHeight + "px";
#endif
if (_imagePosition === CPImageBelow)
{
#if PLATFORM(DOM)
imageStyle.left = FLOOR(centerX - imageWidth / 2.0) + "px";
imageStyle.top = FLOOR(size.height - imageHeight) + "px";
#endif
textRect.size.height = size.height - imageHeight - VERTICAL_MARGIN;
}
else if (_imagePosition === CPImageAbove)
{
#if PLATFORM(DOM)
CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, FLOOR(centerX - imageWidth / 2.0), 0);
#endif
textRect.origin.y += imageHeight + VERTICAL_MARGIN;
textRect.size.height = size.height - imageHeight - VERTICAL_MARGIN;
}
else if (_imagePosition === CPImageLeft)
{
#if PLATFORM(DOM)
imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px";
imageStyle.left = "0px";
#endif
textRect.origin.x = imageWidth + HORIZONTAL_MARGIN;
textRect.size.width -= imageWidth + HORIZONTAL_MARGIN;
}
else if (_imagePosition === CPImageRight)
{
#if PLATFORM(DOM)
imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px";
imageStyle.left = FLOOR(size.width - imageWidth) + "px";
#endif
textRect.size.width -= imageWidth + HORIZONTAL_MARGIN;
}
else if (_imagePosition === CPImageOnly)
{
#if PLATFORM(DOM)
imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px";
imageStyle.left = FLOOR(centerX - imageWidth / 2.0) + "px";
#endif
}
}
#if PLATFORM(DOM)
if (hasDOMTextElement)
{
var textRectX = _CGRectGetMinX(textRect),
textRectY = _CGRectGetMinY(textRect),
textRectWidth = _CGRectGetWidth(textRect),
textRectHeight = _CGRectGetHeight(textRect);
if (_verticalAlignment !== CPTopVerticalTextAlignment)
{
if (!_textSize)
@@ -646,8 +659,8 @@ var HORIZONTAL_MARGIN = 3.0,
textStyle.top = ROUND(textRectY) + "px";
textStyle.left = ROUND(textRectX) + "px";
textStyle.width = MAX(ROUND(textRectWidth), 0) + "px";
textStyle.height = MAX(ROUND(textRectHeight), 0) + "px";
textStyle.width = ROUND(textRectWidth) + "px";
textStyle.height = ROUND(textRectHeight) + "px";
if (shadowStyle)
{
@@ -656,8 +669,8 @@ var HORIZONTAL_MARGIN = 3.0,
shadowStyle.top = ROUND(textRectY + _textShadowOffset.height) + "px";
shadowStyle.left = ROUND(textRectX + _textShadowOffset.width) + "px";
shadowStyle.width = MAX(ROUND(textRectWidth), 0) + "px";
shadowStyle.height = MAX(ROUND(textRectHeight), 0) + "px";
shadowStyle.width = ROUND(textRectWidth) + "px";
shadowStyle.height = ROUND(textRectHeight) + "px";
}
}
#endif
+1 -5
View File
@@ -8,7 +8,7 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
if (!FILE.isFile(aFilename))
return;
var buildFilename = FILE.join($BUILD_CJS_CAPPUCCINO, aFilename);
var buildFilename = FILE.join($BUILD_CONFIGURATION_DIR, "CommonJS", "cappuccino", aFilename);
filedir (buildFilename, [aFilename], function ()
{
@@ -27,7 +27,3 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
task ("build", buildFilename);
CLOBBER.include(buildFilename);
});
task ("build", function() {
setPackageMetadata(FILE.join($BUILD_CJS_CAPPUCCINO, "package.json"));
});
+106 -203
View File
@@ -8,7 +8,6 @@ require("narwhal").ensureEngine("rhino");
var FILE = require("file");
var OS = require("os");
var UTIL = require("util");
var stream = require("term").stream;
var parser = new (require("args").Parser)();
@@ -25,10 +24,6 @@ parser.option("-F", "--framework", "frameworks")
.push()
.help("Add a frameworks directory, relative to INPUT_PROJECT (default: ['Frameworks'])");
parser.option("-P", "--path", "paths")
.push()
.help("Add a path (relative to the application root) to inline.");
parser.option("-f", "--force", "force")
.def(false)
.set(true)
@@ -39,16 +34,6 @@ parser.option("--index", "index")
.set()
.help("The root HTML file to modify (default: index.html)");
parser.option("-s", "--split", "number", "split")
.natural()
.def(0)
.help("Split into multiple files");
parser.option("-c", "--compressor", "compressor")
.def("shrinksafe")
.set()
.help("Select a compressor to use (closure-compiler, yuicompressor, shrinksafe), or \"none\" (default: shrinksafe)");
parser.option("-v", "--verbose", "verbose")
.def(false)
.set(true)
@@ -96,34 +81,32 @@ function main(args)
var flattener = new ObjectiveJFlattener(rootPath);
flattener.options = options;
flattener.setIncludePaths(frameworks);
flattener.setEnvironments([environment, "ObjJ"]);
print("Loading application.");
flattener.load(mainPath);
flattener.finishLoading();
print("Loading default theme.");
flattener.require("objective-j").objj_eval("("+(function() {
var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:[CPApplication defaultThemeName] + ".blend"]];
[blend loadWithDelegate:nil];
})+")")();
var rootResources = flattener.require("objective-j").StaticResource.rootResources();
var applicationJSs = flattener.buildApplicationJS();
var root = rootResources["file:"];
// FIXME: shouldn't have to do this manually
var components = rootPath.split("/").slice(0, -1);
components[0] = "/";
var node = root;
while (components.length) {
node = node.children()[components.shift()];
}
applicationRoot = node;
print(applicationRoot.toString());
var applicationJS = flattener.buildApplicationJS(applicationRoot);
FILE.copyTree(rootPath, outputPath);
applicationJSs.forEach(function(applicationJS, n) {
var name = "Application"+(n||"")+".js";
if (options.compressor === "none") {
print("skipping compression: " + name);
} else {
print("compressing: " + name);
applicationJS = require("minify/"+options.compressor).compress(applicationJS, { charset : "UTF-8", useServer : true });
}
outputPath.join(name).write(applicationJS, { charset : "UTF-8" });
});
outputPath.join("Application.js").write(applicationJS);
rewriteMainHTML(outputPath.join(options.index));
}
@@ -132,197 +115,117 @@ function main(args)
function ObjectiveJFlattener(rootPath) {
ObjectiveJRuntimeAnalyzer.apply(this, arguments);
this.filesToCache = {};
this.fileCacheBuffer = [];
this.resourceBuffer = [];
this.bundleBuffer = [];
this.functionsBuffer = [];
this._outputBundles = {};
}
ObjectiveJFlattener.prototype = Object.create(ObjectiveJRuntimeAnalyzer.prototype);
ObjectiveJFlattener.prototype.buildApplicationJS = function() {
ObjectiveJFlattener.prototype.buildApplicationJS = function(applicationRoot) {
this.serializeStaticResources(applicationRoot);
this.serializeStaticFileExecutables();
this.setupFileCache();
this.serializeFunctions();
this.serializeFileCache();
var buffer = []
var additions = FILE.read(FILE.join(FILE.dirname(module.path), "..", "..", "cappuccino", "lib", "cappuccino", "objj-flatten-additions.js"), { charset:"UTF-8" });
buffer.push("(function(){");
var applicationJSs = [];
buffer.push("var appURL = new CFURL('.', ObjectiveJ.pageURL);")
if (this.options.split === 0) {
var buffer = [];
buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
buffer.push(additions);
buffer.push(this.fileCacheBuffer.join("\n"));
buffer.push(this.functionsBuffer.join("\n"));
buffer.push("ObjectiveJ.bootstrap();");
applicationJSs.push(buffer.join("\n"));
buffer.push(this.bundleBuffer.join("\n"));
buffer.push("var nodeStack = [];");
buffer.push("var applicationRoot = ObjectiveJ.StaticResource.resourceAtURL(appURL, true);");
buffer.push("var currentNode = null;");
buffer.push("var newNode;");
buffer.push(this.resourceBuffer.join("\n"));
buffer.push("})();");
buffer.push(this.functionsBuffer.join("\n"));
buffer.push("ObjectiveJ.bootstrap();");
return buffer.join("\n");
}
ObjectiveJFlattener.prototype.serializeStaticFileExecutables = function() {
this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(aFileExecutable) {
var deps = aFileExecutable.fileDependencies().map(function(dependency) {
return "new ObjectiveJ.FileDependency(new CFURL("+JSON.stringify(dependency.path())+"),"+JSON.stringify(dependency.isLocal())+")"
}).join(",");
var func = aFileExecutable._function.toString();
// HACK
func = func.replace(", require, exports, module, system, print, window", "");
this.functionsBuffer.push("var path = "+JSON.stringify(this.rootPath.relative(aFileExecutable.path()).toString())+";");
this.functionsBuffer.push("new ObjectiveJ.FileExecutable(path,"+
"new ObjectiveJ.Executable(null, ["+deps+"], path, "+func+"));");
}, this);
}
ObjectiveJFlattener.prototype.serializeStaticResources = function(node, depth) {
depth = depth || 0;
var bundle = this.context.global.CFBundle.bundleContainingURL(node.URL());
if (!bundle) {
stream.print("\0yellow(Warning:\0) No bundle for path: \0cyan("+node.URL()+"\0)");
}
else if (!this._outputBundles[bundle.path()]) {
this._outputBundles[bundle.path()] = bundle;
stream.print("Writing bundle: \0cyan("+bundle.path()+"\0)");
print(bundle.infoDictionary())
var relative = this.rootPath.relative(bundle.path()).toString();
this.bundleBuffer.push("var bundle = new CFBundle("+(relative ? JSON.stringify(relative) : "appURL")+");");
this.bundleBuffer.push("bundle._loadStatus = " + (1<<4) + ";");
if (bundle.infoDictionary()) {
this.bundleBuffer.push("bundle._infoDictionary = CFPropertyList.propertyListFromString(" +
JSON.stringify(CPPropertyListCreateData(bundle.infoDictionary()).rawString()) + ");");
}
}
// not the root node:
if (depth > 0) {
this.resourceBuffer.push("newNode = new ObjectiveJ.StaticResource(" +
JSON.stringify(node.name()) +
", currentNode, " +
JSON.stringify(node.isDirectory()) + ", " +
JSON.stringify(node.isResolved()) + ");");
} else {
var appFilesCount = this.options.split;
var buffers = [];
for (var i = 0; i <= appFilesCount; i++)
buffers.push([]);
var chunks = this.fileCacheBuffer.concat(this.functionsBuffer).sort(function(chunkA, chunkB) {
return chunkA.length - chunkB.length;
});
// try to equally distribute the chunks. could be better but good enough for now.
var n = 0;
while (chunks.length) {
buffers[(n++ % appFilesCount) + 1].push(chunks.pop());
}
buffers[0].push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
buffers[0].push(additions);
buffers[0].push("var appFilesCount = " + appFilesCount +";");
buffers[0].push("for (var i = 1; i <= appFilesCount; i++) {");
buffers[0].push(" var script = document.createElement(\"script\");");
buffers[0].push(" script.src = \"Application\"+i+\".js\";");
buffers[0].push(" script.charset = \"UTF-8\";");
buffers[0].push(" script.onload = function() { if (--appFilesCount === 0) ObjectiveJ.bootstrap(); };");
buffers[0].push(" document.getElementsByTagName(\"head\")[0].appendChild(script);");
buffers[0].push("}");
buffers.forEach(function(buffer) {
applicationJSs.push(buffer.join("\n"));
});
this.resourceBuffer.push("newNode = applicationRoot;");
}
return applicationJSs;
}
// var contents = node.contents();
// if (contents) {
// this.resourceBuffer.push("newNode._contents = " + JSON.stringify(contents) + ";");
// }
ObjectiveJFlattener.prototype.serializeFunctions = function() {
var inlineFunctions = true;//this.options.inlineFunctions;
if (!node.children())
return;
var outputFiles = {};
this.resourceBuffer.push("nodeStack.push(currentNode);");
this.resourceBuffer.push("currentNode = newNode;");
var _cachedExecutableFunctions = {};
this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(executable) {
var path = executable.path();
if (inlineFunctions)
{
// stringify the function, replacing arguments
var functionString = executable._function.toString().replace(", require, exports, module, system, print, window", ""); // HACK
var relative = this.rootPath.relative(path).toString();
this.functionsBuffer.push("ObjectiveJ.FileExecutable._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");");
}
var bundle = this.context.global.CFBundle.bundleContainingURL(path);
if (bundle && bundle.infoDictionary())
{
var executablePath = bundle.executablePath(),
relativeToBundle = FILE.relative(FILE.join(bundle.path(), ""), path);
if (executablePath)
{
if (inlineFunctions)
{
// remove the code since we're inlining the functions
executable._code = "alert("+JSON.stringify(relativeToBundle)+");";
}
if (!outputFiles[executablePath])
{
outputFiles[executablePath] = [];
outputFiles[executablePath].push("@STATIC;1.0;");
}
var fileContents = executable.toMarkedString();
outputFiles[executablePath].push("p;" + relativeToBundle.length + ";" + relativeToBundle);
outputFiles[executablePath].push("t;" + fileContents.length + ";" + fileContents);
// stream.print("Adding \0green(" + this.rootPath.relative(path) + "\0) to \0cyan(" + this.rootPath.relative(executablePath) + "\0)");
}
}
else
CPLog.warn("No bundle (or info dictionary for) " + rootPath.relative(path));
}, this);
for (var executablePath in outputFiles)
{
var relative = this.rootPath.relative(executablePath).toString();
var contents = outputFiles[executablePath].join("");
this.filesToCache[relative] = contents;
var children = node.children();
for (var name in children) {
this.serializeStaticResources(children[name], depth+1);
}
}
ObjectiveJFlattener.prototype.serializeFileCache = function() {
for (var relative in this.filesToCache) {
var contents = this.filesToCache[relative];
print("caching: " + relative + " => " + (contents == null ? 404 : 200));
if (contents == null)
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 404);");
else
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");");
}
}
ObjectiveJFlattener.prototype.setupFileCache = function() {
var paths = {};
UTIL.update(paths, this.requestedURLs);
this.options.paths.forEach(function(relativePath) {
paths[this.rootPath.join(relativePath)] = true;
}, this);
Object.keys(paths).forEach(function(absolute) {
var relative = this.rootPath.relative(absolute).toString();
if (relative.indexOf("..") === 0)
{
print("skipping (parent of app root): " + absolute);
return;
}
if (FILE.isFile(absolute))
{
// if (this.options.maxCachedSize && FILE.size(absolute) > this.options.maxCachedSize)
// {
// print("skipping (larger than "+this.options.maxCachedSize+" bytes): " + absolute);
// return;
// }
var contents = FILE.read(absolute, { charset : "UTF-8" });
this.filesToCache[relative] = contents;
} else {
this.filesToCache[relative] = null;
}
}, this);
this.resourceBuffer.push("currentNode = nodeStack.pop();");
}
// "$1" is the matching indentation
var scriptTagsBefore =
'$1<script type = "text/javascript">\n'+
'$1 OBJJ_AUTO_BOOTSTRAP = false;\n'+
'$1</script>';
var scriptTagsAfter =
'$1<script type="text/javascript" src="Application.js" charset="UTF-8"></script>';
// enable CPLog:
// scriptTagsAfter = '$1<script type="text/javascript">\n$1 CPLogRegister(CPLogConsole);\n$1</script>\n' + scriptTagsAfter;
var scriptTagsBefore = '$1<script type = "text/javascript">\n$1 OBJJ_AUTO_BOOTSTRAP = false;\n$1</script>';
var scriptTagsAfter = '$1<script type = "text/javascript" src = "Application.js"></script>';
function rewriteMainHTML(indexHTMLPath) {
if (indexHTMLPath.isFile()) {
var indexHTML = indexHTMLPath.read({ charset : "UTF-8" });
// inline the Application.js if it's smallish
var applicationJSPath = indexHTMLPath.dirname().join("Application.js");
if (applicationJSPath.size() < 10*1024) {
// escape any dollar signs by replacing them with two
// then indent by splitting/joining on newlines
scriptTagsAfter =
'$1<script type="text/javascript">\n'+
'$1 ' + applicationJSPath.read({ charset : "UTF-8" }).replace(/\$/g, "$$$$").split("\n").join("\n$1 ")+'\n'+
'$1</script>';
}
var indexHTML = indexHTMLPath.read();
// attempt to find Objective-J script tag and add ours
var newIndexHTML = indexHTML.replace(/([ \t]+)<script[^>]+Objective-J\.js[^>]+>(?:\s*<\/script>)?/,
@@ -330,7 +233,7 @@ function rewriteMainHTML(indexHTMLPath) {
if (newIndexHTML !== indexHTML) {
stream.print("\0green(Modified: "+indexHTMLPath+".\0)");
indexHTMLPath.write(newIndexHTML, { charset : "UTF-8" });
indexHTMLPath.write(newIndexHTML);
return;
}
} else {
-23
View File
@@ -1,23 +0,0 @@
var FILE = require("file");
var sprintf = require("printf").sprintf;
var pkg = null;
function getPackage() {
if (!pkg)
pkg = JSON.parse(FILE.path(module.path).dirname().dirname().join("package.json").read({ charset : "UTF-8" }));
return pkg;
}
exports.version = function() { return getPackage()["version"]; }
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
exports.fullVersionString = function() {
return sprintf("cappuccino %s (%04d-%02d-%02d %s)",
exports.version(),
exports.timestamp().getUTCFullYear(),
exports.timestamp().getUTCMonth()+1,
exports.timestamp().getUTCDate(),
exports.revision().slice(0,6)
);
}
@@ -5,8 +5,6 @@ var Context = require("interpreter").Context;
ObjectiveJRuntimeAnalyzer = function(rootPath)
{
this.rootPath = rootPath;
this.rootURL = new CFURL(String(rootPath));
this.context = new Context();
this.scope = setupObjectiveJ(this.context);
@@ -30,19 +28,6 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
var url = this.executableURL();
return url ? url.absoluteURL().path() : null;
}
this.require("cappuccino/objj-flatten-additions");
if (!this.context.global.CFHTTPRequest._lookupCachedRequest)
print("Warning: CFHTTPRequest._lookupCachedRequest. Need to import objj-flatten-additions module.");
var requestedURLs = this.requestedURLs = {};
var _lookupCachedRequest = this.context.global.CFHTTPRequest._lookupCachedRequest;
this.context.global.CFHTTPRequest._lookupCachedRequest = function(aURL) {
var path = new CFURL(aURL, this.rootURL).absoluteURL().path();
requestedURLs[path] = true;
return _lookupCachedRequest.apply(null, arguments);
}
}
ObjectiveJRuntimeAnalyzer.prototype.setIncludePaths = function(includePaths) {
@@ -1,57 +0,0 @@
var URLCache = { };
CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password)
{
var cachedRequest = CFHTTPRequest._lookupCachedRequest(url);
if (cachedRequest)
{
var self = this;
this._nativeRequest = cachedRequest;
this._nativeRequest.onreadystatechange = function()
{
ObjectiveJ.determineAndDispatchHTTPRequestEvents(self);
};
}
return this._nativeRequest.open(method, url, async, user, password);
}
CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body)
{
URLCache[aURL] = new MockXMLHttpRequest(status, headers, body);
}
CFHTTPRequest._lookupCachedRequest = function(/*CFURL|String*/ aURL)
{
return URLCache[aURL];
}
function MockXMLHttpRequest(status, headers, body)
{
this.readyState = CFHTTPRequest.UninitializedState;
this.status = status || 200;
this.statusText = "";
this.responseText = body || "";
this._responseHeaders = headers || {};
};
MockXMLHttpRequest.prototype.open = function(method, url, async, user, password)
{
this.readyState = CFHTTPRequest.LoadingState;
this.async = async;
};
MockXMLHttpRequest.prototype.send = function(body)
{
var self = this;
self.responseText = self.responseText.toString();
function complete() {
for (self.readyState = CFHTTPRequest.LoadedState; self.readyState <= CFHTTPRequest.CompleteState; self.readyState++)
self.onreadystatechange();
}
(self.async ? ObjectiveJ.Asynchronous(complete) : complete)();
};
MockXMLHttpRequest.prototype.onreadystatechange = function() {};
MockXMLHttpRequest.prototype.abort = function() {};
MockXMLHttpRequest.prototype.setRequestHeader = function(header, value) {};
MockXMLHttpRequest.prototype.getAllResponseHeaders = function() { return this._responseHeaders; };
MockXMLHttpRequest.prototype.getResponseHeader = function(header) { return this._responseHeaders[header]; };
MockXMLHttpRequest.prototype.overrideMimeType = function(mimetype) {};
+1
View File
@@ -4,6 +4,7 @@
"description": "Cappuccino module",
"keywords": ["objective-j", "objj", "objective j", "capp", "cappuccino"],
"author": "280 North, Inc. (http://280north.com/)",
"version": "0.8.0",
"objj-frameworks": ["Frameworks"],
"objj-debug-frameworks": ["Frameworks/Debug"],
"contributors": [
-11
View File
@@ -153,12 +153,6 @@
continue;
var value = object[key];
if (value === null)
{
[dictionary setObject:[CPNull null] forKey:key];
continue;
}
if (recursively)
{
@@ -527,11 +521,6 @@
return self.toString();
}
- (BOOL)containsKey:(id)aKey
{
var value = [self objectForKey:aKey];
return ((value !== nil) && (value !== undefined));
}
@end
@implementation CPDictionary (CPCoding)
-3
View File
@@ -739,10 +739,7 @@
shifts = [];
for (; j < count; ++j)
{
[shifts addObject:_ranges[j]];
_count -= _ranges[j].length;
}
if ((j = i + 1) < count)
{
+5 -11
View File
@@ -163,15 +163,9 @@ var CPArrayClass = Ni
@param data the data from which to read the graph
@return the unarchived object
*/
+ (id)unarchiveObjectWithData:(CPData)aData
+ (id)unarchiveObjectWithData:(CPData)data
{
if (!aData)
{
CPLog.error("Null data passed to -[CPKeyedUnarchiver unarchiveObjectWithData:].");
return nil;
}
var unarchiver = [[self alloc] initForReadingWithData:aData],
var unarchiver = [[self alloc] initForReadingWithData:data],
object = [unarchiver decodeObjectForKey:@"root"];
[unarchiver finishDecoding];
@@ -206,7 +200,7 @@ var CPArrayClass = Ni
- (CPDictionary)_decodeDictionaryOfObjectsForKey:(CPString)aKey
{
var object = _plistObject.valueForKey(aKey),
objectClass = (object != nil) && object.isa;
objectClass = object && object.isa;
if (objectClass === CPDictionaryClass || objectClass === CPMutableDictionaryClass)
{
@@ -321,7 +315,7 @@ var CPArrayClass = Ni
- (id)decodeObjectForKey:(CPString)aKey
{
var object = _plistObject.valueForKey(aKey),
objectClass = (object != nil) && object.isa;
objectClass = object && object.isa;
if (objectClass === CPDictionaryClass || objectClass === CPMutableDictionaryClass)
return _CPKeyedUnarchiverDecodeObjectAtIndex(self, object.valueForKey(_CPKeyedArchiverUIDKey));
@@ -525,7 +519,7 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
// If this object is a member of _CPKeyedArchiverValue, then we know
// that it is a wrapper for a primitive JavaScript object.
if ((object != nil) && (object.isa === _CPKeyedArchiverValueClass))
if (object && (object.isa === _CPKeyedArchiverValueClass))
object = [object JSObject];
return object;
+1 -1
View File
@@ -61,7 +61,7 @@
- (void)forwardInvocation:(CPInvocation)anInvocation
{
[CPException raise:CPInvalidArgumentException
reason:@"-forwardInvocation: called on abstract CPProxy class."];
reason:@"-methodSignatureForSelector: called on abstract CPProxy class."];
}
// FIXME: This should be moved to the runtime?
+2 -2
View File
@@ -196,8 +196,8 @@ var CPURLURLStringKey = @"CPURLURLStringKey",
- (id)initWithCoder:(CPCoder)aCoder
{
return [self initWithString:[aCoder decodeObjectForKey:CPURLURLStringKey]
relativeToURL:[aCoder decodeObjectForKey:CPURLBaseURLKey]];
return [self initWithURLString:[aCoder decodeObjectForKey:CPURLURLStringKey]
baseURL:[aCoder decodeObjectForKey:CPURLBaseURLKey]];
}
- (void)encodeWithCoder:(CPCoder)aCoder
+1 -1
View File
@@ -34,7 +34,7 @@ foundationTask = framework ("Foundation", function(foundationTask)
foundationTask.setEmail("feedback @nospam@ 280north.com");
foundationTask.setSummary("Foundation classes for Cappuccino");
foundationTask.setIdentifier("com.280n.Foundation");
foundationTask.setVersion(getCappuccinoVersion());
foundationTask.setVersion("0.8.0");
foundationTask.setLicense(BundleTask.License.LGPL_v2_1);
foundationTask.setSources(new FileList("**/*.j"));
foundationTask.setResources(new FileList("Resources/**/*"));
+20 -32
View File
@@ -247,7 +247,7 @@ task ("demos", function()
// Testing
task("test", ["CommonJS", "test-only"]);
task("test", ["build", "test-only"]);
task("test-only", function()
{
@@ -280,23 +280,21 @@ task("push-objective-j", function() {
function pushPackage(path, remote, branch)
{
branch = branch || "master";
var pushPackagesPath = FILE.path(".push-package");
pushPackagesPath.mkdirs();
var packagePath = pushPackagesPath.join(remote.replace(/[^\w]/g, "_"));
stream.print("Pushing \0blue(" + path + "\0) to "+branch+" of \0blue(" + remote + "\0)");
if (packagePath.isDirectory())
OS.system(buildCmd([["cd", packagePath], ["git", "fetch"]]));
else
OS.system(["git", "clone", remote, packagePath]);
FILE.mkdirs(".push-package");
if (OS.system(buildCmd([["cd", packagePath], ["git", "checkout", "origin/"+branch]]))) {
var pushPackageDir = FILE.join(".push-package", remote.replace(/[^\w]/g, "_"));
if (FILE.exists(pushPackageDir))
OS.system(buildCmd([["cd", pushPackageDir], ["git", "fetch"]]));
else
OS.system(["git", "clone", remote, pushPackageDir]);
if (OS.system(buildCmd([["cd", pushPackageDir], ["git", "checkout", "origin/"+branch]]))) {
if (OS.system(buildCmd([
["cd", packagePath],
["cd", pushPackageDir],
["git", "symbolic-ref", "HEAD", "refs/heads/"+branch],
["rm", ".git/index"],
["git", "clean", "-fdx"]
@@ -304,30 +302,20 @@ function pushPackage(path, remote, branch)
throw "pushPackage failed";
}
if (OS.system("cd "+OS.enquote(packagePath)+" && git rm --ignore-unmatch -r * && rm -rf *"))
if (OS.system("cd "+OS.enquote(pushPackageDir)+" && git rm --ignore-unmatch -r * && rm -rf *"))
throw "pushPackage failed";
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(packagePath)+"/."))
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(pushPackageDir)+"/."))
throw "pushPackage failed";
var pkg = JSON.parse(packagePath.join("package.json").read({ charset : "UTF-8" }));
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
var cmd = [
["cd", packagePath],
OS.system(buildCmd([
["cd", pushPackageDir],
["git", "add", "."],
["git", "commit", "-m", "version="+pkg.version+"; revision="+pkg["cappuccino-revision"]+"; timestamp="+pkg["cappuccino-timestamp"]+";"]
];
if (pkg["cappuccino-revision"])
cmd.push(["git", "tag", "rev-"+pkg["cappuccino-revision"].slice(0,6)]);
OS.system(buildCmd(cmd));
["git", "commit", "-m", "Pushed on " + new Date()]
]));
if (OS.system(buildCmd([
["cd", packagePath],
["git", "push", "--tags", "origin", "HEAD:"+branch]
["cd", pushPackageDir],
["git", "push", "origin", "HEAD:"+branch]
])))
throw "pushPackage failed";
}
+1 -30
View File
@@ -81,36 +81,7 @@ function resolveMainBundleURL()
Executable.fileImporterForURL(mainBundleURL)(mainFileURL.lastPathComponent(), YES, function()
{
disableCFURLCaching();
afterDocumentLoad(function()
{
var hashString = window.location.hash.substring(1),
args = [];
if (hashString.length)
{
args = hashString.split("/");
for (var i = 0, count = args.length; i < count; i++)
args[i] = decodeURIComponent(args[i]);
}
var namedArgsArray = window.location.search.substring(1).split("&"),
namedArgs = new CFMutableDictionary();
for (var i = 0, count = namedArgsArray.length; i < count; i++)
{
var thisArg = namedArgsArray[i].split("=");
if (!thisArg[0])
continue;
if (thisArg[1] == null)
thisArg[1] = true;
namedArgs.setValueForKey(decodeURIComponent(thisArg[0]), decodeURIComponent(thisArg[1]));
}
main(args, namedArgs);
});
afterDocumentLoad(main);
});
});
}
+5 -59
View File
@@ -49,7 +49,6 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
this._resourcesDirectoryURL = new CFURL("Resources/", aURL);
this._staticResource = NULL;
this._isValid = NO;
this._loadStatus = CFBundleUnloaded;
this._loadRequests = [];
@@ -59,47 +58,34 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
this._eventDispatcher = new EventDispatcher(this);
}
DISPLAY_NAME(CFBundle);
CFBundle.environments = function()
{
// Passed in by GCC.
return ENVIRONMENTS;
}
DISPLAY_NAME(CFBundle.environments);
CFBundle.bundleContainingURL = function(/*CFURL|String*/ aURL)
{
aURL = new CFURL(".", makeAbsoluteURL(aURL));
var previousURLString,
URLString = aURL.absoluteString();
while (!previousURLString || previousURLString !== URLString)
while (aURL.path() !== "/")
{
var bundle = CFBundlesForURLStrings[URLString];
var bundle = CFBundlesForURLStrings[aURL.absoluteString()];
if (bundle && bundle._isValid)
if (bundle)
return bundle;
aURL = new CFURL("..", aURL);
previousURLString = URLString;
URLString = aURL.absoluteString();
}
return NULL;
}
DISPLAY_NAME(CFBundle.bundleContainingURL);
CFBundle.mainBundle = function()
{
return new CFBundle(mainBundleURL);
}
DISPLAY_NAME(CFBundle.mainBundle);
function addClassToBundle(aClass, aBundle)
{
if (aBundle)
@@ -111,22 +97,16 @@ CFBundle.bundleForClass = function(/*Class*/ aClass)
return CFBundlesForClasses[aClass.name] || CFBundle.mainBundle();
}
DISPLAY_NAME(CFBundle.bundleForClass);
CFBundle.prototype.bundleURL = function()
{
return this._bundleURL;
}
DISPLAY_NAME(CFBundle.prototype.bundleURL);
CFBundle.prototype.resourcesDirectoryURL = function()
{
return this._resourcesDirectoryURL;
}
DISPLAY_NAME(CFBundle.prototype.resourcesDirectoryURL);
CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ aType, /*String*/ aSubDirectory)
{
if (aType)
@@ -140,8 +120,6 @@ CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ a
return resourceURL.absoluteURL();
}
DISPLAY_NAME(CFBundle.prototype.resourceURL);
CFBundle.prototype.mostEligibleEnvironmentURL = function()
{
if (this._mostEligibleEnvironmentURL === undefined)
@@ -150,8 +128,6 @@ CFBundle.prototype.mostEligibleEnvironmentURL = function()
return this._mostEligibleEnvironmentURL;
}
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironmentURL);
CFBundle.prototype.executableURL = function()
{
if (this._executableURL === undefined)
@@ -167,22 +143,16 @@ CFBundle.prototype.executableURL = function()
return this._executableURL;
}
DISPLAY_NAME(CFBundle.prototype.executableURL);
CFBundle.prototype.infoDictionary = function()
{
return this._infoDictionary;
}
DISPLAY_NAME(CFBundle.prototype.infoDictionary);
CFBundle.prototype.valueForInfoDictionaryKey = function(/*String*/ aKey)
{
return this._infoDictionary.valueForKey(aKey);
}
DISPLAY_NAME(CFBundle.prototype.valueForInfoDictionaryKey);
CFBundle.prototype.hasSpritedImages = function()
{
var environments = this._infoDictionary.valueForKey("CPBundleEnvironmentsWithImageSprites") || [],
@@ -196,15 +166,11 @@ CFBundle.prototype.hasSpritedImages = function()
return NO;
}
DISPLAY_NAME(CFBundle.prototype.hasSpritedImages);
CFBundle.prototype.environments = function()
{
return this._infoDictionary.valueForKey("CPBundleEnvironments") || ["ObjJ"];
}
DISPLAY_NAME(CFBundle.prototype.environments);
CFBundle.prototype.mostEligibleEnvironment = function(/*Array*/ environments)
{
environments = environments || this.environments();
@@ -228,15 +194,11 @@ CFBundle.prototype.mostEligibleEnvironment = function(/*Array*/ environments)
return NULL;
}
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironment);
CFBundle.prototype.isLoading = function()
{
return this._loadStatus & CFBundleLoading;
}
DISPLAY_NAME(CFBundle.prototype.isLoading);
CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
{
if (this._loadStatus !== CFBundleUnloaded)
@@ -261,13 +223,7 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
function onsuccess(/*Event*/ anEvent)
{
self._loadStatus &= ~CFBundleLoadingInfoPlist;
var infoDictionary = anEvent.request.responsePropertyList();
self._isValid = !!infoDictionary || CFBundle.mainBundle() === self;
if (infoDictionary)
self._infoDictionary = infoDictionary;
self._infoDictionary = anEvent.request.responsePropertyList();
if (!self._infoDictionary)
{
@@ -284,7 +240,6 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
function onfailure()
{
self._isValid = CFBundle.mainBundle() === self;
self._loadStatus = CFBundleUnloaded;
finishBundleLoadingWithError(self, new Error("Could not load bundle at \"" + self.bundleURL() + "\""));
@@ -294,8 +249,6 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
});
}
DISPLAY_NAME(CFBundle.prototype.load);
function finishBundleLoadingWithError(/*CFBundle*/ aBundle, /*Event*/ anError)
{
resolveStaticResource(aBundle._staticResource);
@@ -437,13 +390,12 @@ function loadSpritedImagesForBundle(/*Bundle*/ aBundle, success, failure)
CFTotalBytesLoaded += anEvent.request.responseText().length;
decompileStaticFile(aBundle, anEvent.request.responseText(), spritedImagesURL);
aBundle._loadStatus &= ~CFBundleLoadingSpritedImages;
success();
}
catch(anException)
{
failure(anException);
}
success();
}, failure);
}
@@ -663,22 +615,16 @@ CFBundle.prototype.addEventListener = function(/*String*/ anEventName, /*Functio
this._eventDispatcher.addEventListener(anEventName, anEventListener);
}
DISPLAY_NAME(CFBundle.prototype.addEventListener);
CFBundle.prototype.removeEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
{
this._eventDispatcher.removeEventListener(anEventName, anEventListener);
}
DISPLAY_NAME(CFBundle.prototype.removeEventListener);
CFBundle.prototype.onerror = function(/*Event*/ anEvent)
{
throw anEvent.error;
}
DISPLAY_NAME(CFBundle.prototype.onerror);
CFBundle.prototype.bundlePath = function()
{
return this._bundleURL.absoluteURL().path();
+33 -22
View File
@@ -196,9 +196,9 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
return this._nativeRequest.overrideMimeType(aMimeType);
}
CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword)
CFHTTPRequest.prototype.open = function(/*...*/)
{
return this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword);
return this._nativeRequest.open(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
}
CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
@@ -254,32 +254,43 @@ function determineAndDispatchHTTPRequestEvents(/*CFHTTPRequest*/ aRequest)
function FileRequest(/*CFURL*/ aURL, onsuccess, onfailure)
{
#ifdef BROWSER
var request = new CFHTTPRequest();
request.onsuccess = Asynchronous(onsuccess);
request.onfailure = Asynchronous(onfailure);
if (aURL.pathExtension() === "plist")
request.overrideMimeType("text/xml");
if (exports.asyncLoader)
{
request.onsuccess = Asynchronous(onsuccess);
request.onfailure = Asynchronous(onfailure);
}
else
{
request.onsuccess = onsuccess;
request.onfailure = onfailure;
}
request.open("GET", aURL.absoluteString(), exports.asyncLoader);
request.open("GET", aURL.absoluteString(), YES);
request.send("");
#else
var FILE = require("file"),
filePath = aURL.absoluteURL().path();
if (!FILE.exists(filePath))
return onfailure();
this._responseText = FILE.read(filePath, { charset:"UTF-8" });
onsuccess({ type:"success", request:this });
#endif
}
#ifdef BROWSER
exports.asyncLoader = YES;
#else
exports.asyncLoader = NO;
#endif
#ifdef COMMONJS
FileRequest.prototype.responseText = function()
{
return this._responseText;
}
// FIXME: Get rid of these when we no longer need Mock requests in flatten.
exports.Asynchronous = Asynchronous;
exports.determineAndDispatchHTTPRequestEvents = determineAndDispatchHTTPRequestEvents;
FileRequest.prototype.responseXML = function()
{
return new DOMParser().parseFromString(anXMLString, "text/xml");
}
FileRequest.prototype.responsePropertyList = function()
{
return CFPropertyList.propertyListFromString(this.responseText());
}
#endif
+7 -25
View File
@@ -314,7 +314,7 @@ function resolveURL(aURL)
resolvedPathComponents.splice(basePathComponents.length - 1, 1);
// If this doesn't start with a "..", then we're simply appending to already standardized paths.
if (pathComponents.length && (pathComponents[0] === ".." || pathComponents[0] === "."))
if (pathComponents.length && pathComponents[0] === "..")
standardizePathComponents(resolvedPathComponents, YES);
resolvedParts.pathComponents = resolvedPathComponents;
@@ -352,26 +352,19 @@ function standardizePathComponents(/*Array*/ pathComponents, /*BOOL*/ inPlace)
var index = 0,
resultIndex = 0,
count = pathComponents.length,
result = inPlace ? pathComponents : [],
startsWithPeriod = NO;
result = inPlace ? pathComponents : [];
for (; index < count; ++index)
{
var component = pathComponents[index];
if (component === "")
if (component === "" || component === ".")
continue;
if (component === ".")
{
startsWithPeriod = resultIndex === 0;
continue;
}
if (component !== ".." || resultIndex === 0 || result[resultIndex - 1] === "..")
{
result[resultIndex] = component;
//if (resultIndex !== index)
result[resultIndex] = component;
resultIndex++;
@@ -382,9 +375,6 @@ function standardizePathComponents(/*Array*/ pathComponents, /*BOOL*/ inPlace)
--resultIndex;
}
if (startsWithPeriod && resultIndex === 0)
result[resultIndex++] = ".";
result.length = resultIndex;
return result;
@@ -515,11 +505,10 @@ CFURL.prototype.hasDirectoryPath = function()
var lastPathComponent = this.lastPathComponent();
hasDirectoryPath = lastPathComponent === "." || lastPathComponent === "..";
this._hasDirectoryPath = hasDirectoryPath;
}
return hasDirectoryPath;
return this._hasDirectoryPath;
}
DISPLAY_NAME(CFURL.prototype.hasDirectoryPath);
@@ -657,14 +646,7 @@ CFURL.prototype.asDirectoryPathURL = function()
if (this.hasDirectoryPath())
return this;
var lastPathComponent = this.lastPathComponent();
// We do this because on Windows the path may start with C: and be
// misinterpreted as a scheme.
if (lastPathComponent !== "/")
lastPathComponent = "./" + lastPathComponent;
return new CFURL(lastPathComponent + "/", this);
return new CFURL(this.lastPathComponent() + "/", this);
}
DISPLAY_NAME(CFURL.prototype.asDirectoryPathURL);
+250 -186
View File
@@ -20,107 +20,175 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
GLOBAL(CPLogDisable) = false;
var CPLogDefaultTitle = "Cappuccino";
var CPLogLevels = ["fatal", "error", "warn", "info", "debug", "trace"];
var CPLogDefaultLevel = CPLogLevels[3];
var _CPLogLevelsInverted = {};
for (var i = 0; i < CPLogLevels.length; i++)
_CPLogLevelsInverted[CPLogLevels[i]] = i;
var _CPLogRegistrations = {};
// defaults:
// Register Functions:
// Register a logger for all levels, or up to an optional max level
GLOBAL(CPLogRegister) = function(aProvider, aMaxLevel)
var CPLogDefaultTitle = "Cappuccino";
var CPLogDefaultLevel = CPLogLevels[3];
var CPLogDefaultFormatter = function(aParameters, aLevel, aTitle, useColor)
{
CPLogRegisterRange(aProvider, CPLogLevels[0], aMaxLevel || CPLogLevels[CPLogLevels.length-1]);
}
var color = useColor && defaultFormatterColorMap[aLevel];
var important = {"fatal":true,"error":true,"warn":true}[aLevel];
// Register a logger for a range of levels
GLOBAL(CPLogRegisterRange) = function(aProvider, aMinLevel, aMaxLevel)
{
var min = _CPLogLevelsInverted[aMinLevel];
var max = _CPLogLevelsInverted[aMaxLevel];
// for unimportant messages colorize just the level
if (!important && color)
aLevel = "\0"+color+"(" + aLevel + "\0)";
if (min !== undefined && max !== undefined)
for (var i = 0; i <= max; i++)
CPLogRegisterSingle(aProvider, CPLogLevels[i]);
}
aLevel = aLevel ? ' [' + aLevel + ']' : '';
// Register a logger for a single level
GLOBAL(CPLogRegisterSingle) = function(aProvider, aLevel)
{
if (!_CPLogRegistrations[aLevel])
_CPLogRegistrations[aLevel] = [];
// prevent duplicate registrations
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
if (_CPLogRegistrations[aLevel][i] === aProvider)
return;
_CPLogRegistrations[aLevel].push(aProvider);
}
GLOBAL(CPLogUnregister) = function(aProvider) {
for (var aLevel in _CPLogRegistrations)
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
if (_CPLogRegistrations[aLevel][i] === aProvider)
_CPLogRegistrations[aLevel].splice(i--, 1); // decrement since we're removing an element
}
// Main CPLog, which dispatches to individual loggers
function _CPLogDispatch(parameters, aLevel, aTitle)
{
if (aTitle == undefined)
aTitle = CPLogDefaultTitle;
if (aLevel == undefined)
aLevel = CPLogDefaultLevel;
// use sprintf if param 0 is a string and there is more than one param. otherwise just convert param 0 to a string
var message = (typeof parameters[0] == "string" && parameters.length > 1) ? exports.sprintf.apply(null, parameters) : String(parameters[0]);
if (_CPLogRegistrations[aLevel])
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
_CPLogRegistrations[aLevel][i](message, aLevel, aTitle);
}
var aString = (typeof aParameters[0] === "string" && aParameters.length > 1) ? exports.sprintf.apply(null, aParameters) : String(aParameters[0]);
// Setup CPLog() and CPLog.xxx() aliases
GLOBAL(CPLog) = function() { _CPLogDispatch(arguments); }
for (var i = 0; i < CPLogLevels.length; i++)
CPLog[CPLogLevels[i]] = (function(level) { return function() { _CPLogDispatch(arguments, level); }; })(CPLogLevels[i]);
// Helpers functions:
var _CPFormatLogMessage = function(aString, aLevel, aTitle)
{
var now = new Date();
aLevel = ( aLevel == null ? '' : ' [' + aLevel + ']' );
var message = exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s",
now.getFullYear(), now.getMonth(), now.getDate(),
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
aTitle, aLevel, aString);
if (typeof exports.sprintf == "function")
return exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s",
now.getFullYear(), now.getMonth(), now.getDate(),
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
aTitle, aLevel, aString);
else
return now + " " + aTitle + aLevel + ": " + aString;
// for important messages colorize entire message
if (important && color)
message = "\0"+color+"(" + message + "\0)";
return message;
}
// Loggers:
var defaultFormatterColorMap = {
"fatal": "red",
"error": "red",
"warn" : "yellow",
"info" : "green",
"debug": "cyan",
"trace": "blue"
};
#if COMMONJS
// attempt to get a better default title based on the command line name
try {
if (require("system").args[0])
CPLogDefaultTitle = require("file").basename(require("system").args[0]);
} catch (e) {
}
#endif
// main Logger constructor / API:
function CreateLogger(aTitle)
{
// public
var self = function() { self._dispatch(arguments, null, _title); };
// logger.error, logger.info, logger.warn
for (var i = 0; i < CPLogLevels.length; i++)
self[CPLogLevels[i]] = (function(level) { return function() { self._dispatch(arguments, level, _title); }; })(CPLogLevels[i]);
self.createLogger = function()
{
return CreateLogger.apply(this, arguments);;
}
// Register a logger for all levels, or up to an optional max level
self.register = function(aProvider, aMaxLevel)
{
if (aMaxLevel === undefined) aMaxLevel = CPLogLevels.length;
self.registerRange(aProvider, 0, aMaxLevel);
}
// Register a logger for a range of levels
self.registerRange = function(aProvider, aMinLevel, aMaxLevel)
{
if (typeof aMinLevel !== "number") aMinLevel = _CPLogLevelsInverted[aMinLevel];
if (typeof aMaxLevel !== "number") aMaxLevel = _CPLogLevelsInverted[aMaxLevel];
if (aMinLevel !== undefined && aMaxLevel !== undefined)
for (var level = aMinLevel; level <= aMaxLevel; level++)
self.registerSingle(aProvider, level);
}
// Register a logger for a single level
self.registerSingle = function(aProvider, aLevel)
{
if (typeof aLevel === "number") aLevel = CPLogLevels[aLevel];
if (!_registrations[aLevel])
_registrations[aLevel] = [];
// prevent duplicate _registrations
for (var i = 0; i < _registrations[aLevel].length; i++)
if (_registrations[aLevel][i] === aProvider)
return;
_registrations[aLevel].push(aProvider);
}
// Unregister a logger for all levels
self.unregister = function(aProvider)
{
for (var aLevel in _registrations)
for (var i = 0; i < _registrations[aLevel].length; i++)
if (_registrations[aLevel][i] === aProvider)
_registrations[aLevel].splice(i--, 1); // decrement since we're removing an element
}
self.setDefaultTitle = function(aTitle)
{
CPLogDefaultTitle = aTitle;
}
self.setDefaultLevel = function(aLevel)
{
CPLogDefaultLevel = aLevel;
}
self.setDefaultFormatter = function(aFormatter)
{
CPLogDefaultFormatter = aFormatter;
}
// private
var _registrations = {};
var _title = aTitle;
self._dispatch = function(aParameters, aLevel, aTitle)
{
aParameters = Array.prototype.slice.call(aParameters);
if (aTitle == undefined) aTitle = CPLogDefaultTitle;
if (aLevel == undefined) aLevel = CPLogDefaultLevel;
if (_registrations[aLevel])
for (var i = 0; i < _registrations[aLevel].length; i++)
_registrations[aLevel][i](aParameters, aLevel, aTitle);
}
return self;
}
// Default CPLog:
GLOBAL(CPLog) = CreateLogger();
// Deprecated global registration functions
GLOBAL(CPLogRegister) = function() { CPLog.register.apply(CPLog, arguments); CPLog("CPLogRegister() is deprecated, use CPLog.register()"); };
GLOBAL(CPLogRegisterRange) = function() { CPLog.registerRange.apply(CPLog, arguments); CPLog("CPLogRegisterRange() is deprecated, use CPLog.registerRange()"); };
GLOBAL(CPLogRegisterSingle) = function() { CPLog.registerSingle.apply(CPLog, arguments); CPLog("CPLogRegisterSingle() is deprecated, use CPLog.registerSingle()"); };
// Included loggers:
// CPLogConsole uses the built in "console" object
GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle)
// (possibly available in CommonJS environments?)
function CPLogConsoleCreate(formatter)
{
if (typeof console != "undefined")
{
var message = _CPFormatLogMessage(aString, aLevel, aTitle);
return function(aString, aLevel, aTitle) {
if (typeof console === "undefined")
return;
var message = (formatter || CPLogDefaultFormatter)(aString, aLevel, aTitle, false);
var logger = {
"fatal": "error",
"error": "error",
@@ -128,107 +196,109 @@ GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle)
"info": "info",
"debug": "debug",
"trace": "debug"
}[aLevel];
if (logger && console[logger])
}[aLevel] || "log";
if (console[logger])
console[logger](message);
else if (console.log)
console.log(message);
}
}
GLOBAL(CPLogConsole) = CPLogConsoleCreate();
CPLogConsole.create = CPLogConsoleCreate;
// CommonJS specific loggers
#if COMMONJS
var levelColorMap = {
"fatal": "red",
"error": "red",
"warn" : "yellow",
"info" : "green",
"debug": "cyan",
"trace": "blue"
}
try {
var SYSTEM = require("system");
var FILE = require("file");
if (SYSTEM.args[0])
CPLogDefaultTitle = FILE.basename(SYSTEM.args[0]);
} catch (e) {
}
var stream;
GLOBAL(CPLogPrint) = function(aString, aLevel, aTitle)
// CPLogPrint uses STDOUT to print to console
function CPLogPrintCreate(formatter, stream, useColor)
{
if (stream === undefined) {
if (!stream) {
try {
stream = require("term").stream;
useColor = true;
} catch (e) {
stream = null;
useColor = false;
if (typeof print != "undefined")
stream = { print : print };
}
}
if (stream) {
if (aLevel == "fatal" || aLevel == "error" || aLevel == "warn")
stream.print("\0"+levelColorMap[aLevel]+"(" + _CPFormatLogMessage(aString, aLevel, aTitle) + "\0)");
else
stream.print(_CPFormatLogMessage(aString, "\0"+levelColorMap[aLevel]+"(" + aLevel + "\0)", aTitle));
} else if (typeof print != "undefined") {
print(_CPFormatLogMessage(aString, aLevel, aTitle))
return function(aParameters, aLevel, aTitle) {
var message = (formatter || CPLogDefaultFormatter)(aParameters, aLevel, aTitle, useColor);
stream.print(message);
}
}
GLOBAL(CPLogPrint) = CPLogPrintCreate();
CPLogPrint.create = CPLogPrintCreate;
// Browser specific loggers
#else
// CPLogAlert uses basic browser alert() functions
GLOBAL(CPLogAlert) = function(aString, aLevel, aTitle)
{
if (typeof alert != "undefined" && !CPLogDisable)
{
var message = _CPFormatLogMessage(aString, aLevel, aTitle);
CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)");
}
}
// TODO: should this not be global?
GLOBAL(CPLogDisable) = false;
// CPLogPopup uses a slick popup window in the browser:
var CPLogWindow = null;
GLOBAL(CPLogPopup) = function(aString, aLevel, aTitle)
// CPLogAlert uses basic browser confirm()
function CPLogAlertCreate(formatter)
{
try {
if (CPLogDisable || window.open == undefined)
return;
if (!CPLogWindow || !CPLogWindow.document)
{
CPLogWindow = window.open("", "_blank", "width=600,height=400,status=no,resizable=yes,scrollbars=yes");
if (!CPLogWindow) {
CPLogDisable = !confirm(aString + "\n\n(Disable pop-up blocking for CPLog window; Click cancel to stop log alerts)");
return;
}
_CPLogInitPopup(CPLogWindow);
return function(aParameters, aLevel, aTitle) {
if (typeof confirm != "undefined" && !CPLogDisable) {
var message = (formatter || CPLogDefaultFormatter)(aParameters, aLevel, aTitle);
CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)");
}
var logDiv = CPLogWindow.document.createElement("div");
logDiv.setAttribute("class", aLevel || "fatal");
var message = _CPFormatLogMessage(aString, null, aTitle);
logDiv.appendChild(CPLogWindow.document.createTextNode(message));
CPLogWindow.log.appendChild(logDiv);
if (CPLogWindow.focusEnabled.checked)
CPLogWindow.focus();
if (CPLogWindow.blockEnabled.checked)
CPLogWindow.blockEnabled.checked = CPLogWindow.confirm(message+"\nContinue blocking?");
if (CPLogWindow.scrollEnabled.checked)
CPLogWindow.scrollToBottom();
} catch(e) {
// TODO: some error handling/reporting
}
}
GLOBAL(CPLogAlert) = CPLogAlertCreate();
CPLogAlert.create = CPLogAlertCreate;
// CPLogPopup uses a slick popup window in the browser
// TODO: move this into DebugKit
function CPLogPopupCreate(formatter)
{
var logWindow = null;
return function(aParameters, aLevel, aTitle) {
var message = (formatter || CPLogDefaultFormatter)(aString, null, aTitle);
try {
if (CPLogDisable || window.open == undefined)
return;
if (!logWindow || !logWindow.document)
{
logWindow = window.open("", "_blank", "width=600,height=400,status=no,resizable=yes,scrollbars=yes");
if (!logWindow) {
CPLogDisable = !confirm(message + "\n\n(Disable pop-up blocking for CPLog window; Click cancel to stop log alerts)");
return;
}
_CPLogPopupInit(logWindow);
}
var logDiv = logWindow.document.createElement("div");
logDiv.setAttribute("class", aLevel || "fatal");
logDiv.appendChild(logWindow.document.createTextNode(message));
logWindow.log.appendChild(logDiv);
if (logWindow.focusEnabled.checked)
logWindow.focus();
if (logWindow.blockEnabled.checked)
logWindow.blockEnabled.checked = logWindow.confirm(message+"\nContinue blocking?");
if (logWindow.scrollEnabled.checked)
logWindow.scrollToBottom();
} catch(e) {
// TODO: some error handling/reporting
}
}
}
GLOBAL(CPLogPopup) = CPLogPopupCreate();
CPLogPopup.create = CPLogPopupCreate;
// private CPLogPopup
var CPLogPopupStyle ='<style type="text/css" media="screen"> \
body{font:10px Monaco,Courier,"Courier New",monospace,mono;padding-top:15px;} \
div > .fatal,div > .error,div > .warn,div > .info,div > .debug,div > .trace{display:none;overflow:hidden;white-space:pre;padding:0px 5px 0px 5px;margin-top:2px;-moz-border-radius:5px;-webkit-border-radius:5px;} \
@@ -248,30 +318,24 @@ ul#options{display:inline-block;margin:0 15px 0px 15px;padding:0 0px;} \
ul#options li{margin:0 0 0 0;padding:0 0 0 0;display:inline;} \
</style>';
function _CPLogInitPopup(logWindow)
function _CPLogPopupInit(logWindow)
{
var doc = logWindow.document;
// HACK so that head is available below:
doc.writeln("<html><head><title></title>"+CPLogPopupStyle+"</head><body></body></html>");
doc.title = CPLogDefaultTitle + " Run Log";
var head = doc.getElementsByTagName("head")[0];
var body = doc.getElementsByTagName("body")[0];
var base = window.location.protocol + "//" + window.location.host + window.location.pathname;
base = base.substring(0,base.lastIndexOf("/")+1);
var div = doc.createElement("div");
div.setAttribute("id", "header");
body.appendChild(div);
// Enablers
var ul = doc.createElement("ul");
ul.setAttribute("id", "enablers");
div.appendChild(ul);
for (var i = 0; i < CPLogLevels.length; i++) {
var li = doc.createElement("li");
li.setAttribute("id", "en"+CPLogLevels[i]);
@@ -281,35 +345,35 @@ function _CPLogInitPopup(logWindow)
li.appendChild(doc.createTextNode(CPLogLevels[i]));
ul.appendChild(li);
}
// Options
var ul = doc.createElement("ul");
ul.setAttribute("id", "options");
div.appendChild(ul);
var options = {"focus":["Focus",false], "block":["Block",false], "wrap":["Wrap",false], "scroll":["Scroll",true], "close":["Close",true]};
for (o in options) {
var li = doc.createElement("li");
ul.appendChild(li);
logWindow[o+"Enabled"] = doc.createElement("input");
logWindow[o+"Enabled"].setAttribute("id", o);
logWindow[o+"Enabled"].setAttribute("type", "checkbox");
if (options[o][1])
if (options[o][1])
logWindow[o+"Enabled"].setAttribute("checked", "checked");
li.appendChild(logWindow[o+"Enabled"]);
var label = doc.createElement("label");
label.setAttribute("for", o);
label.appendChild(doc.createTextNode(options[o][0]));
li.appendChild(label);
}
// Log
logWindow.log = doc.createElement("div");
logWindow.log.setAttribute("class", "enerror endebug enwarn eninfo enfatal entrace");
body.appendChild(logWindow.log);
logWindow.toggle = function(elem) {
var enabled = (elem.getAttribute("enabled") == "yes") ? "no" : "yes";
elem.setAttribute("enabled", enabled);
@@ -319,17 +383,17 @@ function _CPLogInitPopup(logWindow)
else
logWindow.log.className = logWindow.log.className.replace(new RegExp("[\\s]*"+elem.id, "g"), "");
}
// Scroll
logWindow.scrollToBottom = function() {
logWindow.scrollTo(0, body.offsetHeight);
}
// Wrap
logWindow.wrapEnabled.addEventListener("click", function() {
logWindow.log.setAttribute("wrap", logWindow.wrapEnabled.checked ? "yes" : "no");
}, false);
// Clear
logWindow.addEventListener("keydown", function(e) {
var e = e || logWindow.event;
@@ -340,7 +404,7 @@ function _CPLogInitPopup(logWindow)
e.preventDefault();
}
}, "false");
// Parent closing
window.addEventListener("unload", function() {
if (logWindow && logWindow.closeEnabled && logWindow.closeEnabled.checked) {
@@ -348,7 +412,7 @@ function _CPLogInitPopup(logWindow)
logWindow.close();
}
}, false);
// Log popup closing
logWindow.addEventListener("unload", function() {
if (!CPLogDisable) {
@@ -358,9 +422,9 @@ function _CPLogInitPopup(logWindow)
}
#endif
// guess a good default logger:
#if COMMONJS
CPLogDefault = CPLogPrint;
GLOBAL(CPLogDefault) = CPLogPrint;
#else
CPLogDefault = (typeof window === "object" && window.console) ? CPLogConsole : CPLogPopup;
GLOBAL(CPLogDefault) = (typeof console !== "undefined") ? CPLogConsole : CPLogPopup;
#endif
+27 -31
View File
@@ -1,7 +1,5 @@
var FILE = require("file");
var sprintf = require("printf").sprintf;
var window = exports.window = require("browser/window");
if (system.engine === "rhino")
@@ -9,7 +7,7 @@ if (system.engine === "rhino")
window.__parent__ = null;
window.__proto__ = global;
}
// setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc
window.OBJJ_HOME = exports.OBJJ_HOME = FILE.resolve(module.path, "..");
@@ -79,12 +77,6 @@ exports.run = function(args)
// copy the args since we're going to modify them
var argv = args.slice(1);
if (argv[0] === "--version")
{
print(exports.fullVersionString());
return;
}
while (argv.length && argv[0].indexOf('-I') === 0)
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().substr(2).split(':'));
}
@@ -148,12 +140,37 @@ exports.repl = function()
}
}
exports.objj_eval = function(/*String*/ aString)
{
// We need this while code still refers to window.
Executable.setCommonJSArguments(require, exports, module, system, print, window);
var executable = exports.preprocess(aString, "", 0);
if (!executable.hasLoadedFileDependencies())
executable.loadFileDependencies();
// A bit of a hack. Executable compiles the code itself into a function, but we want
// the raw code to eval here.
var code = executable._code;
// Not clear why these should be global, varing them doesn't seem to take effect with evaluateString.
global.objj_executeFile = Executable.fileExecuterForURL(FILE.cwd());
global.objj_importFile = Executable.fileImporterForURL(FILE.cwd());
if (typeof system !== "undefined" && system.engine === "rhino")
return Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(global, code, "objj_eval", 0, NULL);
return eval(code);
}
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
// creates a narwhal factory function in the objj module scope
exports.make_narwhal_factory = function(path)
{
return function(require, exports, module, system, print)
{
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
Executable.setCommonJSArguments(require, exports, module, system, print, window);
Executable.fileImporterForURL(FILE.dirname(path))(path, YES);
}
@@ -161,26 +178,5 @@ exports.make_narwhal_factory = function(path)
} // end "with"
var pkg = null;
function getPackage() {
if (!pkg)
pkg = JSON.parse(FILE.path(module.path).dirname().dirname().join("package.json").read({ charset : "UTF-8" }));
return pkg;
}
exports.version = function() { return getPackage()["version"]; }
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
exports.fullVersionString = function() {
return sprintf("objective-j %s (%04d-%02d-%02d %s)",
exports.version(),
exports.timestamp().getUTCFullYear(),
exports.timestamp().getUTCMonth()+1,
exports.timestamp().getUTCDate(),
exports.revision().slice(0,6)
);
}
if (require.main == module.id)
exports.run(system.args);
@@ -16,7 +16,8 @@ var Task = Jake.Task,
function isImage(/*String*/ aFilename)
{
return UTIL.has([".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"], FILE.extension(aFilename).toLowerCase());
return FILE.isFile(aFilename) &&
UTIL.has([".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"], FILE.extension(aFilename).toLowerCase());
}
function mimeType(/*String*/ aFilename)
@@ -369,17 +370,14 @@ BundleTask.prototype.infoPlist = function()
return anEnvironment.name();
}));
infoPlist.setValueForKey("CPBundleExecutable", this.productName() + ".sj");
var environmentsWithImageSprites = this.environments().filter(
infoPlist.setValueForKey("CPBundleEnvironmentsWithImageSprites", this.environments().filter(
function(anEnvironment)
{
return anEnvironment.spritesImages() && task(this.buildProductDataURLPathForEnvironment(anEnvironment)).prerequisites().filter(isImage).length > 0;
}, this).map(function(anEnvironment)
return anEnvironment.spritesImages();
}).map(function(anEnvironment)
{
return anEnvironment.name();
});
infoPlist.setValueForKey("CPBundleEnvironmentsWithImageSprites", environmentsWithImageSprites);
}));
var principalClass = this.principalClass();
@@ -583,6 +581,7 @@ BundleTask.prototype.defineResourceTasks = function()
}, this);
}
var RESOURCES_PATH = FILE.join(FILE.absolute(FILE.dirname(module.path)), "RESOURCES"),
MHTMLTestPath = FILE.join(RESOURCES_PATH, "MHTMLTest.txt");
@@ -596,29 +595,27 @@ BundleTask.prototype.defineSpritedImagesTask = function()
var folder = anEnvironment.name() + ".environment",
resourcesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources", "");
function isDataResource(/*String*/ aFilename)
{
return FILE.isFile(aFilename) && aFilename.indexOf(resourcesPath) === 0 && isImage(aFilename);
}
var productName = this.productName(),
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment);
filedir (dataURLPath, function(aTask)
{
var prerequisites = aTask.prerequisites().filter(isImage);
if (!prerequisites.length)
{
if (FILE.exists(dataURLPath))
FILE.remove(dataURLPath);
return;
}
TERM.stream.print("Creating data URLs file... \0green(" + dataURLPath +"\0)");
var dataURLStream = FILE.open(dataURLPath, "w+", { charset:"UTF-8" });
dataURLStream.write("@STATIC;1.0;");
prerequisites.forEach(function(aFilename)
aTask.prerequisites().forEach(function(aFilename)
{
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
dataURLStream.write("u;" + resourcePath.length + ";" + resourcePath);
@@ -639,24 +636,17 @@ BundleTask.prototype.defineSpritedImagesTask = function()
filedir (MHTMLPath, function(aTask)
{
var prerequisites = aTask.prerequisites().filter(isImage);
if (!prerequisites.length)
{
if (FILE.exists(MHTMLPath))
FILE.remove(MHTMLPath);
return;
}
TERM.stream.print("Creating MHTML paths file... \0green(" + MHTMLPath +"\0)");
var MHTMLStream = FILE.open(MHTMLPath, "w+", { charset:"UTF-8" });
MHTMLStream.write("@STATIC;1.0;");
prerequisites.forEach(function(aFilename)
aTask.prerequisites().forEach(function(aFilename)
{
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename),
MHTMLResourcePath = "mhtml:" + FILE.join(folder, "MHTMLData.txt!") + resourcePath;
@@ -673,24 +663,17 @@ BundleTask.prototype.defineSpritedImagesTask = function()
filedir (MHTMLDataPath, function(aTask)
{
var prerequisites = aTask.prerequisites().filter(isImage);
if (!prerequisites.length)
{
if (FILE.exists(MHTMLDataPath))
FILE.remove(MHTMLDataPath);
return;
}
TERM.stream.print("Creating MHTML images file... \0green(" + MHTMLDataPath +"\0)");
var MHTMLDataStream = FILE.open(MHTMLDataPath, "w+", { charset:"UTF-8" });
MHTMLDataStream.write("/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n");
prerequisites.forEach(function(aFilename)
aTask.prerequisites().forEach(function(aFilename)
{
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
MHTMLDataStream.write("--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n");
+1
View File
@@ -5,6 +5,7 @@
"description": "Objective-J and Cappuccino module",
"keywords": ["objective-j", "objj", "objective j", "cappuccino"],
"author": "280 North, Inc. (http://280north.com/)",
"version": "0.8.0",
"contributors": [
"Francisco Tolmasky (http://tolmasky.com/)",
"Ross Boucher (http://rossboucher.com/)",
+1 -1
View File
@@ -27,7 +27,7 @@ if (typeof window !== "undefined")
window.setNativeTimeout = window.setTimeout;
window.clearNativeTimeout = window.clearTimeout;
window.setNativeInterval = window.setInterval;
window.clearNativeInterval = window.clearInterval;
window.clearNativeInterval = window.clearNativeInterval;
}
// Objective-J Constants
-4
View File
@@ -20,10 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef BROWSER
CPLogRegister(CPLogDefault);
#endif
// formatting helpers
function objj_debug_object_format(aReceiver)
-55
View File
@@ -1,55 +0,0 @@
GLOBAL(objj_eval) = function(/*String*/ aString)
{
#if COMMONJS
var url = FILE.join(FILE.cwd(), "/");
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
Executable.setCommonJSArguments(require, exports, module, system, print, window);
#else
var url = exports.pageURL;
#endif
// Temporarily switch the loader to sychronous mode since objj_eval must be synchronous
// therefore you shouldn't use @imports in objj_eval the browser
var asyncLoaderSaved = exports.asyncLoader;
exports.asyncLoader = NO;
var executable = exports.preprocess(aString, url, 0);
if (!executable.hasLoadedFileDependencies())
executable.loadFileDependencies();
// here we setup a scope object containing the free variables that would normally be arguments to the module function
global._objj_eval_scope = {};
global._objj_eval_scope.objj_executeFile = Executable.fileExecuterForURL(url);
global._objj_eval_scope.objj_importFile = Executable.fileImporterForURL(url);
#if COMMONJS
global._objj_eval_scope.require = require;
global._objj_eval_scope.exports = exports;
global._objj_eval_scope.module = module;
global._objj_eval_scope.system = system;
global._objj_eval_scope.print = print;
global._objj_eval_scope.window = window;
#endif
// A bit of a hack. Executable compiles the code itself into a function, but we want
// the raw code to eval here so we can get the result.
// No known way to get the result of a statement except via eval.
var code = "with(_objj_eval_scope){" + executable._code + "\n//*/\n}";
var result;
#if COMMONJS
if (typeof system !== "undefined" && system.engine === "rhino")
result = Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(global, code, "objj_eval", 0, NULL);
else
#endif
result = eval(code);
// restore async loader setting
exports.asyncLoader = asyncLoaderSaved;
return result;
}
// deprecated, use global
exports.objj_eval = objj_eval;
+7 -14
View File
@@ -137,7 +137,6 @@ Executable.prototype.execute = function()
#endif
var oldContextBundle = CONTEXT_BUNDLE;
// FIXME: Should we have stored this?
CONTEXT_BUNDLE = CFBundle.bundleContainingURL(this.URL());
var result = this._function.apply(global, this.functionArguments());
@@ -218,13 +217,10 @@ Executable.prototype.loadFileDependencies = function(aCallback)
{
var status = this._fileDependencyStatus;
if (aCallback)
{
if (status === ExecutableLoadedFileDependencies)
return aCallback();
if (status === ExecutableLoadedFileDependencies)
return aCallback();
this._fileDependencyCallbacks.push(aCallback);
}
this._fileDependencyCallbacks.push(aCallback)
if (status === ExecutableUnloadedFileDependencies)
{
@@ -284,18 +280,15 @@ function fileExecutableSearchFinished(/*FileExecutable*/ aFileExecutable)
function fileExecutableDependencyLoadFinished()
{
var executables = fileDependencyExecutables,
index = 0,
count = executables.length;
fileDependencyExecutables = [];
var index = 0,
count = fileDependencyExecutables.length;
for (; index < count; ++index)
executables[index]._fileDependencyStatus = ExecutableLoadedFileDependencies;
fileDependencyExecutables[index]._fileDependencyStatus = ExecutableLoadedFileDependencies;
for (index = 0; index < count; ++index)
{
var executable = executables[index],
var executable = fileDependencyExecutables[index],
callbacks = executable._fileDependencyCallbacks,
callbackIndex = 0,
callbackCount = callbacks.length;
+5 -20
View File
@@ -22,7 +22,7 @@
var FileExecutablesForURLStrings = { };
function FileExecutable(/*CFURL|String*/ aURL)
function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable)
{
aURL = makeAbsoluteURL(aURL);
@@ -38,7 +38,10 @@ function FileExecutable(/*CFURL|String*/ aURL)
executable = NULL,
extension = aURL.pathExtension();
if (fileContents.match(/^@STATIC;/))
if (anExecutable)
executable = anExecutable;
else if (fileContents.match(/^@STATIC;/))
executable = decompile(fileContents, aURL);
else if (extension === "j" || !extension)
@@ -114,23 +117,5 @@ function decompile(/*String*/ aString, /*CFURL*/ aURL)
dependencies.push(new FileDependency(new CFURL(text), YES));
}
var fn = FileExecutable._lookupCachedFunction(aURL)
if (fn)
return new Executable(code, dependencies, aURL, fn);
return new Executable(code, dependencies, aURL);
}
var FunctionCache = { };
FileExecutable._cacheFunction = function(/*CFURL|String*/ aURL, /*Function*/ fn)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
FunctionCache[aURL] = fn;
}
FileExecutable._lookupCachedFunction = function(/*CFURL|String*/ aURL)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return FunctionCache[aURL];
}
-1
View File
@@ -47,7 +47,6 @@
#include "Executable.js"
#include "FileExecutable.js"
#include "Runtime.js"
#include "Eval.js"
#if defined(DEBUG) || defined(COMMONJS)
#include "Debug.js"
#endif
-4
View File
@@ -87,10 +87,6 @@ new FileList("CommonJS/**/*").forEach(function(aFilename)
CLOBBER.include(buildFilename);
});
task ("build", function() {
setPackageMetadata(FILE.join($BUILD_CJS_OBJECTIVE_J, "package.json"));
});
$BUILD_CJS_OBJECTIVE_J_FRAMEWORK = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J");
filedir($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function()
+1 -7
View File
@@ -143,14 +143,8 @@ StaticResource.resourceAtURL = function(/*CFURL|String*/ aURL, /*BOOL*/ resolveA
resource = resource._children[name];
else if (resolveAsDirectoriesIfNecessary)
{
// We do this because on Windows the path may start with C: and be
// misinterpreted as a scheme.
if (name !== "/")
name = "./" + name;
resource = new StaticResource(new CFURL(name, resource.URL()), resource, YES, YES);
}
else
throw new Error("Static Resource at " + aURL + " is not resolved (\"" + name + "\")");
}
+8 -37
View File
@@ -2,9 +2,6 @@
@implementation CPDictionaryTest : OJTestCase
{
CPDictionary string_dict;
CPDictionary json_dict;
JSObject json;
}
- (void)setUp
@@ -57,28 +54,14 @@
- (void)testDictionaryWithJSObjectRecursive
{
var dict = [CPDictionary dictionaryWithJSObject:json recursively:YES];
[self assert:[json_dict count] equals:3];
[self assert:[dict count] equals:3];
[self assert:[[dict objectForKey:@"key3"] count] equals:1];
}
- (void)testDictionaryWithJSObjectRecursiveWithNull
{
var json_with_nulls = {
"key1": ['1', '2', '3'],
"key2": "This is a string",
"key3": null
}
var dict = [CPDictionary dictionaryWithJSObject:json_with_nulls recursively:YES];
[self assert:3 equals:[dict count]];
[self assert:[@"key1", @"key2", @"key3"] equals:[dict allKeys]];
[self assert:[CPNull null] equals:[dict objectForKey:@"key3"]];
}
- (void)testDictionaryWithJSObjectNonRecursive
{
var non_recursive_dict = [CPDictionary dictionaryWithJSObject:json recursively:NO];
[self assertThrows:[non_recursive_dict objectForKey:@"key3"]];
}
- (void)testCopy
@@ -158,6 +141,8 @@
[json_dict removeObjectForKey:@"key1"];
[self assert:[string_dict count] equals:1];
[self assert:[json_dict count] equals:2];
[self assertThrows:[string_dict objectForKey:@"key1"]];
[self assertThrows:[json_dict objectForKey:@"key1"]];
}
- (void)testRemoveObjectsForKeys
@@ -166,6 +151,9 @@
[json_dict removeObjectsForKeys:[@"key1", @"key2"]];
[self assert:[string_dict count] equals:1];
[self assert:[json_dict count] equals:1];
[self assertThrows:[string_dict objectForKey:@"key1"]];
[self assertThrows:[json_dict objectForKey:@"key1"]];
[self assertThrows:[json_dict objectForKey:@"key2"]];
}
- (void)testSetObjectForKey
@@ -185,21 +173,4 @@
[self assert:[json_dict count] equals:5];
}
- (void)testDictionaryWithFalsyValues
{
var dict = [[CPDictionary alloc] initWithObjects:["", 0, [CPNull null]] forKeys:["1", "2", "3"]];
[self assertTrue:[dict containsKey:"1"]];
[self assertTrue:[dict containsKey:"2"]];
[self assertTrue:[dict containsKey:"3"]];
[self assertFalse:[dict containsKey:"4"]];
}
- (void)testThrowsOnNilValue
{
[self assertThrows:function(){
var dict = [[CPDictionary alloc] initWithObjects:[1, nil] forKeys:["1", "2"]];
[self assertFalse:dict];
}];
}
@end
@end
+11 -25
View File
@@ -12,11 +12,6 @@ function descriptionWithoutEntity(aString)
CPIndexSet _set;
}
- (void)setUp
{
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(10, 10)];
}
- (void)testAddIndexes
{
var indexSet = [CPIndexSet indexSet];
@@ -182,6 +177,16 @@ function descriptionWithoutEntity(aString)
[self assert:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59] equals:array];
}
- (void)setUp
{
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(10, 10)];
}
- (void)tearDown
{
_set = nil;
}
- (void)testIndexSet:(CPIndexSet)set containsRange:(CPRange)range
{
[self assertFalse:[set containsIndex:range.location -1]];
@@ -353,24 +358,5 @@ function descriptionWithoutEntity(aString)
[self assertFalse:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(9, 2)]]];
}
- (void)testShiftIndexesStartingAtIndex
{
var startRange = CPMakeRange(1, 5),
shiftRange = CPMakeRange(2, 5);
_set = [CPIndexSet indexSetWithIndexesInRange:startRange];
// positive delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:shiftRange]]];
// negative delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:-1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:startRange]]];
}
- (void)tearDown
{
_set = nil;
}
@end
+2 -2
View File
@@ -32,7 +32,7 @@ CPLogRegister(CPLogConsole);
- (int)numberOfRowsInTableView:(CPTableView)tableView
{
return 100000;
return 700000;
}
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
@@ -43,4 +43,4 @@ CPLogRegister(CPLogConsole);
return String((row + 1) * [[tableColumn identifier] intValue]);
}
@end
@end
File diff suppressed because one or more lines are too long
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="371"/>
<integer value="372"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -84,7 +84,6 @@
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="534516850">
<string key="NSIdentifier">1</string>
<double key="NSWidth">101</double>
<double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double>
@@ -143,7 +142,6 @@
<reference key="NSTableView" ref="86489736"/>
</object>
<object class="NSTableColumn" id="870554271">
<string key="NSIdentifier">2</string>
<double key="NSWidth">154</double>
<double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double>
@@ -170,7 +168,6 @@
<reference key="NSTableView" ref="86489736"/>
</object>
<object class="NSTableColumn" id="192893327">
<string key="NSIdentifier">3</string>
<double key="NSWidth">188</double>
<double key="NSMinWidth">10</double>
<double key="NSMaxWidth">3.4028234663852886e+38</double>
@@ -217,8 +214,8 @@
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
<double key="NSRowHeight">23</double>
<int key="NSTvFlags">-694157312</int>
<double key="NSRowHeight">17</double>
<int key="NSTvFlags">-702545920</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<int key="NSColumnAutoresizingStyle">4</int>
@@ -280,7 +277,7 @@
<reference key="NSContentView" ref="331394667"/>
<reference key="NSHeaderClipView" ref="471528550"/>
<reference key="NSCornerView" ref="167646100"/>
<bytes key="NSScrollAmts">QSAAAEEgAABByAAAQcgAAA</bytes>
<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
</object>
</object>
<string key="NSFrameSize">{558, 348}</string>
@@ -478,9 +475,9 @@
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{370, 244}, {558, 348}}</string>
<string>{{47, 268}, {558, 348}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{370, 244}, {558, 348}}</string>
<string>{{47, 268}, {558, 348}}</string>
<integer value="1"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
+113 -53
View File
@@ -1,6 +1,12 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPIndexSet.j>
@import <AppKit/CPTableColumn.j>
@import <AppKit/CPTableView.j>
tableTestDragType = @"CPTableViewTestDragType";
CPLogRegister(CPLogConsole);
@implementation AppController : CPObject
{
@@ -14,7 +20,6 @@ tableTestDragType = @"CPTableViewTestDragType";
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
dataSet1 = [],
dataSet2 = [],
dataSet3 = [];
@@ -26,40 +31,40 @@ tableTestDragType = @"CPTableViewTestDragType";
dataSet3[i - 1] = [CPNumber numberWithInt:i+20];
}
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,400,400) styleMask:CPClosableWindowMask],
contentView = [theWindow contentView];
var window1 = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask],
view = [window1 contentView];
[view setBackgroundColor:[CPColor whiteColor]];
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];
[tableView setAllowsMultipleSelection:YES];
[tableView setAllowsColumnSelection:YES];
[tableView setUsesAlternatingRowBackgroundColors:YES];
[tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle];
[tableView setDelegate:self];
[tableView setDataSource:self];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
[iconColumn setDataView:iconView];
[tableView addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
[tableView addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
for (var i = 1; i <= 2; i++)
{
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
[column setSortDescriptorPrototype:desc];
[[column headerView] setStringValue:"Number " + i];
[[column headerView] setStringValue:"Number "+i];
[column setMinWidth:50.0];
[column setMaxWidth:500.0];
@@ -69,14 +74,24 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView addTableColumn:column];
}
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]))];
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([view bounds]), CGRectGetHeight([view bounds]))];
[tableView setRowHeight:22.0];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[contentView addSubview:scrollView];
[view addSubview:scrollView];
[theWindow orderFront:self];
[scrollView setAutohidesScrollers:YES];
[tableView setDelegate:self];
[tableView setDataSource:self];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[window1 setAcceptsMouseMovedEvents:YES];
[window1 orderFront:self];
[self newWindow];
[self sourceList];
}
@@ -91,22 +106,39 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView2 setAllowsMultipleSelection:YES];
[tableView2 setUsesAlternatingRowBackgroundColors:YES];
[tableView2 setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView2 setVerticalMotionCanBeginDrag:NO];
[tableView2 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView2 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];
[tableView2 setDelegate:self];
[tableView2 setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
[iconColumn setDataView:iconView];
[iconColumn setResizingMask:CPTableColumnNoResizing];
//[tableView2 addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
var textDataView = [CPTextField new];
[textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];
[textDataView setValue:[CPFont systemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateHighlighted];
var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
for (var i = 1; i <= 3; i++)
{
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
[column setSortDescriptorPrototype:desc];
[[column headerView] setStringValue:"Number "+i];
[column setWidth:i*75];
[column setMinWidth:50.0];
[column setDataView:textDataView];
[column setEditable:YES];
[tableView2 addTableColumn:column];
@@ -121,8 +153,14 @@ tableTestDragType = @"CPTableViewTestDragType";
[[window2 contentView] addSubview:scrollView];
//[scrollView setAutohidesScrollers:YES];
[scrollView setAutohidesScrollers:YES];
[tableView2 setDelegate:self];
[tableView2 setDataSource:self];
[tableView2 setVerticalMotionCanBeginDrag:NO];
[tableView2 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView2 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];
[window2 orderFront:self];
}
@@ -138,19 +176,19 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView3 setUsesAlternatingRowBackgroundColors:NO];
[tableView3 setGridStyleMask:CPTableViewGridNone];
[tableView3 setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleSourceList];
[tableView3 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
[tableView3 setVerticalMotionCanBeginDrag:NO];
[tableView3 setDelegate:self];
[tableView3 setDataSource:self];
var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist"];
[[column headerView] setStringValue:"Source List"];
[column setWidth:200.0];
[column setMinWidth:50.0];
[column setEditable:YES];
[tableView3 addTableColumn:column];
[tableView3 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
var scrollView3 = [[CPScrollView alloc] initWithFrame:[[window3 contentView] bounds]];
[tableView3 setRowHeight:32.0];
[scrollView3 setDocumentView:tableView3];
@@ -159,8 +197,15 @@ tableTestDragType = @"CPTableViewTestDragType";
[[window3 contentView] addSubview:scrollView3];
[scrollView3 setAutohidesScrollers:YES];
[window3 orderFront:self];
[tableView3 setDelegate:self];
[tableView3 setDataSource:self];
[tableView3 setVerticalMotionCanBeginDrag:NO];
//[tableView3 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
//[tableView3 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];*/
[window3 orderFront:self];
}
- (int)numberOfRowsInTableView:(CPTableView)atableView
@@ -173,30 +218,37 @@ tableTestDragType = @"CPTableViewTestDragType";
return dataSet3.length;
}
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRow
- (id)tableView:(CPTableView)atableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if ([aColumn identifier] === "icons")
return iconImage;
if (aTableView === tableView)
return String(dataSet1[aRow]);
else if (aTableView === tableView2)
return String(dataSet2[aRow]);
else if(aTableView === tableView3)
return String(dataSet3[row]);
if(atableView === tableView)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet1[row]);
}
else if(atableView === tableView2)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet2[row]);
}
else if(atableView === tableView3)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet3[row]);
}
}
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
- (id)tableView:(CPTableView)tableView heightOfRow:(int)row
{
CPLogConsole(_cmd + [oldDescriptors description]);
var newDescriptors = [aTableView sortDescriptors];
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
[aTableView reloadData];
return 50;
}
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification
{
CPLog.debug(@"changing! %@", [aNotification description]);
@@ -209,13 +261,13 @@ tableTestDragType = @"CPTableViewTestDragType";
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
{
CPLog.debug(@"tableView:shouldSelectRow");
//CPLog.debug(@"tableView:shouldSelectRow");
return true;
}
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
{
CPLog.debug(@"selectionShouldChangeInTableView");
//CPLog.debug(@"selectionShouldChangeInTableView");
return YES;
}
@@ -233,6 +285,14 @@ tableTestDragType = @"CPTableViewTestDragType";
{
CPLogConsole(_cmd + [notification description]);
}
//- (CPIndexSet)tableView:(CPTableView)tableView selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes
//{
// CPLog.debug(@"selectionIndexesForProposedSelection %@", [proposedSelectionIndexes description]);
// return proposedSelectionIndexes;
//}
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if(aTableView === tableView3)
@@ -345,7 +405,7 @@ tableTestDragType = @"CPTableViewTestDragType";
- (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn
{
CPLog.debug("table: "+aTableView+" clicked column: "+aColumn);
console.log("table: "+aTableView+" clicked column: "+aColumn);
}
@end
-29
View File
@@ -60,33 +60,4 @@
}
}
- (void)testPeriods
{
var URLStrings =
{
"." : "./",
"./" : "./",
".//" : "./",
"/." : "/",
"/./" : "/",
"/.//" : "/",
"./a/" : "a/",
"./a" : "a",
".." : "../",
"../" : "../",
"..//" : "../",
"/.." : "/",
"/../" : "/",
"/..//" : "/",
"../a/" : "../a/",
"../a" : "../a"
};
var URLString;
for (URLString in URLStrings)
if (URLStrings.hasOwnProperty(URLString))
[self assert:new CFURL(URLString).absoluteString() equals:URLStrings[URLString]];
}
@end
+95
View File
@@ -0,0 +1,95 @@
@implementation CPLogTest : OJTestCase
- (void)testCPLogAll
{
var last = null;
var testLogger = function(message, level, title) { last = arguments; }
var log = CPLog.createLogger("asdf");
log.register(testLogger);
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
last = null;
log[level](level);
[self assert:last[0] equals:[level]];
[self assert:last[1] equals:level];
[self assert:last[2] equals:"asdf"];
});
}
- (void)testCPLogSingle
{
var last = null;
var testLogger = function(message, level, title) { last = arguments; }
var log = CPLog.createLogger();
log.registerSingle(testLogger, "info");
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
last = null;
log[level](level);
if (level === "info")
[self assert:last[0] equals:[level]];
else
[self assert:last equals:null];
});
}
- (void)testCPLogRange
{
var last = null;
var testLogger = function(message, level, title) { last = arguments; }
var log = CPLog.createLogger();
log.registerRange(testLogger, "warn", "debug");
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
last = null;
log[level](level);
if (level === "warn" || level === "info" || level === "debug")
[self assert:last[0] equals:[level]];
else
[self assert:last equals:null];
});
}
- (void)testCPLogUnregister
{
var last = null;
var testLogger = function(message, level, title) { last = arguments; }
var log = CPLog.createLogger();
log.register(testLogger);
log.unregister(testLogger);
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
last = null;
log[level](level);
[self assert:last equals:null];
});
}
- (void)testCPLogSetTitle
{
var last = null;
var testLogger = function(message, level, title) { last = arguments; }
var log = CPLog.createLogger();
log.register(testLogger);
CPLog.setDefaultTitle("A")
log("");
[self assert:last[2] equals:"A"];
CPLog.setDefaultTitle("B")
log("");
[self assert:last[2] equals:"B"];
}
@end
-10
View File
@@ -1,10 +0,0 @@
#!/bin/sh
PACKAGE_BRANCH="nightly" jake push-packages
code=$?
if [ $code -ne 0 ]; then
echo "NIGHTLY BUILD PUSH FAILED ($code)"
exit $code
else
echo "NIGHTLY BUILD PUSH SUCCEEDED"
fi
+11 -8
View File
@@ -1,12 +1,11 @@
#!/bin/bash
project_home="$(dirname "$PWD")"
extras="$project_home/ci-extra.sh"
export PATH="$HOME/narwhal/bin:$PATH"
export CAPP_AUTO_UPGRADE="yes"
export CAPP_BUILD="$project_home/build_incremental"
export CAPP_BUILD=$project_home/build_incremental
time jake test
code=$?
if [ $code -ne 0 ]; then
@@ -16,8 +15,8 @@ else
echo "INCREMENTAL BUILD SUCCEEDED"
fi
export CAPP_BUILD="$project_home/build_clean"
rm -rf "$CAPP_BUILD"
export CAPP_BUILD=$project_home/build_clean
rm -rf $CAPP_BUILD
time jake CommonJS test
code=$?
@@ -28,9 +27,13 @@ else
echo "CLEAN BUILD SUCCEEDED"
fi
# run any additional ci commands not common to all branches (like nightly builds)
if [ -f "$extras" ]; then
source "$extras"
PACKAGE_BRANCH="nightly" jake push-packages
code=$?
if [ $code -ne 0 ]; then
echo "NIGHTLY BUILD PUSH FAILED ($code)"
exit $code
else
echo "NIGHTLY BUILD PUSH SUCCEEDED"
fi
exit 0
exit 0
-6
View File
@@ -1,6 +0,0 @@
Project.configure do |project|
project.email_notifier.emails = ['objjbuild@googlegroups.com']
project.build_command = 'Tools/Scripts/ci.sh'
end
+1 -1
View File
@@ -14,7 +14,7 @@ app ("capp", function(cappTask)
cappTask.setSummary("Setup up Cappuccino projects");
cappTask.setIdentifier("com.280n.capp");
cappTask.setLicense(BundleTask.License.LGPL_v2_1);
cappTask.setVersion(getCappuccinoVersion());
cappTask.setVersion("0.8.0");
cappTask.setSources(new FileList("*.j"));
cappTask.setResources(new FileList("Resources/*"));
cappTask.setIncludesNibsAndXibs(true);
@@ -27,7 +27,7 @@ app ("__project.nameasidentifier__", function(task)
task.setEmail("__organization.email__");
task.setSummary("__project.name__");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setResources(new FileList("Resources/*"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
@@ -39,9 +39,9 @@ app ("__project.nameasidentifier__", function(task)
function printResults(configuration)
{
print("----------------------------");
print("----------------------------")
print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__"));
print("----------------------------");
print("----------------------------")
}
task ("default", ["__project.nameasidentifier__"], function()
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index-debug.html
__project.name__
@@ -10,41 +11,34 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>__project.name__</title>
<script type="text/javascript">
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript" charset="UTF-8"></script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<script type="text/javascript">
<script type = "text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script>
<style type="text/css">
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -63,8 +57,8 @@
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index.html
__project.name__
@@ -10,18 +11,18 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>__project.name__</title>
<script type="text/javascript">
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type="text/css">
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -40,8 +41,8 @@
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
@@ -27,7 +27,7 @@ app ("__project.nameasidentifier__", function(task)
task.setEmail("__organization.email__");
task.setSummary("__project.name__");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setResources(new FileList("Resources/*"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/");
@@ -40,9 +40,9 @@ app ("__project.nameasidentifier__", function(task)
function printResults(configuration)
{
print("----------------------------");
print("----------------------------")
print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__"));
print("----------------------------");
print("----------------------------")
}
task ("default", ["__project.nameasidentifier__"], function()
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index-debug.html
__project.name__
@@ -10,41 +11,19 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>__project.name__</title>
<script type="text/javascript">
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script>
<style type="text/css">
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -63,8 +42,8 @@
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index.html
__project.name__
@@ -10,18 +11,18 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>__project.name__</title>
<script type="text/javascript">
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type="text/css">
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -40,8 +41,8 @@
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index-debug.html
__project.name__
@@ -10,19 +11,19 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>__project.name__</title>
<script type="text/javascript">
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type="text/css">
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -41,8 +42,8 @@
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index.html
__project.name__
@@ -10,18 +11,18 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>__project.name__</title>
<script type="text/javascript">
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type="text/css">
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -40,8 +41,8 @@
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
+1 -1
View File
@@ -22,7 +22,7 @@ function main(args)
switch (argument)
{
case "version":
case "--version": return print(require("cappuccino").fullVersionString());
case "--version": return print("capp version 0.8.0");
case "-h":
case "--help": return printUsage();
+1 -1
View File
@@ -13,7 +13,7 @@ app ("nib2cib", function(nib2cibTask)
nib2cibTask.setIdentifier("com.280n.nib2cib");
nib2cibTask.setLicense(BundleTask.License.LGPL_v2_1);
nib2cibTask.setVersion(getCappuccinoVersion());
nib2cibTask.setVersion("0.8.0");
nib2cibTask.setAuthor("280 North, Inc.");
nib2cibTask.setEmail("feedback @nospam@ 280north.com");
nib2cibTask.setSummary("nib2cib converts Cocoa nib and xibs to Cappuccino cibs");
+1 -5
View File
@@ -45,11 +45,7 @@
- (id)initWithCoder:(CPCoder)aCoder
{
self = [self NS_initWithCoder:aCoder];
[self _initWithFrame:[self frame]];
return self;
return [self NS_initWithCoder:aCoder];
}
- (Class)classForKeyedArchiver
+1 -1
View File
@@ -37,7 +37,7 @@
//var dataViewCell = [aCoder decodeObjectForKey:@"NSDataCell"];
_dataView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()];
[_dataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_dataView setValue:[CPColor whiteColor] forThemeAttribute:"text-color" inState:CPThemeStateHighlighted];
var headerCell = [aCoder decodeObjectForKey:@"NSHeaderCell"],
headerView = [[_CPTableColumnHeaderView alloc] initWithFrame:CPRectMakeZero()];
+1 -7
View File
@@ -29,13 +29,7 @@
if (self = [super NS_initWithCoder:aCoder])
{
_tableView = [aCoder decodeObjectForKey:"NSTableView"];
// change the default height
if (_bounds.size.height === 17)
{
_bounds.size.height = 23;
_frame.size.height = 23;
}
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
return self;
+6 -10
View File
@@ -35,21 +35,18 @@
//_dataSource = [aCoder decodeObjectForKey:CPTableViewDataSourceKey];
//_delegate = [aCoder decodeObjectForKey:CPTableViewDelegateKey];
_headerView = [aCoder decodeObjectForKey:@"NSHeaderView"];
_cornerView = [aCoder decodeObjectForKey:@"NSCornerView"];
_tableColumns = [aCoder decodeObjectForKey:@"NSTableColumns"];
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
_rowHeight = [aCoder decodeFloatForKey:@"NSRowHeight"];
// Convert xib default to cib default
if (_rowHeight == 17)
_rowHeight = 23;
if ([_gridColor isEqual:[CPColor colorWithRed:127.0 / 255.0 green:127.0 / 255.0 blue:127.0 / 255.0 alpha:1.0]])
_gridColor = [CPColor colorWithRed:229.0 / 255.0 green:229.0 / 255.0 blue:229.0 / 255.0 alpha:1.0];
_headerView = [aCoder decodeObjectForKey:@"NSHeaderView"];
_cornerView = [aCoder decodeObjectForKey:@"NSCornerView"];
_tableColumns = [aCoder decodeObjectForKey:@"NSTableColumns"];
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
_intercellSpacing = CGSizeMake(0.0, 0.0);//CGSizeMake([aCoder decodeFloatForKey:"NSIntercellSpacingWidth"], [aCoder decodeFloatForKey:"NSIntercellSpacingHeight"]);
@@ -57,7 +54,6 @@
_gridStyleMask = [aCoder decodeIntForKey:@"NSGridStyleMask"];
_usesAlternatingRowBackgroundColors = (flags & 0x00800000) ? YES : NO;
_alternatingRowBackgroundColors =[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]];
_allowsMultipleSelection = (flags & 0x08000000) ? YES : NO;
_allowsEmptySelection = (flags & 0x10000000) ? YES : NO;
+1 -8
View File
@@ -37,14 +37,7 @@
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
_frame.size.height = 23.0;
_bounds.size.height = 23.0;
}
return self;
return [self NS_initWithCoder:aCoder];
}
- (Class)classForKeyedArchiver
-26
View File
@@ -78,32 +78,6 @@ function check_and_exit () {
fi
}
function check_build_environment () {
# make sure user is running HotSpot JVM
java -version 2>&1 | grep HotSpot &> /dev/null
if [ ! "$?" = "0" ]; then
java_ver=`java -version 2>&1 | egrep "(Client|Server)"`
if [ "$java_ver" = "" ]; then
java_ver="your JVM"
fi
echo "Error: Narwhal is not compatible with $java_ver. Please switch to the Sun (HotSpot) JVM and re-run bootstrap.sh."
exit 1
fi
# make sure other dependencies are installed and on the $PATH
OTHER_DEPS=(gcc unzip curl)
for dep in ${OTHER_DEPS[@]}; do
which "$dep" &> /dev/null
if [ ! "$?" = "0" ]; then
echo "Error: $dep is required to build Cappuccino. Please install $dep and re-run bootstrap.sh."
exit 1
fi
done
}
check_build_environment
if [ -w "/usr/local" ]; then
default_directory="/usr/local/narwhal"
else
-26
View File
@@ -2,7 +2,6 @@ var SYSTEM = require("system");
var FILE = require("file");
var OS = require("os");
var UTIL = require("util");
var stream = require("term").stream;
var requiresSudo = false;
@@ -289,31 +288,6 @@ global.symlink_executable = function(source)
FILE.symlink(relative, destination);
}
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) {
var pkg = JSON.parse(FILE.read(packagePath, { charset : "UTF-8" }));
var p = OS.popen(["git", "rev-parse", "--verify", "HEAD"]);
if (p.wait() === 0) {
var sha = p.stdout.read().split("\n")[0];
if (sha.length === 40)
pkg["cappuccino-revision"] = sha;
}
pkg["cappuccino-timestamp"] = new Date().getTime();
pkg["version"] = getCappuccinoVersion();
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
FILE.write(packagePath, JSON.stringify(pkg, null, 4), { charset : "UTF-8" });
}
global.subtasks = function(subprojects, taskNames)
{
taskNames.forEach(function(aTaskName)
-3
View File
@@ -1,3 +0,0 @@
{
"version": "0.8.0"
}