We're getting very close to having generated ActionScript Service and Listener

interfaces, and Marshallers for same. The remaining snag has to do with the
annoyance of ActionScript not supporting inner classes, which means that
ChatService.TellListener for example has to become ChatService_TellListener.

The code for generating the Java marshaller knows to add an import for
ChatService if some random invocation service interface happens to reference
ChatService.TellListener, but now it needs to be made to know to add an import
for ChatService_TellListener in ActionScript land and it has to do it in a way
that doesn't fuck up the Java code generation. Whee!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4397 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-10-04 18:12:56 +00:00
parent 3305c1b922
commit d25d5e53f1
8 changed files with 421 additions and 24 deletions
@@ -63,6 +63,11 @@ public abstract class InvocationTask extends Task
name = StringUtil.replace(name, "Service", "Marshaller");
return StringUtil.replace(name, "Listener", "Marshaller");
}
public String getActionScriptMarshaller ()
{
return getMarshaller().replace(".", "_");
}
}
/** Used to keep track of invocation service methods. */
@@ -106,9 +111,9 @@ public abstract class InvocationTask extends Task
// if it's a listener and not one of the special
// InvocationService listeners, we need to import its
// marshaller as well
String sname = GenUtil.simpleName(arg, null);
if (_ilistener.isAssignableFrom(arg) &&
!GenUtil.simpleName(
arg, null).startsWith("InvocationService")) {
!sname.startsWith("InvocationService")) {
String mname = arg.getName();
mname = StringUtil.replace(mname, "Service", "Marshaller");
mname = StringUtil.replace(mname, "Listener", "Marshaller");
@@ -148,6 +153,20 @@ public abstract class InvocationTask extends Task
return buf.toString();
}
public String getASArgList (boolean skipFirst)
{
StringBuilder buf = new StringBuilder();
Class<?>[] args = method.getParameterTypes();
for (int ii = skipFirst ? 1 : 0; ii < args.length; ii++) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append("arg").append(skipFirst ? ii : ii+1).append(" :");
buf.append(GenUtil.simpleASName(args[ii]));
}
return buf.toString();
}
public String getWrappedArgList (boolean skipFirst)
{
StringBuilder buf = new StringBuilder();
@@ -161,6 +180,25 @@ public abstract class InvocationTask extends Task
return buf.toString();
}
public String getASWrappedArgList (boolean skipFirst)
{
StringBuilder buf = new StringBuilder();
Class<?>[] args = method.getParameterTypes();
for (int ii = (skipFirst ? 1 : 0); ii < args.length; ii++) {
if (buf.length() > 0) {
buf.append(", ");
}
String arg;
if (_ilistener.isAssignableFrom(args[ii])) {
arg = GenUtil.boxASArgument(args[ii], "listener" + (ii+1));
} else {
arg = GenUtil.boxASArgument(args[ii], "arg" + (ii+1));
}
buf.append(arg);
}
return buf.toString();
}
public boolean hasArgs (boolean skipFirst)
{
return (method.getParameterTypes().length > (skipFirst ? 1 : 0));
@@ -186,6 +224,28 @@ public abstract class InvocationTask extends Task
return buf.toString();
}
public String getASUnwrappedArgList (boolean listenerMode)
{
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(", ");
}
String arg;
int argidx = listenerMode ? ii : ii-1;
if (listenerMode && _ilistener.isAssignableFrom(args[ii])) {
arg = "listener" + argidx;
} else {
arg = GenUtil.unboxASArgument(
args[ii], "args[" + argidx + "]");
}
buf.append(arg);
}
return buf.toString();
}
protected String boxArgument (Class<?> clazz, int index)
{
if (_ilistener.isAssignableFrom(clazz)) {