Fix for objj command line tool not working.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2010-01-31 18:36:36 -08:00
1 parent d4f3f83212
commit e64a9a7ab9
4 files changed
+39 -17

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ rootNode.resolveSubPath(cwd, StaticResourceNode.DirectoryType, function(cwdNode)
#ifdef BROWSER
OBJJ_MAIN_FILE = "main.j";
fileImporterForPath(FILE.join(cwd, "main.j"))("main.j", YES, function()
fileImporterForPath(cwd)("main.j", YES, function()
{
afterDocumentLoad(main);
});
+25 -1
View File
@@ -111,6 +111,30 @@ exports.run = function(args)
}
}
function objj_eval(/*String*/ aString)
{
// We need this while code still refers to window.
Executable.setCommonJSArguments(require, exports, module, system, print, window);
var executable = preprocess(aString, "", 0);
if (!executable.hasLoadedFileDependencies())
executable.loadFileDependencies();
// A bit of a hack. Executable compiles the code itself into a function, but we want
// the raw code to eval here.
var code = executable._code;
// Not clear why these should be global, varing them doesn't seem to take effect with evaluateString.
global.objj_executeFile = fileExecuterForPath(FILE.cwd());
global.objj_importFile = fileImporterForPath(FILE.cwd());
if (typeof system !== "undefined" && system.engine === "rhino")
return Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(global, code, "objj_eval", 0, NULL);
return eval(code);
}
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
// creates a narwhal factory function in the objj module scope
@@ -120,7 +144,7 @@ exports.make_narwhal_factory = function(path)
{
Executable.setCommonJSArguments(require, exports, module, system, print, window);
fileImporterForPath(path)(FILE.basename(path), function()
fileImporterForPath(FILE.dirname(path))(path, function()
{
print("all done");
});
+7 -9
View File
@@ -86,8 +86,8 @@ Executable.prototype.functionParameters = function()
Executable.prototype.functionArguments = function()
{
var path = this.path(),
functionArguments = [global, fileExecuterForPath(path), fileImporterForPath(path)];
var dirname = FILE.dirname(this.path()),
functionArguments = [global, fileExecuterForPath(dirname), fileImporterForPath(dirname)];
//functionArguments = exportedValues().concat(fileExecuterForPath(path), fileImporterForPath(path));
@@ -170,9 +170,8 @@ Executable.prototype.loadFileDependencies = function()
var searchedPaths = [{ }, { }],
foundExecutablePaths = { },
fileExecutableSearches = new CFMutableDictionary(),
incompleteFileExecutableSearches = new CFMutableDictionary();
foundExecutablePaths[this.path()] = this;
incompleteFileExecutableSearches = new CFMutableDictionary(),
executablesNeedingEventDispatch = [this];
function searchForFileDependencies(/*Executable*/ anExecutable)
{
@@ -249,7 +248,6 @@ Executable.prototype.loadFileDependencies = function()
CPLog("DEPENDENCY: Ended");
#end
var fileExecutablesNeedingEventDispatch = [];
for (var executablePath in foundExecutablePaths)
if (hasOwnProperty.apply(foundExecutablePaths, [executablePath]))
@@ -259,16 +257,16 @@ Executable.prototype.loadFileDependencies = function()
if (fileExecutable.hasLoadedFileDependencies())
continue;
fileExecutablesNeedingEventDispatch.push(fileExecutable);
executablesNeedingEventDispatch.push(fileExecutable);
fileExecutable._fileDependencyLoadStatus = FileExecutableLoadedDependencies;
}
var index = 0,
count = fileExecutablesNeedingEventDispatch.length;
count = executablesNeedingEventDispatch.length;
for (; index < count; ++index)
{
var fileExecutable = fileExecutablesNeedingEventDispatch[index];
var fileExecutable = executablesNeedingEventDispatch[index];
fileExecutable._eventDispatcher.dispatchEvent(
{
+6 -6
View File
@@ -24,15 +24,15 @@ var cachedFileExecutersForPaths = { };
function fileExecuterForPath(/*String*/ referencePath)
{
referencePath = FILE.normal(referencePath);
var fileExecuter = cachedFileExecutersForPaths[referencePath];
if (!fileExecuter)
{
var dirname = FILE.dirname(referencePath);
fileExecuter = function(/*String*/ aPath, /*BOOL*/ isLocal, /*BOOL*/ shouldForce)
{
aPath = importablePath(aPath, isLocal, dirname);
aPath = importablePath(aPath, isLocal, referencePath);
var fileExecutableSearch = new FileExecutableSearch(aPath, isLocal),
fileExecutable = fileExecutableSearch.result();
@@ -53,15 +53,15 @@ var cachedImportersForPaths = { };
function fileImporterForPath(/*String*/ referencePath)
{
referencePath = FILE.normal(referencePath);
var cachedImporter = cachedImportersForPaths[referencePath];
if (!cachedImporter)
{
var dirname = FILE.dirname(referencePath);
cachedImporter = function(/*String*/ aPath, /*BOOL*/ isLocal, /*Function*/ aCallback)
{
aPath = importablePath(aPath, isLocal, dirname);
aPath = importablePath(aPath, isLocal, referencePath);
var fileExecutableSearch = new FileExecutableSearch(aPath, isLocal);