Commit Graph

1858 Commits

Author SHA1 Message Date
Alex Crichton
a117c057fb More conservatively patch closure descriptors
Previously `wasm-bindgen` would take its `breaks_if_inlined` shims and
attempt to remove them entirely, replacing calls to `breaks_if_inlined`
to the imported closure factories. This worked great in that it would
remove the `breaks_if_inlined` funtion entirely, removing the "cost" of
the `#[inline(never)]`.

Unfortunately as #864 discovered this is "too clever by half". LLVM's
aggressive optimizations won't inline `breaks_if_inlined`, but it may
still change the ABI! We can't replace calls to `breaks_if_inlined` if
the signature changes, because the function its calling has a fixed signature.

This commit cops out a bit and instead of replacing calls to
`breaks_if_inlined` to the imported closure factories, we instead
rewrite calls to `__wbindgen_describe_closure` to the closure factories.
This means that the `breaks_if_inlined` shims do not get removed. It
also means that the closure factory shims have a third and final
argument (what would be the function pointer of the descriptor function)
which is dead and unused.

This should be a functional solution for now and let us iterate on a
true fix later on (if needed). For now the cost of this
`#[inline(never)]` and the extra unused argument should be quite small.

Closes #864
2018-09-21 13:34:59 -07:00
Nick Fitzgerald
c517b00825
Merge pull request #861 from alexcrichton/less-moz
Purge a number of Mozilla-specific WebIDL
2018-09-21 09:57:12 -07:00
Alex Crichton
0c500046f5
Merge pull request #867 from Hywan/patch-1
doc(readme) Add links to doc & clean
2018-09-21 08:28:22 -07:00
Sendil Kumar N
9b758767c3
Merge pull request #863 from alexcrichton/deploy-examples
Build examples and deploy to gh-pages
2018-09-21 11:49:59 +02:00
Ivan Enderlin
54b2482d03
doc(readme) Add links to doc & clean
This patch adds a link to the crate's documentation. It also removes a reference to #275, which is closed now.
2018-09-21 10:08:11 +02:00
Alex Crichton
e353c1cf6f Build examples and deploy to gh-pages
Rejigger Travis slightly to take advantage of build stages to build the
`gh-pages` branch amongst a set of builders, and then when they're all
done we synchronize and deploy the site. For now use S3 as a backing
store for data between jobs.
2018-09-20 20:55:02 -07:00
Alex Crichton
f871cf6354 Update design doc link
Closes #851
2018-09-20 17:38:19 -07:00
Alex Crichton
65bcef3a47 Fix contributing URL 2018-09-20 17:37:04 -07:00
Alex Crichton
70c821b442
Merge pull request #860 from alexcrichton/juggle-examples
Reorganize and rewrite examples
2018-09-20 17:34:37 -07:00
Alex Crichton
a2d6a8ff53 Use anyref helper to reduce some code duplication 2018-09-20 17:26:49 -07:00
Alex Crichton
8c720bee50 Purge a number of Mozilla-specific WebIDL
Did a bunch of grepping for `moz*` and searched for "moz" in rustdoc,
deleting anything that looked mozilla-specific. Now there's nothing left
with the "moz" prefix in rustdoc!
2018-09-20 17:19:36 -07:00
Alex Crichton
3efe51eb8b Reorganize and rewrite examples
This commit is a large-ish scale reorganization of our examples. The
main goal here is to have a dedicated section of the guide for example,
and all examples will be listed there. Each example's `README` is now
just boilerplate pointing at the guide along with a blurb about how to
run it.

Some examples like `math` and `smorgasboard` have been deleted as they
didn't really serve much purpose, and others like `closures` have been
rewritten with `web-sys` instead of hand-bound bindings.

