org.mozilla.javascript.ImporterTopLevel.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 JavaScript  
字(7.5k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中org.mozilla.javascript.ImporterTopLevel.<init>()方法的一些代码示例,展示了ImporterTopLevel.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImporterTopLevel.<init>()方法的具体详情如下:
包路径:org.mozilla.javascript.ImporterTopLevel
类名称:ImporterTopLevel
方法名:<init>

ImporterTopLevel.<init>介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

private Scriptable setupScope(Context cx, ScriptContext context) {
    ScriptableObject scriptable = new ImporterTopLevel(cx);
    Scriptable scope = cx.initStandardObjects(scriptable);
    //ScriptableObject.putProperty(scope, "argv", Context.javaToJS(args, scope));
    return scope;
  }
}

代码示例来源:origin: galenframework/galen

public GalenJsExecutor() {
  this.context = Context.enter();
  this.scope = new ImporterTopLevel(context);
  
  this.loadFunction = new JsFunctionLoad();
  scope.defineProperty("load", loadFunction, ScriptableObject.DONTENUM);
  importAllMajorClasses();
}

代码示例来源:origin: facebook/stetho

private @NonNull ScriptableObject initJsScope(@NonNull Context jsContext) {
 // Set the main Rhino goodies
 ImporterTopLevel importerTopLevel = new ImporterTopLevel(jsContext);
 ScriptableObject scope = jsContext.initStandardObjects(importerTopLevel, false);
 ScriptableObject.putProperty(scope, "context", Context.javaToJS(mContext, scope));
 try {
  importClasses(jsContext, scope);
  importPackages(jsContext, scope);
  importConsole(scope);
  importVariables(scope);
  importFunctions(scope);
 } catch (StethoJsException e) {
  String message = String.format("%s\n%s", e.getMessage(), Log.getStackTraceString(e));
  LogUtil.e(e, message);
  CLog.writeToConsole(Console.MessageLevel.ERROR, Console.MessageSource.JAVASCRIPT, message);
 }
 return scope;
}

代码示例来源:origin: EngineHub/WorldEdit

RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
Context cx = factory.enterContext();
ScriptableObject scriptable = new ImporterTopLevel(cx);
Scriptable scope = cx.initStandardObjects(scriptable);

代码示例来源:origin: rhino/js

