Fixed scope issues when running Cappuccino under CommonJS.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2010-02-13 16:57:09 -08:00
1 parent bc53288fca
commit 8d63c059c5
2 files changed
+15 -5

No files matched your search

+5
View File
@@ -28,6 +28,9 @@
@import "CPGeometry.j"
#include "Platform/DOM.h"
CPImageLoadStatusInitialized = 0;
CPImageLoadStatusLoading = 1;
CPImageLoadStatusCompleted = 2;
@@ -258,6 +261,7 @@ function CPAppKitImage(aFilename, aSize)
_loadStatus = CPImageLoadStatusLoading;
#if PLATFORM(DOM)
_image = new Image();
var isSynchronous = YES;
@@ -304,6 +308,7 @@ function CPAppKitImage(aFilename, aSize)
// onload and friends may fire after this point but BEFORE the end of the run loop,
// crazy, I know. So don't set isSynchronous here, rather wait a bit longer.
window.setTimeout(function() { isSynchronous = NO; }, 0);
#endif
}
- (BOOL)isThreePartImage
+10 -5
View File
@@ -138,26 +138,31 @@ Executable.prototype.setCode = function(code)
{
this._code = code;
#if COMMONJS
code = "function(" + this.functionParameters().join(" , ") + "){" + code + "/**/\n}";
var parameters = this.functionParameters().join(",");
#if COMMONJS
if (typeof system !== "undefined" && system.engine === "rhino")
{
code = "function(" + parameters + "){" + code + "/**/\n}";
this._function = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, code, this._scope, 0, NULL);
}
else
this._function = eval("(" + code + ")");
#else
{
#endif
// "//@ sourceURL=" at the end lets us name our eval'd files for debuggers, etc.
// * WebKit: http://pmuellr.blogspot.com/2009/06/debugger-friendly.html
// * Firebug: http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/
//if (YES) {
code += "/**/\n//@ sourceURL=" + this._scope;
this._function = new Function(this.functionParameters(), code);
this._function = new Function(parameters, code);
//} else {
// // Firebug only does it for "eval()", not "new Function()". Ugh. Slower.
// var functionText = "(function(){"+GET_CODE(aFragment)+"/**/\n})\n//@ sourceURL="+GET_FILE(aFragment).path;
// compiled = eval(functionText);
//}
this._function.displayName = this._scope;
#if COMMONJS
}
#endif
}