Overall it's hoped that this puts us in a good and consistent state for
our examples, with all of them being described in the guide, excerpts
are in the guide, and they're all relatively idiomatically using
`web-sys`.
2018-09-20 16:45:30 -07:00
Alex Crichton
a85e49a2b4
Merge pull request #856 from afdw/master
Add String.raw
2018-09-19 16:28:16 -07:00
Anton Danilkin
f808594efa Add String.raw 2018-09-20 00:40:14 +03:00
Alex Crichton
68c91a503c
Merge pull request #855 from fitzgen/fix-webgl-example
Fix webgl example
2018-09-19 14:16:33 -07:00
Nick Fitzgerald
e9212cfa43
Merge pull request #853 from alexcrichton/clone
Add `#[derive(Clone, Debug)]` to all web-sys types
2018-09-19 13:20:40 -07:00
Nick Fitzgerald
5a267d109a examples(webgl): run rustfmt 2018-09-19 13:19:41 -07:00
Nick Fitzgerald
0c41c0b432 examples(webgl): stop using old window static methods
These were removed and replaced with normal methods on window and a standalone
function to get the global window.
2018-09-19 13:18:48 -07:00
Nick Fitzgerald
b36708fd85
Merge pull request #854 from brisad/object-bindings
Add the last four bindings for Object
2018-09-19 13:16:33 -07:00
Michael Hoffmann
f7b511588b Add binding for Object.entries() 2018-09-19 21:32:05 +02:00
Michael Hoffmann
326e4c0262 Add binding for Object.getPrototypeOf() 2018-09-19 21:10:40 +02:00
Michael Hoffmann
76969bd1e3 Add binding for Object.getOwnPropertySymbols() 2018-09-19 20:58:46 +02:00
Alex Crichton
4ca187cc2b
Merge pull request #835 from blm768/webgl-example
Create basic WebGL example
2018-09-19 11:56:43 -07:00
Alex Crichton
3f68c43d06 Add #[derive(Clone, Debug)] to all web-sys types
They're all cloneable and debuggable!
2018-09-19 11:54:32 -07:00
Michael Hoffmann
4e18493fd7 Add binding for Object.getOwnPropertyNames() 2018-09-19 20:43:50 +02:00
Alex Crichton
35f5127010 Remove unused eslint config 2018-09-18 17:23:29 -07:00
Alex Crichton
5832ff3ca1
Merge pull request #847 from alexcrichton/fix-window
Move all methods on `Window` back to methods
2018-09-18 16:59:46 -07:00
Alex Crichton
a83d561bb3 Add js_sys::global 2018-09-18 15:40:49 -07:00
Alex Crichton
300aca38c2 Squelch warnings in webidl tests 2018-09-18 14:30:24 -07:00
Alex Crichton
604ecd9529 Squelch warnings in webidl tests 2018-09-18 14:30:01 -07:00
Alex Crichton
bbc46f92c6 Fix web-sys Location test 2018-09-18 14:16:01 -07:00
Alex Crichton
9baee66bf3
Merge pull request #850 from alexcrichton/rethrow
Allow returning `Result` from functions
2018-09-18 14:08:23 -07:00
Alex Crichton
7cf4213283 Allow returning Result from functions
This commit adds support for exporting a function defined in Rust that returns a
`Result`, translating the `Ok` variant to the actual return value and the `Err`
variant to an exception that's thrown in JS.

The support for return types and descriptors was rejiggered a bit to be a bit
more abstract and more well suited for this purpose. We no longer distinguish
between functions with a return value and those without a return value.
Additionally a new trait, `ReturnWasmAbi`, is used for converting return values.
This trait is an internal implementation detail, however, and shouldn't surface
itself to users much (if at all).

Closes #841
2018-09-18 13:13:59 -07:00
Ben Merritt
426671d83c Create basic WebGL example 2018-09-17 20:59:26 -07:00
Alex Crichton
285c734a6a Fix an example on nightly 2018-09-17 18:35:41 -07:00
Alex Crichton
ce3068bb3a Work around Travis's own bug... 2018-09-17 18:35:05 -07:00
Alex Crichton
ccced83b0e Fixup merge mistake 2018-09-17 17:44:29 -07:00
Alex Crichton
e66d01f7fb Fix botched merge 2018-09-17 17:38:16 -07:00
Alex Crichton
4ea5d701bb Tweak package.json for fetch example 2018-09-17 17:38:07 -07:00
Alex Crichton
fe31615ca1 Fix webidl-tests fallout 2018-09-17 17:36:53 -07:00
Alex Crichton
f24828a16b Add a top-level web_sys::window function
Returns `Option<Window>` and can be used as a convenience to get a handle to the
global `window` object.
2018-09-17 17:36:53 -07:00
Alex Crichton
99e1b352e5 Translate the WindowProxy type to Window.
This is roughly defined by
https://html.spec.whatwg.org/multipage/window-object.html#windowproxy and
otherwise fits the bill how otherwise only `interface WindowProxy;` exists in
the WebIDL.
2018-09-17 17:36:53 -07:00
Alex Crichton
8cf9da4981 Translate the Global attribute to "structural"
All APIs on `Windows` are tagged where `Window` has `[Global]`, and they all
need to be structurally accessed rather than through a prototype.
2018-09-17 17:36:53 -07:00
Alex Crichton
c67582a315 Remove support for scoped static methods
This is intended to address #834 where we don't actually want methods scoped
like this! Instead we'll provide one unique accessor for the `window` object
itself.
2018-09-17 17:36:53 -07:00
Alex Crichton
a7cda70253
Merge pull request #848 from alexcrichton/closure-docs-again
Tweak more `Closure` docs
2018-09-17 17:36:30 -07:00
Alex Crichton
bb82db9a12 Tweak more Closure docs
Show off usage of the stable `Closure::wrap` instead of `Closure::new` and
additionally add an explicit example of using it with `web_sys`.

Closes #843
2018-09-17 17:36:17 -07:00
Nick Fitzgerald
a37fa45100
Merge pull request #845 from alexcrichton/more-webidl
Uncommented some WebIDL TODO
2018-09-17 15:29:49 -07:00
Nick Fitzgerald
b38b9da499
Merge pull request #846 from alexcrichton/no-modules
Remove `Module` node from the backend AST
2018-09-17 15:19:57 -07:00
Nick Fitzgerald
6ce5e6e1dd
Merge pull request #831 from alexcrichton/more-webidl-types
Add bindings for a few more "long long" types
2018-09-17 15:17:17 -07:00
Nick Fitzgerald
4db375ba97
Merge pull request #844 from alexcrichton/dox
Clarify nightly-ness of `Closure::new`
2018-09-17 15:16:45 -07:00