Mercurial Hosting > luan
changeset 196:be0275bda373
minor
git-svn-id: https://luan-java.googlecode.com/svn/trunk@197 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 03 Jul 2014 18:03:53 +0000 |
parents | 24ede40ee0aa |
children | 4c96cb73dd93 |
files | core/src/luan/LuanTable.java core/src/luan/MetatableGetter.java core/src/luan/modules/JavaLuan.java core/src/luan/modules/PackageLuan.java core/src/luan/modules/StringLuan.java |
diffstat | 5 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
diff -r 24ede40ee0aa -r be0275bda373 core/src/luan/LuanTable.java --- a/core/src/luan/LuanTable.java Thu Jul 03 08:19:48 2014 +0000 +++ b/core/src/luan/LuanTable.java Thu Jul 03 18:03:53 2014 +0000 @@ -18,7 +18,6 @@ private Map<Object,Object> map = null; private List<Object> list = null; private LuanTable metatable = null; - public MetatableGetter metatableGetter = null; // used for modules public LuanTable() {} @@ -63,7 +62,6 @@ } @Override public void deepenClone(LuanTable clone,DeepCloner cloner) { - clone.metatableGetter = this.metatableGetter; if( map != null ) { clone.map = new HashMap<Object,Object>(); for( Map.Entry<Object,Object> entry : map.entrySet() ) {
diff -r 24ede40ee0aa -r be0275bda373 core/src/luan/MetatableGetter.java --- a/core/src/luan/MetatableGetter.java Thu Jul 03 08:19:48 2014 +0000 +++ b/core/src/luan/MetatableGetter.java Thu Jul 03 18:03:53 2014 +0000 @@ -1,5 +1,6 @@ package luan; public interface MetatableGetter extends DeepCloneable<MetatableGetter> { + public static final String KEY = "_METATABLE_GETTER"; public LuanTable getMetatable(Object obj); }
diff -r 24ede40ee0aa -r be0275bda373 core/src/luan/modules/JavaLuan.java --- a/core/src/luan/modules/JavaLuan.java Thu Jul 03 08:19:48 2014 +0000 +++ b/core/src/luan/modules/JavaLuan.java Thu Jul 03 18:03:53 2014 +0000 @@ -32,7 +32,7 @@ public static final LuanFunction LOADER = new LuanFunction() { @Override public Object call(LuanState luan,Object[] args) { LuanTable module = new LuanTable(); - module.metatableGetter = mg; + module.put( MetatableGetter.KEY, mg ); try { module.put( "class", new LuanJavaFunction(JavaLuan.class.getMethod("getClass",LuanState.class,String.class),null) ); add( module, "proxy", LuanState.class, Static.class, LuanTable.class, Object.class );
diff -r 24ede40ee0aa -r be0275bda373 core/src/luan/modules/PackageLuan.java --- a/core/src/luan/modules/PackageLuan.java Thu Jul 03 08:19:48 2014 +0000 +++ b/core/src/luan/modules/PackageLuan.java Thu Jul 03 18:03:53 2014 +0000 @@ -11,6 +11,7 @@ import luan.LuanJavaFunction; import luan.LuanElement; import luan.LuanException; +import luan.MetatableGetter; public final class PackageLuan { @@ -84,8 +85,9 @@ } if( mod instanceof LuanTable ) { LuanTable modTbl = (LuanTable)mod; - if( modTbl.metatableGetter != null ) - luan.addMetatableGetter(modTbl.metatableGetter); + MetatableGetter mg = (MetatableGetter)modTbl.get(MetatableGetter.KEY); + if( mg != null ) + luan.addMetatableGetter(mg); } return mod; }
diff -r 24ede40ee0aa -r be0275bda373 core/src/luan/modules/StringLuan.java --- a/core/src/luan/modules/StringLuan.java Thu Jul 03 08:19:48 2014 +0000 +++ b/core/src/luan/modules/StringLuan.java Thu Jul 03 18:03:53 2014 +0000 @@ -18,7 +18,7 @@ public static final LuanFunction LOADER = new LuanFunction() { @Override public Object call(LuanState luan,Object[] args) { LuanTable module = new LuanTable(); - module.metatableGetter = new MyMetatableGetter(module); + module.put( MetatableGetter.KEY, new MyMetatableGetter(module) ); try { add( module, "to_binary", String.class ); add( module, "to_integers", String.class );