Mercurial Hosting > luan
comparison core/src/luan/modules/BinaryLuan.java @ 171:3dcb0f9bee82
add core component
git-svn-id: https://luan-java.googlecode.com/svn/trunk@172 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 22 Jun 2014 05:41:22 +0000 |
parents | src/luan/modules/BinaryLuan.java@ebe9db183eb7 |
children | ec016471c6eb |
comparison
equal
deleted
inserted
replaced
170:7c792a328a83 | 171:3dcb0f9bee82 |
---|---|
1 package luan.modules; | |
2 | |
3 import luan.LuanState; | |
4 import luan.LuanTable; | |
5 import luan.LuanFunction; | |
6 import luan.LuanJavaFunction; | |
7 import luan.LuanException; | |
8 | |
9 | |
10 public final class BinaryLuan { | |
11 | |
12 public static final LuanFunction LOADER = new LuanFunction() { | |
13 @Override public Object call(LuanState luan,Object[] args) { | |
14 LuanTable module = new LuanTable(); | |
15 try { | |
16 add( module, "to_string", new byte[0].getClass() ); | |
17 } catch(NoSuchMethodException e) { | |
18 throw new RuntimeException(e); | |
19 } | |
20 return module; | |
21 } | |
22 }; | |
23 | |
24 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { | |
25 t.put( method, new LuanJavaFunction(BinaryLuan.class.getMethod(method,parameterTypes),null) ); | |
26 } | |
27 | |
28 public static String to_string(byte[] bytes) { | |
29 return new String(bytes); | |
30 } | |
31 | |
32 } |