public Object coerce(LuaValue value) {
   if (value.isnil()) return null;
   if (targetType == TARGET_TYPE_STRING) return value.tojstring();
   LuaString s = value.checkstring();
   byte[] b = new byte[s.m_length];
   s.copyInto(0, b, 0, b.length);
   return b;
 }
 public Object coerce(LuaValue value) {
   switch (value.type()) {
     case LuaValue.TNUMBER:
       return value.isint()
           ? (Object) new Integer(value.toint())
           : (Object) new Double(value.todouble());
     case LuaValue.TBOOLEAN:
       return value.toboolean() ? Boolean.TRUE : Boolean.FALSE;
     case LuaValue.TSTRING:
       return value.tojstring();
     case LuaValue.TUSERDATA:
       return value.optuserdata(targetType, null);
     case LuaValue.TNIL:
       return null;
     default:
       return value;
   }
 }