comparison core/src/luan/modules/PickleServer.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 23a93c118042
children 8dcf9e12446b
comparison
equal deleted inserted replaced
426:23a93c118042 427:dae264ad6a7b
71 LuanTable env = con.env; 71 LuanTable env = con.env;
72 Object old_reverse_pickle = io.rawGet("reverse_pickle"); 72 Object old_reverse_pickle = io.rawGet("reverse_pickle");
73 Object old_unreverse_pickle = env.rawGet("_unreverse_pickle"); 73 Object old_unreverse_pickle = env.rawGet("_unreverse_pickle");
74 try { 74 try {
75 try { 75 try {
76 io.put("reverse_pickle", new LuanJavaFunction( 76 io.rawPut("reverse_pickle", new LuanJavaFunction(
77 PickleServer.class.getMethod( "reverse_pickle", LuanFunction.class ), this 77 PickleServer.class.getMethod( "reverse_pickle", LuanFunction.class ), this
78 ) ); 78 ) );
79 env.put("_unreverse_pickle", new LuanJavaFunction( 79 env.rawPut("_unreverse_pickle", new LuanJavaFunction(
80 PickleServer.class.getMethod( "_unreverse_pickle" ), this 80 PickleServer.class.getMethod( "_unreverse_pickle" ), this
81 ) ); 81 ) );
82 } catch(NoSuchMethodException e) { 82 } catch(NoSuchMethodException e) {
83 throw new RuntimeException(e); 83 throw new RuntimeException(e);
84 } 84 }
98 } catch(IOException e) { 98 } catch(IOException e) {
99 throw new RuntimeException(e); 99 throw new RuntimeException(e);
100 } 100 }
101 } 101 }
102 } finally { 102 } finally {
103 io.put("reverse_pickle",old_reverse_pickle); 103 io.rawPut("reverse_pickle",old_reverse_pickle);
104 env.put("_unreverse_pickle",old_unreverse_pickle); 104 env.rawPut("_unreverse_pickle",old_unreverse_pickle);
105 } 105 }
106 } 106 }
107 107
108 public void reverse_pickle(LuanFunction fn) throws IOException, LuanException { 108 public void reverse_pickle(LuanFunction fn) throws IOException, LuanException {
109 try { 109 try {