comparison src/luan/lib/PickleCon.java @ 149:f99fd64291b3

change load() to take env instead of using global git-svn-id: https://luan-java.googlecode.com/svn/trunk@150 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 16 Jun 2014 05:47:54 +0000
parents cc3a0578edac
children f35c50027985
comparison
equal deleted inserted replaced
148:dfd0f33b584e 149:f99fd64291b3
25 private final LuanFunction _read_binary; 25 private final LuanFunction _read_binary;
26 final LuanTable ioModule; 26 final LuanTable ioModule;
27 private final DataOutputStream out; 27 private final DataOutputStream out;
28 private final List<byte[]> binaries = new ArrayList<byte[]>(); 28 private final List<byte[]> binaries = new ArrayList<byte[]>();
29 String src; 29 String src;
30 private final LuanTable env;
30 31
31 PickleCon(LuanState luan,DataInputStream in,DataOutputStream out) { 32 PickleCon(LuanState luan,DataInputStream in,DataOutputStream out) {
32 this.in = in; 33 this.in = in;
33 this.luan = luan; 34 this.luan = luan;
34 try { 35 try {
37 ); 38 );
38 } catch(NoSuchMethodException e) { 39 } catch(NoSuchMethodException e) {
39 throw new RuntimeException(e); 40 throw new RuntimeException(e);
40 } 41 }
41 this.ioModule = (LuanTable)luan.loaded().get("Io"); 42 this.ioModule = (LuanTable)luan.loaded().get("Io");
43 this.env = new LuanTable(luan.global());
42 44
43 this.out = out; 45 this.out = out;
44 } 46 }
45 47
46 public byte[] _read_binary(int size) throws IOException, LuanException { 48 public byte[] _read_binary(int size) throws IOException, LuanException {
57 59
58 public Object read() throws IOException, LuanException { 60 public Object read() throws IOException, LuanException {
59 ioModule.put("_read_binary",_read_binary); 61 ioModule.put("_read_binary",_read_binary);
60 try { 62 try {
61 src = in.readUTF(); 63 src = in.readUTF();
62 LuanFunction fn = BasicLib.load(luan,src,"pickle-reader",true,false); 64 LuanFunction fn = BasicLib.load(luan,src,"pickle-reader",env,false);
63 return luan.call(fn); 65 return luan.call(fn);
64 } finally { 66 } finally {
65 ioModule.put("_binaries",null); 67 ioModule.put("_binaries",null);
66 ioModule.put("_read_binary",null); 68 ioModule.put("_read_binary",null);
67 } 69 }