Examples of NativeArray


Examples of org.mozilla.javascript.NativeArray

        }
        Object result = jxcontext_.getValue(xpath);

        if (result instanceof NativeArray) {
            // Convert JavaScript array to Collection
            NativeArray arr = (NativeArray) result;
            int len = (int) arr.jsGet_length();
            List list = new ArrayList(len);

            for (int i = 0; i<len; i++) {
                Object obj = arr.get(i, arr);

                if (obj==Context.getUndefinedValue()) {
                    obj = null;
                }
                list.add(obj);
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

    }

    public Object getValue() {
        Object val = getNode();
        if (val instanceof NativeArray) {
            NativeArray arr = (NativeArray)val;
            List list = new LinkedList();
            int len = (int)arr.jsGet_length();
            for (int i = 0; i < len; i++) {
                Object obj = arr.get(i, arr);
                if (obj == Undefined.instance) {
                    obj = null;
                }
                list.add(obj);
            }
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

                    getDebugger().setVisible(true);
                }
            }
            int size = (params != null ? params.size() : 0);
            Object[] funArgs = new Object[size];
            NativeArray parameters = new NativeArray(size);
            if (size != 0) {
                for (int i = 0; i < size; i++) {
                    Interpreter.Argument arg = (Interpreter.Argument)params.get(i);
                    funArgs[i] = arg.value;
                    if (arg.name == null) arg.name = "";
                    parameters.put(arg.name, parameters, arg.value);
                }
            }
            cocoon.setParameters(parameters);
            NativeArray funArgsArray = new NativeArray(funArgs);
            Object fun = ScriptableObject.getProperty(thrScope, funName);
            if (fun == Scriptable.NOT_FOUND) {
                fun = funName; // this will produce a better error message
            }
            Object callFunArgs[] = { fun, funArgsArray };
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

                                       + "(system.js not loaded?)");

        Object args[] = { jswk };

        int size = (params != null ? params.size() : 0);
        NativeArray parameters = new NativeArray(size);

        if (size != 0) {
            for (int i = 0; i < size; i++) {
                Interpreter.Argument arg = (Interpreter.Argument)params.get(i);
                parameters.put(arg.name, parameters, arg.value);
            }
        }

        cocoon.setParameters(parameters);
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

           
        } else if (items.size()==1) {
            return items.iterator().next();
           
        } else {
            NativeArray result = new NativeArray(items.toArray());
            ScriptRuntime.setObjectProtoAndParent(result, this);
            return result;
        }
    }
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

        for (int i = 0; i < size; i++) {
          Object obj = ((Interpreter.Argument)params.get(i)).value;
          funArgs[i] = ScriptRuntime.toObject(cx, thrScope, obj);
        }
      }
      NativeArray funArgsArray = new NativeArray(funArgs);
      Object callFunArgs[] = { fun, funArgsArray };

      ((Function) callFunction).call(cx, thrScope, thrScope, callFunArgs);
    }
    finally {
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

            final Object interfaceNames = ScriptableObject.getProperty(target, "__implements__");

            if (interfaceNames instanceof NativeArray) {

                final NativeArray interfaceNameArray = (NativeArray) interfaceNames;

                for (int i=0; i<interfaceNameArray.getLength(); i++) {

                    final Object obj = interfaceNameArray.get(i, interfaceNameArray);

                    if (obj instanceof String) {
                        interfaceClasses.add(Class.forName((String) obj));
                    }
                }
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

      final NativeJavaObject object = (NativeJavaObject) o;
      return object.unwrap();
    }
    if (o instanceof NativeArray)
    {
      final NativeArray array = (NativeArray) o;
      final Object[] result = new Object[(int) array.getLength()];
      for (final Object val : array.getIds())
      {
        final int index = (Integer) val;
        result[index] = array.get(index, null);
      }
      return result;
    }
    return null;
  }
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

            Context ctx = Context.getCurrentContext();

            nodeScript.exec(ctx, globalScope);

            NativeObject proc = (NativeObject) globalScope.get("process");
            NativeArray argv = (NativeArray) proc.get("argv");
            argv.defineProperty("length", 0, ScriptableObject.EMPTY);
            int i = 0;
            argv.put(i++, argv, "node");
            argv.put(i++, argv, "tsc.js");
            if (noStandardLib) {
                argv.put(i++, argv, "--nolib");
            }
            if (libDTS != null && libDTS.exists()) {
                if (!watching) {
                    getLog().info("Adding standard library file " + libDTS);
                }
                argv.put(i++, argv, libDTS.getAbsolutePath());

            }
            if (libraryDirectory != null && libraryDirectory.exists()) {
                File[] libFiles = libraryDirectory.listFiles();
                if (libFiles != null) {
                    for (File libFile : libFiles) {
                        if (libFile.getName().endsWith(".d.ts") && libFile.exists()) {
                            if (!watching) {
                                getLog().info("Adding library file " + libFile);
                            }
                            argv.put(i++, argv, libFile.getAbsolutePath());
                        }
                    }
                }
            }

            if (targetVersion != null) {
                getLog().info("Setting target version to " + targetVersion);
                argv.put(i++, argv, "--target");
                argv.put(i++, argv, targetVersion);
            }

            for (String s : args) {
                argv.put(i++, argv, s);
            }

            proc.defineProperty("encoding", encoding, ScriptableObject.READONLY);

            NativeObject mainModule = (NativeObject) proc.get("mainModule");
View Full Code Here

Examples of org.mozilla.javascript.NativeArray

      scope.put("contents", scope, contents);
      context.evaluateString(scope, "results = JSLINT(contents, null);", "JSLint", 1, null);
     
      Scriptable lint = (Scriptable) scope.get("JSLINT", scope);
      NativeArray errors = (NativeArray) lint.get("errors", null);
      clearMarkers(file);
      for (int i = 0; i < errors.getLength(); i++) {
        NativeObject error = (NativeObject) errors.get(i, null);
        if(error == null) continue;
        Double lineNo = ((Double) error.get("line", null)) - 2;
        Object reason = error.get("reason", null);
        IMarker marker = file.createMarker("org.eclipse.core.resources.problemmarker");
        marker.setAttribute(IMarker.LINE_NUMBER, lineNo.intValue());
        marker.setAttribute(IMarker.MESSAGE, reason);
        marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
        // Needed to delete own markers!
        marker.setAttribute("org.pkg.jstools.marker", true);
      }
      if (errors.getLength() == 0) {
        MessageDialog.openInformation(null, "JSLint", "No errors found.");
      }
    } catch (Exception e) {
      e.printStackTrace();
    } 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.