changeset 79:805929c3c6e1

add string.format git-svn-id: https://luan-java.googlecode.com/svn/trunk@80 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 15 Feb 2013 23:12:15 +0000
parents 7c08b611125d
children 851e356101c1
files src/luan/lib/StringLib.java
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/lib/StringLib.java	Fri Feb 15 22:29:16 2013 +0000
+++ b/src/luan/lib/StringLib.java	Fri Feb 15 23:12:15 2013 +0000
@@ -23,6 +23,7 @@
 				module.put( "byte", new LuanJavaFunction(StringLib.class.getMethod("byte_",String.class,Integer.class,Integer.class),null) );
 				module.put( "char", new LuanJavaFunction(StringLib.class.getMethod("char_",new byte[0].getClass()),null) );
 				add( module, "find", String.class, String.class, Integer.class, Boolean.class );
+				add( module, "format", String.class, new Object[0].getClass() );
 				add( module, "gmatch", String.class, String.class );
 				add( module, "gsub", LuanState.class, String.class, String.class, Object.class, Integer.class );
 				add( module, "len", String.class );
@@ -69,8 +70,6 @@
 		return new String(bytes);
 	}
 
-	// format is hard because String.format() is too stupid to convert ints to floats.
-
 	public static int len(String s) {
 		return s.length();
 	}
@@ -210,4 +209,9 @@
 		throw new LuanException( luan, LuanElement.JAVA, "bad argument #3 to 'gsub' (string/function/table expected)" );
 	}
 
+	// note - String.format() is too stupid to convert between ints and floats.
+	public static String format(String format,Object... args) {
+		return String.format(format,args);
+	}
+
 }