jaroslav@1965: /** jaroslav@1965: * Back 2 Browser Bytecode Translator jaroslav@1965: * Copyright (C) 2012-2015 Jaroslav Tulach jaroslav@1965: * jaroslav@1965: * This program is free software: you can redistribute it and/or modify jaroslav@1965: * it under the terms of the GNU General Public License as published by jaroslav@1965: * the Free Software Foundation, version 2 of the License. jaroslav@1965: * jaroslav@1965: * This program is distributed in the hope that it will be useful, jaroslav@1965: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1965: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1965: * GNU General Public License for more details. jaroslav@1965: * jaroslav@1965: * You should have received a copy of the GNU General Public License jaroslav@1965: * along with this program. Look for COPYING file in the top folder. jaroslav@1965: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1965: */ jaroslav@1965: package org.apidesign.vm4brwsr; jaroslav@1965: jaroslav@1966: import static net.java.html.lib.Exports.eval; jaroslav@1966: import net.java.html.lib.Objs; jaroslav@1965: jaroslav@1965: public class LibUse { jaroslav@1965: public static int fourtyTwo() { jaroslav@1966: Number n = (Number) eval("6 * 7"); jaroslav@1965: return n.intValue(); jaroslav@1965: } jaroslav@1966: jaroslav@1966: public static String hiProperty() { jaroslav@1966: final Object obj = eval("var x = {}; x.x = 'Hi'; x"); jaroslav@1966: if (obj == null) { jaroslav@1966: throw new IllegalStateException("Some Value returned " + obj); jaroslav@1966: } jaroslav@1966: if (!(obj instanceof Objs)) { jaroslav@1966: throw new IllegalStateException("The result is Objs: " + obj.getClass()); jaroslav@1966: } jaroslav@1966: Objs js = (Objs) obj; jaroslav@1966: return (String) js.$get("x"); jaroslav@1966: } jaroslav@1965: }