Further blend work.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2010-01-29 08:04:00 -08:00
1 parent 794d8a754c
commit b5ad030e40
8 files changed
+69 -62

No files matched your search

+2 -2
View File
@@ -43,7 +43,7 @@
if (self)
{
_bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"];
_bundle = [[CPBundle alloc] initWithPath:aURL];
}
return self;
@@ -65,7 +65,7 @@
{
var path = [aBundle pathForResource:themes[count]],
unarchiver = [[_CPThemeKeyedUnarchiver alloc]
initForReadingWithData:[CPData dataWithString:objj_files[path].contents]
initForReadingWithData:[[CPURL URLWithString:path] staticResourceData]
bundle:_bundle];
[unarchiver decodeObjectForKey:@"root"];
+1 -1
View File
@@ -171,7 +171,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
{
_data = [CPData dataWithString:data];
_data = [CPData dataWithEncodedString:data];
}
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
+6
View File
@@ -200,6 +200,12 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
[_resourceValues setObject:anObject forKey:aKey];
}
- (CPString)staticResourceData
{
// FIXME: This probably shouldn't go through CFBundle for no reason.
return CFBundle.dataContentsAtPath([self path]);
}
@end
@implementation CPURL (CPCoding)
+39 -27
View File
@@ -26,12 +26,6 @@
@import "CPURLResponse.j"
var XMLHTTPRequestUninitialized = 0,
XMLHTTPRequestLoading = 1,
XMLHTTPRequestLoaded = 2,
XMLHTTPRequestInteractive = 3,
XMLHTTPRequestComplete = 4;
var CPURLConnectionDelegate = nil;
/*!
@@ -84,8 +78,8 @@ var CPURLConnectionDelegate = nil;
id _delegate;
BOOL _isCanceled;
BOOL _isLocalFileConnection;
XMLHTTPRequest _XMLHTTPRequest;
HTTPRequest _HTTPRequest;
}
+ (void)setClassDelegate:(id)delegate
@@ -100,12 +94,12 @@ var CPURLConnectionDelegate = nil;
@param anError not used
@return the data at the URL or \c nil if there was an error
*/
+ (CPData)sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:({CPURLResponse})aURLResponse error:({CPError})anError
+ (CPData)sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:({CPURLResponse})aURLResponse
{
try
{
var request = objj_request_xmlhttp();
var request = new HTTPRequest();
request.open([aRequest HTTPMethod], [[aRequest URL] absoluteString], NO);
var fields = [aRequest allHTTPHeaderFields],
@@ -117,7 +111,7 @@ var CPURLConnectionDelegate = nil;
request.send([aRequest HTTPBody]);
return [CPData dataWithString:request.responseText];
return [CPData dataWithEncodedString:request.responseText()];
}
catch (anException)
{
@@ -163,7 +157,7 @@ var CPURLConnectionDelegate = nil;
window.location &&
(window.location.protocol === "file:" || window.location.protocol === "app:"));
_XMLHTTPRequest = objj_request_xmlhttp();
_HTTPRequest = new HTTPRequest();
if (shouldStartImmediately)
[self start];
@@ -194,18 +188,18 @@ var CPURLConnectionDelegate = nil;
try
{
_XMLHTTPRequest.open([_request HTTPMethod], [[_request URL] absoluteString], YES);
_XMLHTTPRequest.onreadystatechange = function() { [self _readyStateDidChange]; }
_HTTPRequest.open([_request HTTPMethod], [[_request URL] absoluteString], YES);
_HTTPRequest.onreadystatechange = function() { [self _readyStateDidChange]; }
var fields = [_request allHTTPHeaderFields],
key = nil,
keys = [fields keyEnumerator];
while (key = [keys nextObject])
_XMLHTTPRequest.setRequestHeader(key, [fields objectForKey:key]);
_XMLHTTPRequest.send([_request HTTPBody]);
_HTTPRequest.setRequestHeader(key, [fields objectForKey:key]);
_HTTPRequest.send([_request HTTPBody]);
}
catch (anException)
{
@@ -223,7 +217,7 @@ var CPURLConnectionDelegate = nil;
try
{
_XMLHTTPRequest.abort();
_HTTPRequest.abort();
}
// We expect an exception in some browsers like FireFox.
catch (anException)
@@ -239,9 +233,9 @@ var CPURLConnectionDelegate = nil;
/* @ignore */
- (void)_readyStateDidChange
{
if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete)
if (_HTTPRequest.readyState() === HTTPRequest.CompleteState)
{
var statusCode = _XMLHTTPRequest.status,
var statusCode = _HTTPRequest.status(),
URL = [_request URL];
if ([_delegate respondsToSelector:@selector(connection:didReceiveResponse:)])
@@ -259,12 +253,12 @@ var CPURLConnectionDelegate = nil;
}
if (!_isCanceled)
{
if (statusCode == 401 && [CPURLConnectionDelegate respondsToSelector:@selector(connectionDidReceiveAuthenticationChallenge:)])
if (statusCode === 401 && [CPURLConnectionDelegate respondsToSelector:@selector(connectionDidReceiveAuthenticationChallenge:)])
[CPURLConnectionDelegate connectionDidReceiveAuthenticationChallenge:self];
else
{
if ([_delegate respondsToSelector:@selector(connection:didReceiveData:)])
[_delegate connection:self didReceiveData:_XMLHTTPRequest.responseText];
[_delegate connection:self didReceiveData:_HTTPRequest.responseText()];
if ([_delegate respondsToSelector:@selector(connectionDidFinishLoading:)])
[_delegate connectionDidFinishLoading:self];
}
@@ -275,9 +269,27 @@ var CPURLConnectionDelegate = nil;
}
/* @ignore */
- (void)_XMLHTTPRequest
- (HTTPRequest)_HTTPRequest
{
return _XMLHTTPRequest;
return _HTTPRequest;
}
@end
@implementation CPURLConnection (Deprecated)
+ (CPData)sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:({CPURLResponse})aURLResponse error:({CPError})anError
{
CPLog.warn("[CPURLConnecton sendSynchronousRequest:returningResponse:error:] is deprecated, using [CPURLConnecton sendSynchronousRequest:returningResponse:] instead.");
return [self sendSynchronousRequest:aRequest returningResponse:aURLResponse error:NULL];
}
- (HTTPRequest)_XMLHTTPRequest
{
CPLog.warn("[CPURLConnecton _XMLHTTPRequest] is deprecated, using _HTTPRequest instead.");
return [self _HTTPRequest];
}
@end
@@ -341,7 +341,7 @@ BundleTask.prototype.infoPlist = function()
var infoPlistPath = this.infoPlistPath();
if (infoPlistPath && FILE.exists(infoPlistPath))
var infoPlist = PropertyList.createFromString(FILE.read(infoPlistPath, { charset:"UTF-8" }));
var infoPlist = PropertyList.propertyListFromString(FILE.read(infoPlistPath, { charset:"UTF-8" }));
else
var infoPlist = new require("objective-j/core").Dictionary();
@@ -372,7 +372,7 @@ BundleTask.prototype.defineInfoPlistTask = function()
filedir (infoPlistProductPath, function()
{
FILE.write(infoPlistProductPath, PropertyList.createStringWithFormat(bundleTask.infoPlist(), PropertyList.Format280North_v1_0), { charset:"UTF-8" });
FILE.write(infoPlistProductPath, PropertyList.stringFromPropertyList(bundleTask.infoPlist(), PropertyList.Format280North_v1_0), { charset:"UTF-8" });
});
var infoPlistPath = this.infoPlistPath();
+2 -1
View File
@@ -48,6 +48,7 @@ Data.prototype.base64 = function()
function MutableData()
{
Data.call(this);
}
MutableData.prototype = new Data();
@@ -82,7 +83,7 @@ MutableData.prototype.setBytes = function(/*Array*/ bytes)
this._bytes = bytes;
}
MutableData.prototype.setEncodedString = function(/*String*/ aBase64String)
MutableData.prototype.setBase64String = function(/*String*/ aBase64String)
{
clearMutableData(this);
+11 -3
View File
@@ -46,6 +46,12 @@ function HTTPRequest()
}
}
HTTPRequest.UninitializedState = 0;
HTTPRequest.LoadingState = 1;
HTTPRequest.LoadedState = 2;
HTTPRequest.InteractiveState = 3;
HTTPRequest.CompleteState = 4;
HTTPRequest.prototype.status = function()
{
try
@@ -109,9 +115,9 @@ HTTPRequest.prototype.responsePropertyList = function()
var responseText = this.responseText();
if (PropertyList.sniffedFormatOfString(responseText) === PropertyList.FormatXML_v1_0)
return PropertyList.createFromXML(this.responseXML());
return PropertyList.propertyListFromXML(this.responseXML());
return PropertyList.createFromString(responseText);
return PropertyList.propertyListFromString(responseText);
}
HTTPRequest.prototype.responseText = function()
@@ -201,6 +207,8 @@ FileRequest.prototype.responseXML = function()
FileRequest.prototype.responsePropertyList = function()
{
return PropertyList.createFromString(this.responseText());
return PropertyList.propertyListFromString(this.responseText());
}
#endif
exports.HTTPRequest = HTTPRequest;
+6 -26
View File
@@ -44,7 +44,7 @@ PropertyList.sniffedFormatOfString = function(/*String*/ aString)
PropertyList.dataFromPropertyList = function(/*PropertyList*/ aPropertyList, /*Format*/ aFormat)
{
return new Data(PropertyList.stringWithPropertyList(aPropertyList, aFormat));
return new Data(PropertyList.stringFromPropertyList(aPropertyList, aFormat));
}
PropertyList.stringFromPropertyList = function(/*PropertyList*/ aPropertyList, /*Format*/ aFormat)
@@ -59,20 +59,6 @@ PropertyList.stringFromPropertyList = function(/*PropertyList*/ aPropertyList, /
serializers["finish"]();
}
PropertyList.createDataWithFormat = function(/*Format*/ aFormat)
{
return new Data(PropertyList.createStringWithFormat(aFormat));
}
PropertyList.createStringWithFormat = function(/*PropertyList*/ aPropertyList, /*Format*/ aFormat)
{
var serializers = PropertyListSerializers[aFormat];
return serializers["start"]() +
serializePropertyList(aPropertyList, serializers) +
serializers["finish"]();
}
function serializePropertyList(/*PropertyList*/ aPropertyList, /*Object*/ serializers)
{
var type = typeof aPropertyList,
@@ -345,24 +331,18 @@ var _plist_traverseNextNode = function(anXMLNode, stayWithin, stack)
return null;
}
console.log("problem...");
PropertyList.createFromData = function(/*Data*/ aData)
PropertyList.propertyListFromData = function(/*Data*/ aData)
{
return PropertyList.createFromStringWithFormat(aData.createStringWithFormat(aFormat), aFormat);
return PropertyList.propertyListFromString(aData.encodedString(), aFormat);
}
PropertyList.createFromString = function(/*String*/ aString)
{
return PropertyList.createFromStringWithFormat(aString);
}
PropertyList.createFromStringWithFormat = function(/*String*/ aString, /*Format*/ aFormat)
PropertyList.propertyListFromString = function(/*String*/ aString, /*Format*/ aFormat)
{
if (!aFormat)
aFormat = PropertyList.sniffedFormatOfString(aString);
if (aFormat === PropertyList.FormatXML_v1_0)
return PropertyList.createFromXML(aString);
return PropertyList.propertyListFromXML(aString);
if (aFormat === PropertyList.Format280North_v1_0)
return propertyListFrom280NorthString(aString);
@@ -463,7 +443,7 @@ function decodeHTMLComponent(/*String*/ aString)
return aString.replace(/&quot;/g, '"').replace(/&apos;/g, '\'').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
}
PropertyList.createFromXML = function(/*String | XMLNode*/ aStringOrXMLNode)
PropertyList.propertyListFromXML = function(/*String | XMLNode*/ aStringOrXMLNode)
{
var XMLNode = aStringOrXMLNode;