本文整理汇总了Java中dan200.computercraft.api.lua.ILuaObject类的典型用法代码示例。如果您正苦于以下问题:Java ILuaObject类的具体用法?Java ILuaObject怎么用?Java ILuaObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILuaObject类属于dan200.computercraft.api.lua包,在下文中一共展示了ILuaObject类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toLua
import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
public static Object toLua(Object obj) throws LuaException {
if (obj == null || obj instanceof ILuaObject) {
return obj;
}
for (ITypeConverter converter : CONVERTERS) {
Object response = converter.toLua(obj);
if (response != null) {
return response;
}
}
// a catch-all of a catch-all? sure :P
throw new IllegalStateException("Conversion failed on " + obj);
}
示例2: init
import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
public static void init() {
final MethodSelector peripheralSelector = new MethodSelector(Constants.ARCH_COMPUTER_CRAFT)
.allowReturnSignal()
.addDefaultEnv()
.addProvidedEnv(Constants.ARG_ACCESS, IArchitectureAccess.class)
.addProvidedEnv(Constants.ARG_COMPUTER, IComputerAccess.class)
.addProvidedEnv(Constants.ARG_CONTEXT, ILuaContext.class);
PERIPHERAL_METHODS_FACTORY = new ComposedMethodsFactory<IndexedMethodMap>(AdapterRegistry.PERIPHERAL_ADAPTERS, peripheralSelector) {
@Override
protected IndexedMethodMap wrapMethods(Class<?> targetCls, Map<String, IMethodExecutor> methods) {
return new IndexedMethodMap(methods);
}
};
// can't push events, so not allowing return signals
final MethodSelector objectSelector = new MethodSelector(Constants.ARCH_COMPUTER_CRAFT)
.addDefaultEnv()
.addProvidedEnv(Constants.ARG_CONTEXT, ILuaContext.class);
OBJECT_METHODS_FACTORY = new ComposedMethodsFactory<IndexedMethodMap>(AdapterRegistry.OBJECT_ADAPTERS, objectSelector) {
@Override
protected IndexedMethodMap wrapMethods(Class<?> targetCls, Map<String, IMethodExecutor> methods) {
return new IndexedMethodMap(methods);
}
};
CommandDump.addArchSerializer("ComputerCraft", "peripheral", DocBuilder.TILE_ENTITY_DECORATOR, PERIPHERAL_METHODS_FACTORY);
CommandDump.addArchSerializer("ComputerCraft", "object", DocBuilder.SCRIPT_OBJECT_DECORATOR, OBJECT_METHODS_FACTORY);
final IConverter converter = new TypeConversionRegistryCC();
// CC converter is default one (legacy behaviour)
TypeConvertersProvider.INSTANCE.registerConverter(Constants.ARCH_COMPUTER_CRAFT, converter);
TypeClassifier.INSTANCE.registerType(ILuaObject.class, SingleArgType.OBJECT);
ENV = new ComputerCraftEnv(converter);
}
示例3: wrap
import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
public static ILuaObject wrap(Object target) {
Preconditions.checkNotNull(target, "Can't wrap null");
try {
IndexedMethodMap methods = ModuleComputerCraft.OBJECT_METHODS_FACTORY.getAdaptedClass(target.getClass());
return methods.isEmpty()? null : new WrappedLuaObject(methods, target);
} catch (Throwable t) {
throw new GenerationFailedException(String.format("%s (%s)", target, target.getClass()), t);
}
}
示例4: wrapObject
import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
@Override
public ILuaObject wrapObject(Object target) {
return LuaObjectWrapper.wrap(target);
}
示例5: TypeConversionRegistryCC
import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
public TypeConversionRegistryCC() {
super(LUA_OFFSET);
registerIgnored(ILuaObject.class, true);
outbound.addFirst(new ConverterCallableCC());
}
示例6: wrapObject
import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
/**
* @throws GenerationFailedException
*/
public ILuaObject wrapObject(Object target);