Пример #1
0
 public LuaValue get(LuaValue key) {
   if (key.equals(LENGTH)) return valueOf(Array.getLength(m_instance));
   if (key.isint()) {
     int i = key.toint() - 1;
     return i >= 0 && i < Array.getLength(m_instance)
         ? CoerceJavaToLua.coerce(Array.get(m_instance, key.toint() - 1))
         : NIL;
   }
   return super.get(key);
 }
Пример #2
0
 public void set(LuaValue key, LuaValue value) {
   if (key.isint()) {
     int i = key.toint() - 1;
     if (i >= 0 && i < Array.getLength(m_instance))
       Array.set(
           m_instance, i, CoerceLuaToJava.coerce(value, m_instance.getClass().getComponentType()));
     else if (m_metatable == null || !settable(this, key, value))
       error("array index out of bounds");
   } else super.set(key, value);
 }