Commit Graph

1444 Commits

Author SHA1 Message Date
Alex Crichton
efacd8b74d
Merge pull request #1514 from ibaryshnikov/threadsafe-futures
Threadsafe futures
2019-07-19 09:38:04 -05:00
Pauan
ed778f5eb2 Adding in PartialEq and Eq to web-sys types 2019-07-18 23:12:49 +02:00
Alex Crichton
b13f757e90 Shared more betwee legacy with/without atomics 2019-07-18 14:11:59 -07:00
Alex Crichton
be294c8248 Remove a debugging statement 2019-07-18 14:04:45 -07:00
Alex Crichton
c8451d6f3e Rename some files
* Use "legacy" instead of "stable" since `futures 0.1` is quicly
  becoming "legacy"
* Rename "atomics" to "legacy_atomics" to leave room for the
  libstd-based futures atomics version.
* Rename "polyfill" to "wait_async_polyfill" to specify what it's
  polyfilling.
2019-07-18 14:00:45 -07:00
Alex Crichton
d590a9e053 Deduplicate JsFuture definitions
Turns out it's the exact same for both before and after atomics, so
let's use the same definition!
2019-07-18 13:59:14 -07:00
Alex Crichton
cde9684e4b Clean up atomics/futures + polyfill
* Remove now-unneeded `State` enum
* Remove timeout argument from polyfill since we don't need it
* Call `Atomics.waitAsync` if it's available instead of using our polyfill
* Remove some extraneous dead code from the polyfill
* Add a `val: i32` argument to the polyfill
* Simplify the flow of futures with `Package` since `waitAsync` handles
  all the heavy lifting for us.
* Remove `Arc<Package>` and just use `Package`
* Remove `RefCell` from inside of `Package` now that it is no longer
  needed.
