Commit Graph

263 Commits

Author SHA1 Message Date
Alex Crichton
137bbdf2e3 Bump to 0.2.45 2019-05-20 09:44:03 -07:00
Alex Crichton
773c6ff430 Bump to 0.2.44 2019-05-16 07:47:23 -07:00
Alex Crichton
578d59ebc0
Merge pull request #1440 from c410-f3r/getters
Getters/Setters for fields
2019-04-30 12:07:34 -05:00
Caio
470eea9fb0 Getters/Setters for fields 2019-04-30 10:26:03 -03:00
Alex Crichton
f2429be07f Bump to 0.2.43 2019-04-29 08:28:41 -07:00
Ingvar Stepanyan
3a7d384dc8 Generate bindings for indexed struct properties
This allows to export fields of tuple-like structs as indexed JS properties.
2019-04-17 12:56:14 +01:00
Alex Crichton
ff1addbbaa Run cargo fmt 2019-04-16 10:52:27 -07:00
Alex Crichton
c4776becbb Touch up descriptions of has_type 2019-04-12 10:54:36 -07:00
Ingvar Stepanyan
cb880bdbff Add customisable is_type_of 2019-04-12 17:23:42 +01:00
Alex Crichton
df8da56a6c Add PartialEq/Eq to many js-sys types
This commit adds `#[derive(PartialEq, Eq)]` to many types throughout
`js-sys`. These types are basically all based on `Object`, which means
that `Object.is` can be used for `PartialEq` and the `Eq` requirements
are upheld.

The macro has also been updated to internally store the deref target
instead of unconditionally storing `JsValue`, allowing `#[derive]` to
work a bit better in these situations.
2019-04-12 09:02:33 -07:00
Alex Crichton
df6e15e3ab Bump to 0.2.42 2019-04-11 07:39:45 -07:00
Alex Crichton
02394724ea Bump to 0.2.41 2019-04-10 10:53:32 -07:00
Alex Crichton
e4400ac8b4 Improve error message for non-copy struct fields
Make sure the error message points to the type in question instead of to
the `#[wasm_bindgen]` macro which can be overly confusing!
2019-04-08 07:35:14 -07:00
Alex Crichton
778e497186 Generate r#async method names in web-sys
This is a new keyword in the 2018 edition!
2019-03-26 08:51:46 -07:00
Alex Crichton
a6fe0cefa8 Migrate all crates to the 2018 edition
Most of the CLI crates were already in the 2018 edition, and it turns
out that one of the macro crates was already in the 2018 edition so we
may as well move everything to the 2018 edition!

Always nice to remove those `extern crate` statements nowadays!

This commit also does a `cargo fmt --all` to make sure we're conforming
with style again.
2019-03-26 08:10:53 -07:00
Alex Crichton
c5d2b2d1fb
Merge pull request #1359 from konstin/reexporting_in_2018
Allow reexporting proc macro output in the 2018 edition
2019-03-26 10:08:46 -05:00
Alex Crichton
6edb40a807 Implement transitive support for NPM dependencies
This commit implements [RFC 8], which enables transitive and transparent
dependencies on NPM. The `module` attribute, when seen and not part of a
local JS snippet, triggers detection of a `package.json` next to
`Cargo.toml`. If found it will cause the `wasm-bindgen` CLI tool to load
and parse the `package.json` within each crate and then create a merged
`package.json` at the end.

[RFC 8]: https://github.com/rustwasm/rfcs/pull/8
2019-03-22 09:42:40 -07:00
Alex Crichton
6803c619bb Bump to 0.2.40 2019-03-21 17:08:48 -07:00
konstin
42c1cdd8bf
Merge branch 'master' into reexporting_in_2018 2019-03-18 21:38:18 +01:00
Alex Crichton
2177dee9e4
Merge pull request #1353 from alexcrichton/raw-module
Add a `raw_module` attribute to `#[wasm_bindgen]`
2019-03-18 12:48:14 -05:00
konstin
69bbf597af Allow reexporting proc macro output in the 2018 edition
Trying to use a proc macro from a 2018 edition crate in a 2018 edition crate that reexports wasm bindgen's output failed before this commit with "could not find `wasm_bindgen` in `{{root}}`".

This commit was made with 

rg " ::wasm_bindgen::" --files-with-matches | xargs sed -i 's/::wasm_bindgen::/wasm_bindgen::/g'
2019-03-18 10:43:48 +01:00
Alex Crichton
0d592fffb0 Add a raw_module attribute to #[wasm_bindgen]
This allows subverting the checks and resolution performed by the
`module` attribute added as part of [RFC 6] and has been discussed in #1343.

Closes #1343

[RFC 6]: https://github.com/rustwasm/rfcs/pull/6
2019-03-15 08:08:09 -07:00
alexlapa
1014bdb5df Merge remote-tracking branch 'upstream/master' into enable-rtc-rtp-transceiver 2019-03-14 13:24:24 -06:00
alexlapa
9178231b60 impl OptionFromWasmAbi and OptionIntoWasmAbi for ImportEnum, enable RTCRtpTransceiver.webidl, add add rtc_rtp_transceiver_direction test 2019-03-14 12:15:02 -06:00
Caio
59c1b2a565 Merge branch 'master' into arg-names 2019-03-14 09:30:14 -03:00
Caio
70f5373348 Preserve argument names 2019-03-14 08:46:42 -03:00
Alex Crichton
228f58dca3 Bump to 0.2.39 2019-03-13 11:02:27 -07:00
Caio
ded4fdf52d Remove PartialEq and Eq from Function 2019-03-07 15:00:55 -03:00
Alex Crichton
d6e3770350 Scope snippets within a crate
Use the same crate identifier for manually included snippets as well as
inline snippets to help with debugging.
2019-03-05 14:53:14 -08:00
Alex Crichton
f3f3ebee3a Remove unsafe usage in backend/src/encode.rs
Using `unsafe` was just a little too eager there so let's use an
off-the-shelf solution for solving the actual problem we have, which is
to allocate strings with a lifetime of `Interner` rather than
deduplicating strings.
2019-03-05 12:28:14 -08:00
Alex Crichton
93a1301c9f Don't explicitly hide _INCLUDED_FILES
It's already hidden from docs!
2019-03-05 12:17:42 -08:00
Alex Crichton
6283169a30 Paths are relative to CARGO_MANIFEST_DIR
The cwd is different for workspaces, so use the manifest env var
instead.
2019-03-05 08:00:47 -08:00
Alex Crichton
b762948456 Implement the local JS snippets RFC
This commit is an implementation of [RFC 6] which enables crates to
inline local JS snippets into the final output artifact of
`wasm-bindgen`. This is accompanied with a few minor breaking changes
which are intended to be relatively minor in practice:

