mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-28 20:21:35 +00:00
Migrate from a macro to an attribute
This commit migrates from `wasm_bindgen!`-the-macro to `#[wasm_bindgen]`-the-attribute. The actual mechanics of the macro are relatively simple in just generating some shims here and there, but wrapping everything in one huge macro invocation can often seem intimidating as it gives off this feeling of "oh dear anything can happen here!" Using an attribute should curb expectations much more greatly of "oh there's just some extra stuff happening behind the scenes". The usage is otherwise relatively straightforward and close to what it was before, but check out the DESIGN.md/README.md changes for more info!
This commit is contained in:
@ -5,58 +5,39 @@ extern crate fnv;
|
||||
use std::char;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
pub struct Program {
|
||||
pub structs: Vec<Struct>,
|
||||
pub free_functions: Vec<Function>,
|
||||
pub exports: Vec<Export>,
|
||||
pub imports: Vec<Import>,
|
||||
pub imported_structs: Vec<ImportStruct>,
|
||||
pub custom_type_names: Vec<CustomTypeName>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Struct {
|
||||
pub name: String,
|
||||
pub functions: Vec<Function>,
|
||||
pub methods: Vec<Method>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
pub struct Import {
|
||||
pub module: String,
|
||||
pub catch: bool,
|
||||
pub function: Function,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ImportStruct {
|
||||
pub module: Option<String>,
|
||||
pub name: String,
|
||||
pub functions: Vec<ImportStructFunction>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ImportStructFunction {
|
||||
pub catch: bool,
|
||||
pub method: bool,
|
||||
pub js_new: bool,
|
||||
pub catch: bool,
|
||||
pub statik: bool,
|
||||
pub class: Option<String>,
|
||||
pub function: Function,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Method {
|
||||
pub mutable: bool,
|
||||
#[derive(Deserialize)]
|
||||
pub struct Export {
|
||||
pub class: Option<String>,
|
||||
pub method: bool,
|
||||
pub function: Function,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
pub struct Function {
|
||||
pub name: String,
|
||||
pub arguments: Vec<Type>,
|
||||
pub ret: Option<Type>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
pub struct CustomTypeName {
|
||||
pub descriptor: char,
|
||||
pub name: String,
|
||||
|
Reference in New Issue
Block a user