Mercurial Hosting > luan
comparison src/luan/lib/PickleCon.java @ 146:0517a4a7fcc5
add Io.reverse_pickle
git-svn-id: https://luan-java.googlecode.com/svn/trunk@147 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 15 Jun 2014 13:35:33 +0000 |
parents | 0594c132888b |
children | cc3a0578edac |
comparison
equal
deleted
inserted
replaced
145:90f38a5d0e0a | 146:0517a4a7fcc5 |
---|---|
21 | 21 |
22 public final class PickleCon { | 22 public final class PickleCon { |
23 final LuanState luan; | 23 final LuanState luan; |
24 private final DataInputStream in; | 24 private final DataInputStream in; |
25 private final LuanFunction _read_binary; | 25 private final LuanFunction _read_binary; |
26 private 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 | 30 |
31 PickleCon(LuanState luan,DataInputStream in,DataOutputStream out) { | 31 PickleCon(LuanState luan,DataInputStream in,DataOutputStream out) { |
55 return a; | 55 return a; |
56 } | 56 } |
57 | 57 |
58 public Object read() throws IOException, LuanException { | 58 public Object read() throws IOException, LuanException { |
59 ioModule.put("_read_binary",_read_binary); | 59 ioModule.put("_read_binary",_read_binary); |
60 src = in.readUTF(); | 60 try { |
61 LuanFunction fn = BasicLib.load(luan,src,"pickle-reader",true,false); | 61 src = in.readUTF(); |
62 Object rtn = luan.call(fn); | 62 LuanFunction fn = BasicLib.load(luan,src,"pickle-reader",true,false); |
63 ioModule.put("_binaries",null); | 63 return luan.call(fn); |
64 return rtn; | 64 } finally { |
65 ioModule.put("_binaries",null); | |
66 ioModule.put("_read_binary",null); | |
67 } | |
65 } | 68 } |
66 | 69 |
67 public String pickle(Object obj) throws LuanException { | 70 public String pickle(Object obj) throws LuanException { |
68 if( obj == null ) | 71 if( obj == null ) |
69 return "nil"; | 72 return "nil"; |