Commit Graph

105 Commits

Author SHA1 Message Date
Alex Crichton
48f4adfa8c Run rustfmt over everything 2018-11-27 12:07:59 -08:00
Richard Dodd
4fa9865cc9 Add manual docs for single manual function. 2018-11-13 14:36:33 +00:00
Alex Crichton
22ca15f81e Bump to 0.2.28 2018-11-12 09:28:01 -08:00
Alex Crichton
dc4e78550a
Merge pull request #1019 from alexcrichton/rfc-5
Implement rustwasm/rfcs#5, implement `Deref` for imports and `structural` by default
2018-11-12 10:59:46 -06:00
dependabot[bot]
d673d5cfff
Update env_logger requirement from 0.5 to 0.6
Updates the requirements on [env_logger](https://github.com/sebasmagri/env_logger) to permit the latest version.
- [Release notes](https://github.com/sebasmagri/env_logger/releases)
- [Commits](https://github.com/sebasmagri/env_logger/commits/v0.6.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-12 08:17:10 +00:00
Alex Crichton
2c9084d0e2 Update web-sys test to only test compilation 2018-11-09 07:56:48 -08:00
Alex Crichton
5b76a6291e Implement Deref for all imported JS types
This commit implements the first half of [RFC #5] where the `Deref`
trait is implemented for all imported types. The target of `Deref` is
either the first entry of the list of `extends` attribute or `JsValue`.

All examples using `.as_ref()` with various `web-sys` types have been
updated to the more ergonomic deref casts now. Additionally the
`web-sys` generation of the `extends` array has been fixed slightly to
explicitly list implementatoins in the hierarchy order to ensure the
correct target for `Deref` is chosen.

[RFC #5]: https://github.com/rustwasm/rfcs/blob/master/text/005-structural-and-deref.md
2018-11-08 11:01:34 -08:00
Jake Riesterer
3d1f4263ad Change UnionType to IdlType::Union function to include any supported types instead of returning None when there is at least one unsupported type
For example, the constructor in Response.webidl accepts multiple types. However, one of those types is `ReadableStream` which isn't defined yet, and that causes all constructors for Response to be skipped even though the other argument types could be supported.
2018-11-07 10:39:22 -08:00
Alex Crichton
6dfbb4be89 Bump to 0.2.27 2018-10-29 14:30:33 -07:00
Alex Crichton
7fad2bf0c8 Bump to 0.2.26 2018-10-29 12:56:37 -07:00
Nick Fitzgerald
dd82a3e134 Bump to 0.2.25 2018-10-10 13:19:40 -07:00
Alex Crichton
18deb5e848 Fix web-sys build on some Windows builds
The official pathname separator on Windows is `\` instead of `/`, but
we've been unconditionally using `/`. This typically works on Windows
because Cargo's default `OUT_DIR` listing is a normal `C:\...` path
which works with either `/` or `\`. If, however, a user sets
`CARGO_TARGET_DIR` to a UNC-style path like `\\?\C:\...` then `/` is
*not* the same as `\`, but rather `/` is interpreted as part of the file
name (to allow file names with `/` in the name).

Let's bypass all this and just use a build script output env var.

Closes #943
2018-10-08 10:19:43 -07:00
Alex Crichton
c210ccd596 Bump to 0.2.24 2018-10-05 09:53:19 -07:00
Alex Crichton
bb7271aa43 Fix our WebIDL for Safari
This commit employs the strategy described in #908 to apply a
non-breaking change to fix WebIDL to be compatible with all browsers,
including Safari.

The problem here is that `BaseAudioContext` and `AudioScheduledSourceNode`
are not types in Safari, but they are types in Firefox/Chrome. The fix
here was to move the contents of these two interfaces into mixins, and
then include the mixins in all classes which inherit from these two
classes. That should have the same effect as defining the methods
inherently on the original interface.

Additionally a special `[RustDeprecated]` attribute to WebIDL was added
to signify interfaces this has happened to. Currently it's directly
tailored towards this case of "this intermediate class doesn't exist in
all browsers", but we may want to refine and extend the deprecation
message over time.

Although it's possible we could do this as a breaking change to
`web-sys` I'm hoping that we can do this as a non-breaking change for
now and then eventually on the next breaking release batch all these
changes together, deleting the intermediate classes. This is also
hopefully a good trial run for how stable web-sys can be when it's
actually stable!

cc #897
cc #908
2018-10-01 12:24:37 -07:00
Nick Fitzgerald
0a48d2bc29 web-sys: allow unused import warning
This import is only used if some features get used and it is way easier to just
quiet the warning when those features aren't used than to try and `cfg` this
import.
2018-10-01 09:53:03 -07:00
Alex Crichton
230b8f61fd Fix WebIDL mixin attributes on Window
Previously the "container attribute" were set to the attributes of the
mixin itself, but we want the container attributes to be that of the
type which includes the mixin (like `Window`) as those attributes
contain information about whether or not bindings are `structural`.

The end result with this is that the `structural` tag is now used for
properties on `Window`, correctly generating setters/getters.

Closes #904
2018-09-28 21:41:48 -07:00
Alex Crichton
7ecf4aae87 cargo +nightly fmt --all
Rustfmt all the things!
2018-09-26 08:26:00 -07:00
Alex Crichton
18e089fa85 Add some Cargo metadata for web-sys 2018-09-26 08:07:33 -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
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
Alex Crichton
51ec485c94 Bump to 0.2.22 2018-09-21 13:41:58 -07:00
Alex Crichton
8c720bee50 Purge a number of Mozilla-specific WebIDL
Did a bunch of grepping for `moz*` and searched for "moz" in rustdoc,
deleting anything that looked mozilla-specific. Now there's nothing left
with the "moz" prefix in rustdoc!
2018-09-20 17:19:36 -07:00
Alex Crichton
a83d561bb3 Add js_sys::global 2018-09-18 15:40:49 -07:00
Alex Crichton
bbc46f92c6 Fix web-sys Location test 2018-09-18 14:16:01 -07:00
Alex Crichton
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
Alex Crichton
a02c4c1410 Uncommented some WebIDL TODO
This partially reverts commit 4b4bed5ce2 by
restoring a number of items to our WebIDL

Closes #839
2018-09-17 13:25:10 -07:00
Ruben Schmidmeister
170ac21473
Add devicePixelRatio attribute 2018-09-15 12:42:23 +02:00
Nick Fitzgerald
93a510ef93 webidl: All interfaces implicitly extend Object
This information is embedded within the algorithm for constructing interfaces
and their prototypes in the section for ECMAScript glue in the WebIDL spec...

This really *should* make the `wasm_bindgen_backend::ast::ImportType::extends`
member from a `Vec<Ident>` into a `Vec<syn::Path>` so that we could use
`js_sys::Object` in the extends field, but that is a huge pain because then the
`ImportedTypes` trait needs to be changed, and all of its implementers, etc...
2018-09-12 15:25:09 -07:00
Alex Crichton
a59a10d6df Fix tests on nightly 2018-09-12 10:20:03 -07:00
Nick Fitzgerald
f6b199cfb0 web-sys: Crate metadata should point to the web-sys section of the wasm-bindgen guide 2018-09-10 17:56:03 -07:00
Alex Crichton
8181f7fa95 Implement WebIDL callback interfaces
This commit implements callback interfaces for WebIDL, the final WebIDL
construct that we were unconditionally ignoring! Callback interfaces are
implemented as dictionaries of callbacks. Single-operation callback interfaces
are also expanded when flattening to accept a `Function` as well, in accordance
with the WebIDL spec.

New features have been added to `web-sys` for all the new callback interface
types. Additionally the `EventTarget.webidl` was tweaked to not have
`EventListener?` as this is required for all functional usage and there's no
need to keep that sort of web browser compat here.

Closes #258
2018-09-10 12:00:50 -07:00
Alex Crichton
f18b10ca52 Bump to 0.2.21 2018-09-06 22:10:11 -07:00
Alex Crichton
9d5898ab48 Bump to 0.2.20 2018-09-06 14:49:43 -07:00
Alex Crichton
038b087ba3 Provide docs.rs metadata for generating docs
Makes sure that docs.rs, when it supports it, provides all the documentation for
all our features!
2018-09-05 12:57:36 -07:00
Alex Crichton
269c491380
Gate web-sys APIs on activated features (#790)
* Gate `web-sys` APIs on activated features

Currently the compile times of `web-sys` are unfortunately prohibitive,
increasing the barrier to using it. This commit updates the crate to instead
have all APIs gated by a set of Cargo features which affect what bindings are
generated at compile time (and which are then compiled by rustc). It's
significantly faster to activate only a handful of features vs all thousand of
them!

A magical env var is added to print the list of all features that should be
generated, and then necessary logic is added to ferry features from the build
script to the webidl crate which then uses that as a filter to remove items
after parsing. Currently parsing is pretty speedy so we'll unconditionally parse
all WebIDL files, but this may change in the future!

For now this will make the `web-sys` crate a bit less ergonomic to use as lots
of features will need to be specified, but it should make it much more
approachable in terms of first-user experience with compile times.

* Fix AppVeyor testing web-sys

* FIx a typo

* Udpate feature listings from rebase conflicts

* Add some crate docs and such
2018-09-05 12:55:30 -07:00
Alex Crichton
cfb4be8d3c Handle [Unforgeable] on interfaces
In addition to handling it on methods look like it also shows up on interfaces!

Closes #780
2018-08-31 17:38:34 -07:00
Alex Crichton
d9bc0a3176 Bump to 0.2.19 2018-08-27 13:39:23 -07:00
Alex Crichton
98008b9e77 Bump to 0.2.18
At the same time, also add a `publish.rs` script to ease our publishing woes.
2018-08-27 13:37:55 -07:00
Alex Crichton
92b7de3d3d Skip args in overloaded method names if all same
This commit updates how we name overloaded methods. Previously all argument
names were concatenated, but after this commit it only concatenates argument
names where at least one possibility has a different type. Otherwise if all
possibilities have the same type name it in theory isn't adding too much more
information!

Additionally this commit also switches to using `_with_` consistently everywhere
instead of `_with_` for constructors and `_using_` for methods.

Closes #712
2018-08-20 10:30:02 -07:00
Alex Crichton
d4297ad2d3 Remove use_extern_macros features
This has now been stabilized!
2018-08-19 14:33:01 -07:00
Andrew Chin
302f7ba21d Fix missing WindowOrWorkerGlobalScope partial interface mixins.
Without the "mixin" keyword, wasm_bindgen_webidl would report:

     Partial interface WindowOrWorkerGlobalScope missing non-partial interface

Also, including the "mixin" keyword here is consistent with the official
webidl spec (for example see https://fetch.spec.whatwg.org/#fetch-method)
2018-08-18 11:23:29 -04:00
Alex Crichton
57693ee11a Bump to 0.2.17 2018-08-16 23:36:42 -07:00
Nick Fitzgerald
b8afa0abde web-sys: Use mixins instead of [NoInterfaceObject] interfaces and implements
I think these might all be from before WebIDL mixins existed. Either way,
multiple inheritance of interfaces that don't have exposed interface objects is
equivalent to mixins.
2018-08-15 16:57:23 -07:00
Nick Fitzgerald
9616ef3633 web-sys: Remove a bunch of mozilla extensions from our webidl 2018-08-15 16:57:23 -07:00
Nick Fitzgerald
703e2a3fbe web-sys: Fix typedef of nsISupports
The JS Object type is named "object" in webidl, not "Object".
2018-08-15 16:57:23 -07:00
Nick Fitzgerald
ea137a951b web-sys: Remove a few more interfaces from gecko's test suite 2018-08-15 14:34:59 -07:00
Nick Fitzgerald
a40f83ea1b web-sys: Remove a bunch of non-standard, Mozilla-specific Web IDL 2018-08-15 11:12:22 -07:00
Nick Fitzgerald
6b5beda8d1 web-sys: Add a type alias to Object from nsISupports 2018-08-15 10:54:50 -07:00
Alex Crichton
03eb1b1d01 Support named "special" operations in WebIDL
This commit adds support for two different features of the "special" operations
in WebIDL. First, it implements the desugaring [described by WebIDL][1] where
this:

    interface Dictionary {
      getter double getProperty(DOMString propertyName);
      setter void setProperty(DOMString propertyName, double propertyValue);
    };

becomes ...

    interface Dictionary {
      double getProperty(DOMString propertyName);
      void setProperty(DOMString propertyName, double propertyValue);

      getter double (DOMString propertyName);
      setter void (DOMString propertyName, double propertyValue);
    };

where specifically a named `getter` generates both a getter and a named
function.

Second it implements the distinction between two different types of getters in
WebIDL, described as:

> Getters and setters come in two varieties: ones that take a DOMString as a
> property name, known as named property getters and named property setters, and
> ones that take an unsigned long as a property index, known as indexed property
> getters and indexed property setters.

The name `get` is given to DOMString arguments, and the name `get_idx` is given
to index property getters.

[1]: https://heycam.github.io/webidl/#idl-special-operations
2018-08-13 17:52:34 -07:00