changeset 68:877288464542

better type checking git-svn-id: https://luan-java.googlecode.com/svn/trunk@69 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 23 Jan 2013 02:24:41 +0000
parents 8ca58ab6919b
children aeedefd3e3f3
files src/luan/LuanJavaFunction.java
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/LuanJavaFunction.java	Tue Jan 22 21:56:05 2013 +0000
+++ b/src/luan/LuanJavaFunction.java	Wed Jan 23 02:24:41 2013 +0000
@@ -49,8 +49,9 @@
 	}
 
 	@Override public Object[] call(LuanState luan,Object[] args) throws LuanException {
+		args = fixArgs(luan,args);
 		try {
-			return rawCall(luan,args);
+			return doCall(luan,args);
 		} catch(IllegalArgumentException e) {
 			checkArgs(luan,args);
 			throw e;
@@ -59,6 +60,10 @@
 
 	public Object[] rawCall(LuanState luan,Object[] args) throws LuanException {
 		args = fixArgs(luan,args);
+		return doCall(luan,args);
+	}
+
+	private Object[] doCall(LuanState luan,Object[] args) throws LuanException {
 		Object rtn;
 		try {
 			rtn = method.invoke(obj,args);
@@ -81,11 +86,6 @@
 
 	private void checkArgs(LuanState luan,Object[] args) throws LuanException {
 		Class<?>[] a = getParameterTypes();
-		if( takesLuaState ) {
-			Class<?>[] t = new Class<?>[a.length-1];
-			System.arraycopy(a,1,t,0,t.length);
-			a = t;
-		}
 		for( int i=0; i<a.length; i++ ) {
 			Class<?> paramType = a[i];
 			Object arg = args[i];