Alex Crichton
c35d6f4b0a
Fix conditional #[wasm_bindgen] in impls
...
Reported in #1191 the fix requires us to get a bit creative I think. The
general gist is that a block like this:
#[wasm_bindgen]
impl Foo {
pub fn foo() {}
}
was previously expanded all in one go. Now, however, it's expanded into:
impl Foo {
#[__wasm_bindgen_class_marker(Foo = "Foo")]
pub fn foo() {}
}
// goop generated by orginal #[wasm_bindgen]
This method of expansion takes advantage of rustc's recursive expansion
feature. It also allows us to expand `impl` blocks and allow inner items
to not be fully expanded yet, such as still having `#[cfg]` attributes
(like in the original bug report).
We use theinternal `__wasm_bindgen_class_marker` to indicate that we're
parsing an `ImplItemMethod` unconditionally, and then generation
proceeds as usual. The only final catch is that when we're expanding in
an `impl` block we have to generate tokens for the `Program`
(wasm-bindgen injected goop like the custom section) inside the body
of the function itself instead of next to it. Otherwise we'd get syntax
errors inside of impl blocks!
Closes #1191
2019-01-28 12:29:01 -08:00
Henry
2a6d2004e1
minor typo in js-sys lib.rs
2019-01-24 15:35:21 -08:00
rhysd
3300301b3f
add '| undefined' to optional types in generated .d.ts
2019-01-23 20:49:52 +09:00
Alex Crichton
78c4075e40
Bump to 0.2.33
2019-01-18 15:32:17 -08:00
Alex Crichton
ba732a8a72
Merge pull request #1161 from derekdreery/debug_output
...
Better output from `impl Debug for JsValue`.
2019-01-17 16:52:13 -08:00
Richard Dodd (dodj)
867b13b65e
remove array check
2019-01-17 21:07:23 +00:00
Nick Fitzgerald
d79ca22234
Merge pull request #1190 from sagan-software/issue-1186
...
js-sys: JSON::stringify_with_replacer[_and_space]
2019-01-16 16:38:59 -08:00
Liam Curry
6226e6959f
js-sys: JSON::stringify_with_replacer[_and_space]
...
This commit adds two new externs for `JSON.stringify`:
`JSON::stringify_with_replacer` and
`JSON::stringify_with_replacer_and_space`.
Fixes #1186
2019-01-16 18:03:03 -05:00
Nick Fitzgerald
31fdede9fc
Bump to 0.2.32
2019-01-16 13:11:13 -08:00
Richard Dodd
b0906fddba
Better recognition of error type.
2019-01-16 15:36:13 +00:00
Richard Dodd
5f2ba3f98e
Add better support for errors.
2019-01-16 10:46:26 +00:00
Richard Dodd
5bffc28631
Add a proper test.
...
And fix loads of bugs.
2019-01-16 10:16:29 +00:00
Richard Dodd
b60d82a531
Implement suggestings from @fitzgen.
2019-01-16 10:16:29 +00:00
Richard Dodd
72765757ef
Fix tests again.
2019-01-16 10:16:29 +00:00
Richard Dodd
126efd5a95
Redo as js function + fix tests
2019-01-16 10:16:29 +00:00
Richard Dodd
5b51d279b4
Use toString
where JSON.stringify
didn't work
2019-01-16 10:16:29 +00:00
Richard Dodd
34bab511e5
Use JSON serialization to get better debug printouts.
2019-01-16 10:16:29 +00:00
Nick Fitzgerald
41eefa7425
wasm-bindgen-test: Capture more console logging methods' output
...
Fixes #1183
2019-01-15 14:05:22 -08:00
rhysd
8d6839878e
fix missing semicolons to struct fields in .d.ts
...
TypeScript class property requires semicolon at the end:
https://www.typescriptlang.org/docs/handbook/classes.html
2019-01-15 17:45:11 +09:00
Alex Crichton
715b4f4ced
Merge pull request #1179 from alexcrichton/catch-all-errors
...
In debug mode log all imported uncaught exceptions
2019-01-14 17:28:15 -08:00
Alex Crichton
f2f11a01a2
In debug mode log all imported uncaught exceptions
...
This commit updates the `--debug` output of `wasm-bindgen` from the CLI
to catch all JS exceptions from imported functions, log such, and then
rethrow. It's hoped that this can be used when necessary to learn more
information about thrown exceptions and where an uncaught exception
could be causing issues with Rust code.
Closes #1176
2019-01-14 15:59:31 -08:00
Alex Crichton
5c04427382
Merge pull request #1175 from alexcrichton/internal-consistency
...
Fix an issue where closure rewriting required class internals
2019-01-14 15:53:40 -08:00
Alex Crichton
20e871f676
Fix an issue where closure rewriting required class internals
...
Surfaced through previous sanity-checking commits, this reorders some
internal operations to...
Closes #1174
2019-01-14 15:53:29 -08:00
Alex Crichton
b21489368c
Ensure internal exported_classes
map is consistent
...
Throw it in an `Option` and then `take()` it when we consume it to
ensure that future calls to insert data into it panic instead of
producing inconsistent JS.
2019-01-14 15:53:29 -08:00
Nick Fitzgerald
f2cbbb83f3
wasm-bindgen-test: ignore example code that is not intended to compile
...
This was making `cargo test --all` fail.
2019-01-14 14:53:46 -08:00
Nick Fitzgerald
56c4385f42
wasm-bindgen-test: Rename console_*_redirect
to on_console_*
...
Since we are no longer redirecting all console logs, and are instead just
observing them.
2019-01-14 14:51:28 -08:00
Nick Fitzgerald
a94f3f4403
wasm-bindgen-test: Have the test runner JS call the original console.log
...
This makes control flow a little easier to follow and avoids wasm->js->wasm
re-entrancy.
2019-01-14 14:51:28 -08:00
Nick Fitzgerald
51ef19b85f
wasm-bindgen-test: Use spread array arguments instead of arguments objects
...
Our testing runtime tries to call `Array.prototype.forEach` on this object, so
it had damn well better be a proper array!
Fixes #1167
2019-01-14 14:51:28 -08:00
Alex Crichton
c0ddabcca1
Sanity check exposed_globals
map
...
Make sure that we don't actually try to expose something when they've
already been written, causing an internal tool panic rather than wrong
JS.
2019-01-14 13:09:05 -08:00
lcnr/Bastian Kauschke
6e08f579a6
add temporary test
2019-01-14 21:04:29 +01:00
lcnr/Bastian Kauschke
4e611c318e
fix spawn_local
2019-01-12 17:42:05 +01:00
Alex Crichton
12893183b6
Merge pull request #1164 from alexcrichton/fix-tests
...
Fix and execute wasm-bindgen-wasm-interpreter tests
2019-01-11 18:45:47 -08:00
Alex Crichton
61a6fcfced
Fix and execute wasm-bindgen-wasm-interpreter tests
2019-01-11 13:20:08 -08:00
Richard Dodd
cb8bf9390d
Implement webidl sequences.
2019-01-11 19:14:07 +00:00
Ryan Levick
c056235530
Simply remove the web-sys bindings 'tested' list
2019-01-10 19:06:11 +01:00
Alex Crichton
b04f60cf2b
Bump to 0.2.31
2019-01-09 09:17:50 -08:00
Alex Crichton
f404182c47
Fix a typo
2019-01-07 11:00:15 -08:00
Alex Crichton
9dced1d99b
Merge pull request #1147 from alexcrichton/more-slicing
...
Add conversions between typed arrays and Rust
2019-01-07 12:59:38 -06:00
Alex Crichton
8b0416a0e5
Merge pull request #1155 from derekdreery/fix_dictionaries
...
Make dictionaries use their original text in js
2019-01-07 12:45:15 -06:00
Richard Dodd
8bc9fad103
Fix error
2019-01-07 17:40:42 +00:00
Richard Dodd
3d2efb0dff
Add test to check case of field.
2019-01-07 17:09:10 +00:00
Alex Crichton
194a169c24
Merge pull request #1148 from derekdreery/spawn_local
...
Spawn local
2019-01-07 10:27:44 -06:00
Alex Crichton
fbf000a508
Bump to 0.2.30
2019-01-07 07:47:07 -08:00
Richard Dodd
687fc278a7
Revert previous change.
2019-01-07 14:23:10 +00:00
Richard Dodd
46d4330637
Make dictionaries use their original text in js
2019-01-07 14:15:00 +00:00
Richard Dodd
73913c99f2
Relax bound on Future
2019-01-05 18:10:14 +00:00
Richard Dodd
25ac4549a0
Docs
2019-01-05 14:37:39 +00:00
Richard Dodd
c849ef3cf4
Add naive spawn_local implementation + tests
...
This is just a naive implementation. It seems it can be improved using a
custom task queue, but that can be in a separate PR.
2019-01-05 14:34:50 +00:00
Alex Crichton
2d7f601696
Add conversions between typed arrays and Rust
...
For all typed arrays, this commit adds:
* `TypedArray::view(src: &[Type])`
* `TypedArray::copy_to(&self, dst: &mut [Type])`
The `view` function is unsafe because it doesn't provide any guarantees
about lifetimes or mutability. The `copy_to` function is, however, safe.
Closes #811
2019-01-04 10:42:14 -08:00
Alex Crichton
b4f172899c
Fix order of export/gc
...
We might gc a table away so if we need to export it be sure to do so
before we gc! Additionally remove an extraneous gc that snuck in at some
point, no need to do more than one.
Closes #1130
2019-01-03 11:38:28 -08:00