Commit Graph

677 Commits

Author SHA1 Message Date
Richard Dodd
a4835304eb Add codegen to make test work. 2018-08-19 13:39:16 +01:00
Richard Dodd
d9fd2147a0 [wip] support variadic javascript function parameters 2018-08-18 22:15:29 +01:00
Alex Crichton
57693ee11a Bump to 0.2.17 2018-08-16 23:36:42 -07:00
Alex Crichton
a4e8fb6686 Fix compile on latest nightly 2018-08-16 23:30:40 -07:00
Alex Crichton
37068cb47f Fix tests on nightly 2018-08-16 23:25:57 -07:00
R. Andrew Ohana
25b6f5d982
Merge pull request #702 from alexcrichton/dictionaries
Implement support for WebIDL dictionaries
2018-08-16 13:06:06 -07:00
Matt Kraai
c8d0c57990 Check that all errors are instances of Object
Part of #670
2018-08-16 07:14:12 -07:00
Alex Crichton
d6e48195b3 Implement support for WebIDL dictionaries
This commit adds support for generating bindings for dictionaries defined in
WebIDL. Dictionaries are associative arrays which are simply objects in JS with
named keys and some values. In Rust given a dictionary like:

    dictionary Foo {
        long field;
    };

we'll generate a struct like:

    pub struct Foo {
        obj: js_sys::Object,
    }

    impl Foo {
        pub fn new() -> Foo { /* make a blank object */ }

        pub fn field(&mut self, val: i32) -> &mut Self {
            // set the field using `js_sys::Reflect`
        }
    }

    // plus a bunch of AsRef, From, and wasm abi impls

At the same time this adds support for partial dictionaries and dictionary
inheritance. All dictionary fields are optional by default and hence only have
builder-style setters, but dictionaries can also have required fields. Required
fields are exposed as arguments to the `new` constructor.

Closes #241
2018-08-15 17:08:27 -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
69cc7725d6 webidl: Add some more logging for debugging code generation 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
88582ec47c webidl: Fix warning about partial interfaces without non-partial definition 2018-08-15 16:57:23 -07:00
Nick Fitzgerald
13fe2b4aca
Merge pull request #709 from fitzgen/webidl-and-logging
Webidl and logging
2018-08-15 15:09:53 -07:00
Sendil Kumar N
190b45d59c
Merge pull request #708 from sendilkumarn/extends-arr
Adds Extends to TypedArrays
2018-08-15 23:45:04 +02: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
21063fd42f webidl: Make logging a little more consistently formatted
This commit makes these changes:

* Unsupported constructs always log "unsupported" for easy `grep`ing
* There is always a "<generic message> : <details>" format now, so we can easily
  use `cut` to grab the generic message and count which kinds of things are our
  biggest missing features.
* Make sure that we have different `warn!` logs for each kind of unsupported
  thing, instead of grouping them together.

Put all that together and this is the current state of `wasm-bindgen-webidl` and
`web-sys`:

```
$ grep WARN stderr.txt | grep wasm_bindgen_webidl | grep -i unsupported | cut -d ' ' -f5- | cut -d ':' -f 1 | sort | uniq -c | sort -rn
    387 Unsupported WebIDL Dictionary definition
    139 Unsupported argument type
     70 Unsupported return type
     47 Unsupported WebIDL Callback definition
     22 Unsupported WebIDL extended attribute
     18 Unsupported unnamed operation
      9 Unsupported WebIDL CallbackInterface definition
      7 Unsupported WebIDL Stringifier interface member
      7 Unsupported WebIDL Maplike interface member
      2 Unsupported webidl stringifier
      2 Unsupported WebIDL Setlike interface member
      2 Unsupported stringifier on type
```
2018-08-15 14:24:09 -07:00
Sendil Kumar
af9ecac296 js-sys: Add extends attributes for js_sys::Float64Array
address review comments

