本文整理汇总了Java中org.luaj.vm2.LuaTable.set方法的典型用法代码示例。如果您正苦于以下问题:Java LuaTable.set方法的具体用法?Java LuaTable.set怎么用?Java LuaTable.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.LuaTable
的用法示例。
在下文中一共展示了LuaTable.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapping
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static LuaTable mapping(Class<?> c) {
try {
LuaTable luaTable = new LuaTable();
for (Field field : c.getFields()) {
if (!Modifier.isStatic(field.getModifiers()))
continue;
if (LuaValue.class.isAssignableFrom(field.getType())) {
luaTable.set(field.getName(), (LuaValue) field.get(null));
}
if (field.getType().equals(Class.class)) {
luaTable.set(field.getName(), mapping((Class<?>) field.get(null)));
}
}
return new ReadOnlyLuaTable(luaTable);
} catch (Exception e) {
throw new CubesException("Failed to create lua api", e);
}
}
示例2: complexToLua
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static LuaValue complexToLua(Object o) {
try {
Class<?> c = o.getClass();
Field[] fields = c.getFields();
LuaTable table = new LuaTable();
for (Field field : fields) {
if (!(Modifier.isPublic(field.getModifiers()) || field.isAnnotationPresent(LuaInclude.class)) || field.isAnnotationPresent(LuaExclude.class))
continue;
String name = field.getName();
Class<?> type = field.getType();
Object instance = field.get(o);
LuaValue l = convertToLua(instance);
table.set(name, l);
}
return table;
} catch (Exception e) {
Log.warning(e);
}
return NIL;
}
示例3: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
globals.set("require", new require());
package_ = new LuaTable();
package_.set(_LOADED, new LuaTable());
package_.set(_PRELOAD, new LuaTable());
package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH));
package_.set(_LOADLIB, new loadlib());
package_.set(_SEARCHPATH, new searchpath());
LuaTable searchers = new LuaTable();
searchers.set(1, preload_searcher = new preload_searcher());
searchers.set(2, lua_searcher = new lua_searcher());
searchers.set(3, java_searcher = new java_searcher());
package_.set(_SEARCHERS, searchers);
package_.get(_LOADED).set("package", package_);
env.set("package", package_);
globals.package_ = this;
return env;
}
示例4: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value.
* @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, which must be a Globals instance.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
globals.debuglib = this;
LuaTable debug = new LuaTable();
debug.set("debug", new debug());
debug.set("gethook", new gethook());
debug.set("getinfo", new getinfo());
debug.set("getlocal", new getlocal());
debug.set("getmetatable", new getmetatable());
debug.set("getregistry", new getregistry());
debug.set("getupvalue", new getupvalue());
debug.set("getuservalue", new getuservalue());
debug.set("sethook", new sethook());
debug.set("setlocal", new setlocal());
debug.set("setmetatable", new setmetatable());
debug.set("setupvalue", new setupvalue());
debug.set("setuservalue", new setuservalue());
debug.set("traceback", new traceback());
debug.set("upvalueid", new upvalueid());
debug.set("upvaluejoin", new upvaluejoin());
env.set("debug", debug);
env.get("package").get("loaded").set("debug", debug);
return debug;
}
示例5: bindMethods
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* bind lua functions using method
*
* @param factory
* @param methods
* @return
*/
public static LuaTable bindMethods(Class<? extends LibFunction> factory, List<Method> methods) {
LuaTable env = new LuaTable();
try {
if (methods != null) {
for (int i = 0; i < methods.size(); i++) {
LibFunction f = factory.newInstance();
f.opcode = -1;
f.method = methods.get(i);
f.name = methods.get(i).getName();
env.set(f.name, f);
}
}
} catch (Exception e) {
throw new LuaError("[Bind Failed] " + e);
} finally {
return env;
}
}
示例6: bind
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* bind lua functions using opcode
*
* @param factory
* @param methods
* @return
*/
public static LuaTable bind(Class<? extends LibFunction> factory, List<String> methods) {
LuaTable env = new LuaTable();
try {
if (methods != null) {
for (int i = 0; i < methods.size(); i++) {
LibFunction f = factory.newInstance();
f.opcode = i;
f.method = null;
f.name = methods.get(i);
env.set(f.name, f);
}
}
} catch (Exception e) {
throw new LuaError("[Bind Failed] " + e);
} finally {
return env;
}
}
示例7: invoke
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
@Override
public Varargs invoke(Varargs args) {
LuaTable table = new LuaTable();
table.set("device", AndroidUtil.getDevice());
table.set("brand", AndroidUtil.getBrand());
table.set("product", AndroidUtil.getProduct());
table.set("manufacturer", AndroidUtil.getManufacturer());
//screen size
int[] screenSize = AndroidUtil.getWindowSizeInDp(getContext());
table.set("window_width", screenSize[0]);
table.set("window_height", screenSize[1]);
//action bar height
int actionBarHeight = AndroidUtil.getActionBarHeightInDp(getContext());
table.set("nav_height", actionBarHeight);
int bottomNavHeight = AndroidUtil.getNavigationBarHeightInDp(getContext());
table.set("bottom_nav_height", bottomNavHeight);
int statusBarHeight = AndroidUtil.getStatusBarHeightInDp(getContext());
table.set("status_bar_height", statusBarHeight);
return table;
}
示例8: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value.
* Creates a metatable that uses __INDEX to fall back on itself to support string
* method operations.
* If the shared strings metatable instance is null, will set the metatable as
* the global shared metatable for strings.
* <P>
* All tables and metatables are read-write by default so if this will be used in
* a server environment, sandboxing should be used. In particular, the
* {@link LuaString#s_metatable} table should probably be made read-only.
* @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, typically a Globals instance.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
LuaTable string = new LuaTable();
string.set("byte", new byte_());
string.set("char", new char_());
string.set("dump", new dump());
string.set("find", new find());
string.set("format", new format());
string.set("gmatch", new gmatch());
string.set("gsub", new gsub());
string.set("len", new len());
string.set("lower", new lower());
string.set("match", new match());
string.set("rep", new rep());
string.set("reverse", new reverse());
string.set("sub", new sub());
string.set("upper", new upper());
LuaTable mt = LuaValue.tableOf(
new LuaValue[] { INDEX, string });
env.set("string", string);
env.get("package").get("loaded").set("string", string);
if (LuaString.s_metatable == null)
LuaString.s_metatable = mt;
return string;
}
示例9: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/** Perform one-time initialization on the library by adding package functions
* to the supplied environment, and returning it as the return value.
* It also creates the package.preload and package.loaded tables for use by
* other libraries.
* @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, typically a Globals instance.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
globals.set("require", new require());
package_ = new LuaTable();
package_.set(_LOADED, new LuaTable());
package_.set(_PRELOAD, new LuaTable());
package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH));
package_.set(_LOADLIB, new loadlib());
package_.set(_SEARCHPATH, new searchpath());
LuaTable searchers = new LuaTable();
searchers.set(1, preload_searcher = new preload_searcher());
searchers.set(2, lua_searcher = new lua_searcher());
searchers.set(3, java_searcher = new java_searcher());
package_.set(_SEARCHERS, searchers);
package_.get(_LOADED).set("package", package_);
env.set("package", package_);
globals.package_ = this;
return env;
}
示例10: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
LuaTable coroutine = new LuaTable();
coroutine.set("create", new create());
coroutine.set("resume", new resume());
coroutine.set("running", new running());
coroutine.set("status", new status());
coroutine.set("yield", new yield());
coroutine.set("wrap", new wrap());
env.set("coroutine", coroutine);
env.get("package").get("loaded").set("coroutine", coroutine);
return coroutine;
}
示例11: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public LuaValue call(LuaValue modname, LuaValue env) {
LuaTable math = new LuaTable(0,30);
math.set("abs", new abs());
math.set("ceil", new ceil());
math.set("cos", new cos());
math.set("deg", new deg());
math.set("exp", new exp(this));
math.set("floor", new floor());
math.set("fmod", new fmod());
math.set("frexp", new frexp());
math.set("huge", LuaDouble.POSINF );
math.set("ldexp", new ldexp());
math.set("max", new max());
math.set("min", new min());
math.set("modf", new modf());
math.set("pi", Math.PI );
math.set("pow", new pow());
random r;
math.set("random", r = new random());
math.set("randomseed", new randomseed(r));
math.set("rad", new rad());
math.set("sin", new sin());
math.set("sqrt", new sqrt());
math.set("tan", new tan());
env.set("math", math);
env.get("package").get("loaded").set("math", math);
return math;
}
示例12: extend
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public void extend(LuaTable debug){
debug.set("readCmd", new readCmd());
debug.set("sleep", new sleep());
debug.set("printToServer", new printToServer());
debug.set("runningLine", new runningLine());
debug.set("get_file_line", new get_file_line());
}
示例13: toTable
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* convert response to LuaTable
*
* @return
*/
public LuaTable toTable() {
LuaTable result = new LuaTable();
result.set("data", new UDData(getGlobals(), getmetatable(), null).append(mData));
result.set("code", LuaValue.valueOf(mStatusCode));
result.set("header", LuaUtil.toTable(mHeaders));
result.set("message", LuaValue.valueOf(mResponseMsg));
return result;
}
示例14: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value.
* @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, typically a Globals instance.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
LuaTable math = new LuaTable(0,30);
math.set("abs", new abs());
math.set("ceil", new ceil());
math.set("cos", new cos());
math.set("deg", new deg());
math.set("exp", new exp(this));
math.set("floor", new floor());
math.set("fmod", new fmod());
math.set("frexp", new frexp());
math.set("huge", LuaDouble.POSINF );
math.set("ldexp", new ldexp());
math.set("max", new max());
math.set("min", new min());
math.set("modf", new modf());
math.set("pi", Math.PI );
math.set("pow", new pow());
random r;
math.set("random", r = new random());
math.set("randomseed", new randomseed(r));
math.set("rad", new rad());
math.set("sin", new sin());
math.set("sqrt", new sqrt());
math.set("tan", new tan());
env.set("math", math);
env.get("package").get("loaded").set("math", math);
return math;
}
示例15: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value.
* @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, typically a Globals instance.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
LuaTable os = new LuaTable();
for (int i = 0; i < NAMES.length; ++i)
os.set(NAMES[i], new OsLibFunc(i, NAMES[i]));
env.set("os", os);
env.get("package").get("loaded").set("os", os);
return os;
}