diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index 2979e2034..202781a71 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -132,7 +132,7 @@ var CPBundlesForPaths = { }; CPLog.error("Could not find bundle: " + self); }); - _bundle.load(NO); + _bundle.load(YES); } - (CPArray)staticResourceURLs diff --git a/Objective-J/CFBundle.js b/Objective-J/CFBundle.js index 6c3095960..c8bbfde8a 100644 --- a/Objective-J/CFBundle.js +++ b/Objective-J/CFBundle.js @@ -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); diff --git a/Objective-J/Executable.js b/Objective-J/Executable.js index 8ac69954a..66c9b82ad 100644 --- a/Objective-J/Executable.js +++ b/Objective-J/Executable.js @@ -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); diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index ef755d9b9..70f6bc359 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -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];