Commit Graph

1632 Commits

Author SHA1 Message Date
a897715f50 Merge pull request #838 from brisad/object-get-descriptors
Object get descriptors
2018-09-17 10:47:46 +02:00
2d91fa11b5 Add binding for Object.getOwnPropertyDescriptors() 2018-09-16 23:02:46 +02:00
b005e96fd9 Add binding for Object.getOwnPropertyDescriptor() 2018-09-16 22:55:15 +02:00
61eb7df0c8 Update weedle 2018-09-16 23:39:00 +03:00
df18c4b042 Update weedle: use special instead of specials 2018-09-16 21:19:20 +03:00
191e7dc1fb Add binding for Object.defineProperties() 2018-09-15 22:30:27 +02:00
170ac21473 Add devicePixelRatio attribute 2018-09-15 12:42:23 +02:00
ae60bb4ba8 Translate LongLong types to f64
Any LongLong still present after flattening now gets translated to a `f64` type
so we can bind these types. While not a true integral value or truely 64-bits of
integer precision, it's all JS has anyway!
2018-09-14 18:54:29 -07:00
941397745d Enable DOMTimeStamp as UnsignedLongLong
This is apparently how webidl defines it!
2018-09-14 18:44:38 -07:00
96a70c41be reset_indentation: Don't emit indentation on blank lines
This resulted in trailing whitespace in the generated file. In addition
to wasting space in a file that gets served over the wire, this also
gets highlighted as a problem when reviewing the generated file in an
editor that highlights trailing whitespace.
2018-09-13 22:13:07 -07:00
1c52fb1b2f Remove leading and trailing blanks from the --no-modules output
The output using modules already uses string formatting that carefully
avoids emitting leading and trailing blanks; adjust the --no-modules
output to match.
2018-09-13 22:10:59 -07:00
2fc499d66d Merge pull request #819 from fitzgen/webidl-interfaces-should-extend-object
webidl: All interfaces implicitly extend `Object`
2018-09-12 16:21:48 -07:00
e2e815a477 guide: Add documentation for testing with wasm-bindgen-test 2018-09-12 15:40:09 -07:00
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
a59a10d6df Fix tests on nightly 2018-09-12 10:20:03 -07:00
e5af22ee4e Merge pull request #814 from brisad/object-define-property
Add binding for Object.defineProperty()
2018-09-12 09:13:03 -07:00
fe6ad5447e Add binding for Object.defineProperty() 2018-09-12 07:39:39 +02:00
9ca024a812 Merge pull request #792 from afdw/master
Add support for variadic arguments in WebIDL
2018-09-11 16:05:56 -07:00
096848199e Introduce a constant 2018-09-11 23:10:03 +03:00
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
9f4ed536df Use js_sys::Array, generate _n methods for ergonomics 2018-09-11 00:37:59 +03:00
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
116a19962f Change how filtering is done in WebIDL
Instead of actually modifying the `FirstPassRecord` let's instead just skip
relevant entries when we come across them. This should help us retain knowledge
that `optional SomeImportedType arg` can be bound even though `SomeImportedType`
may not exist.

One small tweak was needed to modify the AST afterwards to remove `extends`
annotations which aren't actually defined, but other than that this should...

Closes #802
2018-09-10 11:58:31 -07:00
be4ead7c8a Merge pull request #797 from alexcrichton/iterator
Implement the `Iterator` trait for JS iterators
2018-09-10 11:40:56 -07:00
b7d7d28418 Expand LongLong to (i32 or f64) instead of i64
This commit tweaks WebIDL expansion of the "long long" and "unsigned long long"
types to expand to a union of an 32-bit integer and a double. This reflects how
almost none of the APIs on the web today actually work with a `BigInt` (what the
previous Rust type of `i64` translates to) and how JS itself fundamentally
operates with these APIs.

Eventually this may not be necessary if we can natively connect to C++ engines
with the `i64` type, but until that day comes this should provide more useful
interfaces as they shoudl work in all browsers.

Closes #800
2018-09-10 11:40:20 -07:00
f2608d3155 Implement the Iterator trait for JS iterators
This commit implements the standard library's `Iterator` trait for the
`js_sys::Iterator` type, using the iterator protocol described on [MDN]

