comparison src/luan/lib/HtmlLib.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 4bf3d0c0b6b9
children b1e87f1bcc13
comparison
equal deleted inserted replaced
85:b2551f00bc51 86:6db8f286fa6c
1 package luan.lib; 1 package luan.lib;
2 2
3 import luan.LuanState; 3 import luan.LuanState;
4 import luan.LuanTable; 4 import luan.LuanTable;
5 import luan.LuanFunction; 5 import luan.LuanFunction;
6 import luan.LuanLoader;
6 import luan.LuanJavaFunction; 7 import luan.LuanJavaFunction;
7 8
8 9
9 public final class HtmlLib { 10 public final class HtmlLib {
10 11
11 public static final String NAME = "html"; 12 public static final String NAME = "html";
12 13
13 public static final LuanFunction LOADER = new LuanFunction() { 14 public static final LuanLoader LOADER = new LuanLoader() {
14 public Object[] call(LuanState luan,Object[] args) { 15 @Override protected void load(LuanState luan) {
15 LuanTable module = new LuanTable(); 16 LuanTable module = new LuanTable();
16 LuanTable global = luan.global();
17 try { 17 try {
18 add( module, "encode", String.class ); 18 add( module, "encode", String.class );
19 } catch(NoSuchMethodException e) { 19 } catch(NoSuchMethodException e) {
20 throw new RuntimeException(e); 20 throw new RuntimeException(e);
21 } 21 }
22 return new Object[]{module}; 22 luan.loaded().put(NAME,module);
23 } 23 }
24 }; 24 };
25 25
26 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { 26 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException {
27 t.put( method, new LuanJavaFunction(HtmlLib.class.getMethod(method,parameterTypes),null) ); 27 t.put( method, new LuanJavaFunction(HtmlLib.class.getMethod(method,parameterTypes),null) );