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


Java LuaTable.set方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:19,代码来源:LuaMapping.java

示例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;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:21,代码来源:LuaConversion.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:20,代码来源:PackageLib.java

示例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;
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:31,代码来源:DebugLib.java

示例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;
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:26,代码来源:LuaViewManager.java

示例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;
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:26,代码来源:LuaViewManager.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:23,代码来源:UDSystem.java

示例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;
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:39,代码来源:StringLib.java

示例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;
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:27,代码来源:PackageLib.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:14,代码来源:CoroutineLib.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:29,代码来源:MathLib.java

示例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());
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:8,代码来源:DebugLib.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:14,代码来源:UDHttpResponse.java

示例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;
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:35,代码来源:MathLib.java

示例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;
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:16,代码来源:OsLib.java


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