feat: add js-wasm

This commit is contained in:
2022-07-17 19:39:28 +08:00
parent 30ac42001b
commit 9f61cc748a
8 changed files with 368 additions and 0 deletions

View 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);
}