mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 22:51:28 +00:00
Fix for CPBundle loading all code. Fixes external frameworks with nib2cib.
Reviewed by me.
This commit is contained in:
@@ -132,7 +132,7 @@ var CPBundlesForPaths = { };
|
||||
CPLog.error("Could not find bundle: " + self);
|
||||
});
|
||||
|
||||
_bundle.load(NO);
|
||||
_bundle.load(YES);
|
||||
}
|
||||
|
||||
- (CPArray)staticResourceURLs
|
||||
|
||||
+23
-9
@@ -426,35 +426,49 @@ CFBundle.dataContentsAtPath = function(/*String*/ aPath)
|
||||
return data;
|
||||
}
|
||||
|
||||
function executeBundle(/*Bundle*/ aBundle)
|
||||
function executeBundle(/*Bundle*/ aBundle, /*Function*/ aCallback)
|
||||
{
|
||||
var staticResources = [aBundle._staticResource];
|
||||
var staticResources = [aBundle._staticResource],
|
||||
resourcesPath = aBundle.resourcesPath();
|
||||
|
||||
function executeStaticResources(staticResources, index)
|
||||
function executeStaticResources(index)
|
||||
{
|
||||
for (; index < staticResources.length; ++index)
|
||||
{
|
||||
var staticResource = staticResources[index];
|
||||
var staticResource = staticResources[index],
|
||||
type = staticResource.type();
|
||||
|
||||
if (staticResource.type() === StaticResource.FileType)
|
||||
if (type === StaticResource.FileType)
|
||||
{
|
||||
var executable = new FileExecutable(staticResource.path());
|
||||
|
||||
if (staticResource.hasLoadedFileDependencies())
|
||||
if (executable.hasLoadedFileDependencies())
|
||||
executable.execute();
|
||||
|
||||
else
|
||||
{
|
||||
executable.addEventListeners("dependenciesload", function()
|
||||
executable.addEventListener("dependenciesload", function()
|
||||
{
|
||||
executeStaticResources(index);
|
||||
});
|
||||
executable.loadFileDependencies();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
staticResources = staticResources.concat(staticResource.children());
|
||||
else if (type === StaticResource.DirectoryType)
|
||||
{
|
||||
// We don't want to execute resources.
|
||||
if (staticResource.path() === aBundle.resourcesPath())
|
||||
continue;
|
||||
|
||||
var children = staticResource.children();
|
||||
|
||||
for (var name in children)
|
||||
staticResources.push(children[name]);
|
||||
}
|
||||
}
|
||||
|
||||
aCallback();
|
||||
}
|
||||
|
||||
executeStaticResources(0);
|
||||
|
||||
+27
-38
@@ -193,24 +193,28 @@ Executable.prototype.loadFileDependencies = function()
|
||||
this._fileDependencyLoadStatus = ExecutableLoadingFileDependencies;
|
||||
|
||||
var searchedPaths = [{ }, { }],
|
||||
foundExecutablePaths = { },
|
||||
fileExecutableSearches = new CFMutableDictionary(),
|
||||
incompleteFileExecutableSearches = new CFMutableDictionary(),
|
||||
executablesNeedingEventDispatch = [this];
|
||||
loadingExecutables = { };
|
||||
|
||||
function searchForFileDependencies(/*Executable*/ anExecutable)
|
||||
{
|
||||
if (anExecutable.hasLoadedFileDependencies())
|
||||
return;
|
||||
|
||||
var executables = [anExecutable],
|
||||
executableIndex = 0,
|
||||
executableCount = executables.length;
|
||||
|
||||
for (; executableIndex < executableCount; ++executableIndex)
|
||||
{
|
||||
var executable = executables[executableIndex],
|
||||
cwd = FILE.dirname(executable.path()),
|
||||
var executable = executables[executableIndex];
|
||||
|
||||
if (executable.hasLoadedFileDependencies())
|
||||
continue;
|
||||
|
||||
var executablePath = executable.path();
|
||||
|
||||
loadingExecutables[executablePath] = executable;
|
||||
|
||||
var cwd = FILE.dirname(executablePath),
|
||||
fileDependencies = executable.fileDependencies(),
|
||||
fileDependencyIndex = 0,
|
||||
fileDependencyCount = fileDependencies.length;
|
||||
@@ -236,10 +240,7 @@ Executable.prototype.loadFileDependencies = function()
|
||||
|
||||
if (fileExecutableSearch.isComplete())
|
||||
{
|
||||
var newFileExecutable = fileExecutableSearch.result();
|
||||
|
||||
foundExecutablePaths[newFileExecutable.path()] = executable;
|
||||
executables.push(newFileExecutable);
|
||||
executables.push(fileExecutableSearch.result());
|
||||
++executableCount;
|
||||
}
|
||||
|
||||
@@ -249,13 +250,11 @@ Executable.prototype.loadFileDependencies = function()
|
||||
|
||||
fileExecutableSearch.addEventListener("complete", function( anEvent)
|
||||
{
|
||||
var fileExecutableSearch = anEvent.fileExecutableSearch,
|
||||
fileExecutable = fileExecutableSearch.result();
|
||||
var fileExecutableSearch = anEvent.fileExecutableSearch;
|
||||
|
||||
foundExecutablePaths[fileExecutable.path()] = fileExecutable;
|
||||
incompleteFileExecutableSearches.removeValueForKey(fileExecutableSearch.UID());
|
||||
|
||||
searchForFileDependencies(fileExecutable);
|
||||
searchForFileDependencies(fileExecutableSearch.result());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -274,31 +273,21 @@ Executable.prototype.loadFileDependencies = function()
|
||||
CPLog("DEPENDENCY: Ended");
|
||||
#endif
|
||||
|
||||
for (var executablePath in foundExecutablePaths)
|
||||
if (hasOwnProperty.apply(foundExecutablePaths, [executablePath]))
|
||||
{
|
||||
var fileExecutable = new FileExecutable(executablePath);
|
||||
//CPLog("no go for... " + fileExecutable.path());
|
||||
if (fileExecutable.hasLoadedFileDependencies())
|
||||
continue;
|
||||
for (var path in loadingExecutables)
|
||||
if (hasOwnProperty.call(loadingExecutables, path))
|
||||
loadingExecutables[path]._fileDependencyLoadStatus = ExecutableLoadedFileDependencies;
|
||||
|
||||
executablesNeedingEventDispatch.push(fileExecutable);
|
||||
fileExecutable._fileDependencyLoadStatus = FileExecutableLoadedDependencies;
|
||||
for (var path in loadingExecutables)
|
||||
if (hasOwnProperty.call(loadingExecutables, path))
|
||||
{
|
||||
var executable = loadingExecutables[path];
|
||||
|
||||
executable._eventDispatcher.dispatchEvent(
|
||||
{
|
||||
type:"dependenciesload",
|
||||
fileExecutable:executable
|
||||
});
|
||||
}
|
||||
|
||||
var index = 0,
|
||||
count = executablesNeedingEventDispatch.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var fileExecutable = executablesNeedingEventDispatch[index];
|
||||
|
||||
fileExecutable._eventDispatcher.dispatchEvent(
|
||||
{
|
||||
type:"dependenciesload",
|
||||
fileExecutable:fileExecutable
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
searchForFileDependencies(this);
|
||||
|
||||
@@ -48,17 +48,9 @@ function loadFrameworks(frameworkPaths, aCallback)
|
||||
|
||||
frameworkPaths.forEach(function(aFrameworkPath)
|
||||
{
|
||||
var infoPlistPath = FILE.join(aFrameworkPath, "Info.plist");
|
||||
|
||||
if (!FILE.isReadable(infoPlistPath))
|
||||
{
|
||||
print("'" + aFrameworkPath + "' is not a framework or could not be found.");
|
||||
OS.exit(1);
|
||||
}
|
||||
|
||||
print("Loading " + aFrameworkPath);
|
||||
|
||||
var frameworkBundle = [[CPBundle alloc] initWithPath:infoPlistPath];
|
||||
var frameworkBundle = [[CPBundle alloc] initWithPath:aFrameworkPath];
|
||||
|
||||
[frameworkBundle loadWithDelegate:nil];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user