Examples of NativeObject


Examples of org.mozilla.javascript.NativeObject

    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

Examples of org.mozilla.javascript.NativeObject

   */
  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

Examples of org.mozilla.javascript.NativeObject

        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

Examples of org.mozilla.javascript.NativeObject

                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

Examples of org.mozilla.javascript.NativeObject

        // 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

Examples of org.mozilla.javascript.NativeObject

        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

Examples of org.mozilla.javascript.NativeObject

            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

Examples of org.mozilla.javascript.NativeObject

                if (map == SourceMap.NONE) {
                    return new CompileResult((String) result, null);
                } else {

                    NativeObject nativeObject = (NativeObject) result;
                    String js = nativeObject.get("js").toString();
                    String sourceMap;
                    try {
                        ObjectMapper objectMapper = new ObjectMapper();
                        sourceMap = objectMapper.writeValueAsString(nativeObject.get("v3SourceMap"));
                    } catch (Exception e) {
                        sourceMap = null;
                    }

                    return new CompileResult(js, sourceMap);
View Full Code Here

Examples of org.mozilla.javascript.NativeObject

     
      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);
View Full Code Here

Examples of org.mozilla.javascript.NativeObject

            this.content = content;
            this.scope   = scope;
        }

        public Object[] buildArguments() {
            ScriptableObject so = new NativeObject();
            so.put("success", so,
                   (success) ? Boolean.TRUE : Boolean.FALSE);
            if (mime != null) {
                so.put("contentType", so,
                       Context.toObject(mime, scope));
            }
            if (content != null) {
                so.put("content", so,
                       Context.toObject(content, scope));
            }
            return new Object [] { so };
        }
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.