Commit Graph

1004 Commits

Author SHA1 Message Date
fbb12f519b Bump to 0.2.8 2018-04-30 19:23:44 -07:00
dadcff15ef Add an example of wasm2asm and wasm-bindgen
This commit adds an example of executing the `wasm2asm` tool to generate asm.js
output instead of WebAssembly. This is often useful when supporting older
browsers, such as IE 11, that doesn't have native support for WebAssembly.
2018-04-30 13:29:34 -07:00
6f95e5c531 Print errors to stderr instead of stdout 2018-04-30 13:24:29 -07:00
7cef4a66b8 Merge remote-tracking branch 'alex/master' 2018-04-29 16:38:08 -07:00
befdf07a07 Bump to 0.2.7 2018-04-27 19:48:57 -07:00
4a873af8d1 Enable cargo test where possible
Currently `#[wasm_bindgen]` generates a bunch of references to symbols that
don't actually exist on non-wasm targets, making it more difficult to get a
crate working across multiple platforms. This commit updates the symbol
references to be dummy ones that panic on non-wasm targets to allow simple
testing/benchmarking to work on native targets.

While this isn't a perfect solution for #114 it's probably as good as we can do
for now pending upstream Cargo features, so I'm gonna say that it...

Closes #114
2018-04-27 15:01:35 -07:00
ba03cc3684 Merge pull request #173 from rustwasm/ts-default
Emit `*.d.ts` file by default
2018-04-27 12:40:14 -05:00
89bd10f974 Emit *.d.ts file by default 2018-04-27 07:15:34 -07:00
b8895b3a95 Add JsValue::{from_serde, into_serde}
These functions are activated with the `serde-serialization` feature of the
`wasm-bindgen` crate. When activated they will allow passing any arbitrary value
into JS that implements the `Serialize` trait and receiving any value from JS
using the `Deserialize` trait. The interchange between JS and Rust is JSON.

Closes #96
2018-04-26 20:45:22 -07:00
acb5eac96a Bump to 0.2.6 2018-04-26 19:14:09 -07:00
b7bbcf5ea9 Fix compat with current nightly 2018-04-26 19:12:56 -07:00
6d5ebaf5ac Update parity-wasm and wasmi 2018-04-26 18:42:49 -07:00
412bebca72 Add support for version specifications
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This
information is eventually written into a `__wasm_pack_unstable` section.
Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
2018-04-25 22:23:02 -07:00
d9a71b43db Assert empty JS heap/stack in tests
Turns out there was a bug when passing a vector of `JsValue` instances back to
JS all objects were leaked rather than correctly removed from the global slab.
2018-04-25 22:15:28 -07:00
faed98b843 Correct how slices are iterated over
This commit fixes how the `getArrayJsValueFromWasm` function is defined to
correctly iterate over the slice by looking at the values rather than the
indices.

Closes #169
2018-04-25 21:58:49 -07:00
b2ecf56cb6 Merge pull request #165 from jryans/spans-feature
Add `spans` feature to control `proc-macro2`
2018-04-25 15:23:23 -05:00
11e274b477 Add spans feature to control proc-macro2
Using `proc-macro2`'s `nightly` feature is a good default for most use cases.
However, it causes a build error if used together with crates such as
`cssparser` that also use `proc-macro2` from a build script.

This change adds a default enabled feature `spans` that users can disable if
they need to work around this conflict.

Fixes #160.
2018-04-25 14:42:21 -05:00
5f59d95130 Migrate to the failure crate
Currently errors are reported via Rust panics but there's lots more errors being
added over time so this commit starts the movement towards the `failure` crate
to more idiomatically report errors as well as provide better error messages
over time.
2018-04-25 11:57:17 -07:00
2b9c48d5f9 Favor if let instead of is_some + unwrap 2018-04-23 11:25:30 -07:00
8ae6fe19a3 Merge pull request #153 from FreeMasen/master
include fetch arg for wasm2es6js
2018-04-23 13:23:24 -05:00
79a49b2a56 update fetch to take a string parameter 2018-04-23 09:04:30 -05:00
cbccd2028d include fetch arg for wasm2es6js 2018-04-23 08:41:02 -05:00
0caa6d2ec4 Fix Typescript definition of constructor arguments 2018-04-22 10:57:00 +01:00
4436c0eae6 Avoid invoking a function pointer with JsStatic
The previous codegen wasn't enough to convince LLVM that the function pointer
was a constant value and could be aggressively inlined, so this updates the
`JsStatic` internals slightly to guarantee to LLVM that the function pointer is
constant and no dynamic dispatch is needed after all
2018-04-21 13:14:33 -07:00
4100dc9c53 Recommend installation from crates.io, not git 2018-04-20 19:07:56 -07:00
7108206835 Implement readonly struct fields
Add support for `#[wasm_bindgen(readonly)]` which indicates that an exported
struct field is readonly and attempting to set it in JS will throw an exception.

