From 543e60d91e0d77c4f20fcc9e7ebe3fea7e933012 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 13 May 2018 18:00:47 +0200 Subject: [PATCH] Finally can call a Rust function from JS! #47 --- README.rst | 2 +- src/mango/ui/webi/compile_str.rs | 16 ---------------- static/index.html | 2 +- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/README.rst b/README.rst index 335cec2b..8fe5d92c 100644 --- a/README.rst +++ b/README.rst @@ -70,7 +70,7 @@ These instructions were tested on Ubuntu 18.4 (using Bash). It should also work .. code:: bash cargo +nightly build --target wasm32-unknown-unknown --release - wasm-bindgen target/wasm32-unknown-unknown/release/mango.wasm --out-dir target/deploy/ + wasm-bindgen --no-modules --no-typescript target/wasm32-unknown-unknown/release/mango.wasm --out-dir target/deploy/ # then open target/deploy/index.html in a browser * You're now ready to make changes! If you want to help, you're very welcome! Have a glance at CONTRIBUTING.rst_ if you have a minute. diff --git a/src/mango/ui/webi/compile_str.rs b/src/mango/ui/webi/compile_str.rs index 09e80416..0a0c4825 100644 --- a/src/mango/ui/webi/compile_str.rs +++ b/src/mango/ui/webi/compile_str.rs @@ -1,23 +1,7 @@ -//use std::ffi::CStr; -//use std::ffi::CString; -//use std::os::raw::c_char; use wasm_bindgen::prelude::*; -//// Convert a c-string, e.g. from javascript, into a Rust String. -//fn str_to_rust(external_str: *const c_char) -> String { -// unsafe { CStr::from_ptr(external_str).to_string_lossy().into_owned() } -//} -// -//// Convert a Rust string into a c-string. -//fn str_from_rust(internal_str: String) -> *mut c_char { -// CString::new(internal_str.as_str()).unwrap().into_raw() -//} - #[wasm_bindgen] pub fn compile_string_to_wat(code: &str) -> String { - // let code = str_to_rust(codechrs); // TODO - println!("compiling {}", code); format!("compiled: {}", code).to_owned() - // str_from_rust(code) } diff --git a/static/index.html b/static/index.html index 7e53c811..2bc36268 100644 --- a/static/index.html +++ b/static/index.html @@ -66,7 +66,7 @@

Mango (wasm)

-