Package org.mozilla.javascript

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


      if( null == _setContextObj || !(_setContextObj instanceof Function) ) {
        throw new RuntimeException( "no codewriter._setContext in script" );
      }

      Function _setContext = (Function) _setContextObj;
      _setContext.call(cx,scope,codewriter,new Object[]{context});

      Object _generateObj = codewriter.get( "_generate", codewriter );
      if( null == _generateObj || !(_generateObj instanceof Function) ) {
        throw new RuntimeException( "no codewriter._generate in script" );
      }
View Full Code Here


      if( null == _generateObj || !(_generateObj instanceof Function) ) {
        throw new RuntimeException( "no codewriter._generate in script" );
      }

      Function _generate = (Function) _generateObj;
      result = _generate.call(cx,scope,codewriter,new Object[]{args,new Boolean(throwWriterExceptions)});

      template.setResult( result );
    }

    catch( StandardException se ) {
View Full Code Here

    private void notifyReadyStateChangeListener() {
        if (readyStateChangeListener instanceof Function) {
            LOG.fine("notify " + readyState);
            // for now, call with no args.
            Function listenerFunction = (Function)readyStateChangeListener;
            listenerFunction.call(Context.getCurrentContext(), getParentScope(), null, new Object[] {});
        }
    }

    private void doOpen(String method, String urlString, boolean async, String user, String password) {
        // ignoring auth for now.
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

      if( null == _setContextObj || !(_setContextObj instanceof Function) ) {
        throw new RuntimeException( "no codewriter._setContext in script" );
      }

      Function _setContext = (Function) _setContextObj;
      _setContext.call(cx,scope,codewriter,new Object[]{context});

      Object _generateObj = codewriter.get( "_generate", codewriter );
      if( null == _generateObj || !(_generateObj instanceof Function) ) {
        throw new RuntimeException( "no codewriter._generate in script" );
      }
View Full Code Here

      if( null == _generateObj || !(_generateObj instanceof Function) ) {
        throw new RuntimeException( "no codewriter._generate in script" );
      }

      Function _generate = (Function) _generateObj;
      result = _generate.call(cx,scope,codewriter,new Object[]{args,new Boolean(throwWriterExceptions)});

      template.setResult( result );
    }

    catch( StandardException se ) {
View Full Code Here

            new ContextAction()
            {
              @Override
              public Object run(final Context cx)
              {
                return fnCombine.call(cx, scope, scope, new Object[]{a, b});
              }
            }
        );
        return Context.toNumber(res);
      }
View Full Code Here

    return (T)   cx.evaluateString(scope, code, "<cmd>", 1, null);
  }
 
  public <T> T call(String functionName, Object ... args){
      Function f = getFunction(functionName);
      return (T) f.call(cx, scope, scope, args);
  }
 
  private Function getFunction(String name){
    return (Function) scope.get(name, scope);
  }
View Full Code Here

    private void notifyReadyStateChangeListener() {
        if (readyStateChangeListener instanceof Function) {
            LOG.fine("notify " + readyState);
            // for now, call with no args.
            Function listenerFunction = (Function)readyStateChangeListener;
            listenerFunction.call(Context.getCurrentContext(), getParentScope(), null, new Object[] {});
        }
    }

    private void doOpen(String method, String urlString, boolean async, String user, String password) {
        // ignoring auth for now.
View Full Code Here

            InputStream resourceAsStream = Rhinodo.class.getClassLoader().getResourceAsStream("META-INF/env/path.js");
            ctx.evaluateReader(global,new InputStreamReader(resourceAsStream), "path",-1, null);

            Function function = (Function) exports.get("basename");
            Object result = (Object) function.call(ctx, global, exports, new Object[]{"hello/bye/now"});

            assertEquals("now", Context.toString(result));

        } finally {
            Context.exit();
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.