changeset 69:aeedefd3e3f3

minor git-svn-id: https://luan-java.googlecode.com/svn/trunk@70 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 23 Jan 2013 03:18:13 +0000
parents 877288464542
children 59431bb8d0bf
files src/luan/LuanJavaFunction.java
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
diff -r 877288464542 -r aeedefd3e3f3 src/luan/LuanJavaFunction.java
--- a/src/luan/LuanJavaFunction.java	Wed Jan 23 02:24:41 2013 +0000
+++ b/src/luan/LuanJavaFunction.java	Wed Jan 23 03:18:13 2013 +0000
@@ -86,17 +86,18 @@
 
 	private void checkArgs(LuanState luan,Object[] args) throws LuanException {
 		Class<?>[] a = getParameterTypes();
-		for( int i=0; i<a.length; i++ ) {
+		int start = takesLuaState ? 1 : 0;
+		for( int i=start; i<a.length; i++ ) {
 			Class<?> paramType = a[i];
 			Object arg = args[i];
 			if( !paramType.isInstance(arg) ) {
 				String expected = paramType.getSimpleName();
 				if( arg==null ) {
 					if( paramType.isPrimitive() )
-						throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1)+" ("+expected+" expected, got nil)");
+						throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1-start)+" ("+expected+" expected, got nil)");
 				} else {
 					String got = arg.getClass().getSimpleName();
-					throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1)+" ("+expected+" expected, got "+got+")");
+					throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1-start)+" ("+expected+" expected, got "+got+")");
 				}
 			}
 		}