rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java
changeset 1239 b6317079abe1
parent 1022 00ae3f46e54f
child 1241 30a49f14dfc5
     1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Fri Apr 26 13:35:21 2013 +0200
     1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Tue Jul 09 21:06:35 2013 +0200
     1.3 @@ -96,16 +96,34 @@
     1.4              );
     1.5          }
     1.6          byte[] arrData = jc.findAnnotationData(true);
     1.7 -        String[] arr = findAnnotation(arrData, jc, 
     1.8 -            "org.apidesign.bck2brwsr.core.ExtraJavaScript", 
     1.9 -            "resource", "processByteCode"
    1.10 -        );
    1.11 -        if (arr != null) {
    1.12 -            if (!arr[0].isEmpty()) {
    1.13 -                requireScript(arr[0]);
    1.14 +        {
    1.15 +            String[] arr = findAnnotation(arrData, jc, 
    1.16 +                "org.apidesign.bck2brwsr.core.ExtraJavaScript", 
    1.17 +                "resource", "processByteCode"
    1.18 +            );
    1.19 +            if (arr != null) {
    1.20 +                if (!arr[0].isEmpty()) {
    1.21 +                    requireScript(arr[0]);
    1.22 +                }
    1.23 +                if ("0".equals(arr[1])) {
    1.24 +                    return null;
    1.25 +                }
    1.26              }
    1.27 -            if ("0".equals(arr[1])) {
    1.28 -                return null;
    1.29 +        }
    1.30 +        {
    1.31 +            String[] arr = findAnnotation(arrData, jc, 
    1.32 +                "net.java.html.js.JavaScriptResource", 
    1.33 +                "value"
    1.34 +            );
    1.35 +            if (arr != null) {
    1.36 +                if (arr[0].startsWith("/")) {
    1.37 +                    requireScript(arr[0]);
    1.38 +                } else {
    1.39 +                    int last = jc.getClassName().lastIndexOf('/');
    1.40 +                    requireScript(
    1.41 +                        jc.getClassName().substring(0, last + 1).replace('.', '/') + arr[0]
    1.42 +                    );
    1.43 +                }
    1.44              }
    1.45          }
    1.46          String[] proto = findAnnotation(arrData, jc, 
    1.47 @@ -1575,6 +1593,7 @@
    1.48              return null;
    1.49          }
    1.50          final String jvmType = "Lorg/apidesign/bck2brwsr/core/JavaScriptBody;";
    1.51 +        final String htmlType = "Lnet/java/html/js/JavaScriptBody;";
    1.52          class P extends AnnotationParser {
    1.53              public P() {
    1.54                  super(false, true);
    1.55 @@ -1595,6 +1614,15 @@
    1.56                          throw new IllegalArgumentException(attr);
    1.57                      }
    1.58                  }
    1.59 +                if (type.equals(htmlType)) {
    1.60 +                    if ("body".equals(attr)) {
    1.61 +                        body = value;
    1.62 +                    } else if ("args".equals(attr)) {
    1.63 +                        args[cnt++] = value;
    1.64 +                    } else {
    1.65 +                        throw new IllegalArgumentException(attr);
    1.66 +                    }
    1.67 +                }
    1.68              }
    1.69          }
    1.70          P p = new P();