comparison core/src/luan/modules/TableLuan.java @ 222:b76fcb72d97d

add AbstractLuanTable and improve HttpLuan git-svn-id: https://luan-java.googlecode.com/svn/trunk@223 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 21 Jul 2014 02:23:05 +0000
parents ec016471c6eb
children 8afe9f2fdfec
comparison
equal deleted inserted replaced
221:ec016471c6eb 222:b76fcb72d97d
19 public static final LuanFunction LOADER = new LuanFunction() { 19 public static final LuanFunction LOADER = new LuanFunction() {
20 @Override public Object call(LuanState luan,Object[] args) { 20 @Override public Object call(LuanState luan,Object[] args) {
21 LuanTable module = Luan.newTable(); 21 LuanTable module = Luan.newTable();
22 try { 22 try {
23 add( module, "concat", LuanState.class, LuanTable.class, String.class, Integer.class, Integer.class ); 23 add( module, "concat", LuanState.class, LuanTable.class, String.class, Integer.class, Integer.class );
24 add( module, "insert", LuanState.class, LuanTable.class, Integer.TYPE, Object.class ); 24 add( module, "insert", LuanTable.class, Integer.TYPE, Object.class );
25 add( module, "pack", new Object[0].getClass() ); 25 add( module, "pack", new Object[0].getClass() );
26 add( module, "remove", LuanState.class, LuanTable.class, Integer.TYPE ); 26 add( module, "remove", LuanTable.class, Integer.TYPE );
27 add( module, "sort", LuanState.class, LuanTable.class, LuanFunction.class ); 27 add( module, "sort", LuanState.class, LuanTable.class, LuanFunction.class );
28 add( module, "sub_list", LuanTable.class, Integer.TYPE, Integer.TYPE ); 28 add( module, "sub_list", LuanTable.class, Integer.TYPE, Integer.TYPE );
29 add( module, "unpack", LuanTable.class, Integer.class, Integer.class ); 29 add( module, "unpack", LuanTable.class, Integer.class, Integer.class );
30 } catch(NoSuchMethodException e) { 30 } catch(NoSuchMethodException e) {
31 throw new RuntimeException(e); 31 throw new RuntimeException(e);
54 buf.append(val); 54 buf.append(val);
55 } 55 }
56 return buf.toString(); 56 return buf.toString();
57 } 57 }
58 58
59 public static void insert(LuanState luan,LuanTable list,int pos,Object value) throws LuanException { 59 public static void insert(LuanTable list,int pos,Object value){
60 try { 60 list.insert(pos,value);
61 list.insert(pos,value);
62 } catch(IndexOutOfBoundsException e) {
63 throw luan.exception(e);
64 }
65 } 61 }
66 62
67 public static Object remove(LuanState luan,LuanTable list,int pos) throws LuanException { 63 public static Object remove(LuanTable list,int pos) {
68 try { 64 return list.remove(pos);
69 return list.remove(pos);
70 } catch(IndexOutOfBoundsException e) {
71 throw luan.exception(e);
72 }
73 } 65 }
74 66
75 private static interface LessThan { 67 private static interface LessThan {
76 public boolean isLessThan(Object o1,Object o2); 68 public boolean isLessThan(Object o1,Object o2);
77 } 69 }