2019-07-18 13:55:54 -07:00
Alex Crichton
d122bbca13 Emit a compiler error with futures 0.3 and atomics
Not implemented yet, and the one there doesn't work with atomics! (we'll
get around to this soon-ish)
2019-07-18 10:13:05 -07:00
ibaryshnikov
02be3690cf removed AtomicBool from Waker struct 2019-07-17 01:52:55 +03:00
ibaryshnikov
45d2c7ce93 updated to the latest master 2019-07-17 01:24:44 +03:00
ibaryshnikov
cbaa1d302a added documentation comment for a stable version of wasm-bindgen-futures 2019-07-17 00:58:05 +03:00
ibaryshnikov
6ab1a49a41 moved lib.rs to stable.rs in wasm-bindgen-futures, updated during review 2019-07-17 00:58:05 +03:00
ibaryshnikov
221dc732af updated default timeout and wait_async signature in wasm-bindgen-futures 2019-07-17 00:48:00 +03:00
ibaryshnikov
06c783d5e3 placed web-sys dependency behind a feature flag in wasm-bindgen-futures 2019-07-17 00:48:00 +03:00
ibaryshnikov
16c6bdc966 moved threadsafe futures implementation to a separate file, made updates after review 2019-07-17 00:48:00 +03:00
ibaryshnikov
e466e1a6f1 moved threadsafe futures behind a flag 2019-07-17 00:48:00 +03:00
ibaryshnikov
2fdfe79574 added polyfill implementation in rust 2019-07-17 00:48:00 +03:00
ibaryshnikov
c01575c1bc typo fixed in Atomics docs 2019-07-17 00:48:00 +03:00
ibaryshnikov
d1d3021271 added polyfill for Atomics.wait and used it to notify futures 2019-07-17 00:48:00 +03:00
Nick Fitzgerald
8fd5f4ed6a Check for use-after-move in JS glue when --debug is enabled again
Fixes #1669
2019-07-16 13:35:59 -07:00
Julien Cretin
170ce683d8 Add missing Element::get_elements_by_* methods 2019-07-15 19:47:09 +02:00
Nick Fitzgerald
a48a0aeb93
Merge pull request #1654 from fitzgen/no-import-shims
Skip generating JS import shims when unnecessary
2019-07-15 10:13:11 -07:00
Nick Fitzgerald
31ca527523 Bump wasm-webidl-bindings dep to 0.1.2 2019-07-15 09:35:22 -07:00
Nick Fitzgerald
afb33e5cf4 Assert that a bunch more function signatures don't require JS glue 2019-07-12 12:34:29 -07:00
Nick Fitzgerald
bce892b625 Add #[wasm_bindgen(assert_no_shim)] on imported functions for testing
This should not be used outside of wasm-bindgen's test suite.
2019-07-12 12:34:29 -07:00
Alex Crichton
4f86653e0d Fix parsing of final on Nightly Rust
This fixes an issue also reported to upstream (rust-lang/rust#62628) to
ensure that we parse the `final` attribute as either `r#final` or
`final`, since now the compiler is giving us `r#final` and we were
previously only accepting `final`.

The parsing here was a bit wonky, but this setup ended up working!
2019-07-12 10:05:11 -07:00
Nick Fitzgerald
2d0866da9a cli-support: rustfmt 2019-07-11 15:44:16 -07:00
Nick Fitzgerald
d5d3e46334 cli-support: Skip generating JS shims for imports when unnecessary
After this change, any import that only takes and returns ABI-safe numbers (signed
integers less than 64 bits and unrestricted floating point numbers) will be a
direct import, and will not have a little JS shim in the middle.

We don't have a great mechanism for testing the generated bindings' contents --
as opposed to its behavior -- but I manually verified that everything here does
the Right Thing and doesn't have a JS shim:

```rust
\#[wasm_bindgen]
extern "C" {
    fn trivial();

    fn incoming_i32() -> i32;
    fn incoming_f32() -> f32;
    fn incoming_f64() -> f64;

    fn outgoing_i32(x: i32);
    fn outgoing_f32(y: f32);
    fn outgoing_f64(z: f64);

    fn many(x: i32, y: f32, z: f64) -> i32;
}
```

Furthermore, I verified that when our support for emitting native `anyref` is
enabled, then we do not have a JS shim for the following import, but if it is
disabled, then we do have a JS shim:

```rust
\#[wasm_bindgen]
extern "C" {
    fn works_when_anyref_support_is_enabled(v: JsValue) -> JsValue;
}
```

Fixes #1636.
2019-07-11 15:44:16 -07:00
Nick Fitzgerald
f2a4694c69 cli-support: Fix copy-pasted error message
This error case is for an invalid free function, not an invalid constructor.
2019-07-11 15:44:16 -07:00
Nick Fitzgerald
21fe8dc706 cli-support: Fix typo in comment 2019-07-11 15:44:16 -07:00
Alex Crichton
e596ef596c Bump to 0.2.48 2019-07-11 15:02:39 -07:00
dependabot-preview[bot]
ce40388a7f
Update weedle requirement from 0.9 to 0.10
Updates the requirements on [weedle](https://github.com/rustwasm/weedle) to permit the latest version.
- [Release notes](https://github.com/rustwasm/weedle/releases)
- [Commits](https://github.com/rustwasm/weedle/compare/0.9.0...0.10.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-11 10:07:41 +00:00
Nick Fitzgerald
d02e115fd4
Merge pull request #1650 from alexcrichton/less-csp
Use static accessors if possible to get global object
2019-07-10 09:37:56 -07:00
Alex Crichton
b64f5c0ad8
Merge pull request #1649 from alexcrichton/fix-futures
Update futures implementation to not destroy callbacks
2019-07-10 11:02:43 -05:00
Nick Fitzgerald
6cb659d5ac Fix warning about dead code when testing on non-wasm32 targets
There are functions that are only used on wasm32 targets, but `cfg`ing them is
more work than just making the modules public, and this is just a testing crate.
2019-07-09 13:17:52 -07:00
Nick Fitzgerald
1ba298548f Fix warning about unnecessary parens in generated code 2019-07-09 13:17:34 -07:00
Alex Crichton
d32b6a916c Update futures implementation to not destroy callbacks
JS engines guarantee that at least one of our `then` callbacks are
invoked, so that means if we destroy them prematurely they're guaranteed
to log an exception to the console! Instead to prevent exceptions from
happening tweak how the completion callbacks for JS futures are managed
and ensure that the closures stay alive until they're invoked later.

Closes #1637
2019-07-09 11:14:26 -07:00
Alex Crichton
0b08bba0c7 Use static accessors if possible to get global object
Previously we always used `Function('return this')` but this triggers
CSP errors since it's basically `eval`. Instead this adds a few
preflight checks to look for objects like `globalThis`, `self`, etc.
Currently we don't have a `#[wasm_bindgen]` function annotation to
import a bare global field like `self`, but we test accesses with
`self.self` and `globalThis.globalThis`, catching errors to handle any
issues.

Closes #1641
2019-07-08 13:28:06 -07:00
Alex Crichton
604c036111
Merge pull request #1645 from derekdreery/fix_futures_0_3_hack
Add in (unsafe and incorrect) impls of Send/Sync that are now required.
2019-07-08 12:04:43 -05:00
ibaryshnikov
8f52f10aea added explicit extension for imported .wasm file for --target bundler 2019-07-08 03:50:17 +03:00
Richard Dodd
2541507789 Add in (unsafe and incorrect) impls of Send/Sync that are now required. 2019-07-06 16:30:29 +01:00
dakom
f27de49989 whitelist slices for webgl2 uniformNuiv 2019-07-03 23:32:00 +03:00
Samuel Warfield
367a56eb25 Test are fully implemented 2019-06-28 14:14:27 -06:00
Samuel Warfield
06d0704cf8 Added tests for bind1() 2019-06-28 12:03:45 -06:00
Samuel Warfield
caa86a07a0 Attempted to tackle #1622 2019-06-27 15:48:18 -06:00
Alex Crichton
792ab403a1
Merge pull request #1625 from alexcrichton/less-return-ptr
Remove `__wbindgen_global_argument_ptr` intrinsic
2019-06-26 13:36:57 +02:00
Pauan
497c5ed423 Removing TODOs 2019-06-25 21:42:20 +02:00
Pauan
b9fd30b49e Adding in TODO note 2019-06-25 21:42:20 +02:00
Pauan
8cb9b88acb Adding in unit tests for From impl 2019-06-25 21:42:20 +02:00
Pauan
86937b9dba Adding in From impl for TypedArrays 2019-06-25 21:42:20 +02:00