diff core/src/luan/modules/IoLuan.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 7ea6dfdf81ba
children a74559240b4f
line wrap: on
line diff
--- a/core/src/luan/modules/IoLuan.java	Mon Dec 15 08:03:32 2014 +0000
+++ b/core/src/luan/modules/IoLuan.java	Tue Dec 16 03:26:43 2014 +0000
@@ -35,29 +35,10 @@
 
 public final class IoLuan {
 
-	public static final LuanFunction LOADER = new LuanFunction() {
-		@Override public Object call(LuanState luan,Object[] args) {
-			LuanTable module = Luan.newTable();
-			try {
-				add( module, "read_console_line", String.class );
-				module.put( "schemes", newSchemes() );
-				add( module, "Uri", LuanState.class, String.class, Boolean.class );
-				module.put( "stdin", stdin.table() );
-				add( module, "socket_server", Integer.TYPE );
-			} catch(NoSuchMethodException e) {
-				throw new RuntimeException(e);
-			}
-			module.put( "stdout", textWriter(System.out) );
-			module.put( "stderr", textWriter(System.err) );
-			return module;
-		}
-	};
-
 	private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException {
 		t.put( method, new LuanJavaFunction(IoLuan.class.getMethod(method,parameterTypes),null) );
 	}
 
-
 	public static String read_console_line(String prompt) throws IOException {
 		if( prompt==null )
 			prompt = "> ";
@@ -227,7 +208,7 @@
 			}
 		}
 
-		LuanTable table() {
+		public LuanTable table() {
 			LuanTable tbl = Luan.newTable();
 			try {
 				tbl.put( "to_string", new LuanJavaFunction(
@@ -258,7 +239,7 @@
 		}
 	}
 
-	static final LuanIn stdin = new LuanIn() {
+	public static final LuanIn defaultStdin = new LuanIn() {
 
 		@Override InputStream inputStream() {
 			return System.in;
@@ -310,7 +291,7 @@
 			return binaryWriter(new BufferedOutputStream(outputStream()));
 		}
 
-		@Override LuanTable table() {
+		@Override public LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
 				tbl.put( "write", new LuanJavaFunction(
@@ -348,7 +329,7 @@
 			return new UrlCall(url).post(postS);
 		}
 
-		@Override LuanTable table() {
+		@Override public LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
 				tbl.put( "post", new LuanJavaFunction(
@@ -408,7 +389,7 @@
 			return file.renameTo(new File(dest));
 		}
 
-		@Override LuanTable table() {
+		@Override public LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
 				tbl.put( "name", new LuanJavaFunction(
@@ -486,26 +467,6 @@
 		if( url != null )
 			return new LuanUrl(url).table();
 
-		// try java
-		if( !isLoading )
-			return null;
-		String modName = name.replace('/','.') + "Luan.LOADER";
-//		check(luan,"classpath",modName);
-		try {
-//System.out.println("modName = "+modName);
-			final LuanFunction fn = PackageLuan.load_lib(luan,modName);  // throws exception if not found
-			LuanFunction loader = new LuanFunction() {
-				@Override public Object call(LuanState luan,Object[] args) {
-					return fn;
-				}
-			};
-			LuanTable tbl = Luan.newTable();
-			tbl.put( "loader", loader );
-			return tbl;
-		} catch(ClassNotFoundException e) {
-		} catch(NoSuchFieldException e) {
-		} catch(IllegalAccessException e) {
-		}
 		return null;
 	}
 
@@ -548,7 +509,7 @@
 		return (LuanTable)io.get("stdin");
 	}
 
-	private static LuanTable newSchemes() {
+	public static LuanTable newSchemes() {
 		LuanTable schemes = Luan.newTable();
 		try {
 			add( schemes, "file", LuanState.class, String.class, Boolean.class );
@@ -623,7 +584,7 @@
 			new PickleServer(luan,in,out).run();
 		}
 
-		@Override LuanTable table() {
+		@Override public LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
 				tbl.put( "Pickle_client", new LuanJavaFunction(