Commit Graph

704 Commits

Author SHA1 Message Date
Alex Crichton
61491eafbf Add experimental support for WeakRef
This commit adds experimental support for `WeakRef` to be used to automatically
free wasm objects instead of having to always call the `free` function manually.
Note that when enabled the `free` function for all exported objects is still
generated, it's just optionally invoked by the application.

Support isn't exposed through a CLI flag right now due to the early stages of
the `WeakRef` proposal, but the env var `WASM_BINDGEN_WEAKREF` can be used to
enable this generation. Upon doing so the output can then be edited slightly as
well to work in the SpiderMonkey shell and it looks like this is working!

Closes #704
2018-08-20 11:18:02 -07:00
Alex Crichton
ddc42738cf Tweak some WebIDL type names in methods
Instead of `dom_str`, `byte_str`, and `usv_str`, emit `str` for all of them.
Similarly for `unrestricted_f64` just do `f64` instead. This reflects how we
interpret the types already in terms of Rust types and although technically
makes it possible to have name collisions in WebIDL they don't come up in
practice.
2018-08-20 10:32:04 -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
a4bf239eff
Merge pull request #739 from Hywan/string-replace-regexp
feat(js-sys) Implement `String.replace(&str, …)`
2018-08-20 07:55:05 -07:00
Ivan Enderlin
1e27b588e2
feat(js-sys) Implement String.replace(&str, …). 2018-08-20 11:01:56 +02:00
Ivan Enderlin
a9a1e69f30
feat(js-sys) Implement String.split with regexp. 2018-08-20 10:42:12 +02:00
Alex Crichton
6d49c76bc4
Merge pull request #734 from alexcrichton/stabilize
Remove `use_extern_macros` features
2018-08-19 18:12:00 -07:00
Alex Crichton
d4297ad2d3 Remove use_extern_macros features
This has now been stabilized!
2018-08-19 14:33:01 -07:00
Danielle Pham
4f294224f0 Add bindings for String.prototype.split 2018-08-19 15:09:45 -04:00
Danielle Pham
8698084a43 Add binding for String.prototype.search 2018-08-19 14:52:10 -04:00
Danielle Pham
44877880bb Add bindings for String.prototype.replace 2018-08-19 14:42:22 -04:00
Danielle Pham
7b53b1c88e Add binding for String.prototype.match 2018-08-19 13:59:00 -04:00
Mason Stallmo
b330bd1bf1 Refactor inheritance checks into their own tests 2018-08-19 11:27:04 -05:00
Mason Stallmo
1762b3cba0 Add extends to js-sys:Intl.PluralRules 2018-08-19 11:03:55 -05:00
Mason Stallmo
ee131888da Add extends to js-sys:Intl.NumberFormat 2018-08-19 10:19:03 -05:00
Mason Stallmo
780c7236f1 Add extends to js-sys:Intl.DateTimeFormat 2018-08-19 10:13:25 -05:00
Mason Stallmo
f0811d5ac0 Add extends to js-sys:Intl.Collater 2018-08-19 10:03:56 -05:00
Alex Crichton
9c6225fd80
Merge pull request #720 from kraai/patch-1
Test for and add extends attributes
2018-08-18 22:15:30 -07:00
Alex Crichton
1fd52b08a3
Merge pull request #724 from eminence/partial_mixin
Fix missing WindowOrWorkerGlobalScope partial interface mixins.
2018-08-18 22:10:17 -07:00
Alex Crichton
3697ddf4c0
Merge pull request #723 from mstallmo/add-extends-to-js-sys
Add extends attributes for js_sys:Generator
2018-08-18 22:09:16 -07:00
Alex Crichton
a12fc46a55
Merge pull request #728 from quelledanielle/js_string_from_code_point
Add bindings for String.from_code_point
2018-08-18 22:08:48 -07:00
Danielle Pham
27d48ad267 Add bindings for String.from_code_point 2018-08-18 21:35:38 -04:00
Danielle Pham
00a0152adf Rename local param to locale 2018-08-18 21:05:12 -04:00
Danielle Pham
0d3f706195 Add binding for String.prototype.localeCompare 2018-08-18 21:05:02 -04: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
Mason Stallmo
c543b5d149 Add extends attributes for js_sys:Generator 2018-08-18 09:11:07 -05:00
Matt Kraai
6dccb7f777 Remove blank line
Part of #670
2018-08-17 14:50:15 -07:00
Matt Kraai
bec3178e3c Make all errors extend Object
Part of #670
2018-08-17 13:10:56 -07:00
Matt Kraai
687412ec50 Test for AsRef implementations
Part of #670
2018-08-17 13:09:30 -07: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