comparison src/luan/LuanJavaFunction.java @ 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 6db8f286fa6c
comparison
equal deleted inserted replaced
68:877288464542 69:aeedefd3e3f3
84 return rtnConverter.convert(rtn); 84 return rtnConverter.convert(rtn);
85 } 85 }
86 86
87 private void checkArgs(LuanState luan,Object[] args) throws LuanException { 87 private void checkArgs(LuanState luan,Object[] args) throws LuanException {
88 Class<?>[] a = getParameterTypes(); 88 Class<?>[] a = getParameterTypes();
89 for( int i=0; i<a.length; i++ ) { 89 int start = takesLuaState ? 1 : 0;
90 for( int i=start; i<a.length; i++ ) {
90 Class<?> paramType = a[i]; 91 Class<?> paramType = a[i];
91 Object arg = args[i]; 92 Object arg = args[i];
92 if( !paramType.isInstance(arg) ) { 93 if( !paramType.isInstance(arg) ) {
93 String expected = paramType.getSimpleName(); 94 String expected = paramType.getSimpleName();
94 if( arg==null ) { 95 if( arg==null ) {
95 if( paramType.isPrimitive() ) 96 if( paramType.isPrimitive() )
96 throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1)+" ("+expected+" expected, got nil)"); 97 throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1-start)+" ("+expected+" expected, got nil)");
97 } else { 98 } else {
98 String got = arg.getClass().getSimpleName(); 99 String got = arg.getClass().getSimpleName();
99 throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1)+" ("+expected+" expected, got "+got+")"); 100 throw new LuanException(luan,LuanElement.JAVA,"bad argument #"+(i+1-start)+" ("+expected+" expected, got "+got+")");
100 } 101 }
101 } 102 }
102 } 103 }
103 } 104 }
104 105