Examples of BaseFunction


Examples of org.mozilla.javascript.BaseFunction

    static final String CLASSNAME = "ScriptableList";

    // Set up a custom constructor, for this class is somewhere between a host class and
    // a native wrapper, for which no standard constructor class exists
    public static void init(Scriptable scope) throws NoSuchMethodException {
        BaseFunction ctor = new BaseFunction(scope, ScriptableObject.getFunctionPrototype(scope)) {
            @Override
            public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
                if (args.length > 1) {
                    throw new EvaluatorException("ScriptableList() requires a java.util.List argument");
                }
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

    final static String CLASSNAME = "ScriptableMap";

    // Set up a custom constructor, for this class is somewhere between a host class and
    // a native wrapper, for which no standard constructor class exists
    public static void init(Scriptable scope) throws NoSuchMethodException {
        BaseFunction ctor = new BaseFunction(scope, ScriptableObject.getFunctionPrototype(scope)) {
            @Override
            public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
                boolean reflect = false;
                if (args.length > 2) {
                    throw new EvaluatorException("ScriptableMap() called with too many arguments");
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

    private void initJsProcessor() {
        this.cx = org.mozilla.javascript.Context.enter();
        this.scope = new ImporterTopLevel(cx);

        if (jsFunctions != null) {
            scope.defineProperty("count", new BaseFunction() {
                @Override
                public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
                    if (args.length == 0 || !(args[0] instanceof String)) {
                        throw new IllegalArgumentException("Should take string argument");
                    }
                    return jsFunctions.count((String)args[0]);
                }
            }, ScriptableObject.DONTENUM);

            scope.defineProperty("find", new BaseFunction() {
                @Override
                public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
                    if (args.length == 0 || !(args[0] instanceof String)) {
                        throw new IllegalArgumentException("Should take string argument");
                    }
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

  /**
   * ECMA 11.4.3 says that typeof on host object is Implementation-dependent
   */
  public void test0() throws Exception
  {
        final Function f = new BaseFunction()
        {
          @Override
          public Object call(Context _cx, Scriptable _scope, Scriptable _thisObj,
              Object[] _args)
          {
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.