本文整理汇总了Java中org.luaj.vm2.LuaUserdata类的典型用法代码示例。如果您正苦于以下问题:Java LuaUserdata类的具体用法?Java LuaUserdata怎么用?Java LuaUserdata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaUserdata类属于org.luaj.vm2包,在下文中一共展示了LuaUserdata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeInheritanceMap
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
/**
* Lua Closure for MappingFactory.makeInheritanceMap(jarFile, mappingArg)
* @param jarFile Jar file to make the inheritance map for.
* @param mappingArg Mappings to make the inheritance map for. The inheritance map will only contains symbols also contained in this mapping.
* @return
*/
private static final LuaValue makeInheritanceMap(String jarFile, SrgMapping mapping)
{
File inputJar = new File(jarFile);
try
{
Jar inJar = Jar.init(inputJar);
SrgInheritanceMap inheritMap = new SrgInheritanceMap(new JarProvider(inJar), mapping);
return new LuaUserdata(inheritMap, SrgInheritanceMapMeta.getMetaTable());
}
catch (Exception e)
{
throw new LuaError(e);
}
}
示例2: loadInheritanceMap
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
/**
* Lua Closure for MappingFactory.loadInheritanceMap(filename[, filename[, filename[, ...]]])
* @param filenames The inheritance maps to load.
* @return
*/
private static final LuaValue loadInheritanceMap(Varargs filenames)
{
SrgInheritanceMap inheritance = new SrgInheritanceMap();
int args = filenames.narg() + 1;
for (int i = 1; i != args; ++i)
{
String filename = filenames.arg(i).checkjstring();
File file = new File(filename);
if (!file.exists())
throw new LuaError("File " + filename + " does not exist.");
try
{
inheritance.loadMapping(file);
}
catch (Exception e)
{
throw new LuaError(e);
}
}
return new LuaUserdata(inheritance, SrgInheritanceMapMeta.getMetaTable());
}
示例3: invoke
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
Object o = args.checkuserdata(1);
LuaValue v = args.checkvalue(2);
LuaUserdata u = (LuaUserdata) args.arg1();
u.m_instance = v.checkuserdata();
u.m_metatable = v.getmetatable();
return NONE;
}
示例4: invoke
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
Object o = args.checkuserdata(1);
LuaValue v = args.checkvalue(2);
LuaUserdata u = (LuaUserdata) args.arg1();
u.m_instance = v.checkuserdata();
u.m_metatable = v.getmetatable();
return NONE;
}
示例5: invoke
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
@Override
public Varargs invoke(Varargs arguments) {
BlocksItems.load();
if (arguments.isstring(1)) {
LuaUserdata u = blocksItems.blockUserdata.get(arguments.checkjstring(1));
return u != null ? u : NIL;
} else {
return BlocksItems.blockTable;
}
}
示例6: call
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
@Override
public LuaValue call(LuaValue gb1, LuaValue gb2, LuaValue gb3) {
int x = gb1.checkint();
int y = gb2.checkint();
int z = gb3.checkint();
return new LuaUserdata(world.getBlock(x, y, z));
}
示例7: invoke
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
@Override
public Varargs invoke(Varargs args) {
BlocksItems.load();
if (args.isstring(1)) {
LuaUserdata u = BlocksItems.blockUserdata.get(args.checkjstring(1));
return u != null ? u : NIL;
} else {
return BlocksItems.blockTable;
}
}
示例8: call
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
int x = arg1.checkint();
int y = arg2.checkint();
int z = arg3.checkint();
return new LuaUserdata(world.getBlock(x, y, z));
}
示例9: invoke
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
Object o = args.checkuserdata(1);
LuaValue v = args.checkvalue(2);
LuaUserdata u = (LuaUserdata)args.arg1();
u.m_instance = v.checkuserdata();
u.m_metatable = v.getmetatable();
return NONE;
}
示例10: entries
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
private static LuaValue entries(ZipFile instance)
{
Enumeration<? extends ZipEntry> files = instance.entries();
LuaTable fileTable = new LuaTable();
int i = 1;
while (files.hasMoreElements())
{
ZipEntry entry = files.nextElement();
fileTable.set(i++, new LuaUserdata(entry, ZipEntryMeta.getMetaTable()));
}
return fileTable;
}
示例11: getEntry
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
private static LuaValue getEntry(ZipFile instance, String path)
{
ZipEntry entry = instance.getEntry(path);
if (entry == null)
return LuaValue.NONE;
else
return new LuaUserdata(entry, ZipEntryMeta.getMetaTable());
}
示例12: open
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
private static LuaValue open(String path)
{
try
{
return new LuaUserdata(new ZipFile(new File(path)), ZipFileMeta.getMetaTable());
}
catch (Exception e)
{
throw new LuaError(e);
}
}
示例13: loadSrgMapping
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
/**
* Lua Closure for MappingFactory.loadSrg(filename, ...).
* Loads all specified srg files into a single srg mapping.
*
* @param filenames The filenames to load
* @return The SrgMapping (as UserData)
*/
private static LuaValue loadSrgMapping(Varargs filenames)
{
SrgMapping mapping = new SrgMapping();
int args = filenames.narg() + 1;
for (int i = 1; i != args; ++i)
{
String filename = filenames.arg(i).checkjstring();
File file = new File(filename);
if (!file.exists())
throw new LuaError("File " + filename + " does not exist.");
try
{
mapping.loadMapping(file);
}
catch (Exception e)
{
throw new LuaError(e);
}
}
return new LuaUserdata(mapping, SrgMappingMeta.getMetaTable());
}
示例14: loadMCPMapping
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
/**
* Lua Closure for MappingFactory.loadMCP(fieldsFile, methodsFile, packagesFile).
* Loads the specified MCP csv files into a mapping.
* @param fieldsFile The fields.csv file, or nil to ignore field mappings.
* @param methodsFile The methods.csv file, or nil to ignore method mappings.
* @param packagesFile The packages.csv file, or nil to ignore package mappings.
* @return The MinecraftCodersPackMapping (as UserData)
*/
private static final LuaValue loadMCPMapping(LuaValue fieldsFile, LuaValue methodsFile, LuaValue packagesFile)
{
File fields = fieldsFile.isnil() ? null : new File(fieldsFile.checkjstring());
File methods = methodsFile.isnil() ? null : new File(methodsFile.checkjstring());
File packages = packagesFile.isnil() ? null : new File(packagesFile.checkjstring());
if (fields != null && fields.exists() == false)
throw new LuaError("File " + fields.getAbsolutePath() + " does not exist.");
if (methods != null && methods.exists() == false)
throw new LuaError("File " + fields.getAbsolutePath() + " does not exist.");
if (packages != null && packages.exists() == false)
throw new LuaError("File " + fields.getAbsolutePath() + " does not exist.");
try
{
MinecraftCodersPackMapping mapping = new MinecraftCodersPackMapping(fields, methods, packages);
return new LuaUserdata(mapping);
}
catch (Exception e)
{
throw new LuaError(e);
}
}
示例15: call
import org.luaj.vm2.LuaUserdata; //导入依赖的package包/类
public LuaValue call(LuaValue u) {
return LuaValue.valueOf(Array.getLength(((LuaUserdata)u).m_instance));
}