public static void init(Context cx, Scriptable scope, boolean sealed)
{
  ImporterTopLevel obj = new ImporterTopLevel();
  obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

代码示例来源:origin: geogebra/geogebra

public static void init(Context cx, Scriptable scope, boolean sealed)
{
  ImporterTopLevel obj = new ImporterTopLevel();
  obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

代码示例来源:origin: ro.isdc.wro4j/rhino

public static void init(Context cx, Scriptable scope, boolean sealed)
{
  ImporterTopLevel obj = new ImporterTopLevel();
  obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

代码示例来源:origin: com.github.tntim96/rhino

public static void init(Context cx, Scriptable scope, boolean sealed)
{
  ImporterTopLevel obj = new ImporterTopLevel();
  obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

代码示例来源:origin: io.apigee/rhino

public static void init(Context cx, Scriptable scope, boolean sealed)
{
  ImporterTopLevel obj = new ImporterTopLevel();
  obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

public static void init(Context cx, Scriptable scope, boolean sealed)
{
  ImporterTopLevel obj = new ImporterTopLevel();
  obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

代码示例来源:origin: rhino/js

public static ScriptableObject getGlobal(Context cx) {
  final String GLOBAL_CLASS = "org.mozilla.javascript.tools.shell.Global";
  Class<?> globalClass = Kit.classOrNull(GLOBAL_CLASS);
  if (globalClass != null) {
    try {
      Class<?>[] parm = { ScriptRuntime.ContextClass };
      Constructor<?> globalClassCtor = globalClass.getConstructor(parm);
      Object[] arg = { cx };
      return (ScriptableObject) globalClassCtor.newInstance(arg);
    } catch (Exception e) {
      // fall through...
    }
  }
  return new ImporterTopLevel(cx);
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

public static ScriptableObject getGlobal(Context cx) {
  final String GLOBAL_CLASS = "org.mozilla.javascript.tools.shell.Global";
  Class globalClass = Kit.classOrNull(GLOBAL_CLASS);
  if (globalClass != null) {
    try {
      Class[] parm = { ScriptRuntime.ContextClass };
      Constructor globalClassCtor = globalClass.getConstructor(parm);
      Object[] arg = { cx };
      return (ScriptableObject) globalClassCtor.newInstance(arg);
    } catch (Exception e) {
      // fall through...
    }
  }
  return new ImporterTopLevel(cx);
}

代码示例来源:origin: org.apache.pig/pig

public JsScriptEngine() {
  Context context = getContext();
  scope = new ImporterTopLevel(context); // so that we can use importPackage()
  context.evaluateString(scope, printSource, "print", 1, null); // so that we can print on std out
}

代码示例来源:origin: com.galenframework/galen-core

public GalenJsExecutor() {
  this.context = Context.enter();
  this.scope = new ImporterTopLevel(context);
  
  this.loadFunction = new JsFunctionLoad();
  scope.defineProperty("load", loadFunction, ScriptableObject.DONTENUM);
  importAllMajorClasses();
}

代码示例来源:origin: com.couchbase.mock/CouchbaseMock

public JavascriptRun() {
  Context cx = Context.enter();
  scope = new ImporterTopLevel(cx);
  try {
    cx.evaluateString(scope, COLLATE_JS, "collate.js", 1, null);
    cx.evaluateString(scope, VIEWIDXR_JS, "viewidxr.js", 1, null);
  } finally {
    Context.exit();
  }
  execFunc = (Function) scope.get("execute", scope);
}

代码示例来源:origin: com.couchbase.mock/CouchbaseMock

private Reducer(String reduceTxt, Context cx) {
  Scriptable scope = new ImporterTopLevel(cx);
  cx.evaluateString(scope, REDUCE_JS, "reduce.js", 1, null);
  Scriptable builtins = (Scriptable) scope.get("BUILTIN_REDUCERS", scope);
  if (builtins.has(reduceTxt, builtins)) {
    reduceFunc = (Function)builtins.get(reduceTxt, builtins);
  } else {
    reduceFunc = cx.compileFunction(scope, reduceTxt, "reduce", 1, null);
  }
}

代码示例来源:origin: couchbase/CouchbaseMock

private Reducer(String reduceTxt, Context cx) {
  Scriptable scope = new ImporterTopLevel(cx);
  cx.evaluateString(scope, REDUCE_JS, "reduce.js", 1, null);
  Scriptable builtins = (Scriptable) scope.get("BUILTIN_REDUCERS", scope);
  if (builtins.has(reduceTxt, builtins)) {
    reduceFunc = (Function)builtins.get(reduceTxt, builtins);
  } else {
    reduceFunc = cx.compileFunction(scope, reduceTxt, "reduce", 1, null);
  }
}

代码示例来源:origin: couchbase/CouchbaseMock

public JavascriptRun() {
  Context cx = Context.enter();
  scope = new ImporterTopLevel(cx);
  try {
    cx.evaluateString(scope, COLLATE_JS, "collate.js", 1, null);
    cx.evaluateString(scope, VIEWIDXR_JS, "viewidxr.js", 1, null);
  } finally {
    Context.exit();
  }
  execFunc = (Function) scope.get("execute", scope);
}

代码示例来源:origin: couchbase/CouchbaseMock

private Indexer(String mapTxt, Context cx) {
  scope = new ImporterTopLevel(cx);
  cx.evaluateString(scope, INDEX_JS, "index.js", 1, null); // Index source
  cx.evaluateString(scope, JavascriptRun.getCollateJS(), "collate.js", 1, null); // Collation
  mapFunction = cx.compileFunction(scope, mapTxt, "map", 1, null);
  // var index = new Index()
  indexResults = cx.newObject(scope, "Index");
  indexFunction = (Function) indexResults.getPrototype().get("indexDoc", indexResults);
  // var emit = index.emit
  Function emitFunc = (Function) indexResults.getPrototype().get("emit", indexResults);
  emitFunc = new BoundFunction(cx, scope, emitFunc, indexResults, NO_ARGS);
  scope.put("emit", scope, emitFunc);
}

代码示例来源:origin: com.couchbase.mock/CouchbaseMock

private Indexer(String mapTxt, Context cx) {
  scope = new ImporterTopLevel(cx);
  cx.evaluateString(scope, INDEX_JS, "index.js", 1, null); // Index source
  cx.evaluateString(scope, JavascriptRun.getCollateJS(), "collate.js", 1, null); // Collation
  mapFunction = cx.compileFunction(scope, mapTxt, "map", 1, null);
  // var index = new Index()
  indexResults = cx.newObject(scope, "Index");
  indexFunction = (Function) indexResults.getPrototype().get("indexDoc", indexResults);
  // var emit = index.emit
  Function emitFunc = (Function) indexResults.getPrototype().get("emit", indexResults);
  emitFunc = new BoundFunction(cx, scope, emitFunc, indexResults, NO_ARGS);
  scope.put("emit", scope, emitFunc);
}

相关文章