changeset 84:cca4f8522893

minor changes git-svn-id: https://luan-java.googlecode.com/svn/trunk@85 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 18 Feb 2013 23:15:14 +0000
parents b84f66704026
children b2551f00bc51
files src/luan/LuanState.java src/luan/LuanTable.java src/luan/lib/PackageLib.java src/luan/tools/WebServlet.java
diffstat 4 files changed, 29 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/LuanState.java	Mon Feb 18 22:07:40 2013 +0000
+++ b/src/luan/LuanState.java	Mon Feb 18 23:15:14 2013 +0000
@@ -84,7 +84,7 @@
 		return t.put(a[a.length-1],value);
 	}
 
-	public final void load(LuanFunction loader,String modName) throws LuanException {
+	public final void load(String modName,LuanFunction loader) throws LuanException {
 		Object mod = Luan.first(call(loader,LuanElement.JAVA,"loader",modName));
 		if( mod == null )
 			mod = true;
@@ -96,13 +96,13 @@
 	public static LuanState newStandard() {
 		try {
 			LuanState luan = LuanCompiler.newLuanState();
-			luan.load(BasicLib.LOADER,BasicLib.NAME);
-			luan.load(PackageLib.LOADER,PackageLib.NAME);
-			luan.load(JavaLib.LOADER,JavaLib.NAME);
-			luan.load(MathLib.LOADER,MathLib.NAME);
-			luan.load(StringLib.LOADER,StringLib.NAME);
-			luan.load(TableLib.LOADER,TableLib.NAME);
-			luan.load(HtmlLib.LOADER,HtmlLib.NAME);
+			luan.load(BasicLib.NAME,BasicLib.LOADER);
+			luan.load(PackageLib.NAME,PackageLib.LOADER);
+			luan.load(JavaLib.NAME,JavaLib.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;
 		} catch(LuanException e) {
 			throw new RuntimeException(e);
--- a/src/luan/LuanTable.java	Mon Feb 18 22:07:40 2013 +0000
+++ b/src/luan/LuanTable.java	Mon Feb 18 23:15:14 2013 +0000
@@ -104,12 +104,12 @@
 	@Override public String toString() {
 		return "table: " + Integer.toHexString(hashCode());
 	}
-/*
-	@Override public String toString() {
-		return toString( Collections.newSetFromMap(new IdentityHashMap<LuanTable,Boolean>()) );
+
+	public String show() {
+		return show( Collections.newSetFromMap(new IdentityHashMap<LuanTable,Boolean>()) );
 	}
 
-	private String toString(Set<LuanTable> set) {
+	private String show(Set<LuanTable> set) {
 		if( !set.add(this) ) {
 			return "...";
 		}
@@ -130,7 +130,7 @@
 					}
 					if( gotNull )
 						sb.append(i+1).append('=');
-					sb.append(toString(set,obj));
+					sb.append(show(set,obj));
 				}
 			}
 		}
@@ -141,22 +141,22 @@
 				} else {
 					sb.append(", ");
 				}
-				sb.append(toString(set,entry.getKey())).append('=').append(toString(set,entry.getValue()));
+				sb.append(show(set,entry.getKey())).append('=').append(show(set,entry.getValue()));
 			}
 		}
 		sb.append('}');
 		return sb.toString();
 	}
 
-	private static String toString(Set<LuanTable> set,Object obj) {
+	private static String show(Set<LuanTable> set,Object obj) {
 		if( obj instanceof LuanTable ) {
 			LuanTable t = (LuanTable)obj;
-			return t.toString(set);
+			return t.show(set);
 		} else {
 			return Luan.toString(obj);
 		}
 	}
-*/
+
 	public Object get(Object key) {
 		if( list != null ) {
 			Integer iT = Luan.asInteger(key);
--- a/src/luan/lib/PackageLib.java	Mon Feb 18 22:07:40 2013 +0000
+++ b/src/luan/lib/PackageLib.java	Mon Feb 18 23:15:14 2013 +0000
@@ -100,7 +100,8 @@
 	public static final LuanFunction preloadSearcher = new LuanFunction() {
 		public Object[] call(LuanState luan,Object[] args) throws LuanException {
 			String modName = (String)args[0];
-			return new Object[]{luan.preload().get(modName)};
+			Object mod = luan.preload().get(modName);
+			return new Object[]{mod};
 		}
 	};
 
--- a/src/luan/tools/WebServlet.java	Mon Feb 18 22:07:40 2013 +0000
+++ b/src/luan/tools/WebServlet.java	Mon Feb 18 23:15:14 2013 +0000
@@ -28,25 +28,21 @@
 	protected LuanState luanState = null;
 
 	protected void loadLibs(LuanState luan) throws LuanException {
-		luan.load(BasicLib.LOADER,BasicLib.NAME);
-		luan.load(PackageLib.LOADER,PackageLib.NAME);
-		luan.load(MathLib.LOADER,MathLib.NAME);
-		luan.load(StringLib.LOADER,StringLib.NAME);
-		luan.load(TableLib.LOADER,TableLib.NAME);
-		luan.load(HtmlLib.LOADER,HtmlLib.NAME);
-	}
-
-	protected void loadLuan(LuanState luan) throws LuanException {
-		PackageLib.require(luan,HTTP_SERVER);
-		Object fn = luan.global().get(HttpLib.FN_NAME);
-		if( !(fn instanceof LuanFunction) )
-			throw new LuanException( luan, LuanElement.JAVA, "function '"+HttpLib.FN_NAME+"' not defined" );
+		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);
 	}
 
 	protected LuanState newLuanState() throws LuanException {
 		LuanState luan = LuanCompiler.newLuanState();
 		loadLibs(luan);
-		loadLuan(luan);
+		PackageLib.require(luan,HTTP_SERVER);
+		Object fn = luan.global().get(HttpLib.FN_NAME);
+		if( !(fn instanceof LuanFunction) )
+			throw new LuanException( luan, LuanElement.JAVA, "function '"+HttpLib.FN_NAME+"' not defined" );
 		return luan;
 	}