@Override public Object get(int index, Scriptable start) { if (0 <= index && index < length) { Context cx = Context.getContext(); Object obj = Array.get(array, index); return cx.getWrapFactory().wrap(cx, this, obj, cls); } return Undefined.instance; }
/** @deprecated Use {@link Context#getWrapFactory()} together with calling {@link WrapFactory#wrap(Context, Scriptable, Object, Class)} */ public static Object wrap(Scriptable scope, Object obj, Class<?> staticType) { Context cx = Context.getContext(); return cx.getWrapFactory().wrap(cx, scope, obj, staticType); }
private static Object doCall(Context cx, Scriptable scope, Scriptable thisObj, Function f, Object[] args, long argsToWrap) { // Wrap the rest of objects for (int i = 0; i != args.length; ++i) { if (0 != (argsToWrap & (1 << i))) { Object arg = args[i]; if (!(arg instanceof Scriptable)) { args[i] = cx.getWrapFactory().wrap(cx, scope, arg, null); } } } return f.call(cx, scope, thisObj, args); }
} else { Context cx = Context.getContext(); return cx.getWrapFactory().wrap(cx, scope, value, null);
@Override public Object getDefaultValue(Class<?> hint) { if (hint == ScriptRuntime.FunctionClass) return this; Object rval; Class<?> type; try { rval = field.get(javaObject); type = field.getType(); } catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); } Context cx = Context.getContext(); rval = cx.getWrapFactory().wrap(cx, this, rval, type); if (rval instanceof Scriptable) { rval = ((Scriptable) rval).getDefaultValue(hint); } return rval; }
Object invokeImpl(Context cx, Object target, Scriptable topScope, Method method, Object[] args) { int N = (args == null) ? 0 : args.length; Callable function = (Callable)target; Scriptable thisObj = topScope; Object[] jsargs = new Object[N + 1]; jsargs[N] = method.getName(); if (N != 0) { WrapFactory wf = cx.getWrapFactory(); for (int i = 0; i != N; ++i) { jsargs[i] = wf.wrap(cx, topScope, args[i], null); } } Object result = function.call(cx, topScope, thisObj, jsargs); Class<?> javaResultType = method.getReturnType(); if (javaResultType == Void.TYPE) { result = null; } else { result = Context.jsToJava(result, javaResultType); } return result; } }
return cx.getWrapFactory().wrap(cx, scope, rval, type);
Context cx = Context.getContext(); Scriptable scope = ScriptableObject.getTopLevelScope(start); return cx.getWrapFactory().wrap(cx, scope, javaObject, ScriptRuntime.ClassClass);
Object wrapped = cx.getWrapFactory().wrap(cx, scope, val, null); if (wrapped instanceof Scriptable) return (Scriptable) wrapped;
Object wrapped = cx.getWrapFactory().wrap(cx, scope, retval, staticType); if (debug) {
result = Undefined.instance; } else if (returnTypeTag == JAVA_UNSUPPORTED_TYPE) { result = cx.getWrapFactory().wrap(cx, scope, result, null);
if (iterator != null) { scope = ScriptableObject.getTopLevelScope(scope); return cx.getWrapFactory().wrap(cx, scope, new WrappedJavaIterator(iterator, scope), WrappedJavaIterator.class);