Mercurial Hosting > luan
diff core/src/luan/modules/StringLuan.java @ 539:473e456444ff
Remove object-oriented primitive methods for string and binary
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 17:53:55 -0600 |
parents | e3fb9768dbb3 |
children | f4dfe9c64c25 |
line wrap: on
line diff
--- a/core/src/luan/modules/StringLuan.java Mon Jun 01 00:51:44 2015 -0600 +++ b/core/src/luan/modules/StringLuan.java Mon Jun 01 17:53:55 2015 -0600 @@ -15,32 +15,6 @@ public final class StringLuan { - public static Object __index(LuanBit bit,final String s,Object key) throws LuanException { - LuanState luan = bit.luan; - LuanTable mod = (LuanTable)PackageLuan.require(luan,"luan:String"); - Object obj = mod.get(luan,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] = s; - System.arraycopy(args,0,a,1,args.length); - return fn.call(luan,a); - } - }; - } - if( luan.hasJava() ) { - Object rtn = JavaLuan.__index(bit,s,key,true); - if( rtn != JavaLuan.FAIL ) - return rtn; - } - if( bit.el != null ) - throw bit.exception( "invalid index for string in '"+bit.el.text()+"'" ) ; - else - throw bit.exception( "invalid index for string") ; - } - static int start(String s,int i) { int len = s.length(); return i==0 ? 0 : i > 0 ? Math.min(i-1,len) : Math.max(len+i,0); @@ -78,7 +52,7 @@ return new String(a); } - @LuanMethod public static byte[] to_binary(String s) { + @LuanMethod public static byte[] string_to_binary(String s) { return s.getBytes(); } @@ -249,7 +223,7 @@ return Luan.stringEncode(s); } - public static Number to_number(LuanState luan,String s,Integer base) throws LuanException { + public static Number string_to_number(LuanState luan,String s,Integer base) throws LuanException { Utils.checkNotNull(luan,s); try { if( base == null ) {