* The `module` attribute disallows paths starting with `./` and `../`.
  It requires paths starting with `/` to actually exist on the filesystem.
* The `--browser` flag no longer emits bundler-compatible code, but
  rather emits an ES module that can be natively loaded into a browser.

Otherwise be sure to check out [the RFC][RFC 6] for more details, and
otherwise this should implement at least the MVP version of the RFC!
Notably at this time JS snippets with `--nodejs` or `--no-modules` are
not supported and will unconditionally generate an error.

[RFC 6]: https://github.com/rustwasm/rfcs/pull/6

Closes #1311
2019-03-05 08:00:47 -08:00
Alex Crichton
a659f27c07 Bump to 0.2.38 2019-03-04 09:11:23 -08:00
Alex Crichton
4181fb311a Add experimental support for the anyref type
This commit adds experimental support to `wasm-bindgen` to emit and
leverage the `anyref` native wasm type. This native type is still in a
proposal status (the reference-types proposal). The intention of
`anyref` is to be able to directly hold JS values in wasm and pass the
to imported functions, namely to empower eventual host bindings (now
renamed WebIDL bindings) integration where we can skip JS shims
altogether for many imports.

This commit doesn't actually affect wasm-bindgen's behavior at all
as-is, but rather this support requires an opt-in env var to be
configured. Once the support is stable in browsers it's intended that
this will add a CLI switch for turning on this support, eventually
defaulting it to `true` in the far future.

The basic strategy here is to take the `stack` and `slab` globals in the
generated JS glue and move them into wasm using a table. This new table
in wasm is managed at the fringes via injected shims. At
`wasm-bindgen`-time the CLI will rewrite exports and imports with shims
that actually use `anyref` if needed, performing loads/stores inside the
wasm module instead of externally in the wasm module.

This should provide a boost over what we have today, but it's not a
fantastic strategy long term. We have a more grand vision for `anyref`
being a first-class type in the language, but that's on a much longer
horizon and this is currently thought to be the best we can do in terms
of integration in the near future.

The stack/heap JS tables are combined into one wasm table. The stack
starts at the end of the table and grows down with a stack pointer (also
injected). The heap starts at the end and grows up (state managed in
linear memory). The anyref transformation here will hook up various
intrinsics in wasm-bindgen to the runtime functionality if the anyref
supoprt is enabled.

The main tricky treatment here was applied to closures, where we need JS
to use a different function pointer than the one Rust gives it to use a
JS function pointer empowered with anyref. This works by switching up a
bit how descriptors work, embedding the shims to call inside descriptors
rather than communicated at runtime. This means that we're accessing
constant values in the generated JS and we can just update the constant
value accessed.
2019-02-20 07:28:54 -08:00
Alex Crichton
f831711f5d Support Option<RustStruct> in arguments/returns
Add all the necessary support in a few locations and we should be good
to go!

Closes #1252
2019-02-19 09:08:37 -08:00
Alex Crichton
e9f423d57e Bump to 0.2.37 2019-02-15 08:16:24 -08:00
Camille TJHOA
768b654b58 Fix warning on ATOMIC_USIZE_INIT & ATOMIC_BOOL_INIT 2019-02-15 11:58:48 +00:00
Nick Fitzgerald
802cfedcbd Bump to 0.2.36 2019-02-12 13:19:02 -08:00
Nick Fitzgerald
d9cf9b3735 Bump to version 0.2.35 2019-02-12 11:36:19 -08:00
Nick Fitzgerald
078257943d Bump to 0.2.34 2019-02-11 18:58:54 -08:00
T5uku5hi
5c0da8878d add #[allow(clippy::all)] in top-level items. 2019-02-09 20:20:10 +09:00
T5uku5hi
916789336c add #[allow(clippy::drop_ref)] 2019-02-09 03:47:25 +09:00
T5uku5hi
fb8e158c9b remove unnecessary changes 2019-02-03 22:44:27 +09:00
T5uku5hi
51f7756e83 add #[allow(clippy::*)] to 901 line 2019-02-03 22:40:24 +09:00
T5uku5hi
d3a523439e comment out the all #[allow(clippy::*)] lines 2019-02-03 13:55:57 +09:00
T5uku5hi
223054811d fixed conflict 2019-02-03 13:49:42 +09:00
Alex Crichton
9224455077 Support Option with custom enums in JS
Find a hole automatically to use a sentinel value for `None`, and then
just wire everything up!

Closes #1198
2019-01-28 14:27:57 -08:00
T5uku5hi
e19306c6a9 add #[allow(clippy::*)] in the top-level items 2019-01-25 14:44:10 +09:00
Alex Crichton
78c4075e40 Bump to 0.2.33 2019-01-18 15:32:17 -08:00