Commit Graph

13 Commits

Author SHA1 Message Date
894b479213 Migrate wasm-bindgen to using walrus
This commit moves `wasm-bindgen` the CLI tool from internally using
`parity-wasm` for wasm parsing/serialization to instead use `walrus`.
The `walrus` crate is something we've been working on recently with an
aim to replace the usage of `parity-wasm` in `wasm-bindgen` to make the
current CLI tool more maintainable as well as more future-proof.

The `walrus` crate provides a much nicer AST to work with as well as a
structured `Module`, whereas `parity-wasm` provides a very raw interface
to the wasm module which isn't really appropriate for our use case. The
many transformations and tweaks that wasm-bindgen does have a huge
amount of ad-hoc index management to carefully craft a final wasm
binary, but this is all entirely taken care for us with the `walrus`
crate.

Additionally, `wasm-bindgen` will ingest and rewrite the wasm file,
often changing the binary offsets of functions. Eventually with DWARF
debug information we'll need to be sure to preserve the debug
information throughout the transformations that `wasm-bindgen` does
today. This is practically impossible to do with the `parity-wasm`
architecture, but `walrus` was designed from the get-go to solve this
problem transparently in the `walrus` crate itself. (it doesn't today,
but this is planned work)

It is the intention that this does not end up regressing any
`wasm-bindgen` use cases, neither in functionality or in speed. As a
large change and refactoring, however, it's likely that at least
something will arise! We'll want to continue to remain vigilant to any
issues that come up with this commit.

Note that the `gc` crate has been deleted as part of this change, as the
`gc` crate is no longer necessary since `walrus` does it automatically.
Additionally the `gc` crate was one of the main problems with preserving
debug information as it often deletes wasm items!

Finally, this also starts moving crates to the 2018 edition where
necessary since `walrus` requires the 2018 edition, and in general it's
more pleasant to work within the 2018 edition!
2019-02-12 07:25:53 -08:00
b6db977795 removed extern crate lines 2018-12-12 07:14:26 +09:00
0003fc9115 remove unnecessary lines 2018-12-12 06:56:09 +09:00
2d9dcf6ace run cargo fix --edition-idioms 2018-12-12 00:48:10 +09:00
48f4adfa8c Run rustfmt over everything 2018-11-27 12:07:59 -08:00
7ecf4aae87 cargo +nightly fmt --all
Rustfmt all the things!
2018-09-26 08:26:00 -07:00
f24828a16b Add a top-level web_sys::window function
Returns `Option<Window>` and can be used as a convenience to get a handle to the
global `window` object.
2018-09-17 17:36:53 -07:00
723ed6e856 examples(fetch): Tidy up the fetch example 2018-09-10 17:50:55 -07:00
14cb2dd4cf Fix fetch example ... again? 2018-08-30 14:26:22 -07:00
36b854b69c web-sys: Add support for Global-scope methods
This commit adds further support for the `Global` attribute to not only emit
structural accessors but also emit functions that don't take `&self`. All
methods on a `[Global]` interface will not require `&self` and will call
functions and/or access properties on the global scope.

This should enable things like:

    Window::location() // returns `Location`
    Window::fetch(...) // invokes the `fetch` function

Closes #659
2018-08-28 17:20:31 -07:00
66d96aac11 Fix merge conflicts with fetch example 2018-08-20 11:23:02 -07:00
e4093eb178 No more use_extern_macros feature! 2018-08-20 13:19:00 -04:00
9d7c0af08f Initial example for the Fetch API 2018-08-19 18:41:02 -04:00