Commit Graph

339 Commits

Author SHA1 Message Date
Alex Crichton
b2ecf56cb6
Merge pull request #165 from jryans/spans-feature
Add `spans` feature to control `proc-macro2`
2018-04-25 15:23:23 -05:00
J. Ryan Stinnett
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
Alex Crichton
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
Alex Crichton
2b9c48d5f9 Favor if let instead of is_some + unwrap 2018-04-23 11:25:30 -07:00
Alex Crichton
8ae6fe19a3
Merge pull request #153 from FreeMasen/master
include fetch arg for wasm2es6js
2018-04-23 13:23:24 -05:00
robert masen
79a49b2a56 update fetch to take a string parameter 2018-04-23 09:04:30 -05:00
Robert Masen
cbccd2028d include fetch arg for wasm2es6js 2018-04-23 08:41:02 -05:00
Joshua Sheard
0caa6d2ec4
Fix Typescript definition of constructor arguments 2018-04-22 10:57:00 +01:00
Alex Crichton
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
Alex Crichton
4100dc9c53 Recommend installation from crates.io, not git 2018-04-20 19:07:56 -07:00
Alex Crichton
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
Alex Crichton
3b4bf475be Bump to 0.2.5 2018-04-19 18:46:41 -07:00
Alex Crichton
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
Alex Crichton
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
Alex Crichton
f3c05e5339 Fix compat with stable 2018-04-19 14:28:30 -07:00
Alex Crichton
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
Alex Crichton
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
Alex Crichton
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
Alex Crichton
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
Alex Crichton
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
Alex Crichton
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
Alex Crichton
055a8fb803 Bump to 0.2.4 2018-04-18 07:18:11 -07:00
Alex Crichton
7d5f2e4152 Enable the visit feature of syn 2018-04-18 07:16:14 -07:00
Alex Crichton
c74230b4a9 Bump to 0.2.3 2018-04-17 13:07:43 -07:00
Alex Crichton
9a6a15f605 Fix compilation and support on 32-bit targets 2018-04-17 11:42:10 -07:00
Alex Crichton
f80a7067a0 Use a struct instead of a bool variant
Helps it be a bit more readable!
2018-04-17 11:29:03 -07:00
Alex Crichton
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
Alex Crichton
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
Alex Crichton
5efde3abe9 Be sure to generate classes for empty structs
Closes #131
2018-04-16 08:05:18 -07:00
Alex Crichton
f8ecf912c7 Clean up the generated JS a bit 2018-04-16 07:56:55 -07:00
Alex Crichton
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
Alex Crichton
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
konstin
f63635fce9 Fix merge-breakage 2018-04-15 15:36:59 +02:00
konstin
3999642f66 Merge remote-tracking branch 'upstream/master' into new 2018-04-15 01:50:23 +02:00
konstin
770d7365c4 Fix compilation and docs
The compilation part is effectively a cherry pick from master
2018-04-15 01:39:43 +02:00
konstin
f45ce1f239 Do only use ConstructorToken when needed
Also removing some effectively dead code
2018-04-15 01:29:09 +02:00
Alex Crichton
0e6325d833 Overhaul the conversion traits
This commit overhauls the conversion traits used for types crossing the Rust/JS
boundary. Previously there were a few ad-hoc traits but now there've been
slightly reduced and decoupled.

Conversion from Rust values to JS values is now exclusively done through
`IntoWasmAbi` with no special treatment for references. Conversion from JS to
Rust is a bit trickier as we want to create references in Rust which have
implications in terms of safety. As a result there are now three traits for
this, `FromWasmAbi`, `RefFromWasmAbi`, and `RefMutFromWasmAbi`. These three
traits are implemented for various types and specially dispatched to depending
on the type of argument in the code generator.

