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


Java ILuaObject类代码示例

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

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

示例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);
	}
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:11,代码来源:LuaObjectWrapper.java

示例4: wrapObject

import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
@Override
public ILuaObject wrapObject(Object target) {
	return LuaObjectWrapper.wrap(target);
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:5,代码来源:AdapterFactoryWrapperCC.java

示例5: TypeConversionRegistryCC

import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
public TypeConversionRegistryCC() {
	super(LUA_OFFSET);
	registerIgnored(ILuaObject.class, true);
	outbound.addFirst(new ConverterCallableCC());
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:6,代码来源:TypeConversionRegistryCC.java

示例6: wrapObject

import dan200.computercraft.api.lua.ILuaObject; //导入依赖的package包/类
/**
 * @throws GenerationFailedException
 */
public ILuaObject wrapObject(Object target);
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:5,代码来源:IComputerCraftObjectsFactory.java


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