mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-03 17:33:41 +00:00
Fix to make the Cappuccino framework compile with rhino
This commit is contained in:
@@ -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" });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user