Mercurial Hosting > luan
comparison core/src/luan/LuanMeta.java @ 416:91af5337b9ae
add LuanMeta.__tostring()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 30 Apr 2015 06:28:25 -0600 |
parents | ce8e19567911 |
children | dae264ad6a7b |
comparison
equal
deleted
inserted
replaced
415:ce8e19567911 | 416:91af5337b9ae |
---|---|
43 | 43 |
44 public void __newindex(LuanState luan,LuanTable tbl,Object key,Object value) throws LuanException { | 44 public void __newindex(LuanState luan,LuanTable tbl,Object key,Object value) throws LuanException { |
45 throw new UnsupportedOperationException(); | 45 throw new UnsupportedOperationException(); |
46 } | 46 } |
47 | 47 |
48 protected abstract String type(LuanTable tbl); | |
49 | |
50 public String __tostring(LuanState luan,LuanTable tbl) throws LuanException { | |
51 return type(tbl) + "-" + tbl; | |
52 } | |
53 | |
48 public LuanTable newMetatable() { | 54 public LuanTable newMetatable() { |
49 LuanTable mt = new LuanTable(); | 55 LuanTable mt = new LuanTable(); |
50 mt.put( "__index", this ); | 56 mt.put( "__index", this ); |
51 mt.put( "__pairs", this ); | 57 mt.put( "__pairs", this ); |
58 mt.put( "__tostring", this ); | |
52 if( canNewindex() ) | 59 if( canNewindex() ) |
53 mt.put( "__newindex", this ); | 60 mt.put( "__newindex", this ); |
54 return mt; | 61 return mt; |
55 } | 62 } |
56 | 63 |