Added support for streaming List and ArrayList natively. A List will be

unmarshalled into an ArrayList on the receiver. Along the way, I improved
support for generic types as arguments to invocation services (which required
one unfortunate "sweeping" warning suppression, but since this is in generated
code, I think we can be sure it won't be doing anything untoward).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4375 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-09-19 00:31:50 +00:00
parent 036271438a
commit afad7dd444
15 changed files with 271 additions and 131 deletions
@@ -8,6 +8,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
@@ -54,7 +55,7 @@ public abstract class InvocationTask extends Task
public String getMarshaller ()
{
String name = GenUtil.simpleName(listener);
String name = GenUtil.simpleName(listener, null);
// handle ye olde special case
if (name.equals("InvocationService.InvocationListener")) {
return "ListenerMarshaller";
@@ -106,7 +107,8 @@ public abstract class InvocationTask extends Task
// InvocationService listeners, we need to import its
// marshaller as well
if (_ilistener.isAssignableFrom(arg) &&
!GenUtil.simpleName(arg).startsWith("InvocationService")) {
!GenUtil.simpleName(
arg, null).startsWith("InvocationService")) {
String mname = arg.getName();
mname = StringUtil.replace(mname, "Service", "Marshaller");
mname = StringUtil.replace(mname, "Listener", "Marshaller");
@@ -135,11 +137,12 @@ public abstract class InvocationTask extends Task
{
StringBuilder buf = new StringBuilder();
Class<?>[] args = method.getParameterTypes();
Type[] ptypes = method.getGenericParameterTypes();
for (int ii = skipFirst ? 1 : 0; ii < args.length; ii++) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(GenUtil.simpleName(args[ii]));
buf.append(GenUtil.simpleName(args[ii], ptypes[ii]));
buf.append(" arg").append(skipFirst ? ii : ii+1);
}
return buf.toString();
@@ -172,12 +175,13 @@ public abstract class InvocationTask extends Task
{
StringBuilder buf = new StringBuilder();
Class<?>[] args = method.getParameterTypes();
Type[] ptypes = method.getGenericParameterTypes();
for (int ii = (listenerMode ? 0 : 1); ii < args.length; ii++) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(unboxArgument(args[ii], listenerMode ? ii : ii-1,
listenerMode));
buf.append(unboxArgument(args[ii], ptypes[ii],
listenerMode ? ii : ii-1, listenerMode));
}
return buf.toString();
}
@@ -192,12 +196,13 @@ public abstract class InvocationTask extends Task
}
protected String unboxArgument (
Class<?> clazz, int index, boolean listenerMode)
Class<?> clazz, Type type, int index, boolean listenerMode)
{
if (listenerMode && _ilistener.isAssignableFrom(clazz)) {
return "listener" + index;
} else {
return GenUtil.unboxArgument(clazz, "args[" + index + "]");
return GenUtil.unboxArgument(
clazz, type, "args[" + index + "]");
}
}
}