Commit Graph

2010 Commits

Author SHA1 Message Date
T5uku5hi
493130ee36 [examples] dom - port to rust 2018 2018-12-12 00:39:22 +09:00
Alex Crichton
639724a85e
Merge pull request #1100 from elpiel/port-examples-to-rust-2018
Port examples - console-log, closures and duck-typed-interfaces to Rust 2018
2018-12-11 08:53:35 -05:00
Alex Crichton
6eeb54bf9c
Merge pull request #1101 from andrehjr/port-rust-2018-edition-examples-v1
Port examples: add, canvas, char and hello_world to rust 2018 edition examples
2018-12-11 08:52:48 -05:00
LachezarLechev
90ed520394 [examples] closure - remove unnecessary use statement 2018-12-11 14:50:27 +01:00
André Luis Leal Cardoso Junior
c6a9d4851a Remove extra web_sys call 2018-12-11 11:50:25 -02:00
André Luis Leal Cardoso Junior
ceb269b28a run cargo fix --edition-idioms 2018-12-11 08:53:21 -02:00
LachezarLechev
573c14118a [examples] duck-typed-interfaces - port to rust 2018 2018-12-11 08:45:26 +01:00
LachezarLechev
7107a896da [examples] closures - port to rust 2018 2018-12-11 08:39:49 +01:00
LachezarLechev
26737a2888 [examples] console_log - port to rust 2018 2018-12-11 08:37:53 +01:00
André Luis Leal Cardoso Junior
88c8b9059e Add edition 2018 to Cargo.toml 2018-12-10 23:44:59 -02:00
Alex Crichton
3d2f548ce2
Merge pull request #1098 from fitzgen/raf-loop-example
examples: Add a requestAnimationFrame loop example
2018-12-10 14:54:08 -08:00
Nick Fitzgerald
77ddf5ebcd examples: Add a requestAnimationFrame loop example 2018-12-10 12:50:19 -08:00
Alex Crichton
350112a77f
Merge pull request #1096 from rustwasm/dependabot/cargo/rouille-3.0.0
Update rouille requirement from 2.1.0 to 3.0.0
2018-12-10 10:56:47 -08:00
dependabot[bot]
1610d199e3
Update rouille requirement from 2.1.0 to 3.0.0
Updates the requirements on [rouille](https://github.com/tomaka/rouille) to permit the latest version.
- [Release notes](https://github.com/tomaka/rouille/releases)
- [Changelog](https://github.com/tomaka/rouille/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tomaka/rouille/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-10 08:16:06 +00:00
Alex Crichton
7768328fc4
Merge pull request #1084 from David-OConnor/master
Added an --out-name param to the CLI, to allow custom output file names
2018-12-04 23:16:36 -05:00
DavidOConnor
a4bc5049c6 Added an --out-name param to the CLI, to allow custom output file names 2018-12-04 21:35:05 -05:00
Alex Crichton
5665a0e6c0
Merge pull request #1081 from alexcrichton/bump
Bump to 0.2.29
2018-12-04 08:24:14 -06:00
Alex Crichton
63e3ba722d Bump to 0.2.29 2018-12-04 06:04:47 -08:00
Alex Crichton
23f98dbfe0 Try to fix CI examples build 2018-12-03 10:38:55 -08:00
Alex Crichton
a9eb20b4dc
Merge pull request #1080 from tw1t611/fix-todomvc
Fix todomvc
2018-12-03 05:10:09 -06:00
Daniel Schindler
53c65039b9 Change module import 2018-12-03 11:37:30 +01:00
Daniel Schindler
a25925346a Add index.css to build 2018-12-02 21:22:37 +01:00
Alex Crichton
46f70d3630
Merge pull request #1073 from daxpedda/patch-1
Fix typo in "wasm_bindgen::JsCast" trait docs
2018-12-01 13:17:11 -06:00
daxpedda
4105f7988b
Fix typo in "wasm_bindgen::JsCast" trait docs
This method will return `Err(self)` **is** `self.is_instance_of::<T>()` returns `false`
should be
This method will return `Err(self)` **if** `self.is_instance_of::<T>()` returns `false`
2018-12-01 12:22:39 +01:00
Alex Crichton
0e1494f2a6
Merge pull request #1072 from alexcrichton/dense
Ensure our JS heap is a dense array
2018-11-30 16:00:52 -06:00
Alex Crichton
30f52f7608
Merge pull request #1071 from ibaryshnikov/master
fixed link to compiled raytrace-parallel in examples
2018-11-30 15:24:36 -06:00
Alex Crichton
a83c3af4bf Ensure our JS heap is a dense array
Turns out `heap.fill(undefined)` is required to ensure it's a dense
array, otherwise we'll accidentally be a sparse array and much slower
than necessary!
2018-11-30 13:23:41 -08:00
Alex Crichton
29531c0abf Run rustfmt 2018-11-30 13:04:27 -08:00
ibaryshnikov
2cdc45cef7 fixed link to compiled raytrace-parallel in examples 2018-11-30 23:36:27 +03:00
Alex Crichton
13d9e47d17
Merge pull request #1069 from alexcrichton/rejigger-stack
Switch from heap/stack to just a heap
2018-11-30 14:17:54 -06:00
Alex Crichton
49d835a7bc Switch from heap/stack to just a heap
This commit switches strategies for storing `JsValue` from a heap/stack
to just one heap. This mirrors the new strategy for `JsValue` storage
in #1002 and should make multiplexing those strategies at
`wasm-bindgen`-time much easier.

Instead of having one array which acts as a stack for borrowed values
and one array for a heap of borrowed values, only one JS array is used
for storage of JS values now. This makes `getObject` far simpler by
simply being an array access, but it means that cloning an object now
reserves a new slot instead of reference counting it. If the old
reference counting behavior is needed it's thought that `Rc<JsValue>`
can be used in Rust.

The new "heap" has an initial stack pointer which grows downwards, and a
heap which grows upwards. The heap is a singly-linked-list which is
allocated/deallocated from. The stack grows downwards to zero and
presumably starts generating errors once it underflows. An initial stack
size of 32 is chosen as that should encompass all use cases today, but
we can eventually probably add configuration for this!

Note that the heap is initialized to all `null` for the stack and then
the initial JS values (`undefined`, `null`, `true`, `false`) are pushed
onto the heap in reserved locations.
2018-11-30 12:07:16 -08:00
Alex Crichton
e746ad5a0a
Merge pull request #1070 from tw1t611/fix-todomvc
Add #[wasm_bindgen(start)], plugins to webpack config, Update deps
2018-11-30 11:57:23 -06:00
Daniel Schindler
caac2eba53 Add #[wasm_bindgen(start)], plugins to webpack config, Update deps 2018-11-30 17:42:36 +01:00
Alex Crichton
89e245bddf
Merge pull request #1068 from alexcrichton/defer-expose
Defer exposing methods until they're needed
2018-11-29 22:57:25 -06:00
Alex Crichton
07b148789d Defer exposing methods until they're needed
Previously `catch` and `variadic` would exopse methods in our JS shims,
but they did so earlier than necessary. Turns out `variadic` didn't
actually need to expose anything and `catch` could do so much later!
2018-11-29 17:50:13 -08:00
Sendil Kumar N
fbad34a4cb
Merge pull request #1064 from alexcrichton/wasm2es6js-imports
wasm2es6js: Fix handling of exported imports
2018-11-30 01:01:45 +01:00
Alex Crichton
91e9495805
Merge pull request #1065 from alexcrichton/describe-closures
Move closure shims into the descriptor
2018-11-29 17:30:58 -06:00
Alex Crichton
5f966c5a8f
Merge pull request #1063 from alexcrichton/wasm2es6js-start
wasm2es6js: Fix handling of start function
2018-11-29 17:30:24 -06:00
Alex Crichton
2bd9c0eafb
Merge pull request #1067 from alexcrichton/minor-tweaks
A few minor CLI tweaks during work on #1002
2018-11-29 15:16:14 -06:00
Alex Crichton
0ebd267170
Merge pull request #1066 from alexcrichton/remove-unused
Remove an unused crate from wasm-bindgen-webidl
2018-11-29 14:47:04 -06:00
Alex Crichton
42053ddd4e Move closure shims into the descriptor
Currently closure shims are communicated to JS at runtime, although at
runtime the same constant value is always passed to JS! More pressing,
however, work in #1002 requires knowledge of closure descriptor indices
at `wasm-bindgen` time which is not currently known.

Since the closure descriptor shims and such are already constant values,
this commit moves the descriptor function indices into the *descriptor*
for a closure/function pointer. This way we can learn about these values
at `wasm-bindgen` time instead of only knowing them at runtime.

This should have no semantic change on users of `wasm-bindgen`, although
some closure invocations may be slightly speedier because there's less
arguments being transferred over the boundary. Overall though this will
help #1002 as the closure shims that the Rust compiler generates may not
be the exact ones we hand out to JS, but rather wrappers around them
which do `anyref` business things.
2018-11-29 12:42:44 -08:00
Alex Crichton
430fce7a8b Enable env_logger for the wasm-bindgen CLI tool
This was intended earlier, but fogotten! Found during work on #1002
2018-11-29 12:25:24 -08:00
Alex Crichton
82bfbf9d20 Add more context to a wasm-bindgen-test-runner error
Minor cleanup I found during #1002
2018-11-29 12:25:10 -08:00
Alex Crichton
167274c9b4 Remove an unused crate from wasm-bindgen-webidl
Apparently this is no longer needed according to rustc!
2018-11-29 12:22:54 -08:00
Alex Crichton
b4171d0bb2 wasm2es6js: Fix handling of exported imports
This commit fixes a case in `wasm2es6js` where if an imported function
was reexported it wasn't handled correctly. This doesn't have a direct
test but came up during the development of #1002
2018-11-29 11:56:12 -08:00
Alex Crichton
522e973694 wasm2es6js: Fix handling of start function
This is split out from #1002 and is intended to fix the tool's handling
of the `start` function. For the most accurate emulation of the wasm ESM
spec I believe we need to defer execution of the start function until
all our exports are wired up which should allow valid cyclical
references during instantiation.

The fix here is to remove the start function, if one is present, and
inject an invocation of it at the end of initialization (after our
exports are wired up). This fixes tests on #1002, but doesn't have any
direct analogue for tests here just yet.

Along the way because multiple files now come out of `wasm2es6js` by
default I've added an `--out-dir` argument as well as `-o` to ensure
that a folder for all outputs can be specified.
2018-11-29 11:52:23 -08:00
Alex Crichton
bbde39fe66
Merge pull request #1060 from dbrgn/patch-1
Fix typo in wasm-bindgen-test usage docs
2018-11-29 10:53:52 -06:00
Danilo Bargen
fdf201a8f1
Fix typo in wasm-bindgen-test usage docs 2018-11-29 17:47:07 +01:00
Alex Crichton
ed24a63aae
Merge pull request #1057 from alexcrichton/start
Add a `#[wasm_bindgen(start)]` attribute
2018-11-29 00:11:43 -06:00
Alex Crichton
a2aa28e4d3 Add a #[wasm_bindgen(start)] attribute
This commit adds a new attribute to `#[wasm_bindgen]`: `start`. The
`start` attribute can be used to indicate that a function should be
executed when the module is loaded, configuring the `start` function of
the wasm executable. While this doesn't necessarily literally configure
the `start` section, it does its best!

Only one crate in a crate graph may indicate `#[wasm_bindgen(start)]`,
so it's not recommended to be used in libraries but only end-user
applications. Currently this still must be used with the `crate-type =
["cdylib"]` annotation in `Cargo.toml`.

The implementation here is somewhat tricky because of the circular
dependency between our generated JS and the wasm file that we emit. This
circular dependency makes running initialization routines (like the
`start` shim) particularly fraught with complications because one may
need to run before the other but bundlers may not necessarily respect
it. Workarounds have been implemented for various emission strategies,
for example calling the start function directly after exports are wired
up with `--no-modules` and otherwise working around what appears to be
a Webpack bug with initializers running in a different order than we'd
like. In any case, this in theory doesn't show up to the end user!

Closes #74
2018-11-28 22:11:15 -08:00