1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Sat Jan 26 08:47:05 2013 +0100
1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Sun Feb 03 18:58:09 2013 +0100
1.3 @@ -1605,7 +1605,7 @@
1.4 final String jvmType = "Lorg/apidesign/bck2brwsr/core/JavaScriptBody;";
1.5 class P extends AnnotationParser {
1.6 public P() {
1.7 - super(false);
1.8 + super(false, true);
1.9 }
1.10
1.11 int cnt;
1.12 @@ -1661,7 +1661,7 @@
1.13 final String[] values = new String[attrNames.length];
1.14 final boolean[] found = { false };
1.15 final String jvmType = "L" + className.replace('.', '/') + ";";
1.16 - AnnotationParser ap = new AnnotationParser(false) {
1.17 + AnnotationParser ap = new AnnotationParser(false, true) {
1.18 @Override
1.19 protected void visitAttr(String type, String attr, String at, String value) {
1.20 if (type.equals(jvmType)) {
1.21 @@ -1699,34 +1699,54 @@
1.22 }
1.23
1.24 private static void generateAnno(ClassData cd, final Appendable out, byte[] data) throws IOException {
1.25 - AnnotationParser ap = new AnnotationParser(true) {
1.26 - int anno;
1.27 - int cnt;
1.28 + AnnotationParser ap = new AnnotationParser(true, false) {
1.29 + int[] cnt = new int[32];
1.30 + int depth;
1.31
1.32 @Override
1.33 protected void visitAnnotationStart(String type) throws IOException {
1.34 - if (anno++ > 0) {
1.35 + if (cnt[depth]++ > 0) {
1.36 out.append(",");
1.37 }
1.38 out.append('"').append(type).append("\" : {\n");
1.39 - cnt = 0;
1.40 + cnt[++depth] = 0;
1.41 }
1.42
1.43 @Override
1.44 protected void visitAnnotationEnd(String type) throws IOException {
1.45 out.append("\n}\n");
1.46 + depth--;
1.47 + }
1.48 +
1.49 + @Override
1.50 + protected void visitValueStart(String attrName, char type) throws IOException {
1.51 + if (cnt[depth]++ > 0) {
1.52 + out.append(",\n");
1.53 + }
1.54 + cnt[++depth] = 0;
1.55 + if (attrName != null) {
1.56 + out.append(attrName).append(" : ");
1.57 + }
1.58 + if (type == '[') {
1.59 + out.append("[");
1.60 + }
1.61 + }
1.62 +
1.63 + @Override
1.64 + protected void visitValueEnd(String attrName, char type) throws IOException {
1.65 + if (type == '[') {
1.66 + out.append("]");
1.67 + }
1.68 + depth--;
1.69 }
1.70
1.71 @Override
1.72 protected void visitAttr(String type, String attr, String attrType, String value)
1.73 throws IOException {
1.74 - if (attr == null) {
1.75 + if (attr == null && value == null) {
1.76 return;
1.77 }
1.78 - if (cnt++ > 0) {
1.79 - out.append(",\n");
1.80 - }
1.81 - out.append(attr).append("__").append(attrType).append(" : ").append(value);
1.82 + out.append(value);
1.83 }
1.84 };
1.85 ap.parse(data, cd);