From 5f54cd264e7810d18966ff0d9b3c82b51923fcbf Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Wed, 4 Aug 2004 17:42:56 +0000 Subject: [PATCH] Restoring ScriptRuntime.call: BSF uses it! --- .../org/mozilla/javascript/ScriptRuntime.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index f6596257d50..82ee7990cf8 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -839,6 +839,23 @@ public class ScriptRuntime { return toObject(cx, scope, val); } + public static Object call(Context cx, Object fun, Object thisArg, + Object[] args, Scriptable scope) + throws JavaScriptException + { + if (!(fun instanceof Function)) { + throw notFunctionError(toString(fun)); + } + Function function = (Function)fun; + Scriptable thisObj; + if (thisArg instanceof Scriptable || thisArg == null) { + thisObj = (Scriptable) thisArg; + } else { + thisObj = ScriptRuntime.toObject(cx, scope, thisArg); + } + return function.call(cx, scope, thisObj, args); + } + public static Scriptable newObject(Context cx, Scriptable scope, String constructorName, Object[] args) {