本文整理汇总了Java中org.luaj.vm2.LoadState类的典型用法代码示例。如果您正苦于以下问题:Java LoadState类的具体用法?Java LoadState怎么用?Java LoadState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoadState类属于org.luaj.vm2包,在下文中一共展示了LoadState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: standardGlobals
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see JsePlatform
* @see JmePlatform
*/
public static Globals standardGlobals() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseOsLib());
// globals.load(new JseIoLib());//安全考虑,删除for LuaView
// globals.load(new LuajavaLib());//安全考虑,删除for LuaView
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
示例2: main
import org.luaj.vm2.LoadState; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
//Globals globals = JsePlatform.standardGlobals();
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseIoLib());
globals.load(new JseOsLib());
globals.load(new JavaLibInteractionTest());
LoadState.install(globals);
LuaC.install(globals);
System.out.println(new File(".").getAbsolutePath());
System.out.println(new File(args[0]).exists());
LuaValue chunk = globals.loadfile(new File(args[0]).getAbsolutePath());
chunk.call();
}
示例3: setupCompilerGlobal
import org.luaj.vm2.LoadState; //导入依赖的package包/类
private static Globals setupCompilerGlobal() {
// Create server globals with just enough library support to compile user
// scripts.
compiler = new Globals();
compiler.load(new JseBaseLib());
compiler.load(new PackageLib());
compiler.load(new StringLib());
// To load scripts, we occasionally need a math library in addition to compiler
// support.
// To limit scripts using the debug library, they must be closures, so we only
// install LuaC.
compiler.load(new JseMathLib());
LoadState.install(compiler);
LuaC.install(compiler);
// Set up the LuaString metatable to be read-only since it is shared across all
// scripts.
LuaString.s_metatable = new ReadOnlyLuaTable(LuaString.s_metatable);
return compiler;
}
示例4: standardGlobals
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see JsePlatform
* @see org.luaj.vm2.lib.jme.JmePlatform
*/
public static Globals standardGlobals() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseIoLib());
globals.load(new JseOsLib());
globals.load(new LuajavaLib());
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
示例5: LuaScriptExecutorPool
import org.luaj.vm2.LoadState; //导入依赖的package包/类
public LuaScriptExecutorPool(GameScriptingEngine gameScriptingEngine, int poolSize, boolean sandboxed) {
this.gameScriptingEngine = gameScriptingEngine;
this.sandboxed = sandboxed;
executors = new ArrayBlockingQueue<ScriptExecutor<LuaValue>>(poolSize);
for (int i = 0; i < poolSize; i++) {
executors.offer(new LuaScriptExecutor(this));
}
if(sandboxed) {
//Create sandboxed compiler
sandboxedGlobals = new Globals();
sandboxedGlobals.load(new JseBaseLib());
sandboxedGlobals.load(new PackageLib());
sandboxedGlobals.load(new StringLib());
// To load scripts, we occasionally need a math library in addition to compiler support.
// To limit scripts using the debug library, they must be closures, so we only install LuaC.
sandboxedGlobals.load(new JseMathLib());
LoadState.install(sandboxedGlobals);
LuaC.install(sandboxedGlobals);
}
}
示例6: standardGlobals
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see JsePlatform
* @see JmePlatform
*/
public static Globals standardGlobals() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseIoLib());
globals.load(new JseOsLib());
globals.load(new LuajavaLib());
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
示例7: LuaEngine
import org.luaj.vm2.LoadState; //导入依赖的package包/类
private LuaEngine() {
globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseIoLib());
globals.load(new JseOsLib());
globals.load(new MultiDexLuajavaLib());
LoadState.install(globals);
LuaC.install(globals);
globals.finder = this;
globals.set("loadResource", new resLoader());
}
示例8: loadSkeletalAnimation
import org.luaj.vm2.LoadState; //导入依赖的package包/类
private static void loadSkeletalAnimation(Animation animation, File animationFile) throws IOException
{
Globals globals = new Globals();
globals.load(new PackageLib());
globals.load(new JseMathLib());
LoadState.install(globals);
LuaC.install(globals);
LuaValue chunk = globals.load(new FileReader(animationFile), "SkeletalAnimation");
chunk.call();
LuaTable rootT = globals.get("root").checktable();
LuaTable animationT = globals.get("animation").checktable();
loadAnimation(animation, animationT, rootT);
animation.root = loadBone(animation, rootT);
}
示例9: standardGlobals
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Create a standard set of globals for JME including all the libraries.
*
* @return Table of globals initialized with the standard JME libraries
* @see #debugGlobals()
* @see JsePlatform
* @see JmePlatform
*/
public static Globals standardGlobals() {
Globals globals = new Globals();
globals.load(new BaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new OsLib());
globals.load(new MathLib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JmeIoLib());
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
示例10: dumpHeader
import org.luaj.vm2.LoadState; //导入依赖的package包/类
void dumpHeader() throws IOException {
writer.write( LoadState.LUA_SIGNATURE );
writer.write( LoadState.LUAC_VERSION );
writer.write( LoadState.LUAC_FORMAT );
writer.write( IS_LITTLE_ENDIAN? 1: 0 );
writer.write( SIZEOF_INT );
writer.write( SIZEOF_SIZET );
writer.write( SIZEOF_INSTRUCTION );
writer.write( SIZEOF_LUA_NUMBER );
writer.write( NUMBER_FORMAT );
writer.write( LoadState.LUAC_TAIL );
}
示例11: loadPrototype
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* load a prototype
*
* @param scriptFile
* @return
*/
private Prototype loadPrototype(final ScriptFile scriptFile) {
if (LoadState.instance != null && scriptFile != null) {
try {
return LoadState.instance.undump(new BufferedInputStream(new ByteArrayInputStream(scriptFile.scriptData)), scriptFile.getFilePath());//TODO 低端机性能上可以进一步优化
} catch (LuaError error) {
error.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
示例12: standardGlobals
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see org.luaj.vm2.lib.jse.JsePlatform
* @see org.luaj.vm2.lib.jme.JmePlatform
*/
public static Globals standardGlobals() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new JseMathLib());
globals.load(new JseOsLib());
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
示例13: newStandard
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Create a new lua Globals object representing the standard one used in this game
*
* @return a new Globals instance
*/
public static Globals newStandard() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new JseMathLib());
LoadState.install(globals);
LuaC.install(globals);
LuaJC.install(globals);
return globals;
}
示例14: initEnvironment
import org.luaj.vm2.LoadState; //导入依赖的package包/类
private void initEnvironment() {
environment = new Globals();
LoadState.install(environment);
LuaC.install(environment);
LuaJC.install(environment);
modsTable = new LuaTable();
environment.set("mods", modsTable);
}
示例15: loadScript
import org.luaj.vm2.LoadState; //导入依赖的package包/类
/**
* Loads a script into the global table
*
* @param name The name of the file
* @return The loaded LuaFunction
* @throws IOException
*/
private LuaValue loadScript(String name) throws IOException {
InputStream script = this.findResource(name + ".lua");
if (script == null) fail("Could not load script for test case: " + name);
try {
return LoadState.load(script, "@" + name + ".lua", globals);
} finally {
script.close();
}
}