Package org.mozilla.javascript

Examples of org.mozilla.javascript.Function.call()


 
  public float tf(int arg0) {
    Function func = otherMethods[M_TF_I];
    if (func == null) return super.tf(arg0);
    Object[] args = new Object[]{new Integer(arg0)};
    Object res = func.call(cx, scope, scope, args);
    float f = 0.0f;
    try {
      f = Float.parseFloat(res.toString());
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here


    private String evaluateFormula(String type, Vertex vertex, String workspaceId, Authorizations authorizations) {
        String json = toJson(vertex, workspaceId, authorizations);

        Function f = (Function) scope.get("evaluate" + type + "FormulaJson", scope);
        Object result = f.call(context, scope, scope, new Object[]{json});

        return (String) Context.jsToJava(result, String.class);
    }

    private void setupContext() {
View Full Code Here

        Context cx = Context.enter();
        try {
            Function function = getFunction(scriptScope, functionName);
            Scriptable invocationScope = getInvocationScope(cx, contexts);
            Object[] jsArgs = processArgs(functionName, args, invocationScope);
            Object jsResponse = function.call(cx, invocationScope, invocationScope, jsArgs);
            Object response = processResponse(functionName, jsResponse, responseClass);
            return response;
        } finally {
            Context.exit();
        }
View Full Code Here

        if (!(fObj instanceof Function)) {
            throw new RuntimeException("Missing test function " + functionName);
        }
        Function function = (Function)fObj;
        try {
            return function.call(rhinoContext, rhinoScope, rhinoScope, args);
        } catch (RhinoException angryRhino) {
            if (expectingException != null && angryRhino instanceof JavaScriptException) {
                JavaScriptException jse = (JavaScriptException)angryRhino;
                Assert.assertEquals(jse.getValue(), expectingException);
                return null;
View Full Code Here

        Object process = scope.get("process", scope);
        try {
            if (process instanceof Function) {
                Function processFn = (Function)process;
                Object[] args = {mapToJsObject(input, scope)};
                Object result = processFn.call(cx, scope, scope, args);
                results = jsObjectToMap((Scriptable)result);
            } else {
                throw new RuntimeException(
                    "Script for process: " + myScript.getName() +
                    " is not a valid process script."
View Full Code Here

            if (!(v instanceof Function))
                continue;
            Function fun = (Function) v;
            Context cx = RhinoScriptEngine.enterContext();
            try {
                v = fun.call(cx, fun.getParentScope(), this, args);
            } finally {
                cx.exit();
            }
            if (v != null) {
                if (!(v instanceof Scriptable)) {
View Full Code Here

            Function func = (Function) obj;
            Scriptable scope = func.getParentScope();
            if (scope == null) {
                scope = engineScope;
            }
            Object result = func.call(cx, scope, localScope,
                                      wrapArguments(args));
            return unwrapReturnValue(result);
        } catch (JavaScriptException jse) {
            if (DEBUG) jse.printStackTrace();
            int line = (line = jse.lineNumber()) == 0 ? -1 : line;
View Full Code Here

                Object[] args = new Object[1];
                Scriptable scope = getTopLevelScope(this);
                Scriptable thisObj = scope;
                Context cx = Context.getCurrentContext();
                args[0] = this;
                fun.call(cx, scope, thisObj, args);
            } catch (Exception exc) {
                throw Context.reportRuntimeError(exc.getMessage());
            }
        }
    }
View Full Code Here

                Object[] args = new Object[1];
                Scriptable scope = getTopLevelScope(this);
                Scriptable thisObj = scope;
                Context cx = Context.getCurrentContext();
                args[0] = this;
                fun.call(cx, scope, thisObj, args);
            } catch (Exception exc) {
                throw Context.reportRuntimeError(exc.getMessage());
            }
        }
    }
View Full Code Here

                Scriptable thisObj = scope;
                Context cx = Context.getCurrentContext();
                for (int i = 0; i < len; i++) {
                    ScriptableWidget row = wrap(repeater.getRow(i));
                    args[0] = row;
                    Object result = fun.call(cx, scope, thisObj, args);
                    index[i] = Context.toBoolean(result);
                }   
                for (int i = len-1; i >= 0; --i) {
                    if (index[i]) {
                        deleteRow(repeater, i);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.