本文整理匯總了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;
}
示例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);
}
}
示例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());
}
}
示例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() );
}
}
示例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);
}
示例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);
}
示例7: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue f) {
return new LuaThread(globals, f.checkfunction());
}