當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.newArray方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.Context.newArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.newArray方法的具體用法?Java Context.newArray怎麽用?Java Context.newArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.Context的用法示例。


在下文中一共展示了Context.newArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processFiles

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
static void processFiles(Context cx, String[] args) {
    // define "arguments" array in the top-level object:
    // need to allocate new array since newArray requires instances
    // of exactly Object[], not ObjectSubclass[]
    Object[] array = new Object[args.length];
    System.arraycopy(args, 0, array, 0, args.length);
    Scriptable argsObj = cx.newArray(global, array);
    global.defineProperty("arguments", argsObj,
            ScriptableObject.DONTENUM);

    for (String file : fileList) {
        try {
            processSource(cx, file);
        } catch (IOException ioex) {
            Context.reportError(ToolErrorReporter.getMessage(
                    "msg.couldnt.read.source", file, ioex.getMessage()));
            exitCode = EXITCODE_FILE_NOT_FOUND;
        } catch (RhinoException rex) {
            ToolErrorReporter.reportException(
                    cx.getErrorReporter(), rex);
            exitCode = EXITCODE_RUNTIME_ERROR;
        } catch (VirtualMachineError ex) {
            // Treat StackOverflow and OutOfMemory as runtime errors
            ex.printStackTrace();
            String msg = ToolErrorReporter.getMessage(
                    "msg.uncaughtJSException", ex.toString());
            Context.reportError(msg);
            exitCode = EXITCODE_RUNTIME_ERROR;
        }
    }
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:32,代碼來源:Main.java

示例2: processFiles

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
static void processFiles(Context cx, String[] args)
{
    // define "arguments" array in the top-level object:
    // need to allocate new array since newArray requires instances
    // of exactly Object[], not ObjectSubclass[]
    Object[] array = new Object[args.length];
    System.arraycopy(args, 0, array, 0, args.length);
    Scriptable argsObj = cx.newArray(global, array);
    global.defineProperty("arguments", argsObj,
                          ScriptableObject.DONTENUM);

    for (String file: fileList) {
        processSource(cx, file);
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:16,代碼來源:Main.java

示例3: Require

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
/**
 * Creates a new instance of the require() function. Upon constructing it,
 * you will either want to install it in the global (or some other) scope
 * using {@link #install(Scriptable)}, or alternatively, you can load the
 * program's main module using {@link #requireMain(Context, String)} and
 * then act on the main module's exports.
 * @param cx the current context
 * @param nativeScope a scope that provides the standard native JavaScript
 * objects.
 * @param moduleScriptProvider a provider for module scripts
 * @param preExec an optional script that is executed in every module's
 * scope before its module script is run.
 * @param postExec an optional script that is executed in every module's
 * scope after its module script is run.
 * @param sandboxed if set to true, the require function will be sandboxed.
 * This means that it doesn't have the "paths" property, and also that the
 * modules it loads don't export the "module.uri" property.
 */
public Require(Context cx, Scriptable nativeScope,
        ModuleScriptProvider moduleScriptProvider, Script preExec,
        Script postExec, boolean sandboxed) {
    this.moduleScriptProvider = moduleScriptProvider;
    this.nativeScope = nativeScope;
    this.sandboxed = sandboxed;
    this.preExec = preExec;
    this.postExec = postExec;
    setPrototype(ScriptableObject.getFunctionPrototype(nativeScope));
    if(!sandboxed) {
        paths = cx.newArray(nativeScope, 0);
        defineReadOnlyProperty(this, "paths", paths);
    }
    else {
        paths = null;
    }
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:36,代碼來源:Require.java

示例4: Require

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
/**
 * Creates a new instance of the require() function. Upon constructing it,
 * you will either want to install it in the global (or some other) scope 
 * using {@link #install(Scriptable)}, or alternatively, you can load the
 * program's main module using {@link #requireMain(Context, String)} and 
 * then act on the main module's exports.
 * @param cx the current context
 * @param nativeScope a scope that provides the standard native JavaScript 
 * objects.
 * @param moduleScriptProvider a provider for module scripts
 * @param preExec an optional script that is executed in every module's 
 * scope before its module script is run.
 * @param postExec an optional script that is executed in every module's 
 * scope after its module script is run.
 * @param sandboxed if set to true, the require function will be sandboxed. 
 * This means that it doesn't have the "paths" property, and also that the 
 * modules it loads don't export the "module.uri" property.  
 */
public Require(Context cx, Scriptable nativeScope, 
        ModuleScriptProvider moduleScriptProvider, Script preExec, 
        Script postExec, boolean sandboxed) {
    this.moduleScriptProvider = moduleScriptProvider;
    this.nativeScope = nativeScope;
    this.sandboxed = sandboxed;
    this.preExec = preExec;
    this.postExec = postExec;
    setPrototype(ScriptableObject.getFunctionPrototype(nativeScope));
    if(!sandboxed) {
        paths = cx.newArray(nativeScope, 0);
        defineReadOnlyProperty(this, "paths", paths);
    }
    else {
        paths = null;
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:36,代碼來源:Require.java


注:本文中的org.mozilla.javascript.Context.newArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。