Exemplo n.º 1
0
 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;
   }
 }
Exemplo n.º 2
0
 public int score(LuaValue value) {
   switch (value.type()) {
     case LuaValue.TNUMBER:
       return inheritanceLevels(targetType, value.isint() ? Integer.class : Double.class);
     case LuaValue.TBOOLEAN:
       return inheritanceLevels(targetType, Boolean.class);
     case LuaValue.TSTRING:
       return inheritanceLevels(targetType, String.class);
     case LuaValue.TUSERDATA:
       return inheritanceLevels(targetType, value.touserdata().getClass());
     case LuaValue.TNIL:
       return SCORE_NULL_VALUE;
     default:
       return inheritanceLevels(targetType, value.getClass());
   }
 }
Exemplo n.º 3
0
 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;
   }
 }