Mercurial Hosting > luan
diff core/src/luan/modules/StringLuan.java @ 202:75750ceb45ee
add LuanState.registry
git-svn-id: https://luan-java.googlecode.com/svn/trunk@203 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 04 Jul 2014 17:18:39 +0000 |
parents | 4c96cb73dd93 |
children | 5ba136769034 |
line wrap: on
line diff
--- a/core/src/luan/modules/StringLuan.java Thu Jul 03 22:42:44 2014 +0000 +++ b/core/src/luan/modules/StringLuan.java Fri Jul 04 17:18:39 2014 +0000 @@ -18,9 +18,7 @@ public static final LuanFunction LOADER = new LuanFunction() { @Override public Object call(LuanState luan,Object[] args) { LuanTable module = new LuanTable(); - MyMetatableGetter mmg = new MyMetatableGetter(); - mmg.init(module); - module.put( MetatableGetter.KEY, mmg ); + module.put( MetatableGetter.KEY, new MyMetatableGetter(module) ); try { add( module, "to_binary", String.class ); add( module, "to_integers", String.class ); @@ -51,9 +49,7 @@ private LuanTable module; private LuanTable metatable; - private MyMetatableGetter() {} - - private void init(LuanTable module) { + private MyMetatableGetter(LuanTable module) { this.module = module; this.metatable = new LuanTable(); try { @@ -65,8 +61,10 @@ } } + private MyMetatableGetter(MyMetatableGetter mmg) {} + @Override public MetatableGetter shallowClone() { - return new MyMetatableGetter(); + return new MyMetatableGetter(this); } @Override public void deepenClone(MetatableGetter c,DeepCloner cloner) {