Commit Graph

1991 Commits

Author SHA1 Message Date
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
Alex Crichton
f4c1c64078
Merge pull request #1055 from alexcrichton/strict
Assert all attributes are used by default
2018-11-28 13:43:04 -06:00
Alex Crichton
c8a352189b Assert all attributes are used by default
This commit implements a system that will assert that all
`#[wasm_bindgen]` attributes are actually used during compilation. This
should help ensure that we don't sneak in stray attributes that don't
actually end up having any meaning, and hopefully make it a bit easier
to learn `#[wasm_bindgen]`!
2018-11-28 11:42:48 -08:00
Alex Crichton
e3b628689f
Merge pull request #1053 from alexcrichton/dts-wasm
Generate a `*.d.ts` file for wasm files
2018-11-27 16:55:25 -06:00
Alex Crichton
d54340e5a2
Merge pull request #1051 from alexcrichton/extern
Consistently use `extern "C"`
2018-11-27 16:55:15 -06:00
Alex Crichton
047c41c1ec Generate a *.d.ts file for wasm files
This generates a `*.d.ts` file for the wasm file that wasm-bindgen emits
whenever typescript is enable *in addition* to the `*.d.ts` file that
already exists for the JS shim.

Closes #1040
2018-11-27 12:36:55 -08:00
Alex Crichton
151ed58b69 Consistently use extern "C"
This is what rustfmt favors, so let's favor it too!

Closes #1042
2018-11-27 12:27:00 -08:00
Alex Crichton
48f4adfa8c Run rustfmt over everything 2018-11-27 12:07:59 -08:00
Alex Crichton
4a70198143
Merge pull request #997 from jonathanKingston/todo-clean
Remove compiler warnings in todo example
2018-11-27 11:52:47 -06:00
Alex Crichton
6fd33a73fd
Merge pull request #1044 from ibaryshnikov/dom-example-without-bundlers
Added web-sys dom example withot npm and webpack
2018-11-27 11:52:00 -06:00
ibaryshnikov
873898e6c0 updated no_modules example to show web-sys usage 2018-11-27 14:44:57 +01:00
Alex Crichton
a202f1cd1f
Merge pull request #1048 from tcr/master
Adds support for #[wasm_bindgen(typescript_custom_section)].
2018-11-26 16:48:38 -06:00
Jonathan Kingston
d59716ba5b Remove compiler warnings in todo example, simplify usage of elements into element.rs and fix a bug with focus not working on edit. 2018-11-25 00:29:28 +00:00
Tim Ryan
90193eab51 Adds support for #[wasm_bindgen(typescript_custom_section)]. 2018-11-24 00:49:28 -05:00
Sendil Kumar N
fc0d6528fc
Merge pull request #1047 from RReverser/patch-1
Fix variable name reference for path_or_module
2018-11-22 21:43:39 +01:00
Ingvar Stepanyan
26f1903bee
Fix variable name reference for path_or_module 2018-11-22 18:26:37 +00:00
Alex Crichton
4e4a273f19
Merge pull request #1045 from mstange/mstange-fix-bindgn-typo
Fix typo: wasm-bindgn -> wasm-bindgen
2018-11-22 09:44:14 -06:00
Markus Stange
4c44f7d2db
Fix typo: wasm-bindgn -> wasm-bindgen 2018-11-22 10:34:31 -05:00
Alex Crichton
091eaa66f3
Merge pull request #1041 from alexcrichton/producers-sectino
Add `wasm-bindgen` to the producers section
2018-11-20 11:35:19 -06:00
Alex Crichton
6f1e3c8135 Add wasm-bindgen to the producers section
Recently proposed in WebAssembly/tool-conventions#65 each wasm file will
now have an optional `producers` section listing the tooling that went
into producing it. Let's add `wasm-bindgen` in when it processes a wasm
file!
2018-11-19 15:52:58 -08:00