Commit Graph

2697 Commits

Author SHA1 Message Date
e0ef329e17 Merge pull request #1594 from alexcrichton/webidl-for-realz
Second large refactor for WebIDL bindings
2019-06-25 08:21:24 +02:00
c664110d9f Merge pull request #1618 from alexcrichton/update-webgl
Use `view` instead of `subarray` in WebGL example
2019-06-23 13:28:00 -05:00
7f55067fa0 Merge pull request #1617 from alexcrichton/fix-gc
Be sure to GC our imports as well as the module
2019-06-23 13:27:50 -05:00
04aea4e9ab Use view instead of subarray in WebGL example
Pointed out in #1615!
2019-06-23 08:29:47 -07:00
2e03961ca1 Be sure to GC our imports as well as the module
After a module goes through its primary GC pass we need to look over the
set of remaining imports and use that to prune the set of imports that
we're binding.

Closes #1613
2019-06-23 08:16:11 -07:00
3cc30843e3 Second large refactor for WebIDL bindings
This commit is the second, and hopefully last massive, refactor for
using WebIDL bindings internally in `wasm-bindgen`. This commit actually
fully executes on the task at hand, moving `wasm-bindgen` to internally
using WebIDL bindings throughout its code generation, anyref passes,
etc. This actually fixes a number of issues that have existed in the
anyref pass for some time now!

The main changes here are to basically remove the usage of `Descriptor`
from generating JS bindings. Instead two new types are introduced:
`NonstandardIncoming` and `NonstandardOutgoing` which are bindings lists
used for incoming/outgoing bindings. These mirror the standard
terminology and literally have variants which are the standard values.
All `Descriptor` types are now mapped into lists of incoming/outgoing
bindings and used for process in wasm-bindgen. All JS generation has
been refactored and updated to now process these lists of bindings
instead of the previous `Descriptor`.

In other words this commit takes `js2rust.rs` and `rust2js.rs` and first
splits them in two. Interpretation of `Descriptor` and what to do for
conversions is in the binding selection modules. The actual generation
of JS from the binding selection is now performed by `incoming.rs` and
`outgoing.rs`. To boot this also deduplicates all the code between the
argument handling of `js2rust.rs` and return value handling of
`rust2js.rs`. This means that to implement a new binding you only need
to implement it one place and it's implemented for free in the other!

This commit is not the end of the story though. I would like to add a
mdoe to `wasm-bindgen` that literally emits a WebIDL bindings section.
That's left for a third (and hopefully final) refactoring which is also
intended to optimize generated JS for bindings.

This commit currently loses the optimization where an imported is hooked
up by value directly whenever a shim isn't needed. It's planned that
the next refactoring to emit a webidl binding section that can be added
back in. It shouldn't be too too hard hopefully since all the
scaffolding is in place now.

cc #1524
2019-06-20 19:16:10 -07:00
a1fc270f2a Merge pull request #1608 from alexcrichton/bump
Bump to 0.2.47
0.2.47
2019-06-19 16:46:46 -05:00
b7b92cffe2 Update mdbook install 2019-06-19 13:49:57 -07:00
d71ab78fc6 Bump to 0.2.47 2019-06-19 11:14:37 -07:00
9b8191efb1 Merge pull request #1605 from c410-f3r/getters-check
Forbid duplicated getter/setter names in fields and methods
2019-06-19 13:11:17 -05:00
e7902f384f Merge pull request #1606 from alexcrichton/gc-elss
Preserve the function table during early gc passes
2019-06-19 13:10:45 -05:00
c9ee88bda3 Preserve the function table during early gc passes
Recent refactorings of wasm-bindgen have inserted multiple `gc` passes
executed by walrus. In these passes though the function table was being
removed a bit too aggressively because it's not exported by LLD and it's
only later that we realize we need to export it.

To handle this case we add synthetic and temporary exports of the
function table and these exports are removed just after the GC pass in
question.

Closes #1603
2019-06-18 11:04:17 -07:00
8d90655f98 Merge pull request #1602 from alexcrichton/more-immutable
Handle more slice types in `flag_slices_immutable`
2019-06-18 11:04:09 -07:00
1aa6773c47 Merge pull request #1604 from marienz/link-utils-mixin
Make HTMLHyperlinkElementUtils a mixin, not a NoInterfaceObject
2019-06-17 16:56:21 -07:00
597b697017 Forbid duplicated getter/setter names in fields and methods 2019-06-17 15:09:39 -03:00
3361e02caf Merge pull request #1601 from c410-f3r/unnecessary-result
Remove unnecessary Result return
2019-06-17 09:37:05 -05:00
af1f051e9b Typo 2019-06-17 11:36:51 -03:00
b5da08c6a0 Merge pull request #1598 from Pauan/fix-futures
Fixing panic if the Future wakes up after returning Poll::Ready
2019-06-17 09:36:24 -05:00
46e3cd5aa2 Make HTMLHyperlinkElementUtils a mixin, not a NoInterfaceObject
Commit b8afa0abde converted several interfaces
from NoInterfaceObject to mixins. It looks like it missed
HTMLHyperlinkElementUtils: it did update the interfaces that use
HTMLHyperlinkElementUtils (from "implements" to "includes"), but did not mark
HTMLHyperlinkElementUtils as a mixin.

