use of com.taobao.luaview.fun.mapper.ui.NewIndexFunction in project LuaViewSDK by alibaba.
the class LuaViewManager method createMetatable.
// -----------------------------------------metatable--------------------------------------------
/**
* create metatable for libs
*
* @return
*/
public static LuaTable createMetatable(Class<? extends LibFunction> libClass) {
// get from cache
LuaTable result = AppCache.getCache(CACHE_METATABLES).get(libClass);
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;
}
Aggregations