mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-14 02:33:50 +00:00
Fix for classes declared in subfolders reporting wrong bundle (fictional).
Reviewed by me.
This commit is contained in:
1 parent
6dbb4eedb7
commit
3ae4b1cf19
2 files changed
+59
-5
No files matched your search
+58
-5
@@ -49,6 +49,7 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
|
||||
this._resourcesDirectoryURL = new CFURL("Resources/", aURL);
|
||||
|
||||
this._staticResource = NULL;
|
||||
this._isValid = NO;
|
||||
|
||||
this._loadStatus = CFBundleUnloaded;
|
||||
this._loadRequests = [];
|
||||
@@ -58,34 +59,47 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
|
||||
this._eventDispatcher = new EventDispatcher(this);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle);
|
||||
|
||||
CFBundle.environments = function()
|
||||
{
|
||||
// Passed in by GCC.
|
||||
return ENVIRONMENTS;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.environments);
|
||||
|
||||
CFBundle.bundleContainingURL = function(/*CFURL|String*/ aURL)
|
||||
{
|
||||
aURL = new CFURL(".", makeAbsoluteURL(aURL));
|
||||
|
||||
while (aURL.path() !== "/")
|
||||
{
|
||||
var bundle = CFBundlesForURLStrings[aURL.absoluteString()];
|
||||
var previousURLString,
|
||||
URLString = aURL.absoluteString();
|
||||
|
||||
if (bundle)
|
||||
while (!previousURLString || previousURLString !== URLString)
|
||||
{
|
||||
var bundle = CFBundlesForURLStrings[URLString];
|
||||
|
||||
if (bundle && bundle._isValid)
|
||||
return bundle;
|
||||
|
||||
aURL = new CFURL("..", aURL);
|
||||
previousURLString = URLString;
|
||||
URLString = aURL.absoluteString();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.bundleContainingURL);
|
||||
|
||||
CFBundle.mainBundle = function()
|
||||
{
|
||||
return new CFBundle(mainBundleURL);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.mainBundle);
|
||||
|
||||
function addClassToBundle(aClass, aBundle)
|
||||
{
|
||||
if (aBundle)
|
||||
@@ -97,16 +111,22 @@ CFBundle.bundleForClass = function(/*Class*/ aClass)
|
||||
return CFBundlesForClasses[aClass.name] || CFBundle.mainBundle();
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.bundleForClass);
|
||||
|
||||
CFBundle.prototype.bundleURL = function()
|
||||
{
|
||||
return this._bundleURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.bundleURL);
|
||||
|
||||
CFBundle.prototype.resourcesDirectoryURL = function()
|
||||
{
|
||||
return this._resourcesDirectoryURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.resourcesDirectoryURL);
|
||||
|
||||
CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ aType, /*String*/ aSubDirectory)
|
||||
{
|
||||
if (aType)
|
||||
@@ -120,6 +140,8 @@ CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ a
|
||||
return resourceURL.absoluteURL();
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.resourceURL);
|
||||
|
||||
CFBundle.prototype.mostEligibleEnvironmentURL = function()
|
||||
{
|
||||
if (this._mostEligibleEnvironmentURL === undefined)
|
||||
@@ -128,6 +150,8 @@ CFBundle.prototype.mostEligibleEnvironmentURL = function()
|
||||
return this._mostEligibleEnvironmentURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironmentURL);
|
||||
|
||||
CFBundle.prototype.executableURL = function()
|
||||
{
|
||||
if (this._executableURL === undefined)
|
||||
@@ -143,16 +167,22 @@ CFBundle.prototype.executableURL = function()
|
||||
return this._executableURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.executableURL);
|
||||
|
||||
CFBundle.prototype.infoDictionary = function()
|
||||
{
|
||||
return this._infoDictionary;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.infoDictionary);
|
||||
|
||||
CFBundle.prototype.valueForInfoDictionaryKey = function(/*String*/ aKey)
|
||||
{
|
||||
return this._infoDictionary.valueForKey(aKey);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.valueForInfoDictionaryKey);
|
||||
|
||||
CFBundle.prototype.hasSpritedImages = function()
|
||||
{
|
||||
var environments = this._infoDictionary.valueForKey("CPBundleEnvironmentsWithImageSprites") || [],
|
||||
@@ -166,11 +196,15 @@ CFBundle.prototype.hasSpritedImages = function()
|
||||
return NO;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.hasSpritedImages);
|
||||
|
||||
CFBundle.prototype.environments = function()
|
||||
{
|
||||
return this._infoDictionary.valueForKey("CPBundleEnvironments") || ["ObjJ"];
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.environments);
|
||||
|
||||
CFBundle.prototype.mostEligibleEnvironment = function(/*Array*/ environments)
|
||||
{
|
||||
environments = environments || this.environments();
|
||||
@@ -194,11 +228,15 @@ CFBundle.prototype.mostEligibleEnvironment = function(/*Array*/ environments)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironment);
|
||||
|
||||
CFBundle.prototype.isLoading = function()
|
||||
{
|
||||
return this._loadStatus & CFBundleLoading;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.isLoading);
|
||||
|
||||
CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
{
|
||||
if (this._loadStatus !== CFBundleUnloaded)
|
||||
@@ -223,7 +261,13 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
function onsuccess(/*Event*/ anEvent)
|
||||
{
|
||||
self._loadStatus &= ~CFBundleLoadingInfoPlist;
|
||||
self._infoDictionary = anEvent.request.responsePropertyList();
|
||||
|
||||
var infoDictionary = anEvent.request.responsePropertyList();
|
||||
|
||||
self._isValid = !!infoDictionary || CFBundle.mainBundle() === self;
|
||||
|
||||
if (infoDictionary)
|
||||
self._infoDictionary = infoDictionary;
|
||||
|
||||
if (!self._infoDictionary)
|
||||
{
|
||||
@@ -240,6 +284,7 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
|
||||
function onfailure()
|
||||
{
|
||||
self._isValid = CFBundle.mainBundle() === self;
|
||||
self._loadStatus = CFBundleUnloaded;
|
||||
|
||||
finishBundleLoadingWithError(self, new Error("Could not load bundle at \"" + self.bundleURL() + "\""));
|
||||
@@ -249,6 +294,8 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
});
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.load);
|
||||
|
||||
function finishBundleLoadingWithError(/*CFBundle*/ aBundle, /*Event*/ anError)
|
||||
{
|
||||
resolveStaticResource(aBundle._staticResource);
|
||||
@@ -615,16 +662,22 @@ CFBundle.prototype.addEventListener = function(/*String*/ anEventName, /*Functio
|
||||
this._eventDispatcher.addEventListener(anEventName, anEventListener);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.addEventListener);
|
||||
|
||||
CFBundle.prototype.removeEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
|
||||
{
|
||||
this._eventDispatcher.removeEventListener(anEventName, anEventListener);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.removeEventListener);
|
||||
|
||||
CFBundle.prototype.onerror = function(/*Event*/ anEvent)
|
||||
{
|
||||
throw anEvent.error;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.onerror);
|
||||
|
||||
CFBundle.prototype.bundlePath = function()
|
||||
{
|
||||
return this._bundleURL.absoluteURL().path();
|
||||
|
||||
@@ -137,6 +137,7 @@ Executable.prototype.execute = function()
|
||||
#endif
|
||||
var oldContextBundle = CONTEXT_BUNDLE;
|
||||
|
||||
// FIXME: Should we have stored this?
|
||||
CONTEXT_BUNDLE = CFBundle.bundleContainingURL(this.URL());
|
||||
|
||||
var result = this._function.apply(global, this.functionArguments());
|
||||
|
||||
Reference in new issue
Block a user