From edfdfd5a792e8da4e43fef5ac57c35d2c3601ab3 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 30 Mar 2006 10:19:25 +0000 Subject: [PATCH] * Make sure global reference is always available, even if there is no per-thread scope (e.g. when compiling scripts) --- src/helma/scripting/rhino/DynamicGlobalObject.java | 8 ++++---- src/helma/scripting/rhino/GlobalObject.java | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/helma/scripting/rhino/DynamicGlobalObject.java b/src/helma/scripting/rhino/DynamicGlobalObject.java index 2a7de0f4..0f6a03be 100644 --- a/src/helma/scripting/rhino/DynamicGlobalObject.java +++ b/src/helma/scripting/rhino/DynamicGlobalObject.java @@ -39,10 +39,10 @@ public class DynamicGlobalObject extends GlobalObject { if (obj != null && obj != NOT_FOUND) { return obj; } - } - // make thread scope accessible as "global" - if ("global".equals(s)) { - return scope; + // make thread scope accessible as "global" + if ("global".equals(s)) { + return scope; + } } return super.get(s, scriptable); } diff --git a/src/helma/scripting/rhino/GlobalObject.java b/src/helma/scripting/rhino/GlobalObject.java index 207a81bb..14d0354c 100644 --- a/src/helma/scripting/rhino/GlobalObject.java +++ b/src/helma/scripting/rhino/GlobalObject.java @@ -75,6 +75,7 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder { defineFunctionProperties(globalFuncs, GlobalObject.class, 0); put("app", this, Context.toObject(new ApplicationBean(app), this)); put("Xml", this, Context.toObject(new XmlObject(core), this)); + put("global", this, this); // Define dontEnum() on Object prototype String[] objFuncs = { "dontEnum" }; ScriptableObject objproto = (ScriptableObject) getObjectPrototype(this);