diff src/luan/lib/StringLib.java @ 86:6db8f286fa6c

_ENV is per module, not global git-svn-id: https://luan-java.googlecode.com/svn/trunk@87 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 27 Feb 2013 08:03:51 +0000
parents 805929c3c6e1
children eaf37cfa30c2
line wrap: on
line diff
--- a/src/luan/lib/StringLib.java	Mon Feb 25 03:53:54 2013 +0000
+++ b/src/luan/lib/StringLib.java	Wed Feb 27 08:03:51 2013 +0000
@@ -6,6 +6,7 @@
 import luan.LuanState;
 import luan.LuanTable;
 import luan.LuanFunction;
+import luan.LuanLoader;
 import luan.LuanJavaFunction;
 import luan.LuanElement;
 import luan.LuanException;
@@ -15,10 +16,9 @@
 
 	public static final String NAME = "string";
 
-	public static final LuanFunction LOADER = new LuanFunction() {
-		public Object[] call(LuanState luan,Object[] args) throws LuanException {
+	public static final LuanLoader LOADER = new LuanLoader() {
+		@Override protected void load(LuanState luan) {
 			LuanTable module = new LuanTable();
-			LuanTable global = luan.global();
 			try {
 				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) );
@@ -36,7 +36,7 @@
 			} catch(NoSuchMethodException e) {
 				throw new RuntimeException(e);
 			}
-			return new Object[]{module};
+			luan.loaded().put(NAME,module);
 		}
 	};
 
@@ -134,7 +134,7 @@
 		return new LuanFunction() {
 			public Object[] call(LuanState luan,Object[] args) {
 				if( !m.find() )
-					return LuanFunction.EMPTY_RTN;
+					return LuanFunction.EMPTY;
 				final int n = m.groupCount();
 				if( n == 0 )
 					return new String[]{m.group()};