comparison src/luan/LuanJavaFunction.java @ 783:4083f5a67c63

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 30 Aug 2016 12:00:38 -0600
parents 1a68fc55a80c
children 626815a4b19b
comparison
equal deleted inserted replaced
782:655280eab1e2 783:4083f5a67c63
40 this.varArgCls = paramTypes[paramTypes.length-1].getComponentType(); 40 this.varArgCls = paramTypes[paramTypes.length-1].getComponentType();
41 } else { 41 } else {
42 this.varArgCls = null; 42 this.varArgCls = null;
43 } 43 }
44 } 44 }
45 /* 45
46 private LuanJavaFunction(LuanJavaFunction f) {
47 this.method = f.method;
48 this.rtnConverter = f.rtnConverter;
49 this.takesLuaState = f.takesLuaState;
50 this.argConverters = f.argConverters;
51 this.varArgCls = f.varArgCls;
52 }
53
54 @Override public LuanJavaFunction shallowClone() {
55 return obj==null ? this : new LuanJavaFunction(this);
56 }
57
58 @Override public void deepenClone(LuanJavaFunction clone,DeepCloner cloner) {
59 clone.obj = cloner.get(obj);
60 }
61 */
62 @Override public String toString() { 46 @Override public String toString() {
63 return "java-function: " + method; 47 return "java-function: " + method;
64 } 48 }
65 49
66 public Class[] getParameterTypes() { 50 public int getParameterCount() {
67 return method.getParameterTypes(); 51 return argConverters.length;
68 } 52 }
69 53
70 @Override public Object call(LuanState luan,Object[] args) throws LuanException { 54 @Override public Object call(LuanState luan,Object[] args) throws LuanException {
71 try { 55 try {
72 args = fixArgs(luan,args); 56 args = fixArgs(luan,args);
113 primitiveMap.put(Double.TYPE,Double.class); 97 primitiveMap.put(Double.TYPE,Double.class);
114 primitiveMap.put(Void.TYPE,Void.class); 98 primitiveMap.put(Void.TYPE,Void.class);
115 } 99 }
116 100
117 private void checkArgs(Object[] args) throws LuanException { 101 private void checkArgs(Object[] args) throws LuanException {
118 Class[] a = getParameterTypes(); 102 Class[] a = method.getParameterTypes();
119 int start = takesLuaState ? 1 : 0; 103 int start = takesLuaState ? 1 : 0;
120 for( int i=start; i<a.length; i++ ) { 104 for( int i=start; i<a.length; i++ ) {
121 Class paramType = a[i]; 105 Class paramType = a[i];
122 Class type = paramType; 106 Class type = paramType;
123 if( type.isPrimitive() ) 107 if( type.isPrimitive() )