mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-28 14:27:36 +03:00
d6e48195b3
This commit adds support for generating bindings for dictionaries defined in WebIDL. Dictionaries are associative arrays which are simply objects in JS with named keys and some values. In Rust given a dictionary like: dictionary Foo { long field; }; we'll generate a struct like: pub struct Foo { obj: js_sys::Object, } impl Foo { pub fn new() -> Foo { /* make a blank object */ } pub fn field(&mut self, val: i32) -> &mut Self { // set the field using `js_sys::Reflect` } } // plus a bunch of AsRef, From, and wasm abi impls At the same time this adds support for partial dictionaries and dictionary inheritance. All dictionary fields are optional by default and hence only have builder-style setters, but dictionaries can also have required fields. Required fields are exposed as arguments to the `new` constructor. Closes #241
23 lines
395 B
TOML
23 lines
395 B
TOML
[package]
|
|
name = "webidl-tests"
|
|
version = "0.1.0"
|
|
authors = ["The wasm-bindgen authors"]
|
|
|
|
[lib]
|
|
test = false
|
|
doctest = false
|
|
path = 'lib.rs'
|
|
|
|
[build-dependencies]
|
|
wasm-bindgen-webidl = { path = '../webidl' }
|
|
env_logger = "0.5"
|
|
|
|
[dev-dependencies]
|
|
js-sys = { path = '../js-sys' }
|
|
wasm-bindgen = { path = '../..' }
|
|
wasm-bindgen-test = { path = '../test' }
|
|
|
|
[[test]]
|
|
name = 'wasm'
|
|
path = 'main.rs'
|