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 this field is an array, we need its component types
|
||||||
if (ftype.isArray()) {
|
if (ftype.isArray()) {
|
||||||
Class<?> etype = ftype.getComponentType();
|
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("wrapelem", GenUtil.boxArgument(etype, "value"));
|
||||||
ctx.put("wrapoelem", GenUtil.boxArgument(etype, "ovalue"));
|
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 this field is a generic DSet, we need its bound type
|
||||||
if (_dsclass.isAssignableFrom(ftype)) {
|
if (_dsclass.isAssignableFrom(ftype)) {
|
||||||
Type t = f.getGenericType();
|
Type t = f.getGenericType();
|
||||||
// we need to walk up the heirarchy until we get to the
|
// we need to walk up the heirarchy until we get to the parameterized DSet
|
||||||
// parameterized DSet
|
|
||||||
while (t instanceof Class<?>) {
|
while (t instanceof Class<?>) {
|
||||||
t = ((Class<?>)t).getGenericSuperclass();
|
t = ((Class<?>)t).getGenericSuperclass();
|
||||||
}
|
}
|
||||||
@@ -228,8 +227,7 @@ public class GenDObjectTask extends Task
|
|||||||
ParameterizedType pt = (ParameterizedType)t;
|
ParameterizedType pt = (ParameterizedType)t;
|
||||||
if (pt.getActualTypeArguments().length > 0) {
|
if (pt.getActualTypeArguments().length > 0) {
|
||||||
ctx.put("etype", GenUtil.simpleName(
|
ctx.put("etype", GenUtil.simpleName(
|
||||||
(Class<?>)pt.getActualTypeArguments()[0],
|
(Class<?>)pt.getActualTypeArguments()[0]));
|
||||||
null));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.put("etype", "DSet.Entry");
|
ctx.put("etype", "DSet.Entry");
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class GenServiceTask extends InvocationTask
|
|||||||
|
|
||||||
public String getName ()
|
public String getName ()
|
||||||
{
|
{
|
||||||
String name = GenUtil.simpleName(listener, null);
|
String name = GenUtil.simpleName(listener);
|
||||||
name = StringUtil.replace(name, "Listener", "");
|
name = StringUtil.replace(name, "Listener", "");
|
||||||
int didx = name.indexOf(".");
|
int didx = name.indexOf(".");
|
||||||
return name.substring(didx+1);
|
return name.substring(didx+1);
|
||||||
@@ -608,10 +608,8 @@ public class GenServiceTask extends InvocationTask
|
|||||||
Class[] args = m.getParameterTypes();
|
Class[] args = m.getParameterTypes();
|
||||||
for (int aa = 0; aa < args.length; aa++) {
|
for (int aa = 0; aa < args.length; aa++) {
|
||||||
if (_ilistener.isAssignableFrom(args[aa]) &&
|
if (_ilistener.isAssignableFrom(args[aa]) &&
|
||||||
GenUtil.simpleName(
|
GenUtil.simpleName(args[aa]).startsWith(sname + ".")) {
|
||||||
args[aa], null).startsWith(sname + ".")) {
|
checkedAdd(listeners, new ServiceListener(service, args[aa]));
|
||||||
checkedAdd(listeners, new ServiceListener(
|
|
||||||
service, args[aa]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_verbose) {
|
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
|
* "Unboxes" the supplied argument, ie. turning an <code>Integer</code> object into an
|
||||||
* <code>int</code>.
|
* <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()";
|
return "((Boolean)" + name + ").booleanValue()";
|
||||||
} else if (clazz == Byte.TYPE) {
|
} else if (Byte.TYPE.equals(type)) {
|
||||||
return "((Byte)" + name + ").byteValue()";
|
return "((Byte)" + name + ").byteValue()";
|
||||||
} else if (clazz == Character.TYPE) {
|
} else if (Character.TYPE.equals(type)) {
|
||||||
return "((Character)" + name + ").charValue()";
|
return "((Character)" + name + ").charValue()";
|
||||||
} else if (clazz == Short.TYPE) {
|
} else if (Short.TYPE.equals(type)) {
|
||||||
return "((Short)" + name + ").shortValue()";
|
return "((Short)" + name + ").shortValue()";
|
||||||
} else if (clazz == Integer.TYPE) {
|
} else if (Integer.TYPE.equals(type)) {
|
||||||
return "((Integer)" + name + ").intValue()";
|
return "((Integer)" + name + ").intValue()";
|
||||||
} else if (clazz == Long.TYPE) {
|
} else if (Long.TYPE.equals(type)) {
|
||||||
return "((Long)" + name + ").longValue()";
|
return "((Long)" + name + ").longValue()";
|
||||||
} else if (clazz == Float.TYPE) {
|
} else if (Float.TYPE.equals(type)) {
|
||||||
return "((Float)" + name + ").floatValue()";
|
return "((Float)" + name + ").floatValue()";
|
||||||
} else if (clazz == Double.TYPE) {
|
} else if (Double.TYPE.equals(type)) {
|
||||||
return "((Double)" + name + ").doubleValue()";
|
return "((Double)" + name + ").doubleValue()";
|
||||||
} else if (clazz.equals(Object.class)) {
|
} else if (Object.class.equals(type)) {
|
||||||
return name; // no need to cast object
|
return name; // no need to cast object
|
||||||
} else {
|
} 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.
|
* 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)) {
|
if (dsclazz.equals(clazz)) {
|
||||||
return "(" + name + " == null) ? null : " + name + ".typedClone()";
|
return "(" + name + " == null) ? null : " + name + ".typedClone()";
|
||||||
} else if (clazz.isArray()) {
|
} else if (clazz.isArray()) {
|
||||||
return "(" + name + " == null) ? null : " + name + ".clone()";
|
return "(" + name + " == null) ? null : " + name + ".clone()";
|
||||||
} else if (dsclazz.isAssignableFrom(clazz)) {
|
} else if (dsclazz.isAssignableFrom(clazz)) {
|
||||||
return "(" + name + " == null) ? null : " +
|
return "(" + name + " == null) ? null : " +
|
||||||
"(" + simpleName(f) + ")" + name + ".clone()";
|
"(" + simpleName(field) + ")" + name + ".clone()";
|
||||||
} else {
|
} else {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public abstract class InvocationTask extends Task
|
|||||||
|
|
||||||
public String getMarshaller ()
|
public String getMarshaller ()
|
||||||
{
|
{
|
||||||
String name = GenUtil.simpleName(listener, null);
|
String name = GenUtil.simpleName(listener);
|
||||||
// handle ye olde special case
|
// handle ye olde special case
|
||||||
if (name.equals("InvocationService.InvocationListener")) {
|
if (name.equals("InvocationService.InvocationListener")) {
|
||||||
return "ListenerMarshaller";
|
return "ListenerMarshaller";
|
||||||
@@ -147,13 +147,12 @@ public abstract class InvocationTask extends Task
|
|||||||
public String getArgList (boolean skipFirst)
|
public String getArgList (boolean skipFirst)
|
||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
Class<?>[] args = method.getParameterTypes();
|
|
||||||
Type[] ptypes = method.getGenericParameterTypes();
|
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) {
|
if (buf.length() > 0) {
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
}
|
}
|
||||||
buf.append(GenUtil.simpleName(args[ii], ptypes[ii]));
|
buf.append(GenUtil.simpleName(ptypes[ii]));
|
||||||
buf.append(" arg").append(skipFirst ? ii : ii+1);
|
buf.append(" arg").append(skipFirst ? ii : ii+1);
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
@@ -218,14 +217,12 @@ public abstract class InvocationTask extends Task
|
|||||||
public String getUnwrappedArgList (boolean listenerMode)
|
public String getUnwrappedArgList (boolean listenerMode)
|
||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
Class<?>[] args = method.getParameterTypes();
|
|
||||||
Type[] ptypes = method.getGenericParameterTypes();
|
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) {
|
if (buf.length() > 0) {
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
}
|
}
|
||||||
buf.append(unboxArgument(args[ii], ptypes[ii],
|
buf.append(unboxArgument(ptypes[ii], listenerMode ? ii : ii-1, listenerMode));
|
||||||
listenerMode ? ii : ii-1, listenerMode));
|
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
@@ -274,14 +271,13 @@ public abstract class InvocationTask extends Task
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String unboxArgument (
|
protected String unboxArgument (Type type, int index, boolean listenerMode)
|
||||||
Class<?> clazz, Type type, int index, boolean listenerMode)
|
|
||||||
{
|
{
|
||||||
if (listenerMode && _ilistener.isAssignableFrom(clazz)) {
|
if (listenerMode && (type instanceof Class) &&
|
||||||
|
_ilistener.isAssignableFrom((Class)type)) {
|
||||||
return "listener" + index;
|
return "listener" + index;
|
||||||
} else {
|
} else {
|
||||||
return GenUtil.unboxArgument(
|
return GenUtil.unboxArgument(type, "args[" + index + "]");
|
||||||
clazz, type, "args[" + index + "]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user