Commit Graph

1255 Commits

Author SHA1 Message Date
Alex Crichton
20bcc83b96
Merge pull request #20 from dflemstr/unsupported-exports
Don't panic on unsupported exports
2018-02-12 16:59:53 -06:00
David Flemström
c0f2773c4e Don't panic on unsupported exports
It's most likely safe for us to skip exports that we don't yet
support.  Doing nothing will at least not hurt in those cases.
2018-02-12 17:49:26 -05:00
Alex Crichton
f3c0fc369a Fix compatibility with LLD
Ensure the runtime library is always at least linked as it has important symbols
that we'll use later.
2018-02-10 10:06:56 -08:00
Alex Crichton
75837925e9 Find static descriptions inside data nodes
Right now this library only works if the static description is the entire data
node, but with upcoming LLD support everything will be in one data node. This
updates the logic for finding/parsing the program to search through the entire
data node and also know how big a program description is when it finds it.
2018-02-10 10:05:43 -08:00
Alex Crichton
7f94c662b9
Merge pull request #13 from froydnj/patch-1
small typo tweaks
2018-02-08 13:22:03 -06:00
Nathan Froyd
646e7c92ba
small typo tweaks 2018-02-08 14:09:36 -05:00
Alex Crichton
f49be45a92 Fix a typo for typescript bindings 2018-02-08 10:22:54 -08:00
Alex Crichton
29771b574c Migrate from a macro to an attribute
This commit migrates from `wasm_bindgen!`-the-macro to
`#[wasm_bindgen]`-the-attribute. The actual mechanics of the macro are
relatively simple in just generating some shims here and there, but wrapping
everything in one huge macro invocation can often seem intimidating as it gives
off this feeling of "oh dear anything can happen here!" Using an attribute
should curb expectations much more greatly of "oh there's just some extra stuff
happening behind the scenes".

The usage is otherwise relatively straightforward and close to what it was
before, but check out the DESIGN.md/README.md changes for more info!
2018-02-08 10:18:16 -08:00
Alex Crichton
70614f808e Remove stray mut 2018-02-06 19:14:54 -08:00
Alex Crichton
e9d612a343 Implement optionally catching exceptions 2018-02-06 19:04:12 -08:00
Alex Crichton
43ee52bcbf Change schemes for encoding custom type names
Store JSON a utf-32, map hashes of names to a `char` and store that name
in the map, and then do a reverse mapping when generating JS
2018-02-06 16:56:26 -08:00
Alex Crichton
8312f3ae9f Fix programs with two wasm_bindgen! invocations
Saw the bug coming. Added an assert. Assert tripped. Bug now fixed!
2018-02-06 15:52:44 -08:00
Alex Crichton
2c7c2e7ae1 Cache more objects in generated JS bindings
Cache the `Uint8Array` and `Uint32Array` views into wasm memory as well as the
instances of `TextEncoder` and `TextDecoder`. Should hopefully help cut down on
gc traffic and otherwise convince the engine to keep these as long-lived
objects.
2018-02-06 15:33:17 -08:00
Alex Crichton
ec5f0a29f7 Add a #[wasm_bindgen(constructor)] attribute
This can be used for specifying that a static function should actually delegate
to `new`
2018-02-06 15:25:46 -08:00
Alex Crichton
e60aa6a990 Rename JsObject to JsValue
Let's reserve `JsObject` for something we actually know is an object
2018-02-06 15:04:46 -08:00
Alex Crichton
9de4f1106b
Merge pull request #12 from lukewagner/patch-1
Minor typo fixes and a few wasm links added
2018-02-06 14:55:47 -06:00
Luke Wagner
48db2f4b6e
Minor typo fixes and a few wasm links added 2018-02-06 14:46:50 -06:00
Alex Crichton
aa90715896 Rename free functions to avoid gc'ing too much 2018-02-06 11:54:40 -08:00
Alex Crichton
7384bd1967 Fix some syntax highlighting 2018-02-06 11:48:12 -08:00
Alex Crichton
02abf588d5 Document the current design 2018-02-06 11:44:28 -08:00
Alex Crichton
56b7fa453a Fix some class import methods and auto gc
The runtime functions are now moved to the `wasm-bindgen` crate and are
auto-gc'd if they don't end up actually being required.
2018-02-06 08:58:15 -08:00
Alex Crichton
28966d9853 Fix String type in imports 2018-02-06 08:39:49 -08:00
Alex Crichton
d2f2ed8c1a Get the import-class test working 2018-02-06 08:23:51 -08:00
Alex Crichton
d5ff725913 Greatly simplify handling of types in Rust
Push the compiler to do trait resolution to figure out what each type is bound
with in JS, and that way we can accept effectively all types (so long as they
implement a trait).
2018-02-06 07:56:14 -08:00
Alex Crichton
0320bc0d7c more-wip 2018-02-05 16:39:11 -08:00
Alex Crichton
8f8da49dab wip 2018-02-05 14:24:25 -08:00
Alex Crichton
ec1c263480 Tweak path to rollup for Windows 2018-02-02 08:51:45 -08:00
Alex Crichton
baa144d141 Add a word of warning to wasm2es6js 2018-02-02 08:17:04 -08:00
Alex Crichton
9ac713d4eb Reword intro in README
Not really an exclusive polyfill but moreso nice features too!
2018-02-02 08:14:05 -08:00
Alex Crichton
83a2b314b2 Disable test for lib/doctest, there are none! 2018-02-02 08:10:48 -08:00
Alex Crichton
322f52001e No need to specify port to parcel 2018-01-30 08:06:05 -08:00
Alex Crichton
b75c0354b7 Be a bit more tslint friendly in generated code 2018-01-30 07:58:44 -08:00
Alex Crichton
235bc2957e Tweak typescript option 2018-01-30 07:47:49 -08:00
Alex Crichton
1487288050 Expose typescript option in wasm2es6js 2018-01-30 07:45:36 -08:00
Alex Crichton
89c8621426 Flag free() as returning void 2018-01-30 07:37:25 -08:00
Alex Crichton
5098f97e7d Link to tests in README 2018-01-29 21:54:52 -08:00
Alex Crichton
dac2f2d170 Fix highlighting in README 2018-01-29 21:53:33 -08:00
Alex Crichton
c51a342cb3 Rewrite wasm-bindgen with ES6 modules in mind
This commit is a mostly-rewrite of the `wasm-bindgen` tool. After some recent
discussions it's clear that the previous model wasn't quite going to cut it, and
this iteration is one which primarily embraces ES6 modules and the idea that
this is a polyfill for host bindings.

