Fix to make the Cappuccino framework compile with rhino

This commit is contained in:
Martin Carlberg
2013-01-10 11:21:45 +01:00
parent 89da16afec
commit c192f3b47b
2 changed files with 27 additions and 1 deletions
@@ -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)
{}
@@ -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" });
});