Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:280north/cappuccino
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Boucher committed Dec 22, 2008
2 parents 8b68729 + 3b299aa commit 670efb1
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 24 deletions.
2 changes: 1 addition & 1 deletion AppKit/CPMenu.j
Expand Up @@ -100,7 +100,7 @@ var _CPMenuBarVisible = NO,
[_CPMenuBarSharedWindow orderFront:self];
}
else
[_CPMenuBarWindow orderOut:self];
[_CPMenuBarSharedWindow orderOut:self];

// FIXME: There must be a better way to do this.
#if PLATFORM(DOM)
Expand Down
18 changes: 17 additions & 1 deletion Foundation/CPKeyedUnarchiver.j
Expand Up @@ -316,14 +316,30 @@ var _CPKeyedUnarchiverArrayClass = Ni

if ([object isKindOfClass:_CPKeyedUnarchiverDictionaryClass])
return _CPKeyedUnarchiverDecodeObjectAtIndex(self, [object objectForKey:_CPKeyedArchiverUIDKey]);
else if ([object isKindOfClass:[CPNumber class]])
else if ([object isKindOfClass:[CPNumber class]] || [object isKindOfClass:[CPData class]])
return object;
/* else
alert([object className] + " " + object + " " + aKey + " " + [_plistObject description]);*/

return nil;
}

/*
Decodes bytes from the archive.
@param aKey the object's associated key
@return array of bytes
*/
- (id)decodeBytesForKey:(CPString)aKey
{
// We get the CPData wrapper, then extract the bytes array
var data = [self decodeObjectForKey:aKey];

if ([data isKindOfClass:[CPData class]])
return data.bytes;

return nil;
}

/*
Notifies the delegates that decoding has finished.
*/
Expand Down
6 changes: 3 additions & 3 deletions Foundation/CPLog.j
Expand Up @@ -82,9 +82,9 @@ function _CPLogDispatch(parameters, aLevel, aTitle)
if (aLevel == undefined)
aLevel = CPLogDefaultLevel;

// to format message: use sprintf if available; otherwise do a simple join
var message = (typeof sprintf == "function") ? sprintf.apply(null, parameters) : Array.prototype.join.call(parameters, ", ");

// use sprintf if param 0 is a string and there is more than one param. otherwise just convert param 0 to a string
var message = (typeof parameters[0] == "string" && parameters.length > 1) ? sprintf.apply(null, parameters) : String(parameters[0]);
if (_CPLogRegistrations[aLevel])
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
_CPLogRegistrations[aLevel][i](message, aLevel, aTitle);
Expand Down
3 changes: 2 additions & 1 deletion Objective-J/plist.js
Expand Up @@ -360,7 +360,8 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
case PLIST_BOOLEAN_FALSE: object = false;
break;

case PLIST_DATA: object = FIRST_CHILD(XMLNode) ? CHILD_VALUE(XMLNode) : ""; // FIXME: temporary fix for NIBs with <data> tags
case PLIST_DATA: object = new objj_data();
object.bytes = FIRST_CHILD(XMLNode) ? base64_decode_to_array(CHILD_VALUE(XMLNode), true) : [];
break;

default: objj_exception_throw(new objj_exception(OBJJPlistParseException, "*** " + NODE_NAME(XMLNode) + " tag not recognized in Plist."));
Expand Down
8 changes: 7 additions & 1 deletion Objective-J/utilities.js
Expand Up @@ -254,7 +254,13 @@ function base64_encode_array(input)

function base64_decode_to_string(input, strip)
{
return String.fromCharCode.apply(null, base64_decode_to_array(input, strip));
return bytes_to_string(base64_decode_to_array(input, strip));
}

function bytes_to_string(bytes)
{
// This is relatively efficient, I think:
return String.fromCharCode.apply(null, bytes);
}

