Mercurial Hosting > luan
view core/src/luan/LuanMeta.java @ 408:1b38de2b1845
merge LuanTableImpl into LuanTable
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 29 Apr 2015 13:15:17 -0600 |
parents | 3e68917a0dc6 |
children | 8937263f59f6 |
line wrap: on
line source
package luan; import java.util.Map; public abstract class LuanMeta /*implements Iterable<Map.Entry<Object,Object>>*/ { public abstract Object __index(LuanState luan,LuanTable tbl,Object key) throws LuanException; // public abstract LuanFunction __pairs(LuanState luan,LuanTable tbl) throws LuanException; public boolean canNewindex() { return false; } public void __newindex(LuanState luan,LuanTable tbl,Object key,Object value) throws LuanException { throw new UnsupportedOperationException(); } public LuanTable newMetatable() { LuanTable mt = new LuanTable(); /* try { mt.put( "__index", new LuanJavaFunction( LuanMeta.class.getMethod( "__index", LuanState.class, LuanTable.class, Object.class ), this ) ); if( canNewindex() ) { mt.put( "__newindex", new LuanJavaFunction( LuanMeta.class.getMethod( "__newindex", LuanState.class, LuanTable.class, Object.class, Object.class ), mt ) ); } } catch(NoSuchMethodException e) { throw new RuntimeException(e); } */ mt.put( "__index", this ); // mt.put( "__pairs", this ); if( canNewindex() ) mt.put( "__newindex", this ); return mt; } public LuanTable newTable() { LuanTable tbl = new LuanTable(); tbl.setMetatable( newMetatable() ); return tbl; } }