diff --git a/Objective-J/CommonJS/lib/objective-j/compiler.js b/Objective-J/CommonJS/lib/objective-j/compiler.js index 49b32b878..173fe0977 100644 --- a/Objective-J/CommonJS/lib/objective-j/compiler.js +++ b/Objective-J/CommonJS/lib/objective-j/compiler.js @@ -82,10 +82,23 @@ function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags, asPlainJavasc absolutePath = FILE.absolute(theTranslatedFilename), basePath = absolutePath.substring(0, absolutePath.length - theTranslatedFilename.length); + // This ugly fix to make Cappuccino compile with rhino can be removed when the compiler is not loading classes into the runtime + var rhinoUglyFix = false; + if (system.engine === "rhino") + { + if (typeof document == "undefined") { + document = { createElement: function(x) { return { innerText: ""}}}; + rhinoUglyFix = true; + } + } + ObjectiveJ.setCurrentCompilerFlags(objjcFlags); ObjectiveJ.make_narwhal_factory(absolutePath, basePath, translateFilenameToPath)(require, {}, module, system, print); executable = new ObjectiveJ.FileExecutable(FILE.basename(aFilePath)); + + if (rhinoUglyFix) + delete document; } catch (anException) {} diff --git a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js index dd3a32ba6..34e7c4c5b 100644 --- a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js +++ b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js @@ -861,7 +861,17 @@ BundleTask.prototype.defineSourceTasks = function() filedir (compiledEnvironmentSource, [aFilename], function() { - var compile + // This ugly fix to make Cappuccino compile with rhino can be removed when the compiler is not loading classes into the runtime + var rhinoUglyFix = false; + if (system.engine === "rhino") + { + if (typeof document == "undefined") { + document = { createElement: function(x) { return { innerText: ""}}}; + rhinoUglyFix = true; + } + } + + var compile; // if this file doesn't exist or isn't a .j file, don't preprocess it. if (FILE.extension(aFilename) !== ".j") { @@ -887,6 +897,9 @@ BundleTask.prototype.defineSourceTasks = function() var compiled = executer.toMarkedString(); } + if (rhinoUglyFix) + delete document; + TERM.stream.print(Array(Math.round(compiled.length / 1024) + 3).join(".")); FILE.write(compiledEnvironmentSource, compiled, { charset:"UTF-8" }); });