add review comments
2018-08-15 22:50:27 +02:00
Nick Fitzgerald
c1f7b42662 web-sys: Provide more info in logs when type conversion fails 2018-08-15 11:45:45 -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
a45676045e
Merge pull request #705 from alexcrichton/promise
Translate WebIDL `promise` type to `js_sys::Promise`
2018-08-14 21:41:25 -07:00
Alex Crichton
b15ebf27a8
Merge pull request #687 from eminence/misc_fixes
Misc fixes and enable tests on appveyor
2018-08-14 18:59:44 -07:00
Andrew Chin
156eb24359 Use raw string in paths in webidl-tests generated code
This fixes things on Windows, which uses backslashes in their paths
2018-08-14 19:11:58 -04:00
Andrew Chin
ca5e7b8542 Fix for some unused import warnings 2018-08-14 19:11:38 -04:00
Alex Crichton
da95415bec
Merge pull request #697 from thomaseizinger/bindings/remaining-intl-bindings
Add remaining bindings for the Intl namespace
2018-08-14 15:54:18 -07:00
Alex Crichton
f5ab32a8bc Translate WebIDL promise type to js_sys::Promise
This does involve us losing the type argument present in the WebIDL, but for now
that should be fine as we're exposing low-level bindings and it's not otherwise
clear whether having a typed wrapper is a great option. Usage of `JsCast` can
convert the incoming value to a different object fairly easily.

The purpose of the `web-sys` crate is to expose functionality of the web, not
necessarily take an opinionated stance on how it should be exposed. In that
sense it should be able to work with the `Promise` as you would a typed promise
in terms of no functionality is left out. That being said we'll likely want to
be sure to reconsider this before 1.0-stabilizing the `web-sys` crate!
2018-08-14 15:52:52 -07:00
Nick Fitzgerald
79f9d966e5
Merge pull request #698 from alexcrichton/const-mixins
Generate const mixin bindings
2018-08-14 11:27:33 -07:00
Sendil Kumar
d9fbc48daa js-sys: Add extends attributes for js_sys::Float32Array 2018-08-14 19:38:33 +02:00
Sendil Kumar
10bc69a8cd js-sys: Add extends attributes for js_sys::Int32Array 2018-08-14 19:34:59 +02:00
Sendil Kumar
2d737c5634 js-sys: Add extends attributes for js_sys::Int16Array 2018-08-14 19:34:43 +02:00
Sendil Kumar
17ef5f9702 js-sys: Add extends attributes for js_sys::Int8Array 2018-08-14 19:34:26 +02:00
Sendil Kumar
b80090d395 js-sys: Add extends attributes for js_sys::UInt32Array 2018-08-14 19:32:34 +02:00
Sendil Kumar
e58e231fdf js-sys: Add extends attributes for js_sys::UInt16Array 2018-08-14 19:32:14 +02:00
Sendil Kumar
2979618842 js-sys: Add extends attributes for js_sys::UInt8ClampedArray 2018-08-14 19:31:49 +02:00
Sendil Kumar
ea0ac134db js-sys: Add extends attributes for js_sys::Uint8Array 2018-08-14 19:29:13 +02:00
gnzlbg
5ab54a4094
Remove warning, was fixed with the 0.2.16 release 2018-08-14 10:02:30 +02:00
Alex Crichton
dce4a88f7d Generate const mixin bindings
Whenever an interface includes a mixin which includes consts, inline the consts
onto the interface.
2018-08-13 21:58:40 -07:00
Thomas Eizinger
44f2ac0e9f Add bindings for Intl.NumberFormat and Intl.PluralRules 2018-08-14 13:46:06 +10:00
Thomas Eizinger
ade4a2c97a Fix typo in Intl.DateTimeFormat documentation 2018-08-14 13:45:49 +10: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
Alex Crichton
c0c27775f3
Merge pull request #681 from sepiropht/master
[670] add extends for some types
2018-08-13 18:39:53 -06:00
Alex Crichton
595162b35d
Merge pull request #691 from thomaseizinger/bindings/intl-datetimeformat
Add bindings for Intl.DateTimeFormat
2018-08-13 18:23:57 -06:00
sepiropht
96c24c47a2 add extends for JsString 2018-08-14 00:47:36 +02:00
Thomas Eizinger
ea74b8acba Add bindings for Intl.DateTimeFormat 2018-08-14 07:50:13 +10:00
Nick Fitzgerald
f4012defac futures: Add metadata to Cargo.toml 2018-08-13 14:35:35 -07:00
Nick Fitzgerald
a434880229 Bump js-sys to 0.2.1 2018-08-13 14:32:52 -07:00
Nick Fitzgerald
8974a57fb9 Bump to version 0.2.16 2018-08-13 14:27:10 -07:00
Nick Fitzgerald
ea27a172d9
Merge pull request #692 from quelledanielle/js_string_bindings
Add bindings for static method String.from_char_code
2018-08-13 14:27:00 -07:00
Danielle Pham
30fc99b724 Use u32 params for String.from_char_code bindings 2018-08-13 17:03:58 -04:00