mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-24 08:05:04 +00:00
Reorganize and clean up the WASM wrapper
This commit is contained in:
parent
699657974a
commit
5675126a89
7 changed files with 217 additions and 176 deletions
24
frontend/wasm/src/helpers.rs
Normal file
24
frontend/wasm/src/helpers.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
|
||||
// The JavaScript `Error` type
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[derive(Clone, Debug)]
|
||||
pub type Error;
|
||||
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(msg: &str) -> Error;
|
||||
}
|
||||
|
||||
/// Takes a string and matches it to its equivalently-named enum variant (useful for simple type translations)
|
||||
macro_rules! match_string_to_enum {
|
||||
(match ($e:expr) {$($var:ident),* $(,)?}) => {
|
||||
match $e {
|
||||
$(
|
||||
stringify!($var) => Some($var),
|
||||
)*
|
||||
_ => None
|
||||
}
|
||||
};
|
||||
}
|
||||
pub(crate) use match_string_to_enum;
|
Loading…
Add table
Add a link
Reference in a new issue