diff core/src/luan/modules/PickleCon.java @ 202:75750ceb45ee

add LuanState.registry git-svn-id: https://luan-java.googlecode.com/svn/trunk@203 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 04 Jul 2014 17:18:39 +0000
parents fb3993431f76
children ec016471c6eb
line wrap: on
line diff
--- a/core/src/luan/modules/PickleCon.java	Thu Jul 03 22:42:44 2014 +0000
+++ b/core/src/luan/modules/PickleCon.java	Fri Jul 04 17:18:39 2014 +0000
@@ -23,11 +23,10 @@
 	final LuanState luan;
 	private final DataInputStream in;
 	private final LuanFunction _read_binary;
-	final LuanTable ioModule;
 	private final DataOutputStream out;
 	private final List<byte[]> binaries = new ArrayList<byte[]>();
 	String src;
-	private final LuanTable env = new LuanTable();
+	final LuanTable env = new LuanTable();
 
 	PickleCon(LuanState luan,DataInputStream in,DataOutputStream out) {
 		this.in = in;
@@ -39,8 +38,6 @@
 		} catch(NoSuchMethodException e) {
 			throw new RuntimeException(e);
 		}
-		this.ioModule = (LuanTable)luan.loaded().get("Io");
-		env.put("Io",ioModule);
 
 		this.out = out;
 	}
@@ -58,14 +55,14 @@
 	}
 
 	public Object read() throws IOException, LuanException {
-		ioModule.put("_read_binary",_read_binary);
+		env.put("_read_binary",_read_binary);
 		try {
 			src = in.readUTF();
 			LuanFunction fn = BasicLuan.load(luan,src,"pickle-reader",env,false);
 			return luan.call(fn);
 		} finally {
-			ioModule.put("_binaries",null);
-			ioModule.put("_read_binary",null);
+			env.put("_binaries",null);
+			env.put("_read_binary",null);
 		}
 	}
 
@@ -83,7 +80,7 @@
 		if( obj instanceof byte[] ) {
 			byte[] a = (byte[])obj;
 			binaries.add(a);
-			return "Io._binaries[" + binaries.size() + "]";
+			return "_binaries[" + binaries.size() + "]";
 		}
 		throw luan.exception( "invalid type: " + obj.getClass() );
 	}
@@ -112,9 +109,9 @@
 	public void write(Object... args) throws LuanException, IOException {
 		StringBuilder sb = new StringBuilder();
 		if( !binaries.isEmpty() ) {
-			sb.append( "Io._binaries = {}\n" );
+			sb.append( "_binaries = {}\n" );
 			for( byte[] a : binaries ) {
-				sb.append( "Io._binaries[#Io._binaries+1] = Io._read_binary(" + a.length + ")\n" );
+				sb.append( "_binaries[#_binaries+1] = _read_binary(" + a.length + ")\n" );
 			}
 		}
 		for( Object obj : args ) {