Reluctantly back out 6484. It wasn't quite that simple. The problem appears to be that the AS3 the templates actually end up generating depends on the original sussed-out Java types in sometimes non-obvious ways; for example, parameter types collapse bytes, characters, shorts and ints to a mere 'int', without us really being able know in advance, so we will be generating superfluous e.g. util.Byte imports. A more elegant solution might be to construct Java imports and AS imports side by side in the earlier phases.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6485 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -308,7 +308,13 @@ public class GenServiceTask extends InvocationTask
|
||||
// replace inner classes with action script equivalents
|
||||
imports.translateInnerClasses();
|
||||
|
||||
translateImportsToActionScript(imports);
|
||||
// replace primitive types with OOO types (required for unboxing)
|
||||
imports.replace("byte", "com.threerings.util.Byte");
|
||||
imports.replace("int", "com.threerings.util.Integer");
|
||||
imports.replace("boolean", "com.threerings.util.langBoolean");
|
||||
imports.replace("[B", "flash.utils.ByteArray");
|
||||
imports.replace("float", "com.threerings.util.Float");
|
||||
imports.replace("[I", "com.threerings.io.TypedArray");
|
||||
|
||||
// ye olde special case - any method that uses a default listener
|
||||
// causes the need for the default listener marshaller
|
||||
@@ -325,6 +331,9 @@ public class GenServiceTask extends InvocationTask
|
||||
".client.", ".data.");
|
||||
imports.popIn();
|
||||
|
||||
// convert java primitive types to ooo util types
|
||||
imports.replace(Integer.class, "com.threerings.util.Integer");
|
||||
|
||||
// get rid of java.lang stuff and any remaining primitives
|
||||
imports.removeGlobals();
|
||||
|
||||
@@ -367,7 +376,13 @@ public class GenServiceTask extends InvocationTask
|
||||
// replace '$' with '_' for action script naming convention
|
||||
imports.translateInnerClasses();
|
||||
|
||||
translateImportsToActionScript(imports);
|
||||
// convert primitive java types to ooo util types
|
||||
imports.replace("long", "com.threerings.util.Long");
|
||||
|
||||
// convert object arrays to typed arrays
|
||||
if (imports.removeAll("[L*") > 0) {
|
||||
imports.add("com.threerings.io.TypedArray");
|
||||
}
|
||||
|
||||
// get rid of remaining primitives and java.lang types
|
||||
imports.removeGlobals();
|
||||
@@ -394,7 +409,16 @@ public class GenServiceTask extends InvocationTask
|
||||
imports.add(Client.class);
|
||||
imports.add(InvocationService.class);
|
||||
|
||||
translateImportsToActionScript(imports);
|
||||
// allow primitive types in service methods
|
||||
imports.replace("[B", "flash.utils.ByteArray");
|
||||
imports.replace("[I", "com.threerings.io.TypedArray");
|
||||
|
||||
// convert java primitive types to ooo util types
|
||||
imports.replace("java.lang.Integer", "com.threerings.util.Integer");
|
||||
|
||||
if (imports.removeAll("[L*") > 0) {
|
||||
imports.add("com.threerings.io.TypedArray");
|
||||
}
|
||||
|
||||
// get rid of primitives and java.lang classes
|
||||
imports.removeGlobals();
|
||||
@@ -435,8 +459,13 @@ public class GenServiceTask extends InvocationTask
|
||||
// change Foo$Bar to Foo_Bar
|
||||
imports.translateInnerClasses();
|
||||
|
||||
// convert Java type names to ActionScript ones
|
||||
translateImportsToActionScript(imports);
|
||||
// use a typed array for any arrays of objects
|
||||
if (imports.removeAll("[L*") > 0) {
|
||||
imports.add("com.threerings.io.TypedArray");
|
||||
}
|
||||
|
||||
// convert java primitive types to ooo util types
|
||||
imports.replace("long", "com.threerings.util.Long");
|
||||
|
||||
// get rid of remaining primitives and java.lang types
|
||||
imports.removeGlobals();
|
||||
@@ -580,31 +609,6 @@ public class GenServiceTask extends InvocationTask
|
||||
"Derived from " + name + "Service.java.");
|
||||
}
|
||||
|
||||
protected static void translateImportsToActionScript (ImportSet imports)
|
||||
{
|
||||
// convert java primitive types to ooo util types
|
||||
imports.replace("boolean", "com.threerings.util.langBoolean");
|
||||
imports.replace(Boolean.class, "com.threerings.util.langBoolean");
|
||||
|
||||
imports.replace("float", "com.threerings.util.Float");
|
||||
imports.replace(Float.class, "com.threerings.util.Float");
|
||||
|
||||
imports.replace("byte", "com.threerings.util.Byte");
|
||||
imports.replace(Byte.class, "com.threerings.util.Byte");
|
||||
|
||||
imports.replace("long", "com.threerings.util.Long");
|
||||
imports.replace(Long.class, "com.threerings.util.Long");
|
||||
|
||||
imports.replace("int", "com.threerings.util.Integer");
|
||||
imports.replace(Integer.class, "com.threerings.util.Integer");
|
||||
|
||||
imports.replace("[B", "flash.utils.ByteArray");
|
||||
|
||||
if (imports.removeAll("[*") > 0) {
|
||||
imports.add("com.threerings.io.TypedArray");
|
||||
}
|
||||
}
|
||||
|
||||
/** Rolls up everything needed for the generate* methods. */
|
||||
protected class ServiceDescription
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user