Compare commits

..
180 changed files with 10387 additions and 6525 deletions
-34
View File
@@ -1,34 +0,0 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [17.x, 18.x, 19.x, 20.x, 21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: echo "${PWD}/dist/cappuccino/bin" >> $GITHUB_PATH
- run: echo "${PWD}/dist/objective-j/bin" >> $GITHUB_PATH
- run: npm install
- run: npm update
- run: jake dist
- run: jake test-only
+1 -9
View File
@@ -17,12 +17,4 @@ Tests/Manual/**/*.xcodeproj
*.sublime-project
*.sublime-workspace
*.tm_properties
*.idea
node_modules
*.vscode
/dist/objective-j/objj-executable
/dist/objective-j/package.json
/dist/objective-j/lib
/dist/cappuccino/package.json
/dist/cappuccino/lib
*.idea
-28
View File
@@ -1,28 +0,0 @@
.DS_Store
Frameworks
!/dist/objective-j/Frameworks
!/dist/cappuccino-j/Frameworks
Build
Demos
./Aristo
WebSite
.push-package
*.xcodeproj*
*.xcodeproj/*.pbxuser
*.xcodeproj/*.perspectivev3
xcuserdata/
!*.xcodeproj/project.pbxproj
*.xCodeSupport/
*.XcodeSupport/
*XcodeSupport/
Tests/Manual/**/*.xcodeproj
*.sublime-project
*.sublime-workspace
*.tm_properties
*.idea
node_modules
*.vscode
/dist/objective-j/objj-executable
/dist/objective-j/package.json
/dist/cappuccino/package.json
+1 -1
View File
@@ -87,7 +87,7 @@ var cachedBlackColor,
CPImage _patternImage;
CPString _cssString;
}
@global document
#pragma mark -
#pragma mark Theming
-2
View File
@@ -37,8 +37,6 @@
CPString _expires;
}
@global document
/*!
Initializes a cookie with a given name \c aName.
@param the name for the cookie
@@ -385,18 +385,6 @@ CPAMPMDateType = 6;
return;
}
// if we enter a day that is too high for the current month
// we need to increase the month by one
// if we do not do this, the user input would be silently reset
// very poor user experience
if (parseInt(anObjectValue, 10) > [dateValue _daysInMonth])
{
[_datePickerElementView._textFieldMonth setIntValue:(dateValue.getMonth() + 2)];
[super setObjectValue:objectValue];
return;
}
[super setObjectValue:objectValue];
break;
-2
View File
@@ -29,8 +29,6 @@
@global CPApp
@class CPFontPanel
@global document
CPItalicFontMask = 1 << 0;
CPBoldFontMask = 1 << 1;
CPUnboldFontMask = 1 << 2;
-1
View File
@@ -33,7 +33,6 @@
@import "CPCompatibility.j"
@class CPColor
@global document
@protocol CPImageDelegate <CPObject>
-2
View File
@@ -29,8 +29,6 @@
@global CPImagesPboardType
@global appkit_tag_dom_elements
@global document
@typedef CPImageAlignment
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
-2
View File
@@ -31,8 +31,6 @@
@global CPMenuDidChangeItemNotification
@global CPMenuDidRemoveItemNotification
@global document
@implementation _CPMenuBarWindow : CPPanel
{
CPView _highlightView;
+2 -2
View File
@@ -1881,7 +1881,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
@end
@implementation _CPOutlineViewTableViewDataSource : CPObject <CPTableViewDataSource>
@implementation _CPOutlineViewTableViewDataSource : CPObject
{
CPObject _outlineView;
}
@@ -2011,7 +2011,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
@end
@implementation _CPOutlineViewTableViewDelegate : CPObject <CPTableViewDelegate>
@implementation _CPOutlineViewTableViewDelegate : CPObject
{
CPOutlineView _outlineView;
}
+4 -5
View File
@@ -561,11 +561,10 @@ CPSegmentSwitchTrackingMomentary = 2;
}
else if (aName === "right-segment-bezel")
{
// we have to FLOOR the coordinates to prevent a 1px glitch in Safari
return CGRectMake(FLOOR(CGRectGetWidth([self bounds]) - contentInset.right),
FLOOR(bezelInset.top),
FLOOR(contentInset.right),
FLOOR(height));
return CGRectMake(CGRectGetWidth([self bounds]) - contentInset.right,
bezelInset.top,
contentInset.right,
height);
}
else if (aName.indexOf("segment-bezel") === 0)
{
-6
View File
@@ -312,12 +312,6 @@ var AFFINITY = 5;
if (!trackRect || CGRectIsEmpty(trackRect))
trackRect = bounds;
if (_allowsTickMarkValuesOnly)
{
[self closestTickMarkValueToValue:[self doubleValue]]; // we only need the side effect …
_currentTickMarkSegment = _closestTickMarkIndex;
}
if (_isCircular)
{
var angle = 3 * PI_2 - (1.0 - [self doubleValue] - _minValue) / (_maxValue - _minValue) * PI2,
-1
View File
@@ -32,7 +32,6 @@
@end
@global document
var CPSoundDelegate_sound_didFinishPlaying_ = 1 << 1;
-2
View File
@@ -34,8 +34,6 @@
@global CPStringPboardType
@global CPCursor
@global document
@protocol CPTextFieldDelegate <CPControlTextEditingDelegate>
@end
-2
View File
@@ -32,8 +32,6 @@
@global _MakeRangeFromAbs
@global document
@class CPTextContainer
@class CPTextView
+11 -10
View File
@@ -55,8 +55,6 @@
@end
@global document
_MakeRangeFromAbs = function(a1, a2)
{
return (a1 < a2) ? CPMakeRange(a1, a2 - a1) : CPMakeRange(a2, a1 - a2);
@@ -1053,7 +1051,7 @@ Sets the selection to a range of characters in response to user action.
[[_window platformWindow] _propagateCurrentDOMEvent:YES]; // for the _CPNativeInputManager (necessary at least on FF and chrome)
if (![_CPNativeInputManager isNativeInputFieldActive] && ![_CPNativeInputManager isDeadKey:event])
if (![_CPNativeInputManager isNativeInputFieldActive] && [event charactersIgnoringModifiers].charCodeAt(0) != 229) // filter out 229 because this would be inserted in chrome on each deadkey
[self interpretKeyEvents:[event]];
[_caret setPermanentlyVisible:YES];
@@ -2638,14 +2636,7 @@ var _CPCopyPlaceholder = '-';
{
return _CPNativeInputFieldActive;
}
+ (void)isDeadKey:(CPEvent)event
{
#if PLATFORM(DOM)
return event._DOMEvent && (event._DOMEvent.key == 'Dead' || event._DOMEvent.key == 'Process');
#endif
return NO;
}
+ (void)cancelCurrentNativeInputSession
{
@@ -2718,6 +2709,16 @@ var _CPCopyPlaceholder = '-';
if (![currentFirstResponder respondsToSelector:@selector(_activateNativeInputElement:)])
return false; // prevent the default behaviour
var charCode = _CPNativeInputField.innerHTML.charCodeAt(0);
// å and Å need to be filtered out in keyDown: due to chrome inserting 229 on a deadkey
if (charCode == 229 || charCode == 197)
{
[currentFirstResponder insertText:_CPNativeInputField.innerHTML];
_CPNativeInputField.innerHTML = '';
return;
}
// chrome-trigger: keypressed is omitted for deadkeys
if (!_CPNativeInputFieldActive && _CPNativeInputFieldKeyPressedCalled == NO && _CPNativeInputField.innerHTML.length && _CPNativeInputField.innerHTML != _CPCopyPlaceholder && _CPNativeInputField.innerHTML.length < 3)
{
+2 -9
View File
@@ -40,7 +40,6 @@
@global CPTextFieldDidFocusNotification
@global CPTextFieldDidBlurNotification
@global document
// TODO: should be conform to protocol CPTextFieldDelegate
@protocol CPTokenFieldDelegate <CPObject>
@@ -585,12 +584,6 @@ CPTokenFieldDeleteButtonType = 1;
// Snap to the token if it's only half visible due to mouse wheel scrolling.
_shouldScrollTo = aToken;
}
// this is a hack to compensate for a recent adoption in FR management as introduced by commit #26aab29
// this PR makes the tokenfield loose FR status prematurely, so we have to regain here in order to make deleteForward: and friends work
setTimeout(function(){
[[self window] makeFirstResponder:self];
}, 50);
}
// ===========
@@ -971,8 +964,8 @@ CPTokenFieldDeleteButtonType = 1;
[self _selectToken:tokenView byExtendingSelection:NO];
}
}
// we have to remove unconditionally because the backspace is not propagated anymore starting from commit #26aab29
[self _removeSelectedTokens:nil];
else
[self _removeSelectedTokens:nil];
}
else
{
+1 -12
View File
@@ -44,7 +44,6 @@
@class CPClipView
@class CPScrollView
@class CALayer
@class CPBinder
@global appkit_tag_dom_elements
@@ -233,7 +232,7 @@ var CPViewHighDPIDrawingEnabled = YES;
JSObject _ephemeralSubviews;
JSObject _ephemeralSubviewsForNames;
CPSet _ephemeralSubviews;
CPSet _ephereralSubviews;
// Key View Support
CPView _nextKeyView;
@@ -3733,16 +3732,6 @@ var CPAppearanceVibrantDark = [CPAppearance appearanceNamed:CPAppearanceNameVibr
[owners[i] updateTrackingAreas];
}
// needed by CPWindow's releasedWhenClosed property
- (void)_releaseRecursively
{
[_subviews makeObjectsPerformSelector:@selector(_releaseRecursively)];
[self _removeObservers];
[CPBinder unbindAllForObject:self];
[self removeFromSuperview];
}
@end
var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
-2
View File
@@ -39,8 +39,6 @@ CPWebViewProgressEstimateChangedNotification = "CPWebViewProgressEstimateChan
CPWebViewProgressStartedNotification = "CPWebViewProgressStartedNotification";
CPWebViewProgressFinishedNotification = "CPWebViewProgressFinishedNotification";
@global document
/*!
Automatically choose between AppKit (Cappuccino style) scrollbars and
native scrollbars. In this mode AppKit scrollbars are always used except
-6
View File
@@ -186,7 +186,6 @@ var CPWindowActionMessageKeys = [
BOOL _constrainsToUsableScreen;
unsigned _shadowStyle;
BOOL _showsResizeIndicator;
BOOL _releasedWhenClosed @accessors(property=releasedWhenClosed);
int _positioningMask;
CGRect _positioningScreenRect;
@@ -269,8 +268,6 @@ var CPWindowActionMessageKeys = [
BOOL _inhibitUpdateTrackingAreas; // Used by the CPView when updating tracking areas
}
@global document
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([aBinding hasPrefix:CPDisplayPatternTitleBinding])
@@ -2537,9 +2534,6 @@ CPTexturedBackgroundWindowMask
[_parentWindow removeChildWindow:self];
[self _orderOutRecursively:NO];
[self _detachFromChildrenClosing:!_parentWindow];
if (_releasedWhenClosed)
[_contentView _releaseRecursively];
}
- (void)_detachFromChildrenClosing:(BOOL)shouldCloseChildren
+2 -3
View File
@@ -61,10 +61,9 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
if (!object)
{
var originalClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey];
CPLog.warn(@"Unable to find class " + theClassName + @" referenced in cib file. Will try to use original class " + originalClassName + @".");
CPLog.error("Unable to find class " + theClassName + " referenced in cib file.");
object = [self allocObjectWithCoder:aCoder className:originalClassName];
object = [self allocObjectWithCoder:aCoder className:[aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey]];
}
}
-2
View File
@@ -120,8 +120,6 @@ var CALayerRegisteredRunLoopUpdates = nil;
CGAffineTransform _transformFromLayer;
}
@global document
/*!
Returns a new animation layer.
*/
-4
View File
@@ -291,11 +291,7 @@ var frameToCSSTranslationTransformMatrix = function(start, current)
- (Object)_DOMElement
{
#if PLATFORM(DOM)
return _DOMElement;
#else
return nil;
#endif
}
- (CPString)debug_description
+208 -8
View File
@@ -2,13 +2,213 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPBundleIdentifier</key>
<string>com.280n.AppKit</string>
<key>CPBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CPBundleName</key>
<string>AppKit</string>
<key>CPBundlePackageType</key>
<string>FMWK</string>
<key>CPBundleIdentifier</key>
<string>com.280n.AppKit</string>
<key>CPBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CPBundleName</key>
<string>AppKit</string>
<key>CPBundlePackageType</key>
<string>FMWK</string>
<key>CPCompileIncludeFileArray</key>
<array>
<string>Platform/Platform.h</string>
<string>Platform/DOM/CPDOMDisplayServer.h</string>
</array>
<key>CPFileTranslationDictionary</key>
<dict>
<key>_CPCibCustomObject.j</key>
<string>Cib/_CPCibCustomObject.j</string>
<key>_CPCibCustomView.j</key>
<string>Cib/_CPCibCustomView.j</string>
<key>CPCib.j</key>
<string>Cib/CPCib.j</string>
<key>_CPLocalizableString.j</key>
<string>Cib/_CPLocalizableString.j</string>
<key>CPCibConnector.j</key>
<string>Cib/CPCibConnector.j</string>
<key>CPCibHelpConnector.j</key>
<string>Cib/CPCibHelpConnector.j</string>
<key>_CPCibCustomResource.j</key>
<string>Cib/_CPCibCustomResource.j</string>
<key>_CPCibProxyObject.j</key>
<string>Cib/_CPCibProxyObject.j</string>
<key>_CPCibObjectData.j</key>
<string>Cib/_CPCibObjectData.j</string>
<key>CPCibLoading.j</key>
<string>Cib/CPCibLoading.j</string>
<key>_CPCibWindowTemplate.j</key>
<string>Cib/_CPCibWindowTemplate.j</string>
<key>CPCibRuntimeAttributesConnector.j</key>
<string>Cib/CPCibRuntimeAttributesConnector.j</string>
<key>_CPCibClassSwapper.j</key>
<string>Cib/_CPCibClassSwapper.j</string>
<key>CPCibControlConnector.j</key>
<string>Cib/CPCibControlConnector.j</string>
<key>CPCibOutletConnector.j</key>
<string>Cib/CPCibOutletConnector.j</string>
<key>_CPCibKeyedUnarchiver.j</key>
<string>Cib/_CPCibKeyedUnarchiver.j</string>
<key>CPCibBindingConnector.j</key>
<string>Cib/CPCibBindingConnector.j</string>
<key>_CPObjectAnimator.j</key>
<string>CoreAnimation/_CPObjectAnimator.j</string>
<key>CAAnimation.j</key>
<string>CoreAnimation/CAAnimation.j</string>
<key>CABackingStore.j</key>
<string>CoreAnimation/CABackingStore.j</string>
<key>CABasicAnimation.j</key>
<string>CoreAnimation/CABasicAnimation.j</string>
<key>CAFlashLayer.j</key>
<string>CoreAnimation/CAFlashLayer.j</string>
<key>CAKeyframeAnimation.j</key>
<string>CoreAnimation/CAKeyframeAnimation.j</string>
<key>CALayer.j</key>
<string>CoreAnimation/CALayer.j</string>
<key>CAMediaTimingFunction.j</key>
<string>CoreAnimation/CAMediaTimingFunction.j</string>
<key>CAPropertyAnimation.j</key>
<string>CoreAnimation/CAPropertyAnimation.j</string>
<key>CPAnimationContext.j</key>
<string>CoreAnimation/CPAnimationContext.j</string>
<key>CPViewAnimator.j</key>
<string>CoreAnimation/CPViewAnimator.j</string>
<key>CSSAnimation.j</key>
<string>CoreAnimation/CSSAnimation.j</string>
<key>CGGradient.j</key>
<string>CoreGraphics/CGGradient.j</string>
<key>CGContextText.j</key>
<string>CoreGraphics/CGContextText.j</string>
<key>CGAffineTransform.j</key>
<string>CoreGraphics/CGAffineTransform.j</string>
<key>CGColorSpace.j</key>
<string>CoreGraphics/CGColorSpace.j</string>
<key>CGContext.j</key>
<string>CoreGraphics/CGContext.j</string>
<key>CGGeometry.j</key>
<string>CoreGraphics/CGGeometry.j</string>
<key>CGContextVML.j</key>
<string>CoreGraphics/CGContextVML.j</string>
<key>CGPath.j</key>
<string>CoreGraphics/CGPath.j</string>
<key>CGContextCanvas.j</key>
<string>CoreGraphics/CGContextCanvas.j</string>
<key>CGColor.j</key>
<string>CoreGraphics/CGColor.j</string>
<key>_CPDatePickerCalendar.j</key>
<string>CPDatePicker/_CPDatePickerCalendar.j</string>
<key>_CPDatePickerTextField.j</key>
<string>CPDatePicker/_CPDatePickerTextField.j</string>
<key>_CPDatePickerClock.j</key>
<string>CPDatePicker/_CPDatePickerClock.j</string>
<key>CPDatePicker.j</key>
<string>CPDatePicker/CPDatePicker.j</string>
<key>_CPMenuWindow.j</key>
<string>CPMenu/_CPMenuWindow.j</string>
<key>CPMenu.j</key>
<string>CPMenu/CPMenu.j</string>
<key>_CPMenuManager.j</key>
<string>CPMenu/_CPMenuManager.j</string>
<key>_CPMenuBarWindow.j</key>
<string>CPMenu/_CPMenuBarWindow.j</string>
<key>CPMenuItem.j</key>
<string>CPMenuItem/CPMenuItem.j</string>
<key>_CPMenuItemView.j</key>
<string>CPMenuItem/_CPMenuItemView.j</string>
<key>_CPMenuItemStandardView.j</key>
<string>CPMenuItem/_CPMenuItemStandardView.j</string>
<key>_CPMenuItemSeparatorView.j</key>
<string>CPMenuItem/_CPMenuItemSeparatorView.j</string>
<key>_CPMenuItemMenuBarView.j</key>
<string>CPMenuItem/_CPMenuItemMenuBarView.j</string>
<key>_CPRuleEditorViewSliceRow.j</key>
<string>CPRuleEditor/_CPRuleEditorViewSliceRow.j</string>
<key>CPPredicateEditor.j</key>
<string>CPRuleEditor/CPPredicateEditor.j</string>
<key>CPRuleEditor.j</key>
<string>CPRuleEditor/CPRuleEditor.j</string>
<key>_CPRuleEditorLocalizer.j</key>
<string>CPRuleEditor/_CPRuleEditorLocalizer.j</string>
<key>CPPredicateEditorRowTemplate.j</key>
<string>CPRuleEditor/CPPredicateEditorRowTemplate.j</string>
<key>_CPRuleEditorViewSlice.j</key>
<string>CPRuleEditor/_CPRuleEditorViewSlice.j</string>
<key>CPRuleEditor_Constants.j</key>
<string>CPRuleEditor/CPRuleEditor_Constants.j</string>
<key>_CPPredicateEditorRowNode.j</key>
<string>CPRuleEditor/_CPPredicateEditorRowNode.j</string>
<key>_CPPredicateEditorTree.j</key>
<string>CPRuleEditor/_CPPredicateEditorTree.j</string>
<key>CPTextStorage.j</key>
<string>CPTextView/CPTextStorage.j</string>
<key>_CPRTFParser.j</key>
<string>CPTextView/_CPRTFParser.j</string>
<key>_CPRTFProducer.j</key>
<string>CPTextView/_CPRTFProducer.j</string>
<key>CPTextContainer.j</key>
<string>CPTextView/CPTextContainer.j</string>
<key>CPLayoutManager.j</key>
<string>CPTextView/CPLayoutManager.j</string>
<key>CPTextView.j</key>
<string>CPTextView/CPTextView.j</string>
<key>CPFontDescriptor.j</key>
<string>CPTextView/CPFontDescriptor.j</string>
<key>CPFontPanel.j</key>
<string>CPTextView/CPFontPanel.j</string>
<key>CPParagraphStyle.j</key>
<string>CPTextView/CPParagraphStyle.j</string>
<key>CPTypesetter.j</key>
<string>CPTextView/CPTypesetter.j</string>
<key>CPWindow_Constants.j</key>
<string>CPWindow/CPWindow_Constants.j</string>
<key>_CPStandardWindowView.j</key>
<string>CPWindow/_CPStandardWindowView.j</string>
<key>_CPShadowWindowView.j</key>
<string>CPWindow/_CPShadowWindowView.j</string>
<key>_CPToolTipWindowView.j</key>
<string>CPWindow/_CPToolTipWindowView.j</string>
<key>_CPBorderlessWindowView.j</key>
<string>CPWindow/_CPBorderlessWindowView.j</string>
<key>_CPBorderlessBridgeWindowView.j</key>
<string>CPWindow/_CPBorderlessBridgeWindowView.j</string>
<key>_CPDocModalWindowView.j</key>
<string>CPWindow/_CPDocModalWindowView.j</string>
<key>_CPModalWindowView.j</key>
<string>CPWindow/_CPModalWindowView.j</string>
<key>_CPPopoverWindowView.j</key>
<string>CPWindow/_CPPopoverWindowView.j</string>
<key>_CPWindowView.j</key>
<string>CPWindow/_CPWindowView.j</string>
<key>_CPTitleableWindowView.j</key>
<string>CPWindow/_CPTitleableWindowView.j</string>
<key>CPWindow.j</key>
<string>CPWindow/CPWindow.j</string>
<key>_CPHUDWindowView.j</key>
<string>CPWindow/_CPHUDWindowView.j</string>
<key>CPPlatform.j</key>
<string>Platform/CPPlatform.j</string>
<key>CPPlatformString.j</key>
<string>Platform/CPPlatformString.j</string>
<key>CPPlatformWindow.j</key>
<string>Platform/CPPlatformWindow.j</string>
<key>CPPlatformWindow+DOM.j</key>
<string>Platform/DOM/CPPlatformWindow+DOM.j</string>
<key>CPPlatformPasteboard.j</key>
<string>Platform/DOM/CPPlatformPasteboard.j</string>
<key>CPDOMWindowLayer.j</key>
<string>Platform/DOM/CPDOMWindowLayer.j</string>
<key>CPPlatformWindow+DOMKeys.j</key>
<string>Platform/DOM/CPPlatformWindow+DOMKeys.j</string>
</dict>
</dict>
</plist>
+12 -15
View File
@@ -1,22 +1,19 @@
require("../common.jake");
var framework = require("../Jake/frameworktask.js").framework,
BundleTask = require("../Jake/bundletask.js").BundleTask;
var framework = require("objective-j/jake").framework,
BundleTask = require("objective-j/jake").BundleTask;
const path = require("path");
const utilsFile = ObjectiveJ.utils.file;
$BUILD_PATH = path.join($BUILD_DIR, $CONFIGURATION, 'AppKit');
$BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit');
AppKitFiles = new FileList("**/*.j").exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**/*', 'Tools/**/*', "Platform/DOM/CPPlatform.j", "Platform/DOM/CPPlatformString.j");
FIXME_fileDependency (path.join("Platform", "CPPlatform.j"), path.join("Platform", "DOM", "CPPlatform.j"));
FIXME_fileDependency (path.join("Platform", "CPPlatformString.j"), path.join("Platform", "DOM", "CPPlatformString.j"));
FIXME_fileDependency (FILE.join("Platform", "CPPlatform.j"), FILE.join("Platform", "DOM", "CPPlatform.j"));
FIXME_fileDependency (FILE.join("Platform", "CPPlatformString.j"), FILE.join("Platform", "DOM", "CPPlatformString.j"));
appKitTask = framework ("AppKit", function(appKitTask)
{
appKitTask.setBuildIntermediatesPath(path.join($BUILD_DIR, "AppKit.build", $CONFIGURATION))
appKitTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "AppKit.build", $CONFIGURATION))
appKitTask.setBuildPath($BUILD_CONFIGURATION_DIR);
appKitTask.setAuthor("280 North, Inc.");
@@ -43,11 +40,11 @@ appKitTask = framework ("AppKit", function(appKitTask)
appKitTask.setCompilerFlags("-DDEBUG -g -S --inline-msg-send -Wno-unused-but-set-variable " + INCLUDES);
});
$BUILD_CJS_CAPPUCCINO_APPKIT = path.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "AppKit");
$BUILD_CJS_CAPPUCCINO_APPKIT = FILE.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "AppKit");
filedir ($BUILD_CJS_CAPPUCCINO_APPKIT, ["AppKit"], function()
{
utilsFile.cp_r(appKitTask.buildProductPath(), $BUILD_CJS_CAPPUCCINO_APPKIT);
cp_r(appKitTask.buildProductPath(), $BUILD_CJS_CAPPUCCINO_APPKIT);
});
subtasks (["Themes"], ["clean", "clobber"]);
@@ -56,11 +53,11 @@ task ("Theme", [$BUILD_CJS_CAPPUCCINO_APPKIT], function()
{
subjake(["Themes"], "build");
utilsFile.cp_r(path.join($BUILD_DIR, $CONFIGURATION, 'Aristo.blend'), path.join($BUILD_PATH, 'Resources', 'Aristo.blend'));
utilsFile.cp_r(path.join($BUILD_DIR, $CONFIGURATION, 'Aristo.blend'), path.join($BUILD_CJS_CAPPUCCINO_APPKIT, "Resources", "Aristo.blend"));
cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, 'Aristo.blend'), FILE.join($BUILD_PATH, 'Resources', 'Aristo.blend'));
cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, 'Aristo.blend'), FILE.join($BUILD_CJS_CAPPUCCINO_APPKIT, "Resources", "Aristo.blend"));
utilsFile.cp_r(path.join($BUILD_DIR, $CONFIGURATION, 'Aristo2.blend'), path.join($BUILD_PATH, 'Resources', 'Aristo2.blend'));
utilsFile.cp_r(path.join($BUILD_DIR, $CONFIGURATION, 'Aristo2.blend'), path.join($BUILD_CJS_CAPPUCCINO_APPKIT, "Resources", "Aristo2.blend"));
cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, 'Aristo2.blend'), FILE.join($BUILD_PATH, 'Resources', 'Aristo2.blend'));
cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, 'Aristo2.blend'), FILE.join($BUILD_CJS_CAPPUCCINO_APPKIT, "Resources", "Aristo2.blend"));
});
task ("build", ["AppKit", $BUILD_CJS_CAPPUCCINO_APPKIT, "Theme"]);
-2
View File
@@ -25,8 +25,6 @@
@import "CGGeometry.j"
@global document
@implementation CPDOMWindowLayer : CPObject
{
int _level;
+1 -1
View File
@@ -44,7 +44,7 @@ var screenNeedsInitialization = NO,
screenNeedsInitialization = [CPPlatform isBrowser];
// We do this here because doing it later breaks IE.
if (typeof document !== 'undefined' && document.documentElement)
if (document.documentElement)
document.documentElement.style.overflow = "hidden";
if ([CPPlatform isBrowser])
@@ -133,8 +133,6 @@
@global _CPRunModalLoop
@global document
// List of all open native windows
var PlatformWindows = [CPSet set];
+10 -33
View File
@@ -1,39 +1,16 @@
require("../../../common.jake");
const path = require("path");
var blend = require("cappuccino/jake").blend;
var callback;
blend ("Aristo.blend", function(aristoTask)
{
aristoTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Aristo.build", $CONFIGURATION))
aristoTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
function callbackFunction(blendtask) {
callback(blendtask);
}
$BUILD_CJS_BLENDTASK = path.join($BUILD_CJS_CAPPUCCINO, "lib", "cappuccino", "jake", "blendtask.j");
var promise = new Promise((resolve, reject) => {
callback = function(BLEND_TASK) {
exports.BlendTask = BLEND_TASK.BlendTask;
exports.blend = BLEND_TASK.blend;
defineBlendTask().then(() => {
resolve();
delete exports.jakePromise;
});
}
aristoTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
aristoTask.setIdentifier("com.280n.blend.Aristo");
aristoTask.setResources(new FileList("Resources/*"));
});
require("../../../CommonJS/lib/cappuccino/jake.js").initilize(callbackFunction);
async function defineBlendTask() {
await exports.blend ("Aristo.blend", function(aristoTask)
{
aristoTask.setBuildIntermediatesPath(path.join($BUILD_DIR, "Aristo.build", $CONFIGURATION))
aristoTask.setBuildPath(path.join($BUILD_DIR, $CONFIGURATION));
aristoTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
aristoTask.setIdentifier("com.280n.blend.Aristo");
aristoTask.setResources(new FileList("Resources/*"));
});
task ("build", ["Aristo.blend"]);
}
exports.jakePromise = promise;
task ("build", ["Aristo.blend"]);
+10 -33
View File
@@ -1,39 +1,16 @@
require("../../../common.jake");
const path = require("path");
var blend = require("cappuccino/jake").blend;
var callback;
blend ("Aristo2.blend", function(aristo2Task)
{
aristo2Task.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Aristo2.build", $CONFIGURATION))
aristo2Task.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
function callbackFunction(blendtask) {
callback(blendtask);
}
$BUILD_CJS_BLENDTASK = path.join($BUILD_CJS_CAPPUCCINO, "lib", "cappuccino", "jake", "blendtask.j");
var promise = new Promise((resolve, reject) => {
callback = function(BLEND_TASK) {
exports.BlendTask = BLEND_TASK.BlendTask;
exports.blend = BLEND_TASK.blend;
defineBlendTask().then(() => {
resolve();
delete exports.jakePromise;
});
}
aristo2Task.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
aristo2Task.setIdentifier("com.280n.blend.Aristo2");
aristo2Task.setResources(new FileList("Resources/*"));
});
require("../../../CommonJS/lib/cappuccino/jake.js").initilize(callbackFunction);
async function defineBlendTask() {
await exports.blend ("Aristo2.blend", function(aristoTask)
{
aristoTask.setBuildIntermediatesPath(path.join($BUILD_DIR, "Aristo2.build", $CONFIGURATION))
aristoTask.setBuildPath(path.join($BUILD_DIR, $CONFIGURATION));
aristoTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
aristoTask.setIdentifier("com.280n.blend.Aristo2");
aristoTask.setResources(new FileList("Resources/*"));
});
task ("build", ["Aristo2.blend"]);
}
exports.jakePromise = promise;
task ("build", ["Aristo2.blend"]);
+8 -11
View File
@@ -519,17 +519,15 @@ var themedButtonValues = nil,
width: 9.0,
height: 4.0,
orientation: PatternIsVertical
});
// removed as variable is never read
}),
/* knobColorLegacy = PatternColor(
knobColorLegacy = PatternColor(
"scroller-legacy-vertical-knob{position}.png",
{
width: 14.0,
height: 3.0,
orientation: PatternIsVertical
}) */
});
themedVerticalScrollerValues =
[
@@ -597,16 +595,15 @@ var themedButtonValues = nil,
width: 4.0,
height: 9.0,
orientation: PatternIsHorizontal
});
// removed as variable is never read
/* knobColorLegacy = PatternColor(
}),
knobColorLegacy = PatternColor(
"scroller-legacy-horizontal-knob{position}.png",
{
width: 3.0,
height: 14.0,
orientation: PatternIsHorizontal
}) */
});
themedHorizontalScrollerValues =
[
@@ -2797,7 +2794,7 @@ var themedButtonValues = nil,
closeButtonImageInactive = PatternImage(@"window-standard-close-button-inactive.png", 16, 16),
closeButtonImageHighlighted = PatternImage(@"window-standard-button-highlighted.png", 16, 16),
unsavedButtonImage = PatternImage(@"window-standard-button-unsaved.png", 16, 16),
//unsavedButtonImageInactive = PatternImage(@"window-standard-button-unsaved-inactive.png", 16, 16), removed as it is unused
unsavedButtonImageInactive = PatternImage(@"window-standard-button-unsaved-inactive.png", 16, 16),
unsavedButtonImageHighlighted = PatternImage(@"window-standard-close-button-unsaved-highlighted.png", 16, 16),
minimizeButtonImage = PatternImage(@"window-standard-minimize-button.png", 16, 16),
minimizeButtonImageHighlighted = PatternImage(@"window-standard-minimize-button-highlighted.png", 16, 16),
+8 -11
View File
@@ -1,24 +1,21 @@
require("../../../common.jake");
const path = require("path");
const utilsFile = ObjectiveJ.utils.file;
var framework = require("../../../Jake/frameworktask.js").framework;
var BundleTask = require("../../../Jake/bundletask.js").BundleTask;
var framework = require("objective-j/jake").framework;
var BundleTask = require("objective-j/jake").BundleTask;
blendKitTask = framework ("BlendKit", function(blendKitTask)
{
blendKitTask.setBuildIntermediatesPath(path.join($BUILD_DIR, "BlendKit.build", $CONFIGURATION))
blendKitTask.setBuildPath(path.join($BUILD_DIR, $CONFIGURATION));
blendKitTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "BlendKit.build", $CONFIGURATION))
blendKitTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
blendKitTask.setIdentifier("com.280n.BlendKit");
blendKitTask.setVersion(getCappuccinoVersion());
blendKitTask.setAuthor("280 North, Inc.");
blendKitTask.setEmail("feedback @nospam@ 280north.com");
blendKitTask.setSummary("BlendKit classes for Cappuccino");
blendKitTask.setSources(new FileList("*.j"));
blendKitTask.setResources(new FileList("Resources/*"));
blendKitTask.setSources(FILE.glob("*.j"));
blendKitTask.setResources(FILE.glob("Resources/*"));
blendKitTask.setLicense(BundleTask.License.LGPL_v2_1);
blendKitTask.setFlattensSources(true); // FIXME: how do we non flatten?
@@ -28,11 +25,11 @@ blendKitTask = framework ("BlendKit", function(blendKitTask)
blendKitTask.setCompilerFlags("-DDEBUG -g -Wno-unused-but-set-variable");
});
$BUILD_CJS_PRODUCT_BLENDKIT = path.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "BlendKit");
$BUILD_CJS_PRODUCT_BLENDKIT = FILE.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "BlendKit");
filedir ($BUILD_CJS_PRODUCT_BLENDKIT, ["BlendKit"], function()
{
utilsFile.cp_r(blendKitTask.buildProductPath(), $BUILD_CJS_PRODUCT_BLENDKIT);
cp_r(blendKitTask.buildProductPath(), $BUILD_CJS_PRODUCT_BLENDKIT);
});
task ("build", ["BlendKit", $BUILD_CJS_PRODUCT_BLENDKIT]);
+3 -4
View File
@@ -1,15 +1,14 @@
require("../../../common.jake");
var path = require("path");
const utilsFile = ObjectiveJ.utils.file;
var FILE = require("file");
$BLENDTASK = "blendtask.j";
$BUILD_CJS_BLENDTASK = path.join($BUILD_CJS_CAPPUCCINO, "lib", "cappuccino", "jake", "blendtask.j");
$BUILD_CJS_BLENDTASK = FILE.join($BUILD_CJS_CAPPUCCINO, "lib", "cappuccino", "jake", "blendtask.j");
filedir($BUILD_CJS_BLENDTASK, [$BLENDTASK], function()
{
utilsFile.cp_r($BLENDTASK, $BUILD_CJS_BLENDTASK);
cp_r($BLENDTASK, $BUILD_CJS_BLENDTASK);
});
task("build", [$BUILD_CJS_BLENDTASK]);
+50 -78
View File
@@ -27,14 +27,13 @@
@import <AppKit/_CPCibObjectData.j>
@import <BlendKit/BlendKit.j>
var /* FILE = require("file"), */
TERM = ObjectiveJ.term,
task = JAKE.task,
filedir = JAKE.filedir,
BundleTask = CAPPUCCINO.Jake.BundleTask.BundleTask;
var fs = require("fs");
var path = require("path");
var FILE = require("file"),
TERM = require("narwhal/term"),
task = require("jake").task,
filedir = require("jake").filedir,
BundleTask = require("objective-j/jake/bundletask").BundleTask;
function BlendTask(aName)
{
@@ -54,17 +53,9 @@ BlendTask.prototype.packageType = function()
BlendTask.prototype.infoPlist = function()
{
var infoPlist = BundleTask.prototype.infoPlist.apply(this, arguments);
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
this._keyedThemes.filter(onlyUnique)
infoPlist.setValueForKey("CPKeyedThemes", this._keyedThemes.filter(onlyUnique));
//infoPlist.setValueForKey("CPKeyedThemes", require("narwhal/util").unique(this._keyedThemes));
infoPlist.setValueForKey("CPKeyedThemes", require("narwhal/util").unique(this._keyedThemes));
return infoPlist;
};
@@ -81,10 +72,9 @@ BlendTask.prototype.setThemeDescriptors = function(/*Array | FileList*/ themeDes
BlendTask.prototype.defineTasks = function()
{
var self = this;
return self.defineThemeDescriptorTasks().then(function() {
BundleTask.prototype.defineTasks.apply(self, arguments);
});
this.defineThemeDescriptorTasks();
BundleTask.prototype.defineTasks.apply(this, arguments);
};
BlendTask.prototype.defineSourceTasks = function()
@@ -93,68 +83,52 @@ BlendTask.prototype.defineSourceTasks = function()
BlendTask.prototype.defineThemeDescriptorTasks = function()
{
var self = this;
return new Promise(function(resolve, reject) {
var envsLeft = self.environments().length;
self.environments().forEach(function(anEnvironment)
this.environments().forEach(function(anEnvironment)
{
var folder = anEnvironment.name() + ".environment",
themeDescriptors = this.themeDescriptors(),
resourcesPath = this.resourcesPath(),
intermediatesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources"),
staticPath = this.buildProductStaticPathForEnvironment(anEnvironment),
keyedThemes = this._keyedThemes,
themesTaskName = this.name() + ":themes";
this.enhance(themesTaskName);
themeDescriptors.forEach(function(/*CPString*/ themeDescriptorPath)
{
var folder = anEnvironment.name() + ".environment",
themeDescriptors = this.themeDescriptors(),
resourcesPath = this.resourcesPath(),
intermediatesPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources"),
staticPath = this.buildProductStaticPathForEnvironment(anEnvironment),
keyedThemes = this._keyedThemes,
themesTaskName = this.name() + ":themes";
var tdLeft = themeDescriptors.length;
objj_importFile(FILE.absolute(themeDescriptorPath), YES);
});
this.enhance(themesTaskName);
[BKThemeDescriptor allThemeDescriptorClasses].forEach(function(aClass)
{
var keyedThemePath = FILE.join(intermediatesPath, [aClass themeName] + ".keyedtheme");
themeDescriptors.forEach(function(/*CPString*/ themeDescriptorPath)
filedir (keyedThemePath, themesTaskName);
filedir (staticPath, [keyedThemePath]);
keyedThemes.push([aClass themeName] + ".keyedtheme");
});
task (themesTaskName, function()
{
[BKThemeDescriptor allThemeDescriptorClasses].forEach(function(aClass)
{
var localIntermediatesPath = intermediatesPath;
var localStaticPath = staticPath;
var localKeyedThemes = keyedThemes;
var localThemesTaskName = themesTaskName;
objj_importFile(path.resolve(themeDescriptorPath), YES, function() {
if (--tdLeft === 0) {
[BKThemeDescriptor allThemeDescriptorClasses].forEach(function(aClass)
{
var keyedThemePath = path.join(localIntermediatesPath, [aClass themeName] + ".keyedtheme");
var themeTemplate = [[BKThemeTemplate alloc] init];
filedir (keyedThemePath, themesTaskName);
filedir (localStaticPath, [keyedThemePath]);
[themeTemplate setValue:[aClass themeName] forKey:@"name"];
localKeyedThemes.push([aClass themeName] + ".keyedtheme");
});
task (localThemesTaskName, function()
{
[BKThemeDescriptor allThemeDescriptorClasses].forEach(function(aClass)
{
var themeTemplate = [[BKThemeTemplate alloc] init];
var objectTemplates = [aClass themedObjectTemplates],
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
fileContents = themeFromCibData(data);
[themeTemplate setValue:[aClass themeName] forKey:@"name"];
var objectTemplates = [aClass themedObjectTemplates],
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
fileContents = themeFromCibData(data);
// No filedir in this case, so we have to make it ourselves.
fs.mkdirSync(localIntermediatesPath, { recursive: true });
//FILE.mkdirs(intermediatesPath);
// FIXME: MARKER_TEXT isn't global, so we use "t;".
fs.writeFileSync(path.join(localIntermediatesPath, [aClass themeName] + ".keyedtheme"), "t;" + fileContents.length + ";" + fileContents, { encoding: "utf8" });
//FILE.write(FILE.join(intermediatesPath, [aClass themeName] + ".keyedtheme"), "t;" + fileContents.length + ";" + fileContents, { charset:"UTF-8" });
});
});
if (--envsLeft === 0) {
resolve();
}
}
});
// No filedir in this case, so we have to make it ourselves.
FILE.mkdirs(intermediatesPath);
// FIXME: MARKER_TEXT isn't global, so we use "t;".
FILE.write(FILE.join(intermediatesPath, [aClass themeName] + ".keyedtheme"), "t;" + fileContents.length + ";" + fileContents, { charset:"UTF-8" });
});
}, self);
});
});
}, this);
};
function cibDataFromTopLevelObjects(objects)
@@ -280,7 +254,5 @@ exports.BlendTask = BlendTask;
exports.blend = function(aName, aFunction)
{
// No .apply necessary because the parameters aren't variable.
return BlendTask.defineTask(aName, aFunction).then(function(task) {
return task;
});
};
return BlendTask.defineTask(aName, aFunction);
};
+1
View File
@@ -1,3 +1,4 @@
require("../../common.jake");
subtasks(["BlendKit", "CommonJS", "Aristo", "Aristo2"], ["build", "clean", "clobber"]);
-2
View File
@@ -78,8 +78,6 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
#endif
}
@global document
- (id)initWithFrame:(CGRect)aFrame control:(CPControl)aControl
{
self = [super initWithFrame:aFrame];
+9 -14
View File
@@ -1,31 +1,26 @@
require("../common.jake");
const fs = require("fs");
const path = require("path");
const utilsFile = ObjectiveJ.utils.file;
var FILE = require("file");
var tmp_list = new FileList();
tmp_list.include("**/*");
tmp_list.exclude("Jakefile");
tmp_list.forEach(function(aFilename)
new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
{
if (!fs.lstatSync(aFilename).isFile())
if (!FILE.isFile(aFilename))
return;
var buildFilename = path.join($BUILD_CJS_CAPPUCCINO, aFilename);
var buildFilename = FILE.join($BUILD_CJS_CAPPUCCINO, aFilename);
filedir (buildFilename, [aFilename], function ()
{
utilsFile.cp(aFilename, buildFilename);
cp(aFilename, buildFilename);
});
// HACK: narwhal should copy permissions
if (path.dirname(aFilename) === path.join("bin"))
if (FILE.dirname(aFilename) === FILE.join("bin"))
{
filedir (buildFilename, function ()
{
fs.chmodSync(buildFilename, 0o755);
FILE.chmod(buildFilename, 0755);
});
}
@@ -34,5 +29,5 @@ tmp_list.forEach(function(aFilename)
});
task ("build", function() {
setPackageMetadata(path.join($BUILD_CJS_CAPPUCCINO, "package.json"));
setPackageMetadata(FILE.join($BUILD_CJS_CAPPUCCINO, "package.json"));
});
+1 -1
View File
@@ -233,7 +233,7 @@ ObjectiveJFlattener.prototype.serializeFunctions = function() {
var functionString = executable._function.toString().replace(", require, exports, module, system, print, window", ""); // HACK
var relative = this.rootPath.relative(path).toString();
this.functionsBuffer.push("ObjectiveJ.FileExecutable._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");");
this.functionsBuffer.push("ObjectiveJ.StaticResource._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");");
}
var bundle = this.context.global.CFBundle.bundleContainingURL(path);
-7
View File
@@ -1,7 +0,0 @@
#!/usr/bin/env node
JAKE = require("@objj/jake");
ObjectiveJ = require("@objj/runtime");
CAPPUCCINO = require("@objj/cappuccino");
JAKE.application().run({ args : process.argv });
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env node
ObjectiveJ = require("@objj/runtime");
//CAPPUCCINO = require("@objj/cappuccino");
var ojtest = require("@objj/ojtest");
// Inject path to the OJTest main Objective-J file into the arguments so it is the file to be executed.
var args = process.argv.slice(); // Copy
args.splice(1, 1, ojtest.pathToOJTest);
// Compile, load and run it
ObjectiveJ.run(args, {inlineMsgSendFunctions: true, sourceMap: true, sourceMapIncludeSource: true });
+11 -28
View File
@@ -1,7 +1,8 @@
var path = require("path");
var fs = require("fs");
/* function exposeExports(path)
var FILE = require("file");
function exposeExports(path)
{
var object = require(path);
@@ -10,31 +11,13 @@ var fs = require("fs");
exports[name] = object[name];
}
exposeExports("@objj/jake"); */
exposeExports("objective-j/jake");
var object = JAKE;
// This check is only necessary because during the build process blendtask gets created much later.
if (FILE.exists(FILE.join(FILE.dirname(module.path), "jake", "blendtask.j")))
{
var BLEND_TASK = require("cappuccino/jake/blendtask");
for (var name in object) {
if (object.hasOwnProperty(name)) {
exports[name] = object[name];
}
exports.BlendTask = BLEND_TASK.BlendTask;
exports.blend = BLEND_TASK.blend;
}
exports.initilize = function(callback) {
// This check is only necessary because during the build process blendtask gets created much later.
var blendTaskPath = path.join(process.cwd(), "..", "CommonJS", "blendtask.j");
// var blendTaskPath = path.join(path.dirname(module.path), "jake", "blendtask.j");
// Should be "{something}/AppKit/Themes/CommonJS/blendtask.j"
if (fs.existsSync(blendTaskPath))
{
var anExports = {};
function localCallback() {
callback(anExports);
}
process.env["CONFIG"] = "Debug";
ObjectiveJ.OBJJ_INCLUDE_PATHS.push(path.join(path.join($BUILD_DIR, "Debug"), "CommonJS", "cappuccino", "Frameworks"));
ObjectiveJ.make_narwhal_factory(blendTaskPath, null, null, localCallback)(require, anExports, module, typeof system !== "undefined" && system, console.log);
}
}
+12
View File
@@ -0,0 +1,12 @@
diff -rupN a/engines/rhino/bin/narwhal-rhino b/engines/rhino/bin/narwhal-rhino
--- a/engines/rhino/bin/narwhal-rhino 2011-11-16 11:01:40.000000000 +0000
+++ b/engines/rhino/bin/narwhal-rhino 2012-04-23 18:35:45.000000000 +0100
@@ -22,7 +22,7 @@ fi
CLASSPATH=$NARWHAL_ENGINE_HOME/jars/jna.jar
BOOTCLASSPATH=$NARWHAL_ENGINE_HOME/jars/js.jar
-JAVA_OPTS="-Dnarwhal.http_proxy=$http_proxy"
+JAVA_OPTS="-Dnarwhal.http_proxy=$http_proxy $JAVA_OPTS"
if [ -n "$NARWHAL_CLASSPATH" ]; then
CLASSPATH=$NARWHAL_CLASSPATH:$CLASSPATH
+1 -4
View File
@@ -207,10 +207,7 @@ var CPBundlesForURLStrings = { };
CPLog.error("Could not find bundle: " + self);
});
// Return the answer so it is possible to do 'await' on this 'loadWithDelegate:' method as the
// load function will return a Promise. It is still possible to not do 'await' on this method
// and that gives us the old behaviour.
return _bundle.load(YES);
_bundle.load(YES);
}
- (CPArray)staticResourceURLs
-2
View File
@@ -50,8 +50,6 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
DOMElement _scriptTag;
}
@global document
/*! @deprecated */
+ (CPJSONPConnection)sendRequest:(CPURLRequest)aRequest callback:(CPString)callbackParameter delegate:(id)aDelegate
{
@@ -320,8 +320,8 @@
lhs = lhs.stripDiacritics();
rhs = rhs.stripDiacritics();
}
var commut = (_options & CPCaseInsensitivePredicateOption) ? "i":"",
reg = new RegExp("^" + rhs.escapeForRegExp() + "$",commut);
var commut = (_options & CPCaseInsensitivePredicateOption) ? "gi":"g",
reg = new RegExp(rhs.escapeForRegExp(),commut);
return reg.test(lhs);
case CPBeginsWithPredicateOperatorType: var range = CPMakeRange(0, MIN([lhs length], [rhs length]));
-10
View File
@@ -570,16 +570,6 @@ var CPStringNull = [CPNull null];
return aString && aString != "" && self.indexOf(aString) == 0;
}
/*!
Returns \c YES if the receiver contains
the specified string. If \c aString
is empty, the method will return \c NO.
*/
- (BOOL)containsString:(CPString)aString
{
return aString && aString != "" && self.indexOf(aString) >= 0;
}
/*!
Returns \c YES if the receiver ends
with the specified string. If \c aString
+6 -17
View File
@@ -44,16 +44,6 @@ var abbreviationDictionary,
timeZoneDataVersion,
localizedName;
function abbreviationForDate(date)
{
// Sometimes the browsers will give unmatched timezones in other languages so try one more thing
// Take the locale string for english in the US. It has the following format (9/21/2021, 2:40:44 PM Central European Summer Time)
// Remove the date and time with this regex and take first letter in each word in the time zone name.
// This is not 100% but is better than nothing as JAvascript has no good support for this.
var abbreviation = date.toLocaleString('en-US', {timeZoneName : 'long'}).replace(/^([0]?\d|[1][0-2])\/((?:[0]?|[1-2])\d|[3][0-1])\/([2][01]|[1][6-9])\d{2}(,?\s*([0]?\d|[1][0-2])(\:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?\s*/, "").split(" ").map(function(l) { return l[0]}).join("");
return abbreviation;
}
/*!
@class CPTimeZone
@ingroup foundation
@@ -142,7 +132,6 @@ function abbreviationForDate(date)
@"CLST" : @"America/Santiago",
@"CLT" : @"America/Santiago",
@"COT" : @"America/Bogota",
@"CUT" : @"UTC",
@"CST" : @"America/Chicago",
@"EAT" : @"Africa/Addis_Ababa",
@"EDT" : @"America/New_York",
@@ -280,11 +269,11 @@ function abbreviationForDate(date)
};
var date = [CPDate date],
abbreviation = abbreviationForDate(date);
abbreviation = String(String(date).split("(")[1]).split(")")[0];
localTimeZone = [self timeZoneWithAbbreviation:abbreviation];
systemTimeZone = localTimeZone;
defaultTimeZone = localTimeZone;
systemTimeZone = [self timeZoneWithAbbreviation:abbreviation];
defaultTimeZone = [self timeZoneWithAbbreviation:abbreviation];
localizedName = @{
@"en" : englishLocalizedName,
@@ -441,7 +430,7 @@ function abbreviationForDate(date)
+ (void)resetSystemTimeZone
{
var date = [CPDate date],
abbreviation = abbreviationForDate(date);
abbreviation = String(String(date).split("(")[1]).split(")")[0];
systemTimeZone = [self timeZoneWithAbbreviation:abbreviation];
@@ -571,7 +560,7 @@ function abbreviationForDate(date)
if (!date)
return nil;
return abbreviationForDate(date);
return String(String(date).split("(")[1]).split(")")[0];
}
/*! Returns the number of seconds from GMT for the given date
@@ -584,7 +573,7 @@ function abbreviationForDate(date)
if (!date)
return nil;
var abbreviation = abbreviationForDate(date);
var abbreviation = String(String(date).split("(")[1]).split(")")[0];
return [timeDifferenceFromUTC valueForKey:abbreviation] * 60;
}
-25
View File
@@ -154,31 +154,6 @@ var CPURLConnectionDelegate = nil;
return [[self alloc] _initWithRequest:aRequest queue:aQueue completionHandler:aHandler];
}
/*
Loads the data for a URL request and returns a Promise.
@param aRequest contains the URL to obtain data from.
@discussion If the request completes successfully, the data parameter of the function contains the resource data, and the error parameter is nil. If the request fails, the data parameter is nil and the error parameter contain information about the failure.
Typical use can be like this:
- (async @action)doAction:(id)sender {
const { response, data, error } = await [CPURLConnection sendAsynchronousRequest:[CPURLRequest requestWithURL:@"http://cappuccino.dev"]];
if (error == nil) {
//do the stuff...
} else {
// Handle errors
}
}
*/
+ (async JSObject /* { response: CPURLResponse, data: CPData, error: CPError } */)sendAsynchronousRequest:(CPURLRequest)aRequest
{
return new Promise((resolve, reject) =>
[[self alloc] _initWithRequest:aRequest
queue:[CPOperationQueue mainQueue]
completionHandler:(aResponse, aData, anError) => resolve( {response: aResponse, data: aData, error:anError })]
);
}
/*
Creates a url connection with a delegate to monitor the request progress.
@param aRequest contains the URL to obtain data from
+57
View File
@@ -10,5 +10,62 @@
<string>Foundation</string>
<key>CPBundlePackageType</key>
<string>FMWK</string>
<key>CPFileTranslationDictionary</key>
<dict>
<key>_CPAggregateExpression.j</key>
<string>CPPredicate/_CPAggregateExpression.j</string>
<key>_CPSelfExpression.j</key>
<string>CPPredicate/_CPSelfExpression.j</string>
<key>_CPSubqueryExpression.j</key>
<string>CPPredicate/_CPSubqueryExpression.j</string>
<key>_CPConstantValueExpression.j</key>
<string>CPPredicate/_CPConstantValueExpression.j</string>
<key>CPCompoundPredicate_Constants.j</key>
<string>CPPredicate/CPCompoundPredicate_Constants.j</string>
<key>_CPSetExpression.j</key>
<string>CPPredicate/_CPSetExpression.j</string>
<key>CPCompoundPredicate.j</key>
<string>CPPredicate/CPCompoundPredicate.j</string>
<key>_CPKeyPathExpression.j</key>
<string>CPPredicate/_CPKeyPathExpression.j</string>
<key>CPComparisonPredicate.j</key>
<string>CPPredicate/CPComparisonPredicate.j</string>
<key>_CPPredicate.j</key>
<string>CPPredicate/_CPPredicate.j</string>
<key>_CPFunctionExpression.j</key>
<string>CPPredicate/_CPFunctionExpression.j</string>
<key>_CPExpression.j</key>
<string>CPPredicate/_CPExpression.j</string>
<key>CPExpression.j</key>
<string>CPPredicate/CPExpression.j</string>
<key>_CPBlockExpression.j</key>
<string>CPPredicate/_CPBlockExpression.j</string>
<key>_CPConditionalExpression.j</key>
<string>CPPredicate/_CPConditionalExpression.j</string>
<key>CPComparisonPredicate_Constants.j</key>
<string>CPPredicate/CPComparisonPredicate_Constants.j</string>
<key>CPPredicate.j</key>
<string>CPPredicate/CPPredicate.j</string>
<key>_CPVariableExpression.j</key>
<string>CPPredicate/_CPVariableExpression.j</string>
<key>_CPConcreteMutableSet.j</key>
<string>CPSet/_CPConcreteMutableSet.j</string>
<key>_CPSet.j</key>
<string>CPSet/_CPSet.j</string>
<key>CPSet.j</key>
<string>CPSet/CPSet.j</string>
<key>CPMutableSet.j</key>
<string>CPSet/CPMutableSet.j</string>
<key>_CPArray.j</key>
<string>CPArray/_CPArray.j</string>
<key>_CPJavaScriptArray.j</key>
<string>CPArray/_CPJavaScriptArray.j</string>
<key>CPArray.j</key>
<string>CPArray/CPArray.j</string>
<key>CPMutableArray.j</key>
<string>CPArray/CPMutableArray.j</string>
</dict>
</dict>
</plist>
+7 -13
View File
@@ -22,15 +22,12 @@
require("../common.jake");
var framework = require("../Jake/frameworktask.js").framework;
var BundleTask = require("../Jake/bundletask.js").BundleTask;
const path = require("path");
const utilsFile = ObjectiveJ.utils.file;
var framework = require("objective-j/jake").framework;
var BundleTask = require("objective-j/jake").BundleTask;
foundationTask = framework ("Foundation", function(foundationTask)
{
foundationTask.setBuildIntermediatesPath(path.join($BUILD_DIR, "Foundation.build", $CONFIGURATION))
foundationTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Foundation.build", $CONFIGURATION))
foundationTask.setBuildPath($BUILD_CONFIGURATION_DIR);
foundationTask.setAuthor("280 North, Inc.");
@@ -43,12 +40,10 @@ foundationTask = framework ("Foundation", function(foundationTask)
foundationTask.setResources(new FileList("Resources/**/*"));
foundationTask.setFlattensSources(true);
foundationTask.setInfoPlistPath("Info.plist");
foundationTask.setEnvironments(require("../Jake/environment.js").ObjJ);
foundationTask.setEnvironments(require("objective-j/jake/environment").ObjJ);
// Grab all the .h's and just include them in each file.
var INCLUDES_LIST = new FileList();
INCLUDES_LIST.include("**/*.h");
var INCLUDES = INCLUDES_LIST.map(function(aFilename)
var INCLUDES = new FileList("**/*.h").map(function(aFilename)
{
return "--include \"" + aFilename + "\"";
}).join(" ");
@@ -61,14 +56,13 @@ foundationTask = framework ("Foundation", function(foundationTask)
foundationTask.setCompilerFlags("-DDEBUG -g -S --inline-msg-send -Wno-unused-but-set-variable " + INCLUDES);
});
$BUILD_CJS_FOUNDATION = path.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "Foundation");
$BUILD_CJS_FOUNDATION = FILE.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "Foundation");
filedir ($BUILD_CJS_FOUNDATION, ["Foundation"], function()
{
utilsFile.cp_r(foundationTask.buildProductPath(), $BUILD_CJS_FOUNDATION);
cp_r(foundationTask.buildProductPath(), $BUILD_CJS_FOUNDATION);
});
task ("build", ["Foundation", $BUILD_CJS_FOUNDATION]);
CLOBBER.include($BUILD_CJS_FOUNDATION);
-503
View File
@@ -1,503 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
-9
View File
@@ -1,9 +0,0 @@
/*
Content-Type: multipart/related; boundary="_SEPARATOR_"
--_SEPARATOR_
Content-Location:test
Content-Transfer-Encoding:base64
R0lGODlhAQABAIAAAMc9BQAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
*/
-143
View File
@@ -1,143 +0,0 @@
/*
* Objective-J.js
* Objective-J
*
* Created by Francisco Tolmasky.
* Copyright 2008-2010, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
var /* FILE = require("file"), */
OS = require("os"),
Jake = JAKE,
BundleTask = (require("./bundletask")).BundleTask;
var fs = require("fs");
var path = require("path");
const utilsFile = ObjectiveJ.utils.file;
function ApplicationTask(aName)
{
BundleTask.apply(this, arguments);
if (fs.existsSync("index.html"))
this._indexFilePath = "index.html";
else
this._indexFilePath = null;
if (fs.existsSync("Frameworks"))
this._frameworksPath = "Frameworks";
else
this._frameworksPath = null;
this._shouldGenerateCacheManifest = false;
}
ApplicationTask.__proto__ = BundleTask;
ApplicationTask.prototype.__proto__ = BundleTask.prototype;
ApplicationTask.prototype.packageType = function()
{
return "APPL";
};
ApplicationTask.prototype.defineTasks = function()
{
BundleTask.prototype.defineTasks.apply(this, arguments);
this.defineFrameworksTask();
this.defineIndexFileTask();
this.defineCacheManifestTask();
};
ApplicationTask.prototype.setIndexFilePath = function(aFilePath)
{
this._indexFilePath = aFilePath;
};
ApplicationTask.prototype.indexFilePath = function()
{
return this._indexFilePath;
};
ApplicationTask.prototype.setFrameworksPath = function(aFrameworksPath)
{
this._frameworksPath = aFrameworksPath;
};
ApplicationTask.prototype.frameworksPath = function()
{
return this._frameworksPath;
};
ApplicationTask.prototype.setShouldGenerateCacheManifest = function(shouldGenerateCacheManifest)
{
this._shouldGenerateCacheManifest = shouldGenerateCacheManifest;
};
ApplicationTask.prototype.shouldGenerateCacheManifest = function()
{
return this._shouldGenerateCacheManifest;
};
ApplicationTask.prototype.defineFrameworksTask = function()
{
if (!this._frameworksPath && (this.environments()).indexOf((require("./environment.js")).Browser) === -1)
return;
var buildPath = this.buildProductPath(),
newFrameworks = path.join(buildPath, "Frameworks"),
thisTask = this;
Jake.fileCreate(newFrameworks, function()
{
if (thisTask._frameworksPath === "capp")
OS.system(["capp", "gen", "-f", "--force", buildPath]);
else if (thisTask._frameworksPath)
{
if (fs.existsSync(newFrameworks))
fs.rmSync(newFrameworks, { recursive: true });
var sourcePath = path.join(thisTask._frameworksPath, "Source"),
hasSource = fs.existsSync(sourcePath),
tempPath = path.join(process.cwd(), ".__capp_Frameworks_Source__");
if (hasSource)
fs.moveSync(sourcePath, tempPath);
utilsFile.copyRecursiveSync(thisTask._frameworksPath, newFrameworks);
if (hasSource)
fs.moveSync(tempPath, sourcePath);
} });
this.enhance([newFrameworks]);
};
ApplicationTask.prototype.buildIndexFilePath = function()
{
return path.join(this.buildProductPath(), path.basename(this.indexFilePath()));
};
ApplicationTask.prototype.defineIndexFileTask = function()
{
if (!this._indexFilePath)
return;
var indexFilePath = this.indexFilePath(),
buildIndexFilePath = this.buildIndexFilePath();
Jake.filedir(buildIndexFilePath, [indexFilePath], function()
{
fs.copyFileSync(indexFilePath, buildIndexFilePath);
});
this.enhance([buildIndexFilePath]);
};
ApplicationTask.prototype.defineCacheManifestTask = function()
{
if (!this.shouldGenerateCacheManifest())
return;
var productPath = path.join(this.buildProductPath(), "");
var indexFilePath = this.buildIndexFilePath();
var manifestPath = path.join(productPath, "app.manifest");
Jake.task(manifestPath, function()
{
(require("../cache-manifest")).generateManifest(productPath, {index: indexFilePath});
});
this.enhance([manifestPath]);
};
exports.ApplicationTask = ApplicationTask;
exports.app = function(aName, aFunction)
{
return ApplicationTask.defineTask(aName, aFunction);
};
-751
View File
@@ -1,751 +0,0 @@
/*
* Objective-J.js
* Objective-J
*
* Created by Francisco Tolmasky.
* Copyright 2008-2010, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Core modules
const child_process = require("child_process");
const path = require("path");
// NPM modules
const fs = require("fs");
const term = ObjectiveJ.term;
const utilsFile = ObjectiveJ.utils.file;
// Internal modules
const environment = require("./environment");
var task = JAKE.task;
var Task = JAKE.Task;
var filedir = JAKE.filedir;
var FileList = JAKE.FileList;
CLEAN = JAKE.CLEAN_AND_CLOBBER.CLEAN;
CLOBBER = JAKE.CLEAN_AND_CLOBBER.CLOBBER;
function isImage(aFilename)
{
return [".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"].includes(path.extname(aFilename).toLowerCase());
}
function mimeType(aFilename)
{
var mimeTypeDict = {
".png": "image/png",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".gif": "image/gif",
".tif": "image/tiff",
".tiff": "image/tiff"
};
var lowerCaseExt = path.extname(aFilename).toLowerCase();
return mimeTypeDict[lowerCaseExt];
}
function BundleTask(aName, anApplication)
{
Task.apply(this, arguments);
var ignoreCommonJS = process.env["CAPP_IGNORE_COMMONJS_ENV"];
if (ignoreCommonJS && ignoreCommonJS.toLowerCase() == "no" || ignoreCommonJS == "1")
this.setEnvironments([environment.Browser]);
else
this.setEnvironments([environment.Browser, environment.CommonJS]);
this._author = null;
this._email = null;
this._summary = null;
this._license = null;
this._sources = null;
this._resources = null;
this._spritesResources = true;
this._identifier = null;
this._version = 0.1;
this._compilerFlags = null;
this._flattensSources = false;
this._includesNibsAndXibs = false;
this._preventsNib2Cib = false;
this._productName = this.name();
this._buildIntermediatesPath = null;
this._buildPath = process.cwd();
this._replacedFiles = {};
this._nib2cibFlags = null;
this._infoPlistPath = "Info.plist";
this._principalClass = null;
}
BundleTask.__proto__ = Task;
BundleTask.prototype.__proto__ = Task.prototype;
BundleTask.defineTask = function(aName, aFunction)
{
var bundleTask = Task.defineTask.apply(this, [aName]);
if (aFunction) {
aFunction(bundleTask);
}
var p = bundleTask.defineTasks();
if (p != null) {
return p.then(() => {
return bundleTask;
});
} else {
return bundleTask;
}
};
BundleTask.prototype.setEnvironments = function(environments)
{
if (arguments.length < 1)
this._environments = [];
else if (arguments.length > 1)
this._environments = Array.prototype.slice.apply(environments);
else if (typeof environments.slice === "function")
this._environments = environments.slice();
else
this._environments = [environments];
};
BundleTask.prototype.environments = function()
{
return this._environments;
};
BundleTask.prototype.setAuthor = function(anAuthor)
{
this._author = anAuthor;
};
BundleTask.prototype.author = function()
{
return this._author;
};
BundleTask.prototype.setEmail = function(anEmail)
{
this._email = anEmail;
};
BundleTask.prototype.email = function()
{
return this._email;
};
BundleTask.prototype.setSummary = function(aSummary)
{
this._summary = aSummary;
};
BundleTask.prototype.summary = function()
{
return this._summary;
};
BundleTask.prototype.setIdentifier = function(anIdentifier)
{
this._identifier = anIdentifier;
};
BundleTask.prototype.identifier = function()
{
return this._identifier;
};
BundleTask.prototype.setVersion = function(aVersion)
{
this._version = aVersion;
};
BundleTask.prototype.version = function()
{
return this._version;
};
BundleTask.prototype.setSources = function(sources, environments)
{
if (!environments)
this._sources = sources;
else
{
if (!this._sources)
this._sources = {};
if (!Array.isArray(environments))
environments = [environments];
environments.forEach( function(anEnvironment)
{
this._sources[anEnvironment] = sources;
}, this);
}};
BundleTask.prototype.sources = function()
{
return this._sources;
};
BundleTask.prototype.setResources = function(resources)
{
this._resources = resources;
};
BundleTask.prototype.resources = function(resources)
{
this._resources = resources;
};
BundleTask.prototype.setSpritesResources = function(shouldSpriteResources)
{
this._spritesResources = shouldSpriteResources;
};
BundleTask.prototype.spritesResources = function()
{
return this._spritesResources;
};
BundleTask.prototype.setIncludesNibsAndXibs = function(shouldIncludeNibsAndXibs)
{
this._includesNibsAndXibs = shouldIncludeNibsAndXibs;
};
BundleTask.prototype.includesNibsAndXibs = function()
{
return this._includesNibsAndXibs;
};
BundleTask.prototype.setPreventsNib2Cib = function(shouldPreventNib2Cib)
{
this._preventsNib2Cib = shouldPreventNib2Cib;
};
BundleTask.prototype.preventsNib2Cib = function()
{
return this._preventsNib2Cib;
};
BundleTask.prototype.setProductName = function(aProductName)
{
this._productName = aProductName;
};
BundleTask.prototype.productName = function()
{
return this._productName;
};
BundleTask.prototype.setInfoPlistPath = function(anInfoPlistPath)
{
this._infoPlistPath = anInfoPlistPath;
};
BundleTask.prototype.infoPlistPath = function()
{
return this._infoPlistPath;
};
BundleTask.prototype.setPrincipalClass = function(aPrincipalClass)
{
this._principalClass = aPrincipalClass;
};
BundleTask.prototype.principalClass = function()
{
return this._principalClass;
};
BundleTask.prototype.setCompilerFlags = function(flags)
{
this._compilerFlags = flags;
};
BundleTask.prototype.compilerFlags = function()
{
return this._compilerFlags;
};
BundleTask.prototype.setNib2cibFlags = function(flags)
{
this._nib2cibFlags = flags;
};
BundleTask.prototype.setNib2CibFlags = BundleTask.prototype.setNib2cibFlags;
BundleTask.prototype.nib2cibFlags = function()
{
return this._nib2cibFlags;
};
BundleTask.prototype.flattensSources = function()
{
return this._flattensSources;
};
BundleTask.prototype.setFlattensSources = function(shouldFlattenSources)
{
this._flattensSources = shouldFlattenSources;
};
BundleTask.prototype.setLicense = function(aLicense)
{
this._license = aLicense;
};
BundleTask.prototype.license = function()
{
return this._license;
};
(BundleTask.prototype.setBuildPath = function(aBuildPath)
{
this._buildPath = aBuildPath;
}, BundleTask.prototype.buildPath = function()
{
return this._buildPath;
});
BundleTask.prototype.setBuildIntermediatesPath = function(aBuildPath)
{
this._buildIntermediatesPath = aBuildPath;
};
BundleTask.prototype.buildIntermediatesPath = function()
{
return this._buildIntermediatesPath || this.buildPath();
};
BundleTask.prototype.buildProductPath = function()
{
return path.join(this.buildPath(), this.productName());
};
BundleTask.prototype.buildIntermediatesProductPath = function()
{
return this.buildIntermediatesPath() || path.join(this.buildPath(), this.productName() + ".build");
};
BundleTask.prototype.buildProductStaticPathForEnvironment = function(anEnvironment)
{
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", this.productName() + ".sj");
};
BundleTask.prototype.buildProductMHTMLPathForEnvironment = function(anEnvironment)
{
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLPaths.txt");
};
BundleTask.prototype.buildProductMHTMLDataPathForEnvironment = function(anEnvironment)
{
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLData.txt");
};
BundleTask.prototype.buildProductMHTMLTestPathForEnvironment = function(anEnvironment)
{
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLTest.txt");
};
BundleTask.prototype.buildProductDataURLPathForEnvironment = function(anEnvironment)
{
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "dataURLs.txt");
};
BundleTask.prototype.defineTasks = function()
{
this.defineResourceTasks();
this.defineSourceTasks();
this.defineInfoPlistTask();
this.defineLicenseTask();
this.defineStaticTask();
this.defineSpritedImagesTask();
CLEAN.include(this.buildIntermediatesProductPath());
CLOBBER.include(this.buildProductPath());
};
BundleTask.prototype.packageType = function()
{
return 1;
};
BundleTask.prototype.infoPlist = function()
{
var infoPlistPath = this.infoPlistPath(),
infoPlist;
if (infoPlistPath && fs.existsSync(infoPlistPath))
infoPlist = CFPropertyList.propertyListFromString(fs.readFileSync(infoPlistPath, {encoding: "utf8"}));
else
infoPlist = new CFMutableDictionary();
infoPlist.setValueForKey("CPBundleInfoDictionaryVersion", 6.0);
infoPlist.setValueForKey("CPBundleName", this.productName());
infoPlist.setValueForKey("CPBundleIdentifier", this.identifier());
infoPlist.setValueForKey("CPBundleVersion", this.version());
infoPlist.setValueForKey("CPBundlePackageType", this.packageType());
infoPlist.setValueForKey("CPBundleEnvironments", (this.environments()).map( function(anEnvironment)
{
return anEnvironment.name();
}));
infoPlist.setValueForKey("CPBundleExecutable", this.productName() + ".sj");
var environmentsWithImageSprites = ((this.environments()).filter( function(anEnvironment)
{
return anEnvironment.spritesImages() && (((task(this.buildProductDataURLPathForEnvironment(anEnvironment))).prerequisites()).filter(isImage)).length > 0;
}, this)).map(function(anEnvironment)
{
return anEnvironment.name();
});
infoPlist.setValueForKey("CPBundleEnvironmentsWithImageSprites", environmentsWithImageSprites);
var principalClass = this.principalClass();
if (principalClass)
infoPlist.setValueForKey("CPPrincipalClass", principalClass);
return infoPlist;
};
BundleTask.prototype.defineInfoPlistTask = function()
{
var infoPlistProductPath = path.join(this.buildProductPath(), "Info.plist"),
bundleTask = this;
filedir(infoPlistProductPath, function()
{
fs.writeFileSync(infoPlistProductPath, CFPropertyList.stringFromPropertyList(bundleTask.infoPlist(), CFPropertyList.Format280North_v1_0), { encoding: "utf8"});
});
var infoPlistPath = this.infoPlistPath();
if (infoPlistPath && fs.existsSync(infoPlistPath))
filedir(infoPlistProductPath, [infoPlistPath]);
(this.environments()).forEach( function(anEnvironment)
{
if (!anEnvironment.spritesImages())
return;
filedir(infoPlistProductPath, this.buildProductStaticPathForEnvironment(anEnvironment));
}, this);
this.enhance([infoPlistProductPath]);
};
BundleTask.License = {LGPL_v2_1: "LGPL_v2_1", MIT: "MIT"};
var LICENSES_PATH = path.join(path.resolve(module.path), "LICENSES"),
LICENSE_PATHS = {"LGPL_v2_1": path.join(LICENSES_PATH, "LGPL-v2.1"), "MIT": path.join(LICENSES_PATH, "MIT")};
BundleTask.prototype.defineLicenseTask = function()
{
var license = this.license();
if (!license)
return;
var licensePath = LICENSE_PATHS[license];
licenseProductPath = path.join(this.buildProductPath(), "LICENSE");
filedir(licenseProductPath, [licensePath], function()
{
fs.copyFileSync(licensePath, licenseProductPath);
});
this.enhance([licenseProductPath]);
};
BundleTask.prototype.resourcesPath = function()
{
return path.join(this.buildProductPath(), "Resources", "");
};
BundleTask.isSpritable = function(aResourcePath) {
return isImage(aResourcePath) && fs.lstatSync(aResourcePath).size < 32768 && ("data:" + mimeType(aResourcePath) + ";base64," + Buffer.from(fs.readFileSync(aResourcePath)).toString("base64")).length < 32768;
};
BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPath)
{
if (this.spritesResources() && BundleTask.isSpritable(aResourcePath))
{
(this.environments()).forEach( function(anEnvironment)
{
if (!anEnvironment.spritesImages())
return;
var folder = anEnvironment.name() + ".environment",
spritedDestinationPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources", path.relative(this.resourcesPath(), aDestinationPath));
filedir(spritedDestinationPath, function()
{
fs.writeFileSync(spritedDestinationPath, Buffer.from(fs.readFileSync(aResourcePath)).toString("base64"), { encoding: "utf8" });
});
filedir(this.buildProductDataURLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir(this.buildProductMHTMLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir(this.buildProductMHTMLDataPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir(this.buildProductMHTMLTestPathForEnvironment(anEnvironment), [spritedDestinationPath]);
}, this);
} var extension = path.extname(aResourcePath),
extensionless = aResourcePath.substr(0, aResourcePath.length - extension.length);
if ((extension !== ".cib" || !fs.existsSync(extensionless + ".xib") && !fs.existsSync(extensionless + ".nib") || this._preventsNib2Cib) && (extension !== ".xib" && extension !== ".nib" || this.includesNibsAndXibs()))
{
filedir(aDestinationPath, [aResourcePath], function()
{
if (fs.existsSync(aDestinationPath))
try {
fs.rmSync(aDestinationPath, { recursive: true });
}
catch(anException) {
}
if (fs.lstatSync(aResourcePath).isDirectory())
utilsFile.copyRecursiveSync(aResourcePath, aDestinationPath);
else
fs.copyFileSync(aResourcePath, aDestinationPath);
});
this.enhance([aDestinationPath]);
} if ((extension === ".xib" || extension === ".nib") && !this._preventsNib2Cib)
{
var cibDestinationPath = path.join(path.dirname(aDestinationPath), path.basename(aDestinationPath, extension)) + ".cib";
var nib2cibFlags = this.nib2cibFlags();
if (!nib2cibFlags)
nib2cibFlags = "";
else if (nib2cibFlags.join)
nib2cibFlags = nib2cibFlags.join(" ");
filedir(cibDestinationPath, [aResourcePath], function()
{
try {
child_process.execSync("nib2cib '" + aResourcePath + "' '" + cibDestinationPath + "' " + nib2cibFlags, {stdio: 'inherit'});
} catch(error) {
console.log(error);
console.log(error.output.toString());
}
});
this.enhance([cibDestinationPath]);
}};
function directoryInCommon(filenames)
{
var aCommonDirectory = null;
filenames.forEach( function(aFilename)
{
var directory = path.dirname(aFilename);
if (directory === ".")
directory = "";
if (aCommonDirectory === null)
aCommonDirectory = directory;
else
{
var index = 0,
count = Math.min(directory.length, aFilename.length);
for (; index < count && aCommonDirectory.charAt(index) === directory.charAt(index); ++index);
aCommonDirectory = directory.substr(0, index);
} });
return aCommonDirectory;
}
BundleTask.prototype.defineResourceTasks = function()
{
if (!this._resources)
return;
var resources = [],
basePath = null;
this._resources.forEach( function(aResourcePath)
{
if (fs.existsSync(aResourcePath) && fs.lstatSync(aResourcePath).isDirectory())
{
resources = resources.concat(aResourcePath, (new FileList(aResourcePath + "/**")).toArray());
} else
resources.push(aResourcePath);
});
// TODO: assuming it returns the array without duplicates
// resources = UTIL.unique(resources);
resources = [... new Set(resources)];
if (resources.length <= 0)
return;
var basePathLength = (directoryInCommon(resources)).length,
resourcesPath = this.resourcesPath();
resources.forEach( function(aResourcePath)
{
this.defineResourceTask(aResourcePath, path.join(resourcesPath, aResourcePath.substring(basePathLength)));
}, this);
};
var RESOURCES_PATH = path.join(path.resolve(path.dirname(module.path)), "Jake/RESOURCES"),
MHTMLTestPath = path.join(RESOURCES_PATH, "MHTMLTest.txt");
BundleTask.prototype.defineSpritedImagesTask = function()
{
(this.environments()).forEach( function(anEnvironment)
{
if (!anEnvironment.spritesImages())
return;
var folder = anEnvironment.name() + ".environment",
resourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources", "");
var productName = this.productName(),
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment);
filedir(dataURLPath, function(aTask){
var prerequisites = (aTask.prerequisites()).filter(isImage);
if (!prerequisites.length)
{
if (fs.existsSync(dataURLPath))
fs.removeSync(dataURLPath);
return;
}
term.stream.print("Creating data URLs file... \0green(" + dataURLPath + "\0)");
var dataURLStream = fs.openSync(dataURLPath, "w+");
fs.writeSync(dataURLStream, "@STATIC;1.0;");
prerequisites.forEach(function(aFilename)
{
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename);
fs.writeFileSync(dataURLStream, "u;" + resourcePath.length + ";" + resourcePath, {encoding: "utf8"});
var contents = "data:" + mimeType(aFilename) + ";base64," + fs.readFileSync(aFilename).toString("utf8");
fs.writeFileSync(dataURLStream, contents.length + ";" + contents, { encoding: "utf8" });
});
fs.writeFileSync(dataURLStream, "e;", { encoding: "utf8"});
fs.closeSync(dataURLStream);
});
this.enhance([dataURLPath]);
var MHTMLPath = this.buildProductMHTMLPathForEnvironment(anEnvironment);
filedir(MHTMLPath, function(aTask)
{
var prerequisites = (aTask.prerequisites()).filter(isImage);
if (!prerequisites.length)
{
if (fs.existsSync(MHTMLPath))
fs.rmSync(MHTMLPath);
return;
}
term.stream.print("Creating MHTML paths file... \0green(" + MHTMLPath + "\0)");
var MHTMLStream = fs.openSync(MHTMLPath, "w+");
fs.writeSync(MHTMLStream, "@STATIC;1.0;");
prerequisites.forEach( function(aFilename)
{
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename),
MHTMLResourcePath = "mhtml:" + path.join(folder, "MHTMLData.txt!") + resourcePath;
fs.writeSync(MHTMLStream, "u;" + resourcePath.length + ";" + resourcePath);
fs.writeSync(MHTMLStream, MHTMLResourcePath.length + ";" + MHTMLResourcePath);
});
fs.closeSync(MHTMLStream);
});
this.enhance([MHTMLPath]);
var MHTMLDataPath = this.buildProductMHTMLDataPathForEnvironment(anEnvironment);
filedir(MHTMLDataPath, function(aTask)
{
var prerequisites = (aTask.prerequisites()).filter(isImage);
if (!prerequisites.length)
{
if (fs.existsSync(MHTMLDataPath))
fs.rmSync(MHTMLDataPath);
return;
}
term.stream.print("Creating MHTML images file... \0green(" + MHTMLDataPath + "\0)");
var MHTMLDataStream = fs.openSync(MHTMLDataPath, "w+");
fs.writeSync(MHTMLDataStream, "/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n");
prerequisites.forEach( function(aFilename)
{
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename);
fs.writeSync(MHTMLDataStream, "--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n");
fs.writeSync(MHTMLDataStream, "Content-Location:" + resourcePath + "\r\nContent-Transfer-Encoding:base64\r\n\r\n");
fs.writeSync(MHTMLDataStream, fs.readFileSync(aFilename).toString("utf8"));
fs.writeSync(MHTMLDataStream, "\r\n");
/* MHTMLDataStream.write("--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n");
MHTMLDataStream.write("Content-Location:" + resourcePath + "\r\nContent-Transfer-Encoding:base64\r\n\r\n");
MHTMLDataStream.write(fs.readFileSync(aFilename).toString("utf8"));
MHTMLDataStream.write("\r\n"); */
});
fs.writeSync(MHTMLDataStream, "*/");
fs.closeSync(MHTMLDataStream);
});
this.enhance([MHTMLDataPath]);
var MHTMLTestDestinationPath = this.buildProductMHTMLTestPathForEnvironment(anEnvironment);
filedir(MHTMLTestDestinationPath, function(aTask)
{
term.stream.print("Copying MHTML test file... \0green(" + MHTMLTestDestinationPath + "\0)");
fs.copyFileSync(MHTMLTestPath, MHTMLTestDestinationPath);
});
this.enhance([MHTMLTestDestinationPath]);
}, this);
};
BundleTask.prototype.defineStaticTask = function()
{
(this.environments()).forEach( function(anEnvironment)
{
var folder = anEnvironment.name() + ".environment",
sourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Sources", ""),
resourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources", ""),
staticPath = this.buildProductStaticPathForEnvironment(anEnvironment),
flattensSources = this.flattensSources(),
productName = this.productName();
filedir(staticPath, function(aTask)
{
term.stream.print("Creating static file... \0green(" + staticPath + "\0)");
var fileStream = fs.openSync(staticPath, "w+");
fs.writeSync(fileStream, "@STATIC;1.0;");
(aTask.prerequisites()).forEach( function(aFilename)
{
if (!fs.lstatSync(aFilename).isFile())
return;
var dirname = path.dirname(aFilename);
if (aFilename.indexOf(sourcesPath) === 0)
{
var relativePath = flattensSources ? path.basename(aFilename) : path.relative(sourcesPath, aFilename);
fs.writeSync(fileStream, "p;" + relativePath.length + ";" + relativePath);
var fileContents = fs.readFileSync(aFilename).toString("utf8");
fs.writeSync(fileStream, "t;" + fileContents.length + ";" + fileContents);
}
else if (aFilename.indexOf(resourcesPath) === 0 && !isImage(aFilename))
{
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename);
fs.writeFileSync(fileStream, "p;");
//fileStream.write("p;");
contents = fs.readFileSync(aFilename).toString("utf8");
fs.writeFileSync(fileStream, resourcePath.length + ";" + resourcePath + contents);
//fileStream.write(resourcePath.length + ";" + resourcePath + contents);
}
}, this);
fs.writeFileSync(fileStream, "e;");
fs.closeSync(fileStream);
//fileStream.write("e;");
//fileStream.close();
ObjectiveJ.Executable.resetCachedFileExecutableSearchers();
ObjectiveJ.StaticResource.resetRootResources();
ObjectiveJ.FileExecutable.resetFileExecutables();
objj_resetRegisterClasses();
});
this.enhance([staticPath]);
}, this);
};
BundleTask.prototype.defineSourceTasks = function()
{
var sources = this.sources();
if (!sources) {
return;
}
var compilerFlags = this.compilerFlags();
var flattensSources = this.flattensSources();
if (!compilerFlags)
compilerFlags = "";
else if (compilerFlags.join)
compilerFlags = compilerFlags.join(" ");
(this.environments()).forEach( function(anEnvironment)
{
var environmentSources = sources,
folder = anEnvironment.name() + ".environment",
sourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Sources", ""),
staticPath = this.buildProductStaticPathForEnvironment(anEnvironment);
if (!Array.isArray(environmentSources) && environmentSources.constructor !== FileList)
{
environmentSources = environmentSources[anEnvironment];
if (!environmentSources)
return;
} var replacedFiles = [],
environmentCompilerFlags = (anEnvironment.compilerFlags()).join(" ") + " " + compilerFlags,
flattensSources = this.flattensSources(),
basePath = directoryInCommon(environmentSources),
basePathLength = basePath.length,
translateFilenameToPath = {},
otherwayTranslateFilenameToPath = {};
environmentSources.forEach( function(aFilename)
{
translateFilenameToPath[flattensSources ? path.basename(aFilename) : aFilename] = aFilename;
otherwayTranslateFilenameToPath[aFilename] = flattensSources ? path.basename(aFilename) : aFilename;
}, this);
var e = {};
environmentSources.forEach( function(aFilename)
{
ObjectiveJ.Executable.resetCachedFileExecutableSearchers();
ObjectiveJ.StaticResource.resetRootResources();
ObjectiveJ.FileExecutable.resetFileExecutables();
objj_resetRegisterClasses();
if (!fs.existsSync(aFilename))
return;
var relativePath = aFilename.substring(basePathLength ? basePathLength + 1 : basePathLength),
compiledEnvironmentSource = path.join(sourcesPath, relativePath);
filedir(compiledEnvironmentSource, [aFilename], async function()
{
if ((path.extname(aFilename)).toLowerCase() !== ".j")
{
(term.stream.write("Including [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)"));
var compiled = fs.readFileSync(aFilename, { encoding: "utf8"}).toString();
var dots = (Array(Math.round(compiled.length / 1024 / 4) + 3)).join(".");
var p = await fs.promises.writeFile(compiledEnvironmentSource, compiled, { encoding: "utf8"});
term.stream.print(dots);
return p;
}
else
{
var translatedFilename = translateFilenameToPath[aFilename] ? translateFilenameToPath[aFilename] : aFilename,
otherwayTranslatedFilename = otherwayTranslateFilenameToPath[aFilename] ? otherwayTranslateFilenameToPath[aFilename] : aFilename,
theTranslatedFilename = otherwayTranslatedFilename ? otherwayTranslatedFilename : translatedFilename,
absolutePath = path.resolve(theTranslatedFilename),
basePath = absolutePath.substring(0, absolutePath.length - theTranslatedFilename.length);
ObjectiveJ.StaticResource.setCurrentGccCompilerFlags(environmentCompilerFlags);
CFBundle.environments = function()
{
return [anEnvironment.name(), "ObjJ"];
};
return new Promise((resolve, reject) => {
var callback = function() {
var otherwayTranslatedFilename = otherwayTranslateFilenameToPath[aFilename] ? otherwayTranslateFilenameToPath[aFilename] : aFilename,
translatedFilename = translateFilenameToPath[aFilename] ? translateFilenameToPath[aFilename] : aFilename,
executer = new ObjectiveJ.FileExecutable(otherwayTranslatedFilename);
var compiled = executer.toMarkedString();
//var msg = "Compiling [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)";
var dots = (Array(Math.round(compiled.length / 1024 / 4) + 3)).join(".");
fs.writeFileSync(compiledEnvironmentSource, compiled, { encoding: "utf8"});
term.stream.print(dots);
resolve();
}
var msg = "Compiling [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)";
term.stream.write(msg);
ObjectiveJ.make_narwhal_factory(absolutePath, basePath, translateFilenameToPath, callback)(require, e, module, {}, console.log);
});
}
});
filedir(staticPath, [compiledEnvironmentSource]);
replacedFiles.push(flattensSources ? path.basename(aFilename) : relativePath);
}, this);
this._replacedFiles[anEnvironment] = replacedFiles;
}, this);
};
exports.BundleTask = BundleTask;
exports.bundle = function(aName, aFunction)
{
return BundleTask.defineTask(aName, aFunction);
};
-67
View File
@@ -1,67 +0,0 @@
/*
* Objective-J.js
* Objective-J
*
* Created by Francisco Tolmasky.
* Copyright 2008-2010, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
var environments = {};
function Environment(aName)
{
this._name = aName;
this._compilerFlags = [];
this._spritesImages = false;
environments[aName] = this;
}
Environment.environmentWithName = function(aName)
{
return environments[aName];
};
Environment.prototype.name = function()
{
return this._name;
};
Environment.prototype.toString = function()
{
return this._name;
};
Environment.prototype.compilerFlags = function()
{
return this._compilerFlags;
};
Environment.prototype.setCompilerFlags = function(flags)
{
this._compilerFlags = flags;
};
Environment.prototype.setSpritesImages = function(shouldSpriteImages)
{
this._spritesImages = !!shouldSpriteImages;
};
Environment.prototype.spritesImages = function()
{
return this._spritesImages;
};
exports.Environment = Environment;
exports.ObjJ = new Environment("ObjJ");
var CommonJS = new Environment("CommonJS");
CommonJS.setCompilerFlags(["-DPLATFORM_COMMONJS"]);
exports.CommonJS = CommonJS;
var Browser = new Environment("Browser");
Browser.setCompilerFlags(["-DPLATFORM_BROWSER", "-DPLATFORM_DOM"]);
Browser.setSpritesImages(true);
exports.Browser = Browser;
-38
View File
@@ -1,38 +0,0 @@
/*
* Objective-J.js
* Objective-J
*
* Created by Francisco Tolmasky.
* Copyright 2008-2010, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
BundleTask = (require("./bundletask")).BundleTask;
function FrameworkTask(aName)
{
BundleTask.apply(this, arguments);
}
FrameworkTask.__proto__ = BundleTask;
FrameworkTask.prototype.__proto__ = BundleTask.prototype;
FrameworkTask.prototype.packageType = function()
{
return "FMWK";
};
exports.FrameworkTask = FrameworkTask;
exports.framework = function(aName, aFunction)
{
return FrameworkTask.defineTask(aName, aFunction);
};
+73 -99
View File
@@ -1,19 +1,15 @@
require("./common.jake");
var fs = require('fs');
var path = require('path');
var childProcess = require("child_process");
const term = ObjectiveJ.term;
const utilsFile = ObjectiveJ.utils.file;
var FILE = require("file"),
SYSTEM = require("system"),
OS = require("os"),
UTIL = require("narwhal/util"),
jake = require("jake"),
stream = require("narwhal/term").stream;
var subprojects = ["Objective-J", "CommonJS", "Foundation", "AppKit", "Tools"];
task ("build", function() {
childProcess.execSync(["mkdir", "-p", $BUILD_DIR].map(utilsFile.enquote).join(" "), {stdio: 'inherit'});
childProcess.execSync(['ln', '-sf', '"$PWD"/node_modules', utilsFile.enquote($BUILD_DIR)].join(" "), {stdio: 'inherit'});
});
["build", "clean", "clobber"].forEach(function(aTaskName)
{
task (aTaskName, function()
@@ -22,56 +18,41 @@ task ("build", function() {
});
});
$BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS = path.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Debug");
$BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Debug");
filedir ($BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, ["debug", "release"], function()
{
fs.mkdirSync($BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, { recursive: true });
FILE.mkdirs($BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS);
utilsFile.cp_r(path.join($BUILD_DIR, "Debug", "Objective-J"), path.join($BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, "Objective-J"));
cp_r(FILE.join($BUILD_DIR, "Debug", "Objective-J"), FILE.join($BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, "Objective-J"));
});
$BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS = path.join($BUILD_CJS_CAPPUCCINO, "Frameworks", "Debug");
$BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS = FILE.join($BUILD_CJS_CAPPUCCINO, "Frameworks", "Debug");
filedir ($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, ["debug", "release"], function()
{
fs.mkdirSync($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, { recursive: true });
FILE.mkdirs($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS);
utilsFile.cp_r(path.join($BUILD_DIR, "Debug", "Foundation"), path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "Foundation"));
utilsFile.cp_r(path.join($BUILD_DIR, "Debug", "AppKit"), path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "AppKit"));
utilsFile.cp_r(path.join($BUILD_DIR, "Debug", "BlendKit"), path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "BlendKit"));
cp_r(FILE.join($BUILD_DIR, "Debug", "Foundation"), FILE.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "Foundation"));
cp_r(FILE.join($BUILD_DIR, "Debug", "AppKit"), FILE.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "AppKit"));
cp_r(FILE.join($BUILD_DIR, "Debug", "BlendKit"), FILE.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "BlendKit"));
});
task ("CommonJS", [$BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, $BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "debug", "release"], function() {
});
task ("CommonJS", [$BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, $BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "debug", "release"]);
// Install everything in the dist directory
task ("dist", ["CommonJS"], function()
task ("install", ["CommonJS"], function()
{
installCopy($BUILD_CJS_OBJECTIVE_J, false);
installCopy($BUILD_CJS_CAPPUCCINO, false);
});
task ("sudo-dist", ["CommonJS"], function()
task ("sudo-install", ["CommonJS"], function()
{
installCopy($BUILD_CJS_OBJECTIVE_J, true);
installCopy($BUILD_CJS_CAPPUCCINO, true);
});
// Install everything in the dist directory (task dist) and
// create symlinks to the 'dist' binaries in the global 'npm prefix' path
task ("install", ["dist"], function()
{
installGlobal($BUILD_CJS_OBJECTIVE_J, false);
installGlobal($BUILD_CJS_CAPPUCCINO, false);
});
task ("sudo-install", ["sudo-dist"], function()
{
installGlobal($BUILD_CJS_OBJECTIVE_J, true);
installGlobal($BUILD_CJS_CAPPUCCINO, true);
});
task ("install-symlinks", function()
{
installSymlink($BUILD_CJS_OBJECTIVE_J);
@@ -86,35 +67,35 @@ task ("install-debug-symlinks", function()
task ("clean-sprites", function()
{
var f = new FileList(path.join(SYSTEM.env.CAPP_BUILD, "**/dataURLs.txt")),
var f = new FileList(FILE.join(SYSTEM.env.CAPP_BUILD, "**/dataURLs.txt")),
paths = f.items();
f = new FileList(path.join(SYSTEM.env.CAPP_BUILD, "**/MHTML*.txt"));
f = new FileList(FILE.join(SYSTEM.env.CAPP_BUILD, "**/MHTML*.txt"));
paths = paths.concat(f.items());
paths.forEach(function(path)
{
fs.rmSync(path);
FILE.remove(path);
});
});
task ("clobber-theme", function()
{
var f = new FileList(path.join(SYSTEM.env.CAPP_BUILD, "**/Aristo.blend"), path.join(SYSTEM.env.CAPP_BUILD, "**/Aristo2.blend")),
var f = new FileList(FILE.join(SYSTEM.env.CAPP_BUILD, "**/Aristo.blend"), FILE.join(SYSTEM.env.CAPP_BUILD, "**/Aristo2.blend")),
paths = f.items();
f = new FileList(path.join(SYSTEM.env.CAPP_BUILD, "Aristo.build"), path.join(SYSTEM.env.CAPP_BUILD, "Aristo2.build"));
f = new FileList(FILE.join(SYSTEM.env.CAPP_BUILD, "Aristo.build"), FILE.join(SYSTEM.env.CAPP_BUILD, "Aristo2.build"));
paths = paths.concat(f.items());
paths.forEach(function(path)
{
utilsFile.rm_rf(path);
rm_rf(path);
});
});
// Documentation
$DOCUMENTATION_BUILD = path.join($BUILD_DIR, "Documentation");
$DOCUMENTATION_BUILD = FILE.join($BUILD_DIR, "Documentation");
task ("docs", ["documentation"]);
@@ -133,13 +114,12 @@ task ("documentation-no-frame", function()
task ("docset", function()
{
generateDocs(true);
var documentationDir = path.resolve(path.join("Tools", "Documentation")),
docsetShell = path.join(documentationDir, "support", "docset.sh");
var documentationDir = FILE.canonical(FILE.join("Tools", "Documentation")),
docsetShell = FILE.join(documentationDir, "support", "docset.sh");
OS.system([docsetShell, documentationDir]);
});
function generateDocs(/* boolean */ noFrame)
{
// try to find a doxygen executable in the PATH;
@@ -155,7 +135,7 @@ function generateDocs(/* boolean */ noFrame)
{
var doxygenApps = p.stdout.read().split("\n");
if (doxygenApps[0])
doxygen = path.join(doxygenApps[0], "Contents/Resources/doxygen");
doxygen = FILE.join(doxygenApps[0], "Contents/Resources/doxygen");
}
}
finally
@@ -175,8 +155,8 @@ function generateDocs(/* boolean */ noFrame)
colorPrint("Using " + doxygen + " for doxygen binary.", "green");
colorPrint("Pre-processing source files...", "green");
var documentationDir = FILE.canonical(path.join("Tools", "Documentation")),
processors = FILE.glob(path.join(documentationDir, "preprocess/*"));
var documentationDir = FILE.canonical(FILE.join("Tools", "Documentation")),
processors = FILE.glob(FILE.join(documentationDir, "preprocess/*"));
for (var i = 0; i < processors.length; ++i)
if (OS.system([processors[i], documentationDir]))
@@ -185,26 +165,26 @@ function generateDocs(/* boolean */ noFrame)
if (noFrame)
{
// Back up the default settings, turn off the treeview
if (OS.system(["sed", "-i", ".bak", "s/GENERATE_TREEVIEW.*=.*YES/GENERATE_TREEVIEW = NO/", path.join(documentationDir, "Cappuccino.doxygen")]))
if (OS.system(["sed", "-i", ".bak", "s/GENERATE_TREEVIEW.*=.*YES/GENERATE_TREEVIEW = NO/", FILE.join(documentationDir, "Cappuccino.doxygen")]))
return;
}
else if (FILE.exists(path.join(documentationDir, "Cappuccino.doxygen.bak")))
utilsFile.mv(path.join(documentationDir, "Cappuccino.doxygen.bak"), path.join(documentationDir, "Cappuccino.doxygen"));
else if (FILE.exists(FILE.join(documentationDir, "Cappuccino.doxygen.bak")))
mv(FILE.join(documentationDir, "Cappuccino.doxygen.bak"), FILE.join(documentationDir, "Cappuccino.doxygen"));
var doxygenDidSucceed = !OS.system([doxygen, path.join(documentationDir, "Cappuccino.doxygen")]);
var doxygenDidSucceed = !OS.system([doxygen, FILE.join(documentationDir, "Cappuccino.doxygen")]);
// Restore the original doxygen settings
if (FILE.exists(path.join(documentationDir, "Cappuccino.doxygen.bak")))
utilsFile.mv(path.join(documentationDir, "Cappuccino.doxygen.bak"), path.join(documentationDir, "Cappuccino.doxygen"));
if (FILE.exists(FILE.join(documentationDir, "Cappuccino.doxygen.bak")))
mv(FILE.join(documentationDir, "Cappuccino.doxygen.bak"), FILE.join(documentationDir, "Cappuccino.doxygen"));
colorPrint("Post-processing generated documentation...", "green");
processors = FILE.glob(path.join(documentationDir, "postprocess/*"));
processors = FILE.glob(FILE.join(documentationDir, "postprocess/*"));
for (var i = 0; i < processors.length; ++i)
if (OS.system([processors[i], documentationDir, path.join("Documentation", "html")]))
if (OS.system([processors[i], documentationDir, FILE.join("Documentation", "html")]))
{
utilsFile.rm_rf("Documentation");
rm_rf("Documentation");
return;
}
@@ -213,13 +193,13 @@ function generateDocs(/* boolean */ noFrame)
if (!FILE.isDirectory($BUILD_DIR))
FILE.mkdirs($BUILD_DIR);
utilsFile.rm_rf($DOCUMENTATION_BUILD);
utilsFile.mv("debug.txt", path.join("Documentation", "debug.txt"));
utilsFile.mv("Documentation", $DOCUMENTATION_BUILD);
rm_rf($DOCUMENTATION_BUILD);
mv("debug.txt", FILE.join("Documentation", "debug.txt"));
mv("Documentation", $DOCUMENTATION_BUILD);
// There is a bug in doxygen 1.7.x preventing loading correctly the custom CSS
// So let's do it manually
utilsFile.cp(path.join(documentationDir, "doxygen.css"), path.join($DOCUMENTATION_BUILD, "html", "doxygen.css"));
cp(FILE.join(documentationDir, "doxygen.css"), FILE.join($DOCUMENTATION_BUILD, "html", "doxygen.css"));
}
}
@@ -227,25 +207,25 @@ function generateDocs(/* boolean */ noFrame)
task ("downloads", ["starter_download"]);
$STARTER_README = path.join('Tools', 'READMEs', 'STARTER-README');
$STARTER_README = FILE.join('Tools', 'READMEs', 'STARTER-README');
$STARTER_BOOTSTRAP = 'bootstrap.sh';
$STARTER_DOWNLOAD = path.join($BUILD_DIR, 'Cappuccino', 'Starter');
$STARTER_DOWNLOAD_APPLICATION = path.join($STARTER_DOWNLOAD, 'NewApplication');
$STARTER_DOWNLOAD_README = path.join($STARTER_DOWNLOAD, 'README');
$STARTER_DOWNLOAD_BOOTSTRAP = path.join($STARTER_DOWNLOAD, 'bootstrap.sh');
$STARTER_DOWNLOAD = FILE.join($BUILD_DIR, 'Cappuccino', 'Starter');
$STARTER_DOWNLOAD_APPLICATION = FILE.join($STARTER_DOWNLOAD, 'NewApplication');
$STARTER_DOWNLOAD_README = FILE.join($STARTER_DOWNLOAD, 'README');
$STARTER_DOWNLOAD_BOOTSTRAP = FILE.join($STARTER_DOWNLOAD, 'bootstrap.sh');
task ("starter_download", [$STARTER_DOWNLOAD_APPLICATION, $STARTER_DOWNLOAD_README, $STARTER_DOWNLOAD_BOOTSTRAP, "documentation"], function()
{
if (FILE.exists($DOCUMENTATION_BUILD))
{
utilsFile.rm_rf(path.join($STARTER_DOWNLOAD, 'Documentation'));
utilsFile.cp_r(path.join($DOCUMENTATION_BUILD, 'html', '.'), path.join($STARTER_DOWNLOAD, 'Documentation'));
rm_rf(FILE.join($STARTER_DOWNLOAD, 'Documentation'));
cp_r(FILE.join($DOCUMENTATION_BUILD, 'html', '.'), FILE.join($STARTER_DOWNLOAD, 'Documentation'));
}
});
filedir ($STARTER_DOWNLOAD_APPLICATION, ["CommonJS"], function()
{
utilsFile.rm_rf($STARTER_DOWNLOAD_APPLICATION);
rm_rf($STARTER_DOWNLOAD_APPLICATION);
FILE.mkdirs($STARTER_DOWNLOAD);
if (OS.system(["capp", "gen", $STARTER_DOWNLOAD_APPLICATION, "-t", "Application", "--noconfig"]))
@@ -258,7 +238,7 @@ filedir ($STARTER_DOWNLOAD_APPLICATION, ["CommonJS"], function()
filedir ($STARTER_DOWNLOAD_README, [$STARTER_README], function()
{
utilsFile.cp($STARTER_README, $STARTER_DOWNLOAD_README);
cp($STARTER_README, $STARTER_DOWNLOAD_README);
});
filedir ($STARTER_DOWNLOAD_BOOTSTRAP, [$STARTER_BOOTSTRAP], function()
@@ -272,23 +252,23 @@ filedir ($STARTER_DOWNLOAD_BOOTSTRAP, [$STARTER_BOOTSTRAP], function()
task ("deploy", ["downloads", "demos"], function()
{
var cappuccino_output_path = path.join($BUILD_DIR, 'Cappuccino');
var cappuccino_output_path = FILE.join($BUILD_DIR, 'Cappuccino');
// zip the starter pack
var starter_zip_output = path.join($BUILD_DIR, 'Cappuccino', 'Starter.zip');
utilsFile.rm_rf(starter_zip_output);
var starter_zip_output = FILE.join($BUILD_DIR, 'Cappuccino', 'Starter.zip');
rm_rf(starter_zip_output);
OS.system("cd " + OS.enquote(cappuccino_output_path) + " && zip -ry -8 Starter.zip Starter");
});
task ("demos", function()
{
var demosDir = path.join($BUILD_DIR, "CappuccinoDemos"),
zipDir = path.join(demosDir, "demos.zip"),
var demosDir = FILE.join($BUILD_DIR, "CappuccinoDemos"),
zipDir = FILE.join(demosDir, "demos.zip"),
demosQuoted = OS.enquote(demosDir),
zipQuoted = OS.enquote(zipDir);
utilsFile.rm_rf(demosDir);
rm_rf(demosDir);
FILE.mkdirs(demosDir);
OS.system("curl -L http://github.com/cappuccino/cappuccino-demos/zipball/master > " + zipQuoted);
@@ -299,7 +279,7 @@ task ("demos", function()
function Demo(aPath)
{
this._path = aPath;
this._plist = CFPropertyList.readPropertyListFromFile(path.join(aPath, 'Info.plist'));
this._plist = CFPropertyList.readPropertyListFromFile(FILE.join(aPath, 'Info.plist'));
}
Demo.prototype.plist = function(key)
@@ -329,21 +309,21 @@ task ("demos", function()
return this.name();
};
FILE.glob(path.join(demosDir, "demos", "**/Info.plist")).map(function(demoPath){
FILE.glob(FILE.join(demosDir, "demos", "**/Info.plist")).map(function(demoPath){
return new Demo(FILE.dirname(demoPath));
}).filter(function(demo){
return !demo.excluded();
}).forEach(function(demo)
{
// copy frameworks into the demos
utilsFile.cp_r(path.join($STARTER_DOWNLOAD_APPLICATION, "Frameworks"), path.join(demo.path(), "Frameworks"));
utilsFile.rm_rf(path.join(demo.path(), "Frameworks", "Debug"));
cp_r(FILE.join($STARTER_DOWNLOAD_APPLICATION, "Frameworks"), FILE.join(demo.path(), "Frameworks"));
rm_rf(FILE.join(demo.path(), "Frameworks", "Debug"));
var outputPath = demo.name().replace(/\s/g, "-") + ".zip";
OS.system("cd " + OS.enquote(FILE.dirname(demo.path()))+" && zip -ry -8 " + OS.enquote(outputPath) + " " + OS.enquote(FILE.basename(demo.path())));
// remove the frameworks
utilsFile.rm_rf(path.join(demo.path(), "Frameworks"));
rm_rf(FILE.join(demo.path(), "Frameworks"));
});
});
@@ -353,18 +333,12 @@ task("test", ["CommonJS", "test-only"]);
task("test-only", function()
{
var tests = new FileList('Tests/**/*Test.j');
var cmd = ["ojtest"].concat(tests.items());
var cmdString = cmd.map(utilsFile.enquote).join(" ");
var tests = new FileList('Tests/**/*Test.j'),
cmd = ["ojtest"].concat(tests.items()),
code = OS.system(serializedENV() + " " + cmd.map(OS.enquote).join(" "));
try
{
childProcess.execSync(serializedENV() + " " + cmdString, {stdio: 'inherit'});
}
catch (e)
{
process.exit(1);
}
if (code !== 0)
OS.exit(code);
});
task("check-missing-imports", function()
@@ -427,9 +401,9 @@ function pushPackage(path, remote, branch)
var pkg = JSON.parse(packagePath.join("package.json").read({ charset : "UTF-8" }));
term.stream.print(" Version: " + colorize(pkg.version, "purple"));
term.stream.print(" Revision: " + colorize(pkg["cappuccino-revision"], "purple"));
term.stream.print(" Timestamp: " + colorize(pkg["cappuccino-timestamp"], "purple"));
stream.print(" Version: " + colorize(pkg.version, "purple"));
stream.print(" Revision: " + colorize(pkg["cappuccino-revision"], "purple"));
stream.print(" Timestamp: " + colorize(pkg["cappuccino-timestamp"], "purple"));
var cmd = [
["cd", packagePath],
+16 -2
View File
@@ -52,7 +52,9 @@ if (typeof OBJJ_COMPILER_FLAGS !== 'undefined')
var flags = {};
for (var i = 0; i < OBJJ_COMPILER_FLAGS.length; i++)
{
switch (OBJJ_COMPILER_FLAGS[i])
var aFlag = OBJJ_COMPILER_FLAGS[i];
switch (aFlag)
{
case "IncludeDebugSymbols":
flags.includeMethodFunctionNames = true;
@@ -70,9 +72,21 @@ if (typeof OBJJ_COMPILER_FLAGS !== 'undefined')
case "SourceMap":
flags.sourceMap = true;
break;
case "SourceMapIncludeSource":
flags.sourceMapIncludeSource = true;
break;
default:
if (aFlag.indexOf("-D") === 0) {
var macroDefinition = aFlag.substring(2);
(flags.macros || (flags.macros = [])).push(macroDefinition);
}
break;
}
}
FileExecutable.setCurrentCompilerFlags(flags);
StaticResource.setCurrentCompilerFlags(flags);
}
// Turn the main file into a URL.
+5 -2
View File
@@ -286,7 +286,7 @@ DISPLAY_NAME(CFBundle.prototype.isLoaded);
CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
{
if (this._loadStatus !== CFBundleUnloaded)
if (this._loadStatus !== CFBundleUnloaded)
return;
this._loadStatus = CFBundleLoading | CFBundleLoadingInfoPlist;
@@ -635,7 +635,6 @@ function CFBundleHasTestedSpriteSupport()
function CFBundleTestSpriteSupport(/*String*/ MHTMLPath, /*Function*/ aCallback)
{
if (CFBundleHasTestedSpriteSupport())
return;
@@ -829,7 +828,11 @@ function decompileStaticFile(/*Bundle*/ aBundle, /*String*/ aString, /*String*/
}
else if (marker === MARKER_TEXT)
{
file.write(text);
if (text.match(/^@STATIC;/))
file.decompile();
}
}
}
+19
View File
@@ -152,6 +152,25 @@ CFDictionary.prototype.toString = function()
DISPLAY_NAME(CFDictionary.prototype.toString);
CFDictionary.prototype.toJSObject = function()
{
var jsObject = new Object(),
keys = this._keys,
index = 0,
count = this._count;
for (; index < count; ++index)
{
var key = keys[index];
jsObject[key] = this.valueForKey(key);
}
return jsObject;
};
DISPLAY_NAME(CFDictionary.prototype.toJSObject);
GLOBAL(CFMutableDictionary) = function(/*CFDictionary*/ aDictionary)
{
CFDictionary.apply(this, []);
+1 -5
View File
@@ -20,7 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
var OBJECT_COUNT = 0;
GLOBAL(objj_generateObjectUID) = function()
@@ -83,12 +82,9 @@ CFPropertyList.stringFromPropertyList = function(/*CFPropertyList*/ aPropertyLis
}
#ifdef COMMONJS
var fs = require("fs");
CFPropertyList.readPropertyListFromFile = function(/*String*/ aFilePath)
{
return CFPropertyList.propertyListFromString(fs.readFileSync(aFilePath, { encoding: "utf8" }));
//return CFPropertyList.propertyListFromString(FILE.read(aFilePath, { charset:"UTF-8" }));
return CFPropertyList.propertyListFromString(FILE.read(aFilePath, { charset:"UTF-8" }));
}
CFPropertyList.writePropertyListToFile = function(/*CFPropertyList*/ aPropertyList, /*String*/ aFilePath, /*Format*/ aFormat)
+2 -2
View File
@@ -1,3 +1,3 @@
#!/usr/bin/env node
#!/usr/bin/env narwhal
require("@objj/runtime").run(process.argv.slice(1));
require("objective-j").run(system.args);
+12 -12
View File
@@ -129,51 +129,51 @@ exports.run = function(args)
case "-g":
case "--include-debug-symbols":
argv.shift();
var flags = ObjectiveJ.FileExecutable.currentCompilerFlags();
var flags = ObjectiveJ.StaticResource.currentCompilerFlags();
flags.includeMethodFunctionNames = true;
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(flags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(flags);
break;
case "-T":
case "--dont-include-type-signatures":
argv.shift();
var flags = ObjectiveJ.FileExecutable.currentCompilerFlags();
var flags = ObjectiveJ.StaticResource.currentCompilerFlags();
flags.includeIvarTypeSignatures = true;
flags.includeMethodArgumentTypeSignatures = true;
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(flags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(flags);
break;
case "-O2":
case "--inline-msg-send":
argv.shift();
var flags = ObjectiveJ.FileExecutable.currentCompilerFlags();
var flags = ObjectiveJ.StaticResource.currentCompilerFlags();
flags.inlineMsgSendFunctions = true;
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(flags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(flags);
break;
case "-g":
case "--include-debug-symbols":
argv.shift();
var flags = ObjectiveJ.FileExecutable.currentCompilerFlags();
var flags = ObjectiveJ.StaticResource.currentCompilerFlags();
flags.includeMethodFunctionNames = true;
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(flags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(flags);
break;
case "-T":
case "--dont-include-type-signatures":
argv.shift();
var flags = ObjectiveJ.FileExecutable.currentCompilerFlags();
var flags = ObjectiveJ.StaticResource.currentCompilerFlags();
flags.includeIvarTypeSignatures = true;
flags.includeMethodArgumentTypeSignatures = true;
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(flags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(flags);
break;
case "-O2":
case "--inline-msg-send":
argv.shift();
var flags = ObjectiveJ.FileExecutable.currentCompilerFlags();
var flags = ObjectiveJ.StaticResource.currentCompilerFlags();
flags.inlineMsgSendFunctions = true;
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(flags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(flags);
break;
default:
@@ -113,7 +113,7 @@ function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags, asPlainJavasc
}
}
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(objjcFlags);
ObjectiveJ.StaticResource.setCurrentCompilerFlags(objjcFlags);
ObjectiveJ.make_narwhal_factory(absolutePath, basePath, translateFilenameToPath)(require, {}, module, system, print);
executable = new ObjectiveJ.FileExecutable(FILE.basename(aFilePath));
@@ -907,7 +907,7 @@ BundleTask.prototype.defineSourceTasks = function()
basePath = absolutePath.substring(0, absolutePath.length - theTranslatedFilename.length);
// Here we set the current compiler flags so the load system will know what compiler flags to use
ObjectiveJ.FileExecutable.setCurrentGccCompilerFlags(environmentCompilerFlags);
ObjectiveJ.StaticResource.setCurrentGccCompilerFlags(environmentCompilerFlags);
// Here we tell the CFBundle to load frameworks for the current build enviroment and not the enviroment that is running
CFBundle.environments = function() {return [anEnvironment.name(), "ObjJ"]};
ObjectiveJ.make_narwhal_factory(absolutePath, basePath, translateFilenameToPath)(require, e, module, system, print);
+5 -7
View File
@@ -1,9 +1,7 @@
#!/usr/bin/env node
#!/usr/bin/env narwhal
const path = require("path");
var execPath = require("file").path(module.path);
var mainPath = execPath.dirname().dirname().join("lib", execPath.basename(), "main.j");
var commandName = path.basename(process.argv[1]);
var mainPath = path.resolve(__dirname, "..", "lib", commandName, "main.j");
var args = ["objj", mainPath].concat(process.argv.slice(2));
require("@objj/runtime").run(args);
var args = ["objj", String(mainPath)].concat(system.args.slice(1));
require("objective-j").run(args);
+4 -4
View File
@@ -24,10 +24,10 @@ var undefined;
if (typeof window !== "undefined")
{
window.setNativeTimeout = window.setTimeout || setTimeout;
window.clearNativeTimeout = window.clearTimeout || clearTimeout;
window.setNativeInterval = window.setInterval || setInterval;
window.clearNativeInterval = window.clearInterval || clearInterval;
window.setNativeTimeout = window.setTimeout;
window.clearNativeTimeout = window.clearTimeout;
window.setNativeInterval = window.setInterval;
window.clearNativeInterval = window.clearInterval;
}
// Objective-J Constants
+61 -36
View File
@@ -24,8 +24,7 @@
var ExecutableUnloadedFileDependencies = 0,
ExecutableLoadingFileDependencies = 1,
ExecutableLoadedFileDependencies = 2,
ExecutableCantStartLoadYetFileDependencies = 3,
AnonymousExecutableCount = 0;
AnonymousExecutableCount = 0;
function Executable(/*String*/ aCode, /*Array*/ fileDependencies, /*CFURL|String*/ aURL, /*Function*/ aFunction, /*ObjJCompiler*/aCompiler, /*Dictionary*/ aFilenameTranslateDictionary, /* Base64 String */ sourceMap)
{
@@ -44,13 +43,7 @@ function Executable(/*String*/ aCode, /*Array*/ fileDependencies, /*CFURL|String
if (sourceMap)
this._base64EncodedSourceMap = sourceMap;
// This is a little hacky but if fileDependencies is null we can start loading file dependencies yet
if (!fileDependencies)
{
this._fileDependencyStatus = ExecutableCantStartLoadYetFileDependencies;
this._fileDependencyCallbacks = [];
}
else if (fileDependencies.length)
if (fileDependencies.length)
{
this._fileDependencyStatus = ExecutableUnloadedFileDependencies;
this._fileDependencyCallbacks = [];
@@ -188,9 +181,10 @@ Executable.prototype.execute = function()
this.setCode(this._compiler.compilePass2(), this._compiler.map());
if (FileExecutable.printWarningsAndErrors(this._compiler, exports.messageOutputFormatInXML))
if (Executable.printWarningsAndErrors(this._compiler, exports.messageOutputFormatInXML))
throw "Compilation error";
// We don't need to save the AST tree and the source code. It will take up a lot of memory.
this._compiler = null;
}
@@ -314,8 +308,9 @@ Executable.prototype.loadFileDependencies = function(aCallback)
if (status === ExecutableUnloadedFileDependencies)
{
if (fileDependencyLoadCount)
throw "Can't load";
if (fileDependencyLoadCount) {
throw "Can't load: " + this.URL().absoluteURL();
}
loadFileDependenciesForExecutable(this);
}
@@ -323,20 +318,12 @@ Executable.prototype.loadFileDependencies = function(aCallback)
DISPLAY_NAME(Executable.prototype.loadFileDependencies);
Executable.prototype.setExecutableUnloadedFileDependencies = function()
Executable.prototype.hasExecutableUnloadedFileDependencies = function()
{
if (this._fileDependencyStatus === ExecutableCantStartLoadYetFileDependencies)
this._fileDependencyStatus = ExecutableUnloadedFileDependencies;
return this._fileDependencyStatus === ExecutableUnloadedFileDependencies;
}
DISPLAY_NAME(Executable.prototype.setExecutableUnloadedFileDependencies);
Executable.prototype.isExecutableCantStartLoadYetFileDependencies = function()
{
return this._fileDependencyStatus === ExecutableCantStartLoadYetFileDependencies;
}
DISPLAY_NAME(Executable.prototype.setExecutableUnloadedFileDependencies);
DISPLAY_NAME(Executable.prototype.hasExecutableUnloadedFileDependencies);
function loadFileDependenciesForExecutable(/*Executable*/ anExecutable)
{
@@ -442,6 +429,7 @@ DISPLAY_NAME(Executable.prototype.fileExecutableSearcher);
var cachedFileExecuters = { };
// All the file dependences must be loaded and executed before this can be executed.
Executable.fileExecuterForURL = function(/*CFURL|String*/ aURL)
{
var referenceURL = makeAbsoluteURL(aURL),
@@ -490,13 +478,13 @@ Executable.fileImporterForURL = function(/*CFURL|String*/ aURL)
{
aFileExecutable.loadFileDependencies(function()
{
aFileExecutable.execute();
var result = aFileExecutable.execute();
// No more need to cache these.
disableCFURLCaching();
if (aCallback)
aCallback();
aCallback(result);
});
});
}
@@ -512,16 +500,6 @@ DISPLAY_NAME(Executable.fileImporterForURL);
var cachedFileExecutableSearchers = { },
cachedFileExecutableSearchResults = { };
function countProp(x) {
var count = 0;
for (var k in x) {
if (x.hasOwnProperty(k)) {
++count;
}
}
return count;
}
Executable.resetCachedFileExecutableSearchers = function()
{
cachedFileExecutableSearchers = { };
@@ -583,6 +561,53 @@ Executable.fileExecutableSearcherForURL = function(/*CFURL*/ referenceURL)
DISPLAY_NAME(Executable.fileExecutableSearcherForURL);
/*!
This funtion prints all errors and warnings for the provided compiler. It returns true if there
are any errors in the list. it will print it in xml format if printXML is 'true'
*/
Executable.printWarningsAndErrors = function(/*ObjJCompiler*/ compiler, /*BOOL*/ printXML)
{
var warnings = [],
anyErrors = false;
for (var i = 0; i < compiler.warningsAndErrors.length; i++)
{
var warning = compiler.warningsAndErrors[i],
message = compiler.prettifyMessage(warning);
// Set anyErrors to 'true' if there are any errors in the list
anyErrors = anyErrors || warning.messageType === "ERROR";
#ifdef BROWSER
console.log(message);
#else
if (printXML)
{
var dict = new CFMutableDictionary();
if (warning.messageOnLine != null) dict.addValueForKey('line', warning.messageOnLine)
if (warning.path != null) dict.addValueForKey('sourcePath', new CFURL(warning.path).path())
if (message != null) dict.addValueForKey('message', message)
warnings.push(dict);
}
else
{
print(message);
}
#endif
}
#ifndef BROWSER
if (warnings.length && printXML)
try {
print(CFPropertyListCreateXMLData(warnings, kCFPropertyListXMLFormat_v1_0).rawString());
} catch (e) {
print ("XML encode error: " + e);
}
#endif
return anyErrors;
}
/*
* Adaption to javascript by Malte Tancred 2012 from ConvertUTF.[ch] by Unicode, Inc.
* Speed improvements by Martin Carlberg 2016
+7 -294
View File
@@ -22,10 +22,7 @@
var FileExecutablesForURLStrings = { };
var currentCompilerFlags = {};
var currentGccCompilerFlags = "";
function FileExecutable(/*CFURL|String*/ aURL, /*Dictionary*/ aFilenameTranslateDictionary)
function FileExecutable(/*CFURL|String*/ aURL, /*Dictionary*/ aFilenameTranslateDictionary, success)
{
aURL = makeAbsoluteURL(aURL);
@@ -37,25 +34,14 @@ function FileExecutable(/*CFURL|String*/ aURL, /*Dictionary*/ aFilenameTranslate
FileExecutablesForURLStrings[URLString] = this;
var fileContents = StaticResource.resourceAtURL(aURL).contents(),
executable = NULL,
extension = aURL.pathExtension().toLowerCase();
var aResource = StaticResource.resourceAtURL(aURL),
fileContents = aResource.contents(),
executable = NULL;
this._hasExecuted = NO;
if (fileContents.match(/^@STATIC;/))
executable = decompile(fileContents, aURL);
else if ((extension === "j" || !extension) && !fileContents.match(/^{/))
{
var compilerOptions = currentCompilerFlags || {};
this.cachedIncludeFileSearchResultsContent = {};
this.cachedIncludeFileSearchResultsURL = {};
compile(this, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary);
return;
}
else
executable = new Executable(fileContents, [], aURL);
// Use code if resource contains code. If not use the content of the resource
executable = new Executable(fileContents, aResource._fileDependencies || [], aURL, aResource._function, aResource._compiler, aResource._compiler ? aFilenameTranslateDictionary : null, aResource._sourceMap);
Executable.apply(this, [executable.code(), executable.fileDependencies(), aURL, executable._function, executable._compiler, aFilenameTranslateDictionary]);
}
@@ -64,143 +50,6 @@ exports.FileExecutable = FileExecutable;
FileExecutable.prototype = new Executable();
var compile = function(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary)
{
var acornOptions = compilerOptions.acornOptions || (compilerOptions.acornOptions = {ecmaVersion: 2022});
acornOptions.preprocessGetIncludeFile = function(filePath, isQuoted) {
var referenceURL = new CFURL(".", aURL), // Remove the filename from the url
includeURL = new CFURL(filePath);
var cacheUID = (isQuoted && referenceURL || "") + includeURL,
cachedResult = self.cachedIncludeFileSearchResultsContent[cacheUID];
if (!cachedResult) {
var isAbsoluteURL = (includeURL instanceof CFURL) && includeURL.scheme(),
compileWhenCompleted = NO;
function completed(/*StaticResource*/ aStaticResource) {
var includeString = aStaticResource && aStaticResource.contents(),
lastCharacter = includeString && includeString.charCodeAt(includeString.length - 1);
if (includeString == null) throw new Error("Can't load file " + includeURL);
// Add a new line if the last character is not. If the last thing is a '#define' of other preprocess
// token it will not be handled correctly if we don't have a end of line at the end.
if (lastCharacter !== 10 && lastCharacter !== 13 && lastCharacter !== 8232 && lastCharacter !== 8233) {
includeString += '\n';
}
self.cachedIncludeFileSearchResultsContent[cacheUID] = includeString;
self.cachedIncludeFileSearchResultsURL[cacheUID] = aStaticResource.URL();
if (compileWhenCompleted)
compile(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary);
}
if (isQuoted || isAbsoluteURL)
{
if (!isAbsoluteURL)
includeURL = new CFURL(includeURL, new CFURL((aFilenameTranslateDictionary[aURL.lastPathComponent()] || "."), referenceURL));
StaticResource.resolveResourceAtURL(includeURL, NO, completed);
}
else
StaticResource.resolveResourceAtURLSearchingIncludeURLs(includeURL, completed);
// Now we try to get the cached result again. If we get it then the completed function has already
// executed and we can return the include dictionary.
cachedResult = self.cachedIncludeFileSearchResultsContent[cacheUID];
}
if (cachedResult) {
return {include: cachedResult, sourceFile: self.cachedIncludeFileSearchResultsURL[cacheUID]};
} else {
// When the file is not available (resolved) return null to tell the parser to throw an exception to exit
// Also tell the completed function to compile when finished.
compileWhenCompleted = YES
return null;
}
};
var includeFiles = currentCompilerFlags && currentCompilerFlags.includeFiles,
allPreIncludesResolved = true;
acornOptions.preIncludeFiles = [];
if (includeFiles) for (var i = 0, size = includeFiles.length; i < size; i++)
{
var includeFileUrl = makeAbsoluteURL(includeFiles[i]);
try
{
// try to get all pre include files that acorn will parse before the file from 'aURL'
var aResource = StaticResource.resourceAtURL(makeAbsoluteURL(includeFileUrl));
}
catch (e)
{
// Ok, the file is not available (resolved). Resolve all of the files and try again when available.
StaticResource.resolveResourcesAtURLs(includeFiles.map(function(u) {return makeAbsoluteURL(u)}), function() {
compile(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary);
});
allPreIncludesResolved = false;
break;
}
if (aResource)
{
if (aResource.isNotFound()) {
throw new Error("--include file not found " + includeUrl);
}
var includeString = aResource.contents();
var lastCharacter = includeString.charCodeAt(includeString.length - 1);
// Add a new line if the last character is not. If the last thing is a '#define' of other preprocess
// token it will not be handled correctly if we don't have a end of line at the end.
if (lastCharacter !== 10 && lastCharacter !== 13 && lastCharacter !== 8232 && lastCharacter !== 8233)
includeString += '\n';
acornOptions.preIncludeFiles.push({include: includeString, sourceFile: includeFileUrl.toString()});
}
}
if (allPreIncludesResolved)
{
// '(exports.ObjJCompiler || ObjJCompiler)' is a temporary fix so it can work both in the Narwhal (exports.ObjJCompiler) and Node (ObjJCompiler) world
var compiler = (exports.ObjJCompiler || ObjJCompiler).compileFileDependencies(fileContents, aURL, compilerOptions);
var warningsAndErrors = compiler.warningsAndErrors;
// Kind of a hack but if we get a file not found error on a #include the get include function above should have asked for the resource
// so we should be able to just bail out and wait for the the next call to compile when the include file is loaded (resolved)
if (warningsAndErrors && warningsAndErrors.length === 1 && warningsAndErrors[0].message.indexOf("file not found") > -1)
return;
if (FileExecutable.printWarningsAndErrors(compiler, exports.messageOutputFormatInXML))
throw "Compilation error";
var fileDependencies = compiler.dependencies.map(function (aFileDep) {
return new FileDependency(new CFURL(aFileDep.url), aFileDep.isLocal);
});
}
if (self.isExecutableCantStartLoadYetFileDependencies())
{
// Include files that was not loaded has cancelled the compiler so we are already an initialized Executable.
// Just set the status so we can start loading the file dependencies.
self.setFileDependencies(fileDependencies);
self.setExecutableUnloadedFileDependencies();
self.loadFileDependencies();
}
else if (self._fileDependencyStatus == null)
{
// Are we still a FileExecutable. Call 'super' init method to make us a initilized subclass of an Executable.
executable = new Executable(compiler && compiler.jsBuffer ? compiler.jsBuffer.toString() : null, fileDependencies, aURL, null, compiler);
Executable.apply(self, [executable.code(), executable.fileDependencies(), aURL, executable._function, executable._compiler, aFilenameTranslateDictionary]);
}
}
DISPLAY_NAME(compile);
#ifdef COMMONJS
FileExecutable.allFileExecutables = function()
{
@@ -218,7 +67,6 @@ FileExecutable.allFileExecutables = function()
FileExecutable.resetFileExecutables = function()
{
FileExecutablesForURLStrings = { };
FunctionCache = { };
}
FileExecutable.prototype.execute = function(/*BOOL*/ shouldForce)
@@ -228,7 +76,7 @@ FileExecutable.prototype.execute = function(/*BOOL*/ shouldForce)
this._hasExecuted = YES;
Executable.prototype.execute.call(this);
return Executable.prototype.execute.call(this);
}
DISPLAY_NAME(FileExecutable.prototype.execute);
@@ -240,138 +88,3 @@ FileExecutable.prototype.hasExecuted = function()
DISPLAY_NAME(FileExecutable.prototype.hasExecuted);
function decompile(/*String*/ aString, /*CFURL*/ aURL)
{
var stream = new MarkedStream(aString);
/*
if (stream.version !== "1.0")
return;
*/
var marker = NULL,
code = "",
dependencies = [],
sourceMap;
while (marker = stream.getMarker())
{
var text = stream.getString();
if (marker === MARKER_TEXT)
code += text;
else if (marker === MARKER_IMPORT_STD)
dependencies.push(new FileDependency(new CFURL(text), NO));
else if (marker === MARKER_IMPORT_LOCAL)
dependencies.push(new FileDependency(new CFURL(text), YES));
else if (marker === MARKER_SOURCE_MAP)
sourceMap = text;
}
var fn = FileExecutable._lookupCachedFunction(aURL);
if (fn)
return new Executable(code, dependencies, aURL, fn, null, null, sourceMap);
return new Executable(code, dependencies, aURL, null, null, null, sourceMap);
}
var FunctionCache = { };
FileExecutable._cacheFunction = function(/*CFURL|String*/ aURL, /*Function*/ fn)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
FunctionCache[aURL] = fn;
}
FileExecutable._lookupCachedFunction = function(/*CFURL|String*/ aURL)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return FunctionCache[aURL];
}
FileExecutable.setCurrentGccCompilerFlags = function(/*String*/ compilerFlags)
{
if (currentGccCompilerFlags === compilerFlags) return;
currentGccCompilerFlags = compilerFlags;
// '(exports.ObjJCompiler || ObjJCompiler)' is a temporary fix so it can work both in the Narwhal (exports.ObjJCompiler) and Node (ObjJCompiler) world
var objjcFlags = (exports.ObjJCompiler || ObjJCompiler).parseGccCompilerFlags(compilerFlags);
FileExecutable.setCurrentCompilerFlags(objjcFlags);
}
FileExecutable.currentGccCompilerFlags = function(/*String*/ compilerFlags)
{
return currentGccCompilerFlags;
}
FileExecutable.setCurrentCompilerFlags = function(/*JSObject*/ compilerFlags)
{
currentCompilerFlags = compilerFlags;
// Here we set the default flags if they are not included. We do this as the default values
// in the compiler might not be what we want.
if (currentCompilerFlags.transformNamedFunctionDeclarationToAssignment == null)
currentCompilerFlags.transformNamedFunctionDeclarationToAssignment = true;
if (currentCompilerFlags.sourceMap == null)
currentCompilerFlags.sourceMap = false;
if (currentCompilerFlags.inlineMsgSendFunctions == null)
currentCompilerFlags.inlineMsgSendFunctions = false;
}
FileExecutable.currentCompilerFlags = function(/*JSObject*/ compilerFlags)
{
return currentCompilerFlags;
}
/*!
This funtion prints all errors and warnings for the provieded compiler. It returns true if there
are any errors in the list. it will print it in xml format if printXML is 'true'
*/
FileExecutable.printWarningsAndErrors = function(/*ObjJCompiler*/ compiler, /*BOOL*/ printXML)
{
var warnings = [],
anyErrors = false;
for (var i = 0; i < compiler.warningsAndErrors.length; i++)
{
var warning = compiler.warningsAndErrors[i],
message = compiler.prettifyMessage(warning);
// Set anyErrors to 'true' if there are any errors in the list
anyErrors = anyErrors || warning.messageType === "ERROR";
#ifdef BROWSER
console.log(message);
#else
if (printXML)
{
var dict = new CFMutableDictionary();
if (warning.messageOnLine != null) dict.addValueForKey('line', warning.messageOnLine)
if (warning.path != null) dict.addValueForKey('sourcePath', new CFURL(warning.path).path())
if (message != null) dict.addValueForKey('message', message)
warnings.push(dict);
}
else
{
print(message);
}
#endif
}
#ifndef BROWSER
if (warnings.length && printXML)
try {
print(CFPropertyListCreateXMLData(warnings, kCFPropertyListXMLFormat_v1_0).rawString());
} catch (e) {
print ("XML encode error: " + e);
}
#endif
return anyErrors;
}
// Set the compiler flags to empty dictionary so the default values are correct.
FileExecutable.setCurrentCompilerFlags({});
+3 -3
View File
@@ -47,9 +47,9 @@
#include "StaticResource.js"
#include "Preprocessor.js"
#include "source-map.js"
#include "../node_modules/acorn-walk/dist/walk.js"
#include "../node_modules/objj-parser/dist/objj-parser.js"
#include "../node_modules/objj-transpiler/dist/objj-transpiler.cjs"
#include "acorn.js"
#include "acornwalk.js"
#include "ObjJAcornCompiler.js"
#include "FileDependency.js"
#include "Executable.js"
#include "FileExecutable.js"
+44 -43
View File
@@ -27,64 +27,58 @@ require("../common.jake");
// as we are running in an already built Objective-J environment
require("./OldBrowserCompatibility");
/* var FILE = require("file"),
var FILE = require("file"),
OS = require("os"),
stream = require("narwhal/term").stream; */
stream = require("narwhal/term").stream;
var path = require("path");
var fs = require("fs");
var terser = require("terser");
var walk = require("./acornwalk").acorn.walk;
var walk = require("acorn-walk");
acorn = {walk: walk};
acorn = require("objj-parser");
var compiler = require("objj-transpiler");
acorn = require("./acorn").acorn;
const term = ObjectiveJ.term;
const utilsFile = ObjectiveJ.utils.file;
var compiler = require("./ObjJAcornCompiler").ObjJCompiler;
//$BUILD_CONFIGURATION_DIR = "../Build"
$BROWSER_FILE = path.join("Browser", "Objective-J.js");
$BROWSER_FILE = FILE.join("Browser", "Objective-J.js");
$BUILD_OBJECTIVE_J = path.join($BUILD_CONFIGURATION_DIR, "Objective-J");
$BUILD_BROWSER_FILE = path.join($BUILD_OBJECTIVE_J, "Objective-J.js");
$BUILD_OBJECTIVE_J = FILE.join($BUILD_CONFIGURATION_DIR, "Objective-J");
$BUILD_BROWSER_FILE = FILE.join($BUILD_OBJECTIVE_J, "Objective-J.js");
$INCLUDE_FLAGS = ["'-I" + process.cwd() + "'"];
$INCLUDE_FLAGS = ["'-I" + FILE.cwd() + "'"];
$DEBUG_FLAGS = $CONFIGURATION === "Debug" ? ["-DDEBUG=1"] : [""];
$OBJECTIVEJ_FILES = new FileList("*.js");
$BROWSER_FILES = new FileList($BROWSER_FILE).include($OBJECTIVEJ_FILES);
filedir($BUILD_BROWSER_FILE, $BROWSER_FILES, async function(aTask)
filedir($BUILD_BROWSER_FILE, $BROWSER_FILES, function(aTask)
{
gcc($BROWSER_FILE,
$BUILD_BROWSER_FILE,
environmentFlags("Browser", "ObjJ").concat($INCLUDE_FLAGS, $DEBUG_FLAGS, ["-Wno-unused-but-set-variable"]), $CONFIGURATION !== "Debug");
});
$LICENSE = path.join("CommonJS", "lib", "objective-j", "jake", "LICENSES", "LGPL-v2.1");
$BUILD_LICENSE = path.join($BUILD_OBJECTIVE_J, "LICENSE");
$LICENSE = FILE.join("CommonJS", "lib", "objective-j", "jake", "LICENSES", "LGPL-v2.1");
$BUILD_LICENSE = FILE.join($BUILD_OBJECTIVE_J, "LICENSE");
filedir($BUILD_LICENSE, [$LICENSE], function()
{
fs.copyFileSync($LICENSE, $BUILD_LICENSE);
FILE.copy($LICENSE, $BUILD_LICENSE);
});
new FileList("CommonJS/**/*").forEach( async function(aFilename)
new FileList("CommonJS/**/*").forEach(function(aFilename)
{
// . files should be left out of FileList...
if (!fs.lstatSync(aFilename).isFile() || path.basename(aFilename).charAt(0) === ".")
if (!FILE.isFile(aFilename) || FILE.basename(aFilename).charAt(0) === ".")
return;
var buildFilename = path.join($BUILD_CJS_OBJECTIVE_J, path.relative("CommonJS/", aFilename));
var buildFilename = FILE.join($BUILD_CJS_OBJECTIVE_J, FILE.relative("CommonJS/", aFilename));
filedir (buildFilename, new FileList(aFilename).include($OBJECTIVEJ_FILES), function ()
{
if (path.extname(aFilename) !== ".js")
if (FILE.extension(aFilename) !== ".js")
{
term.stream.print("Copying... \0green(" + aFilename +"\0)");
utilsFile.cp(aFilename, buildFilename);
stream.print("Copying... \0green(" + aFilename +"\0)");
cp(aFilename, buildFilename);
}
else
gcc(aFilename,
@@ -93,26 +87,27 @@ new FileList("CommonJS/**/*").forEach( async function(aFilename)
});
// HACK: narwhal should copy permissions
if (path.dirname(aFilename) === path.join("CommonJS", "bin"))
if (FILE.dirname(aFilename) === FILE.join("CommonJS", "bin"))
{
filedir (buildFilename, function ()
{
fs.chmodSync(buildFilename, 0o755);
FILE.chmod(buildFilename, 0755);
});
}
task ("build", buildFilename);
CLOBBER.include(buildFilename);
});
task ("build", function() {
setPackageMetadata(path.join($BUILD_CJS_OBJECTIVE_J, "package.json"));
setPackageMetadata(FILE.join($BUILD_CJS_OBJECTIVE_J, "package.json"));
});
$BUILD_CJS_OBJECTIVE_J_FRAMEWORK = path.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J");
$BUILD_CJS_OBJECTIVE_J_FRAMEWORK = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J");
filedir($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function()
{
utilsFile.cp_r($BUILD_OBJECTIVE_J, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK);
cp_r($BUILD_OBJECTIVE_J, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK);
});
CLOBBER.include($BUILD_OBJECTIVE_J);
@@ -126,20 +121,24 @@ function environmentFlags()
}).concat("-DENVIRONMENTS=" + JSON.stringify(environments));
}
async function compressor(srcCode) {
return (await terser.minify(srcCode)).code;
var SHRINKSAFE = require("minify/shrinksafe");
function compressor(code) {
return SHRINKSAFE.compress(code, { charset : "UTF-8", useServer : true });
}
var headerText = fs.readFileSync("header.txt", { encoding: "utf8" });
async function gcc(inputFilePath, outputFilePath, flags, compress)
var headerText = FILE.read("header.txt", { charset : "UTF-8" });
function gcc(inputFilePath, outputFilePath, flags, compress)
{
term.stream.print("Building... \0green(" + outputFilePath +"\0)");
var source = fs.readFileSync(inputFilePath, { charset : "utf8" }).toString();
stream.print("Building... \0green(" + outputFilePath +"\0)");
var source = FILE.read(inputFilePath, { charset : "UTF-8" });
var compilerOptions = compiler.parseGccCompilerFlags(flags.join(" "));
var acornOptions = compilerOptions.acornOptions || (compilerOptions.acornOptions = {ecmaVersion: 2022});
var acornOptions = compilerOptions.acornOptions || (compilerOptions.acornOptions = {});
acornOptions.preprocessGetIncludeFile = function(filePath, isQuoted) {
var includeContent = fs.readFileSync(filePath, { charset : "utf8" }).toString();
var includeContent = FILE.read(filePath, { charset : "UTF-8" });
//print ("Include content for file '" + filePath + "': " + includeContent);
//print ("Include file '" + filePath + "'");
return {include: includeContent, sourceFile: filePath};
}
@@ -154,16 +153,18 @@ async function gcc(inputFilePath, outputFilePath, flags, compress)
// Set anyErrors to 'true' if there are any errors in the list
anyErrors = anyErrors || warning.messageType === "ERROR";
console.log(message);
print(message);
}
if (anyErrors) throw "Compilation Error";
var code = c.code();
var contents = headerText + code;
if (path.extname(inputFilePath) === ".js" && compress) {
contents = await compressor(contents);
}
fs.writeFileSync(outputFilePath, contents, { encoding : "utf8" });
if (FILE.extension(inputFilePath) === ".js" && compress)
contents = compressor(contents);
FILE.write(outputFilePath, contents, { charset : "UTF-8" });
}
task("build", [$BUILD_BROWSER_FILE, $BUILD_LICENSE, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK]);
File diff suppressed because it is too large Load Diff
+31
View File
@@ -280,3 +280,34 @@ if (!Array.prototype.find) {
writable: true
});
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
if (typeof Object.assign !== 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) { // .length of function is 2
'use strict';
if (target === null || target === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource !== null && nextSource !== undefined) {
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
+1 -1
View File
@@ -81,7 +81,7 @@ GLOBAL(objj_class) = function(displayName)
#if DEBUG
// Naming the allocator allows the WebKit heap snapshot tool to display object class names correctly
// HACK: displayName property is not respected so we must eval a function to name it
eval("this.allocator = function " + (displayName ? displayName.replace(/^0|\W/g, "_") : "OBJJ_OBJECT") + "() { }");
eval("this.allocator = function " + (displayName || "OBJJ_OBJECT").replace(/\W/g, "_") + "() { }");
#else
this.allocator = function() { };
#endif
+287 -19
View File
@@ -1,6 +1,9 @@
var rootResources = { };
var currentCompilerFlags = {};
var currentGccCompilerFlags = "";
function StaticResource(/*CFURL*/ aURL, /*StaticResource*/ aParent, /*BOOL*/ isDirectory, /*BOOL*/ isResolved, /*Dictionary*/ aFilenameTranslateDictionary)
{
this._parent = aParent;
@@ -37,19 +40,10 @@ StaticResource.rootResources = function()
return rootResources;
};
function countProp(x) {
var count = 0;
for (var k in x) {
if (x.hasOwnProperty(k)) {
++count;
}
}
return count;
}
StaticResource.resetRootResources = function()
{
rootResources = {};
FunctionCache = {};
};
StaticResource.prototype.filenameTranslateDictionary = function()
@@ -69,7 +63,7 @@ function resolveStaticResource(/*StaticResource*/ aResource)
});
}
StaticResource.prototype.resolve = function()
StaticResource.prototype.resolve = function(/*BOOL*/ dontCompile, /*Array*/ compileIncludeFileArray)
{
if (this.isDirectory())
{
@@ -87,8 +81,41 @@ StaticResource.prototype.resolve = function()
function onsuccess(/*anEvent*/ anEvent)
{
self._contents = anEvent.request.responseText();
resolveStaticResource(self);
var fileContents = anEvent.request.responseText(),
aURL = self.URL(),
extension = aURL.pathExtension().toLowerCase();
self._contents = fileContents;
if (fileContents.match(/^@STATIC;/))
{
self.decompile();
resolveStaticResource(self);
}
else if (!dontCompile && (extension === "j" || !extension) && !fileContents.match(/^{/))
{
// Copy compiler options as this can be recursive and/or asynchronous.
// Specially acornOptions.preprocessGetIncludeFile that has a variable 'self' that needs to be referencing the resource.
var compilerOptions = Object.assign({}, currentCompilerFlags || {}),
acornOptions = compilerOptions.acornOptions;
if (acornOptions)
compilerOptions.acornOptions = Object.asign({}, acornOptions);
// If no include files are set use the include files from the bundle, if any.
if (!compilerOptions.includeFiles)
compilerOptions.includeFiles = compileIncludeFileArray;
self.cachedIncludeFileSearchResultsContent = {};
self.cachedIncludeFileSearchResultsURL = {};
compile(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary, function(aResource) {
resolveStaticResource(aResource);
});
}
else
{
resolveStaticResource(self);
}
}
function onfailure()
@@ -114,6 +141,221 @@ StaticResource.prototype.resolve = function()
}
};
var compile = function(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary, success)
{
var acornOptions = compilerOptions.acornOptions || (compilerOptions.acornOptions = {});
acornOptions.preprocessGetIncludeFile = function(filePath, isQuoted) {
var referenceURL = new CFURL(".", aURL), // Remove the filename from the url
includeURL = new CFURL(filePath);
var cacheUID = (isQuoted && referenceURL || "") + includeURL,
cachedResult = self.cachedIncludeFileSearchResultsContent[cacheUID];
if (!cachedResult) {
var isAbsoluteURL = (includeURL instanceof CFURL) && includeURL.scheme(),
compileWhenCompleted = NO;
function completed(/*StaticResource*/ aStaticResource) {
var includeString = aStaticResource && aStaticResource.contents(),
lastCharacter = includeString && includeString.charCodeAt(includeString.length - 1);
if (includeString == null) throw new Error("Can't load file " + includeURL);
// Add a new line if the last character is not. If the last thing is a '#define' of other preprocess
// token it will not be handled correctly if we don't have a end of line at the end.
if (lastCharacter !== 10 && lastCharacter !== 13 && lastCharacter !== 8232 && lastCharacter !== 8233) {
includeString += '\n';
}
self.cachedIncludeFileSearchResultsContent[cacheUID] = includeString;
self.cachedIncludeFileSearchResultsURL[cacheUID] = aStaticResource.URL();
if (compileWhenCompleted)
compile(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary, success);
}
if (isQuoted || isAbsoluteURL)
{
var translateDictionary;
if (!isAbsoluteURL) {
includeURL = new CFURL(includeURL, new CFURL(((aFilenameTranslateDictionary && aFilenameTranslateDictionary[aURL.lastPathComponent()]) || "."), referenceURL));
}
StaticResource.resolveResourceAtURL(includeURL, NO, completed, null, true); // true = don't compile any loaded resource
}
else
StaticResource.resolveResourceAtURLSearchingIncludeURLs(includeURL, completed);
// Now we try to get the cached result again. If we get it then the completed function has already
// executed and we can return the include dictionary.
cachedResult = self.cachedIncludeFileSearchResultsContent[cacheUID];
}
if (cachedResult) {
return {include: cachedResult, sourceFile: self.cachedIncludeFileSearchResultsURL[cacheUID]};
} else {
// When the file is not available (resolved) return null to tell the parser to throw an exception to exit
// Also tell the completed function to compile when finished as it has not yet done so.
// If fetching the resources are synchronous the result will be found above and the completion function
// should not compile again.
compileWhenCompleted = YES;
return null;
}
};
var includeFiles = compilerOptions && compilerOptions.includeFiles,
allPreIncludesResolved = true;
acornOptions.preIncludeFiles = [];
if (includeFiles) for (var i = 0, size = includeFiles.length; i < size; i++)
{
var includeFileUrl = makeAbsoluteURL(includeFiles[i]);
try
{
// try to get all pre include files that acorn will parse before the file from 'aURL'
var aResource = StaticResource.resourceAtURL(makeAbsoluteURL(includeFileUrl));
}
catch (e)
{
// Ok, the file is not available (resolved). Resolve all of the files and try again when available.
StaticResource.resolveResourcesAtURLs(includeFiles.map(function(u) {return makeAbsoluteURL(u)}), function() {
compile(self, fileContents, aURL, compilerOptions, aFilenameTranslateDictionary, success);
});
// Now we need to bail out as the compile completion function has already been
// called (synchronous) or will be called in the future (asynchronous)
return;
}
if (aResource)
{
if (aResource.isNotFound()) {
throw new Error("--include file not found " + includeUrl);
}
var includeString = aResource.contents();
var lastCharacter = includeString.charCodeAt(includeString.length - 1);
// Add a new line if the last character is not. If the last thing is a '#define' of other preprocess
// token it will not be handled correctly if we don't have a end of line at the end.
if (lastCharacter !== 10 && lastCharacter !== 13 && lastCharacter !== 8232 && lastCharacter !== 8233)
includeString += '\n';
acornOptions.preIncludeFiles.push({include: includeString, sourceFile: includeFileUrl.toString()});
}
}
// '(exports.ObjJCompiler || ObjJCompiler)' is a temporary fix so it can work both in the Narwhal (exports.ObjJCompiler) and Node (ObjJCompiler) world
var compiler = (exports.ObjJCompiler || ObjJCompiler).compileFileDependencies(fileContents, aURL, compilerOptions);
var warningsAndErrors = compiler.warningsAndErrors;
// Kind of a hack but if we get a file not found error on a #include the get include function above should have asked for the resource
// so we should be able to just bail out and wait for the the next call to compile when the include file is loaded (resolved)
if (warningsAndErrors && warningsAndErrors.length === 1 && warningsAndErrors[0].message.indexOf("file not found") > -1)
return;
if (Executable.printWarningsAndErrors(compiler, exports.messageOutputFormatInXML)) {
throw "Compilation error";
}
var fileDependencies = compiler.dependencies.map(function (aFileDep) {
return new FileDependency(new CFURL(aFileDep.url), aFileDep.isLocal);
});
self._fileDependencies = fileDependencies;
self._compiler = compiler;
success(self);
}
StaticResource.prototype.decompile = function()
{
var content = this.contents(),
aURL = this.URL(),
stream = new MarkedStream(content);
/*
if (stream.version !== "1.0")
return;
*/
var marker = NULL,
code = "",
dependencies = [],
sourceMap;
while (marker = stream.getMarker())
{
var text = stream.getString();
if (marker === MARKER_TEXT)
code += text;
else if (marker === MARKER_IMPORT_STD)
dependencies.push(new FileDependency(new CFURL(text), NO));
else if (marker === MARKER_IMPORT_LOCAL)
dependencies.push(new FileDependency(new CFURL(text), YES));
else if (marker === MARKER_SOURCE_MAP)
sourceMap = text;
}
this._fileDependencies = dependencies;
this._function = StaticResource._lookupCachedFunction(aURL);
this._sourceMap = sourceMap;
this._contents = code;
}
StaticResource.setCurrentGccCompilerFlags = function(/*String*/ compilerFlags)
{
if (currentGccCompilerFlags === compilerFlags) return;
currentGccCompilerFlags = compilerFlags;
// '(exports.ObjJCompiler || ObjJCompiler)' is a temporary fix so it can work both in the Narwhal (exports.ObjJCompiler) and Node (ObjJCompiler) world
var objjcFlags = (exports.ObjJCompiler || ObjJCompiler).parseGccCompilerFlags(compilerFlags);
StaticResource.setCurrentCompilerFlags(objjcFlags);
}
StaticResource.currentGccCompilerFlags = function(/*String*/ compilerFlags)
{
return currentGccCompilerFlags;
}
StaticResource.setCurrentCompilerFlags = function(/*JSObject*/ compilerFlags)
{
currentCompilerFlags = compilerFlags;
// Here we set the default flags if they are not included. We do this as the default values
// in the compiler might not be what we want.
if (currentCompilerFlags.transformNamedFunctionDeclarationToAssignment == null)
currentCompilerFlags.transformNamedFunctionDeclarationToAssignment = true;
if (currentCompilerFlags.sourceMap == null)
currentCompilerFlags.sourceMap = false;
if (currentCompilerFlags.inlineMsgSendFunctions == null)
currentCompilerFlags.inlineMsgSendFunctions = false;
}
StaticResource.currentCompilerFlags = function(/*JSObject*/ compilerFlags)
{
return currentCompilerFlags;
}
var FunctionCache = { };
StaticResource._cacheFunction = function(/*CFURL|String*/ aURL, /*Function*/ fn)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
FunctionCache[aURL] = fn;
}
StaticResource._lookupCachedFunction = function(/*CFURL|String*/ aURL)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return FunctionCache[aURL];
}
StaticResource.prototype.name = function()
{
return this._name;
@@ -218,11 +460,11 @@ StaticResource.resolveResourcesAtURLs = function(/*Array of CFURL|String*/ URLs,
}
}
StaticResource.resolveResourceAtURL = function(/*CFURL|String*/ aURL, /*BOOL*/ isDirectory, /*Function*/ aCallback, /*Dictionary*/ aFilenameTranslateDictionary)
StaticResource.resolveResourceAtURL = function(/*CFURL|String*/ aURL, /*BOOL*/ isDirectory, /*Function*/ aCallback, /*Dictionary*/ aFilenameTranslateDictionary, /*BOOL*/ dontCompile)
{
aURL = makeAbsoluteURL(aURL).absoluteURL();
resolveResourceComponents(rootResourceForAbsoluteURL(aURL), isDirectory, aURL.pathComponents(), 0, aCallback, aFilenameTranslateDictionary);
resolveResourceComponents(rootResourceForAbsoluteURL(aURL), isDirectory, aURL.pathComponents(), 0, aCallback, aFilenameTranslateDictionary, null, dontCompile);
};
StaticResource.prototype.resolveResourceAtURL = function(/*CFURL|String*/ aURL, /*BOOL*/ isDirectory, /*Function*/ aCallback)
@@ -230,7 +472,7 @@ StaticResource.prototype.resolveResourceAtURL = function(/*CFURL|String*/ aURL,
StaticResource.resolveResourceAtURL(new CFURL(aURL, this.URL()).absoluteURL(), isDirectory, aCallback);
};
function resolveResourceComponents(/*StaticResource*/ aResource, /*BOOL*/ isDirectory, /*Array*/ components, /*Integer*/ index, /*Function*/ aCallback, /*Dictionry*/ aFilenameTranslateDictionary)
function resolveResourceComponents(/*StaticResource*/ aResource, /*BOOL*/ isDirectory, /*Array*/ components, /*Integer*/ index, /*Function*/ aCallback, /*Dictionary*/ aFilenameTranslateDictionary, /*Array*/ compileIncludeFileArray, /*BOOL*/ dontCompile)
{
var count = components.length;
@@ -242,8 +484,31 @@ function resolveResourceComponents(/*StaticResource*/ aResource, /*BOOL*/ isDire
// If the child doesn't exist, create and resolve it.
if (!child)
{
child = new StaticResource(new CFURL(name, aResource.URL()), aResource, index + 1 < count || isDirectory , NO, aFilenameTranslateDictionary);
child.resolve();
var translationDictionary = nil;
if (aFilenameTranslateDictionary == null) {
var bundle = new CFBundle(aResource.URL());
if (bundle != null) {
var bundleTranslationDictionary = bundle.valueForInfoDictionaryKey("CPFileTranslationDictionary");
if (bundleTranslationDictionary != null) {
translationDictionary = bundleTranslationDictionary.toJSObject();
}
var bundleIncludeFileArray = bundle.valueForInfoDictionaryKey("CPCompileIncludeFileArray");
if (bundleIncludeFileArray != null) {
compileIncludeFileArray = bundleIncludeFileArray.map(function(includeFilePath) {
return new CFURL(includeFilePath, aResource.URL());
});
}
}
}
var u = new CFURL(name, aResource.URL());
child = new StaticResource(u, aResource, index + 1 < count || isDirectory , NO, translationDictionary || aFilenameTranslateDictionary);
child.resolve(dontCompile, compileIncludeFileArray);
}
// If this resource is still being resolved, just wait and rerun this same method when it's ready.
@@ -251,7 +516,7 @@ function resolveResourceComponents(/*StaticResource*/ aResource, /*BOOL*/ isDire
return child.addEventListener("resolve", function()
{
// Continue resolving once this is done.
resolveResourceComponents(aResource, isDirectory, components, index, aCallback, aFilenameTranslateDictionary);
resolveResourceComponents(aResource, isDirectory, components, index, aCallback, aFilenameTranslateDictionary, compileIncludeFileArray, dontCompile);
});
// If we've already determined that this file doesn't exist...
@@ -364,3 +629,6 @@ StaticResource.includeURLs = function()
return includeURLs;
};
// Set the compiler flags to empty dictionary so the default values are correct.
StaticResource.setCurrentCompilerFlags({});
+3885
View File
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
Copyright (c) <year> <copyright holders>
Copyright (C) 2012 by Marijn Haverbeke <marijnh@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,8 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
Please note that some subdirectories of the CodeMirror distribution
include their own LICENSE files, and are released under different
licences.
+285
View File
@@ -0,0 +1,285 @@
// AST walker module for Mozilla Parser API compatible trees
if (!exports.acorn) {
exports.acorn = {};
exports.acorn.walk = {};
}
(function(exports) {
"use strict";
// A simple walk is one where you simply specify callbacks to be
// called on specific nodes. The last two arguments are optional. A
// simple use would be
//
// walk.simple(myTree, {
// Expression: function(node) { ... }
// });
//
// to do something with all expressions. All Parser API node types
// can be used to identify node types, as well as Expression,
// Statement, and ScopeBody, which denote categories of nodes.
//
// The base argument can be used to pass a custom (recursive)
// walker, and state can be used to give this walked an initial
// state.
exports.simple = function(node, visitors, base, state) {
if (!base) base = exports;
function c(node, st, override) {
var type = override || node.type, found = visitors[type];
if (found) found(node, st);
base[type](node, st, c);
}
c(node, state);
};
// A recursive walk is one where your functions override the default
// walkers. They can modify and replace the state parameter that's
// threaded through the walk, and can opt how and whether to walk
// their child nodes (by calling their third argument on these
// nodes).
exports.recursive = function(node, state, funcs, base) {
var visitor = exports.make(funcs, base);
function c(node, st, override) {
return visitor[override || node.type](node, st, c);
}
return c(node, state);
};
// Used to create a custom walker. Will fill in all missing node
// type properties with the defaults.
exports.make = function(funcs, base) {
if (!base) base = exports;
var visitor = {};
for (var type in base) visitor[type] = base[type];
for (var type in funcs) visitor[type] = funcs[type];
return visitor;
};
function skipThrough(node, st, c) { c(node, st); }
function ignore(node, st, c) {}
// Node walkers.
exports.Program = exports.BlockStatement = function(node, st, c) {
for (var i = 0; i < node.body.length; ++i) {
c(node.body[i], st, "Statement");
}
};
exports.Statement = skipThrough;
exports.EmptyStatement = ignore;
exports.ExpressionStatement = function(node, st, c) {
c(node.expression, st, "Expression");
};
exports.IfStatement = function(node, st, c) {
c(node.test, st, "Expression");
c(node.consequent, st, "Statement");
if (node.alternate) c(node.alternate, st, "Statement");
};
exports.LabeledStatement = function(node, st, c) {
c(node.body, st, "Statement");
};
exports.BreakStatement = exports.ContinueStatement = ignore;
exports.WithStatement = function(node, st, c) {
c(node.object, st, "Expression");
c(node.body, st, "Statement");
};
exports.SwitchStatement = function(node, st, c) {
c(node.discriminant, st, "Expression");
for (var i = 0; i < node.cases.length; ++i) {
var cs = node.cases[i];
if (cs.test) c(cs.test, st, "Expression");
for (var j = 0; j < cs.consequent.length; ++j)
c(cs.consequent[j], st, "Statement");
}
};
exports.ReturnStatement = function(node, st, c) {
if (node.argument) c(node.argument, st, "Expression");
};
exports.ThrowStatement = function(node, st, c) {
c(node.argument, st, "Expression");
};
exports.TryStatement = function(node, st, c) {
c(node.block, st, "Statement");
if (node.handler) c(node.handler.body, st, "ScopeBody");
if (node.finalizer) c(node.finalizer, st, "Statement");
};
exports.WhileStatement = function(node, st, c) {
c(node.test, st, "Expression");
c(node.body, st, "Statement");
};
exports.DoWhileStatement = function(node, st, c) {
c(node.body, st, "Statement");
c(node.test, st, "Expression");
};
exports.ForStatement = function(node, st, c) {
if (node.init) c(node.init, st, "ForInit");
if (node.test) c(node.test, st, "Expression");
if (node.update) c(node.update, st, "Expression");
c(node.body, st, "Statement");
};
exports.ForInStatement = function(node, st, c) {
c(node.left, st, "ForInit");
c(node.right, st, "Expression");
c(node.body, st, "Statement");
};
exports.ForInit = function(node, st, c) {
if (node.type == "VariableDeclaration") c(node, st);
else c(node, st, "Expression");
};
exports.DebuggerStatement = ignore;
exports.FunctionDeclaration = function(node, st, c) {
c(node, st, "Function");
};
exports.VariableDeclaration = function(node, st, c) {
for (var i = 0; i < node.declarations.length; ++i) {
var decl = node.declarations[i];
if (decl.init) c(decl.init, st, "Expression");
}
};
exports.Function = function(node, st, c) {
c(node.body, st, "ScopeBody");
};
exports.ScopeBody = function(node, st, c) {
c(node, st, "Statement");
};
exports.Expression = skipThrough;
exports.ThisExpression = ignore;
exports.ArrayExpression = exports.ArrayLiteral = function(node, st, c) {
for (var i = 0; i < node.elements.length; ++i) {
var elt = node.elements[i];
if (elt) c(elt, st, "Expression");
}
};
exports.DictionaryLiteral = function(node, st, c) {
for (var i = 0; i < node.keys.length; i++) {
var key = node.keys[i];
c(key, st, "Expression");
var value = node.values[i];
c(value, st, "Expression");
}
};
exports.ObjectExpression = function(node, st, c) {
for (var i = 0; i < node.properties.length; ++i)
c(node.properties[i].value, st, "Expression");
};
exports.FunctionExpression = exports.FunctionDeclaration;
exports.SequenceExpression = function(node, st, c) {
for (var i = 0; i < node.expressions.length; ++i)
c(node.expressions[i], st, "Expression");
};
exports.UnaryExpression = exports.UpdateExpression = function(node, st, c) {
c(node.argument, st, "Expression");
};
exports.BinaryExpression = exports.AssignmentExpression = exports.LogicalExpression = function(node, st, c) {
c(node.left, st, "Expression");
c(node.right, st, "Expression");
};
exports.ConditionalExpression = function(node, st, c) {
c(node.test, st, "Expression");
c(node.consequent, st, "Expression");
c(node.alternate, st, "Expression");
};
exports.NewExpression = exports.CallExpression = function(node, st, c) {
c(node.callee, st, "Expression");
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i)
c(node.arguments[i], st, "Expression");
};
exports.MemberExpression = function(node, st, c) {
c(node.object, st, "Expression");
if (node.computed) c(node.property, st, "Expression");
};
exports.Identifier = exports.Literal = ignore;
exports.ClassDeclarationStatement = function(node, st, c) {
if (node.ivardeclarations) for (var i = 0; i < node.ivardeclarations.length; ++i) {
c(node.ivardeclarations[i], st, "IvarDeclaration");
}
for (var i = 0; i < node.body.length; ++i) {
c(node.body[i], st, "Statement");
}
}
exports.ImportStatement = ignore;
exports.IvarDeclaration = ignore;
exports.PreprocessStatement = ignore;
exports.ClassStatement = ignore;
exports.GlobalStatement = ignore;
exports.ProtocolDeclarationStatement = function(node, st, c) {
if (node.required) for (var i = 0; i < node.required.length; ++i) {
c(node.required[i], st, "Statement");
}
if (node.optional) for (var i = 0; i < node.optional.length; ++i) {
c(node.optional[i], st, "Statement");
}
}
exports.TypeDefStatement = ignore;
exports.MethodDeclarationStatement = function(node, st, c) {
var body = node.body;
if (body)
c(body, st, "Statement");
}
exports.MessageSendExpression = function(node, st, c) {
if (!node.superObject) c(node.object, st, "Expression");
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i)
c(node.arguments[i], st, "Expression");
if (node.parameters) for (var i = 0; i < node.parameters.length; ++i)
c(node.parameters[i], st, "Expression");
}
exports.SelectorLiteralExpression = ignore;
exports.ProtocolLiteralExpression = ignore;
exports.Reference = function(node, st, c) {
c(node.element, st, "Identifier");
}
exports.Dereference = function(node, st, c) {
c(node.expr, st, "Expression");
}
// A custom walker that keeps track of the scope chain and the
// variables defined in it.
function makeScope(prev) {
return {vars: Object.create(null), prev: prev};
}
exports.scopeVisitor = exports.make({
Function: function(node, scope, c) {
var inner = makeScope(scope);
for (var i = 0; i < node.params.length; ++i)
inner.vars[node.params[i].name] = {type: "argument", node: node.params[i]};
if (node.id) {
var decl = node.type == "FunctionDeclaration";
(decl ? scope : inner).vars[node.id.name] =
{type: decl ? "function" : "function name", node: node.id};
}
c(node.body, inner, "ScopeBody");
},
TryStatement: function(node, scope, c) {
c(node.block, scope, "Statement");
if (node.handler) {
var inner = makeScope(scope);
inner.vars[node.handler.param.name] = {type: "catch clause", node: node.handler.param};
c(node.handler.body, inner, "ScopeBody");
}
if (node.finalizer) c(node.finalizer, scope, "Statement");
},
VariableDeclaration: function(node, scope, c) {
for (var i = 0; i < node.declarations.length; ++i) {
var decl = node.declarations[i];
scope.vars[decl.id.name] = {type: "var", node: decl.id};
if (decl.init) c(decl.init, scope, "Expression");
}
}
});
})(typeof exports == "undefined" ? acorn.walk = {} : exports.acorn.walk);
+30 -159
View File
@@ -1,180 +1,51 @@
[![build](https://github.com/cappuccino/cappuccino/actions/workflows/BuildAndTest.yml/badge.svg)](https://github.com/cappuccino/cappuccino/actions/workflows/BuildAndTest.yml)
[![Join the chat at https://gitter.im/cappuccino/cappuccino](https://badges.gitter.im/cappuccino/cappuccino.svg)](
https://gitter.im/cappuccino/cappuccino?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/cappuccino/cappuccino.svg?branch=master)](https://travis-ci.org/cappuccino/cappuccino)
[![Node build status](https://github.com/cappuccino/cappuccino/actions/workflows/BuildAndTest.yml/badge.svg?branch=node)](https://github.com/cappuccino/cappuccino/actions/workflows/BuildAndTest.yml)
[![Join the chat at https://gitter.im/cappuccino/cappuccino](https://badges.gitter.im/cappuccino/cappuccino.svg)](https://gitter.im/cappuccino/cappuccino?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Welcome to Cappuccino!
Welcome to Cappuccino!
======================
Cappuccino, a open-source web application framework in Objective-J (*a superset of JavaScript which is transpiled for deployment but can also run in the browser directly*), enhances app development by faithfully implementing the NeXTSTEP/Apple Cocoa® APIs for browsers as web browser restrictions permit. Leveraging this well-established architecture, Cappuccino facilitates scalable application development for those usage cases requiring developer productivity, reliability and sophisticated interaction support. Resulting applications are served from any web server and deployed to any modern web browser - without plugins or extensions of any kind. Cappuccino has been developed continuously since 2008 and is licensed under the LGPL version 2.
Introduction
------------
Cappuccino is an open source framework that makes it easy to build
desktop-caliber applications that run in a web browser.
### Benefits of Cappuccino for Application Development:
* Developer productivity a rich palette of interface controls and robust event managment APIs go well beyond the functionality provided by current browser standards, allowing rich applications to quickly be built up using high-level constructs that are designed to work well together.
* Consistency predictable behavior across different platforms with desktop-class usability and user experience.
* Stability use of time-tested APIs means an absense of the churn which is all too common in the browser-app ecosystem found elsewhere.
* Cross-platform development any programmer's text editor or IDE is sufficient. The compiler and other parts of the toolchain (used to prepare applications for deployment) are hosted by Node.js.
* Extensibility custom interface controls can reliably build on framework-included controls, when extended or new functionality is required.
* Objective-J's [message-passing architecture](https://en.wikipedia.org/wiki/Message_passing), which the Cappuccino APIs leverage, promotes loose coupling of an app's component functionality — making large scale development more managable.
* Comprehensive documentation for Objective-J is supplemented by over two decades of resources for Objective-C and Cocoa®. Additionally, a large public catalog of native Objective-C applications offers valuable guidance for development. Translation of such sample code to Objective-J is often trivial (see below).
With Cappuccino, you don't concern yourself with HTML, CSS, or the DOM. You write applications with the APIs from Apple's Cocoa frameworks and the Objective-J language.
Check out a [live demo of the standard interface controls provided by Cappuccino](https://cappuccino-testbook.5apps.com/#ThemeKitchenSink)
Check out a [live demo of the widgets in Cappuccino](https://cappuccino-testbook.5apps.com/#ThemeKitchenSink)
Check out some [tutorials](https://cappuccino-cookbook.5apps.com)
For more information, see the
- [Official website](http://cappuccino.dev)
- [Gitter](https://gitter.im/cappuccino/cappuccino)
- [Official website](http://cappuccino-project.org)
- [Github Wiki](https://github.com/cappuccino/cappuccino/wiki)
- [FAQ](http://cappuccino.dev/support/faq.html)
- [Documentation](http://cappuccino.dev/learn/)
- [Mailing list (inactive for historical purposes only)](http://groups.google.com/group/objectivej)
- [FAQ](http://cappuccino-project.org/support/faq.html)
- [Documentation](http://cappuccino-project.org/learn/)
- [Mailing list](http://groups.google.com/group/objectivej)
- [Gitter](https://gitter.im/cappuccino/cappuccino)
Bugs and enhancement requrests can be reported by [creating a Github issue](http://github.com/cappuccino/cappuccino/issues).
Follow [@cappuccino](https://twitter.com/cappuccino) on Twitter for updates on the project.
## System Requirements
If you discover any bugs, please [file a ticket](http://github.com/cappuccino/cappuccino/issues).
* Any modern web browser can run Cappuccino applications.
* Any web server can serve Cappuccino applications.
* Any programmer's editor can be used for coding.
* macOS users can use Xcode - which leverages the visual development tools from Apple for creation of complex applications with minimal coding.
System Requirements
-------------------
To run Cappuccino applications, all you need is a HTML5 compliant web browser.
## Installation instructions
To try Cappuccino:
You can develop Cappuccino applications with only a simple text editor on any platform.
1. Install Node.js and npm from the [Node.js website](https://nodejs.org/download/) or the OS-specific package manager of your choice. Long-term Support (LTS) versions are tested although others will probably work as intended.
2. Run `npm set prefix ~/.npm`. This will set the default install location for npm to `~/.npm`. The reasoning behind
this is outlined in the section about permission issues below.
If you are on a Mac, our integration with Xcode leverages the world-class visual development tools from Apple to create complex applications with minimal coding.
3. Add this line to your `.zshrc` or equivalent config file.
```bash
export PATH="~/.npm/bin:$PATH"
```
Getting Started
---------------
To write you first application, [download the starter package](http://cappuccino.dev/#download).
4. Restart your shell.
To try our new Node (alpha) version of the Cappuccino framework, [check the Node installation instructions](https://github.com/cappuccino/cappuccino/wiki/node)
5. Run `npm install -g @objj/cappuccino`.
6. Done! See below for basic usage.
### Basic usage
On successful installation, follow these steps to create a basic and fully-functional Cappuccino application:
1. `capp gen HelloWorld`
2. `cd HelloWorld`
3. `python3 -m http.server` (any local http server can be used)
4. Open [http://localhost:8000](http://localhost:8000) (any modern browser can be used)
### Technical notes
Cappuccino compiles source code files written in Objective-J to pure Javascript but can also run Objective-J directly in the browser. Pure Javascript code can be intermixed with Objective-J, just as Objective-C allows pure C code. This is because each language is a strict superset of its base language.
For app compilation and running other toolchain components in preparation for deployment to production, a desktop Javascript engine supporting CommonJS for accessing local resources is required.
Historically, this engine was [Narwhal](https://narwhaljs.org/).
A transition to [Node.js](https://nodejs.org) is being finalized.
The results of this transition are available as a **Release Candidate**.
While an official production release is scheduled for early-autumn 2024, it should be considered production-ready as-is. Multiple production deployments over the last twelve months have confirmed this.
In addition to the Node.js-based toolchain, the next formal release will include both maintenance improvements and enhancements to the API.
### Permisson issues
By default npm uses `/usr/local/lib/node_modules` as the install location for globally installed packages. This causes
problems since users typically lack write permissions there. It is therefore recommended to either use a version
manager, or change npm's default install location manually (which is what we did above with the `npm set prefix…` command). For more details see [this article](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
### Building Cappuccino from source
To build Cappuccino from source (for the latest version, including un-released changes) clone the GitHub repository at
https://github.com/cappuccino/cappuccino/ and checkout the `main` branch. Use the command
`jake install` to install the Cappuccino frameworks and toolchain locally.
To build from source, do:
1. `git clone https://github.com/cappuccino/cappuccino.git`
2. `cd cappuccino`
3. `npm install`. Cappuccino source currently uses the release distribution from npm to bootstrap the toolchain.
4. Make sure the environment variable `CAPP_BUILD` is set. This is done by adding the line
```bash
export CAPP_BUILD="/path/to/cappuccino/build/directory"
```
to your `.zshrc` or equivalent config file and of course changing the path to where you want to build Cappuccino.
5. Run `jake build` to build Cappuccino.
6. Run `jake dist` to install the toolchain, as just compiled from source. This step may require elevated permissions.
Beware that building and installing Cappuccino from source will overwrite the binaries installed from npm. To undo this,
simply run `npm install -g @objj/cappuccino` again.
## FAQs
**Q: What is meant by desktop-class apps?**
**A:** Desktop-class apps refer to web applications that offer the same level of functionality, complexity, and user experience as traditional desktop applications. These apps leverage keyboard navigation, advanced user interface components, rich graphics, and responsive interactions. Cappuccino is ideally suited for developing line-of-business applications, which are essential tools used within a company for its operations. Such applications often require robust data handling, complex workflows, and a high degree of reliability. Cappuccinos comprehensive framework, modeled after the Cocoa® APIs, ensures that web applications can match the capabilities and performance of native desktop software.
**Q: I don't see any support for touch-screen devices like tablets and phones. Is this supported?**
**A:** Cappuccino applications can be adapted to support touch-screen devices, including tablets and phones. The framework primarily targets large, information-dense displays typical of desktop environments. Achieving a seamless experience across desktops, tablets, and phones requires additional effort, such as incorporating touch event handling and responsive design. However, with the right adjustments, Cappuccino applications can deliver a consistent user experience on a variety of devices.
For those looking to extend Cappuccino for touch applications, one option worth exploring is the open source Objective-C framework ["Chameleon"](https://github.com/BigZaphod/Chameleon). This predates Apple's Catalyst efforts and ports many UIKit classes to AppKit, allowing for a seamless integration of touch features. See below for porting Objective-C code to Objective-J, something which is mostly a search-and-replace operation.
**Q: How easy is it to port Objective-C code to Objective-J?**
**A:** Porting Objective-C code to Objective-J is mostly a search-and-replace operation, primarily focusing on adapting pointer syntax and class names to fit the Objective-J framework.
Here is a summary of the process:
1. **Replace class prefixes**: Objective-C classes using the 'NS' prefix need to be replaced with 'CP'. Objective-C(J) does not support formal namespaces - class prefixes are used to overcome this ('NS' for Apple/NeXTSTEP, 'CP' for Cappuccino). Third-party code may use something else - or none at all. For example:
`NSString` becomes `CPString`, `NSArray` becomes `CPArray`, and `NSDictionary` becomes `CPDictionary`
2. **Remove pointer references:** Objective-C uses pointers, indicated by the * symbol, which are not used in Objective-J. See example below.
3. **Adapt memory management:** Objective-C's manual memory management and automatic reference counting (ARC) do not apply to Objective-J. Thus, methods like retain, release, and autorelease are removed. Objective-J relies on JavaScript's garbage collection - interaction with it is not supported by any browser.
4. **Modify code with no direct equivalent in Objective-J:** The most common is the C language `enum` construct. Javascript and Objective-J provide no direct equivalent - replace with Javascript objects or functions.
**A simple example:**
*Objective-C:*
```objc
NSString *greeting = [NSString stringWithFormat:@"Hello, %@!", name];
```
*Objective-J:*
```objj
let greeting = [CPString stringWithFormat:@"Hello, %@!", name];
```
**Q: Can I use Cappuccino on Windows/Linux?**
**A:** Yes - while Cappuccino technology is inspired by Apple's framework, it is inherently platform-independent. As long as you have a modern web browser and a compatible development environment (An LTS version of Node.js, a text editor, and an http server), Cappuccino applications can be developed on and deployed from other operating systems without any issues.
**Q: Hasn't Apple moved away from Objective-C and AppKit, making them obsolete?**
**A:** While Apple has indeed introduced Swift as a modern programming language and shifted its focus to frameworks like SwiftUI, Objective-C and AppKit are still widely used and supported. Apple's most sophisticated user applications are written either entirely or substantially in Objective-C and will continue to be for the foreseeable future.
**Q: What is with the funny syntax of Objective-J and its brackets? I've never seen a language like this how can anyone be productive with something so strange?**
**A:** Objective-Js syntax, with its brackets, is inspired by Objective-C, which is a small superset of C. The brackets may seem unusual initially, but provide a powerful way to structure code and manage objects while keeping full compatibility with C. Similarly, Objective-J is a small superset of JavaScript. Developers familiar with Objective-C will find it intuitive, and those new to it can leverage extensive documentation and community resources. The initial learning curve is offset by the productivity gains in building complex, maintainable web applications with the option to mix and match from the vast repository of JavaScript code directly even within Objective-J classes.
**Q: I have my own HTML, JavaScript, and CSS which I would like to use in a larger app. I don't see any JavaScript, HTML, or CSS in the available sample code. How do I do this?**
**A:** Cappuccino abstracts much of the DOM to align with Cocoa®'s model. Existing framework controls can be extended or new ones built from scratch to meet specific requirements. The Cappuccino APIs follow a classic object-oriented programming model most necessary functionality will be inherited from the Cappuccino base class one is starting with. The [CPWebView](https://www.cappuccino.dev/learn/documentation/interface_c_p_web_view.html) control can also be used to embed either HTML/Javascript/CSS fragments or entire web pages. Javascript can be intermixed with Objective-J code.
**Q: What are the advantages of Cappuccino over libraries and frameworks like React and Vue?**
**A:** Cappuccino offers several advantages:
* Cocoa®/NeXTSTEP Architecture: Leverages the mature and robust APIs developed originally by NeXTSETP in the 1980s and extended by Apple, providing a time-tested and solid foundation for complex applications.
* Message-Passing Object-Oriented Approach: Uses Objective-J, which extends JavaScript with powerful object-oriented capabilities. This is used to provide a loosely-coupled component architecture, allowing better opportunities for keeping functionality tightly grouped - enhancing testability, reliability and large-scale development.
* Desktop-Class Usability: Complex controls, coherent keyboard navigation and undo/redo out of the box.
* Unified Framework: Integrated UI components, event handling, and data management in one cohesive package, well beyond what React and Vue provide.
* Legacy and Stability: Continuously in development since 2008.
**Q: Does the license permit non-opensource development?**
**A:** Yes, Cappuccino is released under the Lesser General Public License (LGPL) version 2. This allows developers to use, modify, and distribute Cappuccino for both open-source and closed-source applications. Commercial and proprietary software can be developed with Cappuccino without the obligation to release source code, provided the terms of the LGPL are adhered to. This means any modifications to the Cappuccino framework itself must be made available under the same LGPL license, but your own application code remains proprietary.
Cocoa® is a registered trademark of Apple Inc., covering a series of computer APIs for software user interfaces.
## License
To contribute to Cappuccino, please read here: [Getting and Building the Source](https://github.com/cappuccino/cappuccino/wiki/Getting-and-building-the-source).
License
-------
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
@@ -1 +1 @@
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;18E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;11E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;19E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;12E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;20E;E;D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;11E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;18E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;21E;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;22E;E;D;K;10;$classnameS;18;_CPCibClassSwapperK;8;$classesA;S;18;_CPCibClassSwapperS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;23E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;24E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;24E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;25E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;2;21E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;26E;K;14;CPViewScaleKeyD;K;6;CP$UIDd;2;27E;K;18;CPViewSizeScaleKeyD;K;6;CP$UIDd;2;27E;K;17;CPViewIsScaledKeyD;K;6;CP$UIDd;2;28E;K;19;CPViewAppearanceKeyD;K;6;CP$UIDd;1;0E;K;22;CPViewTrackingAreasKeyD;K;6;CP$UIDd;2;29E;K;30;_CPCibClassSwapperClassNameKeyD;K;6;CP$UIDd;2;30E;K;38;_CPCibClassSwapperOriginalClassNameKeyD;K;6;CP$UIDd;2;30E;E;S;16;CPViewControllerD;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;S;4;viewS;13;CPApplicationd;1;0S;20;{{0, 0}, {480, 272}}d;2;12S;6;normalS;6;{1, 1}F;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;S;6;CPViewE;K;9;$archiverS;15;CPKeyedArchiverK;8;$versionS;6;100000E;
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;18E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;11E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;19E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;12E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;20E;E;D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;11E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;18E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;21E;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;22E;E;D;K;10;$classnameS;18;_CPCibClassSwapperK;8;$classesA;S;18;_CPCibClassSwapperS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;23E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;24E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;24E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;25E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;2;21E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;26E;K;14;CPViewScaleKeyD;K;6;CP$UIDd;2;27E;K;18;CPViewSizeScaleKeyD;K;6;CP$UIDd;2;27E;K;17;CPViewIsScaledKeyD;K;6;CP$UIDd;2;28E;K;19;CPViewAppearanceKeyD;K;6;CP$UIDd;1;0E;K;22;CPViewTrackingAreasKeyD;K;6;CP$UIDd;2;29E;K;30;_CPCibClassSwapperClassNameKeyD;K;6;CP$UIDd;2;30E;K;38;_CPCibClassSwapperOriginalClassNameKeyD;K;6;CP$UIDd;2;31E;E;S;16;CPViewControllerD;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;S;4;viewS;13;CPApplicationd;1;0S;20;{{0, 0}, {480, 272}}d;2;12S;6;normalS;6;{1, 1}F;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;S;6;NSViewS;6;CPViewE;K;9;$archiverS;15;CPKeyedArchiverK;8;$versionS;6;100000E;
+2 -2
View File
@@ -32,8 +32,8 @@
- (void)testColorCreate
{
var colorspace = CGColorSpaceCreateDeviceRGB(),
components = [2,3,4,5]/*,
clruid = CFHashCode(colorspace) + components.join("")*/;
components = [2,3,4,5],
clruid = CFHashCode(colorspace) + components.join("");
// Can't access the colormap cache, but it would be nice to
// [self assert:NULL equals:_CGColorMap[clruid]];
+3 -5
View File
@@ -12,13 +12,11 @@
{
/*
Ensure that we have no canvas nor vml support.
Now when we are moving to Node we don't need to do this check anymore.
Before Node we had to check what engine we where running on to test correctly
*/
//if (system.engine !== "jsc")
//{
if (system.engine !== "jsc")
{
[self assert:YES equals:!CPFeatureIsCompatible(CPHTMLCanvasFeature)];
//}
}
[self assert:YES equals:!CPFeatureIsCompatible(CPVMLFeature)];
}
+2 -4
View File
@@ -875,9 +875,8 @@
- (void)testObservationDuringSetSelectionIndexes
{
var arrayController = [self arrayController];
[self setupObservationFixture];
var arrayController = [self arrayController],
newContent = [self setupObservationFixture];
var newSelection = [CPIndexSet indexSetWithIndex:2];
[arrayController setSelectionIndexes:newSelection];
@@ -1143,7 +1142,6 @@
[self setItemsArray:[]];
var ddd = new Date();
console.log();
CPLog.warn("\n" + [self className] + " Performance tests");
CPLog.warn("EmptyArray -> BigArray (" + [bigArray count] + "): " + (dd - d) + "ms.");
CPLog.warn("BigArray (" + [bigArray count] + ") -> EmptyArray: " + (ddd - dd) + "ms.");
-2
View File
@@ -1,8 +1,6 @@
@import <AppKit/CPButton.j>
@import <AppKit/CPApplication.j>
@import <AppKit/CPText.j>
@import <AppKit/CPRadio.j>
@import <AppKit/CPObjectController.j>
@implementation CPButtonTest : OJTestCase
{
-1
View File
@@ -26,7 +26,6 @@
var archived = [CPKeyedArchiver archivedDataWithRootObject:colorWell],
unarchived = [CPKeyedUnarchiver unarchiveObjectWithData:archived];
[self assertNotNull:unarchived];
[self assertFalse:[colorWell isBordered] message:"color well archived bordered state"];
[self assert:[CPColor greenColor] equals:[colorWell color] message:"color well archived color"];
}
@@ -109,8 +109,6 @@
// this code should run with or without that connection.
var cib = [CPBundle loadCibFile:[[CPBundle bundleForClass:CPKeyValueBindingSimpleBindingsTest] pathForResource:"SimpleBindingsAdoption_03.cib"] externalNameTable:@{ CPCibOwner: self }];
[self assertNotNull:cib];
// Test the interaction.
[textField setStringValue:@"0.7"];
// Simulate user interaction. By default bindings update on action only.
-6
View File
@@ -1,5 +1,4 @@
@import <AppKit/CPApplication.j>
@import <AppKit/CPKeyValueBinding.j>
@import <AppKit/CPTextField.j>
@@ -14,7 +13,6 @@
@import <AppKit/CPClipView.j>
@import <AppKit/CPTableView.j>
@import <AppKit/CPArrayController.j>
@import <AppKit/CPSegmentedControl.j>
@implementation CPKeyValueBindingTest : OJTestCase
{
@@ -360,11 +358,7 @@
[segmented bind:CPSelectedIndexBinding toObject:model withKeyPath:@"cheese" options:nil];
// Try to bind another binding (mutually exclusive) to the same value.
// Turn off logging so we don't get the warning about this
var saveCPLogDisable = CPLogDisable;
CPLogDisable = YES;
[segmented bind:CPSelectedTagBinding toObject:model withKeyPath:@"cheese" options:nil];
CPLogDisable = saveCPLogDisable;
[self assertNotNull:[segmented infoForBinding:CPSelectedIndexBinding]];
-2
View File
@@ -286,8 +286,6 @@
outlineView = decoded;
// Expansion state does not archive.
[outlineView expandItem:nil expandChildren:YES];
// Set the datasource or we will get warnings about this.
[outlineView setDataSource:dataSource];
// While not exhaustive, if this test works nothing is majorly broken with the unarchived outline view.
[self testCollapse];
}
+6 -2
View File
@@ -229,6 +229,7 @@
documentView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 1000, 1000)],
textField1 = [CPTextField textFieldWithStringValue:@"Martin" placeholder:@"" width:10],
textField2 = [CPTextField textFieldWithStringValue:@"Malte" placeholder:@"" width:10],
textField1Size = CGSizeMakeCopy([textField1 bounds].size),
textField2Size = CGSizeMakeCopy([textField2 bounds].size);
[scrollView setDocumentView:documentView];
@@ -276,7 +277,9 @@
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)],
documentView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 1000, 1000)],
view1 = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)],
view2 = [[CPView alloc] initWithFrame:CGRectMake(500, 500, 200, 200)];
view2 = [[CPView alloc] initWithFrame:CGRectMake(500, 500, 200, 200)],
view1Size = CGSizeMakeCopy([view1 bounds].size),
view2Size = CGSizeMakeCopy([view2 bounds].size);
[scrollView setDocumentView:documentView];
@@ -286,7 +289,8 @@
[documentView addSubview:view1];
[documentView addSubview:view2];
var visibleRect = [documentView visibleRect];
var visibleRect = [documentView visibleRect],
originalVisibleSize = CGSizeMakeCopy(visibleRect.size);
// Make sure we are at the top left corner
[self assertPoint:CGPointMake(0, 0) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner"];
+1
View File
@@ -194,6 +194,7 @@
for (var row = 0; row < 50; row++)
{
var column = row * 2;
contentArray.push([CPDictionary dictionaryWithObjects:["R" + row + "C0", "R" + row + "C1"] forKeys:["c1", "c2"]]);
}
[arrayController setContent:contentArray];
-1
View File
@@ -1,4 +1,3 @@
@import <AppKit/CPApplication.j>
@import <AppKit/CPTextView.j>
@import <OJMoq/OJMoq.j>
+2 -2
View File
@@ -8,10 +8,10 @@ var methodsCalled;
CPBundle bundle;
}
- (async void)setUp
- (void)setUp
{
bundle = [CPBundle bundleWithPath:@"Tests/AppKit/BundleTest"];
await [bundle loadWithDelegate:self];
[bundle loadWithDelegate:self];
}
- (void)bundleDidFinishLoading:(CPBundle)aBundle
+1 -1
View File
@@ -932,7 +932,7 @@ var updateTrackingAreasCalls,
[view1 setHidden:YES];
[view2 addSubview:view3];
CPLog.warn("will add view2");
[view1 addSubview:view2];
[self assertTrue: [view2 isHiddenOrHasHiddenAncestor] message:@"Expected " + [view2 identifier] + "isHiddenOrHasHiddenAncestor = YES"];
@@ -38,9 +38,8 @@
- (void)test
{
var theDocument = [MyDocument new];
[CPBundle loadCibFile:[[CPBundle bundleForClass:WithoutBindingsTest] pathForResource:"01_WithoutBindings.cib"] externalNameTable:[CPDictionary dictionaryWithObject:theDocument forKey:CPCibOwner]];
var theDocument = [MyDocument new],
cib = [CPBundle loadCibFile:[[CPBundle bundleForClass:WithoutBindingsTest] pathForResource:"01_WithoutBindings.cib"] externalNameTable:[CPDictionary dictionaryWithObject:theDocument forKey:CPCibOwner]];
[theDocument windowControllerDidLoadCib:self];
@@ -40,9 +40,8 @@
- (void)test
{
var theDocument = [MyDocument2 new];
[CPBundle loadCibFile:[[CPBundle bundleForClass:WithBindingsTest] pathForResource:"02_WithBindings.cib"] externalNameTable:[CPDictionary dictionaryWithObject:theDocument forKey:CPCibOwner]];
var theDocument = [MyDocument2 new],
cib = [CPBundle loadCibFile:[[CPBundle bundleForClass:WithBindingsTest] pathForResource:"02_WithBindings.cib"] externalNameTable:[CPDictionary dictionaryWithObject:theDocument forKey:CPCibOwner]];
[theDocument windowControllerDidLoadCib:self];
+2 -11
View File
@@ -1,5 +1,4 @@
var fs = require("fs");
var path = require("path");
var FILE = require("file");
@import <Foundation/CPArray.j>
@import <Foundation/CPString.j>
@@ -34,7 +33,6 @@ var ELEMENTS = 100,
- (void)testAlmostSortedNumericUsingMergeSort
{
console.log();
CPLog.warn("\nNUMERIC ALMOST SORTED");
var a = [self makeUnsorted],
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingDescriptors:) withObject:descriptors];
@@ -50,7 +48,6 @@ var ELEMENTS = 100,
- (void)testRandomNumericUsingMergeSort
{
console.log();
CPLog.warn("\nNUMERIC RANDOM");
var a = [self makeRandomNumeric],
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingDescriptors:) withObject:descriptors];
@@ -66,7 +63,6 @@ var ELEMENTS = 100,
- (void)testRandomTextUsingMergeSort
{
console.log();
CPLog.warn("\nTEXT RANDOM");
var a = [self makeRandomText],
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingDescriptors:) withObject:descriptors];
@@ -82,7 +78,6 @@ var ELEMENTS = 100,
- (void)testAlmostSortedNumericUsingMergeSelectorSort
{
console.log();
CPLog.warn("\nNUMERIC ALMOST SORTED (SELECTOR)");
var a = [self makeUnsorted],
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
@@ -98,7 +93,6 @@ var ELEMENTS = 100,
- (void)testRandomNumericUsingMergeSelectorSort
{
console.log();
CPLog.warn("\nNUMERIC RANDOM (SELECTOR)");
var a = [self makeRandomNumeric],
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
@@ -114,7 +108,6 @@ var ELEMENTS = 100,
- (void)testRandomTextUsingMergeSelectorSort
{
console.log();
CPLog.warn("\nTEXT RANDOM (SELECTOR)");
var a = [self makeRandomText],
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
@@ -180,7 +173,7 @@ var ELEMENTS = 100,
- (CPArray)makeRandomText
{
var the_big_sort = fs.readFileSync(path.join(path.dirname(__filename), "the_big_sort.txt"), {encoding: 'utf-8'}),
var the_big_sort = FILE.read(FILE.join(FILE.dirname(module.path), "the_big_sort.txt"), { charset:"UTF-8" }),
words = the_big_sort.split(" ", ELEMENTS),
wordcount = words.length,
array = [];
@@ -261,7 +254,6 @@ var ELEMENTS = 100,
test2 = [array objectsAtIndexes:indexes];
var ddd = new Date();
console.log();
CPLog.warn("\n_CPJavaScriptArray -objectsAtIndexes:");
CPLog.warn(" CPArray -objectsAtIndexes: " + (dd - d) + "ms.");
CPLog.warn("_CPJavaScriptArray -objectsAtIndexes: " + (ddd - dd) + "ms.");
@@ -306,7 +298,6 @@ var ELEMENTS = 100,
}
var ddd = new Date();
console.log();
CPLog.warn("\n_CPJavaScriptArray -removeObjectIdenticalTo:");
CPLog.warn(" CPArray -removeObjectIdenticalTo: " + (dd - d) + "ms.");
CPLog.warn("_CPJavaScriptArray -removeObjectIdenticalTo: " + (ddd - dd) + "ms.");
+5 -5
View File
@@ -27,22 +27,22 @@
- (void)testCreationMainBundle
{
[CPBundle mainBundle];
var bundle = [CPBundle mainBundle];
}
- (async void)testLoadingBundle
- (void)testLoadingBundle
{
var bundle = [CPBundle bundleWithPath:@"Tests/Foundation/BundleTest"];
await [bundle loadWithDelegate:self];
[bundle loadWithDelegate:self];
[self assert:[bundle objectForInfoDictionaryKey:"CPBundleDefaultLanguage"] equals:"fr"];
[self assert:[bundle objectForInfoDictionaryKey:"CPBundleLocalizableStrings"] equals:["Localizable.strings"]];
}
- (async void)testLocalization
- (void)testLocalization
{
var bundle = [CPBundle bundleWithPath:@"Tests/Foundation/BundleTest"];
await [bundle loadWithDelegate:self];
[bundle loadWithDelegate:self];
[self assert:[bundle localizedStringForKey:"Label from file" value:"" table:"Localizable"] equals:"Label traduit de fr.lproj du premier context"];
[self assert:[bundle localizedStringForKey:"Wrong key" value:"Default value" table:"Localizable"] equals:"Default value"];
-2
View File
@@ -4,8 +4,6 @@
@import <Foundation/CPKeyedArchiver.j>
@import <Foundation/CPNumber.j>
@global require;
@implementation CPDataTest : OJTestCase
{
}
+1 -1
View File
@@ -83,7 +83,7 @@
- (void)testInitWithString
{
var tests = [
["1900-01-01 00:00:00 +0000", -2208988800],
["1800-01-01 00:00:00 +0000", -5364662400],
["1970-01-01 00:00:00 +0000", 0],
["1970-01-01 00:01:00 +0000", 60],
["1970-01-01 01:00:00 +0000", 60 * 60],

Some files were not shown because too many files have changed in this diff Show More