Examples of Scriptable


Examples of org.mozilla.javascript.Scriptable

            scriptReader = new EspReader(scriptReader);
        }

        // container for replaced properties
        Map<String, Object> replacedProperties = null;
        Scriptable scope = null;
        boolean isTopLevelCall = false;

        // create a rhino Context and execute the script
        try {

            final Context rhinoContext = Context.enter();
            rhinoContext.setOptimizationLevel(optimizationLevel());

            if (ScriptRuntime.hasTopCall(rhinoContext)) {
                // reuse the top scope if we are included
                scope = ScriptRuntime.getTopCallScope(rhinoContext);

            } else {
                // create the request top scope, use the ImporterToplevel here
                // to support the importPackage and importClasses functions
                scope = new ImporterTopLevel();

                // 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
                WrapFactory wrapFactory = ((RhinoJavaScriptEngineFactory) getFactory()).getWrapFactory();
                rhinoContext.setWrapFactory(wrapFactory);
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        SlingScriptHelper.class);
    if (sling == null) {
      throw new NullPointerException(SlingBindings.SLING);
    }

    Scriptable globalScope = ScriptableObject.getTopLevelScope(thisObj);

    Resource scriptResource = sling.getScript().getScriptResource();
    ResourceResolver resolver = scriptResource.getResourceResolver();

    // the path of the current script to resolve realtive paths
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        protected SlingWrapFactory wrapFactory;

        @Override
        public ScriptEngine getScriptEngine() {
            final Context rhinoContext = Context.enter();
            Scriptable scope = rhinoContext.initStandardObjects(new ImporterTopLevel(), false);
            return new RhinoJavaScriptEngine(this, scope);
        }
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

 
  public TabStopStructure(String text) {
    createGroups();
   
    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++) {
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        }

        String[] names = new String[] { "print", "load", "consoleWarn", "consoleError", "readFile" };
        browserSupport.defineFunctionProperties(names, scope.getClass(), ScriptableObject.DONTENUM);

        Scriptable argsObj = context.newArray(scope, new Object[]{});
        scope.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM);
    }
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

      try {

         context.setOptimizationLevel(-1);
         context.setLanguageVersion(Context.VERSION_1_6);

         Scriptable scope = context.initStandardObjects();

         String script = new StringBuilder(baseScript)
                  .append("lessToCss('")
                  .append(escape(less))
                  .append("');")
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

  /**
   * @param cx
   * @param scope
   */
  private void putConf(final Context cx, final ScriptableObject scope) {
    final Scriptable sctConf = cx.newObject(scope);
    ScriptableObject.putProperty(scope, "FILE_SEPARATOR", File.separator);
    ScriptableObject.putProperty(scope, "conf", sctConf);

    final Set<String> keys = properties.keySet();
    for (final String key : keys) {
      if (key.equals(Constants.TARGETS) || key.equals(Constants.PROFILES)) {
        final String value = getProperty(key);
        final List<String> tokens = new ArrayList<String>();
        if (value != null) {
          final StringTokenizer st = new StringTokenizer(value, ",");
          while (st.hasMoreTokens()) {
            final String token = st.nextToken();
            tokens.add(token.trim());
          }
        }
        Common.trimList(tokens);
        final Scriptable sctArray = cx.newArray(scope, tokens.toArray());
        ScriptableObject.putProperty(sctConf, key, sctArray);
      } else {
        final String value = getProperty(key);
        if (key.startsWith(Constants.OPTION_PREFIX)) {
          final Boolean b = new Boolean(value);
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

      }
    }

    Common.trimList(names);
    // System.out.println("getDuplicateFunctions:" + names.size());
    final Scriptable ar = cx.newArray(this, names.toArray());
    return ar;
  }
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

    if(context!=null) {
      return context;
    }
    context = contextFactory.createContext();
    if(scopeName.equals(GLOBAL)) {
      Scriptable scritable = context.initStandardObjects();
      context.scriptable = scritable;
    } else {
      Scriptable scritable = context.newObject(scopes.get(GLOBAL).scriptable);
      context.scriptable = scritable;
    }

    scopes.put(scopeName,context);
    return context;
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

  public void mount(String alias, Object instance) {
    mount(GLOBAL,alias,instance);
  }
 
  public void mount(String scope,String alias, Object instance) {
    Scriptable scriptable = getScope(scope).scriptable;
    Context.enter();
    Object wrappedOut = Context.toObject(instance, scriptable);
    ScriptableObject.putProperty(scriptable, alias, wrappedOut);
    Context.exit();
  }
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.