1.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotations.java Sun Sep 08 11:42:01 2013 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,86 +0,0 @@
1.4 -/**
1.5 - * Back 2 Browser Bytecode Translator
1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.7 - *
1.8 - * This program is free software: you can redistribute it and/or modify
1.9 - * it under the terms of the GNU General Public License as published by
1.10 - * the Free Software Foundation, version 2 of the License.
1.11 - *
1.12 - * This program is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 - * GNU General Public License for more details.
1.16 - *
1.17 - * You should have received a copy of the GNU General Public License
1.18 - * along with this program. Look for COPYING file in the top folder.
1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
1.20 - */
1.21 -package org.apidesign.vm4brwsr;
1.22 -
1.23 -import net.java.html.js.JavaScriptBody;
1.24 -import net.java.html.js.JavaScriptResource;
1.25 -
1.26 -/**
1.27 - *
1.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
1.29 - */
1.30 -@JavaScriptResource("htmlannotations.js")
1.31 -public class HtmlAnnotations {
1.32 - private Object callback;
1.33 -
1.34 -
1.35 - @JavaScriptBody(args = {}, body = "return 42;")
1.36 - public static int fourtyTwo() {
1.37 - return -1;
1.38 - }
1.39 -
1.40 - @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
1.41 - public static native int useExternalMul(int x, int y);
1.42 -
1.43 - public static int callback() {
1.44 - final int[] arr = { 0 };
1.45 - callback(new Runnable() {
1.46 - @Override
1.47 - public void run() {
1.48 - arr[0]++;
1.49 - }
1.50 - });
1.51 - return arr[0];
1.52 - }
1.53 -
1.54 - @JavaScriptBody(args = { "r" }, javacall=true, body = "r.@java.lang.Runnable::run()()")
1.55 - private static native void callback(Runnable r);
1.56 -
1.57 - @JavaScriptBody(args = { }, javacall = true, body = "return @org.apidesign.vm4brwsr.HtmlAnnotations::callback()();")
1.58 - public static native int staticCallback();
1.59 -
1.60 -
1.61 - protected long chooseLong(boolean takeFirst, boolean takeSecond, long first, long second) {
1.62 - long l = 0;
1.63 - if (takeFirst) l += first;
1.64 - if (takeSecond) l += second;
1.65 - return l;
1.66 - }
1.67 -
1.68 - protected void onError(Object obj) throws Exception {
1.69 - callback = obj;
1.70 - }
1.71 -
1.72 - Object getError() {
1.73 - return callback;
1.74 - }
1.75 -
1.76 - public static Object create() {
1.77 - return new HtmlAnnotations();
1.78 - }
1.79 - @JavaScriptBody(args = { "impl", "a", "b" }, javacall = true, body =
1.80 - "return impl.@org.apidesign.vm4brwsr.HtmlAnnotations::chooseLong(ZZJJ)(true, false, a, b);"
1.81 - )
1.82 - public static native long first(Object impl, long a, long b);
1.83 -
1.84 - @JavaScriptBody(args = { "impl", "d" }, javacall = true, body =
1.85 - "impl.@org.apidesign.vm4brwsr.HtmlAnnotations::onError(Ljava/lang/Object;)(d);" +
1.86 - "return impl.@org.apidesign.vm4brwsr.HtmlAnnotations::getError()();"
1.87 - )
1.88 - public static native Double onError(Object impl, Double d);
1.89 -}