Compare commits

...
32 Commits
Author SHA1 Message Date
Francisco Ryan Tolmasky I 49bd25bad4 Fix for updating window background color to match crushed png.
Reviewed by me.
2009-07-05 21:05:01 -07:00
Francisco Ryan Tolmasky I 2b265310ef Fix for having multiple copies of objective-j gem in the system.
Reviewed by me.
2009-06-29 05:39:50 -07:00
tlrobinsonandFrancisco Ryan Tolmasky I f4f48e4e09 Disable encoding/decoding of plusses in URIs 2009-06-23 17:00:25 -07:00
Francisco Ryan Tolmasky I 4afb8003e6 Updating version strings to 0.7.1.
Reviewed by me.
2009-06-23 17:00:25 -07:00
Francisco Ryan Tolmasky I 5876bcf592 Fix for capitalization issue with circular slider images.
Reviewed by me.
2009-06-23 17:00:25 -07:00
Francisco Ryan Tolmasky I 2486965338 Fix for window returning a direct reference to its frame instead of a copy.
Reviewed by me.
2009-06-23 17:00:25 -07:00
Francisco Ryan Tolmasky I ee830f51d7 Fix for dragged types not working on decoded views.
Reviewed by me.
2009-06-23 17:00:25 -07:00
Francisco Ryan Tolmasky I 343b3e41f3 Made CPImageView accept image drag and drop.
Reviewed by me.

Conflicts:

	AppKit/CPPasteboard.j
2009-06-23 17:00:25 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 2474774242 Update Externals to latest. Remove first arg in objj, objjc, and cplutil to match changes to Narwhal. 2009-06-23 17:00:25 -07:00
Francisco Ryan Tolmasky I 3b04b027f8 Fix for image views in toolbar items not displaying their images.
Reviewed by me.
2009-06-13 11:42:23 -07:00
Francisco Ryan Tolmasky I 2beebd4c1e Made class swapping more robust.
Reviewed by me.
2009-06-13 11:42:22 -07:00
Francisco Ryan Tolmasky I 3b9e73faba Added support for custom classes on non-customviews in nib2cib.
Reviewed by me.
2009-06-13 11:42:22 -07:00
Francisco Ryan Tolmasky I 38273e4dab Fix for -description in CPArray containing null or undefined values.
Reviewed by me.
2009-06-13 11:42:22 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 787e0c8afd Update to use JSON.{parse,stringify} 2009-06-13 11:42:22 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 774ea99319 Update JSON support to json2.js, added in Objective-J. Deprecate CPJSObjectCreateJSON and CPJSObjectCreateWithJSON. 2009-06-13 11:42:22 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 0ca573c7e6 Update the documentation of methods define with the BRIDGE macro 2009-06-13 11:42:21 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 751b89237f Fix for VML paths 2009-06-13 11:42:21 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 41eeb69485 Fix for KAPPA missing in CGPath. Looks like it was auto-merged out. 2009-06-13 11:42:21 -07:00
Francisco Ryan Tolmasky I 18a0e7f0d2 Fix for providing too many image slices breaking CPView.
Reviewed by me.
2009-05-31 13:45:58 -07:00
Nicholas SmallandFrancisco Ryan Tolmasky I ef9053f1ba Fix for undefined key handling.
Reviewed by me.
2009-05-31 01:35:51 -07:00
Francisco Ryan Tolmasky I 8a9b9d4821 Fix for nib2cib's separator menu items not showing up.
Reviewed by me.
2009-05-31 01:35:43 -07:00
Francisco Ryan Tolmasky I 6afaff6d2f Support for new CPEvent mechanism.
Reviewed by me.
2009-05-30 23:19:27 -07:00
Francisco Ryan Tolmasky I 95f594131b Coat tailed CPEvents on native DOM events if they exist, saving the creation of many objects.
Reviewed by me.
2009-05-30 23:17:59 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I de9ab95b55 Rename plutil back to cputil. Oops. 2009-05-30 13:34:14 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I ce0c3a9b6e Fixed incorrect variables in regexp-rhino-patch 2009-05-30 13:34:05 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 380b0d0e5d Bring back the Rhino regex patch to use native Java regex. 2009-05-30 13:33:54 -07:00
Francisco Ryan Tolmasky I 90e7508700 Fix for Unicode chars being mangled when building.
Closes #146.

Reviewed by me.
2009-05-27 01:36:10 -07:00
Francisco Ryan Tolmasky I fc7b5a86ef Further work on theme showcase.
Reviewed by me.
2009-05-25 15:31:52 -07:00
tlrobinsonandFrancisco Ryan Tolmasky I 26ebd6bf64 When loading modules escape "+" in case they're converted to spaces later.
Updated to latest Narwhal and Jack
2009-05-25 15:31:35 -07:00
Francisco Ryan Tolmasky I 28b387554f Added Demos, Aristo, and WebSite to .gitignore so they can be checked out together and eventually built together.
Reviewed by me.
2009-05-24 16:11:15 -07:00
Francisco Ryan Tolmasky I c4c9528af6 Organized BlendKit classes into their own files and added licensing info.
Reviewed by me.
2009-05-24 15:01:22 -07:00
Francisco Ryan Tolmasky I a90e9c83f4 Fix for typos in CPButton.j.
Closes #139.

