Mercurial Hosting > luan
comparison core/src/luan/modules/PickleClient.java @ 427:dae264ad6a7b
fix LuanTable.put() to use metatables
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 01 May 2015 19:29:07 -0600 |
parents | 23b99a5039b5 |
children | 60c549d43988 |
comparison
equal
deleted
inserted
replaced
426:23a93c118042 | 427:dae264ad6a7b |
---|---|
37 } | 37 } |
38 | 38 |
39 public Object call(Object... args) throws LuanException, IOException { | 39 public Object call(Object... args) throws LuanException, IOException { |
40 con.write(args); | 40 con.write(args); |
41 Object[] result; | 41 Object[] result; |
42 con.env.put("_reversed_pickle",_reversed_pickle); | 42 con.env.rawPut("_reversed_pickle",_reversed_pickle); |
43 try { | 43 try { |
44 result = Luan.array(con.read()); | 44 result = Luan.array(con.read()); |
45 } finally { | 45 } finally { |
46 con.env.put("_reversed_pickle",null); | 46 con.env.rawPut("_reversed_pickle",null); |
47 } | 47 } |
48 boolean ok = (boolean)result[0]; | 48 boolean ok = (boolean)result[0]; |
49 if( ok ) { | 49 if( ok ) { |
50 Object[] rtn = new Object[result.length-1]; | 50 Object[] rtn = new Object[result.length-1]; |
51 System.arraycopy(result,1,rtn,0,rtn.length); | 51 System.arraycopy(result,1,rtn,0,rtn.length); |
64 } | 64 } |
65 | 65 |
66 LuanTable table() { | 66 LuanTable table() { |
67 LuanTable tbl = new LuanTable(); | 67 LuanTable tbl = new LuanTable(); |
68 try { | 68 try { |
69 tbl.put( "pickle", new LuanJavaFunction( | 69 tbl.rawPut( "pickle", new LuanJavaFunction( |
70 PickleCon.class.getMethod( "pickle", Object.class ), con | 70 PickleCon.class.getMethod( "pickle", Object.class ), con |
71 ) ); | 71 ) ); |
72 tbl.put( "call", new LuanJavaFunction( | 72 tbl.rawPut( "call", new LuanJavaFunction( |
73 PickleClient.class.getMethod( "call", new Object[0].getClass() ), this | 73 PickleClient.class.getMethod( "call", new Object[0].getClass() ), this |
74 ) ); | 74 ) ); |
75 tbl.put( "close", new LuanJavaFunction( | 75 tbl.rawPut( "close", new LuanJavaFunction( |
76 PickleCon.class.getMethod( "close" ), con | 76 PickleCon.class.getMethod( "close" ), con |
77 ) ); | 77 ) ); |
78 } catch(NoSuchMethodException e) { | 78 } catch(NoSuchMethodException e) { |
79 throw new RuntimeException(e); | 79 throw new RuntimeException(e); |
80 } | 80 } |