本文整理汇总了Java中org.luaj.vm2.lib.ZeroArgFunction类的典型用法代码示例。如果您正苦于以下问题:Java ZeroArgFunction类的具体用法?Java ZeroArgFunction怎么用?Java ZeroArgFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZeroArgFunction类属于org.luaj.vm2.lib包,在下文中一共展示了ZeroArgFunction类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: LuaVM
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
LuaVM() {
this.hookfunc = new ZeroArgFunction() {
public LuaValue call() {
System.out.println("script overan resource limits");
// A simple lua error may be caught by the script, but a
// Java Error will pass through to top and stop the script.
throw new Error("Script overran resource limits.");
}
};
this.localState = getLocalCompiler();
}
开发者ID:hamilton-lima,项目名称:robolucha,代码行数:13,代码来源:LuaVM.java
示例2: LResponse
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
LResponse() {
super();
set("header", new ZeroArgFunction() {
@Override
public LuaValue call() {
if (mHeader == null) {
return LuaValue.NIL;
}
return LuaString.valueOf(mHeader);
}
});
set("body", new ZeroArgFunction() {
@Override
public LuaValue call() {
if (mBody == null) {
return LuaValue.NIL;
}
return LuaString.valueOf(mBody);
}
});
set("status", new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaInteger.valueOf(mStatusCode);
}
});
}
开发者ID:hsllany,项目名称:HtmlNative,代码行数:30,代码来源:LHttp.java
示例3: LObject
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
LObject() {
super();
set("type", new ZeroArgFunction() {
@Override
public LuaValue call() {
String className = LObject.this.onObjectClassName();
if (className != null) {
return LuaString.valueOf(className);
} else {
return LuaValue.NIL;
}
}
});
}
开发者ID:hsllany,项目名称:HtmlNative,代码行数:15,代码来源:LObject.java
示例4: LuaClass
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
public LuaClass(final Class c) {
super(new Object());
this.c = c;
luaTable1();
metatable.rawset("__newindex", new ThreeArgFunction() {
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
String s = arg2.tojstring();
try {
Field field = c.getField(s);
int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)
&& field.getAnnotation(LuaExclude.class) == null) {
Class<?> type = field.getType();
Object o = LuaConversion.convertToJava(type, arg3);
field.set(null, o);
return NIL;
}
} catch (Exception e) {
if (e instanceof ConversionError)
throw (ConversionError) e;
}
error("No such field: " + s);
return null;
}
});
luaTable3();
metatable.rawset("__tostring", new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaValue.valueOf("[JClass: " + LuaClass.this.c.getName() + "]");
}
});
metatable.rawset("__metatable", LuaValue.FALSE);
setmetatable(metatable);
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:41,代码来源:LuaClass.java
示例5: LuaPackage
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
public LuaPackage(final String path) {
super(new Object());
this.path = path;
LuaTable metatable = new LuaTable();
metatable.rawset("__index", new TwoArgFunction() {
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2) {
if (arg2.checkjstring().equals("class")) {
try {
Class<?> cla = Class.forName(path);
return new LuaClass(cla);
} catch (ClassNotFoundException e) {
throw new LuaError("No such class: " + path);
}
}
String name = path.isEmpty() ? arg2.checkjstring() : path + "." + arg2.checkjstring();
return new LuaPackage(name);
}
});
metatable.rawset("__tostring", new ZeroArgFunction() {
@Override
public LuaValue call() {
if (path.isEmpty()) return LuaValue.valueOf("[JPackage Root]");
return LuaValue.valueOf("[JPackage: " + path + "]");
}
});
metatable.rawset("__metatable", LuaValue.FALSE);
setmetatable(metatable);
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:31,代码来源:LuaPackage.java
示例6: setUp
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
eventManager = new ScriptEventManager(new DummySafeInvoker());
callbackInvoked = new AtomicInteger(0);
callback = new ZeroArgFunction() {
@Override
public LuaValue call() {
callbackInvoked.incrementAndGet();
return LuaValue.NONE;
}
};
}
开发者ID:leMaik,项目名称:RpgPlus,代码行数:13,代码来源:ScriptEventManagerImplTest.java
示例7: installQuite
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
protected static void installQuite(LuaTable globals) {
globals.set("print", new ZeroArgFunction() {
@Override
public LuaValue call() {
System.out.print("#");
return LuaValue.NONE;
}
});
}
开发者ID:SquidDev,项目名称:luaj.luajc,代码行数:10,代码来源:PerformanceRunner.java
示例8: testFunctionClosureThreadEnv
import org.luaj.vm2.lib.ZeroArgFunction; //导入依赖的package包/类
public void testFunctionClosureThreadEnv() {
// set up suitable environments for execution
LuaValue aaa = LuaValue.valueOf("aaa");
LuaValue eee = LuaValue.valueOf("eee");
final Globals globals = org.luaj.vm2.lib.jse.JsePlatform.standardGlobals();
LuaTable newenv = LuaValue.tableOf( new LuaValue[] {
LuaValue.valueOf("a"), LuaValue.valueOf("aaa"),
LuaValue.valueOf("b"), LuaValue.valueOf("bbb"), } );
LuaTable mt = LuaValue.tableOf( new LuaValue[] { LuaValue.INDEX, globals } );
newenv.setmetatable(mt);
globals.set("a", aaa);
newenv.set("a", eee);
// function tests
{
LuaFunction f = new ZeroArgFunction() { public LuaValue call() { return globals.get("a");}};
assertEquals( aaa, f.call() );
}
// closure tests
{
Prototype p = createPrototype( "return a\n", "closuretester" );
LuaClosure c = new LuaClosure(p, globals);
// Test that a clusure with a custom enviroment uses that environment.
assertEquals( aaa, c.call() );
c = new LuaClosure(p, newenv);
assertEquals( newenv, c.upValues[0].getValue() );
assertEquals( eee, c.call() );
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:33,代码来源:LuaOperationsTest.java
注:本文中的org.luaj.vm2.lib.ZeroArgFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论