Reviewed by me.
2009-05-24 14:27:55 -07:00
72 changed files with 1153 additions and 380 deletions
+3
View File
@@ -1,3 +1,6 @@
.DS_Store
Frameworks
Build
Demos
Aristo
WebSite
+2 -2
View File
@@ -368,7 +368,7 @@ CPButtonStateMixed = CPThemeState("mixed");
- (void)setButtonType:(CPButtonType)aButtonType
{
switch (buttonType)
switch (aButtonType)
{
case CPMomentaryLightButton: [self setHighlightsBy:CPChangeBackgroundCellMask];
[self setShowsStateBy:CPNoCellMask];
@@ -390,7 +390,7 @@ CPButtonStateMixed = CPThemeState("mixed");
[self setShowsStateBy:CPChangeBackgroundCellMask];
break;
case CPToggleButton: [self setHighlightsBy:CPPushInCellMask | NSContentsCellMask];
case CPToggleButton: [self setHighlightsBy:CPPushInCellMask | CPContentsCellMask];
[self setShowsStateBy:CPContentsCellMask];
break;
+1 -1
View File
@@ -491,7 +491,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
var future = new Date();
future.setYear(2019);
[_swatchCookie setValue: CPJSObjectCreateJSON(result) expires:future domain: nil];
[_swatchCookie setValue: JSON.stringify(result) expires:future domain: nil];
}
- (void)setColorPanel:(CPColorPanel)panel
+2
View File
@@ -505,10 +505,12 @@ var CPControlBlackColor = [CPColor blackColor];
}
#define BRIDGE(UPPERCASE, LOWERCASE, ATTRIBUTENAME) \
/*! Sets the value for ATTRIBUTENAME */\
- (void)set##UPPERCASE:(id)aValue\
{\
[self setValue:aValue forThemeAttribute:ATTRIBUTENAME];\
}\
/*! Returns the current value for ATTRIBUTENAME */\
- (id)LOWERCASE\
{\
return [self valueForThemeAttribute:ATTRIBUTENAME];\
+25 -1
View File
@@ -206,6 +206,7 @@ var _CPEventPeriodicEventPeriod = 0,
unsigned _clickCount;
float _pressure;
CPWindow _window;
Number _windowNumber;
CPString _characters;
CPString _charactersIgnoringModifiers
BOOL _isARepeat;
@@ -327,7 +328,7 @@ var _CPEventPeriodicEventPeriod = 0,
_charactersIgnoringModifiers = unmodCharacters;
_isARepeat = isARepeat;
_keyCode = code;
_window = [CPApp windowWithWindowNumber:aWindowNumber];
_windowNumber = aWindowNumber;
}
return self;
@@ -397,6 +398,9 @@ var _CPEventPeriodicEventPeriod = 0,
*/
- (CPWindow)window
{
if (!_window)
_window = [CPApp windowWithWindowNumber:_windowNumber];
return _window;
}
@@ -532,3 +536,23 @@ function _CPEventFirePeriodEvent()
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
}
var CPEventClass = [CPEvent class];
function _CPEventFromNativeMouseEvent(aNativeEvent, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, anEventNumber, aClickCount, aPressure)
{
aNativeEvent.isa = CPEventClass;
aNativeEvent._type = anEventType;
aNativeEvent._location = aPoint;
aNativeEvent._modifierFlags = modifierFlags;
aNativeEvent._timestamp = aTimestamp;
aNativeEvent._windowNumber = aWindowNumber;
aNativeEvent._window = nil;
aNativeEvent._context = aGraphicsContext;
aNativeEvent._eventNumber = anEventNumber;
aNativeEvent._clickCount = aClickCount;
aNativeEvent._pressure = aPressure;
return aNativeEvent;
}
+46 -2
View File
@@ -70,7 +70,9 @@ var LEFT_SHADOW_INSET = 3.0,
BOOL _hasShadow;
CPView _shadowView;
BOOL _isEditable;
CGRect _imageRect;
}
@@ -339,11 +341,47 @@ var LEFT_SHADOW_INSET = 3.0,
[[self nextResponder] mouseDown:anEvent];
}
- (void)setEditable:(BOOL)shouldBeEditable
{
if (_isEditable === shouldBeEditable)
return;
_isEditable = shouldBeEditable;
if (_isEditable)
[self registerForDraggedTypes:[CPImagesPboardType]];
else
{
var draggedTypes = [self registeredDraggedTypes];
[self unregisterDraggedTypes];
[draggedTypes removeObjectIdenticalTo:CPImagesPboardType];
[self registerForDraggedTypes:draggedTypes];
}
}
- (BOOL)isEditable
{
return _isEditable;
}
- (void)performDragOperation:(CPDraggingInfo)aSender
{
var images = [CPKeyedUnarchiver unarchiveObjectWithData:[[aSender draggingPasteboard] dataForType:CPImagesPboardType]];
if ([images count])
[self setImage:images[0]];
}
@end
var CPImageViewImageKey = @"CPImageViewImageKey",
CPImageViewImageScalingKey = @"CPImageViewImageScalingKey",
CPImageViewHasShadowKey = @"CPImageViewHasShadowKey";
CPImageViewHasShadowKey = @"CPImageViewHasShadowKey",
CPImageViewIsEditableKey = @"CPImageViewIsEditableKey";
@implementation CPImageView (CPCoding)
@@ -372,6 +410,9 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
[self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]];
if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey] || NO)
[self setEditable:YES];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -402,6 +443,9 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
_subviews = actualSubviews;
[aCoder encodeBool:_hasShadow forKey:CPImageViewHasShadowKey];
if (_isEditable)
[aCoder encodeBool:_isEditable forKey:CPImageViewIsEditableKey];
}
@end
+3 -3
View File
@@ -684,13 +684,13 @@ var _CPMenuBarVisible = NO,
[_CPMenuWindow poolMenuWindow:aMenuWindow];
if([aMenuItem isEnabled])
[CPApp sendAction:[aMenuItem action] to:[aMenuItem target] from:aMenuItem];
var delegate = [menu delegate];
if ([delegate respondsToSelector:@selector(menuDidClose:)])
[delegate menuDidClose:menu];
if([aMenuItem isEnabled])
[CPApp sendAction:[aMenuItem action] to:[aMenuItem target] from:aMenuItem];
}
// Managing Display of State Column
+17 -24
View File
@@ -38,6 +38,8 @@
*/
@implementation CPMenuItem : CPObject
{
BOOL _isSeparator;
CPString _title;
//CPAttributedString _attributedTitle;
@@ -89,6 +91,8 @@
if (self)
{
_isSeparator = NO;
_title = aTitle;
_action = anAction;
@@ -479,7 +483,11 @@ CPOffState
*/
+ (CPMenuItem)separatorItem
{
return [[_CPMenuItemSeparator alloc] init];
var separatorItem = [[self alloc] initWithTitle:@"" action:nil keyEquivalent:nil];
separatorItem._isSeparator = YES;
return separatorItem;
}
/*!
@@ -487,7 +495,7 @@ CPOffState
*/
- (BOOL)isSeparatorItem
{
return NO;
return _isSeparator;
}
// Managing the Owning Menu
@@ -731,29 +739,9 @@ CPControlKeyMask
@end
/* @ignore */
@implementation _CPMenuItemSeparator : CPMenuItem
{
}
var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
- (id)init
{
self = [super initWithTitle:@"" action:nil keyEquivalent:nil];
if (self)
[self setEnabled:NO];
return self;
}
- (BOOL)isSeparatorItem
{
return YES;
}
@end
var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemTargetKey = @"CPMenuItemTargetKey",
CPMenuItemActionKey = @"CPMenuItemActionKey",
@@ -787,6 +775,8 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
if (self)
{
_isSeparator = [aCoder containsValueForKey:CPMenuItemIsSeparatorKey] && [aCoder decodeBoolForKey:CPMenuItemIsSeparatorKey];
_title = [aCoder decodeObjectForKey:CPMenuItemTitleKey];
// _font;
@@ -832,6 +822,9 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
if (_isSeparator)
[aCoder encodeBool:_isSeparator forKey:CPMenuItemIsSeparatorKey];
[aCoder encodeObject:_title forKey:CPMenuItemTitleKey];
[aCoder encodeObject:_target forKey:CPMenuItemTargetKey];
+4
View File
@@ -38,6 +38,10 @@ CPFontPboardType = @"CPFontPboardType";
CPHTMLPboardType = @"CPHTMLPboardType";
CPStringPboardType = @"CPStringPboardType";
CPURLPboardType = @"CPURLPboardType";
CPImagesPboardType = @"CPImagesPboardType";
CPVideosPboardType = @"CPVideosPboardType";
// Deprecated
CPImagePboardType = @"CPImagePboardType";
var CPPasteboards = nil;
+5 -4
View File
@@ -458,15 +458,16 @@ CPToolbarItemVisibilityPriorityUser
[copy setLabel:_label];
[copy setPaletteLabel:_paletteLabel];
[copy setToolTip:[self toolTip]];
[copy setTag:[self tag]];
[copy setTarget:[self target]];
[copy setAction:[self action]];
[copy setEnabled:[self isEnabled]];
[copy setImage:_image];
[copy setAlternateImage:_alternateImage];
[copy setImage:[self image]];
[copy setAlternateImage:[self alternateImage]];
[copy setMinSize:_minSize];
[copy setMaxSize:_maxSize];
+9 -5
View File
@@ -1208,7 +1208,7 @@ var DOMElementPrototype = nil,
amount = 0 - _DOMImageParts.length;
}
if (amount > 0)
while (amount--)
{
@@ -1236,16 +1236,16 @@ var DOMElementPrototype = nil,
else
{
var slices = [patternImage imageSlices],
count = slices.length,
count = MIN(_DOMImageParts.length, slices.length),
frameSize = _frame.size;
while (count--)
{
var image = slices[count],
size = _DOMImageSizes[count] = image ? [image size] : _CGSizeMakeZero();
CPDOMDisplayServerSetStyleSize(_DOMImageParts[count], size.width, size.height);
_DOMImageParts[count].style.background = image ? "url(\"" + [image filename] + "\")" : "";
}
@@ -1469,7 +1469,7 @@ setBoundsOrigin:
*/
- (void)registerForDraggedTypes:(CPArray)pasteboardTypes
{
if (!pasteboardTypes)
if (!pasteboardTypes || ![pasteboardTypes count])
return;
var theWindow = [self window];
@@ -2234,6 +2234,10 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
_subviews = [aCoder decodeObjectForKey:CPViewSubviewsKey] || [];
_superview = [aCoder decodeObjectForKey:CPViewSuperviewKey];
// FIXME: Should we encode/decode this?
_registeredDraggedTypes = [CPSet set];
_registeredDraggedTypesArray = [];
_autoresizingMask = [aCoder decodeIntForKey:CPViewAutoresizingMaskKey] || CPViewNotSizable;
_autoresizesSubviews = ![aCoder containsValueForKey:CPViewAutoresizesSubviewsKey] || [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey];
+1 -1
View File
@@ -567,7 +567,7 @@ CPTexturedBackgroundWindowMask
*/
- (CGRect)frame
{
return _frame;
return _CGRectMakeCopy(_frame);
}
/*!
+1 -1
View File
@@ -56,7 +56,7 @@ var _CPTexturedWindowHeadGradientColor = nil,
+ (CPColor)solidColor
{
if (!_CPTexturedWindowHeadSolidColor)
_CPTexturedWindowHeadSolidColor = [CPColor colorWithCalibratedRed:182.0 / 255.0 green:182.0 / 255.0 blue:182.0 / 255.0 alpha:1.0];
_CPTexturedWindowHeadSolidColor = [CPColor colorWithCalibratedRed:195.0 / 255.0 green:195.0 / 255.0 blue:195.0 / 255.0 alpha:1.0];
return _CPTexturedWindowHeadSolidColor;
}
+1
View File
@@ -24,6 +24,7 @@
@import <Foundation/CPURLConnection.j>
@import <Foundation/CPURLRequest.j>
@import "_CPCibClassSwapper.j"
@import "_CPCibCustomObject.j"
@import "_CPCibCustomResource.j"
@import "_CPCibCustomView.j"
+76
View File
@@ -0,0 +1,76 @@
/*
* _CPCibClassSwapper.j
* AppKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
_CPCibClassSwapperOriginalClassNameKey = @"_CPCibClassSwapperOriginalClassNameKey";
@implementation _CPCibClassSwapper : CPObject
{
}
+ (void)allocObjectWithCoder:(CPCoder)aCoder className:(CPString)aClassName
{
// FIXME: Also check class classForClassName:
var theClass = [aCoder classForClassName:aClassName];
if (!theClass)
{
theClass = objj_lookUpClass(aClassName);
if (!theClass)
return nil;
}
return [theClass alloc];
}
+ (id)allocWithCoder:(CPCoder)aCoder
{
if ([aCoder respondsToSelector:@selector(usesOriginalClasses)] && [aCoder usesOriginalClasses])
{
var theClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey],
object = [self allocObjectWithCoder:aCoder className:theClassName];
}
else
{
var theClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperClassNameKey],
object = [self allocObjectWithCoder:aCoder className:theClassName];
if (!object)
{
CPLog.error("Unable to find class " + theClassName + " in cib file.");
object = [self allocObjectWithCoder:aCoder className:[aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey]];
}
}
if (!object)
[CPException raise:CPInvalidArgumentException reason:@"Unable to find class " + theClassName + " in cib file."];
return object;
}
@end
+37 -20
View File
@@ -87,20 +87,20 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle,
var center = _CGPointMake(x, y),
end = _CGPointMake(COS(anEndAngle), SIN(anEndAngle)),
start = _CGPointMake(COS(aStartAngle), SIN(aStartAngle));
end = _CGPointApplyAffineTransform(end, aTransform);
start = _CGPointApplyAffineTransform(start, aTransform);
center = _CGPointApplyAffineTransform(center, aTransform);
x = center.x;
y = center.y;
var oldEndAngle = anEndAngle,
oldStartAngle = aStartAngle;
anEndAngle = ATAN2(end.y - aTransform.ty, end.x - aTransform.tx);
aStartAngle = ATAN2(start.y - aTransform.ty, start.x - aTransform.tx);
// Angles that equal "modulo" 2 pi return as equal after transforming them,
// so we have to make sure to make them different again if they were different
// to start out with. It's the difference between no circle and a full circle.
@@ -109,7 +109,7 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle,
anEndAngle = anEndAngle - PI2;
else
aStartAngle = aStartAngle - PI2;
aRadius = _CGSizeMake(aRadius, 0);
aRadius = _CGSizeApplyAffineTransform(aRadius, aTransform);
aRadius = SQRT(aRadius.width * aRadius.width + aRadius.height * aRadius.height);
@@ -169,23 +169,38 @@ function CGPathAddLineToPoint(aPath, aTransform, x, y)
function CGPathAddPath(aPath, aTransform, anotherPath)
{
var i = 0,
count = anotherPath.count;
for (; i < count; ++i)
for (var i = 0, count = anotherPath.count; i < count; ++i)
{
var element = anotherPath.elements[i];
aPath.elements[aPath.count] = { type:element.type, x:element.x, y:element.y,
cpx:element.cpx, cpy:element.cpy,
radius:element.radius, startAngle:element.startAngle, endAngle:element.endAngle,
cp1x:element.cp1x, cp1y:element.cp1y, cp2x:element.cp2x, cp2y:element.cp2y,
points: element.points ? element.points.slice() : nil};
aPath.count++
switch (element.type)
{
case kCGPathElementAddLineToPoint: CGPathAddLineToPoint(aPath, aTransform, element.x, element.y);
break;
case kCGPathElementAddCurveToPoint: CGPathAddCurveToPoint(aPath, aTransform,
element.cp1x, element.cp1y,
element.cp2x, element.cp2y,
element.x, element.y);
break;
case kCGPathElementAddArc: CGPathAddArc(aPath, aTransform, element.x, element.y,
element.radius, element.startAngle,
element.endAngle, element.isClockwise);
break;
case kCGPathElementAddQuadCurveToPoint: CGPathAddQuadCurveToPoint(aPath, aTransform,
element.cpx, element.cpy,
element.x, element.y);
break;
case kCGPathElementMoveToPoint: CGPathMoveToPoint(aPath, aTransform, element.x, element.y);
break;
case kCGPathElementCloseSubpath: CGPathCloseSubpath(aPath);
break;
}
}
aPath.current = anotherPath.current;
}
function CGPathAddQuadCurveToPoint(aPath, aTransform, cpx, cpy, x, y)
@@ -250,6 +265,8 @@ function CGPathMoveToPoint(aPath, aTransform, x, y)
aPath.elements[aPath.count++] = { type:kCGPathElementMoveToPoint, x:point.x, y:point.y };
}
var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
function CGPathWithEllipseInRect(aRect)
{
var path = CGPathCreateMutable();
+11 -17
View File
@@ -351,7 +351,7 @@ var CPDOMWindowGetFrame,
theWindow = candidateWindow;
}
}
return theWindow;
}
@@ -462,7 +462,7 @@ var CTRL_KEY_CODE = 17;
var theType = _overriddenEventType || aDOMEvent.type;
// IE's event order is down, up, up, dblclick, so we have create these events artificially.
if (theType == CPDOMEventDoubleClick)
if (theType === CPDOMEventDoubleClick)
{
_overriddenEventType = CPDOMEventMouseDown;
[self _bridgeMouseEvent:aDOMEvent];
@@ -495,7 +495,7 @@ var CTRL_KEY_CODE = 17;
{
var theWindow = [self hitTest:location];
if (aDOMEvent.type == CPDOMEventMouseDown && theWindow)
if ((aDOMEvent.type === CPDOMEventMouseDown) && theWindow)
_mouseDownWindow = theWindow;
windowNumber = [theWindow windowNumber];
@@ -510,12 +510,10 @@ var CTRL_KEY_CODE = 17;
}
switch (theType)
{
{
case CPDOMEventMouseUp: if(_mouseIsDown)
{
event = [CPEvent mouseEventWithType:CPLeftMouseUp location:location modifierFlags:modifierFlags
timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1
clickCount:CPDOMEventGetClickCount(_lastMouseUp, timestamp, location) pressure:0];
event = _CPEventFromNativeMouseEvent(aDOMEvent, CPLeftMouseUp, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseUp, timestamp, location), 0);
_mouseIsDown = NO;
_lastMouseUp = event;
@@ -547,9 +545,7 @@ var CTRL_KEY_CODE = 17;
return;
}
event = [CPEvent mouseEventWithType:CPLeftMouseDown location:location modifierFlags:modifierFlags
timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1
clickCount:CPDOMEventGetClickCount(_lastMouseDown, timestamp, location) pressure:0];
event = _CPEventFromNativeMouseEvent(aDOMEvent, CPLeftMouseDown, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseDown, timestamp, location), 0);
_mouseIsDown = YES;
_lastMouseDown = event;
@@ -558,10 +554,8 @@ var CTRL_KEY_CODE = 17;
case CPDOMEventMouseMoved: if (_DOMEventMode)
return;
event = [CPEvent mouseEventWithType:_mouseIsDown ? CPLeftMouseDragged : CPMouseMoved
location:location modifierFlags:modifierFlags timestamp:timestamp
windowNumber:windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
event = _CPEventFromNativeMouseEvent(aDOMEvent, _mouseIsDown ? CPLeftMouseDragged : CPMouseMoved, location, modifierFlags, timestamp, windowNumber, nil, -1, 1, 0);
break;
}
@@ -988,15 +982,15 @@ var CPDOMEventStop = function(aDOMEvent)
// IE Model
aDOMEvent.cancelBubble = true;
aDOMEvent.returnValue = false;
// W3C Model
if (aDOMEvent.preventDefault)
aDOMEvent.preventDefault();
if (aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
if (aDOMEvent.type == CPDOMEventMouseDown)
if (aDOMEvent.type === CPDOMEventMouseDown)
{
CPSharedDOMWindowBridge._DOMFocusElement.focus();
CPSharedDOMWindowBridge._DOMFocusElement.blur();
+1 -1
View File
@@ -17,7 +17,7 @@ AppKitFiles = FileList['**/*.j'].exclude('CoreGraphics/CGContextCanvas.j', 'Core
ObjectiveJ::BundleTask.new(:AppKit) do |t|
t.name = 'AppKit'
t.identifier = 'com.280n.AppKit'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'AppKit classes for Cappuccino'
+4
View File
@@ -6,6 +6,10 @@
<string>BKShowcaseController</string>
<key>CPBundleName</key>
<string>Aristo</string>
<key>BKLearnMoreURL</key>
<string>http://cappuccino.org/aristo</string>
<key>BKLearnMoreButtonTitle</key>
<string>Aristo Home Page</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>

Before

Width:  |  Height:  |  Size: 1013 B

After

Width:  |  Height:  |  Size: 1013 B

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+2 -2
View File
@@ -516,12 +516,12 @@
+ (CPSlider)themedCircularSlider
{
var slider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 34.0, 34.0)],
trackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"circularSliderBezel.png" size:CGSizeMake(34.0, 34.0)]);
trackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"slider-circular-bezel.png" size:CGSizeMake(34.0, 34.0)]);
[slider setSliderType:CPCircularSlider];
[slider setValue:trackColor forThemeAttribute:@"track-color" inState:CPThemeStateCircular];
var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"circularSliderKnob.png" size:CGSizeMake(5.0, 5.0)]],
var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"slider-circular-knob.png" size:CGSizeMake(5.0, 5.0)]],
knobHighlightedColor = knobColor;
[slider setValue:CGSizeMake(5.0, 5.0) forThemeAttribute:@"knob-size" inState:CPThemeStateCircular];
+67 -11
View File
@@ -1,13 +1,33 @@
/*
* BKShowcaseController.j
* BlendKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import <AppKit/CPTheme.j>
@import <AppKit/CPView.j>
@import "BKUtilities.j"
var LEFT_PANEL_WIDTH = 176.0;
var BKStateToolbarItemIdentifier = @"BKStateToolbarItemIdentifier",
var BKLearnMoreToolbarItemIdentifier = @"BKLearnMoreToolbarItemIdentifier",
BKStateToolbarItemIdentifier = @"BKStateToolbarItemIdentifier",
BKBackgroundColorToolbarItemIdentifier = @"BKBackgroundColorToolbarItemIdentifier";
@implementation BKShowcaseController : CPObject
@@ -118,14 +138,24 @@ var BKStateToolbarItemIdentifier = @"BKStateToolbarItemIdenti
[BKShowcaseCell setBackgroundColor:[themeDescriptorClass showcaseBackgroundColor]];
}
- (BOOL)hasLearnMoreURL
{
return [[CPBundle mainBundle] objectForInfoDictionaryKey:@"BKLearnMoreURL"];
}
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)aToolbar
{
return [CPToolbarSpaceItemIdentifier, CPToolbarFlexibleSpaceItemIdentifier, BKBackgroundColorToolbarItemIdentifier, BKStateToolbarItemIdentifier];
return [BKLearnMoreToolbarItemIdentifier, CPToolbarSpaceItemIdentifier, CPToolbarFlexibleSpaceItemIdentifier, BKBackgroundColorToolbarItemIdentifier, BKStateToolbarItemIdentifier];
}
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)aToolbar
{
return [CPToolbarFlexibleSpaceItemIdentifier, BKBackgroundColorToolbarItemIdentifier, BKStateToolbarItemIdentifier];
var itemIdentifiers = [CPToolbarFlexibleSpaceItemIdentifier, BKBackgroundColorToolbarItemIdentifier, BKStateToolbarItemIdentifier];
if ([self hasLearnMoreURL])
itemIdentifiers = [BKLearnMoreToolbarItemIdentifier].concat(itemIdentifiers);
return itemIdentifiers;
}
- (CPToolbarItem)toolbar:(CPToolbar)aToolbar itemForItemIdentifier:(CPString)anItemIdentifier willBeInsertedIntoToolbar:(BOOL)aFlag
@@ -151,21 +181,21 @@ var BKStateToolbarItemIdentifier = @"BKStateToolbarItemIdenti
[toolbarItem setMaxSize:CGSizeMake(width + 20.0, 32.0)];
}
else if (BKBackgroundColorToolbarItemIdentifier)
else if (anItemIdentifier === BKBackgroundColorToolbarItemIdentifier)
{
var popUpButton = [CPPopUpButton buttonWithTitle:@"Light Checkers"];
var popUpButton = [CPPopUpButton buttonWithTitle:@"Window Background"];
[popUpButton addItemWithTitle:@"Light Checkers"];
[popUpButton addItemWithTitle:@"Dark Checkers"];
[popUpButton addItemWithTitle:@"Window Background Color"];
[popUpButton addItemWithTitle:@"White"];
[popUpButton addItemWithTitle:@"Black"];
[popUpButton addItemWithTitle:@"More Choices..."];
var itemArray = [popUpButton itemArray];
[itemArray[0] setRepresentedObject:[BKThemeDescriptor lightCheckersColor]];
[itemArray[1] setRepresentedObject:[BKThemeDescriptor darkCheckersColor]];
[itemArray[2] setRepresentedObject:[BKThemeDescriptor windowBackgroundColor]];
[itemArray[0] setRepresentedObject:[BKThemeDescriptor windowBackgroundColor]];
[itemArray[1] setRepresentedObject:[BKThemeDescriptor lightCheckersColor]];
[itemArray[2] setRepresentedObject:[BKThemeDescriptor darkCheckersColor]];
[itemArray[3] setRepresentedObject:[CPColor whiteColor]];
[itemArray[4] setRepresentedObject:[CPColor blackColor]];
@@ -179,10 +209,36 @@ var BKStateToolbarItemIdentifier = @"BKStateToolbarItemIdenti
[toolbarItem setMinSize:CGSizeMake(width, 32.0)];
[toolbarItem setMaxSize:CGSizeMake(width, 32.0)];
}
else if (anItemIdentifier === BKLearnMoreToolbarItemIdentifier)
{
var title = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"BKLearnMoreButtonTitle"];
if (!title)
title = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPBundleName"] || @"Home Page";
var button = [CPButton buttonWithTitle:title];
[button setDefaultButton:YES];
[toolbarItem setView:button];
[toolbarItem setLabel:@"Learn More"];
[toolbarItem setTarget:nil];
[toolbarItem setAction:@selector(learnMore:)];
var width = CGRectGetWidth([button frame]);
[toolbarItem setMinSize:CGSizeMake(width, 32.0)];
[toolbarItem setMaxSize:CGSizeMake(width, 32.0)];
}
return toolbarItem;
}
- (void)learnMore:(id)aSender
{
window.location.href = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"BKLearnMoreURL"];
}
- (BKThemeDescriptor)selectedThemeDescriptor
{
return _themeDescriptorClasses[[[_themesCollectionView selectionIndexes] firstIndex]];
+23 -2
View File
@@ -1,3 +1,24 @@
/*
* BKThemeDescriptor.j
* BlendKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import <Foundation/CPObject.j>
@@ -61,7 +82,7 @@ var ItemSizes = { },
+ (CPColor)defaultShowcaseBackgroundColor
{
return [self lightCheckersColor];
return [_CPStandardWindowView bodyBackgroundColor];//[self lightCheckersColor];
}
+ (CPColor)showcaseBackgroundColor
@@ -121,7 +142,7 @@ var ItemSizes = { },
if (!object)
continue;
var template = [[BKThemeObjectTemplate alloc] init];
var template = [[BKThemedObjectTemplate alloc] init];
[template setValue:object forKey:@"themedObject"];
[template setValue:BKLabelFromIdentifier(selector) forKey:@"label"];
+51
View File
@@ -0,0 +1,51 @@
/*
* BKThemeTemplate.j
* BlendKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import <Foundation/CPObject.j>
@implementation BKThemeTemplate : CPObject
{
CPString _name;
CPString _description;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_name = [aCoder decodeObjectForKey:@"BKThemeTemplateName"];
_description = [aCoder decodeObjectForKey:@"BKThemeTemplateDescription"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_name forKey:@"BKThemeTemplateName"];
[aCoder encodeObject:_description forKey:@"BKThemeTemplateDescription"];
}
@end
@@ -0,0 +1,51 @@
/*
* BKThemedObjectTemplate.j
* BlendKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import <AppKit/CPView.j>
@implementation BKThemedObjectTemplate : CPView
{
CPString _label;
id _themedObject;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_label = [aCoder decodeObjectForKey:@"BKThemedObjectTemplateLabel"];
_themedObject = [aCoder decodeObjectForKey:@"BKThemedObjectTemplateThemedObject"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_label forKey:@"BKThemedObjectTemplateLabel"];
[aCoder encodeObject:_themedObject forKey:@"BKThemedObjectTemplateThemedObject"];
}
@end
-54
View File
@@ -1,54 +0,0 @@
@implementation BKThemeTemplate : CPObject
{
CPString _name;
CPString _description;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_name = [aCoder decodeObjectForKey:@"BKThemeTemplateName"];
_description = [aCoder decodeObjectForKey:@"BKThemeTemplateDescription"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_name forKey:@"BKThemeTemplateName"];
[aCoder encodeObject:_description forKey:@"BKThemeTemplateDescription"];
}
@end
@implementation BKThemeObjectTemplate : CPView
{
CPString _label;
id _themedObject;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_label = [aCoder decodeObjectForKey:@"BKThemeObjectTemplateLabel"];
_themedObject = [aCoder decodeObjectForKey:@"BKThemeObjectTemplateThemedObject"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_label forKey:@"BKThemeObjectTemplateLabel"];
[aCoder encodeObject:_themedObject forKey:@"BKThemeObjectTemplateThemedObject"];
}
@end
+23 -1
View File
@@ -1,4 +1,26 @@
/*
* BlendKit.j
* BlendKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import "BKShowcaseController.j"
@import "BKThemeDescriptor.j"
@import "BKUtilities.j"
@import "BKThemeTemplate.j"
@import "BKThemedObjectTemplate.j"
+1 -1
View File
@@ -12,7 +12,7 @@ $BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'BlendKit')
ObjectiveJ::BundleTask.new(:BlendKit) do |t|
t.name = 'BlendKit'
t.identifier = 'com.280n.BlendKit'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'BlendKit classes for Cappuccino'
+1 -1
View File
@@ -15,7 +15,7 @@ $ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'blend')
ObjectiveJ::BundleTask.new(:blend) do |t|
t.name = 'blend'
t.identifier = 'com.280n.blend'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'blend classes for Cappuccino'
+27 -7
View File
@@ -1,8 +1,28 @@
/*
* main.j
* blend
*
* Created by Francisco Tolmasky.
* Copyright 2009, 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
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import <AppKit/CPCib.j>
@import <AppKit/CPTheme.j>
@import <BlendKit/BlendKit.j>
var File = require("file");
@@ -68,7 +88,7 @@ function main()
temporaryCibFile = Packages.java.io.File.createTempFile("temp", ".cib"),
temporaryCibFilePath = String(temporaryCibFile.getAbsolutePath());
File.write(temporaryCibFilePath, [data string], { charset:"UTF8" });
File.write(temporaryCibFilePath, [data string], { charset:"UTF-8" });
cibFiles.push(temporaryCibFilePath);
}
@@ -151,8 +171,8 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
outputFile.mkdirs();
File.write(outputFilePath + "/Info.plist", [CPPropertyListCreate280NorthData(infoDictionary) string], { charset:"UTF8" });
File.write(outputFilePath + '/' + staticContentName, staticContent, { charset:"UTF8" });
File.write(outputFilePath + "/Info.plist", [CPPropertyListCreate280NorthData(infoDictionary) string], { charset:"UTF-8" });
File.write(outputFilePath + '/' + staticContentName, staticContent, { charset:"UTF-8" });
if (resourcesPath)
rsync(new Packages.java.io.File(resourcesPath), new Packages.java.io.File(outputFilePath));
@@ -246,7 +266,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
{
var theClass = [self class];
if ([theClass isKindOfClass:[BKThemeObjectTemplate class]])
if ([theClass isKindOfClass:[BKThemedObjectTemplate class]])
return [self];
if ([theClass isKindOfClass:[CPView class]])
@@ -266,7 +286,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
@end
@implementation BKThemeObjectTemplate (BlendAdditions)
@implementation BKThemedObjectTemplate (BlendAdditions)
- (void)blendAddThemedObjectAttributesToTheme:(CPTheme)aTheme
{
+1 -1
+13 -20
View File
@@ -255,18 +255,6 @@
return self;
}
/*!
Returns a hash of the CPArray.
@return an unsigned integer hash
*/
- (unsigned)hash
{
if (self.__address == nil)
self.__address = _objj_generateObjectHash();
return self.__address;
}
// Querying an array
/*!
Returns <code>YES</code> if the array contains <code>anObject</code>. Otherwise, it returns <code>NO</code>.
@@ -799,18 +787,23 @@
*/
- (CPString)description
{
var i = 0,
var index = 0,
count = [self count],
description = '(';
for(; i < count; ++i)
for(; index < count; ++index)
{
if (self[i].isa) description += [self[i] description];
else description += self[i];
if (i != count - 1) description += ", ";
var object = self[index];
if (object && object.isa)
description += [object description];
else
description += object;
if (index !== count - 1)
description += ", ";
}
return description + ')';
}
+2 -2
View File
@@ -247,9 +247,9 @@ CPUnknownUserInfoKey = @"CPUnknownUserInfoKey";
self[ivar] = aValue;
[self didChangeValueForKey:aKey];
return;
}
return;
}
[self setValue:aValue forUndefinedKey:aKey];
+7 -6
View File
@@ -424,15 +424,16 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
if (!theClass)
theClass = CPClassFromString(className);
object = [theClass alloc];
// It is important to do this before calling initWithCoder so that decoding can be self referential (something = self).
self._objects[anIndex] = object;
var savedPlistObject = self._plistObject;
self._plistObject = plistObject;
var string = className;
// Should we only call this on _CPCibClassSwapper? (currently the only class that makes use of this).
object = [theClass allocWithCoder:self];
// It is important to do this before calling initWithCoder so that decoding can be self referential (something = self).
self._objects[anIndex] = object;
var processedObject = [object initWithCoder:self];
self._plistObject = savedPlistObject;
+1 -1
View File
@@ -186,7 +186,7 @@ var __placeholder = new Number(),
return anUnsignedShort;
}
- (CPString)hash
- (CPString)UID
{
if (!_CPNumberHashes[self])
_CPNumberHashes[self] = _objj_generateObjectHash();
+13
View File
@@ -92,6 +92,11 @@ CPLog(@"Got some class: %@", inst);</pre>
return class_createInstance(self);
}
+ (id)allocWithCoder:(CPCoder)aCoder
{
return [self alloc];
}
/*!
Initializes the receiver
@return the initialized receiver
@@ -459,6 +464,14 @@ CPLog(@"Got some class: %@", inst);</pre>
*/
- (unsigned)hash
{
return [self UID];
}
- (unsigned)UID
{
if (typeof self.__address === "undefined")
self.__address = _objj_generateObjectHash();
return __address;
}
+3 -3
View File
@@ -502,7 +502,7 @@ var CPStringHashes = new objj_dictionary();
/*!
Returns a hash of the string instance.
*/
- (unsigned)hash
- (unsigned)UID
{
var hash = dictionary_getValue(CPStringHashes, self);
@@ -659,7 +659,7 @@ var CPStringHashes = new objj_dictionary();
*/
+ (CPString)JSONFromObject:(JSObject)anObject
{
return CPJSObjectCreateJSON(anObject);
return JSON.stringify(anObject);
}
/*!
@@ -667,7 +667,7 @@ var CPStringHashes = new objj_dictionary();
*/
- (JSObject)objectFromJSON
{
return CPJSObjectCreateWithJSON(self);
return JSON.parse(self);
}
@end
+6 -118
View File
@@ -83,7 +83,7 @@ var CPValueValueKey = @"CPValueValueKey";
self = [super init];
if (self)
_JSObject = CPJSObjectCreateWithJSON([aCoder decodeObjectForKey:CPValueValueKey]);
_JSObject = JSON.parse([aCoder decodeObjectForKey:CPValueValueKey]);
return self;
}
@@ -94,131 +94,19 @@ var CPValueValueKey = @"CPValueValueKey";
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:CPJSObjectCreateJSON(_JSObject) forKey:CPValueValueKey];
[aCoder encodeObject:JSON.stringify(_JSObject) forKey:CPValueValueKey];
}
@end
var _JSONCharacterEncodings = {};
_JSONCharacterEncodings['\b'] = "\\b";
_JSONCharacterEncodings['\t'] = "\\t";
_JSONCharacterEncodings['\n'] = "\\n";
_JSONCharacterEncodings['\f'] = "\\f";
_JSONCharacterEncodings['\r'] = "\\r";
_JSONCharacterEncodings['"'] = "\\\"";
_JSONCharacterEncodings['\\'] = "\\\\";
// FIXME: Workaround for https://trac.280north.com/ticket/16
var _JSONEncodedCharacters = new RegExp("[\\\"\\\\\\x00-\\x1f\\x7f-\\x9f]", 'g');
function CPJSObjectCreateJSON(aJSObject)
{
// typeof new Number() and new String() gives you "object",
// so valueof in those cases.
var type = typeof aJSObject,
valueOf = aJSObject ? aJSObject.valueOf() : null,
typeValueOf = typeof valueOf;
if (type != typeValueOf)
{
type = typeValueOf;
aJSObject = valueOf;
}
switch (type)
{
case "string": // If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe sequences.
if (!_JSONEncodedCharacters.test(aJSObject))
return '"' + aJSObject + '"';
return '"' + aJSObject.replace(_JSONEncodedCharacters, _CPJSObjectEncodeCharacter) + '"';
case "number": // JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(aJSObject) ? String(aJSObject) : "null";
case "boolean":
case "null": return String(aJSObject);
case "object": // Due to a specification blunder in ECMAScript,
// typeof null is 'object', so watch out for that case.
if (!aJSObject)
return "null";
// If the object has a toJSON method, call it, and stringify the result.
if (typeof aJSObject.toJSON === "function")
return CPJSObjectCreateJSON(aJSObject.toJSON());
var array = [];
// If the object is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
if (aJSObject.slice)
{
var index = 0,
count = aJSObject.length;
for (; index < count; ++index)
array.push(CPJSObjectCreateJSON(aJSObject[index]) || "null");
// Join all of the elements together and wrap them in brackets.
return '[' + array.join(',') + ']';
}
// Otherwise, iterate through all of the keys in the object.
var key = NULL;
for (key in aJSObject)
{
if (!(typeof key === "string"))
continue;
var value = CPJSObjectCreateJSON(aJSObject[key]);
if (value)
array.push(CPJSObjectCreateJSON(key) + ':' + value);
}
// Join all of the member texts together and wrap them in braces.
return '{' + array.join(',') + '}';
}
CPLog.warn("CPJSObjectCreateJSON deprecated, use JSON.stringify() or CPString's objectFromJSON");
return JSON.stringify(aJSObject);
}
var _CPJSObjectEncodeCharacter = function(aCharacter)
{
var encoding = _JSONCharacterEncodings[aCharacter];
if (encoding)
return encoding;
encoding = aCharacter.charCodeAt(0);
return '\\u00' + FLOOR(encoding / 16).toString(16) + (encoding % 16).toString(16);
}
var _JSONBackslashCharacters = new RegExp("\\\\.", 'g'),
_JSONSimpleValueTokens = new RegExp("\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?", 'g'),
_JSONValidOpenBrackets = new RegExp("(?:^|:|,)(?:\\s*\\[)+", 'g'),
_JSONValidExpression = new RegExp("^[\\],:{}\\s]*$");
function CPJSObjectCreateWithJSON(aString)
{
if (_JSONValidExpression.test(aString.replace(_JSONBackslashCharacters, '@').replace(_JSONSimpleValueTokens, ']').replace(_JSONValidOpenBrackets, '')))
return eval('(' + aString + ')');
return nil;
CPLog.warn("CPJSObjectCreateWithJSON deprecated, use JSON.parse() or CPString's JSONFromObject");
return JSON.parse(aString);
}
/*
var _JSONBackslashCharacters = /\\./g,
_JSONSimpleValueTokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
_JSONValidOpenBrackets = /(?:^|:|,)(?:\s*\[)+/g,
_JSONValidExpression = /^[\],:{}\s]*$/;
*/
+1 -1
View File
@@ -14,7 +14,7 @@ task :build => [:Foundation, $ENVIRONMENT_PRODUCT]
ObjectiveJ::BundleTask.new(:Foundation) do |t|
t.name = 'Foundation'
t.identifier = 'com.280n.Foundation'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'Foundation classes for Cappuccino'
+1
View File
@@ -19,6 +19,7 @@ task :Products => [$BROWSER_FILE, $RHINO_FILE, $LICENSE_PRODUCT]
Files = [ 'constants.js',
'utilities.js',
'json2.js',
'runtime.js',
'dictionary.js',
'plist.js',
+1 -1
View File
@@ -11,7 +11,7 @@ $ENVIRONMENT_OBJJ_PRODUCT = File.join($ENVIRONMENT_NARWHAL_PRODUCT, 'packages',
$OBJJC_JS_COMPILER = File.join($ENVIRONMENT_LIB_DIR, 'shrinksafe.jar')
$OBJJC_JS_COMPILER_RHINO = File.join($ENVIRONMENT_LIB_DIR, 'js.jar')
$EXECUTABLES = ['objj', 'objjc', 'plutil']
$EXECUTABLES = ['objj', 'objjc', 'cplutil']
$EXECUTABLES_PRODUCTS = $EXECUTABLES.map {|e| File.join($ENVIRONMENT_BIN_DIR, e) }
$EXECUTABLES.each do |executable|
@@ -13,6 +13,9 @@ function printUsage()
function main()
{
// FIXME: ARGS
system.args.shift();
if (system.args.length < 1)
return printUsage();
+13 -24
View File
@@ -1,15 +1,14 @@
#!/usr/bin/env narwhal
var objjc = require("objj/objjc");
var objjc = require("objj/objjc"),
File = require("file");
with (objjc)
{
importPackage(java.lang);
importClass(java.io.BufferedReader);
importClass(java.io.FileReader);
importClass(java.io.BufferedWriter);
importClass(java.io.FileWriter);
OBJJ_PREPROCESSOR_PREPROCESS = 1 << 10;
@@ -22,7 +21,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
output = "",
process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream()));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream(), "UTF-8"));
while (line = reader.readLine())
{
@@ -32,7 +31,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
output += line + '\n';
}
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream()));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream(), "UTF-8"));
while (line = reader.readLine())
System.out.println(line);
@@ -52,13 +51,9 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
function compress(/*String*/ aCode, /*Object*/ flags, /*File*/ tmpFile)
{
var writer = new BufferedWriter(new FileWriter(tmpFile));
writer.write(aCode);
writer.close();
File.write(tmpFile, aCode, { charset:"UTF-8" });
return exec(["java", "-classpath", OBJJ_HOME + "/lib/js.jar" + ":" + OBJJ_HOME + "/lib/shrinksafe.jar", "org.dojotoolkit.shrinksafe.Main", tmpFile.getCanonicalPath(), "-escape-unicode"]);
return exec(["java", "-Dfile.encoding=UTF-8", "-classpath", OBJJ_HOME + "/lib/js.jar" + ":" + OBJJ_HOME + "/lib/shrinksafe.jar", "org.dojotoolkit.shrinksafe.Main", tmpFile.getCanonicalPath()]);
}
//#define SET_CONTEXT(aFragment, aContext) aFragment.context = aContext
@@ -112,15 +107,8 @@ function preprocess(aFilePath, outFilePath, gccArgs, flags)
return;
// Read file and preprocess it.
var reader = new BufferedReader(new FileReader(tmpFile)),
fileContents = "";
// Get contents of the file
while (reader.ready())
fileContents += reader.readLine() + '\n';
reader.close();
var fileContents = File.read(tmpFile, { charset: "UTF-8" });
// Preprocess contents into fragments.
var filePath = new String(new java.io.File(aFilePath).getName()),
fragments = objj_preprocess(fileContents, { path:"/x" }, {path:filePath}, flags),
@@ -171,13 +159,14 @@ function preprocess(aFilePath, outFilePath, gccArgs, flags)
}
// Write file.
var writer = new BufferedWriter(new FileWriter(outFilePath));
writer.write(preprocessed);
writer.close();
File.write(outFilePath, preprocessed, { charset: "UTF-8" });
}
function main()
{
// FIXME: ARGS
system.args.shift();
var filePaths = [],
outFilePaths = [],
+4 -1
View File
@@ -12,9 +12,12 @@ if (system.env["OBJJ_INCLUDE_PATHS"])
window.args = system.args;
// FIXME: ARGS
system.args.shift();
with (window)
{
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js", { charset : "UTF-8" }));
eval(File.read(OBJJ_HOME + "/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js", { charset:"UTF-8" }));
if (system.args.length > 0)
{
+3 -1
View File
@@ -1,6 +1,8 @@
var File = require("file");
var window = require("browser/window");
require("./regexp-rhino-patch");
var exported = ["OBJJ_HOME", "objj_preprocess",
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
@@ -10,7 +12,7 @@ var OBJJ_HOME = system.prefix + "/..";
with (window)
{
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js").toString());
eval(File.read(OBJJ_HOME + "/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js", { charset:"UTF-8" }).toString());
for (var i = 0; i < exported.length; i++)
exports[exported[i]] = eval(exported[i]);
@@ -1,9 +1,3 @@
importClass(java.util.ArrayList);
importClass(java.util.List);
importClass(java.util.regex.Matcher);
importClass(java.util.regex.Pattern);
importClass(java.util.regex.PatternSyntaxException);
var CachedRegexData = [];
function regexDataFromRegex(aRegex)
@@ -37,10 +31,10 @@ function regexDataFromRegex(aRegex)
source = source.replace("(?<!\\\\)\\{(?!\\d)", "\\\\{", "g");
source = source.replace("(?<!(\\d,?|\\\\))\\}", "\\\\}", "g");
return CachedRegexData[string] = { pattern:Pattern.compile(source, 0), flags:flags };
return CachedRegexData[string] = { pattern:java.util.regex.Pattern.compile(source, 0), flags:flags };
}
String.prototype.match = function(regex)
function newMatch(regex)
{
var regexData = regexDataFromRegex(regex);
@@ -68,9 +62,12 @@ String.prototype.match = function(regex)
var group = matcher.group(index);
if (group != null)
groups[i] = group;
groups[index] = group;
}
}
return groups;
}
if (system.platform === "rhino")
String.prototype.match = newMatch;
+2
View File
@@ -301,6 +301,8 @@ objj_search.prototype.request = function(aFilePath, aMethod)
try
{
// unclear whether plusses are reserved in the URI path
//request.open("GET", aFilePath.replace(/\+/g, "%2B"), YES);
request.open("GET", aFilePath, YES);
request.send("");
}
+478
View File
@@ -0,0 +1,478 @@
/*
http://www.JSON.org/json2.js
2009-04-16
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the object holding the key.
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
*/
/*jslint evil: true */
/*global JSON */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (!this.JSON) {
JSON = {};
}
(function () {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ?
'"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' :
'"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ? '[]' :
gap ? '[\n' + gap +
partial.join(',\n' + gap) + '\n' +
mind + ']' :
'[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
k = rep[i];
if (typeof k === 'string') {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ? '{}' :
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
mind + '}' : '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function' ?
walk({'': j}, '') : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());
+5 -8
View File
@@ -177,8 +177,8 @@ function class_addMethod(/*Class*/ aClass, /*SEL*/ aName, /*IMP*/ anImplementati
// FIXME: Should this be done here?
// If this is a root class...
if (!ISMETA(aClass) && GETMETA(aClass).isa === GETMETA(aClass))
class_addMethods(GETMETA(aClass), methods);
class_addMethod(GETMETA(aClass), method);
return YES;
}
@@ -472,12 +472,9 @@ function objj_msgSend(/*id*/ aReceiver, /*SEL*/ aSelector)
switch(arguments.length)
{
case 2:
return implementation(aReceiver, aSelector);
case 3:
return implementation(aReceiver, aSelector, arguments[2]);
case 4:
return implementation(aReceiver, aSelector, arguments[2], arguments[3]);
case 2: return implementation(aReceiver, aSelector);
case 3: return implementation(aReceiver, aSelector, arguments[2]);
case 4: return implementation(aReceiver, aSelector, arguments[2], arguments[3]);
}
return implementation.apply(aReceiver, arguments);
+1 -1
View File
@@ -247,7 +247,7 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
+1
View File
@@ -37,5 +37,6 @@ done
chmod +x $INSTALL_DIR/share/objj/bin/*
gem install *.gem
gem cleanup objective-j
echo "Cappuccino Tools Installed"
+2 -2
View File
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
s.homepage = 'http://cappuccino.org/'
s.summary = "Objective-J extensions to Rake."
s.name = 'objective-j'
s.version = "0.7.0"
s.version = "0.7.1"
s.requirements << 'rake'
s.require_path = 'lib'
s.files = PKG_FILES
@@ -34,7 +34,7 @@ Rake::GemPackageTask.new(spec) do |pkg|
end
#task :install do
# Gem::Installer.new(File.join($BUILD_DIR, $CONFIGURATION, 'rake', 'objective-j-0.7.0.gem')).install
# Gem::Installer.new(File.join($BUILD_DIR, $CONFIGURATION, 'rake', 'objective-j-0.7.1.gem')).install
#end
task :objj_gem => [:gem] do
+2
View File
@@ -545,6 +545,8 @@ module ObjectiveJ
list.each do |fileName|
fileName = File.expand_path(fileName)
File.open(fileName) do |file|
if fileName.index(platform_absolute_path) == 0
+1 -1
View File
@@ -15,7 +15,7 @@ $ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'bake')
ObjectiveJ::BundleTask.new(:bake) do |t|
t.name = 'bake'
t.identifier = 'com.280n.bake'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'Deployment tool for Cappuccino applications'
+1 -1
View File
@@ -28,7 +28,7 @@ function readConfig(configFile)
if (!fileData)
throw new Error("Couldn't read file: " + configFile);
var configs = CPJSObjectCreateWithJSON(fileData);
var configs = JSON.parse(fileData);
return configs;
}
+1 -1
View File
@@ -14,7 +14,7 @@ $ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'capp')
ObjectiveJ::BundleTask.new(:capp) do |t|
t.name = 'capp'
t.identifier = 'com.280n.capp'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'Setup up Cappuccino projects'
+1 -1
View File
@@ -24,7 +24,7 @@ function main()
switch (argument)
{
case "version":
case "--version": return print("capp version 0.7.0");
case "--version": return print("capp version 0.7.1");
case "-h":
case "--help": return printUsage();
+1
View File
@@ -22,6 +22,7 @@
@import "NSButton.j"
@import "NSCell.j"
@import "NSClassSwapper.j"
@import "NSClipView.j"
@import "NSColor.j"
@import "NSColorWell.j"
+66
View File
@@ -0,0 +1,66 @@
var NSClassSwapperClassNames = {},
NSClassSwapperOriginalClassNames = {};
var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
_CPCibClassSwapperOriginalClassNameKey = @"_CPCibClassSwapperOriginalClassNameKey";
@implementation NSClassSwapper : _CPCibClassSwapper
{
}
+ (id)swapperClassForClassName:(CPString)aClassName originalClassName:(CPString)anOriginalClassName
{
var swapperClassName = "$NSClassSwapper_" + aClassName + "_" + anOriginalClassName;
swapperClass = objj_lookUpClass(swapperClassName);
if (!swapperClass)
{
var originalClass = objj_lookUpClass(anOriginalClassName);
swapperClass = objj_allocateClassPair(originalClass, swapperClassName);
objj_registerClassPair(swapperClass);
class_addMethod(swapperClass, @selector(initWithCoder:), function(self, _cmd, aCoder)
{
self = objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
if (self)
{
var UID = [self UID];
NSClassSwapperClassNames[UID] = aClassName;
NSClassSwapperOriginalClassNames[UID] = anOriginalClassName;
}
return self;
}, "");
class_addMethod(swapperClass, @selector(classForKeyedArchiver), function(self, _cmd)
{
return [_CPCibClassSwapper class];
}, "");
class_addMethod(swapperClass, @selector(encodeWithCoder:), function(self, _cmd, aCoder)
{
objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
// FIXME: map class name as well?
[aCoder encodeObject:aClassName forKey:_CPCibClassSwapperClassNameKey];
[aCoder encodeObject:CP_NSMapClassName(anOriginalClassName) forKey:_CPCibClassSwapperOriginalClassNameKey];
}, "");
}
return swapperClass;
}
+ (id)allocWithCoder:(CPCoder)aCoder
{
var className = [aCoder decodeObjectForKey:@"NSClassName"],
originalClassName = [aCoder decodeObjectForKey:@"NSOriginalClassName"];
return [[self swapperClassForClassName:className originalClassName:originalClassName] alloc];
}
@end
+3 -3
View File
@@ -75,9 +75,9 @@
//_accessibilityOidsKeys = [aCoder decodeObjectForKey:@"NSAccessibilityOidsKeys"];
//_accessibilityOidsValues = [aCoder decodeObjectForKey:@"NSAccessibilityOidsValues"];
_classesKeys = [aCoder decodeObjectForKey:@"NSClassesKeys"];print("d");
_classesValues = [aCoder decodeObjectForKey:@"NSClassesValues"];print("e");
_classesKeys = [aCoder decodeObjectForKey:@"NSClassesKeys"];
_classesValues = [aCoder decodeObjectForKey:@"NSClassesValues"];
_connections = [aCoder decodeObjectForKey:@"NSConnections"];
//_fontManager = [aCoder decodeObjectForKey:@"NSFontManager"] retain];
+1
View File
@@ -34,6 +34,7 @@
var cell = [aCoder decodeObjectForKey:@"NSCell"];
_imageScaling = [cell imageScaling];
_isEditable = [cell isEditable];
}
return self;
+2 -1
View File
@@ -33,6 +33,8 @@
if (self)
{
_isSeparator = [aCoder decodeObjectForKey:@"NSIsSeparator"] || NO;
_title = [aCoder decodeObjectForKey:"NSTitle"];
// _font = [aCoder decodeObjectForKey:"NSTitle"];
@@ -89,7 +91,6 @@
@end
@implementation NSMenuItemCell : NSButtonCell
{
}
+3 -3
View File
@@ -31,14 +31,14 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
_frame = CGRectMakeZero();
if ([aCoder containsValueForKey:@"NSFrame"])
_frame = [aCoder decodeRectForKey:@"NSFrame"];
else if ([aCoder containsValueForKey:@"NSFrameSize"])
_frame.size = [aCoder decodeSizeForKey:@"NSFrameSize"];
_frame.size = [aCoder decodeSizeForKey:@"NSFrameSize"];
self = [super NS_initWithCoder:aCoder];
if (self)
{
_tag = -1;
+1 -1
View File
@@ -14,7 +14,7 @@ $ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'nib2cib')
ObjectiveJ::BundleTask.new(:nib2cib) do |t|
t.name = 'nib2cib'
t.identifier = 'com.280n.nib2cib'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'nib2cib converts Cocoa nib and xibs to Cappuccino cibs'
+3 -3
View File
@@ -125,7 +125,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
return;
}
var data = [CPData dataWithString:File.read(String(temporaryPlistFilePath), { charset:"UTF8" })];
var data = [CPData dataWithString:File.read(String(temporaryPlistFilePath), { charset:"UTF-8" })];
// Minor NSKeyedArchive to CPKeyedArchive conversion.
[data setString:[data string].replace(/\<key\>\s*CF\$UID\s*\<\/key\>/g, "<key>CP$UID</key>")];
@@ -141,7 +141,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
[archiver encodeObject:objectData forKey:@"CPCibObjectDataKey"];
[archiver finishEncoding];
File.write(outputFileName, [data string], { charset:"UTF8" });
File.write(outputFileName, [data string], { charset:"UTF-8" });
}
function loadFrameworks(frameworkPaths, aCallback)
@@ -159,7 +159,7 @@ function loadFrameworks(frameworkPaths, aCallback)
java.lang.System.exit(1);
}
var infoDictionary = CPPropertyListCreateFromData([CPData dataWithString:File.read(frameworkPath + "/Info.plist", { charset:"UTF8" })]);
var infoDictionary = CPPropertyListCreateFromData([CPData dataWithString:File.read(frameworkPath + "/Info.plist", { charset:"UTF-8" })]);
if ([infoDictionary objectForKey:@"CPBundlePackageType"] !== "FMWK")
{
+1 -1
View File
@@ -16,7 +16,7 @@ $ENVIRONMENT_BRIDGE = File.join($ENVIRONMENT_LIB_DIR, 'press', 'bridge.js')
ObjectiveJ::BundleTask.new(:press) do |t|
t.name = 'press'
t.identifier = 'com.280n.press'
t.version = '0.7.0'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'Deployment tool for Cappuccino applications'
+1 -1
View File
@@ -239,7 +239,7 @@ function main()
// add fake bundle response bookkeeping
applicationJS.push("var __fakeDidReceiveBundleResponse = " + String(fakeDidReceiveBundleResponse));
applicationJS.push("var __fakeBundleArchives = " + CPJSObjectCreateJSON(bundleArchives) + ";");
applicationJS.push("var __fakeBundleArchives = " + JSON.stringify(bundleArchives) + ";");
applicationJS.push("for (var i = 0; i < __fakeBundleArchives.length; i++) __fakeDidReceiveBundleResponse(__fakeBundleArchives[i]);")
// add each fragment, wrapped in a function, along with OBJJ_CURRENT_BUNDLE bookkeeping