Mercurial Hosting > luan
comparison src/luan/lib/BasicLib.java @ 2:4da26b11d12a
start interp
git-svn-id: https://luan-java.googlecode.com/svn/trunk@3 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 14 Nov 2012 08:53:25 +0000 |
parents | |
children | 7a2cdbc5767f |
comparison
equal
deleted
inserted
replaced
1:2df768b926aa | 2:4da26b11d12a |
---|---|
1 package luan.lib; | |
2 | |
3 import luan.Lua; | |
4 import luan.LuaTable; | |
5 import luan.LuaJavaFunction; | |
6 | |
7 | |
8 public class BasicLib { | |
9 | |
10 public static void register(LuaTable t) { | |
11 add( t, "print", new Object[0].getClass() ); | |
12 } | |
13 | |
14 private static void add(LuaTable t,String method,Class<?>... parameterTypes) { | |
15 try { | |
16 t.set( method, new LuaJavaFunction(BasicLib.class.getMethod(method,parameterTypes),null) ); | |
17 } catch(NoSuchMethodException e) { | |
18 throw new RuntimeException(e); | |
19 } | |
20 } | |
21 | |
22 public static void print(Object... args) { | |
23 for( int i=0; i<args.length; i++ ) { | |
24 if( i > 0 ) | |
25 System.out.print('\t'); | |
26 System.out.print( Lua.toString(args[i]) ); | |
27 } | |
28 System.out.println(); | |
29 } | |
30 | |
31 } |