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


Java LuaValue.checkfunction方法代碼示例

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


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

示例1: parseValue

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * parse a value to given type
 *
 * @param type
 * @param value
 * @return
 */
private static Object parseValue(int type, LuaValue value) {
    switch (type) {
        case LuaValue.TBOOLEAN:
            if (isBoolean(value)) return value.checkboolean();
            break;
        case LuaValue.TNUMBER:
            if (isNumber(value)) return value.checknumber();
            break;
        case LuaValue.TSTRING:
            if (isString(value)) return value.checkjstring();
            break;
        case LuaValue.TTABLE:
            if (isTable(value)) return value.checktable();
            break;
        case LuaValue.TFUNCTION:
            if (isFunction(value)) return value.checkfunction();
            break;
        case LuaValue.TUSERDATA:
            if (isUserdata(value)) return value.checkuserdata();
            break;
        case LuaValue.TVALUE:
            return value;
    }
    return null;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:33,代碼來源:LuaUtil.java

示例2: method

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@RuntimeType
public Object method(@Origin Method aMethod, @This Object o, @AllArguments Object[] objects,
		@SuperCall Callable supercall) {
	LuaValue value = delegations.get(aMethod.getName());
	if (value.isnil()) {
		try {
			return supercall.call();
		} catch (Exception e) {
			throw new DynamicDelegationError("Supercall threw exception - no delegation supplied", e);
		}
	}
	if (value.isfunction()) {
		LuaFunction function = value.checkfunction();
		LuaValue[] parameters = convertParamsToLua(o, objects, supercall);
		Varargs invoke = function.invoke(parameters);
		if (aMethod.getReturnType() == Void.class || invoke.narg() == 0)
			return null;
		return LuaConversion.convertToJava(aMethod.getReturnType(), invoke.checkvalue(1));
	} else {
		return LuaConversion.convertToJava(aMethod.getReturnType(), value);
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:23,代碼來源:LuaGeneration.java

示例3: dump

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * string.dump (function)
 *
 * Returns a string containing a binary representation of the given function,
 * so that a later loadstring on this string returns a copy of the function.
 * function must be a Lua function without upvalues.
 *
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump(LuaValue arg) {
    LuaValue f = arg.checkfunction();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        DumpState.dump(((LuaClosure) f).p, baos, true);
        return LuaString.valueOf(baos.toByteArray());
    } catch (IOException e) {
        return error(e.getMessage());
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:20,代碼來源:StringLib.java

示例4: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg) {
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {
		DumpState.dump( ((LuaClosure)f).p, baos, true );
		return LuaString.valueUsing(baos.toByteArray());
	} catch (IOException e) {
		return error( e.getMessage() );
	}
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:11,代碼來源:StringLib.java

示例5: constructor

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void constructor(@This Object o, @AllArguments Object[] objects) { // @Origin
																			// Constructor
																			// constructor,
	LuaValue value = delegations.get("__new__");
	if (value.isnil())
		return;
	if (!value.isfunction())
		throw new DynamicDelegationError("__new__ for " + o.getClass().getName() + " is a " + value.typename());
	LuaFunction function = value.checkfunction();
	LuaValue[] parameters = convertParamsToLua(o, objects);
	function.invoke(parameters);
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:13,代碼來源:LuaGeneration.java

示例6: constructor

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void constructor(@This Object o, @AllArguments Object[] objects) { // @Origin Constructor constructor,
  LuaValue value = delegations.get("__new__");
  if (value.isnil()) return;
  if (!value.isfunction()) throw new DynamicDelegationError("__new__ for " + o.getClass().getName() + " is a " + value.typename());
  LuaFunction function = value.checkfunction();
  LuaValue[] parameters = convertParamsToLua(o, objects);
  function.invoke(parameters);
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:9,代碼來源:LuaGeneration.java

示例7: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue f) {
	return new LuaThread(globals, f.checkfunction());
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:4,代碼來源:CoroutineLib.java


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