mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
moved all crates into seperate folder + related path fixes
This commit is contained in:
parent
12ef03bb86
commit
eee85fa45d
1063 changed files with 92 additions and 93 deletions
35
crates/repl_wasm/src/externs_js.rs
Normal file
35
crates/repl_wasm/src/externs_js.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// wasm_bindgen procedural macro breaks this clippy rule
|
||||
// https://github.com/rustwasm/wasm-bindgen/issues/2774
|
||||
#![allow(clippy::unused_unit)]
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn js_create_app(wasm_module_bytes: &[u8]) -> Result<(), JsValue>;
|
||||
|
||||
pub fn js_run_app() -> usize;
|
||||
|
||||
pub fn js_get_result_and_memory(buffer_alloc_addr: *mut u8) -> usize;
|
||||
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn log(s: &str);
|
||||
}
|
||||
|
||||
// To debug in the browser, start up the web REPL as per instructions in repl_www/README.md
|
||||
// and sprinkle your code with console_log!("{:?}", my_value);
|
||||
// (Or if you're running the unit tests in Wasmer, you can just use println! or dbg!)
|
||||
#[macro_export]
|
||||
macro_rules! console_log {
|
||||
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
|
||||
/// Async entrypoint for the browser
|
||||
/// The browser only has an async API to generate a Wasm module from bytes
|
||||
/// wasm_bindgen manages the interaction between Rust Futures and JS Promises
|
||||
#[wasm_bindgen]
|
||||
pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
|
||||
crate::repl::entrypoint_from_js(src).await
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue