wasm-bindgen/crates/backend/Cargo.toml

25 lines
699 B
TOML
Raw Normal View History

[package]
name = "wasm-bindgen-backend"
2018-08-17 09:36:42 +03:00
version = "0.2.17"
authors = ["The wasm-bindgen Developers"]
2018-04-04 00:02:04 +03:00
license = "MIT/Apache-2.0"
repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/backend"
homepage = "https://rustwasm.github.io/wasm-bindgen/"
2018-04-04 00:02:04 +03:00
documentation = "https://docs.rs/wasm-bindgen-backend"
description = """
Backend code generation of the wasm-bindgen tool
"""
[features]
spans = ["proc-macro2/nightly"]
extra-traits = ["syn/extra-traits"]
[dependencies]
lazy_static = "1.0.0"
log = "0.4"
2018-07-17 17:11:30 +03:00
proc-macro2 = "0.4.8"
quote = '0.6'
Overhaul how type information gets to the CLI This commit is a complete overhaul of how the `#[wasm_bindgen]` macro communicates type information to the CLI tool, and it's done in a somewhat... unconventional fashion. Today we've got a problem where the generated JS needs to understand the types of each function exported or imported. This understanding is what enables it to generate the appropriate JS wrappers and such. We want to, however, be quite flexible and extensible in types that are supported across the boundary, which means that internally we rely on the trait system to resolve what's what. Communicating the type information historically was done by creating a four byte "descriptor" and using associated type projections to communicate that to the CLI tool. Unfortunately four bytes isn't a lot of space to cram information like arguments to a generic function, tuple types, etc. In general this just wasn't flexible enough and the way custom references were treated was also already a bit of a hack. This commit takes a radical step of creating a **descriptor function** for each function imported/exported. The really crazy part is that the `wasm-bindgen` CLI tool now embeds a wasm interpreter and executes these functions when the CLI tool is invoked. By allowing arbitrary functions to get executed it's now *much* easier to inform `wasm-bindgen` about complicated structures of types. Rest assured though that all these descriptor functions are automatically unexported and gc'd away, so this should not have any impact on binary sizes A new internal trait, `WasmDescribe`, is added to represent a description of all types, sort of like a serialization of the structure of a type that `wasm-bindgen` can understand. This works by calling a special exported function with a `u32` value a bunch of times. This means that when we run a descriptor we effectively get a `Vec<u32>` in the `wasm-bindgen` CLI tool. This list of integers can then be parsed into a rich `enum` for the JS generation to work with. This commit currently only retains feature parity with the previous implementation. I hope to soon solve issues like #123, #104, and #111 with this support.
2018-04-13 17:33:46 +03:00
serde_json = "1.0"
syn = { version = '0.14', features = ['full', 'visit'] }
2018-08-17 09:36:42 +03:00
wasm-bindgen-shared = { path = "../shared", version = "=0.2.17" }