Mercurial Hosting > luan
comparison core/src/luan/modules/HtmlLuan.java @ 302:2f8938fc518c
fix modules Binary and Html
git-svn-id: https://luan-java.googlecode.com/svn/trunk@303 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 18 Dec 2014 04:56:30 +0000 |
parents | ec016471c6eb |
children | 4fe6c9fed486 |
comparison
equal
deleted
inserted
replaced
301:a6bf8ff720f8 | 302:2f8938fc518c |
---|---|
2 | 2 |
3 import luan.Luan; | 3 import luan.Luan; |
4 import luan.LuanState; | 4 import luan.LuanState; |
5 import luan.LuanTable; | 5 import luan.LuanTable; |
6 import luan.LuanFunction; | 6 import luan.LuanFunction; |
7 import luan.LuanJavaFunction; | |
8 import luan.LuanException; | 7 import luan.LuanException; |
9 | 8 |
10 | 9 |
11 public final class HtmlLuan { | 10 public final class HtmlLuan { |
12 | |
13 public static final LuanFunction LOADER = new LuanFunction() { | |
14 @Override public Object call(LuanState luan,Object[] args) { | |
15 LuanTable module = Luan.newTable(); | |
16 try { | |
17 add( module, "encode", String.class ); | |
18 } catch(NoSuchMethodException e) { | |
19 throw new RuntimeException(e); | |
20 } | |
21 return module; | |
22 } | |
23 }; | |
24 | |
25 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { | |
26 t.put( method, new LuanJavaFunction(HtmlLuan.class.getMethod(method,parameterTypes),null) ); | |
27 } | |
28 | 11 |
29 public static String encode(String s) { | 12 public static String encode(String s) { |
30 char[] a = s.toCharArray(); | 13 char[] a = s.toCharArray(); |
31 StringBuilder buf = new StringBuilder(); | 14 StringBuilder buf = new StringBuilder(); |
32 for( int i=0; i<a.length; i++ ) { | 15 for( int i=0; i<a.length; i++ ) { |