本文整理汇总了Java中org.luaj.vm2.lib.jse.JsePlatform.debugGlobals方法的典型用法代码示例。如果您正苦于以下问题:Java JsePlatform.debugGlobals方法的具体用法?Java JsePlatform.debugGlobals怎么用?Java JsePlatform.debugGlobals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.lib.jse.JsePlatform
的用法示例。
在下文中一共展示了JsePlatform.debugGlobals方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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;
}
示例5: 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);
}
示例6: 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;
}
示例7: runFragment
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
public void runFragment( Varargs expected, String script ) {
try {
String name = getName();
Globals globals = JsePlatform.debugGlobals();
Reader reader = new StringReader(script);
LuaValue chunk ;
switch ( TEST_TYPE ) {
case TEST_TYPE_LUAJC:
LuaJC.install(globals);
chunk = globals.load(reader, name);
break;
default:
Prototype p = globals.compilePrototype(reader, name);
chunk = new LuaClosure(p, globals);
Print.print(p);
break;
}
Varargs actual = chunk.invoke();
assertEquals( expected.narg(), actual.narg() );
for ( int i=1; i<=actual.narg(); i++ )
assertEquals( expected.arg(i), actual.arg(i) );
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.toString());
}
}
示例8: compile
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
@Override
protected void compile()
{
if(globals == null) globals = JsePlatform.debugGlobals();
globals.set("require", new RequireFunction(scriptResource, globals));
globals.set("print", new PrintFunction(globals));
globals.load(new EngineLib());
globals.load(scriptSource, scriptResource.getResourceLocation().getName()).call();
}
示例9: LuaVM
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
public LuaVM(boolean debug)
{
_G = debug ? JsePlatform.debugGlobals() : JsePlatform.standardGlobals();
// Global libraries
_G.load(new MappingLib());
_G.load(new RemapperLib());
_G.load(new FSLib());
_G.load(new HTTPLib());
_G.load(new ZipLib());
// Load-on-demand libraries
_G.load(new ProfilerLib());
}
示例10: setup
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
@Before
public void setup() {
globals = JsePlatform.debugGlobals();
BaseLib.FINDER = this;
}
示例11: getGlobals
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
protected static LuaTable getGlobals() {
return JsePlatform.debugGlobals();
}
示例12: setup
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
@Before
public void setup() {
globals = JsePlatform.debugGlobals();
}
示例13: LuajContext
import org.luaj.vm2.lib.jse.JsePlatform; //导入方法依赖的package包/类
/** Construct a LuajContext with its own globals, which
* which optionally are debug globals, and optionally use the
* luajc direct lua to java bytecode compiler.
* <p>
* If createDebugGlobals is set, the globals
* created will be a debug globals that includes the debug
* library. This may provide better stack traces, but may
* have negative impact on performance.
* @param createDebugGlobals true to create debug globals,
* false for standard globals.
* @param useLuaJCCompiler true to use the luajc compiler,
* reqwuires bcel to be on the class path.
*/
public LuajContext(boolean createDebugGlobals, boolean useLuaJCCompiler) {
globals = createDebugGlobals?
JsePlatform.debugGlobals():
JsePlatform.standardGlobals();
if (useLuaJCCompiler)
LuaJC.install(globals);
stdin = globals.STDIN;
stdout = globals.STDOUT;
stderr = globals.STDERR;
}