diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 3736ad700..e35b96dd0 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -739,7 +739,23 @@ var _CPRunModalLoop = function(anEvent) @class CPApplication @return void */ +@implementation X : CPObject +{ +} +- (void)blendDidFinishLoading:(CPBundle)aBundle +{ + [CPTheme setDefaultTheme:[CPTheme themeNamed:@"Aristo"]]; + _CPApplicationMain() +} +@end function CPApplicationMain(args, namedArgs) +{ + var blend = [[CPBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:@"Aristo.blend"]]; + + [blend loadWithDelegate:[X new]]; +} + +function _CPApplicationMain(args, namedArgs) { var mainBundle = [CPBundle mainBundle], principalClass = [mainBundle principalClass]; diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 1e1d7f30a..343cfca55 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -111,6 +111,7 @@ _tileWidth = -1.0; _selectionIndexes = [CPIndexSet indexSet]; + _isSelectable = YES; } return self; @@ -258,7 +259,7 @@ */ - (void)setSelectionIndexes:(CPIndexSet)anIndexSet { - if (_selectionIndexes == anIndexSet) + if (_selectionIndexes == anIndexSet || !_isSelectable) return; var index = CPNotFound; diff --git a/AppKit/CPColor.j b/AppKit/CPColor.j index c26071173..47517a5de 100644 --- a/AppKit/CPColor.j +++ b/AppKit/CPColor.j @@ -523,6 +523,8 @@ var hexCharacters = "0123456789ABCDEF"; */ function hexToRGB(hex) { + if ( hex.length == 3 ) + hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2); if(hex.length != 6) return null; diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 626fe0cb8..a06ba9ba3 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -103,6 +103,8 @@ var CPControlBlackColor = [CPColor blackColor]; JSObject _ephemeralSubviewsForNames; CPSet _ephereralSubviews; + + CPString _toolTip; // FIXME: Who uses this? BOOL _isBezeled; @@ -183,6 +185,33 @@ var CPControlBlackColor = [CPColor blackColor]; return previousMask; } +/*! + Sets the tooltip for the receiver. + @param aToolTip the tooltip +*/ +/* +-(void)setToolTip:(CPString)aToolTip +{ + if (_toolTip == aToolTip) + return; + + _toolTip = aToolTip; + +#if PLATFORM(DOM) + _DOMElement.title = aToolTip; +#endif +} +*/ +/*! + Returns the receiver's tooltip +*/ +/* +-(CPString)toolTip +{ + return _toolTip; +} +*/ + /*! Returns whether the control can continuously send its action messages. */ diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 80d463868..bc68954dc 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -450,7 +450,7 @@ CPPopUpButtonStatePullsDown = 1 << 12; */ - (int)indexOfItemWithRepresentedObject:(id)anObject { - return [_menu indexOfItemWithRepresentedObejct:anObject]; + return [_menu indexOfItemWithRepresentedObject:anObject]; } /*! diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index 3bdc05543..efa3d9209 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -173,6 +173,16 @@ return [super createEphemeralSubviewNamed:aName]; } +- (void)setAltIncrementValue:(float)anAltIncrementValue +{ + _altIncrementValue = anAltIncrementValue; +} + +- (float)altIncrementValue +{ + return _altIncrementValue; +} + - (int)isVertical { var bounds = [self bounds], diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 449a2c119..43cb1c14f 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -780,4 +780,4 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", [aCoder encodeObject:_placeholderString forKey:CPTextFieldPlaceholderStringKey]; } -@end +@end \ No newline at end of file diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index 76f08eb06..e4c39a17f 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -27,6 +27,60 @@ @import "CPThemedAttribute.j" +@implementation CPBlend : CPObject +{ + CPBundle _bundle; + CPArray _themes @accessors(readonly); + id _loadDelegate; +} + +- (id)initWithContentsOfURL:(CPURL)aURL +{ + self = [super init]; + + if (self) + { + _bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"]; + } + + return self; +} + +- (void)loadWithDelegate:(id)aDelegate +{ + _loadDelegate = aDelegate; + + [_bundle loadWithDelegate:self]; +} + +- (void)bundleDidFinishLoading:(CPBundle)aBundle +{ + var paths = [_bundle objectForInfoDictionaryKey:@"CPBundleReplacedFiles"], + index = 0, + count = paths.length, + bundlePath = [_bundle bundlePath]; + + while (count--) + { + var path = paths[count]; + + if ([path pathExtension] === "keyedtheme") + { + var unarchiver = [[_CPThemeKeyedUnarchiver alloc] + initForReadingWithData:[CPData dataWithString:objj_files[bundlePath + '/' + path].contents] + bundle:_bundle]; + + [unarchiver decodeObjectForKey:@"root"]; + + [unarchiver finishDecoding]; + } + } + + [_loadDelegate blendDidFinishLoading:self]; +} + +@end + var CPThemesByName = nil, CPThemeDefaultTheme = nil, diff --git a/AppKit/CoreAnimation/CAMediaTimingFunction.j b/AppKit/CoreAnimation/CAMediaTimingFunction.j index 9a6091da1..c75df75cf 100644 --- a/AppKit/CoreAnimation/CAMediaTimingFunction.j +++ b/AppKit/CoreAnimation/CAMediaTimingFunction.j @@ -95,7 +95,7 @@ var CAMediaNamedTimingFunctions = nil; else { reference[0] = 1.0; - reference[0] = 1.0; + reference[1] = 1.0; } } diff --git a/AppKit/Rakefile b/AppKit/Rakefile new file mode 100644 index 000000000..d7a944118 --- /dev/null +++ b/AppKit/Rakefile @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../common' +require 'objective-j' +require 'objective-j/bundletask' + + +$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'AppKit') +$ENVIRONMENT_PRODUCT = File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'AppKit') +$THEME_PRODUCT = File.join($BUILD_PATH, 'Resources', 'Aristo.blend') + +subprojects = %w{Tools} + +subrake(subprojects) + +AppKitFiles = FileList['**/*.j'].exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**', 'Tools/**') + +ObjectiveJ::BundleTask.new(:AppKit) do |t| + t.name = 'AppKit' + t.identifier = 'com.280n.AppKit' + t.version = '0.6.5' + t.author = '280 North, Inc.' + t.email = 'feedback @nospam@ 280north.com' + t.summary = 'AppKit classes for Cappuccino' + t.sources = AppKitFiles + t.resources = FileList['Resources/*'] + t.license = ObjectiveJ::License::LGPL_v2_1 + t.build_path = $BUILD_PATH + t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' + t.platforms = [ObjectiveJ::Platform::Browser, ObjectiveJ::Platform::Rhino] +end + +#Framework in environment directory +file_d $ENVIRONMENT_PRODUCT => [:AppKit] do + cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_PRODUCT) +end + +ThemeFiles = FileList['Themes/Aristo/*'] + +file_d $THEME_PRODUCT => ThemeFiles do + File.popen("blend -d Themes/Aristo/ThemeDescriptors.j -o #{$THEME_PRODUCT} -R Themes/Aristo/Resources") do |blend| + puts blend.read + end +end + +task :build => [:AppKit, $ENVIRONMENT_PRODUCT, $THEME_PRODUCT] diff --git a/Tools/steam/Templates/ThemeDescriptor/Info.plist b/AppKit/Themes/Aristo/Info.plist similarity index 92% rename from Tools/steam/Templates/ThemeDescriptor/Info.plist rename to AppKit/Themes/Aristo/Info.plist index f09701c61..9acb0906e 100644 --- a/Tools/steam/Templates/ThemeDescriptor/Info.plist +++ b/AppKit/Themes/Aristo/Info.plist @@ -5,7 +5,7 @@ CPApplicationDelegateClass BKShowcaseController CPBundleName - __Product__ + A CPPrincipalClass CPApplication diff --git a/AppKit/Themes/Aristo/Resources/button-bezel-center.png b/AppKit/Themes/Aristo/Resources/button-bezel-center.png new file mode 100644 index 000000000..9481b3044 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/button-bezel-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-center.png b/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-center.png new file mode 100644 index 000000000..3e1b49146 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-left.png b/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-left.png new file mode 100644 index 000000000..d6a3317de Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-right.png b/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-right.png new file mode 100644 index 000000000..463623cad Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/button-bezel-highlighted-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/button-bezel-left.png b/AppKit/Themes/Aristo/Resources/button-bezel-left.png new file mode 100644 index 000000000..957f25208 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/button-bezel-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/button-bezel-right.png b/AppKit/Themes/Aristo/Resources/button-bezel-right.png new file mode 100644 index 000000000..a53638cc2 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/button-bezel-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/buttonbar-bezel-right.png b/AppKit/Themes/Aristo/Resources/buttonbar-bezel-right.png new file mode 100644 index 000000000..cdde2d04e Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/buttonbar-bezel-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/buttonbar-bezel.png b/AppKit/Themes/Aristo/Resources/buttonbar-bezel.png new file mode 100644 index 000000000..e215d9d8e Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/buttonbar-bezel.png differ diff --git a/AppKit/Themes/Aristo/Resources/horizontal-track-center.png b/AppKit/Themes/Aristo/Resources/horizontal-track-center.png new file mode 100644 index 000000000..efccbec29 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/horizontal-track-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/horizontal-track-left.png b/AppKit/Themes/Aristo/Resources/horizontal-track-left.png new file mode 100644 index 000000000..0904f3d7a Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/horizontal-track-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/horizontal-track-right.png b/AppKit/Themes/Aristo/Resources/horizontal-track-right.png new file mode 100644 index 000000000..eea7bfae9 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/horizontal-track-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/knob-highlighted.png b/AppKit/Themes/Aristo/Resources/knob-highlighted.png new file mode 100644 index 000000000..df1a1f005 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/knob-highlighted.png differ diff --git a/AppKit/Themes/Aristo/Resources/knob.png b/AppKit/Themes/Aristo/Resources/knob.png new file mode 100644 index 000000000..073980fb8 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/knob.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow-disabled.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow-disabled.png new file mode 100644 index 000000000..01c0f95be Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow-disabled.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow-highlighted.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow-highlighted.png new file mode 100644 index 000000000..1c7e4715e Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow-highlighted.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow.png new file mode 100644 index 000000000..51fe09670 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-down-arrow.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow-disabled.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow-disabled.png new file mode 100644 index 000000000..6c3296150 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow-disabled.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow-highlighted.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow-highlighted.png new file mode 100644 index 000000000..afb254629 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow-highlighted.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow.png new file mode 100644 index 000000000..6349869c7 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-up-arrow.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-bottom.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-bottom.png new file mode 100644 index 000000000..aaab8b419 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-center.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-center.png new file mode 100644 index 000000000..d672d4410 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-top.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-top.png new file mode 100644 index 000000000..e825ed9a9 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-knob-top.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-track-disabled.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-track-disabled.png new file mode 100644 index 000000000..cabb6e2c1 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-track-disabled.png differ diff --git a/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-track.png b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-track.png new file mode 100644 index 000000000..db3e09fc5 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/old-scroller/scroller-vertical-track.png differ diff --git a/AppKit/Themes/Aristo/Resources/popup-arrows-pullsdown.png b/AppKit/Themes/Aristo/Resources/popup-arrows-pullsdown.png new file mode 100644 index 000000000..ad83187fb Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/popup-arrows-pullsdown.png differ diff --git a/AppKit/Themes/Aristo/Resources/popup-arrows.png b/AppKit/Themes/Aristo/Resources/popup-arrows.png new file mode 100644 index 000000000..9fbe069aa Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/popup-arrows.png differ diff --git a/AppKit/Themes/Aristo/Resources/popup-bezel-right-pullsdown.png b/AppKit/Themes/Aristo/Resources/popup-bezel-right-pullsdown.png new file mode 100644 index 000000000..a17bed227 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/popup-bezel-right-pullsdown.png differ diff --git a/AppKit/Themes/Aristo/Resources/popup-bezel-right.png b/AppKit/Themes/Aristo/Resources/popup-bezel-right.png new file mode 100644 index 000000000..0d8c2fc22 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/popup-bezel-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-down-arrow-disabled.png b/AppKit/Themes/Aristo/Resources/scroller-down-arrow-disabled.png new file mode 100644 index 000000000..da7b0d2c5 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-down-arrow-disabled.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-down-arrow-highlighted.png b/AppKit/Themes/Aristo/Resources/scroller-down-arrow-highlighted.png new file mode 100644 index 000000000..7b3c5e527 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-down-arrow-highlighted.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-down-arrow.png b/AppKit/Themes/Aristo/Resources/scroller-down-arrow.png new file mode 100644 index 000000000..afa831cb8 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-down-arrow.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png new file mode 100644 index 000000000..1bc643125 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png new file mode 100644 index 000000000..8b417a826 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png new file mode 100644 index 000000000..90198e6ed Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track.png new file mode 100644 index 000000000..34c1cc7e1 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-left-arrow.png b/AppKit/Themes/Aristo/Resources/scroller-left-arrow.png new file mode 100644 index 000000000..1fa62615b Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-left-arrow.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-right-arrow.png b/AppKit/Themes/Aristo/Resources/scroller-right-arrow.png new file mode 100644 index 000000000..3ae19c5eb Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-right-arrow.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-up-arrow-disabled.png b/AppKit/Themes/Aristo/Resources/scroller-up-arrow-disabled.png new file mode 100644 index 000000000..2ce2f5519 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-up-arrow-disabled.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-up-arrow-highlighted.png b/AppKit/Themes/Aristo/Resources/scroller-up-arrow-highlighted.png new file mode 100644 index 000000000..e7b72c5ea Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-up-arrow-highlighted.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-up-arrow.png b/AppKit/Themes/Aristo/Resources/scroller-up-arrow.png new file mode 100644 index 000000000..52256c0ff Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-up-arrow.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png new file mode 100644 index 000000000..de4bc2cb1 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png new file mode 100644 index 000000000..f50eb1bd2 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png new file mode 100644 index 000000000..dcfc02c96 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-disabled.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-disabled.png new file mode 100644 index 000000000..4ade298c0 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-disabled.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-track.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-track.png new file mode 100644 index 000000000..6e2e98884 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/scroller-vertical-track.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-center.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-center.png new file mode 100644 index 000000000..3b42d1c6b Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-left.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-left.png new file mode 100644 index 000000000..8af10bb9d Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-right.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-right.png new file mode 100644 index 000000000..43b5d7995 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-rounded-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-0.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-0.png new file mode 100644 index 000000000..1819bb3a8 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-0.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-1.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-1.png new file mode 100644 index 000000000..2c77bb764 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-1.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-2.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-2.png new file mode 100644 index 000000000..848e1da44 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-2.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-3.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-3.png new file mode 100644 index 000000000..81cd27451 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-3.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-4.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-4.png new file mode 100644 index 000000000..9432d30c9 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-4.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-5.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-5.png new file mode 100644 index 000000000..21f81000e Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-5.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-6.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-6.png new file mode 100644 index 000000000..acc67dfa2 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-6.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-7.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-7.png new file mode 100644 index 000000000..0c228f14c Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-7.png differ diff --git a/AppKit/Themes/Aristo/Resources/textfield-bezel-square-8.png b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-8.png new file mode 100644 index 000000000..07f219728 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/textfield-bezel-square-8.png differ diff --git a/AppKit/Themes/Aristo/Resources/vertical-track-bottom.png b/AppKit/Themes/Aristo/Resources/vertical-track-bottom.png new file mode 100644 index 000000000..54b7bf7df Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/vertical-track-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/vertical-track-center.png b/AppKit/Themes/Aristo/Resources/vertical-track-center.png new file mode 100644 index 000000000..a37f85437 Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/vertical-track-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/vertical-track-top.png b/AppKit/Themes/Aristo/Resources/vertical-track-top.png new file mode 100644 index 000000000..425e1e99b Binary files /dev/null and b/AppKit/Themes/Aristo/Resources/vertical-track-top.png differ diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j new file mode 100644 index 000000000..95d365808 --- /dev/null +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -0,0 +1,321 @@ +/* + * AppController.j + * A + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +@import + + +@implementation AristoThemeDescriptor : CPObject +{ +} + ++ (CPString)themeName +{ + return @"Aristo"; +} + ++ (CPScroller)themedVerticalScroller +{ + var scroller = [[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, 17.0, 170.0)], + trackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track.png" size:CGSizeMake(17.0, 1.0)]), + disabledTrackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]); + + [scroller setValue:CGSizeMake(15.0, 19.0) forThemedAttributeName:@"minimum-knob-size" inControlState:CPControlStateVertical]; + + [scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemedAttributeName:@"track-overlap-inset" inControlState:CPControlStateVertical]; + [scroller setValue:trackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateVertical]; + [scroller setValue:disabledTrackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateVertical | CPControlStateDisabled]; + + var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow.png" size:CGSizeMake(17.0, 30.0)]), + highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]), + disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]); + + [scroller setValue:CGSizeMake(17.0, 30.0) forThemedAttributeName:@"decrement-line-size" inControlState:CPControlStateVertical]; + [scroller setValue:arrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateVertical]; + [scroller setValue:highlightedArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateVertical | CPControlStateHighlighted], + [scroller setValue:disabledArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateVertical | CPControlStateDisabled]; + + var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow.png" size:CGSizeMake(17.0, 30.0)]), + highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]), + disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]); + + [scroller setValue:CGSizeMake(17.0, 30.0) forThemedAttributeName:@"increment-line-size"]; + [scroller setValue:arrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateVertical]; + [scroller setValue:highlightedArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateVertical | CPControlStateHighlighted]; + [scroller setValue:disabledArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateVertical | CPControlStateDisabled]; + + var knobColor = PatterColor([[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"scroller-vertical-knob-top.png" size:CGSizeMake(15.0, 8.0)], + [_CPCibCustomResource imageResourceWithName:"scroller-vertical-knob-center.png" size:CGSizeMake(15.0, 1.0)], + [_CPCibCustomResource imageResourceWithName:"scroller-vertical-knob-bottom.png" size:CGSizeMake(15.0, 10.0)] + ] + isVertical:YES]); + + [scroller setValue:knobColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateVertical]; + + [scroller setFloatValue:0.1 knobProportion:0.5]; + + return scroller; +} + ++ (CPScroller)themedHorizontalScroller +{CPControlStateHorizontal = 0; + var scroller = [[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, 170.0, 17.0)], + trackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-horizontal-track.png" size:CGSizeMake(1.0, 17.0)]), + disabledTrackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]); + [scroller setBackgroundColor:[CPColor blueColor]]; + [scroller setValue:CGSizeMake(19.0, 15.0) forThemedAttributeName:@"minimum-knob-size" inControlState:CPControlStateHorizontal]; + + [scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemedAttributeName:@"track-overlap-inset" inControlState:CPControlStateHorizontal]; + [scroller setValue:trackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateHorizontal]; + [scroller setValue:disabledTrackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateHorizontal | CPControlStateDisabled]; + + var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow.png" size:CGSizeMake(32.0, 17.0)]), + highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]), + disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]); + + [scroller setValue:CGSizeMake(32.0, 17.0) forThemedAttributeName:@"decrement-line-size" inControlState:CPControlStateHorizontal]; + [scroller setValue:arrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateHorizontal]; + [scroller setValue:highlightedArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateHorizontal | CPControlStateHighlighted], + [scroller setValue:disabledArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateHorizontal | CPControlStateDisabled]; + + var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow.png" size:CGSizeMake(31.0, 17.0)]), + highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]), + disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]); + + [scroller setValue:CGSizeMake(31.0, 17.0) forThemedAttributeName:@"increment-line-size"]; + [scroller setValue:arrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateHorizontal]; + [scroller setValue:highlightedArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateHorizontal | CPControlStateHighlighted]; + [scroller setValue:disabledArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateHorizontal | CPControlStateDisabled]; + + var knobColor = PatterColor([[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"scroller-horizontal-knob-left.png" size:CGSizeMake(11.0, 15.0)], + [_CPCibCustomResource imageResourceWithName:"scroller-horizontal-knob-center.png" size:CGSizeMake(1.0, 15.0)], + [_CPCibCustomResource imageResourceWithName:"scroller-horizontal-knob-right.png" size:CGSizeMake(9.0, 15.0)] + ] + isVertical:NO]); + + [scroller setValue:knobColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateHorizontal]; + + [scroller setFloatValue:0.1 knobProportion:0.5]; + + return scroller; +} + ++ (CPTextField)themedStandardTextField +{ + var textfield = [[CPTextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 22.0)], + bezelColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-0.png" size:CGSizeMake(2.0, 3.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-1.png" size:CGSizeMake(1.0, 3.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-2.png" size:CGSizeMake(2.0, 3.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-3.png" size:CGSizeMake(2.0, 1.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-4.png" size:CGSizeMake(1.0, 1.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-5.png" size:CGSizeMake(2.0, 1.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-6.png" size:CGSizeMake(2.0, 2.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-7.png" size:CGSizeMake(1.0, 2.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-square-8.png" size:CGSizeMake(2.0, 2.0)] + ]]]; + + [textfield setBezeled:YES]; + [textfield setValue:bezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBezeled]; + [textfield setValue:[CPFont systemFontOfSize:12.0] forThemedAttributeName:@"font"]; + [textfield setValue:CGInsetMake(5.0, 4.0, 2.0, 3.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBezeled]; + + [textfield setValue:[CPColor colorWithCalibratedRed:189.0 / 255.0 green:199.0 / 255.0 blue:211.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color" inControlState:CPTextFieldStatePlaceholder]; + + [textfield setPlaceholderString:"cheese cheese"]; + [textfield setStringValue:""]; + [textfield setEditable:YES]; + + return textfield; +} + ++ (CPTextField)themedRoundedTextField +{ + var textfield = [[CPTextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 22.0)], + bezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-rounded-left.png" size:CGSizeMake(13.0, 22.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-rounded-center.png" size:CGSizeMake(1.0, 22.0)], + [_CPCibCustomResource imageResourceWithName:"textfield-bezel-rounded-right.png" size:CGSizeMake(13.0, 22.0)] + ] isVertical:NO]]; + + [textfield setBezeled:YES]; + [textfield setBezelStyle:CPTextFieldRoundedBezel]; + [textfield setValue:bezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBezeled | CPTextFieldStateRounded]; + [textfield setValue:[CPFont systemFontOfSize:12.0] forThemedAttributeName:@"font"]; + [textfield setValue:CGInsetMake(5.0, 10.0, 2.0, 10.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBezeled | CPTextFieldStateRounded]; + + [textfield setValue:[CPColor colorWithCalibratedRed:189.0 / 255.0 green:199.0 / 255.0 blue:211.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color" inControlState:CPTextFieldStatePlaceholder]; + + [textfield setPlaceholderString:"cheese cheese"]; + [textfield setStringValue:""]; + [textfield setEditable:YES]; + + return textfield; +} + ++ (CPButton)themedButton +{ + var button = [[CPButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 24.0)], + + bezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"button-bezel-left.png" size:CGSizeMake(4.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"button-bezel-center.png" size:CGSizeMake(1.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"button-bezel-right.png" size:CGSizeMake(4.0, 24.0)] + ] + isVertical:NO]]; + + highlightedBezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"button-bezel-highlighted-left.png" size:CGSizeMake(4.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"button-bezel-highlighted-center.png" size:CGSizeMake(1.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"button-bezel-highlighted-right.png" size:CGSizeMake(4.0, 24.0)] + ] + isVertical:NO]]; + + [button setTitle:@"Cancel"]; + + [button setValue:[CPFont boldSystemFontOfSize:12.0] forThemedAttributeName:@"font" inControlState:CPControlStateBordered]; + [button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color"]; + [button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-shadow-color" inControlState:CPControlStateBordered]; + [button setValue:CGSizeMake(0.0, 1.0) forThemedAttributeName:@"text-shadow-offset" inControlState:CPControlStateBordered]; + [button setValue:CPLineBreakByTruncatingTail forThemedAttributeName:@"line-break-mode"]; + + [button setValue:bezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered]; + [button setValue:highlightedBezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered|CPControlStateHighlighted]; + [button setValue:CGInsetMake(0.0, 5.0, 0.0, 5.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBordered]; + + [button setValue:24.0 forThemedAttributeName:@"default-height"]; + + return button; +} + ++ (CPPopUpButton)themedPopUpButton +{ + var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 24.0) pullsDown:NO],color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"button-bezel-left.png" size:CGSizeMake(4.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"button-bezel-center.png" size:CGSizeMake(1.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"popup-bezel-right.png" size:CGSizeMake(27.0, 24.0)] + ] + isVertical:NO]]; + + [button setTitle:@"Pop Up"]; + + [button setValue:color forThemedAttributeName:@"bezel-color"]; + [button setValue:CGInsetMake(0, 5, 0, 27.0 + 5.0) forThemedAttributeName:@"content-inset"]; + [button setValue:[CPFont boldSystemFontOfSize:12.0] forThemedAttributeName:@"font"]; + [button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color"]; + [button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-shadow-color"]; + [button setValue:CGSizeMake(0.0, 1.0) forThemedAttributeName:@"text-shadow-offset"]; + + [button addItemWithTitle:@"item"]; + + return button; +} + ++ (CPPopUpButton)themedPullDownMenu +{ + var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 24.0) pullsDown:YES], + color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"button-bezel-left.png" size:CGSizeMake(4.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"button-bezel-center.png" size:CGSizeMake(1.0, 24.0)], + [_CPCibCustomResource imageResourceWithName:"popup-bezel-right-pullsdown.png" size:CGSizeMake(27.0, 24.0)] + ] + isVertical:NO]]; + + [button setTitle:@"Pop Up"]; + + [button setValue:color forThemedAttributeName:@"bezel-color" inControlState:CPPopUpButtonStatePullsDown]; + [button setValue:CGInsetMake(0, 5, 0, 27.0 + 5.0) forThemedAttributeName:@"content-inset"]; + [button setValue:[CPFont boldSystemFontOfSize:12.0] forThemedAttributeName:@"font"]; + [button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color"]; + [button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-shadow-color"]; + [button setValue:CGSizeMake(0.0, 1.0) forThemedAttributeName:@"text-shadow-offset"]; + + [button addItemWithTitle:@"item"]; + + return button; +} + ++ (CPSlider)themedHorizontalSlider +{ + var slider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 24.0)], + trackColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"horizontal-track-left.png" size:CGSizeMake(4.0, 5.0)], + [_CPCibCustomResource imageResourceWithName:"horizontal-track-center.png" size:CGSizeMake(1.0, 5.0)], + [_CPCibCustomResource imageResourceWithName:"horizontal-track-right.png" size:CGSizeMake(4.0, 5.0)] + ] + isVertical:NO]]; + + [slider setValue:5.0 forThemedAttributeName:@"track-width"]; + [slider setValue:trackColor forThemedAttributeName:@"horizontal-track-color"]; + + var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob.png" size:CGSizeMake(23.0, 24.0)]]; + knobHighlightedColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob-highlighted.png" size:CGSizeMake(23.0, 24.0)]]; + + [slider setValue:CGSizeMake(23.0, 24.0) forThemedAttributeName:@"knob-size"]; + [slider setValue:knobColor forThemedAttributeName:@"knob-color"]; + [slider setValue:knobHighlightedColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateHighlighted]; + + return slider; +} + ++ (CPSlider)themedVerticalSlider +{ + var slider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 24.0, 50.0)], + trackColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"vertical-track-top.png" size:CGSizeMake(5.0, 6.0)], + [_CPCibCustomResource imageResourceWithName:"vertical-track-center.png" size:CGSizeMake(5.0, 1.0)], + [_CPCibCustomResource imageResourceWithName:"vertical-track-bottom.png" size:CGSizeMake(5.0, 4.0)] + ] + isVertical:YES]]; + + [slider setValue:5.0 forThemedAttributeName:@"track-width"]; + [slider setValue:trackColor forThemedAttributeName:@"vertical-track-color"]; + + var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob.png" size:CGSizeMake(23.0, 24.0)]]; + knobHighlightedColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob-highlighted.png" size:CGSizeMake(23.0, 24.0)]]; + + [slider setValue:CGSizeMake(23.0, 24.0) forThemedAttributeName:@"knob-size"]; + [slider setValue:knobColor forThemedAttributeName:@"knob-color"]; + [slider setValue:knobHighlightedColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateHighlighted]; + + return slider; +} +/* + var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 30.0)], + color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices: + [ + [_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 30.0)], + [_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 30.0)], + [_CPCibCustomResource imageResourceWithName:"buttonbar-bezel-right.png" size:CGSizeMake(13.0, 30.0)] + ] + isVertical:NO]]; + + [buttonBar setValue:color forThemedAttributeName:@"bezel-color"]; + [buttonBar setNeedsLayout]; + + views.push(buttonBar); + + return views; +*/ +@end + +function PatterColor(anImage) +{ + return [CPColor colorWithPatternImage:anImage]; +} diff --git a/AppKit/Themes/Aristo/build.xml b/AppKit/Themes/Aristo/build.xml new file mode 100644 index 000000000..bde34921e --- /dev/null +++ b/AppKit/Themes/Aristo/build.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tools/steam/Templates/ThemeDescriptor/index-debug.html b/AppKit/Themes/Aristo/index-debug.html similarity index 98% rename from Tools/steam/Templates/ThemeDescriptor/index-debug.html rename to AppKit/Themes/Aristo/index-debug.html index d941b006a..df94938fc 100644 --- a/Tools/steam/Templates/ThemeDescriptor/index-debug.html +++ b/AppKit/Themes/Aristo/index-debug.html @@ -6,7 +6,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Objective-J/Tools/Rakefile b/Objective-J/Tools/Rakefile new file mode 100644 index 000000000..caa3700a6 --- /dev/null +++ b/Objective-J/Tools/Rakefile @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../../common' + + +subprojects = %w{cplutil objj objjc} + +%w(build clean).each do |task_name| + task task_name do + subrake(subprojects) + end +end diff --git a/Objective-J/Tools/cplutil/Rakefile b/Objective-J/Tools/cplutil/Rakefile new file mode 100644 index 000000000..3c90a0481 --- /dev/null +++ b/Objective-J/Tools/cplutil/Rakefile @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../../../common' +require 'objective-j' + + +$CPLUTIL_SCRIPT = File.join($BUILD_DIR, 'cplutil.build', $CONFIGURATION, 'main-concat.js') +$CPLUTIL_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'cplutil', 'main.class') +$CPLUTIL_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'cplutil') +$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable')) + +task :build => [$CPLUTIL_CLASS, $CPLUTIL_EXECUTABLE] + +Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck! + File.join($HOME_DIR, 'Tools', 'Utilities', 'regex-bridge.js'), #double-yuck! + File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'), + 'main.js']; + +file_d $CPLUTIL_EXECUTABLE => [$STANDARD_EXECUTABLE] do + cp($STANDARD_EXECUTABLE, $CPLUTIL_EXECUTABLE) + File.chmod 0755, $CPLUTIL_EXECUTABLE +end + +file_d $CPLUTIL_SCRIPT => Files do |t| + cat(Files, $CPLUTIL_SCRIPT) +end + +file_d $CPLUTIL_CLASS => $CPLUTIL_SCRIPT do |t| + js2java($CPLUTIL_SCRIPT, 'main.class', false) + cp(File.join(File.dirname($CPLUTIL_SCRIPT), 'main.class'), $CPLUTIL_CLASS) +end diff --git a/Objective-J/Tools/cplutil/main.js b/Objective-J/Tools/cplutil/main.js index 455df7a0f..1904d0a29 100644 --- a/Objective-J/Tools/cplutil/main.js +++ b/Objective-J/Tools/cplutil/main.js @@ -100,4 +100,4 @@ function main() } } -main.apply(main, arguments); +main.apply(main, args); diff --git a/Objective-J/Tools/executable b/Objective-J/Tools/executable index f2d87c461..efec401f6 100644 --- a/Objective-J/Tools/executable +++ b/Objective-J/Tools/executable @@ -1,7 +1,7 @@ #!/bin/sh # if OBJJ_HOME isn't set, try to determine it out -if [ -z $OBJJ_HOME ]; then +#if [ -z $OBJJ_HOME ]; then # get path of the executable SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") @@ -15,13 +15,13 @@ if [ -z $OBJJ_HOME ]; then export OBJJ_HOME=`dirname $SELF_DIR` # check to ensure it exists, print message - if [ -d $OBJJ_HOME ]; then - echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 - else - echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 - exit 2 - fi -fi +# if [ -d $OBJJ_HOME ]; then +# echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 +# else +# echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 +# exit 2 +# fi +#fi OBJJ_LIB="$OBJJ_HOME/lib" CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar:$OBJJ_HOME/lib/$(basename $SELF_PATH):$CLASSPATH" diff --git a/Objective-J/Tools/objj/rakefile b/Objective-J/Tools/objj/Rakefile similarity index 96% rename from Objective-J/Tools/objj/rakefile rename to Objective-J/Tools/objj/Rakefile index 83744b388..d6c4b2f66 100644 --- a/Objective-J/Tools/objj/rakefile +++ b/Objective-J/Tools/objj/Rakefile @@ -13,7 +13,7 @@ $STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable')) task :build => [$OBJJ_CLASS, $OBJJ_EXECUTABLE] Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck! - File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'Rhino.platform', 'Objective-J.js'), + File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'), 'main.js']; file_d $OBJJ_EXECUTABLE => [$STANDARD_EXECUTABLE] do diff --git a/Objective-J/Tools/objj/main.js b/Objective-J/Tools/objj/main.js index 3dce72c56..99414de96 100644 --- a/Objective-J/Tools/objj/main.js +++ b/Objective-J/Tools/objj/main.js @@ -2,6 +2,7 @@ debug = false; args = arguments; // FIXME: remove these Rhino/Java dependencies +/* var OBJJ_LIB = Packages.java.lang.System.getenv("OBJJ_LIB"); // chicken/egg problem, getenv is defined in bridge.js if (!this.window) @@ -15,17 +16,12 @@ if (!this.objj_import) print("Loading Objective-J."); load(OBJJ_LIB+'/Frameworks-Rhino/Objective-J/Objective-J.js'); } - -var defaultFrameworks = OBJJ_LIB+'/Frameworks-Rhino'; -OBJJ_INCLUDE_PATHS = [defaultFrameworks]; +*/ var OBJJ_INCLUDE_PATHS_STRING = getenv("OBJJ_INCLUDE_PATHS"); if (OBJJ_INCLUDE_PATHS_STRING) -{ - OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS_STRING.split(":"); - OBJJ_INCLUDE_PATHS.push(defaultFrameworks); -} + OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS_STRING.split(":").concat(OBJJ_INCLUDE_PATHS); try { @@ -37,6 +33,12 @@ try while (count--) args[count] = String(args[count]); + while (args.length && args[0].indexOf('-I') === 0) + OBJJ_INCLUDE_PATHS = args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS); + } + + if (args.length > 0) + { // Grab the location of the objj file to run. var mainFilePath = args.shift(); @@ -47,7 +49,7 @@ try if (debug) print("Loading: " + mainFilePath); - objj_import(mainFilePath, YES, function() { if (typeof main === "Function") main.apply(main, args); } ); + objj_import(mainFilePath, YES, function() { if (typeof main === "function") main.apply(main, args); } ); serviceTimeouts(); diff --git a/Objective-J/Tools/objjc/rakefile b/Objective-J/Tools/objjc/Rakefile similarity index 97% rename from Objective-J/Tools/objjc/rakefile rename to Objective-J/Tools/objjc/Rakefile index f2edbb35f..0f701426f 100644 --- a/Objective-J/Tools/objjc/rakefile +++ b/Objective-J/Tools/objjc/Rakefile @@ -15,7 +15,7 @@ task :build => [$OBJJC_CLASS, $OBJJC_EXECUTABLE, $OBJJC_JS_COMPILER] Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck! File.join($HOME_DIR, 'Tools', 'Utilities', 'regex-bridge.js'), #double-yuck! - File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'Rhino.platform', 'Objective-J.js'), + File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'), 'main.js']; file_d $OBJJC_EXECUTABLE => [$STANDARD_EXECUTABLE] do diff --git a/Objective-J/Tools/objjc/main.js b/Objective-J/Tools/objjc/main.js index 2256ad544..81d62d58e 100644 --- a/Objective-J/Tools/objjc/main.js +++ b/Objective-J/Tools/objjc/main.js @@ -123,7 +123,7 @@ function preprocess(aFilePath, outFilePath, gccArgs, flags) fragments = objj_preprocess(fileContents, { path:"/x" }, {path:filePath}, flags), index = 0, count = fragments.length, - preprocessed = MARKER_PATH + ';' + filePath.length + ';' + filePath; + preprocessed = ""; // Writer preprocessed fragments out. for (; index < count; ++index) diff --git a/Objective-J/Tools/steam/Project.js b/Objective-J/Tools/steam/Project.js deleted file mode 100644 index 3e48b401c..000000000 --- a/Objective-J/Tools/steam/Project.js +++ /dev/null @@ -1,331 +0,0 @@ - -importClass(java.io.FileOutputStream); -importClass(java.io.BufferedWriter); -importClass(java.io.OutputStreamWriter); - -function Target(dictionary) -{ - this._name = dictionary_getValue(dictionary, "Name"); - - var flagsString = dictionary_getValue(dictionary, "Flags"); - - this._flags = flagsString ? flagsString.split(/\s+/) : []; - - this._type = dictionary_getValue(dictionary, "Type"); - - if (!this._type) - this._type = "280N.application"; - - this._exclusions = []; - - var exclusions = dictionary_getValue(dictionary, "Excluded"); - - if (exclusions) - { - var index = 0, - count = exclusions.length; - - for (; index < count; ++index) - this._exclusions.push(new File((exclusions[index])).getCanonicalFile()); - } - - return this; -} - -Target.prototype.name = function() -{ - return this._name; -} - -Target.prototype.exclusions = function() -{ - return this._exclusions; -} - -Target.prototype.flags = function() -{ - return this._flags; -} - -Target.prototype.type = function() -{ - return this._type; -} - -function Configuration(dictionary) -{ - this._name = dictionary_getValue(dictionary, "Name"); - - var flagsString = dictionary_getValue(dictionary, "Flags"); - - this._flags = flagsString ? flagsString.split(/\s+/) : []; - - return this; -} - -Configuration.prototype.name = function() -{ - return this._name; -} - -Configuration.prototype.flags = function() -{ - return this._flags; -} - -function Project(/*String*/ aFilePath, /*String*/ aBuildPath) -{ - this._file = new File(aFilePath).getCanonicalFile(); - this._root = this._file.getParentFile(); - - // Read the project file (its just a plist). - this._properties = readPlist(this._file); - - this._name = dictionary_getValue(this._properties, "Name"); - - // Read existing Info.plist if it exists. - var infoPlist = new File(this._root.getAbsolutePath() + "/Info.plist"); - - if (infoPlist.exists()) - this._infoDictionary = readPlist(new File(this._root.getAbsolutePath() + "/Info.plist")); - else - this._infoDictionary = new objj_dictionary(); - - this.buildPath = aBuildPath; - - // Covert target dictionaries to target objects. - var targetDictionaries = dictionary_getValue(this._properties, "Targets"); - - this._targets = []; - - for (var index = 0, count = targetDictionaries.length; index < count; ++index) - this._targets.push(new Target(targetDictionaries[index])); - - this.setActiveTarget(this._targets[0]); - - // Covert target dictionaries to target objects. - var configurationDictionaries = dictionary_getValue(this._properties, "Configurations"); - - this._configurations = []; - - for (index = 0, count = configurationDictionaries.length; index < count; ++index) - this._configurations.push(new Configuration(configurationDictionaries[index])); - - this.setActiveConfiguration(this._configurations[0]); - - // Grab the Resources Directory (if it exists) - this._resources = new File(this._root.getAbsolutePath() + "/Resources/").getCanonicalFile(); - - return this; -} - -Project.prototype.name = function() -{ - return this._name; -} - -Project.prototype.targetWithName = function(/*String*/ aName) -{ - var targets = this._targets, - index = 0, - count = targets.length; - - for (; index < count; ++index) - { - var target = targets[index]; - - if (target.name() == aName) - return target; - } - - return null; -} - -Project.prototype.configurationWithName = function(/*String*/ aName) -{ - var configurations = this._configurations, - index = 0, - count = configurations.length; - - for (; index < count; ++index) - { - var configuration = configurations[index]; - - if (configuration.name() == aName) - return configuration; - } - - return null; -} - -Project.prototype.setActiveTarget = function(/*Target*/ aTarget) -{ - this._activeTarget = aTarget; - - this._buildProducts = null; - this._buildIntermediates = null; - this._buildObjects = null; -} - -Project.prototype.activeTarget = function() -{ - return this._activeTarget; -} - -Project.prototype.setActiveConfiguration = function(/*Configuration*/ aConfiguration) -{ - this._activeConfiguration = aConfiguration; - - this._buildProducts = null; - this._buildIntermediates = null; - this._buildObjects = null; -} - -Project.prototype.activeConfiguration = function() -{ - return this._activeConfiguration; -} - -Project.prototype.buildProducts = function() -{ - if (!this._buildProducts) - { - this._buildProducts = new File(this.buildPath + '/' + this._activeConfiguration.name() + '/' + this._activeTarget.name()).getCanonicalFile(); - this._buildProducts.mkdirs(); - } - - return this._buildProducts; -} - -Project.prototype.buildIntermediates = function() -{ - if (!this._buildIntermediates) - { - this._buildIntermediates = new File(this.buildPath + '/' + this._activeTarget.name() + ".build/" + this._activeConfiguration.name()).getCanonicalFile(); - this._buildIntermediates.mkdirs(); - } - - return this._buildIntermediates; -} - -Project.prototype.buildObjects = function() -{ - if (!this._buildObjects) - { - this._buildObjects = new File(this.buildIntermediates().getAbsolutePath() + '/' + this._activeTarget.name()).getCanonicalFile(); - this._buildObjects.mkdirs(); - } - - return this._buildObjects; -} - -Project.prototype.activeFlags = function() -{ - return this.activeTarget().flags().concat(this.activeConfiguration().flags()); -} - -Project.prototype.build = function() -{ - java.lang.System.out.println("Building Target \"" + this.activeTarget().name() + - "\" of Project \"" + this.name() + - "\" with Configuration \"" + this.activeConfiguration().name() + "\"."); - - var jFiles = getFiles(this._root, "j", this._activeTarget.exclusions()), - replacedFiles = []; - hasModifiedJFiles = false; - shouldObjjPreprocess = true, - shouldGzip = this._gzip, - objjcComponents = ["sh", OBJJ_HOME + "/bin/objjc"]; - - objjcComponents = objjcComponents.concat(this.activeFlags()); - - if (!shouldObjjPreprocess) - objjcComponents.push("-E"); - - var buildObjects = this.buildObjects(), - buildProducts = this.buildProducts(); - - for (index = 0, count = jFiles.length; index < count; ++index) - { - var file = jFiles[index], - builtFile = new File(buildObjects.getAbsolutePath() + '/' + getFileNameWithoutExtension(file) + '.o'); - - replacedFiles.push(file.getName() + ""); - - if (builtFile.exists() && file.lastModified() < builtFile.lastModified()) - continue; - else - hasModifiedJFiles = true; - - objjcComponents.push(file.getAbsolutePath()); - - objjcComponents.push("-o"); - objjcComponents.push(buildObjects.getAbsolutePath() + '/' + getFileNameWithoutExtension(file) + '.o'); - } - - exec(objjcComponents, true); - - var oFiles = getFiles(buildObjects, 'o'), - sjFile = new File(buildProducts.getCanonicalPath() + '/' + this._activeTarget.name() + ".sj"); - - if (hasModifiedJFiles) - { - // concatenate sjheader.txt and individual .o - exec(["sh", "-c", "cat '" + OBJJ_STEAM + "/sjheader.txt' '" + oFiles.join("' '") + "' > '" + sjFile.getCanonicalPath() + "'"], true); - } - - if (shouldGzip) - { - // gzip and copy .htaccess file - exec(["sh", "-c", "gzip -c '" + sjFile.getCanonicalPath() + "' > '" + sjFile.getCanonicalPath() + ".gz'"], true); - exec(["cp", OBJJ_HOME + "/lib/htaccess", sjFile.getParentFile().getCanonicalPath() + "/.htaccess"], true); - } - else - { - // remove gzip and .htaccess file if present - exec(["rm", "-f", sjFile.getParentFile().getCanonicalPath() + "/.htaccess", sjFile.getCanonicalPath() + ".gz"], true); - } - - dictionary_setValue(this._infoDictionary, "CPBundleExecutable", this._activeTarget.name() + ".sj"); - dictionary_setValue(this._infoDictionary, "CPBundleReplacedFiles", replacedFiles); - - this.writeInfoPlist(); - - this.copyResources(); - - // FIXME: This should be, if this is an app... - if (dictionary_getValue(this._infoDictionary, "CPBundlePackageType") == "280N") - this.copyIndexFile(); - -} - -Project.prototype.clean = function() -{ - java.lang.System.out.println("Cleaning Target \"" + this.activeTarget().name() + - "\" of Project \"" + this.name() + - "\" with Configuration \"" + this.activeConfiguration().name() + "\"."); - - exec(["rm", "-rf", this.buildIntermediates().getAbsolutePath()], true); - exec(["rm", "-rf", this.buildProducts().getAbsolutePath()], true); -} - -Project.prototype.copyIndexFile = function() -{ - var indexFile = new File(this._root.getAbsolutePath() + "/index.html").getCanonicalFile(); - - rsync(indexFile, this.buildProducts()); -} - -Project.prototype.writeInfoPlist = function() -{ - var writer = new BufferedWriter(new FileWriter(this.buildProducts().getAbsolutePath() + '/' + "Info.plist")); - - writer.write(CPPropertyListCreateXMLData(this._infoDictionary).string); - - writer.close(); -} - -Project.prototype.copyResources = function() -{ - rsync(this._resources, this.buildProducts()); -} diff --git a/Objective-J/Tools/steam/build.js b/Objective-J/Tools/steam/build.js deleted file mode 100644 index 042decf11..000000000 --- a/Objective-J/Tools/steam/build.js +++ /dev/null @@ -1,102 +0,0 @@ -function build() -{ - var index = 0, - count = arguments.length, - - actions = [], - - targetName = null, - configurationName = null, - - buildPath = null, - projectFilePath = null, - - gzip = false; - - for (; index < count; ++index) - { - switch (arguments[index]) - { - case "-f": if (index + 1 == count) - throw "-f needs project file."; - - projectFilePath = arguments[++index]; - break; - - case "-t": if (index + 1 == count) - throw "-t needs a target"; - - targetName = arguments[++index]; - break; - - case "-c": if (index + 1 == count) - throw "-c needs configuration"; - - configurationName = arguments[++index]; - break; - - case "-b": if (index + 1 == count) - throw "-b needs a build location"; - - buildPath = arguments[++index]; - break; - - case "--gzip": gzip = true; - break; - - case "clean": - case "build": actions.push(arguments[index]); - break; - } - } - - // If no project file was specified, look for one. - if (!projectFilePath) - { - var candidates = getFiles(new File('.'), "steam"); - - if (candidates.length < 1) - throw "No project file specified or found."; - - projectFilePath = candidates[0]; - } - - // Construct the Build Directory - if (!buildPath) - { - buildPath = System.getenv("STEAM_BUILD"); - - if (!buildPath) - buildPath = "Build"; - } - - var project = new Project(projectFilePath, buildPath); - - project._gzip = gzip; - - if (targetName) - { - var target = project.targetWithName(targetName); - - if (!target) - throw "Target \"" + targetName + "\" not found in project."; - - project.setActiveTarget(target); - } - - if (configurationName) - { - var configuration = project.configurationWithName(configurationName); - - if (!configuration) - throw "Configuration \"" + configurationName + "\" not found in project."; - - project.setActiveConfiguration(configuration); - } - - if (!actions.length) - actions.push("build"); - - for (index = 0, count = actions.length; index < count; ++index) - project[actions[index]](); -} diff --git a/Objective-J/Tools/steam/build.xml b/Objective-J/Tools/steam/build.xml deleted file mode 100644 index 568809646..000000000 --- a/Objective-J/Tools/steam/build.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Objective-J/Tools/steam/create.js b/Objective-J/Tools/steam/create.js deleted file mode 100644 index 73abaa8dc..000000000 --- a/Objective-J/Tools/steam/create.js +++ /dev/null @@ -1,54 +0,0 @@ -function create() -{ - if (arguments.length < 1) - printUsage("create"); - - var shouldSymbolicallyLink = false, - index = 0, - count = arguments.length, - - template = "Application", - destination = ""; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-l": shouldSymbolicallyLink = true; - break; - - case "--template": template = arguments[++index]; - break; - - default: destination = argument; - } - } - - var sourceTemplate = new File(OBJJ_HOME + "/lib/steam/Templates/" + template), - destinationProject = new File(destination); - - if (!destinationProject.exists()) - { - exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true); - - var files = getFiles(destinationProject, ['j', "plist", "html"]), - index = 0, - count = files.length; - - for (; index < count; ++index) - { - var file = files[index], - contents = readFile(file); - - contents = contents.replace(/__Product__/g, destinationProject.getName()); - - writeContentsToFile(contents, file); - } - - createFrameworksInFile(destinationProject, shouldSymbolicallyLink); - } - else - System.out.println("Directory already exists"); -} diff --git a/Objective-J/Tools/steam/htaccess b/Objective-J/Tools/steam/htaccess deleted file mode 100644 index 6afc67f10..000000000 --- a/Objective-J/Tools/steam/htaccess +++ /dev/null @@ -1,12 +0,0 @@ -Options +FollowSymLinks - -AddEncoding x-gzip .gz -AddType text/plain .gz - -RewriteEngine on - -# These conditions slow down the requests significantly. We can probably assume they're always true. -# We should ensure the gzipped version always exists if we include this .htaccess. All supported browsers accept gzip encoding. -#RewriteCond %{REQUEST_FILENAME}.gz -f -#RewriteCond %{HTTP:Accept-Encoding} gzip -RewriteRule ^(.*\.(sj|js))$ %{REQUEST_URI}/../$1.gz diff --git a/Objective-J/Tools/steam/inline-bundle.js b/Objective-J/Tools/steam/inline-bundle.js deleted file mode 100644 index 2e2dc8643..000000000 --- a/Objective-J/Tools/steam/inline-bundle.js +++ /dev/null @@ -1,156 +0,0 @@ -function inlineBundle() -{ - var index = 0, - count = arguments.length, - bundlePath = NULL; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-d": directoryPath = arguments[++index]; - break; - - default: bundlePath = argument; - } - } - - var bundleFile = new File(bundlePath).getCanonicalFile(), - bundlePath = String(bundleFile.getCanonicalPath()), - inlinedBundle = readBundle(bundleFile, true), - inlinedFiles = [], - replacedFiles = [], - staticContent = ""; - - // Find all internal bundles. - var bundleCandidates = getFiles(bundleFile, "plist"), - bundleCandidatesCount = bundleCandidates.length; - - while (bundleCandidatesCount--) - { - var bundleCandidate = bundleCandidates[bundleCandidatesCount]; - - // We only care about Info.plists, specifically the ones that aren't us. - if (String(bundleCandidate.getName()) !== "Info.plist" || String(bundleCandidate.getCanonicalPath()) === inlinedBundle.path) - continue; - - var infoDictionary = readPlist(bundleCandidate); - - // At least one of these two has to be present for this to be a real deal bundle. - if (!dictionary_getValue(infoDictionary, "CPBundleIdentifier") && !dictionary_getValue(infoDictionary, "CPBundleName")) - continue; - - java.lang.System.out.println(" Examining " + pathRelativeTo(bundleCandidate.getCanonicalPath(), bundlePath)); - - dictionary_removeValue(infoDictionary, "CPBundleExecutable"); - - var bundle = readBundle(bundleCandidate.getParentFile(), true); - - bundle.path = pathRelativeTo(bundle.path, bundlePath); - - // We want to inline the info plist too. - var inlinedFiles = [makeOBJJPlistFile(infoDictionary, bundleCandidate, bundle)].concat(bundle.files), - index = 0, - count = inlinedFiles.length; - - for (; index < count; ++index) - { - var file = inlinedFiles[index]; - - file.path = pathRelativeTo(String(file.path), bundlePath); - - java.lang.System.out.println(" Inlining " + file.path); - - replacedFiles.push(file.path); - staticContent += fileToMarkedString(inlinedFiles[index], true); - } - } - - var index = 0, - existingStaticFiles = inlinedBundle.files, - count = existingStaticFiles.length, - topLevelContent = "@STATIC;1.0;"; - - for (; index < count; ++index) - { - var file = existingStaticFiles[index]; - - // If this isn't actually part of our bundle, drop it! - if (file.bundle !== inlinedBundle) - continue; - - file.path = pathRelativeTo(String(file.path), bundlePath); - - replacedFiles.push(file.path); - topLevelContent += fileToMarkedString(file, false); - } - - dictionary_setValue(inlinedBundle.info, "CPBundleReplacedFiles", replacedFiles); - - writeContentsToFile(CPPropertyListCreateXMLData(inlinedBundle.info).string, inlinedBundle.path); - writeContentsToFile(topLevelContent + staticContent, inlinedBundle._staticContentPath); -} - -function fileToMarkedString(anOBJJFile, encodeBundle) -{ - var markedString = ""; - - markedString += MARKER_PATH + ';' + anOBJJFile.path.length + ';' + anOBJJFile.path; - - if (encodeBundle) - markedString += MARKER_BUNDLE + ';' + anOBJJFile.bundle.path.length + ';' + anOBJJFile.bundle.path; - - var fragments = anOBJJFile.fragments; - - if (fragments && fragments.length > 0) - { - var fragmentIndex = 0, - fragmentCount = fragments.length; - - for (; fragmentIndex < fragmentCount; ++fragmentIndex) - markedString += fragments[fragmentIndex].toMarkedString(); - } - - else - markedString += MARKER_TEXT + ';' + anOBJJFile.contents.length + ';' + anOBJJFile.contents; - - return markedString; -} - -function makeOBJJPlistFile(aDictionary, aFile, aBundle) -{ - var file = new objj_file(); - - file.path = typeof aFile === "string" ? aFile : aFile.getCanonicalPath(); - file.bundle = aBundle; - file.contents = CPPropertyListCreate280NorthData(aDictionary).string; - - return file; -} - -function pathRelativeTo(target, relativeTo) -{ - var components = [], - targetParts = target.split("/"), - relativeParts = relativeTo ? relativeTo.split("/") : []; - - var i = 0; - while (i < targetParts.length) - { - if (targetParts[i] != relativeParts[i]) - break; - i++; - } - - for (var j = i; j < relativeParts.length; j++) - components.push(".."); - - for (var j = i; j < targetParts.length; j++) - components.push(targetParts[j]); - - var result = components.join("/"); - - return result; -} \ No newline at end of file diff --git a/Objective-J/Tools/steam/main.js b/Objective-J/Tools/steam/main.js deleted file mode 100644 index d007905f7..000000000 --- a/Objective-J/Tools/steam/main.js +++ /dev/null @@ -1,203 +0,0 @@ - -importPackage(java.lang); -importPackage(java.util); - -importClass(java.io.File); -importClass(java.io.BufferedReader); -importClass(java.io.FileReader); -importClass(java.io.BufferedWriter); -importClass(java.io.FileWriter); -importClass(java.io.SequenceInputStream); - -#include "../Utilities/bundle.js" - -#include "Project.js" - -OBJJ_STEAM = OBJJ_HOME + "/lib/steam/"; - -function main() -{ - if (arguments.length < 1) - printUsage(); - - var command = Array.prototype.shift.apply(arguments); - - switch (command) - { - case "create": create.apply(create, arguments); - break; - - case "create-frameworks": createFrameworks.apply(createFrameworks, arguments); - break; - - - case "inline-bundle": inlineBundle.apply(inlineBundle, arguments); - break; - - case "build": build.apply(build, arguments); - break; - - case "help": printUsage(arguments[1]); - break; - - case "version": - case "--version": printVersion(); - break; - - default : printUsage(command); - } - -} - -function fileArrayContainsFile(/*Array*/ files, /*File*/ aFile) -{ - var index = 0, - count = files.length; - - for (; index < count; ++index) - if (files[index].equals(aFile)) - return true; - - return false; -} - -function getFiles(/*File*/ sourceDirectory, /*nil|String|Array*/ extensions, /*Array*/ exclusions) -{ - var matches = [], - files = sourceDirectory.listFiles(), - hasMultipleExtensions = typeof extensions !== "string"; - - if (files) - { - var index = 0, - count = files.length; - - for (; index < count; ++index) - { - var file = files[index].getCanonicalFile(), - name = String(file.getName()), - isValidExtension = !extensions; - - if (exclusions && fileArrayContainsFile(exclusions, file)) - continue; - - if (!isValidExtension) - if (hasMultipleExtensions) - { - var extensionCount = extensions.length; - - while (extensionCount-- && !isValidExtension) - { - var extension = extensions[extensionCount]; - - if (name.substring(name.length - extension.length - 1) === ("." + extension)) - isValidExtension = true; - } - } - else if (name.substring(name.length - extensions.length - 1) === ("." + extensions)) - isValidExtension = true; - - if (isValidExtension) - matches.push(file); - - if (file.isDirectory()) - matches = matches.concat(getFiles(file, extensions, exclusions)); - } - } - - return matches; -} - -function exec(/*Array*/ command, /*Boolean*/ showOutput) -{ - var line = "", - output = "", - - process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command)); - reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream())); - - while (line = reader.readLine()) - { - if (showOutput) - System.out.println(line); - - output += line + '\n'; - } - - reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream())); - - while (line = reader.readLine()) - System.out.println(line); - - try - { - if (process.waitFor() != 0) - System.err.println("exit value = " + process.exitValue()); - } - catch (anException) - { - System.err.println(anException); - } - - return output; -} - -function rsync(srcFile, dstFile) -{ - var src, dst; - - if (String(java.lang.System.getenv("OS")).indexOf("Windows") < 0) - { - src = srcFile.getAbsolutePath(); - dst = dstFile.getAbsolutePath(); - } - else - { - src = exec(["cygpath", "-u", srcFile.getAbsolutePath() + '/']); - dst = exec(["cygpath", "-u", dstFile.getAbsolutePath() + "/Resources"]); - } - - if (srcFile.exists()) - exec(["rsync", "-avz", src, dst]); -} - -function getFileName(aPath) -{ - var index = aPath.lastIndexOf('/'); - - if (index == -1) - return aPath; - - return aPath.substr(index + 1); -} - -function getFileNameWithoutExtension(aFileOrFileName) -{ - var name = typeof aFileOrFileName === "string" ? aFileOrFileName : aFileOrFileName.getName(), - index = name.lastIndexOf('.'); - - if (index == -1 || index == 0) - return name; - - return name.substr(0, index); -} - -function getFileExtension(aPath) -{ - var slash = aPath.lastIndexOf('/'), - period = aPath.lastIndexOf('.'); - - if (period < slash || (period == slash + 1)) - return ""; - - return aPath.substr(period + 1); -} - -main.apply(main, arguments); - -#include "build.js" -#include "create.js" -#include "create-frameworks.js" -#include "inline-bundle.js" -#include "usage.js" -#include "version.js" diff --git a/Objective-J/Tools/steam/sjheader.txt b/Objective-J/Tools/steam/sjheader.txt deleted file mode 100644 index 57390737c..000000000 --- a/Objective-J/Tools/steam/sjheader.txt +++ /dev/null @@ -1 +0,0 @@ -@STATIC;1.0; \ No newline at end of file diff --git a/Objective-J/Tools/steam/steam b/Objective-J/Tools/steam/steam deleted file mode 100644 index e66147478..000000000 --- a/Objective-J/Tools/steam/steam +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# if OBJJ_HOME isn't set, try to determine it -if [ -z $OBJJ_HOME ]; then - # get path of the executable - SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") - - # resolve symlinks - if [ -h $SELF_PATH ]; then - SELF_PATH=`readlink $SELF_PATH` - fi - - # get second ancestor directory - SELF_DIR=`dirname $SELF_PATH` - export OBJJ_HOME=`dirname $SELF_DIR` - - # check to ensure it exists, print message - if [ -d $OBJJ_HOME ]; then - echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 - else - echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 - exit 2 - fi -fi - -OBJJ_LIB="$OBJJ_HOME/lib" -STEAM="$OBJJ_LIB/steam" -CLASSPATH="$STEAM:$OBJJ_LIB:$OBJJ_LIB/js.jar" - -# convert paths for Cygwin -if [[ `uname` == CYGWIN* ]]; then - CLASSPATH=`cygpath -wp "$CLASSPATH"` - STEAM_BUILD=`cygpath -wp "$STEAM_BUILD"` -fi - -export OBJJ_LIB - -java -classpath $CLASSPATH steam $@ diff --git a/Objective-J/Tools/steam/steam.xml b/Objective-J/Tools/steam/steam.xml deleted file mode 100644 index 8b5e0a9f6..000000000 --- a/Objective-J/Tools/steam/steam.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Objective-J/Tools/steam/usage.js b/Objective-J/Tools/steam/usage.js deleted file mode 100644 index 389fadc53..000000000 --- a/Objective-J/Tools/steam/usage.js +++ /dev/null @@ -1,22 +0,0 @@ -function printUsage(command) -{ - var usage = "usage: steam COMMAND [ARGS]\n\n"+ -"The most commonly used steam commands are:\n"+ -"\tbuild Build a project\n"+ -"\tcreate Create a new project\n\n"+ -"See 'steam help COMMAND' for more information on a specific command."; - - switch (command) - { - case "--help": - case undefined: java.lang.System.out.println(usage); - break; - - case "create": java.lang.System.out.println("Creates a new Cappuccino project.\n\nusage: steam create PROJECT_NAME [-l]\n\n"+ - "\t-l Link Frameworks to $STEAM_BUILD/Release, instead of installing default Frameworks"); - break; - - default: java.lang.System.out.println("steam: '" + command + "' is not a steam command. See 'steam --help'."); - } - java.lang.System.exit(1); -} diff --git a/Objective-J/Tools/steam/version.js b/Objective-J/Tools/steam/version.js deleted file mode 100644 index c22171a3f..000000000 --- a/Objective-J/Tools/steam/version.js +++ /dev/null @@ -1,5 +0,0 @@ -function printVersion() -{ - java.lang.System.out.println("steam version 0.6"); - java.lang.System.exit(1); -} \ No newline at end of file diff --git a/Objective-J/Runtime/bootstrap.js b/Objective-J/bootstrap.js similarity index 100% rename from Objective-J/Runtime/bootstrap.js rename to Objective-J/bootstrap.js diff --git a/Objective-J/build.xml b/Objective-J/build.xml index 9e1a1bd0f..4084587f5 100644 --- a/Objective-J/build.xml +++ b/Objective-J/build.xml @@ -1,27 +1,64 @@ - + - + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/Objective-J/Runtime/constants.js b/Objective-J/constants.js similarity index 100% rename from Objective-J/Runtime/constants.js rename to Objective-J/constants.js diff --git a/Objective-J/Runtime/debug.js b/Objective-J/debug.js similarity index 100% rename from Objective-J/Runtime/debug.js rename to Objective-J/debug.js diff --git a/Objective-J/Runtime/dictionary.js b/Objective-J/dictionary.js similarity index 100% rename from Objective-J/Runtime/dictionary.js rename to Objective-J/dictionary.js diff --git a/Objective-J/Runtime/evaluate.js b/Objective-J/evaluate.js similarity index 100% rename from Objective-J/Runtime/evaluate.js rename to Objective-J/evaluate.js diff --git a/Objective-J/Runtime/exception.js b/Objective-J/exception.js similarity index 100% rename from Objective-J/Runtime/exception.js rename to Objective-J/exception.js diff --git a/Objective-J/Runtime/file.js b/Objective-J/file.js similarity index 95% rename from Objective-J/Runtime/file.js rename to Objective-J/file.js index d495a4deb..78f58af4d 100644 --- a/Objective-J/Runtime/file.js +++ b/Objective-J/file.js @@ -27,6 +27,7 @@ // Look inside bundleResponseCallback. +OBJJ_PLATFORMS = PLATFORMS #define DIRECTORY(aPath) (aPath).substr(0, (aPath).lastIndexOf('/') + 1) OBJJFileNotFoundException = "OBJJFileNotFoundException"; @@ -39,8 +40,8 @@ var objj_files = { }, var OBJJ_NO_FILE = {}; -if (!window.OBJJ_INCLUDE_PATHS) - var OBJJ_INCLUDE_PATHS = ["Frameworks", "SomethingElse"]; +if (typeof OBJJ_INCLUDE_PATHS === "undefined") + OBJJ_INCLUDE_PATHS = ["Frameworks", "SomethingElse"]; var OBJJ_BASE_URI = ""; @@ -127,7 +128,7 @@ objj_search.prototype.attemptNextSearchPath = function() { var searchPath = this.nextSearchPath(), file = objj_files[searchPath]; - + objj_alert("Will attempt to find " + this.filePath + " at " + searchPath); // If a file for this search path already exists, then it has already been downloaded. @@ -150,7 +151,7 @@ objj_search.prototype.attemptNextSearchPath = function() } var existingSearch = objj_searches[searchPath]; - + // If there is already an ongoing search for this search path, then we can let it find // the file for us. Make sure to assign it our callback, if we have one, since only // one search can have a callback at a time. @@ -364,6 +365,28 @@ objj_search.prototype.didReceiveBundleResponse = function(aResponse) if (executablePath) { + var platform = NULL, + platforms = dictionary_getValue(bundle.info, "CPBundlePlatforms"), + index = 0, + count = OBJJ_PLATFORMS.length, + innerCount = platforms.length; + + // Ugh, no indexOf, no objects-in-common. + for(; index < count; ++index) + { + var innerIndex = 0, + currentPlatform = OBJJ_PLATFORMS[index]; + + for (; innerIndex < innerCount; ++innerIndex) + if(currentPlatform === platforms[innerIndex]) + { + platform = currentPlatform; + break; + } + } + + executablePath = platform + ".platform/" + executablePath; + this.request(DIRECTORY(aResponse.filePath) + executablePath, this.didReceiveExecutableResponse); // FIXME: Is this the right approach? @@ -581,7 +604,7 @@ function objj_decompile(aString, bundle) { case MARKER_PATH: if (file && file.contents && file.path === file.bundle.path) file.bundle.info = CPPropertyListCreateWithData({string:file.contents}); - + file = new objj_file(); file.path = DIRECTORY(bundle.path) + text; file.bundle = bundle; diff --git a/Objective-J/Runtime/license.txt b/Objective-J/license.txt similarity index 100% rename from Objective-J/Runtime/license.txt rename to Objective-J/license.txt diff --git a/Objective-J/Runtime/plist.js b/Objective-J/plist.js similarity index 100% rename from Objective-J/Runtime/plist.js rename to Objective-J/plist.js diff --git a/Objective-J/Runtime/preprocess.js b/Objective-J/preprocess.js similarity index 100% rename from Objective-J/Runtime/preprocess.js rename to Objective-J/preprocess.js diff --git a/Objective-J/Runtime/runtime.js b/Objective-J/runtime.js similarity index 100% rename from Objective-J/Runtime/runtime.js rename to Objective-J/runtime.js diff --git a/Objective-J/Runtime/utilities.js b/Objective-J/utilities.js similarity index 100% rename from Objective-J/Runtime/utilities.js rename to Objective-J/utilities.js diff --git a/Rake/Rakefile b/Rake/Rakefile new file mode 100644 index 000000000..c924c3978 --- /dev/null +++ b/Rake/Rakefile @@ -0,0 +1,36 @@ + +require '../common' +require 'rubygems' +require 'rubygems/installer' +require 'rake' +require 'rake/gempackagetask' + + +PKG_FILES = FileList['lib/**/*'] + +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.author = '280 North, Inc.' + s.email = 'feedback @nospam@ 280north.com' + s.homepage = 'cappuccino.org' + s.summary = "Objective-J extensions to Rake." + s.name = 'objective-j' + s.version = "0.7.0" + s.requirements << 'rake' + s.require_path = 'lib' + s.files = PKG_FILES + s.description = <&2 - else - echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 - exit 2 - fi -fi - -OBJJ_LIB="$OBJJ_HOME/lib" -CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar:$OBJJ_HOME/lib/$(basename $SELF_PATH):$CLASSPATH" - -OBJJ="$OBJJ_LIB/objj.js" -RLWRAP=`which rlwrap` - -# if there's a "lib" directory, add all the jars from it -if [ -d "lib" ]; then - JARS=`find ./lib -name '*.jar' 2> /dev/null | tr "\n" ":"` - CLASSPATH="$JARS:$CLASSPATH" -fi - -# convert paths for Cygwin -if [[ `uname` == CYGWIN* ]]; then - OBJJ_HOME=`cygpath -wp "$OBJJ_HOME"` - OBJJ_LIB=`cygpath -wp "$OBJJ_LIB"` - OBJJ=`cygpath -wp "$OBJJ"` - CLASSPATH=`cygpath -wp "$CLASSPATH"` -fi - -export OBJJ_LIB -echo $RLWRAP java -classpath $CLASSPATH main $@ -#if [ -e $STEAM_BUILD/Objective-J.build/Release/Rhino ]; then - $RLWRAP java -classpath $CLASSPATH main $@ - #$RLWRAP java -classpath $CLASSPATH org.mozilla.javascript.tools.shell.Main $OBJJ $@ -#else -# echo "Missing frameworks at $STEAM_BUILD/Objective-J.build/Release/Rhino" 1>&2 -#fi diff --git a/Rake/LGPL-v2.1 b/Rake/lib/licenses/LGPL-v2.1 similarity index 100% rename from Rake/LGPL-v2.1 rename to Rake/lib/licenses/LGPL-v2.1 diff --git a/Rake/lib/objective-j.rb b/Rake/lib/objective-j.rb new file mode 100644 index 000000000..f29eaa719 --- /dev/null +++ b/Rake/lib/objective-j.rb @@ -0,0 +1,72 @@ +require 'rake' +require 'date' +require 'plist' + +module ObjectiveJ + + class Platform + ObjJ = 'objj' + + Rhino = 'rhino' + Desktop = 'desktop' + Browser = 'browser' + BrowserDesktop = 'browser-desktop' + BrowserIPhone = 'browser-iphone' + BrowseriPhone = 'browser-iphone' + + PLATFORM_DIRECTORIES = + { + Platform::ObjJ => 'objj.platform', + Platform::Rhino => 'rhino.platform', + Platform::Browser => 'browser.platform', + Platform::BrowserDesktop => 'browser-desktop.platform', + Platform::BrowserIPhone => 'browser-iphone.platform' + } + + PLATFORM_FLAGS = + { + Platform::ObjJ => [], + Platform::Rhino => ['PLATFORM_RHINO'], + Platform::Browser => ['PLATFORM_BROWSER', 'PLATFORM_DOM'], + Platform::BrowserDesktop => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_DESKTOP'], + Platform::BrowserIPhone => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_IPHONE', 'PLATFORM_MOBILE'] + } + + def Platform.directory(aPlatform) + return PLATFORM_DIRECTORIES[aPlatform] + end + + def Platform.flags(aPlatform) + return PLATFORM_FLAGS[aPlatform] + end + end + +end # module ObjectiveJ + +module ObjectiveJ + + module License + LGPL_v2_1 = 'LGPL_v2_1' + end + +end + +def file_d(*args, &block) + + fileTask = Rake::FileTask.define_task(*args, &block) + + fileDirectory = File.dirname(fileTask.name) + directory fileDirectory + + file fileTask.name => fileDirectory +end + +def resolve_flags(flags) + + case flags + when nil then '' + when String then '-D' + flags + when Array then flags.map { |flag| '-D' + flag }.join(' ') + when Hash then flags.map { |flag, value| '-D' + flag + (value != '' ? '=' + value : '') }.join(' ') + end +end diff --git a/Rake/objective-j.rb b/Rake/lib/objective-j/bundletask.rb similarity index 56% rename from Rake/objective-j.rb rename to Rake/lib/objective-j/bundletask.rb index 7d41aa4b6..10d6abe44 100644 --- a/Rake/objective-j.rb +++ b/Rake/lib/objective-j/bundletask.rb @@ -1,48 +1,41 @@ + +require 'objective-j' require 'rake' -require 'date' + +module Rake + class Application + # Is there a better (read:supported) way to do this? + def add_task(name, task) + @tasks[name.to_s] = task + end + end +end module ObjectiveJ - class Platform - OBJJ = 'objj' - RHINO = 'rhino' - BROWSER = 'browser' - end + class BundleTask < Rake::Task + + def initialize(name) + super name, Rake.application + Rake.application.add_task name, self + + # Each attribute has a default value (possibly nil). Here, we + # initialize all attributes to their default value. This is done + # through the accessor methods, so special behaviours will be honored. + # Furthermore, we take a _copy_ of the default so each specification + # instance has its own empty + # arrays, etc. + @@attributes.each do |name, default| + self.send "#{name}=", copy_of(default) + end - ## - # == ObjectiveJ::BundleSpecification - # - # The Specification class contains the metadata for a Framework. Typically defined in a - # Rakefile, and looks like this: - # - # spec = ObjJ::BundleSpecification.new do |s| - # s.name = 'NewKit' - # s.version = '1.0' - # s.summary = 'Example framework specification' - # ... - # end - # - # There are many framework attributes, and the best place to learn about them in - # the "Framework Reference" linked from the Cappuccino wiki. - # + @loaded = false + @@list << self + yield self if block_given? + @@gather.call(self) if @@gather + define + end - class BundleSpecification - - # ------------------------- Specification version contstants. - - # The specification version applied to any new Specification instances created. This - # should be bumped whenever something in the spec format changes. - CURRENT_SPECIFICATION_VERSION = 1 - - # An informal list of changes to the specification. The highest-valued key should be - # equal to the CURRENT_SPECIFICATION_VERSION. - SPECIFICATION_VERSION_HISTORY = { - -1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'], - 1 => [ - 'First Specification' - ] - } - # ------------------------- Class variables. # List of Specification instances. @@ -189,16 +182,14 @@ module ObjectiveJ end # ------------------------- REQUIRED framework attributes. - - required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION + required_attribute :name required_attribute :version #required_attribute :date attribute :date required_attribute :summary required_attribute :identifier - - read_only :specification_version + required_attribute :platforms, [Platform::ObjJ] # ------------------------- OPTIONAL gemspec attributes. @@ -224,6 +215,7 @@ module ObjectiveJ # attribute_alias_singular :executable, :executables attribute_alias_singular :author, :authors attribute_alias_singular :flag, :flags + attribute_alias_singular :platform, :platforms # attribute_alias_singular :require_path, :require_paths # attribute_alias_singular :test_file, :test_files @@ -281,78 +273,10 @@ module ObjectiveJ overwrite_accessor :build_path do return @build_path || './' + name end -=begin - overwrite_accessor :test_files do - # Handle the possibility that we have @test_suite_file but not @test_files. This will - # happen when an old gem is loaded via YAML. - if @test_suite_file - @test_files = [@test_suite_file].flatten - @test_suite_file = nil - end - @test_files ||= [] - end -=end # ------------------------- Predicates. def loaded?; @loaded ? true : false ; end - # def has_unit_tests?; not test_files.empty?; end - - # ------------------------- Constructors. - - ## - # Specification constructor. Assigns the default values to the - # attributes, adds this spec to the list of loaded specs (see - # Specification.list), and yields itself for further initialization. - # - def initialize - # Each attribute has a default value (possibly nil). Here, we - # initialize all attributes to their default value. This is done - # through the accessor methods, so special behaviours will be honored. - # Furthermore, we take a _copy_ of the default so each specification - # instance has its own empty - # arrays, etc. - @@attributes.each do |name, default| - self.send "#{name}=", copy_of(default) - end - @loaded = false - @@list << self - yield self if block_given? - @@gather.call(self) if @@gather - end -=begin - ## - # Special loader for YAML files. When a Specification object is loaded from a YAML file, - # it bypasses the normal Ruby object initialization routine (#initialize). This method - # makes up for that and deals with gems of different ages. - # - # 'input' can be anything that YAML.load() accepts: String or IO. - # - def Specification.from_yaml(input) - spec = YAML.load(input) - if(spec.class == FalseClass) then - raise Gem::EndOfYAMLException - end - unless Specification === spec - raise Gem::Exception, "YAML data doesn't evaluate to gem specification" - end - unless spec.instance_variable_get :@specification_version - spec.instance_variable_set :@specification_version, NONEXISTENT_SPECIFICATION_VERSION - end - spec - end -=end - - def BundleSpecification.load(filename) - gemspec = nil - fail "NESTED Specification.load calls not allowed!" if @@gather - @@gather = proc { |gs| gemspec = gs } - data = File.read(filename) - eval(data) - gemspec - ensure - @@gather = nil - end # ------------------------- Instance methods. @@ -379,36 +303,7 @@ module ObjectiveJ end true end -=begin - # ------------------------- Export methods (YAML and Ruby code). - # Returns an array of attribute names to be used when generating a YAML - # representation of this object. If an attribute still has its default - # value, it is omitted. - def to_yaml_properties - mark_version - @@attributes.map { |name, default| "@#{name}" } - end - - # Returns a Ruby code representation of this specification, such that it - # can be eval'ed and reconstruct the same specification later. Attributes - # that still have their default values are omitted. - def to_ruby - mark_version - result = "Gem::Specification.new do |s|\n" - @@attributes.each do |name, default| - # TODO better implementation of next line (read_only_attribute? ... something like that) - next if name == :dependencies or name == :specification_version - current_value = self.send(name) - result << " s.#{name} = #{ruby_code(current_value)}\n" unless current_value == default - end - dependencies.each do |dep| - version_reqs_param = dep.requirements_list.inspect - result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})\n" - end - result << "end\n" - end -=end # ------------------------- Validation and normalization methods. ## @@ -455,70 +350,181 @@ module ObjectiveJ @files.uniq! if @files end - def to_s - "#" - end - - def info_plist - return { 'CPBundleName' => name, 'CPBundleIdentifier' => identifier, 'CPBundleInfoDictionaryVersion' => 6.0, 'CPBundleVersion' => version } + def copy_of(obj) + case obj + when Numeric, Symbol, true, false, nil then obj + else obj.dup + end end - private -=begin - def find_all_satisfiers(dep) - Gem.source_index.each do |name,gem| - if(gem.satisfies_requirement?(dep)) then - yield gem +######### + + + PLATFORM_DIRECTORIES = + { + Platform::ObjJ => 'objj.platform', + Platform::Rhino => 'rhino.platform', + Platform::Browser => 'browser.platform', + Platform::BrowserDesktop => 'browser-desktop.platform', + Platform::BrowserIPhone => 'browser-iphone.platform' + } + + PLATFORM_FLAGS = + { + Platform::ObjJ => [], + Platform::Rhino => ['PLATFORM_RHINO'], + Platform::Browser => ['PLATFORM_BROWSER', 'PLATFORM_DOM'], + Platform::BrowserDesktop => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_DESKTOP'], + Platform::BrowserIPhone => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_IPHONE', 'PLATFORM_MOBILE'] + } + + # Objective-J Bundle spec containing the metadata for this bundle. + attr_accessor :bundle_spec + + def self.overwrite_accessor(name, &block) + remove_method name + define_method(name, &block) end - end - end -=end - # Duplicate an object unless it's an immediate value. - def copy_of(obj) - case obj - when Numeric, Symbol, true, false, nil then obj - else obj.dup - end - end + + def define - # Return a string containing a Ruby code representation of the given object. - def ruby_code(obj) - case obj - when String then '%q{' + obj + '}' - when Array then obj.inspect - when Gem::Version then obj.to_s.inspect - when Date, Time then '%q{' + obj.strftime('%Y-%m-%d') + '}' - when Numeric then obj.inspect - when true, false, nil then obj.inspect - when Gem::Version::Requirement then "Gem::Version::Requirement.new(#{obj.to_s.inspect})" - else raise Exception, "ruby_code case not handled: #{obj.class}" - end - end + validate + + resources_path = File.join(build_path, 'Resources') + copied_resources = [] - end # class BundleSpecification + # create file tasks for copied resources + resources.each do |resource| -end # module ObjectiveJ + copied_resource = File.join(resources_path, File.basename(resource)) -module ObjectiveJ + file_d copied_resource => [resource] do + cp_r(resource, resources_path) + end + + copied_resources << copied_resource + end + + info_plist_path = build_path + '/Info.plist' + info_plist = { 'CPBundleName' => name, 'CPBundleIdentifier' => identifier, 'CPBundleInfoDictionaryVersion' => 6.0, 'CPBundleVersion' => version } + + info_plist['CPBundlePlatforms'] = platforms; + + file_d info_plist_path do + File.open(info_plist_path, 'w') do |file| + file.puts info_plist.to_plist + end + end + + preprocessed_files = [] + + # create file tasks for object files + platforms.uniq.each do |platform| + + executable_path = File.join(build_path, PLATFORM_DIRECTORIES[platform], name + '.sj') + enhance([executable_path]) + + file_d executable_path do + BundleTask.compact(build_path) + end + + # Yes its unfortunate that we need to regenerate the whole executable if the Info.plist changes. Oh well. + file_d executable_path => info_plist_path + + sources.each do |source| - module License - LGPL_v2_1 = 'LGPL_v2_1' - end + preprocessed_file = File.join(build_path, PLATFORM_DIRECTORIES[platform], File.basename(source)) -end + file_d preprocessed_file => source do + IO.popen("objjc #{resolve_flags(flags)} #{resolve_flags(PLATFORM_FLAGS[platform])} #{source} -o #{preprocessed_file}") do |objjc| + puts objjc.read + end + end + + preprocessed_files << preprocessed_file + + file_d executable_path => preprocessed_file + end + end -def file_d(*args, &block) + # copy license file + license_path = nil + + # check if a license type has been specified + if license != nil + + copied_license = build_path + '/LICENSE' - fileTask = file_create(*args, &block) - - fileDirectory = File.dirname(fileTask.name) - directory fileDirectory - - file fileTask.name => fileDirectory + case license + when License::LGPL_v2_1 + license_path = File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'licenses', '/LGPL-v2.1')) + else + license_path = license + end + + file_d copied_license => license_path do + cp(license_path, copied_license) + end + end -end + enhance(preprocessed_files + copied_resources + [info_plist_path]) + end -def bundle(spec, *args, &block) - task = ObjectiveJ::BundleTask.define_task(*args, &block) - task.bundle_spec = spec -end + def BundleTask.compact(path, *patterns) + + puts 'Compacting ' + path + + info_plist_path = File.join(path, 'Info.plist') + info_plist = Plist::parse_xml(info_plist_path) + + absolute_path = File.expand_path(path) + '/' + + patterns = patterns.map { |pattern| "#{path}/#{pattern}" } + + bundle_name = info_plist['CPBundleName'] + replaced_files = [] + + FileList.new(File.join(path, '**', '*.platform')).each do |platform| + + FileList.new(File.join(platform, '*.j')) do |list| + + list.include(*patterns) + + executable_path = File.join(platform, bundle_name) + '.sj' + platform_absolute_path = File.expand_path(platform) + '/' + + File.open(executable_path, 'w+') do |executable| + + executable.write '@STATIC;1.0;' + + list.each do |fileName| + + File.open(fileName) do |file| + + if fileName.index(platform_absolute_path) == 0 + fileName = File.expand_path(fileName)[platform_absolute_path.length..-1] + else + fileName = File.expand_path(fileName)[absolute_path.length..-1] + end + + executable.write "p;#{fileName.length};#{fileName}#{file.read}" + + replaced_files << fileName + end + end + end + end + end + + info_plist['CPBundleReplacedFiles'] = replaced_files.uniq + info_plist['CPBundleExecutable'] = bundle_name + '.sj' + + File.open(info_plist_path, 'w') do |file| + file.puts info_plist.to_plist + end + + end + + end # class BundleSpecification + +end # module ObjectiveJ diff --git a/Tools/cplutil/cplutil b/Rake/lib/objj-executable old mode 100644 new mode 100755 similarity index 56% rename from Tools/cplutil/cplutil rename to Rake/lib/objj-executable index db0767b56..451929d45 --- a/Tools/cplutil/cplutil +++ b/Rake/lib/objj-executable @@ -1,7 +1,7 @@ #!/bin/sh # if OBJJ_HOME isn't set, try to determine it -if [ -z $OBJJ_HOME ]; then +#if [ -z $OBJJ_HOME ]; then # get path of the executable SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") @@ -15,20 +15,22 @@ if [ -z $OBJJ_HOME ]; then export OBJJ_HOME=`dirname $SELF_DIR` # check to ensure it exists, print message - if [ -d $OBJJ_HOME ]; then - echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 - else - echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 - exit 2 - fi -fi +# if [ -d $OBJJ_HOME ]; then +# echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 +# else +# echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 +# exit 2 +# fi +#fi OBJJ_LIB="$OBJJ_HOME/lib" -CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar" +FRAMEWORKS="$OBJJ_HOME/lib/Frameworks" +MAIN="$OBJJ_LIB/$(basename $SELF_PATH)/main.j" # convert paths for Cygwin if [[ `uname` == CYGWIN* ]]; then - CLASSPATH=`cygpath -wp "$CLASSPATH"` + OBJJ_HOME=`cygpath -w "$OBJJ_HOME"` + BAKE=`cygpath -w "$BLEND"` fi -java -classpath $CLASSPATH cplutil $@ +objj -I$FRAMEWORKS $MAIN $@ diff --git a/Rake/objective-j/bundle.rb b/Rake/objective-j/bundle.rb deleted file mode 100644 index fb0ced840..000000000 --- a/Rake/objective-j/bundle.rb +++ /dev/null @@ -1,146 +0,0 @@ -require 'rake' -require 'objective-j/plist' - -module ObjectiveJ - - # Create a package based upon a Gem spec. Gem packages, as well as - # zip files and tar/gzipped packages can be produced by this task. - # - # In addition to the Rake targets generated by PackageTask, a - # GemPackageTask will also generate the following tasks: - # - # ["package_dir/name-version.gem"] - # Create a Ruby GEM package with the given name and version. - # - # Example using a Ruby GEM spec: - # - # require 'rubygems' - # - # spec = Gem::Specification.new do |s| - # s.platform = Gem::Platform::RUBY - # s.summary = "Ruby based make-like utility." - # s.name = 'rake' - # s.version = PKG_VERSION - # s.requirements << 'none' - # s.require_path = 'lib' - # s.autorequire = 'rake' - # s.files = PKG_FILES - # s.description = < [resource] do - cp_r(resource, resources_path) - end - - copied_resources << copied_resource - end - - objects_path = @bundle_spec.intermediates_path - objects = [] - replaced_files = [] - - # create file tasks for object files - @bundle_spec.sources.each do |source| - - object_path = File.join(objects_path, File.basename(source, File.extname(source))) + '.o' - flags = [] - - @bundle_spec.flags.each do |flag| - flags << '-D' + flag - end - - file_d object_path => source do - IO.popen("objjc #{flags.join(' ')} #{source} -o #{object_path}") do |objjc| - puts objjc.read - end - end - - objects << object_path - replaced_files << File.basename(source) - end - - #the actual executable path - executable_path = File.join(@bundle_spec.build_path, @bundle_spec.name + '.sj') - - # copy license file - license_path = nil - - # check if a license type has been specified - if @bundle_spec.license != nil - - copied_license = @bundle_spec.build_path + '/LICENSE' - - case @bundle_spec.license - when License::LGPL_v2_1 - license_path = File.expand_path(File.join(File.dirname(__FILE__), '../LGPL-v2.1')) - else - license_path = license - end - - file_d executable_path => copied_license - - file_d copied_license => license_path do - cp(license_path, copied_license) - end - end - - file executable_path => objects do - - File.open(executable_path, "w") do |file| - - file.write('@STATIC;1.0;') - - objects.each do |object| - file.write(IO.read(object)) - end - end - end - - info_plist_path = @bundle_spec.build_path + '/Info.plist' - info_plist = @bundle_spec.info_plist - - info_plist['CPBundleExecutable'] = File.basename(executable_path) - info_plist['CPBundleReplacedFiles'] = replaced_files - - file_d info_plist_path do - File.open(info_plist_path, 'w') do |file| - file.puts info_plist.to_plist - end - end - - enhance(copied_resources + [executable_path, info_plist_path]) - end - end -end diff --git a/Rake/objective-j/plist.rb b/Rake/objective-j/plist.rb deleted file mode 100644 index d993be27a..000000000 --- a/Rake/objective-j/plist.rb +++ /dev/null @@ -1,134 +0,0 @@ -require 'rake' - -module ObjectiveJ - PLIST_START = ' - -' - PLIST_END = '' -end - -class Module - - def objj_extension(method) - - if instance_methods.include?(method) - $stderr.puts "WARNING: Possible conflict with Objective-J extension: #{self}##{method} already exists" - else - yield - end - end - -end - -class Array - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' - - each do |value| - str += value.to_plist(false) - end - - str = str + '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END if start - - return str - end - end -end - -class FalseClass - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END if start - - return str - end - end -end - -class Float - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' + to_s + '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END if start - - return str - end - end -end - -class Hash - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' - - each do |key, value| - str += '' + key.html_encode + '' + value.to_plist(false) - end - - str += '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END if start - - return str - end - end -end - -class Integer - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' + to_s + '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END - - return str - end - end -end - -class String - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' + html_encode + '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END if start - - return str - end - end - - objj_extension('html_encode') do - def html_encode - return self.gsub(//, '>'). - gsub(/"/,'"'). - gsub(/'/, '''). - gsub(/&/, '&') - end - end -end - -class TrueClass - - objj_extension('to_plist') do - def to_plist(start = true) - - str = '' - str = ObjectiveJ::PLIST_START + str + ObjectiveJ::PLIST_END if start - - return str - end - end -end diff --git a/rakefile b/Rakefile similarity index 76% rename from rakefile rename to Rakefile index 253d35f74..a52f5a657 100644 --- a/rakefile +++ b/Rakefile @@ -4,7 +4,7 @@ require 'rake' require 'common' -subprojects = %w{Objective-J Foundation AppKit} +subprojects = %w{Objective-J Foundation AppKit Tools} %w(build clean).each do |task_name| task task_name do diff --git a/Tests/Foundation/CPDateTest.j b/Tests/Foundation/CPDateTest.j index a94ec00c5..075f93ce7 100644 --- a/Tests/Foundation/CPDateTest.j +++ b/Tests/Foundation/CPDateTest.j @@ -2,6 +2,14 @@ import @implementation CPDateTest : OJTestCase +- (void)testSince1970 +{ + /* These two dates should be equal to Fri Feb 13 2009 15:31:30 GMT-0800 */ + unixDate = [CPDate dateWithTimeIntervalSince1970: 1234567890]; + cocoaDate = [CPDate dateWithTimeIntervalSinceReferenceDate: 253582290]; + [self assertTrue:[unixDate isEqualToDate: cocoaDate]]; +} + - (void)testDate { var before = new Date(); @@ -17,4 +25,4 @@ import [self assert:middle equals:[middle laterDate:past] message:"laterDate incorrect"]; } -@end \ No newline at end of file +@end diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j index f509e8128..50b07d41c 100644 --- a/Tests/Foundation/CPStringTest.j +++ b/Tests/Foundation/CPStringTest.j @@ -16,14 +16,112 @@ import } - (void)testStringByAppendingFormat { - var format = @"%d X %d = %d"; - var expectedString = "2 X 3 = 6"; - var dummyString = @""; - var actualString = [dummyString stringByAppendingFormat:format ,2 ,3 ,6]; + var format = @"%d X %d = %d", + expectedString = "2 X 3 = 6", + dummyString = @"", + actualString = [dummyString stringByAppendingFormat:format, 2, 3, 6]; + [self assertTrue:(expectedString === actualString) message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString]; - } + +- (void)testStringWithString +{ + var original = [[CPString alloc] initWithString:"str"], + copy = [CPString stringWithString:original]; + + [self assertTrue:(original == copy) message:"Contents should be equal"]; +} + +- (void)testInitWithString +{ + var str = [[CPString alloc] initWithString:"str"]; + [self assert:"str" equals:str]; +} + +- (void) testInitWithFormat +{ + // this could be really big + var str = [[CPString alloc] initWithFormat:"%s", "str"]; + [self assert:"str" equals:str]; + + str = [[CPString alloc] initWithFormat:"%d", 42]; + [self assert:"42" equals:str]; + + str = [[CPString alloc] initWithFormat:"%f", 42.2]; + [self assert:"42.2" equals:str]; +} + +- (void)testStringWithFormat +{ + // this could be equally big + var str = [CPString stringWithFormat:"%s", "str"]; + [self assert:"str" equals:str]; + + str = [CPString stringWithFormat:"%d", 42]; + [self assert:"42" equals:str]; + + str = [CPString stringWithFormat:"%f", 42.2]; + [self assert:"42.2" equals:str]; +} + +- (void)testLength +{ + [self assert:0 equals:["" length]]; + [self assert:1 equals:["a" length]]; + [self assert:5 equals:["abcde" length]]; + [self assert:3 equals:["日本語" length]]; +} + +- (void)testCharacterAtIndex +{ + [self assert:"a" equals:["abcd" characterAtIndex:0]]; + [self assert:"b" equals:["abcd" characterAtIndex:1]]; + [self assert:"d" equals:["abcd" characterAtIndex:3]]; + [self assert:"語" equals:["日本語" characterAtIndex:2]]; +} + +- (void)testStringByAppendingSting +{ + [self assert:"onetwo" equals:["one" stringByAppendingString:"two"]]; +} + + +- (void)testStringByPaddingToLength +{ + [self assert:"onebcd" + equals:["one" stringByPaddingToLength:6 + withString:"abcdefg" + startingAtIndex:1]]; +} + +- (void)testComponentsSeparatedByString +{ + [self assert:["arash", "francisco", "ross", "tom"] + equals:["arash.francisco.ross.tom" componentsSeparatedByString:"."]]; +} + +- (void)testSubstringFromIndex +{ + [self assert:"abcd" equals:["abcd" substringFromIndex:0]]; + [self assert:"bcd" equals:["abcd" substringFromIndex:1]]; + [self assert:"" equals:["abcd" substringFromIndex:4]]; +} + +- (void)testSubstringWithRange +{ + [self assert:"bcd" equals:["abcde" substringWithRange:CPMakeRange(1,3)]]; + [self assert:"abcde" equals:["abcde" substringWithRange:CPMakeRange(0,5)]]; + [self assert:"" equals:["abcde" substringWithRange:CPMakeRange(1,0)]]; +} + +- (void)testSubstringToIndex +{ + [self assert:"abcd" equals:["abcd" substringToIndex:4]]; + [self assert:"abc" equals:["abcd" substringToIndex:3]]; + [self assert:"" equals:["abcd" substringToIndex:0]]; +} + - (void)testBoolValue { var testStrings = [ @@ -59,6 +157,27 @@ import [self assert:[testStrings[i][0] capitalizedString] equals:testStrings[i][1]]; } +- (void)testUppercaseString +{ + var str = "This is a test"; + [self assert:[str uppercaseString] equals:"THIS IS A TEST"]; +} + +- (void)testLowercaseString +{ + var str = "This Is A TEST"; + [self assert:"this is a test" equals:[str lowercaseString]]; +} + +- (void)testStringWithHash +{ + [self assert:"000000" equals:[CPString stringWithHash:0]]; + [self assert:"000001" equals:[CPString stringWithHash:1]]; + [self assert:"00000a" equals:[CPString stringWithHash:10]]; + [self assert:"000010" equals:[CPString stringWithHash:16]]; + [self assert:"ffffff" equals:[CPString stringWithHash:16777215]]; +} + - (void)testStringByDeletingLastPathComponent { var testStrings = [ @@ -80,4 +199,31 @@ import [self assert:[testStrings[i][0] stringByDeletingLastPathComponent] equals:testStrings[i][1]]; } +- (void)testPathComponents +{ + var testStrings = [ + ["tmp/scratch", ["tmp", "scratch"]], + ["/tmp/scratch", ["/", "tmp", "scratch"]] + ] + + for (var i = 0; i < testStrings.length; i++) { + var result = [testStrings[i][0] pathComponents]; + [self assertTrue:[result isEqualToArray:testStrings[i][1]] message:"Expected [" + testStrings[i][1] + "] was [" + result + "]"]; + } +} + +- (void)testLastPathComponent +{ + var testStrings = [ + ["/tmp/scratch.tiff", "scratch.tiff"], + ["/tmp/scratch", "scratch"], + ["/tmp/", "tmp"], + ["scratch", "scratch"], + ["/", "/"] + ]; + + for (var i = 0; i < testStrings.length; i++) + [self assert:testStrings[i][1] equals:[testStrings[i][0] lastPathComponent]]; +} + @end diff --git a/Tools/Documentation/Cappuccino.doxygen b/Tools/Documentation/Cappuccino.doxygen index d083ca453..91129133f 100644 --- a/Tools/Documentation/Cappuccino.doxygen +++ b/Tools/Documentation/Cappuccino.doxygen @@ -137,7 +137,8 @@ EXCLUDE = AppKit/Cib \ EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = _* EXCLUDE_SYMBOLS = _* -EXAMPLE_PATH = +EXAMPLE_PATH = ./README \ + ./LICENSE EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO IMAGE_PATH = diff --git a/Tools/SubEthaEdit/Objective-J.mode.zip b/Tools/Editors/SubEthaEdit/Objective-J.mode.zip similarity index 64% rename from Tools/SubEthaEdit/Objective-J.mode.zip rename to Tools/Editors/SubEthaEdit/Objective-J.mode.zip index 95f9b988f..83fa37b09 100644 Binary files a/Tools/SubEthaEdit/Objective-J.mode.zip and b/Tools/Editors/SubEthaEdit/Objective-J.mode.zip differ diff --git a/Tools/TextMate/JavaScript Objective-J.tmbundle.zip b/Tools/Editors/TextMate/JavaScript Objective-J.tmbundle.zip similarity index 100% rename from Tools/TextMate/JavaScript Objective-J.tmbundle.zip rename to Tools/Editors/TextMate/JavaScript Objective-J.tmbundle.zip diff --git a/Tools/Vim/objj.vim b/Tools/Editors/Vim/objj.vim similarity index 100% rename from Tools/Vim/objj.vim rename to Tools/Editors/Vim/objj.vim diff --git a/Objective-J/rakefile b/Tools/Rakefile similarity index 72% rename from Objective-J/rakefile rename to Tools/Rakefile index 4631e50dd..05ee29aa5 100644 --- a/Objective-J/rakefile +++ b/Tools/Rakefile @@ -4,10 +4,12 @@ require 'rake' require '../common' -subprojects = %w{Runtime Tools} +subprojects = %w{capp nib2cib} %w(build clean).each do |task_name| task task_name do subrake(subprojects) end end + +#task :deploy => [:build] \ No newline at end of file diff --git a/Tools/Utilities/bridge.js b/Tools/Utilities/bridge.js index d86c72471..1306ef2c0 100644 --- a/Tools/Utilities/bridge.js +++ b/Tools/Utilities/bridge.js @@ -584,4 +584,86 @@ if (!OBJJ_HOME) { OBJJ_HOME = "/usr/local/share/objj"; alert("OBJJ_HOME environment variable not set, defaulting to " + OBJJ_HOME); -} \ No newline at end of file +} + +function exec(/*Array*/ command, /*Boolean*/ showOutput) +{ + var line = "", + output = "", + + process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command)); + reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream())); + + while (line = reader.readLine()) + { + if (showOutput) + Packages.java.lang.System.out.println(line); + + output += line + '\n'; + } + + reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream())); + + while (line = reader.readLine()) + Packages.java.lang.System.out.println(line); + + try + { + if (process.waitFor() != 0) + Packages.java.lang.System.err.println("exit value = " + process.exitValue()); + } + catch (anException) + { + Packages.java.lang.System.err.println(anException); + } + + return output; +} + + +function getFiles(/*File*/ sourceDirectory, /*nil|String|Array*/ extensions, /*Array*/ exclusions) +{ + var matches = [], + files = sourceDirectory.listFiles(), + hasMultipleExtensions = typeof extensions !== "string"; + + if (files) + { + var index = 0, + count = files.length; + + for (; index < count; ++index) + { + var file = files[index].getCanonicalFile(), + name = String(file.getName()), + isValidExtension = !extensions; + + if (exclusions && fileArrayContainsFile(exclusions, file)) + continue; + + if (!isValidExtension) + if (hasMultipleExtensions) + { + var extensionCount = extensions.length; + + while (extensionCount-- && !isValidExtension) + { + var extension = extensions[extensionCount]; + + if (name.substring(name.length - extension.length - 1) === ("." + extension)) + isValidExtension = true; + } + } + else if (name.substring(name.length - extensions.length - 1) === ("." + extensions)) + isValidExtension = true; + + if (isValidExtension) + matches.push(file); + + if (file.isDirectory()) + matches = matches.concat(getFiles(file, extensions, exclusions)); + } + } + + return matches; +} diff --git a/Tools/blend/BlendKit/BlendKit.steam b/Tools/blend/BlendKit/BlendKit.steam deleted file mode 100644 index 75d93232e..000000000 --- a/Tools/blend/BlendKit/BlendKit.steam +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Name - BlendKit - Targets - - - Name - BlendKit - - - Configurations - - - Name - Debug - Flags - -DDEBUG -DPLATFORM_DOM -g - - - Name - Release - Flags - -DPLATFORM_DOM -O - - - Name - Debug-Rhino - Flags - -DDEBUG -g - - - Name - Release-Rhino - Flags - -O - - - - diff --git a/Tools/blend/BlendKit/build.xml b/Tools/blend/BlendKit/build.xml deleted file mode 100644 index 67c5ff641..000000000 --- a/Tools/blend/BlendKit/build.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/blend/build.xml b/Tools/blend/build.xml deleted file mode 100644 index 903d5a94a..000000000 --- a/Tools/blend/build.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/capp/Rakefile b/Tools/capp/Rakefile new file mode 100644 index 000000000..afd9c0ec9 --- /dev/null +++ b/Tools/capp/Rakefile @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../../common' +require 'objective-j' +require 'objective-j/bundletask' + + +$PRODUCT = :capp +$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'capp') +$ENVIRONMENT_BIN_PRODUCT = File.join($ENVIRONMENT_BIN_DIR, 'capp') +$ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'capp') + +task :build => [:capp, $ENVIRONMENT_BIN_PRODUCT, $ENVIRONMENT_LIB_PRODUCT] + +# Debug Framework +ObjectiveJ::BundleTask.new(:capp) do |t| + t.name = 'capp' + t.identifier = 'com.280n.capp' + t.version = '0.6.5' + t.author = '280 North, Inc.' + t.email = 'feedback @nospam@ 280north.com' + t.summary = 'Setup up Cappuccino projects' + t.sources = FileList['*.j'] + t.resources = FileList['Resources/*', 'Templates'] + t.license = ObjectiveJ::License::LGPL_v2_1 + t.build_path = $BUILD_PATH + t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' +end + +#executable in environment directory +file_d $ENVIRONMENT_BIN_PRODUCT do + make_objj_executable($ENVIRONMENT_BIN_PRODUCT) +end + +file_d $ENVIRONMENT_LIB_PRODUCT => [:capp] do + cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_LIB_PRODUCT) +end diff --git a/Objective-J/Tools/steam/Templates/Application/AppController.j b/Tools/capp/Templates/Application/AppController.j similarity index 100% rename from Objective-J/Tools/steam/Templates/Application/AppController.j rename to Tools/capp/Templates/Application/AppController.j diff --git a/Objective-J/Tools/steam/Templates/Application/Info.plist b/Tools/capp/Templates/Application/Info.plist similarity index 100% rename from Objective-J/Tools/steam/Templates/Application/Info.plist rename to Tools/capp/Templates/Application/Info.plist diff --git a/Objective-J/Tools/steam/Templates/Application/index-debug.html b/Tools/capp/Templates/Application/index-debug.html similarity index 100% rename from Objective-J/Tools/steam/Templates/Application/index-debug.html rename to Tools/capp/Templates/Application/index-debug.html diff --git a/Objective-J/Tools/steam/Templates/Application/index.html b/Tools/capp/Templates/Application/index.html similarity index 100% rename from Objective-J/Tools/steam/Templates/Application/index.html rename to Tools/capp/Templates/Application/index.html diff --git a/Objective-J/Tools/steam/Templates/Application/main.j b/Tools/capp/Templates/Application/main.j similarity index 100% rename from Objective-J/Tools/steam/Templates/Application/main.j rename to Tools/capp/Templates/Application/main.j diff --git a/Objective-J/Tools/steam/Templates/ThemeDescriptor/Info.plist b/Tools/capp/Templates/ThemeDescriptor/Info.plist similarity index 100% rename from Objective-J/Tools/steam/Templates/ThemeDescriptor/Info.plist rename to Tools/capp/Templates/ThemeDescriptor/Info.plist diff --git a/Objective-J/Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j b/Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j similarity index 100% rename from Objective-J/Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j rename to Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j diff --git a/Objective-J/Tools/steam/Templates/ThemeDescriptor/index-debug.html b/Tools/capp/Templates/ThemeDescriptor/index-debug.html similarity index 100% rename from Objective-J/Tools/steam/Templates/ThemeDescriptor/index-debug.html rename to Tools/capp/Templates/ThemeDescriptor/index-debug.html diff --git a/Objective-J/Tools/steam/Templates/ThemeDescriptor/index.html b/Tools/capp/Templates/ThemeDescriptor/index.html similarity index 100% rename from Objective-J/Tools/steam/Templates/ThemeDescriptor/index.html rename to Tools/capp/Templates/ThemeDescriptor/index.html diff --git a/Objective-J/Tools/steam/Templates/ThemeDescriptor/main.j b/Tools/capp/Templates/ThemeDescriptor/main.j similarity index 100% rename from Objective-J/Tools/steam/Templates/ThemeDescriptor/main.j rename to Tools/capp/Templates/ThemeDescriptor/main.j diff --git a/Objective-J/Tools/steam/create-frameworks.js b/Tools/capp/main.j similarity index 50% rename from Objective-J/Tools/steam/create-frameworks.js rename to Tools/capp/main.j index 89b355ea9..024fdd617 100644 --- a/Objective-J/Tools/steam/create-frameworks.js +++ b/Tools/capp/main.j @@ -1,9 +1,25 @@ -function createFrameworks() + +importClass(java.lang.System); +importClass(java.io.File); +importClass(java.io.FileWriter); +importClass(java.io.FileOutputStream); +importClass(java.io.BufferedWriter); +importClass(java.io.OutputStreamWriter); + +@import + +function main() { - var shouldSymbolicallyLink = false, - index = 0, + if (arguments.length < 1) + return printUsage(); + + var index = 0, count = arguments.length, + shouldSymbolicallyLink = false, + justFrameworks = false, + + template = "Application", destination = ""; for (; index < count; ++index) @@ -12,14 +28,50 @@ function createFrameworks() switch (arguments[index]) { - case "-l": shouldSymbolicallyLink = true; - break; + case "-l": shouldSymbolicallyLink = true; + break; + + case "-h": + case "--help": printUsage(); + return; - default: destination = argument; + case "-t": + case "--template": template = arguments[++index]; + break; + + case "-f": + case "--frameworks": justFrameworks = true; + break; + + default: destination = argument; } } - createFrameworksInFile(new File(destination), shouldSymbolicallyLink); + var sourceTemplate = new File(OBJJ_HOME + "/lib/capp/Resources/Templates/" + template), + destinationProject = new File(destination); + + if (!destinationProject.exists()) + { + exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true); + + var files = getFiles(destinationProject, ['j', "plist", "html"]), + index = 0, + count = files.length; + + for (; index < count; ++index) + { + var file = files[index], + contents = readFile(file); + + contents = contents.replace(/__Product__/g, destinationProject.getName()); + + writeContentsToFile(contents, file); + } + + createFrameworksInFile(destinationProject, shouldSymbolicallyLink); + } + else + print("Directory already exists"); } function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLink) @@ -29,12 +81,10 @@ function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLi if (!shouldSymbolicallyLink) { - var sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks"), - sourceDebugFrameworks = new File(OBJJ_HOME + "/lib/Frameworks-Debug"); + var sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks"); exec(["cp", "-vR", sourceFrameworks.getCanonicalPath(), destinationFrameworks.getCanonicalPath()], true); - exec(["cp", "-vR", sourceDebugFrameworks.getCanonicalPath(), destinationDebugFrameworks.getCanonicalPath()], true); - + return true; } @@ -63,4 +113,19 @@ function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLi exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(), new File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true); -} \ No newline at end of file +} + +function printUsage() +{ + print("capp /path/to/your/app [options]"); +} + + +function writeContentsToFile(/*String*/ aString, /*File*/ aFile) +{ + var writer = new BufferedWriter(new FileWriter(aFile)); + + writer.write(aString); + + writer.close(); +} diff --git a/Tools/cplutil/build.xml b/Tools/cplutil/build.xml deleted file mode 100644 index 39463c3d1..000000000 --- a/Tools/cplutil/build.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/cplutil/cplutil.js b/Tools/cplutil/cplutil.js deleted file mode 100644 index 455df7a0f..000000000 --- a/Tools/cplutil/cplutil.js +++ /dev/null @@ -1,103 +0,0 @@ - -importPackage(java.lang); - -importClass(java.io.File); -importClass(java.io.BufferedReader); -importClass(java.io.FileReader); -importClass(java.io.BufferedWriter); -importClass(java.io.FileWriter); - - -function printUsage() -{ - print("this is where you say the usage"); -} - -function main() -{ - if (arguments.length < 1) - return printUsage(); - - var allFiles = NO, - format = nil, - filePaths = [], - outPath = nil, - outExtension = nil; - - index = 0, - count = arguments.length; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - if (argument.charAt(0) === '-' && !allFiles) - { - if (filePaths.length > 0) - return printUsage(); - - else if (argument === "-convert") - format = arguments[++index]; - - else if (argument === "-o") - outPath = arguments[++index]; - - else if (argument === "-e") - outExtension = arguments[++index]; - - else if (argument === "--") - allFiles = YES; - - else if (argument === "-help") - return printUsage(); - } - else - filePaths.push(arguments[index]); - } - - index = 0; - count = filePaths.length; - - for (; index < count; ++index) - { - // Read the plist file - var file = new File(filePaths[index]), - reader = new BufferedReader(new FileReader(file)), - fileContents = ""; - - // Get contents of the file - while (reader.ready()) - fileContents += reader.readLine() + '\n'; - - reader.close(); - - var data = new objj_data(); - - data.string = fileContents; - - var plistObject = new CPPropertyListCreateFromData(data); - - if (format === "280north1") - data = CPPropertyListCreate280NorthData(plistObject); - - else if (format === "xml1") - data = CPPropertyListCreateXMLData(plistObject); - - var outFile = file; - - if (outPath) - outFile = new File(outPath); - -// else if (outExtension) - - - // Write out file - var writer = new BufferedWriter(new FileWriter(outFile)); - - writer.write(data.string); - - writer.close(); - } -} - -main.apply(main, arguments); diff --git a/Tools/nib2cib/Rakefile b/Tools/nib2cib/Rakefile new file mode 100644 index 000000000..1d28a345f --- /dev/null +++ b/Tools/nib2cib/Rakefile @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../../common' +require 'objective-j' +require 'objective-j/bundletask' + + +$PRODUCT = :nib2cib +$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'nib2cib') +$ENVIRONMENT_BIN_PRODUCT = File.join($ENVIRONMENT_BIN_DIR, 'nib2cib') +$ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'nib2cib') + +task :build => [:nib2cib, $ENVIRONMENT_BIN_PRODUCT, $ENVIRONMENT_LIB_PRODUCT] + +# Debug Framework +ObjectiveJ::BundleTask.new(:nib2cib) do |t| + t.name = 'nib2cib' + t.identifier = 'com.280n.nib2cib' + t.version = '0.6.5' + t.author = '280 North, Inc.' + t.email = 'feedback @nospam@ 280north.com' + t.summary = 'nib2cib converts Cocoa nib and xibs to Cappuccino cibs' + t.sources = FileList['**/*.j'] + t.resources = FileList['Resources/*'] + t.license = ObjectiveJ::License::LGPL_v2_1 + t.build_path = $BUILD_PATH + t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' +end + +#executable in environment directory +file_d $ENVIRONMENT_BIN_PRODUCT do + make_objj_executable($ENVIRONMENT_BIN_PRODUCT) +end + +file_d $ENVIRONMENT_LIB_PRODUCT => [:nib2cib] do + cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_LIB_PRODUCT) +end diff --git a/Tools/nib2cib/build.xml b/Tools/nib2cib/build.xml deleted file mode 100644 index 4ab48491f..000000000 --- a/Tools/nib2cib/build.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index cda30b1e3..52b5882c1 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -248,5 +248,3 @@ function main() else convert(inputFileName, outputFileName, resourcesPath); } - -main.apply(main, args); diff --git a/Tools/nib2cib/nib2cib.steam b/Tools/nib2cib/nib2cib.steam deleted file mode 100644 index 06ed7627c..000000000 --- a/Tools/nib2cib/nib2cib.steam +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Name - nib2cib - Targets - - - Name - nib2cib - - - Configurations - - - Name - Debug - Settings - - PREPROCESS - - FLAGS - -DDEBUG - - - - Name - Release - Settings - - PREPROCESS - - PREINTERPRET - - - - - - diff --git a/Tools/press/objj-analysis-tools.j b/Tools/press/objj-analysis-tools.j index 628c6c78a..c225998fc 100644 --- a/Tools/press/objj-analysis-tools.j +++ b/Tools/press/objj-analysis-tools.j @@ -85,7 +85,7 @@ function traverseDependencies(context, file) { if (context.dependencies[token]) { - var files = context.dependencies[token] + var files = context.dependencies[token]; for (var j = 0; j < files.length; j++) { // don't record references to self @@ -232,7 +232,7 @@ function findGlobalDefines(context, scope, rootPath, evaledFragments) if (evaledFragments) { - evaledFragments.push(aFragment); + evaledFragments.push(aFragment); } var result = fragment_evaluate_code_original(aFragment); diff --git a/Tools/press/press.j b/Tools/press/press.j index b3aa7aba9..ed96f4536 100644 --- a/Tools/press/press.j +++ b/Tools/press/press.j @@ -11,7 +11,8 @@ var usageMessage = --frameworks path The relative path (from root_directory) to the frameworks directory (default: 'Frameworks')\n\ --png Run pngcrush on all PNGs (pngcrush must be installed!)\n\ --flatten Flatten all code into a single Application.js file and attempt add script tag to index.html (useful for Adobe AIR and CDN deployment)\n\ - --nostrip Don't strip any files"; + --nostrip Don't strip any files\n\ + --v Verbose"; function main() { @@ -22,7 +23,7 @@ function main() optimizePNG = false, flatten = false, noStrip = false, - verbose = true; + verbose = false; var usageError = false; while (args.length && !usageError) @@ -51,6 +52,9 @@ function main() case "--nostrip": noStrip = true; break; + case "--v": + verbose = true; + break; default: if (rootDirectory == null) rootDirectory = arg.replace(/\/$/, ""); @@ -125,6 +129,11 @@ function main() // coalesce the results var dependencies = coalesceGlobalDefines(globals); + // Log + CPLog.trace("Global defines:"); + for (var i in dependencies) + CPLog.trace(" " + i + " => " + dependencies[i]); + // phase 2: walk the dependency tree (both imports and references) to determine exactly which files need to be included CPLog.error("PHASE 2: Walk dependency tree..."); @@ -143,7 +152,7 @@ function main() return; } - CPLog.info("Analyzing dependencies..."); + CPLog.warn("Analyzing dependencies..."); var context = { scope : scope, @@ -172,21 +181,21 @@ function main() } else { - CPLog.warn("Excluded: " + path); + CPLog.info("Excluded: " + path); } total++; } - CPLog.info("Total required files: " + count + " out of " + total); + CPLog.warn("Total required files: " + count + " out of " + total); // FIXME: sprite images - for (var i in context.bundleImages) - { - var images = context.bundleImages[i]; - - //CPLog.info("Bundle images for " + i); - //for (var j in images) - // CPLog.debug(j + " = " + images[j]); - } + //for (var i in context.bundleImages) + //{ + // var images = context.bundleImages[i]; + // + // CPLog.debug("Bundle images for " + i); + // for (var j in images) + // CPLog.trace(j + " = " + images[j]); + //} } var outputFiles = {}; @@ -236,7 +245,7 @@ function main() } else { - CPLog.warn("Stripping " + evaledFragments[i].file.path); + CPLog.info("Stripping " + evaledFragments[i].file.path); } } @@ -272,7 +281,7 @@ function main() directory = dirname(path); if (file.path != path) - CPLog.warn("Sanity check (file path): " + file.path + " vs. " + path); + CPLog.warn("Sanity check failed (file path): " + file.path + " vs. " + path); if (file.bundle) { @@ -282,7 +291,7 @@ function main() bundles[file.bundle.path] = file.bundle; if (bundleDirectory != directory) - CPLog.warn("Sanity check (directory path): " + directory + " vs. " + bundleDirectory); + CPLog.warn("Sanity check failed (directory path): " + directory + " vs. " + bundleDirectory); // if it's in a .sj var dict = file.bundle.info, @@ -337,7 +346,7 @@ function main() } } else - CPLog.warn("Ignoring import fragment " + file.fragments[i].info + " in " + path); + CPLog.info("Ignoring import fragment " + file.fragments[i].info + " in " + path); } else CPLog.error("Unknown fragment type"); @@ -362,6 +371,8 @@ function main() dict = bundles[path].info, replacedFiles = [dict objectForKey:"CPBundleReplacedFiles"]; + CPLog.info("Modifying .sj: " + path); + if (replacedFiles) { var newReplacedFiles = []; diff --git a/Tools/steam/Project.js b/Tools/steam/Project.js deleted file mode 100644 index 3e48b401c..000000000 --- a/Tools/steam/Project.js +++ /dev/null @@ -1,331 +0,0 @@ - -importClass(java.io.FileOutputStream); -importClass(java.io.BufferedWriter); -importClass(java.io.OutputStreamWriter); - -function Target(dictionary) -{ - this._name = dictionary_getValue(dictionary, "Name"); - - var flagsString = dictionary_getValue(dictionary, "Flags"); - - this._flags = flagsString ? flagsString.split(/\s+/) : []; - - this._type = dictionary_getValue(dictionary, "Type"); - - if (!this._type) - this._type = "280N.application"; - - this._exclusions = []; - - var exclusions = dictionary_getValue(dictionary, "Excluded"); - - if (exclusions) - { - var index = 0, - count = exclusions.length; - - for (; index < count; ++index) - this._exclusions.push(new File((exclusions[index])).getCanonicalFile()); - } - - return this; -} - -Target.prototype.name = function() -{ - return this._name; -} - -Target.prototype.exclusions = function() -{ - return this._exclusions; -} - -Target.prototype.flags = function() -{ - return this._flags; -} - -Target.prototype.type = function() -{ - return this._type; -} - -function Configuration(dictionary) -{ - this._name = dictionary_getValue(dictionary, "Name"); - - var flagsString = dictionary_getValue(dictionary, "Flags"); - - this._flags = flagsString ? flagsString.split(/\s+/) : []; - - return this; -} - -Configuration.prototype.name = function() -{ - return this._name; -} - -Configuration.prototype.flags = function() -{ - return this._flags; -} - -function Project(/*String*/ aFilePath, /*String*/ aBuildPath) -{ - this._file = new File(aFilePath).getCanonicalFile(); - this._root = this._file.getParentFile(); - - // Read the project file (its just a plist). - this._properties = readPlist(this._file); - - this._name = dictionary_getValue(this._properties, "Name"); - - // Read existing Info.plist if it exists. - var infoPlist = new File(this._root.getAbsolutePath() + "/Info.plist"); - - if (infoPlist.exists()) - this._infoDictionary = readPlist(new File(this._root.getAbsolutePath() + "/Info.plist")); - else - this._infoDictionary = new objj_dictionary(); - - this.buildPath = aBuildPath; - - // Covert target dictionaries to target objects. - var targetDictionaries = dictionary_getValue(this._properties, "Targets"); - - this._targets = []; - - for (var index = 0, count = targetDictionaries.length; index < count; ++index) - this._targets.push(new Target(targetDictionaries[index])); - - this.setActiveTarget(this._targets[0]); - - // Covert target dictionaries to target objects. - var configurationDictionaries = dictionary_getValue(this._properties, "Configurations"); - - this._configurations = []; - - for (index = 0, count = configurationDictionaries.length; index < count; ++index) - this._configurations.push(new Configuration(configurationDictionaries[index])); - - this.setActiveConfiguration(this._configurations[0]); - - // Grab the Resources Directory (if it exists) - this._resources = new File(this._root.getAbsolutePath() + "/Resources/").getCanonicalFile(); - - return this; -} - -Project.prototype.name = function() -{ - return this._name; -} - -Project.prototype.targetWithName = function(/*String*/ aName) -{ - var targets = this._targets, - index = 0, - count = targets.length; - - for (; index < count; ++index) - { - var target = targets[index]; - - if (target.name() == aName) - return target; - } - - return null; -} - -Project.prototype.configurationWithName = function(/*String*/ aName) -{ - var configurations = this._configurations, - index = 0, - count = configurations.length; - - for (; index < count; ++index) - { - var configuration = configurations[index]; - - if (configuration.name() == aName) - return configuration; - } - - return null; -} - -Project.prototype.setActiveTarget = function(/*Target*/ aTarget) -{ - this._activeTarget = aTarget; - - this._buildProducts = null; - this._buildIntermediates = null; - this._buildObjects = null; -} - -Project.prototype.activeTarget = function() -{ - return this._activeTarget; -} - -Project.prototype.setActiveConfiguration = function(/*Configuration*/ aConfiguration) -{ - this._activeConfiguration = aConfiguration; - - this._buildProducts = null; - this._buildIntermediates = null; - this._buildObjects = null; -} - -Project.prototype.activeConfiguration = function() -{ - return this._activeConfiguration; -} - -Project.prototype.buildProducts = function() -{ - if (!this._buildProducts) - { - this._buildProducts = new File(this.buildPath + '/' + this._activeConfiguration.name() + '/' + this._activeTarget.name()).getCanonicalFile(); - this._buildProducts.mkdirs(); - } - - return this._buildProducts; -} - -Project.prototype.buildIntermediates = function() -{ - if (!this._buildIntermediates) - { - this._buildIntermediates = new File(this.buildPath + '/' + this._activeTarget.name() + ".build/" + this._activeConfiguration.name()).getCanonicalFile(); - this._buildIntermediates.mkdirs(); - } - - return this._buildIntermediates; -} - -Project.prototype.buildObjects = function() -{ - if (!this._buildObjects) - { - this._buildObjects = new File(this.buildIntermediates().getAbsolutePath() + '/' + this._activeTarget.name()).getCanonicalFile(); - this._buildObjects.mkdirs(); - } - - return this._buildObjects; -} - -Project.prototype.activeFlags = function() -{ - return this.activeTarget().flags().concat(this.activeConfiguration().flags()); -} - -Project.prototype.build = function() -{ - java.lang.System.out.println("Building Target \"" + this.activeTarget().name() + - "\" of Project \"" + this.name() + - "\" with Configuration \"" + this.activeConfiguration().name() + "\"."); - - var jFiles = getFiles(this._root, "j", this._activeTarget.exclusions()), - replacedFiles = []; - hasModifiedJFiles = false; - shouldObjjPreprocess = true, - shouldGzip = this._gzip, - objjcComponents = ["sh", OBJJ_HOME + "/bin/objjc"]; - - objjcComponents = objjcComponents.concat(this.activeFlags()); - - if (!shouldObjjPreprocess) - objjcComponents.push("-E"); - - var buildObjects = this.buildObjects(), - buildProducts = this.buildProducts(); - - for (index = 0, count = jFiles.length; index < count; ++index) - { - var file = jFiles[index], - builtFile = new File(buildObjects.getAbsolutePath() + '/' + getFileNameWithoutExtension(file) + '.o'); - - replacedFiles.push(file.getName() + ""); - - if (builtFile.exists() && file.lastModified() < builtFile.lastModified()) - continue; - else - hasModifiedJFiles = true; - - objjcComponents.push(file.getAbsolutePath()); - - objjcComponents.push("-o"); - objjcComponents.push(buildObjects.getAbsolutePath() + '/' + getFileNameWithoutExtension(file) + '.o'); - } - - exec(objjcComponents, true); - - var oFiles = getFiles(buildObjects, 'o'), - sjFile = new File(buildProducts.getCanonicalPath() + '/' + this._activeTarget.name() + ".sj"); - - if (hasModifiedJFiles) - { - // concatenate sjheader.txt and individual .o - exec(["sh", "-c", "cat '" + OBJJ_STEAM + "/sjheader.txt' '" + oFiles.join("' '") + "' > '" + sjFile.getCanonicalPath() + "'"], true); - } - - if (shouldGzip) - { - // gzip and copy .htaccess file - exec(["sh", "-c", "gzip -c '" + sjFile.getCanonicalPath() + "' > '" + sjFile.getCanonicalPath() + ".gz'"], true); - exec(["cp", OBJJ_HOME + "/lib/htaccess", sjFile.getParentFile().getCanonicalPath() + "/.htaccess"], true); - } - else - { - // remove gzip and .htaccess file if present - exec(["rm", "-f", sjFile.getParentFile().getCanonicalPath() + "/.htaccess", sjFile.getCanonicalPath() + ".gz"], true); - } - - dictionary_setValue(this._infoDictionary, "CPBundleExecutable", this._activeTarget.name() + ".sj"); - dictionary_setValue(this._infoDictionary, "CPBundleReplacedFiles", replacedFiles); - - this.writeInfoPlist(); - - this.copyResources(); - - // FIXME: This should be, if this is an app... - if (dictionary_getValue(this._infoDictionary, "CPBundlePackageType") == "280N") - this.copyIndexFile(); - -} - -Project.prototype.clean = function() -{ - java.lang.System.out.println("Cleaning Target \"" + this.activeTarget().name() + - "\" of Project \"" + this.name() + - "\" with Configuration \"" + this.activeConfiguration().name() + "\"."); - - exec(["rm", "-rf", this.buildIntermediates().getAbsolutePath()], true); - exec(["rm", "-rf", this.buildProducts().getAbsolutePath()], true); -} - -Project.prototype.copyIndexFile = function() -{ - var indexFile = new File(this._root.getAbsolutePath() + "/index.html").getCanonicalFile(); - - rsync(indexFile, this.buildProducts()); -} - -Project.prototype.writeInfoPlist = function() -{ - var writer = new BufferedWriter(new FileWriter(this.buildProducts().getAbsolutePath() + '/' + "Info.plist")); - - writer.write(CPPropertyListCreateXMLData(this._infoDictionary).string); - - writer.close(); -} - -Project.prototype.copyResources = function() -{ - rsync(this._resources, this.buildProducts()); -} diff --git a/Tools/steam/Templates/Application/AppController.j b/Tools/steam/Templates/Application/AppController.j deleted file mode 100644 index 21ede646e..000000000 --- a/Tools/steam/Templates/Application/AppController.j +++ /dev/null @@ -1,39 +0,0 @@ -/* - * AppController.j - * __Product__ - * - * Created by __Me__ on __Date__. - * Copyright 2008 __MyCompanyName__. All rights reserved. - */ - -@import - - -@implementation AppController : CPObject -{ -} - -- (void)applicationDidFinishLaunching:(CPNotification)aNotification -{ - var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], - contentView = [theWindow contentView]; - - var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; - - [label setStringValue:@"Hello World!"]; - [label setFont:[CPFont boldSystemFontOfSize:24.0]]; - - [label sizeToFit]; - - [label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; - [label setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([label frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([label frame])) / 2.0)]; - - [contentView addSubview:label]; - - [theWindow orderFront:self]; - - // Uncomment the following line to turn on the standard menu bar. - //[CPMenu setMenuBarVisible:YES]; -} - -@end diff --git a/Tools/steam/Templates/Application/Info.plist b/Tools/steam/Templates/Application/Info.plist deleted file mode 100644 index a81852dcd..000000000 --- a/Tools/steam/Templates/Application/Info.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - CPApplicationDelegateClass - AppController - CPBundleName - __Product__ - CPPrincipalClass - CPApplication - - diff --git a/Tools/steam/Templates/Application/index-debug.html b/Tools/steam/Templates/Application/index-debug.html deleted file mode 100644 index d941b006a..000000000 --- a/Tools/steam/Templates/Application/index-debug.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - Hello World - - - - - - - - -
-
- -
-
- - - diff --git a/Tools/steam/Templates/Application/index.html b/Tools/steam/Templates/Application/index.html deleted file mode 100644 index bea6f5f36..000000000 --- a/Tools/steam/Templates/Application/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - Hello World - - - - - - - - - -
-
- -
-
- - - - diff --git a/Tools/steam/Templates/Application/main.j b/Tools/steam/Templates/Application/main.j deleted file mode 100755 index d4cec69f3..000000000 --- a/Tools/steam/Templates/Application/main.j +++ /dev/null @@ -1,18 +0,0 @@ -/* - * main.j - * __Product__ - * - * Created by __Me__ on __Date__. - * Copyright 2008 __MyCompanyName__. All rights reserved. - */ - -@import -@import - -@import "AppController.j" - - -function main(args, namedArgs) -{ - CPApplicationMain(args, namedArgs); -} diff --git a/Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j b/Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j deleted file mode 100644 index aab4c6581..000000000 --- a/Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ThemeDescriptors.j - * __Product__ - * - * Created by __Me__ on __Date__. - * Copyright 2008 __MyCompanyName__. All rights reserved. - */ - -@import - - -@implementation __Product__ThemeDescriptor : CPObject -{ -} - -+ (CPString)themeName -{ - return @"__Product__"; -} - -+ (CPTextField)themedTextField -{ - var textField = [[CPTextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 20.0)]; - - [textField setValue:[CPColor blueColor] forThemedAttributeName:@"bezel-color"]; - [textField setValue:[CPColor redColor] forThemedAttributeName:@"text-color"]; - - [textField setStringValue:@"Yikes!"]; - - return textField; -} - -@end diff --git a/Tools/steam/build.js b/Tools/steam/build.js deleted file mode 100644 index 042decf11..000000000 --- a/Tools/steam/build.js +++ /dev/null @@ -1,102 +0,0 @@ -function build() -{ - var index = 0, - count = arguments.length, - - actions = [], - - targetName = null, - configurationName = null, - - buildPath = null, - projectFilePath = null, - - gzip = false; - - for (; index < count; ++index) - { - switch (arguments[index]) - { - case "-f": if (index + 1 == count) - throw "-f needs project file."; - - projectFilePath = arguments[++index]; - break; - - case "-t": if (index + 1 == count) - throw "-t needs a target"; - - targetName = arguments[++index]; - break; - - case "-c": if (index + 1 == count) - throw "-c needs configuration"; - - configurationName = arguments[++index]; - break; - - case "-b": if (index + 1 == count) - throw "-b needs a build location"; - - buildPath = arguments[++index]; - break; - - case "--gzip": gzip = true; - break; - - case "clean": - case "build": actions.push(arguments[index]); - break; - } - } - - // If no project file was specified, look for one. - if (!projectFilePath) - { - var candidates = getFiles(new File('.'), "steam"); - - if (candidates.length < 1) - throw "No project file specified or found."; - - projectFilePath = candidates[0]; - } - - // Construct the Build Directory - if (!buildPath) - { - buildPath = System.getenv("STEAM_BUILD"); - - if (!buildPath) - buildPath = "Build"; - } - - var project = new Project(projectFilePath, buildPath); - - project._gzip = gzip; - - if (targetName) - { - var target = project.targetWithName(targetName); - - if (!target) - throw "Target \"" + targetName + "\" not found in project."; - - project.setActiveTarget(target); - } - - if (configurationName) - { - var configuration = project.configurationWithName(configurationName); - - if (!configuration) - throw "Configuration \"" + configurationName + "\" not found in project."; - - project.setActiveConfiguration(configuration); - } - - if (!actions.length) - actions.push("build"); - - for (index = 0, count = actions.length; index < count; ++index) - project[actions[index]](); -} diff --git a/Tools/steam/build.xml b/Tools/steam/build.xml deleted file mode 100644 index 723ea5b2f..000000000 --- a/Tools/steam/build.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/steam/create-frameworks.js b/Tools/steam/create-frameworks.js deleted file mode 100644 index 89b355ea9..000000000 --- a/Tools/steam/create-frameworks.js +++ /dev/null @@ -1,66 +0,0 @@ -function createFrameworks() -{ - var shouldSymbolicallyLink = false, - index = 0, - count = arguments.length, - - destination = ""; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-l": shouldSymbolicallyLink = true; - break; - - default: destination = argument; - } - } - - createFrameworksInFile(new File(destination), shouldSymbolicallyLink); -} - -function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLink) -{ - var destinationFrameworks = new File(aFile.getCanonicalPath()+ "/Frameworks"), - destinationDebugFrameworks = new File(aFile.getCanonicalPath() + "/Frameworks/Debug"); - - if (!shouldSymbolicallyLink) - { - var sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks"), - sourceDebugFrameworks = new File(OBJJ_HOME + "/lib/Frameworks-Debug"); - - exec(["cp", "-vR", sourceFrameworks.getCanonicalPath(), destinationFrameworks.getCanonicalPath()], true); - exec(["cp", "-vR", sourceDebugFrameworks.getCanonicalPath(), destinationDebugFrameworks.getCanonicalPath()], true); - - return true; - } - - var STEAM_BUILD = System.getenv("STEAM_BUILD"); - - // Release Frameworks - new File(destinationFrameworks).mkdir(); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Objective-J").getCanonicalPath(), - new File(aFile.getCanonicalPath() + "/Frameworks/Objective-J").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Foundation").getCanonicalPath(), - new File(aFile.getCanonicalPath() + "/Frameworks/Foundation").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Release/AppKit").getCanonicalPath(), - new File(aFile.getCanonicalPath() + "/Frameworks/AppKit").getCanonicalPath()], true); - - // Debug Frameworks - new File(destinationDebugFrameworks).mkdir(); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Objective-J").getCanonicalPath(), - new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Foundation").getCanonicalPath(), - new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Foundation").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(), - new File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true); -} \ No newline at end of file diff --git a/Tools/steam/create.js b/Tools/steam/create.js deleted file mode 100644 index 73abaa8dc..000000000 --- a/Tools/steam/create.js +++ /dev/null @@ -1,54 +0,0 @@ -function create() -{ - if (arguments.length < 1) - printUsage("create"); - - var shouldSymbolicallyLink = false, - index = 0, - count = arguments.length, - - template = "Application", - destination = ""; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-l": shouldSymbolicallyLink = true; - break; - - case "--template": template = arguments[++index]; - break; - - default: destination = argument; - } - } - - var sourceTemplate = new File(OBJJ_HOME + "/lib/steam/Templates/" + template), - destinationProject = new File(destination); - - if (!destinationProject.exists()) - { - exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true); - - var files = getFiles(destinationProject, ['j', "plist", "html"]), - index = 0, - count = files.length; - - for (; index < count; ++index) - { - var file = files[index], - contents = readFile(file); - - contents = contents.replace(/__Product__/g, destinationProject.getName()); - - writeContentsToFile(contents, file); - } - - createFrameworksInFile(destinationProject, shouldSymbolicallyLink); - } - else - System.out.println("Directory already exists"); -} diff --git a/Tools/steam/htaccess b/Tools/steam/htaccess deleted file mode 100644 index 6afc67f10..000000000 --- a/Tools/steam/htaccess +++ /dev/null @@ -1,12 +0,0 @@ -Options +FollowSymLinks - -AddEncoding x-gzip .gz -AddType text/plain .gz - -RewriteEngine on - -# These conditions slow down the requests significantly. We can probably assume they're always true. -# We should ensure the gzipped version always exists if we include this .htaccess. All supported browsers accept gzip encoding. -#RewriteCond %{REQUEST_FILENAME}.gz -f -#RewriteCond %{HTTP:Accept-Encoding} gzip -RewriteRule ^(.*\.(sj|js))$ %{REQUEST_URI}/../$1.gz diff --git a/Tools/steam/inline-bundle.js b/Tools/steam/inline-bundle.js deleted file mode 100644 index 2e2dc8643..000000000 --- a/Tools/steam/inline-bundle.js +++ /dev/null @@ -1,156 +0,0 @@ -function inlineBundle() -{ - var index = 0, - count = arguments.length, - bundlePath = NULL; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-d": directoryPath = arguments[++index]; - break; - - default: bundlePath = argument; - } - } - - var bundleFile = new File(bundlePath).getCanonicalFile(), - bundlePath = String(bundleFile.getCanonicalPath()), - inlinedBundle = readBundle(bundleFile, true), - inlinedFiles = [], - replacedFiles = [], - staticContent = ""; - - // Find all internal bundles. - var bundleCandidates = getFiles(bundleFile, "plist"), - bundleCandidatesCount = bundleCandidates.length; - - while (bundleCandidatesCount--) - { - var bundleCandidate = bundleCandidates[bundleCandidatesCount]; - - // We only care about Info.plists, specifically the ones that aren't us. - if (String(bundleCandidate.getName()) !== "Info.plist" || String(bundleCandidate.getCanonicalPath()) === inlinedBundle.path) - continue; - - var infoDictionary = readPlist(bundleCandidate); - - // At least one of these two has to be present for this to be a real deal bundle. - if (!dictionary_getValue(infoDictionary, "CPBundleIdentifier") && !dictionary_getValue(infoDictionary, "CPBundleName")) - continue; - - java.lang.System.out.println(" Examining " + pathRelativeTo(bundleCandidate.getCanonicalPath(), bundlePath)); - - dictionary_removeValue(infoDictionary, "CPBundleExecutable"); - - var bundle = readBundle(bundleCandidate.getParentFile(), true); - - bundle.path = pathRelativeTo(bundle.path, bundlePath); - - // We want to inline the info plist too. - var inlinedFiles = [makeOBJJPlistFile(infoDictionary, bundleCandidate, bundle)].concat(bundle.files), - index = 0, - count = inlinedFiles.length; - - for (; index < count; ++index) - { - var file = inlinedFiles[index]; - - file.path = pathRelativeTo(String(file.path), bundlePath); - - java.lang.System.out.println(" Inlining " + file.path); - - replacedFiles.push(file.path); - staticContent += fileToMarkedString(inlinedFiles[index], true); - } - } - - var index = 0, - existingStaticFiles = inlinedBundle.files, - count = existingStaticFiles.length, - topLevelContent = "@STATIC;1.0;"; - - for (; index < count; ++index) - { - var file = existingStaticFiles[index]; - - // If this isn't actually part of our bundle, drop it! - if (file.bundle !== inlinedBundle) - continue; - - file.path = pathRelativeTo(String(file.path), bundlePath); - - replacedFiles.push(file.path); - topLevelContent += fileToMarkedString(file, false); - } - - dictionary_setValue(inlinedBundle.info, "CPBundleReplacedFiles", replacedFiles); - - writeContentsToFile(CPPropertyListCreateXMLData(inlinedBundle.info).string, inlinedBundle.path); - writeContentsToFile(topLevelContent + staticContent, inlinedBundle._staticContentPath); -} - -function fileToMarkedString(anOBJJFile, encodeBundle) -{ - var markedString = ""; - - markedString += MARKER_PATH + ';' + anOBJJFile.path.length + ';' + anOBJJFile.path; - - if (encodeBundle) - markedString += MARKER_BUNDLE + ';' + anOBJJFile.bundle.path.length + ';' + anOBJJFile.bundle.path; - - var fragments = anOBJJFile.fragments; - - if (fragments && fragments.length > 0) - { - var fragmentIndex = 0, - fragmentCount = fragments.length; - - for (; fragmentIndex < fragmentCount; ++fragmentIndex) - markedString += fragments[fragmentIndex].toMarkedString(); - } - - else - markedString += MARKER_TEXT + ';' + anOBJJFile.contents.length + ';' + anOBJJFile.contents; - - return markedString; -} - -function makeOBJJPlistFile(aDictionary, aFile, aBundle) -{ - var file = new objj_file(); - - file.path = typeof aFile === "string" ? aFile : aFile.getCanonicalPath(); - file.bundle = aBundle; - file.contents = CPPropertyListCreate280NorthData(aDictionary).string; - - return file; -} - -function pathRelativeTo(target, relativeTo) -{ - var components = [], - targetParts = target.split("/"), - relativeParts = relativeTo ? relativeTo.split("/") : []; - - var i = 0; - while (i < targetParts.length) - { - if (targetParts[i] != relativeParts[i]) - break; - i++; - } - - for (var j = i; j < relativeParts.length; j++) - components.push(".."); - - for (var j = i; j < targetParts.length; j++) - components.push(targetParts[j]); - - var result = components.join("/"); - - return result; -} \ No newline at end of file diff --git a/Tools/steam/main.js b/Tools/steam/main.js deleted file mode 100644 index d007905f7..000000000 --- a/Tools/steam/main.js +++ /dev/null @@ -1,203 +0,0 @@ - -importPackage(java.lang); -importPackage(java.util); - -importClass(java.io.File); -importClass(java.io.BufferedReader); -importClass(java.io.FileReader); -importClass(java.io.BufferedWriter); -importClass(java.io.FileWriter); -importClass(java.io.SequenceInputStream); - -#include "../Utilities/bundle.js" - -#include "Project.js" - -OBJJ_STEAM = OBJJ_HOME + "/lib/steam/"; - -function main() -{ - if (arguments.length < 1) - printUsage(); - - var command = Array.prototype.shift.apply(arguments); - - switch (command) - { - case "create": create.apply(create, arguments); - break; - - case "create-frameworks": createFrameworks.apply(createFrameworks, arguments); - break; - - - case "inline-bundle": inlineBundle.apply(inlineBundle, arguments); - break; - - case "build": build.apply(build, arguments); - break; - - case "help": printUsage(arguments[1]); - break; - - case "version": - case "--version": printVersion(); - break; - - default : printUsage(command); - } - -} - -function fileArrayContainsFile(/*Array*/ files, /*File*/ aFile) -{ - var index = 0, - count = files.length; - - for (; index < count; ++index) - if (files[index].equals(aFile)) - return true; - - return false; -} - -function getFiles(/*File*/ sourceDirectory, /*nil|String|Array*/ extensions, /*Array*/ exclusions) -{ - var matches = [], - files = sourceDirectory.listFiles(), - hasMultipleExtensions = typeof extensions !== "string"; - - if (files) - { - var index = 0, - count = files.length; - - for (; index < count; ++index) - { - var file = files[index].getCanonicalFile(), - name = String(file.getName()), - isValidExtension = !extensions; - - if (exclusions && fileArrayContainsFile(exclusions, file)) - continue; - - if (!isValidExtension) - if (hasMultipleExtensions) - { - var extensionCount = extensions.length; - - while (extensionCount-- && !isValidExtension) - { - var extension = extensions[extensionCount]; - - if (name.substring(name.length - extension.length - 1) === ("." + extension)) - isValidExtension = true; - } - } - else if (name.substring(name.length - extensions.length - 1) === ("." + extensions)) - isValidExtension = true; - - if (isValidExtension) - matches.push(file); - - if (file.isDirectory()) - matches = matches.concat(getFiles(file, extensions, exclusions)); - } - } - - return matches; -} - -function exec(/*Array*/ command, /*Boolean*/ showOutput) -{ - var line = "", - output = "", - - process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command)); - reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream())); - - while (line = reader.readLine()) - { - if (showOutput) - System.out.println(line); - - output += line + '\n'; - } - - reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream())); - - while (line = reader.readLine()) - System.out.println(line); - - try - { - if (process.waitFor() != 0) - System.err.println("exit value = " + process.exitValue()); - } - catch (anException) - { - System.err.println(anException); - } - - return output; -} - -function rsync(srcFile, dstFile) -{ - var src, dst; - - if (String(java.lang.System.getenv("OS")).indexOf("Windows") < 0) - { - src = srcFile.getAbsolutePath(); - dst = dstFile.getAbsolutePath(); - } - else - { - src = exec(["cygpath", "-u", srcFile.getAbsolutePath() + '/']); - dst = exec(["cygpath", "-u", dstFile.getAbsolutePath() + "/Resources"]); - } - - if (srcFile.exists()) - exec(["rsync", "-avz", src, dst]); -} - -function getFileName(aPath) -{ - var index = aPath.lastIndexOf('/'); - - if (index == -1) - return aPath; - - return aPath.substr(index + 1); -} - -function getFileNameWithoutExtension(aFileOrFileName) -{ - var name = typeof aFileOrFileName === "string" ? aFileOrFileName : aFileOrFileName.getName(), - index = name.lastIndexOf('.'); - - if (index == -1 || index == 0) - return name; - - return name.substr(0, index); -} - -function getFileExtension(aPath) -{ - var slash = aPath.lastIndexOf('/'), - period = aPath.lastIndexOf('.'); - - if (period < slash || (period == slash + 1)) - return ""; - - return aPath.substr(period + 1); -} - -main.apply(main, arguments); - -#include "build.js" -#include "create.js" -#include "create-frameworks.js" -#include "inline-bundle.js" -#include "usage.js" -#include "version.js" diff --git a/Tools/steam/sjheader.txt b/Tools/steam/sjheader.txt deleted file mode 100644 index 57390737c..000000000 --- a/Tools/steam/sjheader.txt +++ /dev/null @@ -1 +0,0 @@ -@STATIC;1.0; \ No newline at end of file diff --git a/Tools/steam/steam b/Tools/steam/steam deleted file mode 100644 index e66147478..000000000 --- a/Tools/steam/steam +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# if OBJJ_HOME isn't set, try to determine it -if [ -z $OBJJ_HOME ]; then - # get path of the executable - SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") - - # resolve symlinks - if [ -h $SELF_PATH ]; then - SELF_PATH=`readlink $SELF_PATH` - fi - - # get second ancestor directory - SELF_DIR=`dirname $SELF_PATH` - export OBJJ_HOME=`dirname $SELF_DIR` - - # check to ensure it exists, print message - if [ -d $OBJJ_HOME ]; then - echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 - else - echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 - exit 2 - fi -fi - -OBJJ_LIB="$OBJJ_HOME/lib" -STEAM="$OBJJ_LIB/steam" -CLASSPATH="$STEAM:$OBJJ_LIB:$OBJJ_LIB/js.jar" - -# convert paths for Cygwin -if [[ `uname` == CYGWIN* ]]; then - CLASSPATH=`cygpath -wp "$CLASSPATH"` - STEAM_BUILD=`cygpath -wp "$STEAM_BUILD"` -fi - -export OBJJ_LIB - -java -classpath $CLASSPATH steam $@ diff --git a/Tools/steam/steam.xml b/Tools/steam/steam.xml deleted file mode 100644 index 8b5e0a9f6..000000000 --- a/Tools/steam/steam.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/steam/usage.js b/Tools/steam/usage.js deleted file mode 100644 index 389fadc53..000000000 --- a/Tools/steam/usage.js +++ /dev/null @@ -1,22 +0,0 @@ -function printUsage(command) -{ - var usage = "usage: steam COMMAND [ARGS]\n\n"+ -"The most commonly used steam commands are:\n"+ -"\tbuild Build a project\n"+ -"\tcreate Create a new project\n\n"+ -"See 'steam help COMMAND' for more information on a specific command."; - - switch (command) - { - case "--help": - case undefined: java.lang.System.out.println(usage); - break; - - case "create": java.lang.System.out.println("Creates a new Cappuccino project.\n\nusage: steam create PROJECT_NAME [-l]\n\n"+ - "\t-l Link Frameworks to $STEAM_BUILD/Release, instead of installing default Frameworks"); - break; - - default: java.lang.System.out.println("steam: '" + command + "' is not a steam command. See 'steam --help'."); - } - java.lang.System.exit(1); -} diff --git a/Tools/steam/version.js b/Tools/steam/version.js deleted file mode 100644 index c22171a3f..000000000 --- a/Tools/steam/version.js +++ /dev/null @@ -1,5 +0,0 @@ -function printVersion() -{ - java.lang.System.out.println("steam version 0.6"); - java.lang.System.exit(1); -} \ No newline at end of file diff --git a/build.xml b/build.xml index 4b9816333..6cb012522 100644 --- a/build.xml +++ b/build.xml @@ -125,6 +125,8 @@
+ + diff --git a/common.rb b/common.rb index 7cba7ef64..6984948cf 100644 --- a/common.rb +++ b/common.rb @@ -36,7 +36,7 @@ if !(defined? COMMON_DO_ONCE) COMMON_DO_ONCE = true - $LOAD_PATH << File.join($HOME_DIR, 'Rake') + $LOAD_PATH << File.join($HOME_DIR, 'Rake', 'lib') ENV['PATH'] = $ENVIRONMENT_BIN_DIR + ':' + ENV['PATH'] end @@ -79,5 +79,12 @@ def cat(files, outfile) end end +$OBJJ_TEMPLATE_EXECUTABLE = File.join($HOME_DIR, 'Rake', 'lib', 'objj-executable') + +def make_objj_executable(path) + cp($OBJJ_TEMPLATE_EXECUTABLE, path) + File.chmod 0755, path +end + task :build => [$ENVIRONMENT_JS] task :default => [:build]