本文整理匯總了Java中org.luaj.vm2.LuaValue.checkjstring方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.checkjstring方法的具體用法?Java LuaValue.checkjstring怎麽用?Java LuaValue.checkjstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.checkjstring方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2) {
String fileName = arg1.checkjstring(1);
String lineNumber = String.valueOf(arg2.checkint());
if (globals.debugConnection != null) {
globals.debugConnection.sendCmd("running", fileName, lineNumber.getBytes());
}
return NIL;
}
示例3: toJava
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public String toJava(LuaValue l, Class<? extends String> c) {
return l.checkjstring();
}
示例4: fromLua
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* Create hub from a lua script text
*/
public static Hub fromLua(String luaText) throws Exception {
// Obatain a lua globals for loading configs
final Globals globals = new Globals();
LoadState.install(globals);
LuaC.install(globals);
final Hub hub = new Hub();
globals.load(luaText).call();
Varargs pair;
LuaValue key = LuaValue.NIL;
LuaValue value;
String keyStr;
while (true) {
pair = globals.next(key);
if ((key = pair.arg1()).isnil())
break;
value = pair.arg(2);
keyStr = key.checkjstring();
switch (keyStr) {
case "ID":
hub.setId(value.checkjstring().toLowerCase());
break;
case "NAME":
hub.setName(value.checkjstring());
break;
case "TYPE":
final String type = value.checkjstring();
boolean isTypeSupported = false;
for (String supportedType : SUPPORTED_TYPES) {
if (supportedType.equalsIgnoreCase(type)) {
isTypeSupported = true;
break;
}
}
if (isTypeSupported) {
hub.setType(type);
} else {
throw new Exception("Not supported hub type.");
}
break;
case "VERSION":
hub.setVersion(value.checkjstring());
break;
case "ENTRY":
hub.setEntry(value.checkjstring());
break;
case "DEBUG":
hub.setDebug(value.checkboolean());
break;
default:
hub.userConfig.put(keyStr, value);
break;
}
}
hub.checkProperties();
return hub;
}
示例5: toJava
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public String toJava(LuaValue l, Class<? extends String> c) {
return l.checkjstring();
}