changeset 135:3119326260ea

revert rev 125 and only preload Java git-svn-id: https://luan-java.googlecode.com/svn/trunk@136 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 11 Jun 2014 06:30:46 +0000
parents b585d0915621
children 7e160d2f6d9c
files src/luan/Luan.java src/luan/LuanState.java src/luan/lib/BasicLib.java src/luan/lib/BinaryLib.java src/luan/lib/HtmlLib.java src/luan/lib/HttpLib.java src/luan/lib/IoLib.java src/luan/lib/JavaLib.java src/luan/lib/MathLib.java src/luan/lib/PackageLib.java src/luan/lib/StringLib.java src/luan/lib/TableLib.java src/luan/lib/ThreadLib.java src/luan/tools/WebServlet.java
diffstat 14 files changed, 29 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/Luan.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/Luan.java	Wed Jun 11 06:30:46 2014 +0000
@@ -12,8 +12,8 @@
 			LuanFunction standalone = (LuanFunction)BasicLib.load_java_resource(luan,"luan/tools/cmd_line.luan");
 			luan.call(standalone,args);
 		} catch(LuanException e) {
-//			System.err.println(e.getMessage());
-			e.printStackTrace();
+			System.err.println(e.getMessage());
+//			e.printStackTrace();
 			System.exit(-1);
 		}
 	}
--- a/src/luan/LuanState.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/LuanState.java	Wed Jun 11 06:30:46 2014 +0000
@@ -141,17 +141,17 @@
 	public static LuanState newStandard() {
 		try {
 			LuanState luan = LuanCompiler.newLuanState();
-			BasicLib.load(luan);
-			PackageLib.load(luan);
-			MathLib.load(luan);
-			StringLib.load(luan);
-			TableLib.load(luan);
-			HtmlLib.load(luan);
-			BinaryLib.load(luan);
-			IoLib.load(luan);
-			ThreadLib.load(luan);
+			luan.load(BasicLib.NAME,BasicLib.LOADER);
+			luan.load(PackageLib.NAME,PackageLib.LOADER);
+			luan.load(MathLib.NAME,MathLib.LOADER);
+			luan.load(StringLib.NAME,StringLib.LOADER);
+			luan.load(TableLib.NAME,TableLib.LOADER);
+			luan.load(HtmlLib.NAME,HtmlLib.LOADER);
+			luan.load(BinaryLib.NAME,BinaryLib.LOADER);
+			luan.load(IoLib.NAME,IoLib.LOADER);
+			luan.load(ThreadLib.NAME,ThreadLib.LOADER);
 			BasicLib.do_java_resource(luan,"luan/lib/init.luan");
-			JavaLib.load(luan);
+			luan.preload.put(JavaLib.NAME,JavaLib.LOADER);
 			return luan;
 		} catch(LuanException e) {
 			throw new RuntimeException(e);
--- a/src/luan/lib/BasicLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/BasicLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -21,9 +21,7 @@
 
 public final class BasicLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Basic",LOADER);
-	}
+	public static final String NAME = "Basic";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/BinaryLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/BinaryLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -9,9 +9,7 @@
 
 public final class BinaryLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Binary",LOADER);
-	}
+	public static final String NAME = "Binary";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/HtmlLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/HtmlLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -9,9 +9,7 @@
 
 public final class HtmlLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Html",LOADER);
-	}
+	public static final String NAME = "Html";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/HttpLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/HttpLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -21,7 +21,7 @@
 
 public final class HttpLib {
 
-	private static final String NAME = "Http";
+	public static final String NAME = "Http";
 	public static final String FN_NAME = "Http.server";
 
 	public static void load(LuanState luan) throws LuanException {
--- a/src/luan/lib/IoLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/IoLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -33,9 +33,7 @@
 
 public final class IoLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Io",LOADER);
-	}
+	public static final String NAME = "Io";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/JavaLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/JavaLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -27,9 +27,7 @@
 
 public final class JavaLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Java",LOADER);
-	}
+	public static final String NAME = "Java";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/MathLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/MathLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -9,9 +9,7 @@
 
 public final class MathLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Math",LOADER);
-	}
+	public static final String NAME = "Math";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/PackageLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/PackageLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -16,9 +16,7 @@
 
 public final class PackageLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Package",LOADER);
-	}
+	public static final String NAME = "Package";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/StringLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/StringLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -14,9 +14,7 @@
 
 public final class StringLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("String",LOADER);
-	}
+	public static final String NAME = "String";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/TableLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/TableLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -16,9 +16,7 @@
 
 public final class TableLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Table",LOADER);
-	}
+	public static final String NAME = "Table";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/lib/ThreadLib.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/lib/ThreadLib.java	Wed Jun 11 06:30:46 2014 +0000
@@ -12,9 +12,7 @@
 
 public final class ThreadLib {
 
-	public static void load(LuanState luan) throws LuanException {
-		luan.load("Thread",LOADER);
-	}
+	public static final String NAME = "Thread";
 
 	public static final LuanFunction LOADER = new LuanFunction() {
 		@Override public Object call(LuanState luan,Object[] args) {
--- a/src/luan/tools/WebServlet.java	Wed Jun 11 05:24:11 2014 +0000
+++ b/src/luan/tools/WebServlet.java	Wed Jun 11 06:30:46 2014 +0000
@@ -28,12 +28,12 @@
 
 	protected LuanState newLuanState() throws LuanException {
 		LuanState luan = LuanCompiler.newLuanState();
-		BasicLib.load(luan);
-		PackageLib.load(luan);
-		MathLib.load(luan);
-		StringLib.load(luan);
-		TableLib.load(luan);
-		HtmlLib.load(luan);
+		luan.load(BasicLib.NAME,BasicLib.LOADER);
+		luan.load(PackageLib.NAME,PackageLib.LOADER);
+		luan.load(MathLib.NAME,MathLib.LOADER);
+		luan.load(StringLib.NAME,StringLib.LOADER);
+		luan.load(TableLib.NAME,TableLib.LOADER);
+		luan.load(HtmlLib.NAME,HtmlLib.LOADER);
 		return luan;
 	}