Closes #151
2018-04-20 10:56:10 -07:00
3b4bf475be Bump to 0.2.5 2018-04-19 18:46:41 -07:00
c6f7d3dfd5 Fix methods returning Self
Rewrite any instance of `Self` to the name of the class

Closes #137
2018-04-19 18:43:37 -07:00
ce31859590 Generate accessors for public struct fields
Automatically infer public struct fields as "JS wants to access this" and
generate appropriate getters/setters for the field. At this time the field is
required to implement `Copy`, but we will probably want to relax that in the
future to at least encompass `JsValue` and maybe other `Clone` values as well.

Closes #121
2018-04-19 16:49:46 -07:00
f3c05e5339 Fix compat with stable 2018-04-19 14:28:30 -07:00
eb73e05b7a Deserialize less to match schema versions
Currently the entire `Program` is deserialized to match schema versions but this
is likely to fail when the schema changes. Instead just deserialize the
schema/version fields, compare those, and if successful go ahead and deserialize
everything.
2018-04-19 13:36:59 -07:00
0ade4b8cac Add a --no-modules-global flag
This can be used to configure the name of the global that's initialized so it's
not unconditionally `wasm_bindgen`.

Closes #145
2018-04-19 13:33:58 -07:00
212703671a No need to expose ptr in TypeScript
This was needed long ago but is no longer needed!

Closes #147
2018-04-19 13:28:50 -07:00
748184ae66 Work with #![no_std] contexts
This commit adds support for both `#![no_std]` in the wasm-bindgen runtime
support (disabled by default with an on-by-default `std` feature). This also
adds support to work and compile in the context of `#![no_std]` crates.

Closes #146
2018-04-19 13:24:30 -07:00
792a8e132e Fix unused variables in generated code
Also deny all warnings in tests to prevent this creeping back in.

Closes #141
2018-04-19 13:16:59 -07:00
45e4983e8c Use self instead of window
That should hopefully get us more compatible with web workers!

Closes #144
2018-04-19 07:20:04 -07:00
055a8fb803 Bump to 0.2.4 2018-04-18 07:18:11 -07:00
7d5f2e4152 Enable the visit feature of syn 2018-04-18 07:16:14 -07:00
c74230b4a9 Bump to 0.2.3 2018-04-17 13:07:43 -07:00
9a6a15f605 Fix compilation and support on 32-bit targets 2018-04-17 11:42:10 -07:00
f80a7067a0 Use a struct instead of a bool variant
Helps it be a bit more readable!
2018-04-17 11:29:03 -07:00
0e032955fb Use a length accessor instead of byteLength
This way we should be naturally compatible with normal JS arrays that get passed
in as well!

Closes #133
2018-04-16 13:50:21 -07:00
efb64b87d4 Extract Rust2Js like Js2Rust was extracted
Along the way clean up a lot of the formatting of the auto-generated code to
make it a bit prettier by default.
2018-04-16 13:31:56 -07:00
5efde3abe9 Be sure to generate classes for empty structs
Closes #131
2018-04-16 08:05:18 -07:00
f8ecf912c7 Clean up the generated JS a bit 2018-04-16 07:56:55 -07:00
d96e7309ad Format generated JS of export shims nicer
Apply a few indents and a few strategic slashes to make it look a bit nicer
2018-04-16 07:56:05 -07:00
c64f178543 Support closures with "rich" arguments
This commit adds support for closures with arguments like strings and such. In
other words, closures passed to JS can now have the same suite of arguments as
all functions that can be exported from Rust, as one might expect!

At this time due to the way trait objects work closures still cannot use types
with references like `&str`, but bare values like `String` or `ImportedType`
should work just fine.

Closes #104
2018-04-16 07:51:51 -07:00
f63635fce9 Fix merge-breakage 2018-04-15 15:36:59 +02:00
3999642f66 Merge remote-tracking branch 'upstream/master' into new 2018-04-15 01:50:23 +02:00
770d7365c4 Fix compilation and docs
The compilation part is effectively a cherry pick from master
2018-04-15 01:39:43 +02:00