Fix it, which makes HtmlAnchorElement gain useful functions like `set_href`.
2019-06-18 00:25:56 +10:00
379cad047a Merge pull request #1599 from marienz/typescript-init
Make the argument to init optional in the Typescript declaration too
2019-06-17 07:32:09 -05:00
3b06e58c9e Handle more slice types in flag_slices_immutable
Should address the latest comment on #1539
2019-06-17 05:30:10 -07:00
f1cd643992 Merge pull request #1600 from c410-f3r/repo-url
Update repository url
2019-06-17 07:18:50 -05:00
00d47c1958 Remove unnecessary Result return 2019-06-16 22:24:27 -03:00
62681425b0 Update repository url 2019-06-16 19:52:11 -03:00
1b91457200 Make the argument to init optional in the Typescript declaration too
Commit 8ace8287ff made the argument to the
generated init() function optional (when the target is "web"), but it is still
marked as required in the generated .d.ts file.

Fix the generated declaration to match the function definition again.
2019-06-16 21:34:31 +10:00
5a1dfdf2ab Fixing panic if the Future wakes up after returning Poll::Ready 2019-06-15 15:08:34 +02:00
9cac16f2d6 Merge pull request #1596 from alexcrichton/bump
Bump to 0.2.46
0.2.46
2019-06-14 13:45:17 -05:00
8fc0a38402 Bump to 0.2.46 2019-06-14 11:44:58 -07:00
83a3f5d44a Run cargo fmt --all 2019-06-13 08:30:06 -07:00
3aa803c55c Merge pull request #1380 from alexcrichton/rayon-example
Rewrite the parallel raytracing example with `rayon`
2019-06-13 08:50:38 -05:00
eafc6024cc Rewrite the parallel raytracing example with rayon
One of the best parts about concurrency in Rust is using `rayon` and how
easy it makes parallelization of tasks, so it's the ideal example for
parallel Rust on the web! Previously we've been unable to use `rayon`
because there wasn't a way to customize how rayon threads themselves are
spawned, but [that's now being developed for us][rayon]!

This commit uses that PR to rewrite the `raytrace-parallel` example in
this repository. While not a perfect idiomatic representation of using
`rayon` I think this is far more idiomatic than the previous iteration
of `raytrace-parallel`! I'm hoping that we can continue to iterate on
this, but otherwise show it off as a good example of parallel Rust on
the web.

[rayon]: https://github.com/rayon-rs/rayon/pull/636
2019-06-13 06:48:53 -07:00
f027bb2e09 Merge pull request #1593 from vmx/patch-1
guide: fix typo in rust-type-conversions.md
2019-06-12 09:04:19 -05:00
5c79298dc9 guide: fix typo in rust-type-conversions.md 2019-06-12 14:14:57 +02:00
1c558fac92 Merge pull request #1592 from alexcrichton/explicit-self
Include self-pointer in `Function` descriptions
2019-06-11 17:11:58 -05:00
80c75df166 Merge pull request #1590 from alexcrichton/intrinsics
Correct some intrinsic signatures
2019-06-11 14:53:22 -05:00
754328bef2 Merge pull request #1589 from alexcrichton/clamped
Remove the `Clamped` descriptor type
2019-06-11 14:53:15 -05:00
c0df37b2f2 Merge pull request #1588 from alexcrichton/exnptr
Communicate exceptions through global memory
2019-06-11 14:53:01 -05:00
afbd7d3ff8 Include self-pointer in Function descriptions
Previously a `Function` didn't actually take into account the self
pointer and instead left it as an implicit argument. This instead
ensures that there's a `Descriptor::I32` type inside of a `Function`
description that we have to later skip, and this should not only make
the anyref pass correct for Rust exports but it should also make it more
accurate for future webidl transformations.
2019-06-11 12:51:53 -07:00
ce4cc317e8 Correct some intrinsic signatures
While this doesn't currently cause issues in the upcoming webidl
refactor this is actually being asserted and causes verification issues
if the types don't align!

These are basically just mistakes from the original implementation of
this module, but this doesn't actually fix a known bug today.
2019-06-11 11:56:08 -07:00
621fc9c440 Remove the Clamped descriptor type
This is just a bit too general to work with and is pretty funky. Instead
just tweak `Clamped<&[u8]>` to naturally generate a descriptor for
`Ref(Slice(ClampedU8))`, requiring fewer gymnastics when interpreting
descriptors.
2019-06-11 11:52:13 -07:00
6796bc6895 Communicate exceptions through global memory
Instead of allocating space on the stack and returning a pointer we
should be able to use a single global memory location to communicate
this error payload information. This shouldn't run into any reentrancy
issues since it's only stored just before returning to wasm and it's
always read just after returning from wasm.
2019-06-11 11:41:05 -07:00
535aa3193c Attempt to fix compilation issues on CI
Can't reproduce the errors on Azure locally, but hopefully tweaking
generated code can get things to work.
2019-06-10 08:47:19 -07:00
c3e0edd956 Merge pull request #1586 from alexcrichton/no-web-sys
Make `env_logger` an optional dependency
2019-06-10 10:47:14 -05:00
a7726545ac Merge pull request #1579 from ibaryshnikov/default-init-module
added default module path inside init function when target is web
2019-06-10 10:40:38 -05:00
5cf8224d99 Make env_logger an optional dependency
Only used during development no need to pull in its set of features when
typically compiled as a dependency of other crates!

Closes #1580
2019-06-10 07:12:44 -07:00
2e05b62013 Merge pull request #1583 from Pauan/asref
Adding in AsRef impl for all wasm_bindgen types
2019-06-10 09:05:22 -05:00
b205045424 Adding in AsRef impl for all wasm_bindgen types 2019-06-10 08:05:59 +02:00
8ace8287ff added default module path inside init function when target is web 2019-06-08 01:27:35 +03:00
96d333af84 Merge pull request #1577 from c410-f3r/getters-setters-ts
Fix getter and setter for TS
2019-06-07 10:10:22 -05:00
e7e8ae1877 Fix getter and setter 2019-06-06 16:11:51 -03:00