Commit Graph

1863 Commits

Author SHA1 Message Date
Alex Crichton
f3dd28e294 Add more documentation to web-sys constructors
Closes #899
2018-09-27 12:35:46 -07:00
Alex Crichton
5a0ac2d37c Add #[inline] for IntoWasmAbi for ()
No need for it to not be inlined, it literally compiles to nothing!
2018-09-27 12:22:05 -07:00
Alex Crichton
fd1a00db76 Escape HTML text in browser failure messages
When browser tests fail we're appending to `innerHTML`, which means that
we need to escape some characters for all to show up!

Closes #898
2018-09-27 12:21:41 -07:00
Alex Crichton
65fc8228f1 Remove a stray script 2018-09-27 12:21:41 -07:00
Alex Crichton
35a7233101
Merge pull request #891 from alexcrichton/rustfmt
cargo +nightly fmt --all
2018-09-26 14:20:33 -05:00
Nick Fitzgerald
826619870f examples(webaudio): allow turning the noise off again 2018-09-26 10:37:12 -07:00
Alex Crichton
7ecf4aae87 cargo +nightly fmt --all
Rustfmt all the things!
2018-09-26 08:26:00 -07:00
Alex Crichton
a3e160744e Update Window example in web-sys 2018-09-26 08:14:14 -07:00
Alex Crichton
7a2f55d2d1 Update another git url 2018-09-26 08:11:55 -07:00
Alex Crichton
3b2448cce1 Update web-sys docs now that it's published 2018-09-26 08:10:18 -07:00
Alex Crichton
18e089fa85 Add some Cargo metadata for web-sys 2018-09-26 08:07:33 -07:00
Nick Fitzgerald
dbbb904562
Merge pull request #890 from fitzgen/bump-to-0.2.23
Bump to version 0.2.23 (and js-sys and wasm-bindgen-futures to 0.3.0)
2018-09-26 07:47:55 -07:00
Nick Fitzgerald
e0f47935db changelog: Note that this is the first web-sys release 2018-09-26 07:44:58 -07:00
Nick Fitzgerald
4c766c5c7a Start web-sys at 0.3.0 2018-09-26 07:37:51 -07:00
Nick Fitzgerald
f834a427d7 Bump to version 0.2.23 (and js-sys and wasm-bindgen-futures to 0.3.0) 2018-09-26 07:31:54 -07:00
Alex Crichton
0ab03bb4c3
Merge pull request #888 from ctaggart/webpack-cli
update to "webpack-cli": "^3.1.1"
2018-09-25 21:52:13 -07:00
Cameron Taggart
052b41b84c update to "webpack-cli": "^3.1.1" 2018-09-25 18:50:27 -07:00
Nick Fitzgerald
ee0e4bc089
Merge pull request #887 from fitzgen/iterating-over-js-values
Iterating over js values
2018-09-25 16:04:50 -07:00
Nick Fitzgerald
a920656e09 guide: Update untyped JS values section to handle fallibility of Reflect::* APIs 2018-09-25 14:30:26 -07:00
Nick Fitzgerald
dfd0f534f9 guide: Add section about iterating over JS values 2018-09-25 14:30:26 -07:00
Nick Fitzgerald
7db28b4548 js-sys: run rustfmt 2018-09-25 14:30:26 -07:00
Nick Fitzgerald
f9cd329b14 js-sys: Add js_sys::try_iter for iterating over any JsValue
Fixes #776
2018-09-25 14:30:26 -07:00
Nick Fitzgerald
e3d2ea2628 js-sys: Catch exceptions thrown in Reflect APIs
Proxies passed to Reflect APIs can throw for any of these operations and it is a
bit of a mess.
2018-09-25 14:30:26 -07:00
Alex Crichton
d50e2f8605
Merge pull request #881 from alexcrichton/test-beta
Start running CI tests on Rust beta
2018-09-25 12:27:41 -07:00
Alex Crichton
9b99ebfc87
Merge pull request #886 from alexcrichton/tweak-features
Update and improve crate features in `web-sys`
2018-09-25 12:26:45 -07:00
Alex Crichton
97cceebe7e Update and improve crate features in web-sys
* Regenerate the list of features for the crate given recent
  improvements, enabling some more types to be bound.
