Skip to content

Commit

Permalink
add hello world sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Horcrux7 committed Dec 28, 2019
1 parent a60d58c commit d63ecdc
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/samples/HelloWorld/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -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 );
}
}
Binary file added docs/samples/HelloWorld/HelloWorld.wasm
Binary file not shown.
27 changes: 27 additions & 0 deletions docs/samples/HelloWorld/HelloWorld.wasm.js
Original file line number Diff line number Diff line change
@@ -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<off+count;i++){s+=String.fromCharCode(value[i]);}return s}
}
};
if (typeof module !== 'undefined') module.exports = wasmImports;
6 changes: 6 additions & 0 deletions docs/samples/HelloWorld/HelloWorld.wasm.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version":3,
"sources":["de/inetsoftware/jwebassembly/api/java/lang/Object.java","Object.java","de/inetsoftware/jwebassembly/web/dom/Object.java","de/inetsoftware/jwebassembly/module/Object.java","de/inetsoftware/jwebassembly/web/Object.java","java/lang/Object.java"],
"names":[],
"mappings":"u1BAgCA,uBAQA,IACA,SACA,SACA,qBAEA,MAEA,OACA,6BACA,OACA,iDAEA,sEAEA,gCAEA,aAGA,sBACA,EAEA,qBCrCA,IACA,kBACA,oBACA,gBACA,4BACA,YCYA,6BCyIA,MACA,EACA,KAIA,aACA,IAEA,IAEA,iBACA,cACA,OACA,MAGA,UACA,aACA,eADA,SAGA,SAEA,MACA,QDjKA,kCAWA,oCASA,oBACA,CACA,IAEA,eAzBA,yBACA,wCAXA,MACA,IADA,MACA,IADA,MACA,IADA,MACA,IADA,MACA,IAFA,MACA,IESA,IACA,QACA,IAuCA,cA+BA,gBFjFA,MACA,IGIA;"
}

0 comments on commit d63ecdc

Please sign in to comment.