diff --git a/Objective-J/Bootstrap.js b/Objective-J/Bootstrap.js index 53d476812..fb314e625 100644 --- a/Objective-J/Bootstrap.js +++ b/Objective-J/Bootstrap.js @@ -13,11 +13,33 @@ rootNode.resolveSubPath(cwd, StaticResourceNode.DirectoryType, function(cwdNode) for (; index < count; ++index) cwdNode.nodeAtSubPath(FILE.normal(includePaths[index]), YES); -#ifndef RHINO +#ifdef BROWSER + OBJJ_MAIN_FILE = "main.j"; + fileImporterForPath(FILE.join(cwd, "main.j"))("main.j", YES, function() { - console.log(rootNode.toString(true)); - console.log("done."); + afterDocumentLoad(main); }); #endif -}); \ No newline at end of file +}); + +#ifdef BROWSER +function afterDocumentLoad(/*Function*/ aFunction) +{ + if (documentLoaded) + return aFunction(); + + if (window.addEventListener) + window.addEventListener("load", aFunction, false); + + else if (window.attachEvent) + window.attachEvent("onload", aFunction); +} + +var documentLoaded = NO; + +afterDocumentLoad(function() +{ + documentLoaded = YES; +}); +#endif diff --git a/Objective-J/Executable.js b/Objective-J/Executable.js index f73bc3fd2..4ae4972fb 100644 --- a/Objective-J/Executable.js +++ b/Objective-J/Executable.js @@ -43,8 +43,8 @@ function Executable(/*String*/ aCode, /*Array*/ fileDependencies, /*String*/ aSc var code = this._code; -#if RHINO - code = "function(\"" + this.functionParameters().join("\",\"" + "\"){" + code + "/**/\n}"; +#if COMMONJS + code = "function(" + this.functionParameters().join(" , ") + "){" + code + "/**/\n}"; if (typeof system !== "undefined" && system.engine === "rhino") this._function = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, code, this._scope, 0, null); diff --git a/Objective-J/Jakefile b/Objective-J/Jakefile index 79daf79fb..e57d29828 100644 --- a/Objective-J/Jakefile +++ b/Objective-J/Jakefile @@ -88,7 +88,11 @@ CLOBBER.include($BUILD_OBJECTIVE_J); function environmentFlags() { - return "-DENVIRONMENTS=\"[" + Array.prototype.map.apply(arguments, [function(anEnvironment) { + return Array.prototype.map.apply(arguments, [function(anEnvironment) + { + return "-D" + anEnvironment.toUpperCase(); + }]).join(" ") + + " -DENVIRONMENTS=\"[" + Array.prototype.map.apply(arguments, [function(anEnvironment) { return "\\\"" + anEnvironment + "\\\""; }]).join(", ") + "]\""; } diff --git a/Objective-J/Scope.js b/Objective-J/Scope.js index 52aaf1f0d..980074252 100644 --- a/Objective-J/Scope.js +++ b/Objective-J/Scope.js @@ -114,10 +114,14 @@ function fileImporterForPath(/*String*/ referencePath) fileExecutable.addEventListener("dependenciesload", function() { fileExecuter(aPath, isLocal); + aCallback(); }); } else + { fileExecuter(aPath, isLocal); + aCallback(); + } } if (fileExecutableSearch.isComplete())