* Add feature gates for the `css` and `console` namespaces (modules),
  gating the APIs by default. Now `web_sys` has zero APIs unless they're
  requested.
* Improved the "required feature" documentation for `struct` types to
  not list parent classes and mention just the `struct` type instead.
2018-09-25 11:27:22 -07:00
Nick Fitzgerald
6edb871c36 js-sy: Add a doc comment for js_sys::IntoIter 2018-09-25 11:21:56 -07:00
Nick Fitzgerald
dc22965e71 js-sys: Add doc comment for js_sys::Iter 2018-09-25 11:21:56 -07:00
Alex Crichton
5af3d72f42 Start running CI tests on Rust beta
We'll graduate these to stable once 1.30.0 is released, but for now
let's start testing beta! Some matrix entries remain on nightly, but the
bulk of tests are switching to beta.
2018-09-25 10:36:28 -07:00
Nick Fitzgerald
8a2b2cb6e1
Merge pull request #876 from alexcrichton/contrib-js-sys
Update contributing docs for js-sys
2018-09-24 17:35:28 -07:00
Nick Fitzgerald
f9f8d2c214
Merge pull request #877 from alexcrichton/opt-tests
Add some blurbs about optimizing for size
2018-09-24 17:30:41 -07:00
Nick Fitzgerald
2c62795a8d
Merge pull request #880 from alexcrichton/better-link-mem-intrinsics
Improve `link_mem_intrinsics` hack
2018-09-24 17:20:54 -07:00
Nick Fitzgerald
e786d991ce
Merge pull request #883 from alexcrichton/no-chrome
Temporarily disable Chrome on CI
2018-09-24 17:11:24 -07:00
Nick Fitzgerald
91eb399f6f
Merge pull request #878 from alexcrichton/clamped
Implement support for `Uint8ClampedArray`
2018-09-24 16:43:12 -07:00
Alex Crichton
b932260b40 Temporarily disable Chrome on CI
It's been extremely flaky and is tracked by #882 for re-enabling.
2018-09-24 16:02:25 -07:00
Alex Crichton
b256b98e38 Improve link_mem_intrinsics hack
Previously the `link_mem_intrinsics` hack actually had a runtime
overhead by storing a value into a global location, but it turns out we
can actually use a non-inlined function call as part of the *descriptor*
which requires this to be in the final binary, but we'll end up snip'ing
the value at the end.

All in all this should mean that it's not a zero-overhead solution for
linking these intrinsics! The `#[wasm_bindgen]` attribute already has
other problems if the descriptors don't show up, so that's the least of
our issues!
2018-09-24 15:43:04 -07:00
Alex Crichton
7b495468f6 Implement support for Uint8ClampedArray
This commit implements support for binding APIs that take
`Uint8ClampedArray` in JS. This is pretty rare but comes up in a
`web-sys` binding or two, and we're now able to bind these APIs instead
of having to omit the bindings.

The `Uint8ClampedArray` type is bound by using the `Clamped` marker
struct in Rust. For example this is declaring a JS API that takes
`Uint8ClampedArray`:

    use wasm_bindgen::Clamped;

    #[wasm_bindgen]
    extern {
        fn takes_clamped(a: Clamped<&[u8]>);
    }

The `Clamped` type currently only works when wrapping the `&[u8]`, `&mut
[u8]`, and `Vec<u8>` types. Everything else will produce an error at
`wasm-bindgen` time.

Closes #421
2018-09-24 13:58:37 -07:00
Alex Crichton
ac9342dd8d
Merge pull request #872 from alexcrichton/less-math
Remove no-longer-needed math bindings
2018-09-24 11:32:54 -07:00
Alex Crichton
0ba7e8107c Add some blurbs about optimizing for size
The main thing we mention is to explicitly not measure the output of the
compiler, but only the ouput of `wasm-bindgen` itself.

