diff src/luan/LuanJavaFunction.java @ 1333:25746915a241

merge Luan and LuanState
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Feb 2019 22:33:40 -0700
parents 9fa8b8389578
children e0cf0d108a77
line wrap: on
line diff
--- a/src/luan/LuanJavaFunction.java	Tue Feb 12 21:50:26 2019 -0700
+++ b/src/luan/LuanJavaFunction.java	Tue Feb 12 22:33:40 2019 -0700
@@ -55,7 +55,7 @@
 		return method.isVarArgs();
 	}
 
-	@Override public Object call(LuanState luan,Object[] args) throws LuanException {
+	@Override public Object call(Luan luan,Object[] args) throws LuanException {
 		try {
 			args = fixArgs(luan,args);
 			return doCall(luan,args);
@@ -65,12 +65,12 @@
 		}
 	}
 
-	public Object rawCall(LuanState luan,Object[] args) throws LuanException {
+	public Object rawCall(Luan luan,Object[] args) throws LuanException {
 		args = fixArgs(luan,args);
 		return doCall(luan,args);
 	}
 
-	private Object doCall(LuanState luan,Object[] args) throws LuanException {
+	private Object doCall(Luan luan,Object[] args) throws LuanException {
 		Object rtn;
 		try {
 			rtn = method.invoke(obj,args);
@@ -146,7 +146,7 @@
 		return type;
 	}
 
-	private Object[] fixArgs(LuanState luan,Object[] args) throws LuanException {
+	private Object[] fixArgs(Luan luan,Object[] args) throws LuanException {
 		int n = argConverters.length;
 		Object[] rtn;
 		int start = 0;
@@ -189,23 +189,23 @@
 
 
 	private interface RtnConverter {
-		public Object convert(LuanState luan,Object obj);
+		public Object convert(Luan luan,Object obj);
 	}
 
 	private static final RtnConverter RTN_NOTHING = new RtnConverter() {
-		@Override public Object[] convert(LuanState luan,Object obj) {
+		@Override public Object[] convert(Luan luan,Object obj) {
 			return NOTHING;
 		}
 	};
 
 	private static final RtnConverter RTN_SAME = new RtnConverter() {
-		@Override public Object convert(LuanState luan,Object obj) {
+		@Override public Object convert(Luan luan,Object obj) {
 			return obj;
 		}
 	};
 
 	private static final RtnConverter RTN_ARRAY = new RtnConverter() {
-		@Override public Object convert(LuanState luan,Object obj) {
+		@Override public Object convert(Luan luan,Object obj) {
 			if( obj == null )
 				return null;
 			Object[] a = new Object[Array.getLength(obj)];
@@ -227,11 +227,11 @@
 	}
 
 	private interface ArgConverter {
-		public Object convert(LuanState luan,Object obj) throws LuanException;
+		public Object convert(Luan luan,Object obj) throws LuanException;
 	}
 
 	private static final ArgConverter ARG_SAME = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			return obj;
 		}
 		@Override public String toString() {
@@ -240,7 +240,7 @@
 	};
 
 	private static final ArgConverter ARG_DOUBLE = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof Double )
 				return obj;
 			if( obj instanceof Number ) {
@@ -255,7 +255,7 @@
 	};
 
 	private static final ArgConverter ARG_FLOAT = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof Float )
 				return obj;
 			if( obj instanceof Number ) {
@@ -270,7 +270,7 @@
 	};
 
 	private static final ArgConverter ARG_LONG = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof Long )
 				return obj;
 			if( obj instanceof Number ) {
@@ -287,7 +287,7 @@
 	};
 
 	private static final ArgConverter ARG_INTEGER = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof Integer )
 				return obj;
 			if( obj instanceof Number ) {
@@ -304,7 +304,7 @@
 	};
 
 	private static final ArgConverter ARG_SHORT = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof Short )
 				return obj;
 			if( obj instanceof Number ) {
@@ -321,7 +321,7 @@
 	};
 
 	private static final ArgConverter ARG_BYTE = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof Byte )
 				return obj;
 			if( obj instanceof Number ) {
@@ -338,7 +338,7 @@
 	};
 
 	private static final ArgConverter ARG_TABLE = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			LuanTable tbl = luan.toTable(obj);
 			return tbl!=null ? tbl : obj;
 		}
@@ -348,7 +348,7 @@
 	};
 
 	private static final ArgConverter ARG_MAP = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) throws LuanException {
+		public Object convert(Luan luan,Object obj) throws LuanException {
 			if( obj instanceof LuanTable ) {
 				LuanTable t = (LuanTable)obj;
 				return t.asMap();
@@ -361,7 +361,7 @@
 	};
 
 	private static final ArgConverter ARG_LIST = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof LuanTable ) {
 				LuanTable t = (LuanTable)obj;
 				if( t.isList() )
@@ -375,7 +375,7 @@
 	};
 
 	private static final ArgConverter ARG_SET = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) throws LuanException {
+		public Object convert(Luan luan,Object obj) throws LuanException {
 			if( obj instanceof LuanTable ) {
 				LuanTable t = (LuanTable)obj;
 				if( t.isSet() )
@@ -389,7 +389,7 @@
 	};
 
 	private static final ArgConverter ARG_COLLECTION = new ArgConverter() {
-		public Object convert(LuanState luan,Object obj) throws LuanException {
+		public Object convert(Luan luan,Object obj) throws LuanException {
 			if( obj instanceof LuanTable ) {
 				LuanTable t = (LuanTable)obj;
 				if( t.isList() )
@@ -411,7 +411,7 @@
 			a = (Object[])Array.newInstance(cls.getComponentType(),0);
 		}
 
-		public Object convert(LuanState luan,Object obj) {
+		public Object convert(Luan luan,Object obj) {
 			if( obj instanceof LuanTable ) {
 				LuanTable t = (LuanTable)obj;
 				if( t.isList() ) {
@@ -426,7 +426,7 @@
 
 	private static boolean takesLuaState(JavaMethod m) {
 		Class[] paramTypes = m.getParameterTypes();
-		return paramTypes.length > 0 && paramTypes[0].equals(LuanState.class);
+		return paramTypes.length > 0 && paramTypes[0].equals(Luan.class);
 	}
 
 	private static ArgConverter[] getArgConverters(boolean takesLuaState,JavaMethod m) {