feat: add js-wasm
This commit is contained in:
16
__wasm/js-wasm/helloworld/src/lib.rs
Normal file
16
__wasm/js-wasm/helloworld/src/lib.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use js::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub fn main() {
|
||||
// let's dynamically create a javascript function we can invoke to write logs
|
||||
let fn_log = js!(r##"function(strPtr, strLen) {
|
||||
console.log(this.readUtf8FromMemory(strPtr, strLen));
|
||||
}"##);
|
||||
// let fn_alert = js!(r##"function(strPtr, strLen) {
|
||||
// alert(this.readUtf8FromMemory(strPtr, strLen));
|
||||
// }"##);
|
||||
let msg = "Hello World!";
|
||||
fn_log.invoke_2(msg.as_ptr() as u32, msg.len() as u32);
|
||||
// fn_alert.invoke_2(msg.as_ptr() as u32, msg.len() as u32);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user