Closes #826
2018-09-24 11:28:02 -07:00
Alex Crichton
752ad99cbd Update contributing docs for js-sys
Tweak a few links here and there and otherwise mention that we should be
complete and stage 4 proposals can be added in the future

Closes #859
2018-09-24 10:51:05 -07:00
Alex Crichton
d10ca579e4 Yarn is no longer needed for tests 2018-09-24 10:44:14 -07:00
Alex Crichton
b91817f181 Remove no-longer-needed math bindings
All these functions are now provided by upstream compiler-builtins, so
there's no need for us to be binding them automatically. The remaining
`Math_*` functions are also no longer needed on nightly after
https://github.com/rust-lang/rust/pull/54257 but that PR isn't on beta,
so we'll need to leave these here for awhile while beta rides the trains
2018-09-24 10:42:04 -07:00
Alex Crichton
c5d3ca9c00
Merge pull request #862 from alexcrichton/more-types
Enable union types without interfaces in WebIDL
2018-09-24 10:00:26 -07:00
Alex Crichton
d098d3cf28 Enable union types without interfaces in WebIDL
Bind them all as `JsValue` as that's the "least common ancestor" we can
work with. Fixes up one location in WebIDL where `Option<JsValue>`
arose as we haven't implemented that.

Closes #817
2018-09-24 09:33:22 -07:00
Alex Crichton
6ae2ce6a26 Remove no-longer-needed math bindings
All these functions are now provided by upstream compiler-builtins, so
there's no need for us to be binding them automatically. The remaining
`Math_*` functions are also no longer needed on nightly after
https://github.com/rust-lang/rust/pull/54257 but that PR isn't on beta,
so we'll need to leave these here for awhile while beta rides the trains
2018-09-21 21:43:29 -07:00
Alex Crichton
9a1fa5a81b
Merge pull request #870 from alexcrichton/no-constructor-token
Remove the need for a `ConstructorToken`
2018-09-21 21:40:08 -07:00
Alex Crichton
a663a9d410
Merge pull request #871 from alexcrichton/better-setters
Support `#[wasm_bindgen(setter, js_name = ...)]`
2018-09-21 21:39:28 -07:00
Alex Crichton
75f005be23 Support #[wasm_bindgen(setter, js_name = ...)]
Previously we'd require the explicit `js_name` to *also* start with
`set_`, but when explicitly specified it shouldn't be mangled at all!

Closes #584
2018-09-21 17:54:26 -07:00
Alex Crichton
3f85d7db9f Remove the need for a ConstructorToken
This commit removes the need for an injected `ConstructorToken` type and
also cleans up the story we have for generating constructors a bit.
After this commit a `constructor()` is omitted entirely if we're in
non-debug mode and there's no actual listed constructor. Additionally we
don't deal with splat arguments and rerouting constructors, Nick was
kind enough to enlighten me about `Object.create` which is creating an
instance without running the constructor!

Instances of an exported type are now created through one of two
methods:

* If `#[wasm_bindgen(constructor)]` is present, then a `constructor` is
  generated with the appropriate signature. If a constructor is not
  present and we're in debug mode, a throwing constructor is generated.
  If we're in release mode and there's no constructor, no constructor is
  generated.

* Otherwise if a binding returns an instance of a type (or otherwise
  needs to manfuacture an instance, then it will cause an internal
  `__wrap` function to be generated. This function will use
  `Object.create` to create an instance without running the constructor.

This should ideally clean up our generated JS for classes quite a bit,
making it much more lean-and-mean!
2018-09-21 17:42:06 -07:00
Alex Crichton
534cceafc8 Improve error message for infer_setter_property
If the setter doesn't start with `set_*` then we currently panic, but
panicking is bad! Instead let's thread through structured errors to make
sure they make their way to the top
2018-09-21 17:29:50 -07:00