當前位置: 首頁>>代碼示例>>Java>>正文


Java LuaValue.tableOf方法代碼示例

本文整理匯總了Java中org.luaj.vm2.LuaValue.tableOf方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.tableOf方法的具體用法?Java LuaValue.tableOf怎麽用?Java LuaValue.tableOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.luaj.vm2.LuaValue的用法示例。


在下文中一共展示了LuaValue.tableOf方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMetatable

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * create metatable for libs
 *
 * @return
 */
public static LuaTable createMetatable(Class<? extends LibFunction> libClass) {
    LuaTable result = AppCache.getCache(CACHE_METATABLES).get(libClass);//get from cache

    if (result == null) {
        LuaTable libTable = null;
        if (LuaViewConfig.isUseNoReflection()) {
            final List<String> methodNames = getMapperMethodNames(libClass);
            libTable = LuaViewManager.bind(libClass, methodNames);
        } else {
            final List<Method> methods = getMapperMethods(libClass);
            libTable = LuaViewManager.bindMethods(libClass, methods);
        }
        result = LuaValue.tableOf(new LuaValue[]{LuaValue.INDEX, libTable, LuaValue.NEWINDEX, new NewIndexFunction(libTable)});

        //update cache
        AppCache.getCache(CACHE_METATABLES).put(libClass, result);
    }
    return result;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:25,代碼來源:LuaViewManager.java

示例2: call

import org.luaj.vm2.LuaValue; //導入方法依賴的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:hsllany,項目名稱:HtmlNative,代碼行數:39,代碼來源:StringLib.java

示例3: toLuaTable

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * Transforming a collection of strings to a LUA value table.
 * 
 * @param collection
 * 				Collection of strings.
 * @return
 * 				LUA value table.
 */
public static LuaValue toLuaTable(Collection<String> collection) {
	LuaValue table = LuaValue.tableOf();
	int i = 1;
	for (String s : collection) {
		table.set(i, LuaValue.valueOf(s));
		i++;
	}
	return table;
}
 
開發者ID:joakimkistowski,項目名稱:HTTP-Load-Generator,代碼行數:18,代碼來源:LuaHelpers.java


注:本文中的org.luaj.vm2.LuaValue.tableOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。