mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-14 18:43:27 +01:00
add hello world sample
This commit is contained in:
parent
a60d58c352
commit
d63ecdc716
32
docs/samples/HelloWorld/HelloWorld.java
Normal file
32
docs/samples/HelloWorld/HelloWorld.java
Normal file
@ -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 );
|
||||
}
|
||||
}
|
BIN
docs/samples/HelloWorld/HelloWorld.wasm
Normal file
BIN
docs/samples/HelloWorld/HelloWorld.wasm
Normal file
Binary file not shown.
27
docs/samples/HelloWorld/HelloWorld.wasm.js
Normal file
27
docs/samples/HelloWorld/HelloWorld.wasm.js
Normal file
@ -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
docs/samples/HelloWorld/HelloWorld.wasm.map
Normal file
6
docs/samples/HelloWorld/HelloWorld.wasm.map
Normal file
@ -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;"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user