comparison core/src/luan/impl/SetTableEntry.java @ 224:05eb2837ddbf

change LuanTable.put() to not return old value git-svn-id: https://luan-java.googlecode.com/svn/trunk@225 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 21 Jul 2014 09:27:06 +0000
parents b76fcb72d97d
children d55e873e1f0d
comparison
equal deleted inserted replaced
223:a9fe265dbac3 224:05eb2837ddbf
23 23
24 private void newindex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException { 24 private void newindex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException {
25 Object h; 25 Object h;
26 if( t instanceof LuanTable ) { 26 if( t instanceof LuanTable ) {
27 LuanTable table = (LuanTable)t; 27 LuanTable table = (LuanTable)t;
28 Object old; 28 h = luan.getHandler("__newindex",table);
29 try { 29 if( h==null || table.get(key)!=null ) {
30 old = table.put(key,value); 30 try {
31 } catch(IllegalArgumentException e) { 31 table.put(key,value);
32 throw luan.bit(se).exception(e); 32 } catch(IllegalArgumentException e) {
33 } catch(UnsupportedOperationException e) { 33 throw luan.bit(se).exception(e);
34 throw luan.bit(se).exception(e); 34 } catch(UnsupportedOperationException e) {
35 throw luan.bit(se).exception(e);
36 }
37 return;
35 } 38 }
36 if( old != null )
37 return;
38 h = luan.getHandler("__newindex",t);
39 if( h==null )
40 return;
41 table.put(key,old);
42 } else { 39 } else {
43 h = luan.getHandler("__newindex",t); 40 h = luan.getHandler("__newindex",t);
44 if( h==null ) 41 if( h==null )
45 throw luan.bit(se).exception( "attempt to index '"+tableExpr.se().text()+"' (a " + Luan.type(t) + " value)" ); 42 throw luan.bit(se).exception( "attempt to index '"+tableExpr.se().text()+"' (a " + Luan.type(t) + " value)" );
46 } 43 }