Closes #777

[MDN]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
2018-09-10 10:38:04 -07:00
14eb317509 Merge remote-tracking branch 'upstream/master' 2018-09-07 13:46:20 +03:00
f18b10ca52 Bump to 0.2.21 2018-09-06 22:10:11 -07:00
e632dd3fda Parse names before we take the module
Otherwise when we try to parse the names there's no module with contents!
2018-09-06 22:08:04 -07:00
457efc0f31 Implement support for WebIDL Callback types
This commit adds support for the WebIDL `Callback` type by translating all
callbacks to the `js_sys::Function` type. This will enable passing raw JS values
into callbacks as well as Rust valus using the `Closure` type.

This commit doesn't currently implement "callback interfaces" in WebIDL, that's
left for a follow-up commit.
2018-09-06 19:50:46 -07:00
1cd2229c66 Merge pull request #795 from fitzgen/lots-more-js-sys-bindings
Lots more js-sys bindings
2018-09-06 16:42:18 -07:00
bfff31fcb9 js-sys: Expose bindings to WebAssembly.Table.prototype.set
Part of #275
2018-09-06 15:02:01 -07:00
8f9514d216 Update syn to 0.15
New and faster parsers!
2018-09-06 15:01:24 -07:00
8dbb0fc5f2 js-sys: Expose bindings to WebAssembly.Table.prototype.grow
Par of #275
2018-09-06 14:58:46 -07:00
2d4f36c9da js-sys: Add bindings to WebAssembly.Table.prototype.get
Part of #275
2018-09-06 14:54:49 -07:00
e67397ec27 Merge pull request #793 from alexcrichton/bump
Bump to 0.2.20
2018-09-06 14:49:54 -07:00
9d5898ab48 Bump to 0.2.20 2018-09-06 14:49:43 -07:00
fb5e6e9c06 js-sys: Add bindings for WebAssembly.instantiateStreaming
Part of #275
2018-09-06 14:47:37 -07:00
5a3cd893e0 Implement AsRef<JsValue> for Closure<T>
This commit adds an implementation of `AsRef<JsValue>` for the `Closure<T>`
type. Previously this was not possible because the `JsValue` didn't actually
exist until the closure was passed to JS, but the implementation has been
changed to ... something a bit more unconventional. The end result, however, is
that `Closure<T>` now always contains a `JsValue`.

The end result of this work is intended to be a precursor to binding callbacks
in `web-sys` as `JsValue` everywhere but still allowing usage with `Closure<T>`.
2018-09-06 14:46:59 -07:00
021cbbab71 js-sys: Add bindings for WebAssembly.instantiate
Part of #275
2018-09-06 14:35:45 -07:00
8b5f5a7560 js-sys: Add exports getter to WebAssembly.Instance
Part of #275
2018-09-06 14:16:28 -07:00
cb2aa999c0 js-sys: Define imports for WebAssembly.Instance and its constructor
Part of #670 and #275
2018-09-06 14:16:18 -07:00
66d155d708 js-sys: Add extends to Reflect
Part of #670
2018-09-06 13:42:16 -07:00
bfff8661c1 js-sys: Add extends to Math
Part of #670
2018-09-06 13:39:30 -07:00
5df2347a7a js-sys: Add extends to JSON
Part of #670
2018-09-06 13:32:31 -07:00
cda71757d3 Tweak ArrayBuffer IDL type expansion slightly
A few small changes here:

* `ArrayBufferView` and `BufferSource` are expanded to themselves plus
  `Uint8ArrayMut` instead of `Object` to ensure we keep the original type.
* Generating an argument type for `ArrayBufferView`, `BufferSource`, and
  `Object` all now generate shared references instead of owned objects, which is
  a little more consistent with the other interface types.
2018-09-06 10:09:03 -07:00
1c0a34ff8e Add support for variadic arguments in WebIDL 2018-09-06 20:02:12 +03:00
6efbf5076c Adding Uint8ArrayMut, disable mutability for all other than this one 2018-09-06 16:24:43 +02:00
3076e40b21 Require shared refs to be mutable 2018-09-06 16:24:17 +02:00
8b08fc16c5 Making ArrayBufferView & BufferSource a union 2018-09-06 16:23:39 +02:00