Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeObject


        // unwrap if argument is a Wrapper
        if (arg instanceof Wrapper) {
            arg = ((Wrapper) arg).unwrap();
        }
        if (arg instanceof NativeObject) {
            NativeObject no = (NativeObject) arg;
            Object[] ids = no.getIds();
            Hashtable ht = new Hashtable(ids.length*2);
            for (int i=0; i<ids.length; i++) {
                if (ids[i] instanceof String) {
                    String key = (String) ids[i];
                    Object o = no.get(key, no);
                    if (o != null) {
                        ht.put(key, processXmlRpcResponse(o));
                    }
                }
            }
View Full Code Here


    Emmet jse = Emmet.getSingleton();
    Scriptable tabstopData = (Scriptable) jse.execJSFunction("javaExtractTabstops", text);
    if (tabstopData != null) {
      text = Context.toString(ScriptableObject.getProperty(tabstopData, "text"));
      NativeArray tabstops = (NativeArray) ScriptableObject.getProperty(tabstopData, "tabstops");
      NativeObject tabstopItem;
      for (int i = 0; i < tabstops.getLength(); i++) {
        tabstopItem = (NativeObject) ScriptableObject.getProperty(tabstops, i);
        addTabStopToGroup(
            Context.toString(ScriptableObject.getProperty(tabstopItem, "group")),
            (int) Context.toNumber(ScriptableObject.getProperty(tabstopItem, "start")),
View Full Code Here

  }
 
  private static ArrayList<AbstractMenuItem> itemsFromJSArray(NativeArray ar) {
    ArrayList<AbstractMenuItem> list = new ArrayList<AbstractMenuItem>();
   
    NativeObject menuItem;
    for (int i = 0; i < ar.getLength(); i++) {
      menuItem = (NativeObject) ScriptableObject.getProperty(ar, i);
      if (Context.toString(ScriptableObject.getProperty(menuItem, "type")).equals("action")) {
        list.add(new Action(menuItem));
      } else {
View Full Code Here

    boolean goodExecution = false;
    try {
      final Reader buildFile = new FileReader(new File(fileToInspect));
      final Script sc = cx.compileReader(buildFile, fileToInspect, 1, null);

      final NativeObject window = new NativeObject();
      ScriptableObject.putProperty(scope, "window", window);
      final NativeObject htmlelement = new NativeObject();
      ScriptableObject.putProperty(scope, "HTMLElement", htmlelement);
      final NativeObject prototype = new NativeObject();
      ScriptableObject.putProperty(htmlelement, "prototype", prototype);
      final NativeObject external = new NativeObject();
      ScriptableObject.putProperty(scope, "external", external);

      sc.exec(cx, scope);
      buildFile.close();
      goodExecution = true;
View Full Code Here

   */
  public static void applyFilterFeature(final Context cx, final Scriptable thisObj, final Object[] args, final Function funObj) throws WinkBuildException {
    if (args.length != 2 || args[0] == null || args[1] == null || !(args[0] instanceof NativeObject) || !(args[1] instanceof NativeArray)) {
      throw new WinkBuildException("applyFilterFeature() error: bad arguments");
    }
    final NativeObject no = (NativeObject) args[0];
    final List<String> files = convertNativeArrayIntoList((NativeArray) args[1]);

    final Map<String, Boolean> featureMap = new HashMap<String, Boolean>();

    final Object[] noIds = no.getIds();
    for (final Object o : noIds) {
      final Boolean value = (Boolean) no.get((String) o, no);
      featureMap.put((String) o, value);
    }

    if (featureMap.size() == 0) {
      return;
View Full Code Here

        ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
        NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();

        for (int i = 0; i < array.getLength(); i++) {
            NativeObject object = (NativeObject) array.get(i, array);
            String data = null;
            Object dataObject = object.get("data", object);

            if (!(dataObject instanceof Undefined)) {
                data = (String) dataObject;
            }

            Double startTime = (Double) object.get("startTime", object);
            Double endTime = (Double) object.get("endTime", object);
            Object aborted = object.get("aborted", object);
            boolean abortedBoolean = aborted instanceof Boolean && (Boolean) aborted;

            result.addData(new RequestData(data, startTime, endTime, abortedBoolean));
        }
View Full Code Here

                interpreter.callMethod(object, COMPLETE,
                                       new RhinoInterpreter.ArgumentsBuilder() {
                                           public Object[] buildArguments() {
                                               Object[] arguments = new Object[1];
                                               ScriptableObject so =
                                                   new NativeObject();
                                               so.put("success", so,
                                                      (success) ?
                                                      Boolean.TRUE : Boolean.FALSE);
                                               if (mime != null) {
                                                   so.put("contentType", so,
                                                          Context.toObject(mime,
                                                                           windowWrapper));
                                               }
                                               if (content != null) {
                                                   so.put("content", so,
                                                          Context.toObject(content,
                                                                           windowWrapper));
                                               }
                                               arguments[0] = so;
                                               return arguments;
View Full Code Here

        // create a rhino Context and execute the script
        try {
           
            final Context rhinoContext = Context.enter();
            final ScriptableObject scope = new NativeObject();

            // Set the global scope to be our prototype
            scope.setPrototype(rootScope);

            // We want "scope" to be a new top-level scope, so set its parent
            // scope to null. This means that any variables created by assignments
            // will be properties of "scope".
            scope.setParentScope(null);

            // setup the context for use
            rhinoContext.setWrapFactory(SlingWrapFactory.INSTANCE);

            // add initial properties to the scope
View Full Code Here

        RhinoExecutor executor = executorPool.get();

        try
        {

            NativeObject result = (NativeObject) executor.invokeFunction("compileCoffeeScriptSource", content, source.toString());

            if (result.containsKey("exception"))
            {
                throw new RuntimeException(getString(result, "exception"));
            }

            return IOUtils.toInputStream(getString(result, "output"), UTF8);
View Full Code Here

            Context.enter();
            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");
            mainModule.defineProperty("filename", new File("tsc.js").getAbsolutePath(), ScriptableObject.READONLY);

            tscScript.exec(ctx, globalScope);
        } catch (JavaScriptException e) {
            if (e.getValue() instanceof NativeJavaObject) {
                NativeJavaObject njo = (NativeJavaObject) e.getValue();
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeObject

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.