ModuleScope.<init>
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.mozilla.javascript.commonjs.module.ModuleScope.<init> (Showing top 8 results out of 315)

origin: com.github.tntim96/rhino

static Scriptable getScope(String path) {
  if (useRequire) {
    // If CommonJS modules are enabled use a module scope that resolves
    // relative ids relative to the current URL, file or working directory.
    URI uri;
    if (path == null) {
      // use current directory for shell and -e switch
      uri = new File(System.getProperty("user.dir")).toURI();
    } else {
      // find out whether this is a file path or a URL
      if (SourceReader.toUrl(path) != null) {
        try {
          uri = new URI(path);
        } catch (URISyntaxException x) {
          // fall back to file uri
          uri = new File(path).toURI();
        }
      } else {
        uri = new File(path).toURI();
      }
    }
    return new ModuleScope(global, uri, null);
  } else {
    return global;
  }
}
origin: ro.isdc.wro4j/rhino

static Scriptable getScope(String path) {
  if (useRequire) {
    // If CommonJS modules are enabled use a module scope that resolves
    // relative ids relative to the current URL, file or working directory.
    URI uri;
    if (path == null) {
      // use current directory for shell and -e switch
      uri = new File(System.getProperty("user.dir")).toURI();
    } else {
      // find out whether this is a file path or a URL
      if (SourceReader.toUrl(path) != null) {
        try {
          uri = new URI(path);
        } catch (URISyntaxException x) {
          // fall back to file uri
          uri = new File(path).toURI();
        }
      } else {
        uri = new File(path).toURI();
      }
    }
    return new ModuleScope(global, uri, null);
  } else {
    return global;
  }
}
origin: mulesoft-labs/rhinodo

  @Override
  public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
    final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
        thisObj);
    defineReadOnlyProperty(moduleObject, "id", args[0]);
    String path = Context.toString(args[1]);
    File file = new File(path);
    URI uri = file.toURI();
    URI base;
    if (file.exists() && file.isFile()) {
      base = file.getParentFile().toURI();
    } else {
      base = file.toURI();
    }
    final Scriptable executionScope = new ModuleScope(thisObj, uri, base);
    defineReadOnlyProperty(moduleObject, "uri", uri.toString());
    Scriptable exports = cx.newObject(scope);
    executionScope.put("exports", executionScope, exports);
    executionScope.put("module", executionScope, moduleObject);
    moduleObject.put("exports", moduleObject, exports);
    install(executionScope);
    executeOptionalScript(preExec, cx, executionScope);
    cx.compileString(Context.toString(args[0]), path, 0, null).exec(cx, executionScope);
    executeOptionalScript(postExec, cx, executionScope);
    return ScriptRuntime.toObject(scope,
        ScriptableObject.getProperty(moduleObject, "exports"));
  }
};
origin: de.matrixweb.smaller/javascript

private void init(final Class<?> clazz) {
 final Context context = Context.enter();
 context.setOptimizationLevel(this.optimizationLevel);
 context.setLanguageVersion(Context.VERSION_1_7);
 final ScriptableObject scope = context.initStandardObjects();
 final Require require = new Require(Context.getCurrentContext(), scope,
   getModuleScriptProvider(clazz), null, null, false);
 require.install(scope);
 try {
  this.moduleScope = new ModuleScope(scope, new URI("./" + this.name), null);
 } catch (final URISyntaxException e) {
  throw new SmallerException("Failed to create moduleScope", e);
 }
 addGlobalFunction("print", LOGGER, "info");
}
origin: io.apigee/rhino

private Scriptable executeModuleScript(Context cx, String id,
    Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
  final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
      nativeScope);
  URI uri = moduleScript.getUri();
  URI base = moduleScript.getBase();
  defineReadOnlyProperty(moduleObject, "id", id);
  if(!sandboxed) {
    defineReadOnlyProperty(moduleObject, "uri", uri.toString());
  }
  final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
  // Set this so it can access the global JS environment objects.
  // This means we're currently using the "MGN" approach (ModuleScript
  // with Global Natives) as specified here:
  // <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
  executionScope.put("exports", executionScope, exports);
  executionScope.put("module", executionScope, moduleObject);
  moduleObject.put("exports", moduleObject, exports);
  install(executionScope);
  if(isMain) {
    defineReadOnlyProperty(this, "main", moduleObject);
  }
  executeOptionalScript(preExec, cx, executionScope);
  moduleScript.getScript().exec(cx, executionScope);
  executeOptionalScript(postExec, cx, executionScope);
  return ScriptRuntime.toObject(nativeScope,
      ScriptableObject.getProperty(moduleObject, "exports"));
}
origin: geogebra/geogebra

