Mercurial Hosting > luan
diff core/src/luan/impl/SetTableEntry.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 | df95199ca4c0 |
line wrap: on
line diff
--- a/core/src/luan/impl/SetTableEntry.java Fri May 01 18:44:20 2015 -0600 +++ b/core/src/luan/impl/SetTableEntry.java Fri May 01 19:29:07 2015 -0600 @@ -25,29 +25,9 @@ private void newindex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException { if( t instanceof LuanTable ) { - LuanTable table = (LuanTable)t; - Object h = table.getHandler("__newindex"); - if( h==null || table.rawGet(key)!=null ) { - try { - table.put(key,value); - } catch(IllegalArgumentException e) { - throw luan.bit(se).exception(e); - } catch(UnsupportedOperationException e) { - throw luan.bit(se).exception(e); - } - return; - } - if( h instanceof LuanFunction ) { - LuanFunction fn = (LuanFunction)h; - luan.bit(se).call(fn,"__newindex",new Object[]{t,key,value}); - return; - } - if( h instanceof LuanMeta ) { - LuanMeta meta = (LuanMeta)h; - meta.__newindex(luan,table,key,value); - return; - } - newindex(luan,h,key,value); + LuanTable tbl = (LuanTable)t; + tbl.put(luan,key,value); + return; } if( t != null && luan.currentEnvironment().hasJava() ) JavaLuan.__newindex(luan,t,key,value);