diff core/src/luan/modules/TableLuan.java @ 297:899253043270

remove PackageLuan.load_lib() git-svn-id: https://luan-java.googlecode.com/svn/trunk@298 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 16 Dec 2014 03:26:43 +0000
parents 8afe9f2fdfec
children 7fd9f1b7b878
line wrap: on
line diff
--- a/core/src/luan/modules/TableLuan.java	Mon Dec 15 08:03:32 2014 +0000
+++ b/core/src/luan/modules/TableLuan.java	Tue Dec 16 03:26:43 2014 +0000
@@ -8,37 +8,13 @@
 import luan.LuanState;
 import luan.LuanTable;
 import luan.LuanFunction;
-import luan.LuanJavaFunction;
-import luan.LuanElement;
 import luan.LuanException;
 import luan.LuanRuntimeException;
+import luan.LuanMethod;
 
 
 public final class TableLuan {
 
-	public static final LuanFunction LOADER = new LuanFunction() {
-		@Override public Object call(LuanState luan,Object[] args) {
-			LuanTable module = Luan.newTable();
-			try {
-				add( module, "clone", LuanTable.class );
-				add( module, "concat", LuanState.class, LuanTable.class, String.class, Integer.class, Integer.class );
-				add( module, "insert", LuanTable.class, Integer.TYPE, Object.class );
-				add( module, "pack", new Object[0].getClass() );
-				add( module, "remove", LuanTable.class, Integer.TYPE );
-				add( module, "sort", LuanState.class, LuanTable.class, LuanFunction.class );
-				add( module, "sub_list", LuanTable.class, Integer.TYPE, Integer.TYPE );
-				add( module, "unpack", LuanTable.class, Integer.class, Integer.class );
-			} catch(NoSuchMethodException e) {
-				throw new RuntimeException(e);
-			}
-			return module;
-		}
-	};
-
-	private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException {
-		t.put( method, new LuanJavaFunction(TableLuan.class.getMethod(method,parameterTypes),null) );
-	}
-
 	public static String concat(LuanState luan,LuanTable list,String sep,Integer i,Integer j) throws LuanException {
 		int first = i==null ? 1 : i;
 		int last = j==null ? list.length() : j;
@@ -120,7 +96,7 @@
 		return tbl;
 	}
 
-	public static Object[] unpack(LuanTable tbl,Integer iFrom,Integer iTo) {
+	@LuanMethod public static Object[] unpack(LuanTable tbl,Integer iFrom,Integer iTo) {
 		int from = iFrom!=null ? iFrom : 1;
 		int to = iTo!=null ? iTo : tbl.length();
 		List<Object> list = new ArrayList<Object>();