Mercurial Hosting > luan
comparison src/luan/lib/StringLib.java @ 74:f003338d503b
improve package lib
git-svn-id: https://luan-java.googlecode.com/svn/trunk@75 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 13 Feb 2013 06:27:56 +0000 |
parents | f86e4f77ef32 |
children | 4bf3d0c0b6b9 |
comparison
equal
deleted
inserted
replaced
73:f86e4f77ef32 | 74:f003338d503b |
---|---|
17 | 17 |
18 public static final LuanFunction LOADER = new LuanFunction() { | 18 public static final LuanFunction LOADER = new LuanFunction() { |
19 public Object[] call(LuanState luan,Object[] args) throws LuanException { | 19 public Object[] call(LuanState luan,Object[] args) throws LuanException { |
20 LuanTable module = new LuanTable(); | 20 LuanTable module = new LuanTable(); |
21 LuanTable global = luan.global; | 21 LuanTable global = luan.global; |
22 global.put(NAME,module); | |
23 try { | 22 try { |
24 module.put( "byte", new LuanJavaFunction(StringLib.class.getMethod("byte_",String.class,Integer.class,Integer.class),null) ); | 23 module.put( "byte", new LuanJavaFunction(StringLib.class.getMethod("byte_",String.class,Integer.class,Integer.class),null) ); |
25 module.put( "char", new LuanJavaFunction(StringLib.class.getMethod("char_",new byte[0].getClass()),null) ); | 24 module.put( "char", new LuanJavaFunction(StringLib.class.getMethod("char_",new byte[0].getClass()),null) ); |
26 add( module, "find", String.class, String.class, Integer.class, Boolean.class ); | 25 add( module, "find", String.class, String.class, Integer.class, Boolean.class ); |
27 add( module, "gmatch", String.class, String.class ); | 26 add( module, "gmatch", String.class, String.class ); |
34 add( module, "sub", String.class, Integer.TYPE, Integer.class ); | 33 add( module, "sub", String.class, Integer.TYPE, Integer.class ); |
35 add( module, "upper", String.class ); | 34 add( module, "upper", String.class ); |
36 } catch(NoSuchMethodException e) { | 35 } catch(NoSuchMethodException e) { |
37 throw new RuntimeException(e); | 36 throw new RuntimeException(e); |
38 } | 37 } |
39 return LuanFunction.EMPTY_RTN; | 38 return new Object[]{module}; |
40 } | 39 } |
41 }; | 40 }; |
42 | 41 |
43 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { | 42 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { |
44 t.put( method, new LuanJavaFunction(StringLib.class.getMethod(method,parameterTypes),null) ); | 43 t.put( method, new LuanJavaFunction(StringLib.class.getMethod(method,parameterTypes),null) ); |