diff --git a/docs/samples/HelloWorld/HelloWorld.java b/docs/samples/HelloWorld/HelloWorld.java new file mode 100644 index 0000000..33d92ba --- /dev/null +++ b/docs/samples/HelloWorld/HelloWorld.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 Volker Berlin (i-net software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import de.inetsoftware.jwebassembly.api.annotation.Export; +import de.inetsoftware.jwebassembly.web.dom.Document; +import de.inetsoftware.jwebassembly.web.dom.HTMLElement; +import de.inetsoftware.jwebassembly.web.dom.Text; +import de.inetsoftware.jwebassembly.web.dom.Window; + +public class HelloWorld { + + @Export + public static void main() { + Document document = Window.document(); + HTMLElement div = document.createElement("div"); + Text text = document.createTextNode("Hello World, this text come from WebAssembly."); + div.appendChild( text ); + document.body().appendChild( div ); + } +} diff --git a/docs/samples/HelloWorld/HelloWorld.wasm b/docs/samples/HelloWorld/HelloWorld.wasm new file mode 100644 index 0000000..c62e108 Binary files /dev/null and b/docs/samples/HelloWorld/HelloWorld.wasm differ diff --git a/docs/samples/HelloWorld/HelloWorld.wasm.js b/docs/samples/HelloWorld/HelloWorld.wasm.js new file mode 100644 index 0000000..9db6fb9 --- /dev/null +++ b/docs/samples/HelloWorld/HelloWorld.wasm.js @@ -0,0 +1,27 @@ +'use strict';var wasmImports = { +Web:{ +get0:(o,p)=>o[p], +win_get:(p)=>window[p], +invoke1:(o,m,p1)=>o[m](p1) +}, +NonGC:{ +array_set_i16:(a,i,v) => a[i]=v, +get_anyref:(a,i) => a[i], +set_anyref:(a,v,i) => a[i]=v, +new_java_lang_String:() => Object.seal({0:48}), +array_len_i8:(a) => a.length, +new_de_inetsoftware_jwebassembly_web_dom_Node:() => Object.seal({0:48,1:null}), +array_get_i8:(a,i) => a[i], +new_de_inetsoftware_jwebassembly_web_dom_HTMLElement:() => Object.seal({0:24,1:null}), +get_i32:(a,i) => a[i], +new_de_inetsoftware_jwebassembly_web_dom_Document:() => Object.seal({0:0,1:null}), +array_new_i8:(l) => new Uint8Array(l), +array_set_i8:(a,i,v) => a[i]=v, +array_new_i16:(l) => new Int16Array(l), +new_de_inetsoftware_jwebassembly_web_dom_Text:() => Object.seal({0:36,1:null}) +}, +StringHelper:{ +newFromSubChars:(value,off,count)=>{var s='';for(var i=off;i