Commit Graph

1436 Commits

Author SHA1 Message Date
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
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
Alex Crichton
b9c27b93a5 Update all non-mutable slices into Rust to use AllocCopy
This commit migrates all non-mutable slices incoming into Rust to use
the standard `AllocCopy` binding instead of using a custom `Slice`
binding defined by `wasm-bindgen`. This is done by freeing the memory
from Rust rather than freeing the memory from JS. We can't do this for
mutable slices yet but otherwise this should be working well!
2019-06-25 05:44:32 -07:00
Alex Crichton
eb550f5b4f Remove __wbindgen_global_argument_ptr intrinsic
We don't actually need this since we can simply pass in a number like 8
for the return pointer all the time. There's no need to allocate more
space in static data for a return pointer tha may not even get used!
2019-06-25 05:24:08 -07:00
Alex Crichton
a021a967b2 Remove the long-defunkt Stack trait
This was used oh-so-long ago but hasn't been used in a very long time
since then. It's served no purpose for a very long time now and I don't
think we have a plan for giving it a purpose any time soon, so let's
remove it.
2019-06-25 05:08:50 -07:00
Alex Crichton
597d66ab87 Update git repo for wasm-webidl-bindings 2019-06-25 01:16:00 -07:00
Alex Crichton
e0ef329e17
Merge pull request #1594 from alexcrichton/webidl-for-realz
Second large refactor for WebIDL bindings
2019-06-25 08:21:24 +02:00
Alex Crichton
2e03961ca1 Be sure to GC our imports as well as the module
After a module goes through its primary GC pass we need to look over the
set of remaining imports and use that to prune the set of imports that
we're binding.

Closes #1613
2019-06-23 08:16:11 -07:00
Alex Crichton
3cc30843e3 Second large refactor for WebIDL bindings
This commit is the second, and hopefully last massive, refactor for
using WebIDL bindings internally in `wasm-bindgen`. This commit actually
fully executes on the task at hand, moving `wasm-bindgen` to internally
using WebIDL bindings throughout its code generation, anyref passes,
etc. This actually fixes a number of issues that have existed in the
anyref pass for some time now!

The main changes here are to basically remove the usage of `Descriptor`
from generating JS bindings. Instead two new types are introduced:
`NonstandardIncoming` and `NonstandardOutgoing` which are bindings lists
used for incoming/outgoing bindings. These mirror the standard
terminology and literally have variants which are the standard values.
All `Descriptor` types are now mapped into lists of incoming/outgoing
bindings and used for process in wasm-bindgen. All JS generation has
been refactored and updated to now process these lists of bindings
instead of the previous `Descriptor`.

In other words this commit takes `js2rust.rs` and `rust2js.rs` and first
splits them in two. Interpretation of `Descriptor` and what to do for
conversions is in the binding selection modules. The actual generation
of JS from the binding selection is now performed by `incoming.rs` and
`outgoing.rs`. To boot this also deduplicates all the code between the
argument handling of `js2rust.rs` and return value handling of
`rust2js.rs`. This means that to implement a new binding you only need
to implement it one place and it's implemented for free in the other!

This commit is not the end of the story though. I would like to add a
mdoe to `wasm-bindgen` that literally emits a WebIDL bindings section.
That's left for a third (and hopefully final) refactoring which is also
intended to optimize generated JS for bindings.

This commit currently loses the optimization where an imported is hooked
up by value directly whenever a shim isn't needed. It's planned that
the next refactoring to emit a webidl binding section that can be added
back in. It shouldn't be too too hard hopefully since all the
scaffolding is in place now.

cc #1524
2019-06-20 19:16:10 -07:00
Alex Crichton
d71ab78fc6 Bump to 0.2.47 2019-06-19 11:14:37 -07:00