Simplified (and improved) name simplification.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5250 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -211,7 +211,7 @@ public class GenDObjectTask extends Task
|
||||
// if this field is an array, we need its component types
|
||||
if (ftype.isArray()) {
|
||||
Class<?> etype = ftype.getComponentType();
|
||||
ctx.put("elemtype", GenUtil.simpleName(etype, null));
|
||||
ctx.put("elemtype", GenUtil.simpleName(etype));
|
||||
ctx.put("wrapelem", GenUtil.boxArgument(etype, "value"));
|
||||
ctx.put("wrapoelem", GenUtil.boxArgument(etype, "ovalue"));
|
||||
}
|
||||
@@ -219,8 +219,7 @@ public class GenDObjectTask extends Task
|
||||
// if this field is a generic DSet, we need its bound type
|
||||
if (_dsclass.isAssignableFrom(ftype)) {
|
||||
Type t = f.getGenericType();
|
||||
// we need to walk up the heirarchy until we get to the
|
||||
// parameterized DSet
|
||||
// we need to walk up the heirarchy until we get to the parameterized DSet
|
||||
while (t instanceof Class<?>) {
|
||||
t = ((Class<?>)t).getGenericSuperclass();
|
||||
}
|
||||
@@ -228,8 +227,7 @@ public class GenDObjectTask extends Task
|
||||
ParameterizedType pt = (ParameterizedType)t;
|
||||
if (pt.getActualTypeArguments().length > 0) {
|
||||
ctx.put("etype", GenUtil.simpleName(
|
||||
(Class<?>)pt.getActualTypeArguments()[0],
|
||||
null));
|
||||
(Class<?>)pt.getActualTypeArguments()[0]));
|
||||
}
|
||||
} else {
|
||||
ctx.put("etype", "DSet.Entry");
|
||||
|
||||
@@ -103,7 +103,7 @@ public class GenServiceTask extends InvocationTask
|
||||
|
||||
public String getName ()
|
||||
{
|
||||
String name = GenUtil.simpleName(listener, null);
|
||||
String name = GenUtil.simpleName(listener);
|
||||
name = StringUtil.replace(name, "Listener", "");
|
||||
int didx = name.indexOf(".");
|
||||
return name.substring(didx+1);
|
||||
@@ -608,10 +608,8 @@ public class GenServiceTask extends InvocationTask
|
||||
Class[] args = m.getParameterTypes();
|
||||
for (int aa = 0; aa < args.length; aa++) {
|
||||
if (_ilistener.isAssignableFrom(args[aa]) &&
|
||||
GenUtil.simpleName(
|
||||
args[aa], null).startsWith(sname + ".")) {
|
||||
checkedAdd(listeners, new ServiceListener(
|
||||
service, args[aa]));
|
||||
GenUtil.simpleName(args[aa]).startsWith(sname + ".")) {
|
||||
checkedAdd(listeners, new ServiceListener(service, args[aa]));
|
||||
}
|
||||
}
|
||||
if (_verbose) {
|
||||
|
||||
@@ -110,28 +110,28 @@ public class GenUtil extends com.samskivert.util.GenUtil
|
||||
* "Unboxes" the supplied argument, ie. turning an <code>Integer</code> object into an
|
||||
* <code>int</code>.
|
||||
*/
|
||||
public static String unboxArgument (Class<?> clazz, Type type, String name)
|
||||
public static String unboxArgument (Type type, String name)
|
||||
{
|
||||
if (clazz == Boolean.TYPE) {
|
||||
if (Boolean.TYPE.equals(type)) {
|
||||
return "((Boolean)" + name + ").booleanValue()";
|
||||
} else if (clazz == Byte.TYPE) {
|
||||
} else if (Byte.TYPE.equals(type)) {
|
||||
return "((Byte)" + name + ").byteValue()";
|
||||
} else if (clazz == Character.TYPE) {
|
||||
} else if (Character.TYPE.equals(type)) {
|
||||
return "((Character)" + name + ").charValue()";
|
||||
} else if (clazz == Short.TYPE) {
|
||||
} else if (Short.TYPE.equals(type)) {
|
||||
return "((Short)" + name + ").shortValue()";
|
||||
} else if (clazz == Integer.TYPE) {
|
||||
} else if (Integer.TYPE.equals(type)) {
|
||||
return "((Integer)" + name + ").intValue()";
|
||||
} else if (clazz == Long.TYPE) {
|
||||
} else if (Long.TYPE.equals(type)) {
|
||||
return "((Long)" + name + ").longValue()";
|
||||
} else if (clazz == Float.TYPE) {
|
||||
} else if (Float.TYPE.equals(type)) {
|
||||
return "((Float)" + name + ").floatValue()";
|
||||
} else if (clazz == Double.TYPE) {
|
||||
} else if (Double.TYPE.equals(type)) {
|
||||
return "((Double)" + name + ").doubleValue()";
|
||||
} else if (clazz.equals(Object.class)) {
|
||||
} else if (Object.class.equals(type)) {
|
||||
return name; // no need to cast object
|
||||
} else {
|
||||
return "(" + simpleName(clazz, type) + ")" + name;
|
||||
return "(" + simpleName(type) + ")" + name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,16 +188,16 @@ public class GenUtil extends com.samskivert.util.GenUtil
|
||||
/**
|
||||
* Potentially clones the supplied argument if it is the type that needs such treatment.
|
||||
*/
|
||||
public static String cloneArgument (Class<?> dsclazz, Field f, String name)
|
||||
public static String cloneArgument (Class<?> dsclazz, Field field, String name)
|
||||
{
|
||||
Class<?> clazz = f.getType();
|
||||
Class<?> clazz = field.getType();
|
||||
if (dsclazz.equals(clazz)) {
|
||||
return "(" + name + " == null) ? null : " + name + ".typedClone()";
|
||||
} else if (clazz.isArray()) {
|
||||
return "(" + name + " == null) ? null : " + name + ".clone()";
|
||||
} else if (dsclazz.isAssignableFrom(clazz)) {
|
||||
return "(" + name + " == null) ? null : " +
|
||||
"(" + simpleName(f) + ")" + name + ".clone()";
|
||||
"(" + simpleName(field) + ")" + name + ".clone()";
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class InvocationTask extends Task
|
||||
|
||||
public String getMarshaller ()
|
||||
{
|
||||
String name = GenUtil.simpleName(listener, null);
|
||||
String name = GenUtil.simpleName(listener);
|
||||
// handle ye olde special case
|
||||
if (name.equals("InvocationService.InvocationListener")) {
|
||||
return "ListenerMarshaller";
|
||||
@@ -147,13 +147,12 @@ public abstract class InvocationTask extends Task
|
||||
public String getArgList (boolean skipFirst)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Class<?>[] args = method.getParameterTypes();
|
||||
Type[] ptypes = method.getGenericParameterTypes();
|
||||
for (int ii = skipFirst ? 1 : 0; ii < args.length; ii++) {
|
||||
for (int ii = skipFirst ? 1 : 0; ii < ptypes.length; ii++) {
|
||||
if (buf.length() > 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
buf.append(GenUtil.simpleName(args[ii], ptypes[ii]));
|
||||
buf.append(GenUtil.simpleName(ptypes[ii]));
|
||||
buf.append(" arg").append(skipFirst ? ii : ii+1);
|
||||
}
|
||||
return buf.toString();
|
||||
@@ -218,14 +217,12 @@ public abstract class InvocationTask extends Task
|
||||
public String getUnwrappedArgList (boolean listenerMode)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Class<?>[] args = method.getParameterTypes();
|
||||
Type[] ptypes = method.getGenericParameterTypes();
|
||||
for (int ii = (listenerMode ? 0 : 1); ii < args.length; ii++) {
|
||||
for (int ii = (listenerMode ? 0 : 1); ii < ptypes.length; ii++) {
|
||||
if (buf.length() > 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
buf.append(unboxArgument(args[ii], ptypes[ii],
|
||||
listenerMode ? ii : ii-1, listenerMode));
|
||||
buf.append(unboxArgument(ptypes[ii], listenerMode ? ii : ii-1, listenerMode));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
@@ -274,14 +271,13 @@ public abstract class InvocationTask extends Task
|
||||
}
|
||||
}
|
||||
|
||||
protected String unboxArgument (
|
||||
Class<?> clazz, Type type, int index, boolean listenerMode)
|
||||
protected String unboxArgument (Type type, int index, boolean listenerMode)
|
||||
{
|
||||
if (listenerMode && _ilistener.isAssignableFrom(clazz)) {
|
||||
if (listenerMode && (type instanceof Class) &&
|
||||
_ilistener.isAssignableFrom((Class)type)) {
|
||||
return "listener" + index;
|
||||
} else {
|
||||
return GenUtil.unboxArgument(
|
||||
clazz, type, "args[" + index + "]");
|
||||
return GenUtil.unboxArgument(type, "args[" + index + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user