function base64_encode_string(input)
Expand Down
14 changes: 7 additions & 7 deletions Tools/NibApp/MainMenu.xib
Expand Up @@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1" id="9"/>
<integer value="106"/>
<integer value="13"/>
<integer value="15"/>
</object>
Expand Down Expand Up @@ -146,7 +146,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="12" id="779933340"/>
<reference ref="779933340"/>
<reference ref="9"/>
<integer value="1" id="9"/>
</object>
</object>
</object>
Expand Down Expand Up @@ -380,7 +380,7 @@
<bool key="NSIsNotContinuous">YES</bool>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4wNTgxMzA0OTkgMC4wNTU1NDE4OTkgMQA</bytes>
<bytes key="NSRGB">MC4zNzUyMzAzNyAwLjQ1NjE5NzE0IDEAA</bytes>
</object>
</object>
<object class="NSColorWell" id="426656007">
Expand All @@ -398,7 +398,7 @@
<bool key="NSEnabled">YES</bool>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4wNTgxMzA0OTkgMC4wNTU1NDE4OTkgMQA</bytes>
<bytes key="NSRGB">MSAwLjE3MjgzOTUyIDAuMTcyODM5NTIAA</bytes>
</object>
</object>
<object class="NSButton" id="684874808">
Expand Down Expand Up @@ -3327,7 +3327,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{199, 438}, {480, 303}}</string>
<string>{{438, 741}, {480, 303}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{628, 654}</string>
<string>{{257, 484}, {480, 272}}</string>
Expand All @@ -3352,7 +3352,7 @@
<string>{{56, 843}, {299, 193}}</string>
<reference ref="9"/>
<string>{{115, 207}, {299, 193}}</string>
<integer value="0"/>
<integer value="0" id="8"/>
<reference ref="9"/>
<string>{299, 193}</string>
<string>{299, 193}</string>
Expand All @@ -3373,7 +3373,7 @@
<string>{{0, 822}, {276, 323}}</string>
<reference ref="9"/>
<string>{{118, 105}, {276, 323}}</string>
<integer value="0"/>
<reference ref="8"/>
<string>{3.40282e+38, 3.40282e+38}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down
85 changes: 83 additions & 2 deletions Tools/nib2cib/NSColor.j
Expand Up @@ -2,6 +2,9 @@
* NSColor.j
* nib2cib
*
* Portions based on NSColor.m (12/18/2008) in Cocotron (http://www.cocotron.org/)
* Copyright (c) 2006-2007 Christopher J. W. Lloyd
*
* Created by Thomas Robinson.
* Copyright 2008, 280 North, Inc.
*
Expand Down Expand Up @@ -35,8 +38,86 @@ var NSUnknownColorSpaceModel = -1,

- (id)NS_initWithCoder:(CPCoder)aCoder
{
//var colorSpace = [aCoder decodeIntForKey:@"NSColorSpace"];
return self = [CPColor blueColor];
var colorSpace = [aCoder decodeIntForKey:@"NSColorSpace"],
result;

switch (colorSpace)
{
case 1: // [NSColor colorWithCalibratedRed:values[0] green:values[1] blue:values[2] alpha:values[3]];
case 2: // [NSColor colorWithDeviceRed:values[0] green:values[1] blue:values[2] alpha:values[3]];

// NSComponents data
// NSCustomColorSpace NSColorSpace
var rgb = [aCoder decodeBytesForKey:@"NSRGB"],
string = bytes_to_string(rgb),
components = [string componentsSeparatedByString:@" "],
values = [0,0,0,1];

for (var i = 0; i < components.length && i < 4; i++)
values[i] = [components[i] floatValue];

CPLog.warn("rgb="+rgb+" string=" + string + " values=" + values);

result = [CPColor colorWithCalibratedRed:values[0] green:values[1] blue:values[2] alpha:values[3]];
break;

case 3: // [NSColor colorWithCalibratedWhite:values[0] alpha:values[1]];
case 4: // [NSColor colorWithDeviceWhite:values[0] alpha:values[1]];

var bytes = [aCoder decodeBytesForKey:@"NSWhite"],
string = bytes_to_string(rgb),
components = [string componentsSeparatedByString:@" "],
values = [0,1];

for (var i = 0; i < components.length && i < 2; i++)
values[i] = [components[i] floatValue];

result = [CPColor colorWithCalibratedWhite:values[0] alpha:values[1]];
break;
/*
case 5:
var cmyk = [aCoder decodeBytesForKey:@"NSCMYK"],
string = bytes_to_string(rgb),
components = [string componentsSeparatedByString:@" "],
values = [0,0,0,0,1];
for (var i = 0; i < components.length && i < 5; i++)
values[i] = [components[i] floatValue];
result = [CPColor colorWithDeviceCyan:values[0] magenta:values[1] yellow:values[2] black:values[3] alpha:values[4]];
break;
*/
case 6:
var catalogName = [aCoder decodeObjectForKey:@"NSCatalogName"],
colorName = [aCoder decodeObjectForKey:@"NSColorName"],
color = [aCoder decodeObjectForKey:@"NSColor"];

// We don't having color mappings implemented, so just use the cached NSColor

if (catalogName === @"System")
{
var //display = [NSDisplay currentDisplay],
result = null;//[display colorWithName: colorName];
if (!result)
{
result = color;
//[display _addSystemColor: result forName: colorName];
}
}
else
{
result = null;//[CPColor colorWithCatalogName: catalogName colorName: colorName];
if (!result)
result = color;
}
break;
default:
CPLog(@"-[%@ %s] unknown color space %d", isa, _cmd, colorSpace);
result = [CPColor blackColor];
break;
}

return result;
}

@end
Expand Down
6 changes: 0 additions & 6 deletions Tools/nib2cib/build.xml
Expand Up @@ -19,12 +19,6 @@
<steam-build>
<arg line = "-f nib2cib.steam -c ${Configuration} -t nib2cib" />
</steam-build>

<copy todir = "${Build.nib2cib.lib}">
<fileset dir = "${Build}/${Configuration}/nib2cib/" />
</copy>

<copy file = "nib2cib" tofile = "${Build.nib2cib.bin}/nib2cib" />

</target>

Expand Down
5 changes: 3 additions & 2 deletions build.xml
Expand Up @@ -242,15 +242,16 @@
<copy todir = "${Build.Cappuccino.Tools.Bin}">
<fileset dir = "${Build}/Release/bake/bin" />
<fileset dir = "${Build}/Release/cplutil/bin" />
<fileset dir = "${Build}/Release/nib2cib/bin" />
<fileset dir = "${Build}/Release/objj/bin" />
<fileset dir = "${Build}/Release/objjc/bin" />
<fileset dir = "${Build}/Release/press/bin" />
<fileset dir = "${Build}/Release/steam/bin" />
</copy>

<copy file = "Tools/nib2cib/nib2cib" todir = "${Build.Cappuccino.Tools.Bin}" />

<copy todir = "${Build.Cappuccino.Tools.Lib}/nib2cib">
<fileset dir = "${Build}/Release/nib2cib/lib" />
<fileset dir = "${Build}/Release/nib2cib" />
</copy>

<copy todir = "${Build.Cappuccino.Tools.Lib}">
Expand Down

0 comments on commit 670efb1

Please sign in to comment.