-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement rustwasm/rfcs#5, implement Deref
for imports and structural
by default
#1019
Commits on Nov 8, 2018
-
Implement
Deref
for all imported JS typesThis commit implements the first half of [RFC rustwasm#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 rustwasm#5]: https://github.com/rustwasm/rfcs/blob/master/text/005-structural-and-deref.md
Configuration menu - View commit details
-
Copy full SHA for 5b76a62 - Browse repository at this point
Copy the full SHA 5b76a62View commit details -
Use splat instead of
arguments
in testsPreviously `arguments` was used to pass around an array of arguments, but this wasn't actually a `js_sys::Array` but rather a somewhat esoteric internal object. When switching over `Array` methods to be `structural` this caused issues because the inherent methods on an `arguments` object were different than that of `js_sys::Array`.
Configuration menu - View commit details
-
Copy full SHA for b013ec6 - Browse repository at this point
Copy the full SHA b013ec6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 64a6241 - Browse repository at this point
Copy the full SHA 64a6241View commit details -
Fix a test to actually test the right property
This was a copy/paste typo!
Configuration menu - View commit details
-
Copy full SHA for 58c3a99 - Browse repository at this point
Copy the full SHA 58c3a99View commit details -
Optimize shim generation for
structural
itemsThis commit removes shims, where possible, for `structural` items. Instead of generating code that looks like: const target = function() { this.foo(); }; exports.__wbg_thing = function(a) { target.call(getObject(a)); }; we now instead generate: exports.__wbg_thing = function(a) { getObject(a).foo(); }; Note that this only applies to `structural` bindings, all default bindings (as of this commit) are still using imported targets to ensure that their binding can't change after instantiation. This change was [detailed in RFC rustwasm#5][link] as an important optimization for `structural` bindings to ensure they've got performance parity with today's non-`structural` default bindings. [link]: https://rustwasm.github.io/rfcs/005-structural-and-deref.html#why-is-it-ok-to-make-structural-the-default
Configuration menu - View commit details
-
Copy full SHA for a16b4dd - Browse repository at this point
Copy the full SHA a16b4ddView commit details -
Don't convert boolean arguments going to wasm
The wasm spec defines boolean conversion when crossing to the wasm type i32 as 1 for `true` and 0 for `false`, so no need for us to do it ourselves!
Configuration menu - View commit details
-
Copy full SHA for 6093fd2 - Browse repository at this point
Copy the full SHA 6093fd2View commit details -
Switch all imports to
structural
by defaultThis commit switches all imports of JS methods to `structural` by default. Proposed in [RFC 5] this should increase the performance of bindings today while also providing future-proofing for possible confusion with the recent addition of the `Deref` trait for all imported types by default as well. A new attribute, `host_binding`, is introduced in this PR as well to recover the old behavior of binding directly to an imported function which will one day be the precise function on the prototype. Eventually `web-sys` will switcsh over entirely to being driven via `host_binding` methods, but for now it's been measured to be not quite as fast so we're not making that switch yet. Note that `host_binding` differs from the proposed name of `final` due to the controversy, and its hoped that `host_binding` is a good middle-ground! [RFC 5]: https://rustwasm.github.io/rfcs/005-structural-and-deref.html
Configuration menu - View commit details
-
Copy full SHA for 4c42aba - Browse repository at this point
Copy the full SHA 4c42abaView commit details
Commits on Nov 9, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 8ba467e - Browse repository at this point
Copy the full SHA 8ba467eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2c9084d - Browse repository at this point
Copy the full SHA 2c9084dView commit details -
Configuration menu - View commit details
-
Copy full SHA for cb246e3 - Browse repository at this point
Copy the full SHA cb246e3View commit details