Compare commits

..
35 Commits
Author SHA1 Message Date
Randall Luecke 8d824ddf53 Fixed bug with nib2cib tableviews loading incorrect resources. 2010-03-14 17:26:26 -04:00
Ross Boucher eee6a1926c A few minor bug fixes for key/main window handling. 2010-03-13 22:48:32 -08:00
Tom Robinson 60e2be5da9 Add CFHTTPRequest and FileExecutable hooks for inlining files and module functions (for flatten). Removed hook used by flatten. 2010-03-13 21:51:28 -08:00
Tom Robinson 956ef29449 Change FileRequest to always use CFHTTPRequest and make async/sync configurable. Preparation for "flatten" changes. 2010-03-13 21:51:19 -08:00
Tom Robinson 7bc8c643a5 Update flatten to use new file/function caching system. 2010-03-13 21:50:51 -08:00
Tom Robinson 2b56811f4c Cleanup flatten, use resourceAtURL instead of manually walking path. 2010-03-13 21:50:42 -08:00
Randall Luecke 65722739d7 Fixes flickering issues with CPTableView if you hold the command key and drag. Closes #544 2010-03-13 00:10:12 -05:00
Ross Boucher a33b712219 Don't encode the search/cancel buttons. They add bloat and complicate the process. 2010-03-12 19:44:18 -08:00
Ross Boucher f5a1b90558 Fix nib2cib support for CPSearchField 2010-03-12 18:45:40 -08:00
Tom Robinson 948a5a7c39 Updated flatten to work with new loader changes. 2010-03-12 12:19:24 -08:00
Tom Robinson 4e650d61c8 Fix CFBundle path deprecation warning and absoluteString not found. 2010-03-12 12:19:16 -08:00
Ross Boucher ed66d78585 Update the template files to more modern standards. 2010-03-11 14:27:15 -08:00
Ross Boucher 39e1514620 temporary fix for whiteSpace style issue in IE. 2010-03-11 14:18:24 -08:00
Randall Luecke 672be3991d Merge branch '0.8.0' of git://github.com/280north/cappuccino into 0.8.0 2010-03-09 23:49:03 -05:00
Randall Luecke b350c2be91 Fixed previous commit so it doesn't break buttons in the tableview. 2010-03-09 19:19:25 -05:00
Tom Robinson 68ab5bd4e7 Typo in CI script. 2010-03-09 16:12:13 -08:00
Tom Robinson 9cca7ead17 Factor out nightly build portion of CI script so not all branches push builds 2010-03-09 15:35:53 -08:00
Randall Luecke 6d353f378d Fixed bug where editable tableview would not honor setEditable:NO for columns unless resized. closes #426 2010-03-09 14:43:12 -05:00
appdenandRandall Luecke 67def34e29 Added semi-colons to global vars and removed accidental gloabl variable. 2010-03-09 03:22:02 -05:00
Tom Robinson 3e7c3e952b Merge branch '0.8.0' of github.com:280north/cappuccino into 0.8.0 2010-03-08 19:03:14 -08:00
Francisco Ryan Tolmasky I e6411d7d90 Fix for classes declared in subfolders reporting wrong bundle (fictional).
Reviewed by me.
2010-03-08 18:27:43 -08:00
Francisco Ryan Tolmasky I 9e7d0d3183 Merge branch 'master' of git@github.com:280north/cappuccino 2010-03-08 18:23:36 -08:00
Francisco Ryan Tolmasky I 3ae4b1cf19 Fix for classes declared in subfolders reporting wrong bundle (fictional).
Reviewed by me.
2010-03-08 18:22:53 -08:00
Ross Boucher 2841223c9d Create the args and namedArgs objects in Bootstrap.js, pass them along up to CPApplication. 2010-03-08 15:14:09 -08:00
Tom Robinson ba713b8b06 Use getCappuccinoVersion() in various Jakefiles instead of hardcoded versions. 2010-03-08 15:10:08 -08:00
Tom Robinson c53bff288a Add a central version.json file. Change package building to insert version, revision, and timestamp. Auto-push tags. 2010-03-08 15:10:08 -08:00
Ross Boucher d85e8798c2 Create the args and namedArgs objects in Bootstrap.js, pass them along up to CPApplication. 2010-03-08 15:00:52 -08:00
Randall Luecke 6dbb4eedb7 Merge branch 'master' of git://github.com/280north/cappuccino 2010-03-08 10:56:56 -05:00
Francisco Ryan Tolmasky I 33b4b94426 Fix for loading bundles generating multiple did load callbacks.
Reviewed by me.
2010-03-08 01:03:52 -08:00
Randall Luecke 8410198c37 Merge branch 'master' of git://github.com/280north/cappuccino 2010-03-08 00:58:28 -05:00
Randall Luecke 4c4b42833a Added -selectedColumn to the tableview. 2010-03-08 00:00:28 -05:00
Randall Luecke 519a9300e2 Merge branch 'master' of git://github.com/280north/cappuccino 2010-03-07 23:39:41 -05:00
Randall Luecke 7522751fd2 Merge branch 'master' of git://github.com/280north/cappuccino 2010-03-07 20:50:29 -05:00
Randall Luecke f2165af48f Merge branch 'master' of git://github.com/280north/cappuccino 2010-03-07 10:30:17 -05:00
Randall Luecke e3a65a1847 Added preparatory support for group items in CPOutlineView. 2010-03-06 18:46:49 -05:00
42 changed files with 827 additions and 736 deletions
+18 -35
View File
@@ -860,12 +860,11 @@ 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;
}
@@ -973,10 +972,9 @@ CPRunContinuesResponse = -1002;
[self endSheet:sheet returnCode:0];
}
- (CPArray)arguments
{
if(_fullArgsString != window.location.hash)
if(_fullArgsString !== window.location.hash)
[self _reloadArguments];
return _args;
@@ -1009,12 +1007,18 @@ CPRunContinuesResponse = -1002;
- (void)_reloadArguments
{
_fullArgsString = window.location.hash;
var args = _fullArgsString.replace("#", "").split("/").slice(0);
for(var i=0, count = args.length; i<count; i++)
args[i] = decodeURIComponent(args[i]);
_args = args;
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 = [];
}
- (CPDictionary)namedArguments
@@ -1058,7 +1062,7 @@ CPRunContinuesResponse = -1002;
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
[[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work
[[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
_previousMainWindow = nil;
@@ -1143,29 +1147,8 @@ function CPApplicationMain(args, namedArgs)
[principalClass sharedApplication];
//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)];
}
}
if ([args containsObject:"debug"])
CPLogRegister(CPLogPopup);
CPApp._args = args;
CPApp._namedArgs = namedArgs;
+13 -3
View File
@@ -52,9 +52,10 @@ 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_willDisplayView_forTableColumn_item_ = 1 << 4,
CPOutlineViewDelegate_outlineView_isGroupItem_ = 1 << 5;
CPOutlineViewDropOnItemIndex = -1;
@@ -468,7 +469,10 @@ 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
@@ -1020,7 +1024,13 @@ 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
+56 -80
View File
@@ -24,26 +24,10 @@
#include "Platform/Platform.h"
/*!
@global
@group Menu tags
*/
CPSearchFieldRecentsTitleMenuItemTag = 1000;
/*!
@global
@group Menu tags
*/
CPSearchFieldRecentsMenuItemTag = 1001;
/*!
@global
@group Menu tags
*/
CPSearchFieldClearRecentsMenuItemTag = 1002;
/*!
@global
@group Menu tags
*/
CPSearchFieldNoRecentsMenuItemTag = 1003;
CPSearchFieldRecentsTitleMenuItemTag = 1000;
CPSearchFieldRecentsMenuItemTag = 1001;
CPSearchFieldClearRecentsMenuItemTag = 1002;
CPSearchFieldNoRecentsMenuItemTag = 1003;
var CPSearchFieldSearchImage = nil,
CPSearchFieldFindImage = nil,
@@ -79,64 +63,49 @@ var CPSearchFieldSearchImage = nil,
return;
var bundle = [CPBundle bundleForClass:self];
CPSearchFieldSearchImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldSearch.png"]];
CPSearchFieldFindImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldFind.png"]];
CPSearchFieldCancelImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancel.png"]];
CPSearchFieldCancelPressedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancelPressed.png"]];
CPSearchFieldSearchImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldSearch.png"] size:CGSizeMake(25, 22)];
CPSearchFieldFindImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldFind.png"] size:CGSizeMake(25, 22)];
CPSearchFieldCancelImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancel.png"] size:CGSizeMake(22, 22)];
CPSearchFieldCancelPressedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancelPressed.png"] size:CGSizeMake(22, 22)];
}
- (id)initWithFrame:(CPRect)frame
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
if (self = [super initWithFrame:frame])
{
_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;
}
- (id)copy
- (void)_initWithFrame:(CGRect)frame
{
var copy = [super copy];
[self setBezeled:YES];
[self setBezelStyle:CPTextFieldRoundedBezel];
[self setBordered:YES];
[self setEditable:YES];
[self setDelegate:self];
[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]];
_cancelButton = [[CPButton alloc] initWithFrame:CGRectMake(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
[self resetCancelButton];
[_cancelButton setHidden:YES];
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_cancelButton];
return copy;
_searchButton = [[CPButton alloc] initWithFrame:CGRectMake(5,(frame.size.height-25)/2,25,25)];
[self resetSearchButton];
[self addSubview:_searchButton];
}
// Managing Buttons
@@ -695,9 +664,7 @@ var CPSearchFieldSearchImage = nil,
@end
var CPSearchButtonKey = @"CPSearchButtonKey",
CPCancelButtonKey = @"CPCancelButtonKey",
CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey",
CPSendsSearchStringImmediatelyKey = @"CPSendsSearchStringImmediatelyKey",
CPMaximumRecentsKey = @"CPMaximumRecentsKey",
@@ -707,13 +674,20 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
- (void)encodeWithCoder:(CPCoder)coder
{
[super encodeWithCoder:coder];
[coder encodeObject:_searchButton forKey:CPSearchButtonKey];
[coder encodeObject:_cancelButton forKey:CPCancelButtonKey];
[_searchButton removeFromSuperview];
[_cancelButton removeFromSuperview];
[super encodeWithCoder:coder];
if (_searchButton)
[self addSubview:_searchButton];
if (_cancelButton)
[self addSubview:_cancelButton];
[coder encodeBool:_sendsWholeSearchString forKey:CPSendsWholeSearchStringKey];
[coder encodeBool:_sendsSearchStringImmediately forKey:CPSendsSearchStringImmediatelyKey];
[coder encodeInt:_maximumRecents forKey:CPMaximumRecentsKey];
if (_recentsAutosaveName)
[coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
if (_searchMenuTemplate)
@@ -722,21 +696,23 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
- (id)initWithCoder:(CPCoder)coder
{
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];
if (self = [super initWithCoder:coder])
{
[self _initWithFrame:[self frame]];
_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
+15 -17
View File
@@ -160,21 +160,24 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
CPTableView _tableView @accessors(property=tableView);
}
- (void)initWithFrame:(CGRect)aFrame
- (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
{
self = [super initWithFrame:aFrame];
if (self)
{
_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))]];
}
[self _init];
return self;
}
@@ -481,12 +484,7 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
{
if (self = [super initWithCoder:aCoder])
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self _init];
_tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey];
}
+26 -17
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;
@@ -194,6 +194,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
SEL _doubleAction;
unsigned _columnAutoResizingStyle;
int _lastTrackedRowIndex;
CGPoint _originalMouseDownPoint;
BOOL _verticalMotionCanDrag;
unsigned _destinationDragStyle;
@@ -878,6 +879,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
}
}
- (int)selectedColumn
{
[_selectedColumnIndexes lastIndex];
}
- (CPIndexSet)selectedColumnIndexes
{
return _selectedColumnIndexes;
@@ -1991,7 +1997,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
// Now clear all the leftovers
// FIXME: this could be faster!
for (identifier in _cachedDataViews)
for (var identifier in _cachedDataViews)
{
var dataViews = _cachedDataViews[identifier],
count = dataViews.length;
@@ -2149,12 +2155,12 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
}
}
- (void)_commitDataViewObjectValue:(CPTextView)sender
- (void)_commitDataViewObjectValue:(id)sender
{
[_dataSource tableView:self
setObjectValue:[sender objectValue]
forTableColumn:sender.tableViewEditedColumnObj
row:sender.tableViewEditedRowIndex];
[_dataSource tableView:self setObjectValue:[sender objectValue] forTableColumn:sender.tableViewEditedColumnObj row:sender.tableViewEditedRowIndex];
if ([sender respondsToSelector:@selector(setEditable:)])
[sender setEditable:NO];
}
- (CPView)_newDataViewForRow:(CPInteger)aRow tableColumn:(CPTableColumn)aTableColumn
@@ -2649,8 +2655,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
}
_isSelectingSession = YES;
if(row >= 0)
if(row >= 0 && row !== _lastTrackedRowIndex)
{
_lastTrackedRowIndex = row;
[self _updateSelectionWithMouseAtRow:row];
}
if ((_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_)
&& !_trackingPointMovedOutOfClickSlop)
+5 -7
View File
@@ -1497,7 +1497,8 @@ CPTexturedBackgroundWindowMask
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
CPApp._keyWindow = nil;
if (CPApp._keyWindow === self)
CPApp._keyWindow = nil;
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidResignKeyNotification
@@ -1858,7 +1859,8 @@ CPTexturedBackgroundWindowMask
postNotificationName:CPWindowDidResignMainNotification
object:self];
CPApp._mainWindow = nil;
if (CPApp._mainWindow === self)
CPApp._mainWindow = nil;
}
- (void)_updateMainAndKeyWindows
@@ -1866,9 +1868,6 @@ CPTexturedBackgroundWindowMask
var allWindows = [CPApp orderedWindows],
windowCount = [allWindows count];
if (!windowCount)
return;
if ([self isKeyWindow])
{
var keyWindow = [CPApp keyWindow];
@@ -1893,11 +1892,10 @@ CPTexturedBackgroundWindowMask
}
if (![CPApp keyWindow])
[keyWindow makeKeyWindow];
[menuWindow makeKeyWindow];
}
}
if ([self isMainWindow])
{
var mainWindow = [CPApp mainWindow];
+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("0.8.0");
appKitTask.setVersion(getCappuccinoVersion());
appKitTask.setLicense(BundleTask.License.LGPL_v2_1);
appKitTask.setSources(AppKitFiles);
appKitTask.setResources(new FileList("Resources/**/*"));
+23 -6
View File
@@ -67,11 +67,15 @@ var DOMSpanElement = nil,
DOMSpanElement = DOMIFrameDocument.createElement("span");
DOMSpanElement.style.position = "absolute";
DOMSpanElement.style.whiteSpace = "pre";
DOMSpanElement.style.visibility = "visible";
DOMSpanElement.style.padding = "0px";
DOMSpanElement.style.margin = "0px";
try {
DOMSpanElement.style.whiteSpace = "pre";
}
catch (e) {}
DOMDivElement.appendChild(DOMSpanElement);
}
@@ -93,16 +97,29 @@ var DOMSpanElement = nil,
if (!aWidth)
{
style.width = "";
style.whiteSpace = "pre";
try {
style.whiteSpace = "pre";
}
catch (e) {}
style.wordWrap = "normal";
}
else
{
style.width = ROUND(aWidth) + "px";
try
{
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.wordWrap = "break-word";
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
}
style.font = [aFont cssString];
+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("0.8.0");
blendKitTask.setVersion(getCappuccinoVersion());
blendKitTask.setAuthor("280 North, Inc.");
blendKitTask.setEmail("feedback @nospam@ 280north.com");
blendKitTask.setSummary("BlendKit classes for Cappuccino");
+5 -1
View File
@@ -8,7 +8,7 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
if (!FILE.isFile(aFilename))
return;
var buildFilename = FILE.join($BUILD_CONFIGURATION_DIR, "CommonJS", "cappuccino", aFilename);
var buildFilename = FILE.join($BUILD_CJS_CAPPUCCINO, aFilename);
filedir (buildFilename, [aFilename], function ()
{
@@ -27,3 +27,7 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
task ("build", buildFilename);
CLOBBER.include(buildFilename);
});
task ("build", function() {
setPackageMetadata(FILE.join($BUILD_CJS_CAPPUCCINO, "package.json"));
});
+93 -93
View File
@@ -87,22 +87,7 @@ function main(args)
flattener.load(mainPath);
flattener.finishLoading();
var rootResources = flattener.require("objective-j").StaticResource.rootResources();
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);
var applicationJS = flattener.buildApplicationJS();
FILE.copyTree(rootPath, outputPath);
@@ -115,7 +100,9 @@ function main(args)
function ObjectiveJFlattener(rootPath) {
ObjectiveJRuntimeAnalyzer.apply(this, arguments);
this.resourceBuffer = [];
this.fileCacheBuffer = [];
this.staticResourceBuffer = [];
this.bundleBuffer = [];
this.functionsBuffer = [];
@@ -124,105 +111,118 @@ function ObjectiveJFlattener(rootPath) {
ObjectiveJFlattener.prototype = Object.create(ObjectiveJRuntimeAnalyzer.prototype);
ObjectiveJFlattener.prototype.buildApplicationJS = function(applicationRoot) {
this.serializeStaticResources(applicationRoot);
this.serializeStaticFileExecutables();
ObjectiveJFlattener.prototype.buildApplicationJS = function() {
var buffer = []
this.serializeFunctions();
this.serializeFileCache();
buffer.push("(function(){");
buffer.push("var appURL = new CFURL('.', ObjectiveJ.pageURL);")
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("})();");
var buffer = [];
buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
buffer.push(this.fileCacheBuffer.join("\n"))
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(",");
ObjectiveJFlattener.prototype.serializeFunctions = function() {
var inlineFunctions = true;//this.options.inlineFunctions;
var func = aFileExecutable._function.toString();
// HACK
func = func.replace(", require, exports, module, system, print, window", "");
var outputFiles = {};
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+"));");
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), "+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.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");");
}
}
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()) + ");");
ObjectiveJFlattener.prototype.serializeFileCache = function() {
Object.keys(this.requestedURLs).forEach(function(absolute) {
var relative = this.rootPath.relative(absolute).toString();
if (relative.indexOf("..") === 0)
{
print("skipping (parent of app root): " + absolute);
return;
}
}
// 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 {
this.resourceBuffer.push("newNode = applicationRoot;");
}
if (FILE.isFile(absolute))
{
if (FILE.extension(absolute) === ".sj")
{
print("skipping (bundle executable): " + absolute);
return;
}
// if (this.options.maxCachedSize && FILE.size(absolute) > this.options.maxCachedSize)
// {
// print("skipping (larger than "+this.options.maxCachedSize+" bytes): " + absolute);
// return;
// }
// var contents = node.contents();
// if (contents) {
// this.resourceBuffer.push("newNode._contents = " + JSON.stringify(contents) + ";");
// }
if (!node.children())
return;
this.resourceBuffer.push("nodeStack.push(currentNode);");
this.resourceBuffer.push("currentNode = newNode;");
var children = node.children();
for (var name in children) {
this.serializeStaticResources(children[name], depth+1);
}
this.resourceBuffer.push("currentNode = nodeStack.pop();");
print("caching: " + absolute);
var contents = FILE.read(absolute, { charset : "UTF-8" });
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");");
} else {
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 404);");
}
}, this);
}
// "$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"></script>';
// enable CPLog:
// scriptTagsAfter = '$1<script type = "text/javascript">\n$1 CPLogRegister(CPLogConsole);\n$1</script>\n' + scriptTagsAfter;
function rewriteMainHTML(indexHTMLPath) {
if (indexHTMLPath.isFile()) {
var indexHTML = indexHTMLPath.read();
+23
View File
@@ -0,0 +1,23 @@
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,6 +5,8 @@ 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);
@@ -28,6 +30,14 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
var url = this.executableURL();
return url ? url.absoluteURL().path() : null;
}
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
View File
@@ -4,7 +4,6 @@
"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": [
+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("0.8.0");
foundationTask.setVersion(getCappuccinoVersion());
foundationTask.setLicense(BundleTask.License.LGPL_v2_1);
foundationTask.setSources(new FileList("**/*.j"));
foundationTask.setResources(new FileList("Resources/**/*"));
+30 -18
View File
@@ -280,21 +280,23 @@ 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)");
FILE.mkdirs(".push-package");
var pushPackageDir = FILE.join(".push-package", remote.replace(/[^\w]/g, "_"));
if (FILE.exists(pushPackageDir))
OS.system(buildCmd([["cd", pushPackageDir], ["git", "fetch"]]));
if (packagePath.isDirectory())
OS.system(buildCmd([["cd", packagePath], ["git", "fetch"]]));
else
OS.system(["git", "clone", remote, pushPackageDir]);
OS.system(["git", "clone", remote, packagePath]);
if (OS.system(buildCmd([["cd", pushPackageDir], ["git", "checkout", "origin/"+branch]]))) {
if (OS.system(buildCmd([["cd", packagePath], ["git", "checkout", "origin/"+branch]]))) {
if (OS.system(buildCmd([
["cd", pushPackageDir],
["cd", packagePath],
["git", "symbolic-ref", "HEAD", "refs/heads/"+branch],
["rm", ".git/index"],
["git", "clean", "-fdx"]
@@ -302,20 +304,30 @@ function pushPackage(path, remote, branch)
throw "pushPackage failed";
}
if (OS.system("cd "+OS.enquote(pushPackageDir)+" && git rm --ignore-unmatch -r * && rm -rf *"))
if (OS.system("cd "+OS.enquote(packagePath)+" && git rm --ignore-unmatch -r * && rm -rf *"))
throw "pushPackage failed";
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(pushPackageDir)+"/."))
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(packagePath)+"/."))
throw "pushPackage failed";
OS.system(buildCmd([
["cd", pushPackageDir],
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],
["git", "add", "."],
["git", "commit", "-m", "Pushed on " + new Date()]
]));
["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));
if (OS.system(buildCmd([
["cd", pushPackageDir],
["git", "push", "origin", "HEAD:"+branch]
["cd", packagePath],
["git", "push", "--tags", "origin", "HEAD:"+branch]
])))
throw "pushPackage failed";
}
+30 -1
View File
@@ -81,7 +81,36 @@ function resolveMainBundleURL()
Executable.fileImporterForURL(mainBundleURL)(mainFileURL.lastPathComponent(), YES, function()
{
disableCFURLCaching();
afterDocumentLoad(main);
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);
});
});
});
}
+58 -5
View File
@@ -49,6 +49,7 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
this._resourcesDirectoryURL = new CFURL("Resources/", aURL);
this._staticResource = NULL;
this._isValid = NO;
this._loadStatus = CFBundleUnloaded;
this._loadRequests = [];
@@ -58,34 +59,47 @@ 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));
while (aURL.path() !== "/")
{
var bundle = CFBundlesForURLStrings[aURL.absoluteString()];
var previousURLString,
URLString = aURL.absoluteString();
if (bundle)
while (!previousURLString || previousURLString !== URLString)
{
var bundle = CFBundlesForURLStrings[URLString];
if (bundle && bundle._isValid)
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)
@@ -97,16 +111,22 @@ 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)
@@ -120,6 +140,8 @@ CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ a
return resourceURL.absoluteURL();
}
DISPLAY_NAME(CFBundle.prototype.resourceURL);
CFBundle.prototype.mostEligibleEnvironmentURL = function()
{
if (this._mostEligibleEnvironmentURL === undefined)
@@ -128,6 +150,8 @@ CFBundle.prototype.mostEligibleEnvironmentURL = function()
return this._mostEligibleEnvironmentURL;
}
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironmentURL);
CFBundle.prototype.executableURL = function()
{
if (this._executableURL === undefined)
@@ -143,16 +167,22 @@ 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") || [],
@@ -166,11 +196,15 @@ 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();
@@ -194,11 +228,15 @@ 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)
@@ -223,7 +261,13 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
function onsuccess(/*Event*/ anEvent)
{
self._loadStatus &= ~CFBundleLoadingInfoPlist;
self._infoDictionary = anEvent.request.responsePropertyList();
var infoDictionary = anEvent.request.responsePropertyList();
self._isValid = !!infoDictionary || CFBundle.mainBundle() === self;
if (infoDictionary)
self._infoDictionary = infoDictionary;
if (!self._infoDictionary)
{
@@ -240,6 +284,7 @@ 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() + "\""));
@@ -249,6 +294,8 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
});
}
DISPLAY_NAME(CFBundle.prototype.load);
function finishBundleLoadingWithError(/*CFBundle*/ aBundle, /*Event*/ anError)
{
resolveStaticResource(aBundle._staticResource);
@@ -615,16 +662,22 @@ 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();
+62 -27
View File
@@ -196,9 +196,14 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
return this._nativeRequest.overrideMimeType(aMimeType);
}
CFHTTPRequest.prototype.open = function(/*...*/)
CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password)
{
return this._nativeRequest.open(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
var cachedRequest = CFHTTPRequest._lookupCachedRequest(url);
if (cachedRequest) {
cachedRequest.onreadystatechange = this._nativeRequest.onreadystatechange;
this._nativeRequest = cachedRequest;
}
return this._nativeRequest.open(method, url, async, user, password);
}
CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
@@ -254,43 +259,73 @@ 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");
request.open("GET", aURL.absoluteString(), YES);
if (FileRequest.async)
{
request.onsuccess = Asynchronous(onsuccess);
request.onfailure = Asynchronous(onfailure);
}
else
{
request.onsuccess = onsuccess;
request.onfailure = onfailure;
}
request.open("GET", aURL.absoluteString(), FileRequest.async);
request.send("");
}
#ifdef BROWSER
FileRequest.async = YES;
#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 });
FileRequest.async = NO;
#endif
var URLCache = { };
CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
URLCache[aURL] = new MockXMLHttpRequest(status, headers, body);
}
#ifdef COMMONJS
FileRequest.prototype.responseText = function()
CFHTTPRequest._lookupCachedRequest = function(/*CFURL|String*/ aURL)
{
return this._responseText;
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return URLCache[aURL];
}
FileRequest.prototype.responseXML = function()
function MockXMLHttpRequest(status, headers, body)
{
return new DOMParser().parseFromString(anXMLString, "text/xml");
}
FileRequest.prototype.responsePropertyList = function()
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)
{
return CFPropertyList.propertyListFromString(this.responseText());
}
#endif
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 ? 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) {};
+180 -251
View File
@@ -20,175 +20,107 @@
* 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;
// defaults:
var _CPLogRegistrations = {};
var CPLogDefaultTitle = "Cappuccino";
var CPLogDefaultLevel = CPLogLevels[3];
var CPLogDefaultFormatter = function(aParameters, aLevel, aTitle, useColor)
// Register Functions:
// Register a logger for all levels, or up to an optional max level
GLOBAL(CPLogRegister) = function(aProvider, aMaxLevel)
{
var color = useColor && defaultFormatterColorMap[aLevel];
var important = {"fatal":true,"error":true,"warn":true}[aLevel];
// for unimportant messages colorize just the level
if (!important && color)
aLevel = "\0"+color+"(" + aLevel + "\0)";
aLevel = aLevel ? ' [' + aLevel + ']' : '';
// use sprintf if param 0 is a string and there is more than one param. otherwise just convert param 0 to a string
var aString = (typeof aParameters[0] === "string" && aParameters.length > 1) ? exports.sprintf.apply(null, aParameters) : String(aParameters[0]);
var now = new Date();
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);
// for important messages colorize entire message
if (important && color)
message = "\0"+color+"(" + message + "\0)";
return message;
CPLogRegisterRange(aProvider, CPLogLevels[0], aMaxLevel || CPLogLevels[CPLogLevels.length-1]);
}
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)
// Register a logger for a range of levels
GLOBAL(CPLogRegisterRange) = function(aProvider, aMinLevel, aMaxLevel)
{
// public
var min = _CPLogLevelsInverted[aMinLevel];
var max = _CPLogLevelsInverted[aMaxLevel];
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;
if (min !== undefined && max !== undefined)
for (var i = 0; i <= max; i++)
CPLogRegisterSingle(aProvider, CPLogLevels[i]);
}
// 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
// (possibly available in CommonJS environments?)
function CPLogConsoleCreate(formatter)
// Register a logger for a single level
GLOBAL(CPLogRegisterSingle) = function(aProvider, aLevel)
{
return function(aString, aLevel, aTitle) {
if (typeof console === "undefined")
if (!_CPLogRegistrations[aLevel])
_CPLogRegistrations[aLevel] = [];
// prevent duplicate registrations
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
if (_CPLogRegistrations[aLevel][i] === aProvider)
return;
var message = (formatter || CPLogDefaultFormatter)(aString, aLevel, aTitle, false);
_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);
}
// 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 + ']' );
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;
}
// Loggers:
// CPLogConsole uses the built in "console" object
GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle)
{
if (typeof console != "undefined")
{
var message = _CPFormatLogMessage(aString, aLevel, aTitle);
var logger = {
"fatal": "error",
"error": "error",
@@ -196,109 +128,107 @@ function CPLogConsoleCreate(formatter)
"info": "info",
"debug": "debug",
"trace": "debug"
}[aLevel] || "log";
if (console[logger])
}[aLevel];
if (logger && console[logger])
console[logger](message);
else if (console.log)
console.log(message);
}
}
GLOBAL(CPLogConsole) = CPLogConsoleCreate();
CPLogConsole.create = CPLogConsoleCreate;
// CommonJS specific loggers
#if COMMONJS
// CPLogPrint uses STDOUT to print to console
function CPLogPrintCreate(formatter, stream, useColor)
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)
{
if (!stream) {
if (stream === undefined) {
try {
stream = require("term").stream;
useColor = true;
} catch (e) {
useColor = false;
if (typeof print != "undefined")
stream = { print : print };
stream = null;
}
}
return function(aParameters, aLevel, aTitle) {
var message = (formatter || CPLogDefaultFormatter)(aParameters, aLevel, aTitle, useColor);
stream.print(message);
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))
}
}
GLOBAL(CPLogPrint) = CPLogPrintCreate();
CPLogPrint.create = CPLogPrintCreate;
// Browser specific loggers
#else
// TODO: should this not be global?
GLOBAL(CPLogDisable) = false;
// CPLogAlert uses basic browser confirm()
function CPLogAlertCreate(formatter)
// CPLogAlert uses basic browser alert() functions
GLOBAL(CPLogAlert) = function(aString, aLevel, aTitle)
{
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)");
}
if (typeof alert != "undefined" && !CPLogDisable)
{
var message = _CPFormatLogMessage(aString, aLevel, aTitle);
CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)");
}
}
GLOBAL(CPLogAlert) = CPLogAlertCreate();
CPLogAlert.create = CPLogAlertCreate;
// CPLogPopup uses a slick popup window in the browser
// TODO: move this into DebugKit
function CPLogPopupCreate(formatter)
// CPLogPopup uses a slick popup window in the browser:
var CPLogWindow = null;
GLOBAL(CPLogPopup) = function(aString, aLevel, aTitle)
{
var logWindow = null;
return function(aParameters, aLevel, aTitle) {
var message = (formatter || CPLogDefaultFormatter)(aString, null, aTitle);
try {
if (CPLogDisable || window.open == undefined)
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;
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
_CPLogInitPopup(CPLogWindow);
}
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(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;} \
@@ -318,24 +248,30 @@ 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 _CPLogPopupInit(logWindow)
function _CPLogInitPopup(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]);
@@ -345,35 +281,35 @@ function _CPLogPopupInit(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);
@@ -383,17 +319,17 @@ function _CPLogPopupInit(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;
@@ -404,7 +340,7 @@ function _CPLogPopupInit(logWindow)
e.preventDefault();
}
}, "false");
// Parent closing
window.addEventListener("unload", function() {
if (logWindow && logWindow.closeEnabled && logWindow.closeEnabled.checked) {
@@ -412,7 +348,7 @@ function _CPLogPopupInit(logWindow)
logWindow.close();
}
}, false);
// Log popup closing
logWindow.addEventListener("unload", function() {
if (!CPLogDisable) {
@@ -421,10 +357,3 @@ function _CPLogPopupInit(logWindow)
}, false);
}
#endif
// guess a good default logger:
#if COMMONJS
GLOBAL(CPLogDefault) = CPLogPrint;
#else
GLOBAL(CPLogDefault) = (typeof console !== "undefined") ? CPLogConsole : CPLogPopup;
#endif
+30 -1
View File
@@ -1,5 +1,7 @@
var FILE = require("file");
var sprintf = require("printf").sprintf;
var window = exports.window = require("browser/window");
if (system.engine === "rhino")
@@ -7,7 +9,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, "..");
@@ -77,6 +79,12 @@ 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(':'));
}
@@ -178,5 +186,26 @@ 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);
-1
View File
@@ -5,7 +5,6 @@
"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/)",
+8 -4
View File
@@ -137,6 +137,7 @@ 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());
@@ -280,15 +281,18 @@ function fileExecutableSearchFinished(/*FileExecutable*/ aFileExecutable)
function fileExecutableDependencyLoadFinished()
{
var index = 0,
count = fileDependencyExecutables.length;
var executables = fileDependencyExecutables,
index = 0,
count = executables.length;
fileDependencyExecutables = [];
for (; index < count; ++index)
fileDependencyExecutables[index]._fileDependencyStatus = ExecutableLoadedFileDependencies;
executables[index]._fileDependencyStatus = ExecutableLoadedFileDependencies;
for (index = 0; index < count; ++index)
{
var executable = fileDependencyExecutables[index],
var executable = executables[index],
callbacks = executable._fileDependencyCallbacks,
callbackIndex = 0,
callbackCount = callbacks.length;
+20 -5
View File
@@ -22,7 +22,7 @@
var FileExecutablesForURLStrings = { };
function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable)
function FileExecutable(/*CFURL|String*/ aURL)
{
aURL = makeAbsoluteURL(aURL);
@@ -38,10 +38,7 @@ function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable)
executable = NULL,
extension = aURL.pathExtension();
if (anExecutable)
executable = anExecutable;
else if (fileContents.match(/^@STATIC;/))
if (fileContents.match(/^@STATIC;/))
executable = decompile(fileContents, aURL);
else if (extension === "j" || !extension)
@@ -117,5 +114,23 @@ 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];
}
+4
View File
@@ -87,6 +87,10 @@ 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()
-95
View File
@@ -1,95 +0,0 @@
@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
@@ -0,0 +1,10 @@
#!/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
+8 -11
View File
@@ -1,11 +1,12 @@
#!/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
@@ -15,8 +16,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=$?
@@ -27,13 +28,9 @@ else
echo "CLEAN BUILD SUCCEEDED"
fi
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"
# run any additional ci commands not common to all branches (like nightly builds)
if [ -f "$extras" ]; then
source "$extras"
fi
exit 0
exit 0
+6
View File
@@ -0,0 +1,6 @@
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("0.8.0");
cappTask.setVersion(getCappuccinoVersion());
cappTask.setSources(new FileList("*.j"));
cappTask.setResources(new FileList("Resources/*"));
cappTask.setIncludesNibsAndXibs(true);
@@ -1,8 +1,7 @@
<?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__
@@ -11,34 +10,34 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<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"></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;
</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;}
@@ -57,7 +56,7 @@
<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;">
<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' /> " +
@@ -1,8 +1,7 @@
<?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__
@@ -11,18 +10,18 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>__project.name__</title>
<script type = "text/javascript">
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></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;}
@@ -41,7 +40,7 @@
<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;">
<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' /> " +
@@ -1,8 +1,7 @@
<?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__
@@ -11,19 +10,34 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<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"></script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type = "text/css">
<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;
</script>
<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;}
@@ -42,7 +56,7 @@
<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;">
<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' /> " +
@@ -1,8 +1,7 @@
<?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__
@@ -11,18 +10,18 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>__project.name__</title>
<script type = "text/javascript">
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></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;}
@@ -41,7 +40,7 @@
<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;">
<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' /> " +
@@ -1,8 +1,7 @@
<?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__
@@ -11,19 +10,19 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<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"></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;}
@@ -42,7 +41,7 @@
<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;">
<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' /> " +
@@ -1,8 +1,7 @@
<?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__
@@ -11,18 +10,18 @@
Copyright __project.year__, __organization.name__ All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>__project.name__</title>
<script type = "text/javascript">
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></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;}
@@ -41,7 +40,7 @@
<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;">
<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' /> " +
+1 -1
View File
@@ -22,7 +22,7 @@ function main(args)
switch (argument)
{
case "version":
case "--version": return print("capp version 0.8.0");
case "--version": return print(require("cappuccino").fullVersionString());
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("0.8.0");
nib2cibTask.setVersion(getCappuccinoVersion());
nib2cibTask.setAuthor("280 North, Inc.");
nib2cibTask.setEmail("feedback @nospam@ 280north.com");
nib2cibTask.setSummary("nib2cib converts Cocoa nib and xibs to Cappuccino cibs");
+3 -1
View File
@@ -45,7 +45,9 @@
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
self = [self NS_initWithCoder:aCoder];
return self;
}
- (Class)classForKeyedArchiver
-3
View File
@@ -27,10 +27,7 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
if (self = [super NS_initWithCoder:aCoder])
{
_tableView = [aCoder decodeObjectForKey:"NSTableView"];
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
return self;
}
+26
View File
@@ -2,6 +2,7 @@ var SYSTEM = require("system");
var FILE = require("file");
var OS = require("os");
var UTIL = require("util");
var stream = require("term").stream;
var requiresSudo = false;
@@ -288,6 +289,31 @@ 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
@@ -0,0 +1,3 @@
{
"version": "0.8.0"
}