changeset 434:472fc70853cd

remove more generics
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 May 2015 16:21:25 -0600
parents c6bcb8859b93
children 5b36f663a1b8
files core/src/luan/LuanJavaFunction.java core/src/luan/LuanTable.java
diffstat 2 files changed, 33 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/LuanJavaFunction.java	Sun May 03 15:45:39 2015 -0600
+++ b/core/src/luan/LuanJavaFunction.java	Sun May 03 16:21:25 2015 -0600
@@ -19,7 +19,7 @@
 	private final RtnConverter rtnConverter;
 	private final boolean takesLuaState;
 	private final ArgConverter[] argConverters;
-	private final Class<?> varArgCls;
+	private final Class varArgCls;
 
 	public LuanJavaFunction(Method method,Object obj) {
 		this( JavaMethod.of(method), obj );
@@ -36,7 +36,7 @@
 		this.takesLuaState = takesLuaState(method);
 		this.argConverters = getArgConverters(takesLuaState,method);
 		if( method.isVarArgs() ) {
-			Class<?>[] paramTypes = method.getParameterTypes();
+			Class[] paramTypes = method.getParameterTypes();
 			this.varArgCls = paramTypes[paramTypes.length-1].getComponentType();
 		} else {
 			this.varArgCls = null;
@@ -63,7 +63,7 @@
 		return "java-function: " + method;
 	}
 
-	public Class<?>[] getParameterTypes() {
+	public Class[] getParameterTypes() {
 		return method.getParameterTypes();
 	}
 
@@ -103,7 +103,7 @@
 		return rtnConverter.convert(rtn);
 	}
 
-	private static final Map<Class,Class> primitiveMap = new HashMap<Class,Class>();
+	private static final Map primitiveMap = new HashMap();
 	static {
 		primitiveMap.put(Boolean.TYPE,Boolean.class);
 		primitiveMap.put(Character.TYPE,Character.class);
@@ -117,13 +117,13 @@
 	}
 
 	private void checkArgs(LuanState luan,Object[] args) throws LuanException {
-		Class<?>[] a = getParameterTypes();
+		Class[] a = getParameterTypes();
 		int start = takesLuaState ? 1 : 0;
 		for( int i=start; i<a.length; i++ ) {
-			Class<?> paramType = a[i];
-			Class<?> type = paramType;
+			Class paramType = a[i];
+			Class type = paramType;
 			if( type.isPrimitive() )
-				type = primitiveMap.get(type);
+				type = (Class)primitiveMap.get(type);
 			Object arg = args[i];
 			if( !type.isInstance(arg) ) {
 				String expected = paramType.getSimpleName();
@@ -206,7 +206,7 @@
 	};
 
 	private static RtnConverter getRtnConverter(JavaMethod m) {
-		Class<?> rtnType = m.getReturnType();
+		Class rtnType = m.getReturnType();
 		if( rtnType == Void.TYPE )
 			return RTN_NOTHING;
 		if( !m.isLuan() && rtnType.isArray() && !rtnType.getComponentType().isPrimitive() ) {
@@ -216,7 +216,7 @@
 		return RTN_SAME;
 	}
 
-	private static boolean isNumber(Class<?> rtnType) {
+	private static boolean isNumber(Class rtnType) {
 		return rtnType == Short.TYPE
 			|| rtnType == Integer.TYPE
 			|| rtnType == Long.TYPE
@@ -395,19 +395,13 @@
 			if( obj == null )
 				return null;
 			if( obj instanceof List ) {
-				@SuppressWarnings("unchecked")
-				List<Object> list = (List<Object>)obj;
-				return new LuanTable(list);
+				return new LuanTable((List)obj);
 			}
 			if( obj instanceof Map ) {
-				@SuppressWarnings("unchecked")
-				Map<Object,Object> map = (Map<Object,Object>)obj;
-				return new LuanTable(map);
+				return new LuanTable((Map)obj);
 			}
 			if( obj instanceof Set ) {
-				@SuppressWarnings("unchecked")
-				Set<Object> set = (Set<Object>)obj;
-				return new LuanTable(set);
+				return new LuanTable((Set)obj);
 			}
 			Class cls = obj.getClass();
 			if( cls.isArray() && !cls.getComponentType().isPrimitive() ) {
@@ -499,21 +493,21 @@
 	}
 
 	private static boolean takesLuaState(JavaMethod m) {
-		Class<?>[] paramTypes = m.getParameterTypes();
+		Class[] paramTypes = m.getParameterTypes();
 		return paramTypes.length > 0 && paramTypes[0].equals(LuanState.class);
 	}
 
 	private static ArgConverter[] getArgConverters(boolean takesLuaState,JavaMethod m) {
 		final boolean isVarArgs = m.isVarArgs();
-		Class<?>[] paramTypes = m.getParameterTypes();
+		Class[] paramTypes = m.getParameterTypes();
 		if( takesLuaState ) {
-			Class<?>[] t = new Class<?>[paramTypes.length-1];
+			Class[] t = new Class[paramTypes.length-1];
 			System.arraycopy(paramTypes,1,t,0,t.length);
 			paramTypes = t;
 		}
 		ArgConverter[] a = new ArgConverter[paramTypes.length];
 		for( int i=0; i<a.length; i++ ) {
-			Class<?> paramType = paramTypes[i];
+			Class paramType = paramTypes[i];
 			if( isVarArgs && i == a.length-1 )
 				paramType = paramType.getComponentType();
 			a[i] = getArgConverter(paramType);
@@ -521,7 +515,7 @@
 		return a;
 	}
 
-	private static ArgConverter getArgConverter(Class<?> cls) {
+	private static ArgConverter getArgConverter(Class cls) {
 		if( cls == Boolean.TYPE )
 			return ARG_BOOLEAN;
 		if( cls.equals(Boolean.class) )
@@ -557,10 +551,10 @@
 
 	private static abstract class JavaMethod {
 		abstract boolean isVarArgs();
-		abstract Class<?>[] getParameterTypes();
+		abstract Class[] getParameterTypes();
 		abstract Object invoke(Object obj,Object... args)
 			throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException;
-		abstract Class<?> getReturnType();
+		abstract Class getReturnType();
 		abstract boolean isLuan();
 	
 		static JavaMethod of(final Method m) {
@@ -568,7 +562,7 @@
 				@Override boolean isVarArgs() {
 					return m.isVarArgs();
 				}
-				@Override Class<?>[] getParameterTypes() {
+				@Override Class[] getParameterTypes() {
 					return m.getParameterTypes();
 				}
 				@Override Object invoke(Object obj,Object... args)
@@ -576,7 +570,7 @@
 				{
 					return m.invoke(obj,args);
 				}
-				@Override Class<?> getReturnType() {
+				@Override Class getReturnType() {
 					return m.getReturnType();
 				}
 				@Override boolean isLuan() {
@@ -593,7 +587,7 @@
 				@Override boolean isVarArgs() {
 					return c.isVarArgs();
 				}
-				@Override Class<?>[] getParameterTypes() {
+				@Override Class[] getParameterTypes() {
 					return c.getParameterTypes();
 				}
 				@Override Object invoke(Object obj,Object... args)
@@ -601,7 +595,7 @@
 				{
 					return c.newInstance(args);
 				}
-				@Override Class<?> getReturnType() {
+				@Override Class getReturnType() {
 					return c.getDeclaringClass();
 				}
 				@Override boolean isLuan() {
--- a/core/src/luan/LuanTable.java	Sun May 03 15:45:39 2015 -0600
+++ b/core/src/luan/LuanTable.java	Sun May 03 16:21:25 2015 -0600
@@ -16,14 +16,14 @@
 
 
 public final class LuanTable implements DeepCloneable {
-	private Map<Object,Object> map = null;
-	private List<Object> list = null;
+	private Map map = null;
+	private List list = null;
 	private LuanTable metatable = null;
 	private boolean hasJava = false;
 
 	public LuanTable() {}
 
-	public LuanTable(List<Object> list) {
+	public LuanTable(List list) {
 		int n = list.size();
 		for( int i=0; i<n; i++ ) {
 			Object val = list.get(i);
@@ -32,8 +32,9 @@
 		}
 	}
 
-	public LuanTable(Map<Object,Object> map) {
-		for( Map.Entry<Object,Object> entry : map.entrySet() ) {
+	public LuanTable(Map map) {
+		for( Object stupid : map.entrySet() ) {
+			Map.Entry entry = (Map.Entry)stupid;
 			Object key = entry.getKey();
 			Object value = entry.getValue();
 			if( key != null && value != null )
@@ -41,7 +42,7 @@
 		}
 	}
 
-	public LuanTable(Set<Object> set) {
+	public LuanTable(Set set) {
 		for( Object el : set ) {
 			if( el != null )
 				rawPut(el,Boolean.TRUE);
@@ -64,7 +65,8 @@
 		LuanTable clone = (LuanTable)dc;
 		if( map != null ) {
 			clone.map = newMap();
-			for( Map.Entry<Object,Object> entry : map.entrySet() ) {
+			for( Object stupid : map.entrySet() ) {
+				Map.Entry entry = (Map.Entry)stupid;
 				clone.map.put( cloner.get(entry.getKey()), cloner.get(entry.getValue()) );
 			}
 		}