diff src/luan/modules/StringLuan.java @ 1335:e0cf0d108a77

major cleanup
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 14 Feb 2019 03:10:45 -0700
parents c88b486a9511
children f5368cd8c056
line wrap: on
line diff
--- a/src/luan/modules/StringLuan.java	Tue Feb 12 22:53:57 2019 -0700
+++ b/src/luan/modules/StringLuan.java	Thu Feb 14 03:10:45 2019 -0700
@@ -7,7 +7,6 @@
 import luan.LuanTable;
 import luan.LuanFunction;
 import luan.LuanException;
-import luan.LuanMethod;
 
 
 public final class StringLuan {
@@ -30,7 +29,7 @@
 		return i==null ? dflt : end(s,i);
 	}
 
-	@LuanMethod public static Integer[] unicode(String s,Integer i,Integer j) throws LuanException {
+	public static Integer[] unicode(String s,Integer i,Integer j) throws LuanException {
 		Utils.checkNotNull(s);
 		int start = start(s,i,1);
 		int end = end(s,j,start+1);
@@ -49,7 +48,7 @@
 		return new String(a);
 	}
 
-	@LuanMethod public static byte[] to_binary(String s) {
+	public static byte[] to_binary(String s) {
 		return s.getBytes();
 	}
 
@@ -92,7 +91,7 @@
 		return s.substring(start,end);
 	}
 
-	@LuanMethod public static Object[] find(String s,String pattern,Integer init,Boolean plain) {
+	public static Object[] find(String s,String pattern,Integer init,Boolean plain) {
 		int start = start(s,init,0);
 		if( Boolean.TRUE.equals(plain) ) {
 			int i = s.indexOf(pattern,start);
@@ -111,7 +110,7 @@
 		return rtn;
 	}
 
-	@LuanMethod public static String[] match(String s,String pattern,Integer init) {
+	public static String[] match(String s,String pattern,Integer init) {
 		int start = start(s,init,0);
 		Matcher m = Pattern.compile(pattern).matcher(s);
 		if( !m.find(start) )
@@ -129,8 +128,8 @@
 	public static LuanFunction gmatch(String s,String pattern) throws LuanException {
 		Utils.checkNotNull(s);
 		final Matcher m = Pattern.compile(pattern).matcher(s);
-		return new LuanFunction() {
-			@Override public Object call(Luan luan,Object[] args) {
+		return new LuanFunction(false) {
+			@Override public Object call(Object[] args) {
 				if( !m.find() )
 					return null;
 				final int n = m.groupCount();
@@ -145,7 +144,7 @@
 		};
 	}
 
-	@LuanMethod public static Object[] gsub(Luan luan,String s,String pattern,Object repl,Integer n) throws LuanException {
+	public static Object[] gsub(String s,String pattern,Object repl,Integer n) throws LuanException {
 		Utils.checkNotNull(s);
 		int max = n==null ? Integer.MAX_VALUE : n;
 		final Matcher m = Pattern.compile(pattern).matcher(s);
@@ -191,7 +190,7 @@
 						args[j] = m.group(j+1);
 					}
 				}
-				Object val = Luan.first( fn.call(luan,args) );
+				Object val = Luan.first( fn.call(args) );
 				if( val != null ) {
 					String replacement = Luan.luanToString(val);
 					m.appendReplacement(sb,replacement);
@@ -238,7 +237,7 @@
 		return Pattern.compile(pattern).matcher(s).find();
 	}
 
-	@LuanMethod public static String[] split(String s,String pattern,Integer limit) throws LuanException {
+	public static String[] split(String s,String pattern,Integer limit) throws LuanException {
 		Utils.checkNotNull(s);
 		int n = limit==null ? -1 : limit;
 		return s.split(pattern,n);