Mercurial Hosting > luan
diff core/src/luan/modules/BinaryLuan.java @ 404:d55e873e1f0d
metatables now only apply to tables
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 29 Apr 2015 07:04:40 -0600 |
parents | cbb94a7c7a9e |
children | abce9b0041b0 |
line wrap: on
line diff
--- a/core/src/luan/modules/BinaryLuan.java Tue Apr 28 22:49:33 2015 -0600 +++ b/core/src/luan/modules/BinaryLuan.java Wed Apr 29 07:04:40 2015 -0600 @@ -11,20 +11,18 @@ public final class BinaryLuan { public static Object __index(LuanState luan,final byte[] binary,Object key) throws LuanException { - LuanTable mod = (LuanTable)PackageLuan.loaded(luan).get("luan:Binary"); - if( mod!=null ) { - Object obj = mod.get(key); - if( obj instanceof LuanFunction ) { - final LuanFunction fn = (LuanFunction)obj; - return new LuanFunction() { - @Override public Object call(LuanState luan,Object[] args) throws LuanException { - Object[] a = new Object[args.length+1]; - a[0] = binary; - System.arraycopy(args,0,a,1,args.length); - return fn.call(luan,a); - } - }; - } + LuanTable mod = (LuanTable)luan.require("luan:Binary"); + Object obj = mod.get(key); + if( obj instanceof LuanFunction ) { + final LuanFunction fn = (LuanFunction)obj; + return new LuanFunction() { + @Override public Object call(LuanState luan,Object[] args) throws LuanException { + Object[] a = new Object[args.length+1]; + a[0] = binary; + System.arraycopy(args,0,a,1,args.length); + return fn.call(luan,a); + } + }; } return null; }