Java Code Examples for jdk.nashorn.api.scripting.JSObject#call()
The following examples show how to use
jdk.nashorn.api.scripting.JSObject#call() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSObjectLinker.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") private static Object jsObjectScopeCall(final JSObject jsObj, final Object thiz, final Object[] args) { final Object modifiedThiz; if (thiz == ScriptRuntime.UNDEFINED && !jsObj.isStrictFunction()) { final Global global = Context.getGlobal(); modifiedThiz = ScriptObjectMirror.wrap(global, global); } else { modifiedThiz = thiz; } return jsObj.call(modifiedThiz, args); }
Example 2
Source File: JSObjectLinker.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") private static Object jsObjectScopeCall(final JSObject jsObj, final Object thiz, final Object[] args) { final Object modifiedThiz; if (thiz == ScriptRuntime.UNDEFINED && !jsObj.isStrictFunction()) { final Global global = Context.getGlobal(); modifiedThiz = ScriptObjectMirror.wrap(global, global); } else { modifiedThiz = thiz; } return jsObj.call(modifiedThiz, args); }
Example 3
Source File: JSObjectLinker.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") private static Object jsObjectScopeCall(final JSObject jsObj, final Object thiz, final Object[] args) { final Object modifiedThiz; if (thiz == ScriptRuntime.UNDEFINED && !jsObj.isStrictFunction()) { final Global global = Context.getGlobal(); modifiedThiz = ScriptObjectMirror.wrap(global, global); } else { modifiedThiz = thiz; } return jsObj.call(modifiedThiz, args); }
Example 4
Source File: JSObjectLinker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") private static Object jsObjectScopeCall(final JSObject jsObj, final Object thiz, final Object[] args) { final Object modifiedThiz; if (thiz == ScriptRuntime.UNDEFINED && !jsObj.isStrictFunction()) { final Global global = Context.getGlobal(); modifiedThiz = ScriptObjectMirror.wrap(global, global); } else { modifiedThiz = thiz; } return jsObj.call(modifiedThiz, args); }
Example 5
Source File: JSObjectLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") private static Object jsObjectScopeCall(final JSObject jsObj, final Object thiz, final Object[] args) { final Object modifiedThiz; if (thiz == ScriptRuntime.UNDEFINED && !jsObj.isStrictFunction()) { final Global global = Context.getGlobal(); modifiedThiz = ScriptObjectMirror.wrap(global, global); } else { modifiedThiz = thiz; } return jsObj.call(modifiedThiz, args); }
Example 6
Source File: JsMagmaScriptEvaluator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates magmascript bindings for a given Entity. * * @param entity the entity to bind to the magmascript $ function * @param depth maximum depth to follow references when creating the entity value map * @return Bindings with $ function bound to the entity */ private Bindings createBindings(Entity entity, int depth) { Bindings bindings = new SimpleBindings(); JSObject global = (JSObject) magmaBindings.get("nashorn.global"); JSObject magmaScript = (JSObject) global.getMember(KEY_MAGMA_SCRIPT); JSObject dollarFunction = (JSObject) magmaScript.getMember(KEY_DOLLAR); JSObject bindFunction = (JSObject) dollarFunction.getMember(BIND); Object boundDollar = bindFunction.call(dollarFunction, toScriptEngineValueMap(entity, depth)); bindings.put(KEY_DOLLAR, boundDollar); bindings.put(KEY_NEW_VALUE, magmaScript.getMember(KEY_NEW_VALUE)); bindings.put(KEY_IS_NULL, magmaScript.getMember(KEY_IS_NULL)); return bindings; }