The overall interface and functionality hasn't changed much but the underlying
technology has now changed significantly. Previously `wasm-bindgen` would emit a
JS file that acted as an ES6 module but had a bit of a wonky interface. It
exposed an async function for instantiation of the wasm module, but that's the
bundler's job, not ours!

Instead this iteration views each input and output as a discrete ES6 module. The
input wasm file is interpreted as "this *should* be an ES6 module with rich
types" and the output is "well here's some ES6 modules that fulfill that
contract". Notably the tool now replaces the original wasm ES6 module with a JS
ES6 module that has the "rich interface". Additionally a second ES6 module is
emitted (the actual wasm file) which imports and exports to the original ES6
module.

This strategy is hoped to be much more amenable to bundlers and controlling how
the wasm itself is instantiated. The emitted files files purely assume ES6
modules and should be able to work as-is once ES6 module integration for wasm is
completed.

Note that there aren't a ton of tools to pretend a wasm module is an ES6 module
at the moment but those should be coming soon! In the meantime a local
`wasm2es6js` hack was added to help make *something* work today. The README has
also been updated with instructions for interacting with this model.
2018-01-29 21:50:01 -08:00
Alex Crichton
f27e4a9e94 Update parity-wasm dependency 2018-01-25 13:32:27 -08:00
Alex Crichton
b38c273ee5 Add an --output-js flag
This'll output just vanilla JS rather than TypeScript!

Closes #8
2018-01-24 19:15:34 -08:00
Alex Crichton
25faad9390
Merge pull request #7 from johannhof/patch-1
Really fix bindings link in README.md
2018-01-20 12:45:39 -06:00
Johann Hofmann
a84f87040d
Really fix bindings link in README.md 2018-01-20 19:20:01 +01:00
Alex Crichton
d8a123306d
Merge pull request #6 from johannhof/patch-1
Fix bindings link in README.md
2018-01-20 11:54:15 -06:00
Johann Hofmann
04a3e596a5
Fix bindings link in README.md 2018-01-20 18:47:44 +01:00
Alex Crichton
9f939d9625
Merge pull request #4 from rillian/typo
Fix typos in the README.
2018-01-15 15:24:44 -08:00
Ralph Giles
5b37523d87 Fix typos in the README. 2018-01-15 15:12:38 -08:00
Alex Crichton
b8292a617a Try to fix Travis 2018-01-08 14:57:00 -08:00
Alex Crichton
28a25ef8b9 Update to released syn/quote verisons 2018-01-08 10:42:01 -08:00
Alex Crichton
5c0f9613f6 Update for syn master 2018-01-02 12:30:47 -08:00
Alex Crichton
b2ce19bd3c Update to master quote 2017-12-31 15:53:29 -08:00