Package org.mozilla.javascript

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


           
        } 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

        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

            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

      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

            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

      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

        Function func = getAdapteeFunction(GET_PROPIDS);
        if (func != null) {
            Object val = call(func, new Object[0]);
            // in most cases, adaptee would return native JS array
            if (val instanceof NativeArray) {
                NativeArray array = (NativeArray) val;
                Object[] res = new Object[(int)array.getLength()];
                for (int index = 0; index < res.length; index++) {
                    res[index] = mapToId(array.get(index, array));
                }
                return res;
            } else if (val instanceof NativeJavaArray) {
                // may be attempt wrapped Java array
                Object tmp = ((NativeJavaArray)val).unwrap();
View Full Code Here

        return pwk;
    }

    public NativeArray jsFunction_getChildren() throws Exception {
        List list = wk.getChildren();
        NativeArray arr =
            (NativeArray)org.mozilla.javascript.Context.getCurrentContext().newObject(getParentScope(),
                                                                                      "Array",
                                                                                      new Object[]{new Integer(list.size())});
        Iterator iter = list.iterator();
        for (int i = 0; iter.hasNext(); i++) {
            WebContinuation child = (WebContinuation)iter.next();
            FOM_WebContinuation cwk = new FOM_WebContinuation(child);
            cwk.setParentScope(getParentScope());
            cwk.setPrototype(getClassPrototype(getParentScope(),
                                               cwk.getClassName()));
            arr.put(i, arr, cwk);
        }
        return arr;
    }
View Full Code Here

                value = unwrap(value);
                field.setValue(value);
            } else if (sub instanceof Repeater) {
                Repeater repeater = (Repeater)sub;
                if (value instanceof NativeArray) {
                    NativeArray arr = (NativeArray)value;
                    Object length = getProperty(arr, "length");
                    int len = ((Number)length).intValue();
                    for (int i = repeater.getSize(); i >= len; --i) {
                        repeater.removeRow(i);
                    }
                    for (int i = 0; i < len; i++) {
                        Object elemValue = getProperty(arr, i);
                        if (elemValue instanceof Scriptable) {
                            Scriptable s = (Scriptable)elemValue;
                            Object[] ids = s.getIds();
                            ScriptableWidget wid = wrap(repeater.getRow(i));
                            for (int j = 0; j < ids.length; j++) {
                                String idStr = ids[j].toString();
                                wid.put(idStr, wid, getProperty(s, idStr));
                            }
                        }
                    }
                    return;
                }
            } else if (sub instanceof MultiValueField) {
                MultiValueField field = (MultiValueField)sub;
                Object[] values = null;
                if (value instanceof NativeArray) {
                    NativeArray arr = (NativeArray)value;
                    Object length = getProperty(arr, "length");
                    int len = ((Number)length).intValue();
                    values = new Object[len];
                    for (int i = 0; i < len; i++) {
                        Object elemValue = getProperty(arr, i);
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeArray

Copyright © 2018 www.massapicom. 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.