1.1 --- a/ko/pom.xml Fri Jun 28 16:10:26 2013 +0200
1.2 +++ b/ko/pom.xml Tue Jul 09 21:06:35 2013 +0200
1.3 @@ -11,9 +11,6 @@
1.4 <artifactId>bck2brwsr</artifactId>
1.5 <version>0.8-SNAPSHOT</version>
1.6 </parent>
1.7 - <properties>
1.8 - <net.java.html.version>0.4-SNAPSHOT</net.java.html.version>
1.9 - </properties>
1.10 <modules>
1.11 <module>archetype</module>
1.12 <module>archetype-test</module>
2.1 --- a/pom.xml Fri Jun 28 16:10:26 2013 +0200
2.2 +++ b/pom.xml Tue Jul 09 21:06:35 2013 +0200
2.3 @@ -15,6 +15,7 @@
2.4 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2.5 <netbeans.version>RELEASE73</netbeans.version>
2.6 <license>COPYING</license>
2.7 + <net.java.html.version>0.4-SNAPSHOT</net.java.html.version>
2.8 </properties>
2.9 <modules>
2.10 <module>dew</module>
3.1 --- a/rt/vm/pom.xml Fri Jun 28 16:10:26 2013 +0200
3.2 +++ b/rt/vm/pom.xml Tue Jul 09 21:06:35 2013 +0200
3.3 @@ -151,6 +151,12 @@
3.4 <artifactId>closure-compiler</artifactId>
3.5 <version>r2388</version>
3.6 <scope>compile</scope>
3.7 - </dependency>
3.8 + </dependency>
3.9 + <dependency>
3.10 + <groupId>org.apidesign.html</groupId>
3.11 + <artifactId>net.java.html.boot</artifactId>
3.12 + <scope>test</scope>
3.13 + <version>${net.java.html.version}</version>
3.14 + </dependency>
3.15 </dependencies>
3.16 </project>
4.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Jun 28 16:10:26 2013 +0200
4.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Jul 09 21:06:35 2013 +0200
4.3 @@ -96,16 +96,34 @@
4.4 );
4.5 }
4.6 byte[] arrData = jc.findAnnotationData(true);
4.7 - String[] arr = findAnnotation(arrData, jc,
4.8 - "org.apidesign.bck2brwsr.core.ExtraJavaScript",
4.9 - "resource", "processByteCode"
4.10 - );
4.11 - if (arr != null) {
4.12 - if (!arr[0].isEmpty()) {
4.13 - requireScript(arr[0]);
4.14 + {
4.15 + String[] arr = findAnnotation(arrData, jc,
4.16 + "org.apidesign.bck2brwsr.core.ExtraJavaScript",
4.17 + "resource", "processByteCode"
4.18 + );
4.19 + if (arr != null) {
4.20 + if (!arr[0].isEmpty()) {
4.21 + requireScript(arr[0]);
4.22 + }
4.23 + if ("0".equals(arr[1])) {
4.24 + return null;
4.25 + }
4.26 }
4.27 - if ("0".equals(arr[1])) {
4.28 - return null;
4.29 + }
4.30 + {
4.31 + String[] arr = findAnnotation(arrData, jc,
4.32 + "net.java.html.js.JavaScriptResource",
4.33 + "value"
4.34 + );
4.35 + if (arr != null) {
4.36 + if (arr[0].startsWith("/")) {
4.37 + requireScript(arr[0]);
4.38 + } else {
4.39 + int last = jc.getClassName().lastIndexOf('/');
4.40 + requireScript(
4.41 + jc.getClassName().substring(0, last + 1).replace('.', '/') + arr[0]
4.42 + );
4.43 + }
4.44 }
4.45 }
4.46 String[] proto = findAnnotation(arrData, jc,
4.47 @@ -1575,6 +1593,7 @@
4.48 return null;
4.49 }
4.50 final String jvmType = "Lorg/apidesign/bck2brwsr/core/JavaScriptBody;";
4.51 + final String htmlType = "Lnet/java/html/js/JavaScriptBody;";
4.52 class P extends AnnotationParser {
4.53 public P() {
4.54 super(false, true);
4.55 @@ -1595,6 +1614,15 @@
4.56 throw new IllegalArgumentException(attr);
4.57 }
4.58 }
4.59 + if (type.equals(htmlType)) {
4.60 + if ("body".equals(attr)) {
4.61 + body = value;
4.62 + } else if ("args".equals(attr)) {
4.63 + args[cnt++] = value;
4.64 + } else {
4.65 + throw new IllegalArgumentException(attr);
4.66 + }
4.67 + }
4.68 }
4.69 }
4.70 P p = new P();
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotations.java Tue Jul 09 21:06:35 2013 +0200
5.3 @@ -0,0 +1,37 @@
5.4 +/**
5.5 + * Back 2 Browser Bytecode Translator
5.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.7 + *
5.8 + * This program is free software: you can redistribute it and/or modify
5.9 + * it under the terms of the GNU General Public License as published by
5.10 + * the Free Software Foundation, version 2 of the License.
5.11 + *
5.12 + * This program is distributed in the hope that it will be useful,
5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 + * GNU General Public License for more details.
5.16 + *
5.17 + * You should have received a copy of the GNU General Public License
5.18 + * along with this program. Look for COPYING file in the top folder.
5.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
5.20 + */
5.21 +package org.apidesign.vm4brwsr;
5.22 +
5.23 +import net.java.html.js.JavaScriptBody;
5.24 +import net.java.html.js.JavaScriptResource;
5.25 +
5.26 +/**
5.27 + *
5.28 + * @author Jaroslav Tulach <jtulach@netbeans.org>
5.29 + */
5.30 +@JavaScriptResource("htmlannotations.js")
5.31 +public class HtmlAnnotations {
5.32 + @JavaScriptBody(args = {}, body = "return 42;")
5.33 + public static int fourtyTwo() {
5.34 + return -1;
5.35 + }
5.36 +
5.37 + @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
5.38 + public static native int useExternalMul(int x, int y);
5.39 +
5.40 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotationsTest.java Tue Jul 09 21:06:35 2013 +0200
6.3 @@ -0,0 +1,59 @@
6.4 +/**
6.5 + * Back 2 Browser Bytecode Translator
6.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
6.7 + *
6.8 + * This program is free software: you can redistribute it and/or modify
6.9 + * it under the terms of the GNU General Public License as published by
6.10 + * the Free Software Foundation, version 2 of the License.
6.11 + *
6.12 + * This program is distributed in the hope that it will be useful,
6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.15 + * GNU General Public License for more details.
6.16 + *
6.17 + * You should have received a copy of the GNU General Public License
6.18 + * along with this program. Look for COPYING file in the top folder.
6.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
6.20 + */
6.21 +package org.apidesign.vm4brwsr;
6.22 +
6.23 +import org.testng.annotations.AfterClass;
6.24 +import org.testng.annotations.BeforeClass;
6.25 +import org.testng.annotations.Test;
6.26 +
6.27 +/** Verify cooperation with net.java.html.js annotations.
6.28 + *
6.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
6.30 + */
6.31 +public class HtmlAnnotationsTest {
6.32 + @Test public void fourtyTwo() throws Exception {
6.33 + assertExec("Annotation used", HtmlAnnotations.class,
6.34 + "fourtyTwo__I",
6.35 + Double.valueOf(42)
6.36 + );
6.37 + }
6.38 +
6.39 + @Test public void externalMul() throws Exception {
6.40 + assertExec("mul function is loaded", HtmlAnnotations.class,
6.41 + "useExternalMul__III",
6.42 + Double.valueOf(42),
6.43 + 7, 6
6.44 + );
6.45 + }
6.46 +
6.47 +
6.48 + private static TestVM code;
6.49 +
6.50 + @BeforeClass
6.51 + public void compileTheCode() throws Exception {
6.52 + code = TestVM.compileClass("org/apidesign/vm4brwsr/HtmlAnnotations");
6.53 + }
6.54 + @AfterClass
6.55 + public static void releaseTheCode() {
6.56 + code = null;
6.57 + }
6.58 + private static void assertExec(String msg, Class clazz, String method, Object expRes, Object... args) throws Exception {
6.59 + code.assertExec(msg, clazz, method, expRes, args);
6.60 + }
6.61 +
6.62 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/rt/vm/src/test/resources/org/apidesign/vm4brwsr/htmlannotations.js Tue Jul 09 21:06:35 2013 +0200
7.3 @@ -0,0 +1,19 @@
7.4 +/*
7.5 + * Back 2 Browser Bytecode Translator
7.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
7.7 + *
7.8 + * This program is free software: you can redistribute it and/or modify
7.9 + * it under the terms of the GNU General Public License as published by
7.10 + * the Free Software Foundation, version 2 of the License.
7.11 + *
7.12 + * This program is distributed in the hope that it will be useful,
7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.15 + * GNU General Public License for more details.
7.16 + *
7.17 + * You should have received a copy of the GNU General Public License
7.18 + * along with this program. Look for COPYING file in the top folder.
7.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
7.20 + */
7.21 +
7.22 +function mul(x, y) { return x * y; }