The goal of this commit is to lay the groundwork for using these traits in
closures with straightforward-ish definitions.
2018-04-14 12:01:07 -07:00
Alex Crichton
9976971e7e Fix CI 2018-04-14 11:34:37 -07:00
konstin
e87b32fb22 Allow arbitratry constructor names 2018-04-14 11:19:17 -07:00
konstin
32ab5a5644 Suppport for javascript constructors
This is a conservative version where the function used for the constructor must be called `new`
2018-04-14 11:19:17 -07:00
Alex Crichton
a8d6ca3d62 Add support for mutable stack closures
This commit adds support for passing `&mut FnMut(..)` to JS via imports. These
closures cannot be invoked recursively in JS (they invalidate themselves while
they're being invoked) and otherwise work the same as `&Fn(..)` closures.

Closes #123
2018-04-14 11:16:16 -07:00
Alex Crichton
3305621012 Overhaul how type information gets to the CLI
This commit is a complete overhaul of how the `#[wasm_bindgen]` macro
communicates type information to the CLI tool, and it's done in a somewhat...
unconventional fashion.

Today we've got a problem where the generated JS needs to understand the types
of each function exported or imported. This understanding is what enables it to
generate the appropriate JS wrappers and such. We want to, however, be quite
flexible and extensible in types that are supported across the boundary, which
means that internally we rely on the trait system to resolve what's what.

Communicating the type information historically was done by creating a four byte
"descriptor" and using associated type projections to communicate that to the
CLI tool. Unfortunately four bytes isn't a lot of space to cram information like
arguments to a generic function, tuple types, etc. In general this just wasn't
flexible enough and the way custom references were treated was also already a
bit of a hack.

This commit takes a radical step of creating a **descriptor function** for each
function imported/exported. The really crazy part is that the `wasm-bindgen` CLI
tool now embeds a wasm interpreter and executes these functions when the CLI
tool is invoked. By allowing arbitrary functions to get executed it's now *much*
easier to inform `wasm-bindgen` about complicated structures of types. Rest
assured though that all these descriptor functions are automatically unexported
and gc'd away, so this should not have any impact on binary sizes

A new internal trait, `WasmDescribe`, is added to represent a description of all
types, sort of like a serialization of the structure of a type that
`wasm-bindgen` can understand. This works by calling a special exported function
with a `u32` value a bunch of times. This means that when we run a descriptor we
effectively get a `Vec<u32>` in the `wasm-bindgen` CLI tool. This list of
integers can then be parsed into a rich `enum` for the JS generation to work
with.

This commit currently only retains feature parity with the previous
implementation. I hope to soon solve issues like #123, #104, and #111 with this
support.
2018-04-14 11:15:28 -07:00
Alex Crichton
eb9a6524b9 Bump to 0.2.2 2018-04-13 07:50:24 -07:00
Alex Crichton
8854936599 Tweak initialization with --no-modules
* Have the global `wasm_bindgen` variable be a function which runs
  initialization rather than exporting an `init` function.
* Save off the wasm object on `wasm_bindgen.wasm` so the memory can be accessed
* Tidy up the code slightly
2018-04-13 07:44:35 -07:00
Alex Crichton
98016324f7 Merge branch 'umd' of https://github.com/csharad/wasm-bindgen 2018-04-13 07:34:27 -07:00
Sharad Chand
85c9f2319c Expose on window.wasm_bindgen 2018-04-13 14:25:27 +05:45
Sharad Chand
ffdb8a6a32 Simplified the preamble 2018-04-12 10:31:13 +05:45
Alex Crichton
b9b8756cd0 Demangle Rust symbols by default 2018-04-11 11:43:18 -07:00
Sharad Chand
aa6487b6f1 panic when modules used 2018-04-11 14:22:20 +05:45
Sharad Chand
8c935d5d94 Change flag to --no-modules 2018-04-11 13:59:58 +05:45
Mark Andrus Roberts
0aef97215c Call fs.readFileSync with __dirname
Node's fs APIs resolve relative paths relative to the current working directory:

https://nodejs.org/api/fs.html#fs_file_paths

This creates a problem if you try to require the wasm-bindgen-generated
JavaScript from a different directory. For example, if you have

  build/foo.js
  build/foo_bg.js
  build/foo_bg.wasm

and another script, script/index.js, that requires build/foo.js. We can instead
use __dirname to get the correct path to the file.
2018-04-09 17:38:22 -07:00
Alex Crichton
656d69816d Move all tests to the same suite
Nowadays the compile times are mitigated with incremental compilation and
otherwise it's much more ergonomic to run only one test if they're all in the
same suite.
2018-04-09 15:32:06 -07:00
Alex Crichton
60ac57331b Bump to 0.2.1 2018-04-09 15:18:39 -07:00
Alex Crichton
a3e5485b86 Add examples/documentation for closures 2018-04-09 14:34:21 -07:00
Alex Crichton
66bdd92fa2 More aggressively gc module
As soon as we've removed unneeded exports immediately run a gc pass to ensure
that we don't bind functions in JS that don't actually end up getting needed.
2018-04-09 14:34:21 -07:00
Alex Crichton
f7f0d578e7 Support long-lived closures
Docs coming soon!
2018-04-09 14:34:21 -07:00
Alex Crichton
28d6c1bc12 Support stack closures with up to 7 arguments 2018-04-09 14:34:21 -07:00
Alex Crichton
c0cad447c1 Initial support for closures
This commit starts wasm-bindgen down the path of supporting closures. We
discussed this at the recent Rust All-Hands but I ended up needing to pretty
significantly scale back the ambitions of what closures are supported. This
commit is just the initial support and provides only a small amount of support
but will hopefully provide a good basis for future implementations.

Specifically this commit adds support for passing `&Fn(...)` to an *imported
function*, but nothing elese. The `&Fn` type can have any lifetime and the JS
object is invalidated as soon as the import returns. The arguments and return
value of `Fn` must currently implement the `WasmAbi` trait, aka they can't
require any conversions like strings/types/etc.

I'd like to soon expand this to `&mut FnMut` as well as `'static` closures that
can be passed around for a long time in JS, but for now I'm putting that off
until later. I'm not currently sure how to implement richer argument types, but
hopefully that can be figured out at some point!
2018-04-09 14:34:21 -07:00
Alex Crichton
a699455f03 Walk the prototype chain looking for descriptors
Looks like this breakage may occur in some scenarios so let's try to
future-proof ourselves!

Closes #109
2018-04-09 06:16:41 -07:00
Sharad Chand
ee1e3abd45 Am an idiot 2018-04-07 13:22:03 +05:45
Sharad Chand
b9192592a9 Updated docopts 2018-04-07 13:17:56 +05:45
Sharad Chand
e8f4b7ed86 Skip window assertions 2018-04-07 13:08:57 +05:45
Sharad Chand
0bd8713bd5 Dropped node support in umd -> amd 2018-04-07 13:06:36 +05:45
Sharad Chand
2b9af53030 wasm is compiled, mod in uncompiled 2018-04-06 12:59:07 +05:45
Sharad Chand
1a428d69da {global} not referenced 2018-04-05 20:30:58 +05:45
Sharad Chand
2877d0bdb6 UMD import added 2018-04-05 19:50:26 +05:45
Sharad Chand
3a83b02de0 Added umd switch 2018-04-04 20:06:53 +05:45
Alex Crichton
9723fdd69b
Merge pull request #100 from sendilkumarn/remove-coder-func
Reduce the JS file size and optimizing encoder and decoder functions
2018-04-04 08:46:36 -05:00
Sendil Kumar N
64d7c8d082
Update lib.rs 2018-04-04 11:27:27 +02:00
Sendil Kumar
9421edaab5 add missed out TextEncoder 2018-04-04 11:22:34 +02:00
Sendil Kumar
6d5afbb3d2 reduce the js file generated code
remove node test for browser test

update usages

revert test-support changes
2018-04-04 11:22:32 +02:00
Alex Crichton
0d1759abd5 Add description to backend crate 2018-04-03 14:02:04 -07:00
Alex Crichton
de3a7e3242 Remove nodejs-checking logic from math exports
Instead create a temporary vector which is used to later invoke the generic
`export` function
2018-04-03 13:29:26 -07:00
Alex Crichton
62e9f580d0 Use Context::export in write_classes
No need to doubly check for `nodejs`
2018-04-03 13:25:10 -07:00
Alex Crichton
23f6049619 Fixup various refactoring issues 2018-04-03 13:20:56 -07:00
Alex Crichton
7f614c3c3a Reduce node/browser duplication
Centralize the export of a function to one location to reduce duplication in
various other locations checking whether Node is being targeted or not.
2018-04-03 13:12:28 -07:00
Alex Crichton
cc11505dc8 Remove an unused unsafe block 2018-04-03 12:53:24 -07:00
Alex Crichton
455e86ef6d Merge branch 'node-math' of https://github.com/ashleygwilliams/wasm-bindgen 2018-04-03 12:53:15 -07:00
Alex Crichton
1ff9ccf072 Tighten up getStringFromWasm a bit
no need for some extra locals here
2018-04-03 12:44:35 -07:00
Alex Crichton
978b5ada63 Tighten up passStringToWasm a bit
Only emit `throw` on debug mode primarily
2018-04-03 12:44:09 -07:00
Alex Crichton
f1e8e2bee0 Remove GLOBAL_ARGUMENT_CNT JS binding
This is easier to manage statically so no need to track it dynamically
2018-04-03 12:38:33 -07:00
Alex Crichton
a805e04a81 Track next_global at codegen time
No need to track it at runtime as we should statically know its value!
2018-04-03 12:24:35 -07:00
Alex Crichton
8e5f5d20fc Remove accidental double braces 2018-04-03 12:24:19 -07:00
Alex Crichton
76cc1ca295 Fix imports of TextEncoder/TextDecoder 2018-04-03 08:09:25 -07:00
Alex Crichton
30b1964255 Bump all crates to 0.2 2018-04-03 07:10:07 -07:00
Alex Crichton
bb2e0c205f
Merge pull request #77 from dflemstr/wasm-construct-js-class
Add support for constructing JsValue instances generically
2018-04-03 16:08:30 +02:00
Alex Crichton
782378e7c0 Update dependencies 2018-04-03 07:07:14 -07:00
David Flemström
540ccfac9d Only generate JS class constructor export if import is needed 2018-04-03 11:28:25 +02:00
Alex Crichton
03433a0ef6 Update to recent WasmBoundary abi changes 2018-04-02 09:59:08 -07:00
David Flemström
73619b5d15 Add support for constructing JsValue instances generically 2018-04-02 09:59:01 -07:00
Alex Crichton
e6a483f906 Hurray for fun with hygiene! 2018-03-31 14:29:47 -07:00
Alex Crichton
f2254628dd Fix a typo 2018-03-31 14:26:00 -07:00
Alex Crichton
9bc2718943 Clean up a bit of duplication in codegen 2018-03-31 09:38:31 -07:00
Alex Crichton
7880545b3b Finish fixing fallout in all tests 2018-03-31 09:15:39 -07:00
Alex Crichton
2880247acf Get the imports test passing 2018-03-31 08:26:20 -07:00
Alex Crichton
cdbb31f3a9 Start removal of vector special-casing
This commit starts wasm-bindgen down a path of removing the special
casing it currently has around vectors, slices, and strings. This has
long been a thorn in wasm-bindgen's side as it doesn't handle other
kinds of vectors and otherwise is very inflexible with future additions.
Additionally it leads to a lot of duplicated-ish code throughout various
portions of codegen.

The fundamental reason for this was that two arguments were required to
be passed back to wasm, and I couldn't figure out a way to shove both
those arguments into a function argument. The new strategy here is that
there is one global stack well known to both JS and Rust which arguments
*may* also be transferred between.

By default all ABI arguments pass as literal function arguments, but if
two or more arguments need to be passed then the extra ones are all
passed through this global stack. The stack is effectively temporary
scratch space when crossing the JS/Rust boundary (both ways). No long
term storage is intended here.

The `simple` test is passing as a result of this commit, using strings
internally. The `Vector` type in the AST has been removed (yay!) and the
bulk of the implementation of slices and vectors now resides in the
`wasm-bindgen` crate itself, defining how to pass all these arguments
around. The JS generator, however, still needs to know about all the
sorts of vectors so it can generate appropriate code for JS.

Future commits will continue cleanup and get the rest of the tests
working.
2018-03-31 07:57:47 -07:00
Alex Crichton
25af16c7d9 Fix an unused mut warning 2018-03-31 02:35:09 -07:00
Corbin Uselton
13520e324b Fix import TextDecoder in output for nodejs config 2018-03-30 10:50:01 -07:00
Alex Crichton
c97df46e08 Remove dummy test in backend 2018-03-29 14:51:00 -07:00
Alex Crichton
4e923445eb Remove executable bits 2018-03-29 14:50:40 -07:00
Alex Crichton
80243acc37 Fix running node tests 2018-03-29 14:49:36 -07:00
Alex Crichton
646df20d70 Fix a typo when running commands 2018-03-29 12:26:42 -07:00
Alex Crichton
afc43174d9
Merge pull request #95 from fitzgen/backend
Split out the AST and codegen into the wasm-bindgen-backend crate
2018-03-29 18:31:38 +02:00
Nick Fitzgerald
0bd54480c6 Split out the AST and codegen into the wasm-bindgen-backend crate 2018-03-29 09:14:32 -07:00
Ashley Williams
3ed363ae39 feat(enum): object.freeze the enum 2018-03-29 17:30:28 +02:00
Nick Fitzgerald
393841779a Rename directories to remove "wasm-bindgen-" prefix in sub-crates 2018-03-29 08:28:25 -07:00
Ashley Williams
ae51c3b6f7 feat(node): support node enums 2018-03-29 17:11:28 +02:00
Ashley Williams
256b34736e feat(node): support node classes 2018-03-29 16:08:50 +02:00
Alex Crichton
a0bfb8103b Generate node.js require directives for --nodejs 2018-03-29 01:47:44 -07:00
Pascal Hertleif
7cc8ef58bd Cli: Fix browser flag 2018-03-28 17:26:46 +02:00
Alex Crichton
28c3fdddf5 Remove --nodejs-runtime-detect
Instead use it by default and add a --browser argument to explicity
remove the shim.

Closes #79
2018-03-28 07:37:56 -07:00
David Flemström
930219fc53 Fix some JS == → === and != → !== occurrences
These are the ones my linter complained about in particular
2018-03-25 12:15:34 +02:00
Alex Crichton
02b7021053 Leverage new rustc wasm features
This commit leverages two new attributes in the Rust compiler,
`#[wasm_custom_section]` and `#[wasm_import_module]`. These two attributes allow
removing a lot of hacks found in wasm-bindgen and also allows removing the
requirement of `wasm-opt` to remove the unused data sections.

This does require two new nightly features but we already required the
`proc_macro` nightly feature and these will hopefully be stabilized before that
feature!
2018-03-24 10:36:19 -07:00
Alex Crichton
d258ea4e2a The schema has definitely changed now 2018-03-22 19:07:20 -07:00
Alex Crichton
7ebc428646 Implement a js_name customization
This'll allow binding multiple signatures of a JS function as well as otherwise
changing the name of the JS function you're calling from the Rust function that
you're defining.

Closes #72
2018-03-22 19:05:14 -07:00
Alex Crichton
30936a6b22 Allow specifying getter/setter properties
Should help with style clashes!
2018-03-22 18:21:41 -07:00
Alex Crichton
8830f540a9 Add a structural bindgen attribute
This attribute indicates that methods are to be accessed in a structural method
rather than through their class. This should allow direct access to properties
embedded on objects rather than forcing all objects to have a class/prototype.
2018-03-22 17:37:27 -07:00
Alex Crichton
0e1fee5ddd Rename namespace to js_namespace
Along the way remove the namespace in Rust as this ended up causing too many
problems, alas! The `js_namespace` attribute now almost exclusively modifies the
JS bindings, hence the "js" in the name now.
2018-03-22 17:03:51 -07:00
Alex Crichton
fc81d8f6d3 Add From/Into JsValue for imported types 2018-03-21 12:37:10 -07:00
Alex Crichton
48b34604cb Add some #[allow] directives to generated code
No need to warn about JS/Rust conventions not lining up!
2018-03-21 10:23:03 -07:00
Alex Crichton
8b3ca9b85c Remove a stray println! 2018-03-21 10:00:07 -07:00
Alex Crichton
4a4f8b18b6 Rename static to namespace
This commit renames the `static` attribute to `namespace` and simultaneously
reduces and expands the scope. The `namespace` attribute can now be applied to
all imports in addition to functions, and it no longer recognizes full typed
paths but rather just a bare identifier. The `namespace` attribute will generate
a Rust namespace to invoke the item through if one doesn't already exist (aka
bindign a type).
2018-03-21 09:55:16 -07:00
Alex Crichton
8e894fcfc5 Implement static imports
This allows importing static objects like `document`, `window`, or an arbitrary
JS object from a module
2018-03-21 08:09:59 -07:00
William Lundstedt
89a00bee29 Support passing custom types by value into JS imports 2018-03-16 00:09:18 +00:00
Alex Crichton
37146395c9 Bump wasm-bindgen-cli-support to 0.1.3 2018-03-14 10:50:46 -07:00
Alex Crichton
8b2f34b51a Zero out descriptor statics
This way postprocessing tools like `wasm-opt` can optimize out the data section
altogether, dropping lots of zeros
2018-03-14 10:50:12 -07:00
Alex Crichton
9825b7a7c9 Bump wasm-bindgen-cli-support to 0.1.2 2018-03-09 16:10:08 -08:00
Alex Crichton
6e75d4777c Fix handling *almost* aligned data globals
Looks like LLD implicitly pads data values with zeros at the end rather than
explicitly listing them, this means that we need to read out the last byte, even
if it's not 4-byte aligned, as it could still represent a wasm-bindgen-generated
32-bit value.
2018-03-09 16:09:07 -08:00
Nick Fitzgerald
92436069bd wasm-bindgen-macro: Formalize building literals with a trait 2018-03-07 16:29:25 -08:00
Nick Fitzgerald
c2e9a4b71e Implement quote::ToTokens for AST types
They were already implemented, just without the formalization ;)
2018-03-07 14:49:40 -08:00
Nick Fitzgerald
9e24dabe9c test-support: Add ability to add new local dependencies to Cargo.toml 2018-03-07 10:06:25 -08:00
Alex Crichton
1a9e031ed0 Bump wasm-bindgen-cli to 0.1.1 2018-03-07 08:52:19 -08:00
Alex Crichton
8296e7feee Bump wasm-bindgen-cli-support to 0.1.1 2018-03-07 08:51:40 -08:00
Alex Crichton
8254d9f516 Add an option to detect node at runtime
Sometimes builds are done once and used in both the browser and in node, so add
an option to do runtime detection if necessary
2018-03-07 08:50:56 -08:00
Alex Crichton
800376010d Bump wasm-bindgen-macro to 0.1.1 2018-03-06 13:50:45 -08:00
Nick Fitzgerald
3ad3123882 Disambiguate generated wrappers 2018-03-06 13:45:44 -08:00
Alex Crichton
46f1b5680f Add the wasm category to wasm-bindgen-cli 2018-03-05 20:28:45 -08:00
Alex Crichton
f58c436f77 Prep work for the 0.1 release 2018-03-05 20:24:35 -08:00
Alex Crichton
98030e0e4a Switch from version strings to schema versions
Should help reduce some churn a bit!
2018-03-05 20:05:44 -08:00
Alex Crichton
1db5b3fb50 Add Travis/AppVeyor deployments 2018-03-05 20:05:39 -08:00
Sendil Kumar
49a7b9fef5 Merge branch 'master' into fix-no-mangle 2018-03-05 23:26:22 +01:00
Sendil Kumar
0dd8a77757 fix: remove unwanted no_mangle and extern wherever applicable 2018-03-05 23:25:15 +01:00
Sendil Kumar
d5ac523fe2 feat: rename generated file to have bg instead of wasm 2018-03-05 22:25:14 +01:00
Alex Crichton
67601c4293 No more need to optimize in dev! 2018-03-04 18:23:23 -08:00
Alex Crichton
d9e1dae298 Migrate from rollup to webpack in tests
Building on the previous commit to invoke not invoke `npm install` this takes
the commit a step further (to hopefully fix some races) to use Webpack's native
bundled wasm support.

It turns out the circular dependencies between the wasm module and the module
using it wasn't quite working out so a number of imports had to be tweaked, but
otherwise it's a nice transition where we don't have to base64 encode anything
in tests any more!
2018-03-02 19:20:14 -08:00
Alex Crichton
353794417c Don't run npm install during tests
Instead add a `package.json` and use `yarn run`.
2018-03-02 15:44:28 -08:00
Alex Crichton
31853ad0ba Require version agreement between CLI and dep
One day may be able to relax this but for now its not tenable!

Closes #47
2018-03-01 19:36:59 -08:00
Alex Crichton
1c8061e675 Implement a version string
Add a `--version` and `-V` to the command to print out the version
2018-03-01 19:19:12 -08:00
Ryan Levick
37da9eba14 Address feedback on commit dab6ba1 2018-02-28 17:29:40 +01:00
Ryan Levick
dab6ba1df8 Enable returning a vector of js values 2018-02-28 10:56:56 +01:00