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; } }
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; } }