当前位置: 首页>>代码示例>>Java>>正文


Java JsePlatform类代码示例

本文整理汇总了Java中org.luaj.vm2.lib.jse.JsePlatform的典型用法代码示例。如果您正苦于以下问题:Java JsePlatform类的具体用法?Java JsePlatform怎么用?Java JsePlatform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsePlatform类属于org.luaj.vm2.lib.jse包,在下文中一共展示了JsePlatform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupGlobals

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
/**
 * setup global values
 *
 * @param globals
 */
private static Globals setupGlobals(Globals globals) {
    if (globals != null) {
        if (LuaViewConfig.isOpenDebugger()) {
            JsePlatform.debugGlobals(globals);
        } else {
            JsePlatform.standardGlobals(globals);//加载系统libs TODO 性能瓶颈
        }

        if (LuaViewConfig.isUseLuaDC()) {
            LuaDC.install(globals);
        }
        loadLuaViewLibs(globals);//加载用户lib TODO 性能瓶颈
        globals.isInited = true;
    }
    return globals;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:22,代码来源:LuaViewManager.java

示例2: HTTPInputGenerator

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
/**
 * Constructs a new HTTPInputGenerator using a Lua generation script.
 * The Lua script must contain the onInit() and onCall(callnum) functions.
 * onCall(callnum) must return the HTTP request for a specific call with number callnum.
 * callnum begins at 1 (Lua convention) and increments for each call. It resets back to 1
 * if onCall returns nil.
 * @param scriptFile The url generator script.
 * @param randomSeed Seed for Lua random function.
 * @param timeout The http read timeout.
 */
public HTTPInputGenerator(File scriptFile, int randomSeed, int timeout) {
	OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
	cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
	httpClientBuilder = httpClientBuilder.cookieJar(new JavaNetCookieJar(cookieManager));
	if (timeout > 0) {
		httpClientBuilder = httpClientBuilder.readTimeout(timeout, TimeUnit.MILLISECONDS)
			.connectTimeout(timeout, TimeUnit.MILLISECONDS);
	}
	httpClient = httpClientBuilder.build();
	if (scriptFile != null) {
		luaGlobals = JsePlatform.standardGlobals();
		//luaGlobals.get("require").call(LuaValue.valueOf("tools.descartes.httploadgenerator.http.lua.HTML"));
		LuaValue library = new LuaTable();
		library.set("getMatches", new GetMatches(htmlFunctions));
		library.set("extractMatches", new ExtractAllMatches(htmlFunctions));
		luaGlobals.set("html", library);
		luaGlobals.get("math").get("randomseed").call(LuaValue.valueOf(5));
		luaGlobals.get("dofile").call(LuaValue.valueOf(scriptFile.getAbsolutePath()));
	}
}
 
开发者ID:joakimkistowski,项目名称:HTTP-Load-Generator,代码行数:31,代码来源:HTTPInputGenerator.java

示例3: main

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public static void main(String[] args) {
        Globals globals = JsePlatform.debugGlobals();
        globals.set("Core", new LuaTable());
        globals.get("Core").set("createEntityTemplate", new CreateEntityTemplate());
        globals.get("Core").set("invoke", new Invoke());
        globals.get("Core").set("destroy", new CreateEntityTemplate());
        
        ScriptableComponent cmp = new ScriptableComponent();
        
        File scripts = new File("scripts/");
        
        List<File> files = getFilesRec(scripts);
        for (File f : files) {
            if (f.getName().equals("autorun.lua")) globals.loadfile(f.getAbsolutePath()).call();
        }
//        cmp.initMethods();
        
//        cmp.awake();
        
//        cmp.setEnabled(true);
        
//        cmp.executeMethod(Events.CollisionEnter);
    }
 
开发者ID:AlexMog,项目名称:SurvivalMMO,代码行数:24,代码来源:TestScripts.java

示例4: completed

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public void completed(String message, SocketReader socketReader) throws IOException {
    final int valueSize = Integer.parseInt(message);
    final String valueString = socketReader.readBytes(valueSize);

    log.debug("Read value: " + valueString);
    try {
        Globals globals = JsePlatform.debugGlobals();
        LuaValue chunk = globals.load(valueString);
        LuaTable stackDump = chunk.call().checktable();  // Executes the chunk and returns it
        LuaRemoteStack.clearIdKey(stackDump);
        LuaValue rawValue = stackDump;
        if (stackDump.keyCount() == 1)
            rawValue = stackDump.get(1);
        else if (stackDump.keyCount() == 0)
            rawValue = LuaValue.NIL;
        LuaDebugValue value = new LuaDebugValue(rawValue, AllIcons.Debugger.Watch);
        myPromise.setResult(value);
    } catch (LuaError e) {
        LuaDebugValue errorValue = new LuaDebugValue(
                "error",
                "Error during evaluation: " + e.getMessage(),
                AllIcons.Nodes.ErrorMark
        );
        myPromise.setResult(errorValue);
    }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:27,代码来源:LuaDebuggerController.java

示例5: main

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public static void main(String[] args)  {

    	String script = "/lua/luatest.lua";
    	//URL url = LuaTest.class.getResource(script).toExternalForm();

    	// From luatest.lua
    	// function MyAdd( num1, num2 )
        //		return num1 + num2
        // end

        //run the lua script defining your function
        LuaValue _G = JsePlatform.standardGlobals();
        _G.get("dofile").call( LuaValue.valueOf(script));

        //call the function MyAdd with two parameters 5, and 5
        LuaValue addition = _G.get("MyAdd");
        LuaValue retvals = addition.call(LuaValue.valueOf(5), LuaValue.valueOf(5));

        //print out the result from the lua function
        System.out.println("The result from executing the script is :\n\n" + retvals.tojstring(1));
    }
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:22,代码来源:LuaTest.java

示例6: makeGlobals

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public static LuaTable makeGlobals(boolean stdout) {
	LuaTable globals = JsePlatform.debugGlobals();

	if (!stdout) {
		JseBaseLib lib = new JseBaseLib();
		lib.STDOUT = new PrintStream(new OutputStream() {
			@Override
			public void write(int b) throws IOException {
			}
		});

		globals.load(lib);
	}
	globals.set("assertEquals", new AssertFunction());
	globals.set("assertMany", new AssertManyFunction());
	globals.set("makeError", new MakeErrorFunction());

	return globals;
}
 
开发者ID:SquidDev,项目名称:luaj.luajc,代码行数:20,代码来源:LuaEnv.java

示例7: compile

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
/**
 * Compiles this script in preperation for evaluation
 *
 * @see LuaScript#exec()
 *
 * @throws ScriptException if the script has already been compiled
 */
public final void compile() throws ScriptException {
    // Create globals
    globals = JsePlatform.standardGlobals();

    // Load libs
    LuaValue require = globals.get("require");
    DEFAULT_LIBS.forEach(lib -> require.call("clientapi.lua.lib." + lib));

    // Compile script
    compiled = globals.load(code);
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:19,代码来源:LuaScript.java

示例8: testLuaRunner

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
@Test
public void testLuaRunner() {
    String luaScript = Utils.toString(new File("lua_test/test.lua"));
    Globals globals = JsePlatform.standardGlobals();
    LuaValue value = globals.load(luaScript);
    value.invoke();
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:8,代码来源:LuaRunnerTest.java

示例9: execute

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
@Test
public void execute() throws Exception {
    Globals globals = JsePlatform.standardGlobals();
    //        globals.set("LCallback", new LCallback());

    LuaValue value = globals.load(helloWorldScript);
    value.call();
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:9,代码来源:ScriptTest.java

示例10: Environment

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
/**
 * Constructor. Prepare LuaJ and start game.
 * @param game Game to start
 * @param player Player in game
 */
public Environment(Game game, Player player) {
    Environment.game = game;

    lua = JsePlatform.standardGlobals();

    registerPlayer(player);
    registerGame();
    registerIO();
}
 
开发者ID:achjaj,项目名称:Tengine,代码行数:15,代码来源:Environment.java

示例11: create

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public static LuaRemoteStack create(String code) {
    Globals globals = JsePlatform.debugGlobals();
    LuaValue chunk = globals.load(code);
    LuaTable stackDump = chunk.call().checktable();
    clearIdKey(stackDump);
    return new LuaRemoteStack(stackDump);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:8,代码来源:LuaRemoteStack.java

示例12: init

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public static Globals init() {
    if(g == null) {
        LuaMesh.debug = System.out::println;
        register("ObjectFields");
        register("ObjectLibraries");
        register("ObjectMethods");
        register("ObjectNames");
        register("UnidirectionalDelegate");
        LuaMesh.register(UnidirectionalTarget.class, name -> {
            switch(name) {
                case "doThings": return "doStuff";
                default: return name;
            }
        });

        try {
            LuaMesh.init();
        } catch(Throwable any) {
            any.printStackTrace();
            Assert.fail("Initialization failed.");
        }

        g = JsePlatform.debugGlobals();
        g.set("ctype", new FunctionCType());
    }

    return g;
}
 
开发者ID:Xemiru,项目名称:LuaMesh,代码行数:29,代码来源:Utility.java

示例13: getLocalGlobals

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public Globals getLocalGlobals() {
	long threadId = Thread.currentThread().getId();
	if (!threadCompilers.containsKey(threadId)) {
		if(sandboxed) {
			threadCompilers.put(threadId, createSandboxedGlobals());
		} else {
			threadCompilers.put(threadId, JsePlatform.standardGlobals());
		}
	}
	return threadCompilers.get(threadId);
}
 
开发者ID:mini2Dx,项目名称:miniscript,代码行数:12,代码来源:LuaScriptExecutorPool.java

示例14: LuaJScript

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public LuaJScript (LuaJScriptLoader scriptLoader, String script, String name) {
	this.script = script;
	this.loader = scriptLoader;
	this.name = name;
	this.context = JsePlatform.standardGlobals();
	this.scriptTable = new LuaTable();
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:8,代码来源:LuaJScript.java

示例15: main

import org.luaj.vm2.lib.jse.JsePlatform; //导入依赖的package包/类
public static void main( String[] args )
  {
String script1 = "print('Hello, Mars!')";
String script2 = "print('Running version', _VERSION)";


// create an environment to run in
Globals globals = JsePlatform.standardGlobals();

// Use the convenience function on the globals to load a chunk.
LuaValue chunk = globals.load(script1, "maven-exmaple");

// Use any of the "call()" or "invoke()" functions directly on the chunk.
chunk.call();
  }
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:16,代码来源:App.java


注:本文中的org.luaj.vm2.lib.jse.JsePlatform类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。