Package org.mozilla.javascript

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


            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("resolve");
            Object result = (Object) function.call(ctx, global, exports, new Object[]{"../hello"});
            assertEquals("/a/b/hello", Context.toString(result));

            result = (Object) function.call(ctx, global, exports, new Object[]{"./bye"});
            assertEquals("/a/b/c/bye", Context.toString(result));
View Full Code Here


            Function function = (Function) exports.get("resolve");
            Object result = (Object) function.call(ctx, global, exports, new Object[]{"../hello"});
            assertEquals("/a/b/hello", Context.toString(result));

            result = (Object) function.call(ctx, global, exports, new Object[]{"./bye"});
            assertEquals("/a/b/c/bye", Context.toString(result));

        } 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

            }
            Function queueModified = (Function) queueModifiedObj;
            Context cx = getCurrentContext();
            Scriptable scope = getParentScope();
            Object[] args = { this, name };
            queueModified.call(cx, scope, layer, args);
        }
        return this;
    }

    @JSFunction
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

            // (see the pom.xml for the wrapper code). What we actually
            // need to do here is to invoke the wrapper function after running the script.

            Object ret = compiled.exec(cx, runner.getScriptScope());
            Function fn = (Function)ret;
            fn.call(cx, runner.getScriptScope(), null, new Object[] { mod.getExports(), requireFunc,
                                                                      mod, mod.getFileName() });
            mod.setLoaded(true);
        }

        @JSFunction
View Full Code Here

                if (status instanceof String) {
                    setErrno(status.toString());
                } else {
                    clearErrno();
                }
                ocf.call(cx, ocf, this,
                         new Object[]{status, this, s, readable, writable});
            }
        }

        @JSFunction
View Full Code Here

                            {
                                try {
                                    JdbcConnection conn =
                                        (JdbcConnection)cx.newObject(self, JdbcConnection.CLASS_NAME);
                                    conn.init(jdbcConn, self.runtime);
                                    cb.call(cx, cb, self, new Object[] {Undefined.instance, conn});
                                } finally {
                                    self.runtime.unPin();
                                }
                            }
                        }, domain);
View Full Code Here

                    } catch (final SQLException sqle) {
                        self.runtime.enqueueTask(new ScriptTask() {
                            @Override
                            public void execute(Context cx, Scriptable scope)
                            {
                                cb.call(cx, cb, self, new Object[] { makeSqlError(cx, scope, sqle) });
                            }
                        }, domain);
                    } finally {
                        self.runtime.unPin();
                    }
View Full Code Here

                    } catch (final SQLException sqle) {
                        self.runtime.enqueueTask(new ScriptTask() {
                            @Override
                            public void execute(Context cx, Scriptable scope)
                            {
                                cb.call(cx, cb, self, new Object[] {
                                    JdbcWrap.makeSqlError(cx, scope, sqle)
                                });
                            }
                        }, domain);
                    } finally {
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.