本文整理匯總了Java中org.luaj.vm2.LuaValue.TTABLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.TTABLE屬性的具體用法?Java LuaValue.TTABLE怎麽用?Java LuaValue.TTABLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.TTABLE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: coerce
public Object coerce(LuaValue value) {
switch ( value.type() ) {
case LuaValue.TTABLE: {
int n = value.length();
Object a = Array.newInstance(componentType, n);
for ( int i=0; i<n; i++ )
Array.set(a, i, componentCoercion.coerce(value.get(i+1)));
return a;
}
case LuaValue.TUSERDATA:
return value.touserdata();
case LuaValue.TNIL:
return null;
default:
return null;
}
}
示例2: parseValue
/**
* 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;
}
示例3: score
public int score(LuaValue value) {
switch ( value.type() ) {
case LuaValue.TTABLE:
return value.length()==0? 0: componentCoercion.score( value.get(1) );
case LuaValue.TUSERDATA:
return inheritanceLevels( componentType, value.touserdata().getClass().getComponentType() );
case LuaValue.TNIL:
return SCORE_NULL_VALUE;
default:
return SCORE_UNCOERCIBLE;
}
}
示例4: add_value
public void add_value(Buffer lbuf, int soffset, int end, LuaValue repl) {
switch (repl.type()) {
case LuaValue.TSTRING:
case LuaValue.TNUMBER:
add_s(lbuf, repl.strvalue(), soffset, end);
return;
case LuaValue.TFUNCTION:
repl = repl.invoke(push_captures(true, soffset, end)).arg1();
break;
case LuaValue.TTABLE:
// Need to call push_onecapture here for the error checking
repl = repl.get(push_onecapture(0, soffset, end));
break;
default:
error("bad argument: string/function/table expected");
return;
}
if (!repl.toboolean()) {
repl = s.substring(soffset, end);
} else if (!repl.isstring()) {
error("invalid replacement value (a " + repl.typename() + ")");
}
lbuf.append(repl.strvalue());
}
示例5: add_value
public void add_value( Buffer lbuf, int soffset, int end, LuaValue repl ) {
switch ( repl.type() ) {
case LuaValue.TSTRING:
case LuaValue.TNUMBER:
add_s( lbuf, repl.strvalue(), soffset, end );
return;
case LuaValue.TFUNCTION:
repl = repl.invoke( push_captures( true, soffset, end ) ).arg1();
break;
case LuaValue.TTABLE:
// Need to call push_onecapture here for the error checking
repl = repl.get( push_onecapture( 0, soffset, end ) );
break;
default:
error( "bad argument: string/function/table expected" );
return;
}
if ( !repl.toboolean() ) {
repl = s.substring( soffset, end );
} else if ( ! repl.isstring() ) {
error( "invalid replacement value (a "+repl.typename()+")" );
}
lbuf.append( repl.strvalue() );
}
示例6: isTable
/**
* is table
*
* @param target
* @return
*/
public static boolean isTable(final LuaValue target) {
return target != null && target.type() == LuaValue.TTABLE;
}