comparison core/src/luan/modules/TableLuan.java @ 578:60c549d43988

remove LuanState.exception()
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 14 Jul 2015 17:40:48 -0600
parents 7c3ad6db8ac3
children 1e69d9c21461
comparison
equal deleted inserted replaced
577:d7a85fbe15f1 578:60c549d43988
32 return buf.toString(); 32 return buf.toString();
33 } 33 }
34 34
35 public static void insert(LuanState luan,LuanTable list,int pos,Object value) throws LuanException { 35 public static void insert(LuanState luan,LuanTable list,int pos,Object value) throws LuanException {
36 if( list.getMetatable() != null ) 36 if( list.getMetatable() != null )
37 throw luan.exception("can't insert into a table with a metatable"); 37 throw new LuanException(luan,"can't insert into a table with a metatable");
38 list.rawInsert(pos,value); 38 list.rawInsert(pos,value);
39 } 39 }
40 40
41 public static Object remove(LuanState luan,LuanTable list,int pos) throws LuanException { 41 public static Object remove(LuanState luan,LuanTable list,int pos) throws LuanException {
42 if( list.getMetatable() != null ) 42 if( list.getMetatable() != null )
43 throw luan.exception("can't remove from a table with a metatable"); 43 throw new LuanException(luan,"can't remove from a table with a metatable");
44 return list.rawRemove(pos); 44 return list.rawRemove(pos);
45 } 45 }
46 46
47 private static interface LessThan { 47 private static interface LessThan {
48 public boolean isLessThan(Object o1,Object o2); 48 public boolean isLessThan(Object o1,Object o2);
49 } 49 }
50 50
51 public static void sort(final LuanState luan,LuanTable list,final LuanFunction comp) throws LuanException { 51 public static void sort(final LuanState luan,LuanTable list,final LuanFunction comp) throws LuanException {
52 if( list.getMetatable() != null ) 52 if( list.getMetatable() != null )
53 throw luan.exception("can't sort a table with a metatable"); 53 throw new LuanException(luan,"can't sort a table with a metatable");
54 final LessThan lt; 54 final LessThan lt;
55 if( comp==null ) { 55 if( comp==null ) {
56 lt = new LessThan() { 56 lt = new LessThan() {
57 public boolean isLessThan(Object o1,Object o2) { 57 public boolean isLessThan(Object o1,Object o2) {
58 try { 58 try {