Commit Graph

252 Commits

Author SHA1 Message Date
1d0c333a2b Run cargo fmt over all code 2019-08-12 11:28:37 -07:00
50683f0c3c Removed unnecessary dereference in Store::find
Prefer no dereference when it is not needed.
`todo` has type `&&Item`. Argument needs to be `&Item`, but this is converted via deref coercion.
2019-08-06 20:34:39 -07:00
af922fb670 Fixup styling in sync_local_storage
- `storage_string` is already a `JsString`, calling `to_string` is redundant

- `as_str` is not required, so it is more idiomatic to just use a borrow.
2019-08-06 09:27:09 -07:00
fffcc5ef35 Makes code clearing by providing code symmetry.
```            
child.push(&JsValue::from(&item.title));
child.push(&JsValue::from(item.completed));
child.push(&JsValue::from(&item.id));
```
Parallel syntax makes it easier to see that each iteration intends to push each of `item`'s fields to `child`.
2019-08-05 23:16:53 -07:00
09b37b4a43 Removed unnecessary and confusing clone of String 2019-08-05 22:59:53 -07:00
0dbf4294c2 Merge pull request #1702 from UnHumbleBen/patch-2
Fixes description of Closure lifetime in comments.
2019-08-05 10:15:23 -05:00
89067c1ddf Updated description for single closure 2019-08-04 20:22:41 -07:00
af4622ff3d Fixes description of Closure lifetime in comments. 2019-08-04 11:01:13 -07:00
b978531536 Use idiomatic syntax of Rc::clone() 2019-08-03 19:52:14 -07:00
8cb792474c Fully update threading support for LLVM 9
Support has landed in rust-lang/rust for full support for LLVM 9's
interpretation of WebAssembly threads. This commit updates our thread
transformation pass to take all this into account, namely:

* The threadign pass now runs by default and is keyed on whether memory
  is shared, not off an env var.
* TLS is initialized in addition to memory on each thread.
* Stack pointer finding is tweaked to account for the TLS base also
  being a mutable global.
* The build of the parallel raytrace example was updated to use today's
  nightly.
2019-07-30 09:17:23 -07:00
9f77f8dd00 Update parallel raytrace example to use futures
Use the atomics support now implemented!
2019-07-18 10:13:34 -07:00
6ab1a49a41 moved lib.rs to stable.rs in wasm-bindgen-futures, updated during review 2019-07-17 00:58:05 +03:00
16c6bdc966 moved threadsafe futures implementation to a separate file, made updates after review 2019-07-17 00:48:00 +03:00
e596ef596c Bump to 0.2.48 2019-07-11 15:02:39 -07:00
92a464d48e Updating a couple examples 2019-06-25 21:42:20 +02:00
b601c3fb2e Revert add example to what was originally intended
Remove stray debugging code added in the meantime.
2019-06-25 04:51:52 -07:00
e0ef329e17 Merge pull request #1594 from alexcrichton/webidl-for-realz
Second large refactor for WebIDL bindings
2019-06-25 08:21:24 +02:00
04aea4e9ab Use view instead of subarray in WebGL example
Pointed out in #1615!
2019-06-23 08:29:47 -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
d71ab78fc6 Bump to 0.2.47 2019-06-19 11:14:37 -07:00
8fc0a38402 Bump to 0.2.46 2019-06-14 11:44:58 -07: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
8ace8287ff added default module path inside init function when target is web 2019-06-08 01:27:35 +03:00
81fbc642f4 Don't pass strings in raytrace-parallel example
Make sure to explicitly parse strings to numbers
2019-06-05 07:52:14 -07:00
82467f9793 Use dyn with all trait objects
Fixes new warnings showing up on nightly nowadays.
2019-06-03 08:28:55 -07:00
cbedf0bba0 added websockets example to the guide 2019-06-01 16:17:50 +03:00
6825da384f added websockets example 2019-06-01 15:40:32 +03:00
546f65e2f3 chore: bump again 2019-05-29 17:37:37 +01:00
e65791d5c1 fix: remove css modification 2019-05-29 17:10:43 +01:00
f63238ee24 chore: update wasm-pack-plugin to 0.4.1 2019-05-29 17:09:26 +01:00
f3ec734310 docs: update docs link 2019-05-26 16:43:00 +09:00
137bbdf2e3 Bump to 0.2.45 2019-05-20 09:44:03 -07:00
773c6ff430 Bump to 0.2.44 2019-05-16 07:47:23 -07:00
98de4d7098 Update webpack.config.js 2019-05-01 17:43:50 +02:00
f2429be07f Bump to 0.2.43 2019-04-29 08:28:41 -07:00
cd7aa717c5 Merge pull request #1467 from RReverser/tuple-structs
Generate bindings for indexed struct properties
2019-04-26 09:21:36 -05:00
03299a73b4 Fix raytrace example by using an older nightly
Unfortunately xargo is currently broken against master Rust, so let's
pin to an older nightly while that's sorted out
2019-04-25 19:47:59 -07:00
a0a3a1446d Include props usage in exported_types example 2019-04-24 20:30:31 +01:00
df6e15e3ab Bump to 0.2.42 2019-04-11 07:39:45 -07:00
02394724ea Bump to 0.2.41 2019-04-10 10:53:32 -07:00
b6d041e4d5 Remove debugging code accidentally added in #1416 2019-04-08 07:49:58 -07:00
44738e049a Add warnings about UTF-16 vs UTF-8 strings
This commit aims to address #1348 via a number of strategies:

* Documentation is updated to warn about UTF-16 vs UTF-8 problems
  between JS and Rust. Notably documenting that `as_string` and handling
  of arguments is lossy when there are lone surrogates.

* A `JsString::is_valid_utf16` method was added to test whether
  `as_string` is lossless or not.

The intention is that most default behavior of `wasm-bindgen` will
remain, but where necessary bindings will use `JsString` instead of
`str`/`String` and will manually check for `is_valid_utf16` as
necessary. It's also hypothesized that this is relatively rare and not
too performance critical, so an optimized intrinsic for `is_valid_utf16`
is not yet provided.

Closes #1348
2019-04-05 08:11:50 -07:00
faf49c7d56 Reorganize the import_js example 2019-03-25 13:49:29 -07:00
6803c619bb Bump to 0.2.40 2019-03-21 17:08:48 -07:00
629a19b8de Bring back accidentally deleted raytrace build script 2019-03-21 14:32:27 -07:00
995be7c027 Replace target flags with --target
This commit deprecates the `--web`, `--no-modules`, and `--nodejs` flags
in favor of one `--target` flag. The motivation for this commit is to be
consistent between `wasm-bindgen` and `wasm-pack` so documentation for
one is applicable for the other (so we don't have to document everywhere
what the translation is between flags). Additionally this should make it
a bit easier to add new targets (if necessary) in the future as it won't
add to the proliferation of flags.

For now the old flags (like `--web`) continue to be accepted, but
they'll be removed during the next set of breaking changes for
`wasm-bindgen`.
2019-03-21 14:00:33 -07:00
1e98f6b0dd Use wasm-pack build --target web for without-a-bundler example 2019-03-21 13:55:25 -07:00
185c2b66fa Import correct functions 2019-03-14 23:28:18 +01:00
228f58dca3 Bump to 0.2.39 2019-03-13 11:02:27 -07:00
daad58f9b3 simplified webgl example 2019-03-10 17:40:02 +03:00