1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Wed Oct 31 18:05:24 2012 +0100
1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Thu Nov 08 18:32:32 2012 +0100
1.3 @@ -17,11 +17,8 @@
1.4 */
1.5 package org.apidesign.vm4brwsr;
1.6
1.7 -import java.io.BufferedWriter;
1.8 -import java.io.FileWriter;
1.9 import java.io.IOException;
1.10 import java.io.InputStream;
1.11 -import java.io.Writer;
1.12 import java.net.URL;
1.13 import java.util.ArrayList;
1.14 import java.util.Arrays;
1.15 @@ -41,18 +38,6 @@
1.16 final class GenJS {
1.17 private GenJS() {}
1.18
1.19 - public static void main(String... args) throws IOException {
1.20 - if (args.length < 2) {
1.21 - System.err.println("Usage: java -cp ... -jar ... <file_to_generate_js_code_to> java/lang/Class org/your/App ...");
1.22 - return;
1.23 - }
1.24 -
1.25 - Writer w = new BufferedWriter(new FileWriter(args[0]));
1.26 - List<String> classes = Arrays.asList(args).subList(1, args.length);
1.27 - compile(w, classes);
1.28 - w.close();
1.29 - }
1.30 -
1.31 static void compile(Appendable out, String... names) throws IOException {
1.32 compile(out, Arrays.asList(names));
1.33 }
1.34 @@ -197,5 +182,10 @@
1.35 }
1.36 return u.openStream();
1.37 }
1.38 -
1.39 +
1.40 + static String toString(String name) throws IOException {
1.41 + StringBuilder sb = new StringBuilder();
1.42 + compile(sb, name);
1.43 + return sb.toString().toString();
1.44 + }
1.45 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/Main.java Thu Nov 08 18:32:32 2012 +0100
2.3 @@ -0,0 +1,46 @@
2.4 +/**
2.5 + * Back 2 Browser Bytecode Translator
2.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.7 + *
2.8 + * This program is free software: you can redistribute it and/or modify
2.9 + * it under the terms of the GNU General Public License as published by
2.10 + * the Free Software Foundation, version 2 of the License.
2.11 + *
2.12 + * This program is distributed in the hope that it will be useful,
2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.15 + * GNU General Public License for more details.
2.16 + *
2.17 + * You should have received a copy of the GNU General Public License
2.18 + * along with this program. Look for COPYING file in the top folder.
2.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
2.20 + */
2.21 +package org.apidesign.vm4brwsr;
2.22 +
2.23 +import java.io.BufferedWriter;
2.24 +import java.io.FileWriter;
2.25 +import java.io.IOException;
2.26 +import java.io.Writer;
2.27 +import java.util.Arrays;
2.28 +import java.util.List;
2.29 +
2.30 +/** Generator of JavaScript from bytecode of classes on classpath of the VM
2.31 + * with a Main method.
2.32 + *
2.33 + * @author Jaroslav Tulach <jtulach@netbeans.org>
2.34 + */
2.35 +final class Main {
2.36 + private Main() {}
2.37 +
2.38 + public static void main(String... args) throws IOException {
2.39 + if (args.length < 2) {
2.40 + System.err.println("Usage: java -cp ... -jar ... <file_to_generate_js_code_to> java/lang/Class org/your/App ...");
2.41 + return;
2.42 + }
2.43 +
2.44 + Writer w = new BufferedWriter(new FileWriter(args[0]));
2.45 + List<String> classes = Arrays.asList(args).subList(1, args.length);
2.46 + GenJS.compile(w, classes);
2.47 + w.close();
2.48 + }
2.49 +}