Further improvements to the Java to ActionScript converter.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4499 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-01-06 03:31:31 +00:00
parent 84e21d0125
commit af7e3ca5ae
2 changed files with 22 additions and 0 deletions
@@ -278,6 +278,11 @@ public class ActionScriptSource
return "int";
}
if (Float.TYPE.equals(type) ||
Double.TYPE.equals(type)) {
return "Number";
}
if (Long.TYPE.equals(type)) {
return "Long";
}
@@ -649,6 +654,7 @@ public class ActionScriptSource
Member curmem = null;
while ((line = bin.readLine()) != null) {
line = line.replaceAll("\\s+$", "");
// System.err.println(" " + mode + " : " + line);
switch (mode) {
case PREAMBLE:
// look for the package declaration
@@ -667,6 +673,10 @@ public class ActionScriptSource
imports = accum.toString();
accum.setLength(0);
mode = Mode.CLASSCOMMENT;
} else if (line.startsWith("public ")) {
imports = accum.toString();
accum.setLength(0);
mode = line.endsWith("{") ? Mode.CLASSBODY : Mode.CLASSDECL;
}
accum.append(line).append("\n");
break;
@@ -295,6 +295,12 @@ public class GenActionScriptTask extends Task
} else if (type.equals(Long.TYPE)) {
return "new Long(ins.readInt(), ins.readInt())";
} else if (type.equals(Float.TYPE)) {
return "ins.readFloat()";
} else if (type.equals(Double.TYPE)) {
return "ins.readDouble()";
} else if (type.isArray()) {
if (Byte.TYPE.equals(type.getComponentType())) {
return "(ins.readObject() as ByteArray)";
@@ -331,6 +337,12 @@ public class GenActionScriptTask extends Task
" out.writeInt(" +
name + " == null ? 0 : " + name + ".high)";
} else if (type.equals("float")) {
return "writeFloat(" + name + ")";
} else if (type.equals("double")) {
return "writeDouble(" + name + ")";
} else if (type.equals("java.lang.String")) {
return "writeField(" + name + ")";