private Scriptable executeModuleScript(Context cx, String id,
    Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
  final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
      nativeScope);
  URI uri = moduleScript.getUri();
  URI base = moduleScript.getBase();
  defineReadOnlyProperty(moduleObject, "id", id);
  if(!sandboxed) {
    defineReadOnlyProperty(moduleObject, "uri", uri.toString());
  }
  final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
  // Set this so it can access the global JS environment objects.
  // This means we're currently using the "MGN" approach (ModuleScript
  // with Global Natives) as specified here:
  // <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
  executionScope.put("exports", executionScope, exports);
  executionScope.put("module", executionScope, moduleObject);
  moduleObject.put("exports", moduleObject, exports);
  install(executionScope);
  if(isMain) {
    defineReadOnlyProperty(this, "main", moduleObject);
  }
  executeOptionalScript(preExec, cx, executionScope);
  moduleScript.getScript().exec(cx, executionScope);
  executeOptionalScript(postExec, cx, executionScope);
  return ScriptRuntime.toObject(cx, nativeScope,
      ScriptableObject.getProperty(moduleObject, "exports"));
}
origin: ro.isdc.wro4j/rhino

private Scriptable executeModuleScript(Context cx, String id,
    Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
  final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
      nativeScope);
  URI uri = moduleScript.getUri();
  URI base = moduleScript.getBase();
  defineReadOnlyProperty(moduleObject, "id", id);
  if(!sandboxed) {
    defineReadOnlyProperty(moduleObject, "uri", uri.toString());
  }
  final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
  // Set this so it can access the global JS environment objects.
  // This means we're currently using the "MGN" approach (ModuleScript
  // with Global Natives) as specified here:
  // <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
  executionScope.put("exports", executionScope, exports);
  executionScope.put("module", executionScope, moduleObject);
  moduleObject.put("exports", moduleObject, exports);
  install(executionScope);
  if(isMain) {
    defineReadOnlyProperty(this, "main", moduleObject);
  }
  executeOptionalScript(preExec, cx, executionScope);
  moduleScript.getScript().exec(cx, executionScope);
  executeOptionalScript(postExec, cx, executionScope);
  return ScriptRuntime.toObject(nativeScope,
      ScriptableObject.getProperty(moduleObject, "exports"));
}
origin: com.github.tntim96/rhino

private Scriptable executeModuleScript(Context cx, String id,
    Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
  final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
      nativeScope);
  URI uri = moduleScript.getUri();
  URI base = moduleScript.getBase();
  defineReadOnlyProperty(moduleObject, "id", id);
  if(!sandboxed) {
    defineReadOnlyProperty(moduleObject, "uri", uri.toString());
  }
  final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
  // Set this so it can access the global JS environment objects.
  // This means we're currently using the "MGN" approach (ModuleScript
  // with Global Natives) as specified here:
  // <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
  executionScope.put("exports", executionScope, exports);
  executionScope.put("module", executionScope, moduleObject);
  moduleObject.put("exports", moduleObject, exports);
  install(executionScope);
  if(isMain) {
    defineReadOnlyProperty(this, "main", moduleObject);
  }
  executeOptionalScript(preExec, cx, executionScope);
  moduleScript.getScript().exec(cx, executionScope);
  executeOptionalScript(postExec, cx, executionScope);
  return ScriptRuntime.toObject(nativeScope,
      ScriptableObject.getProperty(moduleObject, "exports"));
}
org.mozilla.javascript.commonjs.moduleModuleScope<init>

Popular methods of ModuleScope

  • getBase
  • getUri
  • cacheBuiltins
  • setPrototype

Popular in Java

  • Making http post requests using okhttp
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Permission (java.security)
    Legacy security code; do not use.
  • JTable (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)