Mercurial Hosting > luan
annotate 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 |
rev | line source |
---|---|
405 | 1 package luan; |
2 | |
3 import java.util.Map; | |
4 | |
5 | |
6 public abstract class LuanMeta /*implements Iterable<Map.Entry<Object,Object>>*/ { | |
7 | |
8 public abstract Object __index(LuanState luan,LuanTable tbl,Object key) throws LuanException; | |
9 | |
10 // public abstract LuanFunction __pairs(LuanState luan,LuanTable tbl) throws LuanException; | |
11 | |
12 public boolean canNewindex() { | |
13 return false; | |
14 } | |
15 | |
16 public void __newindex(LuanState luan,LuanTable tbl,Object key,Object value) throws LuanException { | |
17 throw new UnsupportedOperationException(); | |
18 } | |
19 | |
20 public LuanTable newMetatable() { | |
408
1b38de2b1845
merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents:
405
diff
changeset
|
21 LuanTable mt = new LuanTable(); |
405 | 22 /* |
23 try { | |
24 mt.put( "__index", new LuanJavaFunction( | |
25 LuanMeta.class.getMethod( "__index", LuanState.class, LuanTable.class, Object.class ), this | |
26 ) ); | |
27 if( canNewindex() ) { | |
28 mt.put( "__newindex", new LuanJavaFunction( | |
29 LuanMeta.class.getMethod( "__newindex", LuanState.class, LuanTable.class, Object.class, Object.class ), mt | |
30 ) ); | |
31 } | |
32 } catch(NoSuchMethodException e) { | |
33 throw new RuntimeException(e); | |
34 } | |
35 */ | |
36 mt.put( "__index", this ); | |
37 // mt.put( "__pairs", this ); | |
38 if( canNewindex() ) | |
39 mt.put( "__newindex", this ); | |
40 return mt; | |
41 } | |
42 | |
43 public LuanTable newTable() { | |
408
1b38de2b1845
merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents:
405
diff
changeset
|
44 LuanTable tbl = new LuanTable(); |
405 | 45 tbl.setMetatable( newMetatable() ); |
46 return tbl; | |
47 } | |
48 } |