comparison src/luan/lib/TableLib.java @ 130:0594c132888b

cleanup git-svn-id: https://luan-java.googlecode.com/svn/trunk@131 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 10 Jun 2014 02:43:40 +0000
parents f537ff5e511d
children 3119326260ea
comparison
equal deleted inserted replaced
129:486a0641bca4 130:0594c132888b
52 break; 52 break;
53 if( sep!=null && k > first ) 53 if( sep!=null && k > first )
54 buf.append(sep); 54 buf.append(sep);
55 String s = Luan.asString(val); 55 String s = Luan.asString(val);
56 if( s==null ) 56 if( s==null )
57 throw luan.JAVA.exception( "invalid value ("+Luan.type(val)+") at index "+k+" in table for 'concat'" ); 57 throw luan.exception( "invalid value ("+Luan.type(val)+") at index "+k+" in table for 'concat'" );
58 buf.append(val); 58 buf.append(val);
59 } 59 }
60 return buf.toString(); 60 return buf.toString();
61 } 61 }
62 62
63 public static void insert(LuanState luan,LuanTable list,int pos,Object value) throws LuanException { 63 public static void insert(LuanState luan,LuanTable list,int pos,Object value) throws LuanException {
64 try { 64 try {
65 list.insert(pos,value); 65 list.insert(pos,value);
66 } catch(IndexOutOfBoundsException e) { 66 } catch(IndexOutOfBoundsException e) {
67 throw luan.JAVA.exception(e); 67 throw luan.exception(e);
68 } 68 }
69 } 69 }
70 70
71 public static Object remove(LuanState luan,LuanTable list,int pos) throws LuanException { 71 public static Object remove(LuanState luan,LuanTable list,int pos) throws LuanException {
72 try { 72 try {
73 return list.remove(pos); 73 return list.remove(pos);
74 } catch(IndexOutOfBoundsException e) { 74 } catch(IndexOutOfBoundsException e) {
75 throw luan.JAVA.exception(e); 75 throw luan.exception(e);
76 } 76 }
77 } 77 }
78 78
79 private static interface LessThan { 79 private static interface LessThan {
80 public boolean isLessThan(Object o1,Object o2); 80 public boolean isLessThan(Object o1,Object o2);
84 final LessThan lt; 84 final LessThan lt;
85 if( comp==null ) { 85 if( comp==null ) {
86 lt = new LessThan() { 86 lt = new LessThan() {
87 public boolean isLessThan(Object o1,Object o2) { 87 public boolean isLessThan(Object o1,Object o2) {
88 try { 88 try {
89 return luan.JAVA.isLessThan(o1,o2); 89 return luan.isLessThan(o1,o2);
90 } catch(LuanException e) { 90 } catch(LuanException e) {
91 throw new LuanRuntimeException(e); 91 throw new LuanRuntimeException(e);
92 } 92 }
93 } 93 }
94 }; 94 };
95 } else { 95 } else {
96 lt = new LessThan() { 96 lt = new LessThan() {
97 public boolean isLessThan(Object o1,Object o2) { 97 public boolean isLessThan(Object o1,Object o2) {
98 try { 98 try {
99 return Luan.toBoolean(Luan.first(luan.JAVA.call(comp,"comp-arg",new Object[]{o1,o2}))); 99 return Luan.toBoolean(Luan.first(luan.call(comp,"comp-arg",new Object[]{o1,o2})));
100 } catch(LuanException e) { 100 } catch(LuanException e) {
101 throw new LuanRuntimeException(e); 101 throw new LuanRuntimeException(e);
102 } 102 }
103 } 103 }
104 }; 104 };