Commit Graph

2199 Commits

Author SHA1 Message Date
f49be45a92 Fix a typo for typescript bindings 2018-02-08 10:22:54 -08:00
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
70614f808e Remove stray mut 2018-02-06 19:14:54 -08:00
e9d612a343 Implement optionally catching exceptions 2018-02-06 19:04:12 -08:00
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
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
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
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
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
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
48db2f4b6e Minor typo fixes and a few wasm links added 2018-02-06 14:46:50 -06:00
aa90715896 Rename free functions to avoid gc'ing too much 2018-02-06 11:54:40 -08:00
7384bd1967 Fix some syntax highlighting 2018-02-06 11:48:12 -08:00
02abf588d5 Document the current design 2018-02-06 11:44:28 -08:00
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
28966d9853 Fix String type in imports 2018-02-06 08:39:49 -08:00
d2f2ed8c1a Get the import-class test working 2018-02-06 08:23:51 -08:00
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
0320bc0d7c more-wip 2018-02-05 16:39:11 -08:00
8f8da49dab wip 2018-02-05 14:24:25 -08:00
ec1c263480 Tweak path to rollup for Windows 2018-02-02 08:51:45 -08:00
baa144d141 Add a word of warning to wasm2es6js 2018-02-02 08:17:04 -08:00
9ac713d4eb Reword intro in README
Not really an exclusive polyfill but moreso nice features too!
2018-02-02 08:14:05 -08:00
83a2b314b2 Disable test for lib/doctest, there are none! 2018-02-02 08:10:48 -08:00
322f52001e No need to specify port to parcel 2018-01-30 08:06:05 -08:00
b75c0354b7 Be a bit more tslint friendly in generated code 2018-01-30 07:58:44 -08:00
235bc2957e Tweak typescript option 2018-01-30 07:47:49 -08:00
1487288050 Expose typescript option in wasm2es6js 2018-01-30 07:45:36 -08:00
89c8621426 Flag free() as returning void 2018-01-30 07:37:25 -08:00
5098f97e7d Link to tests in README 2018-01-29 21:54:52 -08:00
dac2f2d170 Fix highlighting in README 2018-01-29 21:53:33 -08:00
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
f27e4a9e94 Update parity-wasm dependency 2018-01-25 13:32:27 -08:00
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
25faad9390 Merge pull request #7 from johannhof/patch-1
Really fix bindings link in README.md
2018-01-20 12:45:39 -06:00
a84f87040d Really fix bindings link in README.md 2018-01-20 19:20:01 +01:00
d8a123306d Merge pull request #6 from johannhof/patch-1
Fix bindings link in README.md
2018-01-20 11:54:15 -06:00
04a3e596a5 Fix bindings link in README.md 2018-01-20 18:47:44 +01:00
9f939d9625 Merge pull request #4 from rillian/typo
Fix typos in the README.
2018-01-15 15:24:44 -08:00
5b37523d87 Fix typos in the README. 2018-01-15 15:12:38 -08:00
b8292a617a Try to fix Travis 2018-01-08 14:57:00 -08:00
28a25ef8b9 Update to released syn/quote verisons 2018-01-08 10:42:01 -08:00
5c0f9613f6 Update for syn master 2018-01-02 12:30:47 -08:00
b2ce19bd3c Update to master quote 2017-12-31 15:53:29 -08:00
0b81185c99 Expose primitive information about JsObject
Adds bindings for wbindgen to fill in via JS bindings to read the various
primitive properties of a JS value.
2017-12-31 15:45:47 -08:00
996c296de8 Disable incremental for tests
Seems buggy?
2017-12-31 14:48:56 -08:00
4151461ab9 Expose construction of a JsObject as a string
Start fleshing out the `JsObject` API!
2017-12-31 14:44:44 -08:00
8ba64bab68 Update to syn master 2017-12-31 14:40:57 -08:00
e03ef1c2a4 Enable wasm-bindgen -h
Closes #3
2017-12-27 07:50:43 -08:00
c0e2cb3ac8 Merge pull request #2 from fschutt/master
Remove synom
2017-12-27 09:18:42 -06:00