Add Hashable for classes that override hashCode(); strip out *Codes interfaces

because we can't do that in ActionScript; properly handle static var and
non-static const.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4404 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-10-04 21:25:16 +00:00
parent 874d8eaa8f
commit ed51df0807
@@ -149,13 +149,14 @@ public class ActionScriptSource
builder.append("private "); builder.append("private ");
} }
// are we static const or variable? // are we static?
if (Modifier.isStatic(mods)) { if (Modifier.isStatic(mods)) {
builder.append("static const "); builder.append("static ");
} else {
builder.append("var ");
} }
// const or variable?
builder.append(Modifier.isFinal(mods) ? "const " : "var ");
// next comes the name // next comes the name
builder.append(field.getName()).append(" :"); builder.append(field.getName()).append(" :");
@@ -300,9 +301,13 @@ public class ActionScriptSource
// note our implemented interfaces // note our implemented interfaces
ArrayList<String> ifaces = new ArrayList<String>(); ArrayList<String> ifaces = new ArrayList<String>();
for (Class iclass : jclass.getInterfaces()) { for (Class iclass : jclass.getInterfaces()) {
// we cannot use the FooCodes interface pattern in ActionScript so
// we just have to nix it
if (iclass.getName().endsWith("Codes")) {
continue;
}
ifaces.add(toSimpleName(iclass.getName())); ifaces.add(toSimpleName(iclass.getName()));
} }
implementedInterfaces = ifaces.toArray(new String[ifaces.size()]);
// convert the field members // convert the field members
for (Field field : jclass.getDeclaredFields()) { for (Field field : jclass.getDeclaredFields()) {
@@ -367,6 +372,14 @@ public class ActionScriptSource
mem.definition = decl; mem.definition = decl;
} }
} }
// if we override hashCode() then add Hashable to our interfaces
if (getMember(publicMethods, "hashCode") != null) {
ifaces.add("Hashable");
}
// finally turn our implemented interfaces into an array
implementedInterfaces = ifaces.toArray(new String[ifaces.size()]);
} }
public void absorbJava (File jsource) public void absorbJava (File jsource)