Commit Graph

1650 Commits

Author SHA1 Message Date
73619b5d15 Add support for constructing JsValue instances generically 2018-04-02 09:59:01 -07:00
e6a483f906 Hurray for fun with hygiene! 2018-03-31 14:29:47 -07:00
f2254628dd Fix a typo 2018-03-31 14:26:00 -07:00
9bc2718943 Clean up a bit of duplication in codegen 2018-03-31 09:38:31 -07:00
7880545b3b Finish fixing fallout in all tests 2018-03-31 09:15:39 -07:00
2880247acf Get the imports test passing 2018-03-31 08:26:20 -07:00
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
25af16c7d9 Fix an unused mut warning 2018-03-31 02:35:09 -07:00
13520e324b Fix import TextDecoder in output for nodejs config 2018-03-30 10:50:01 -07:00
c97df46e08 Remove dummy test in backend 2018-03-29 14:51:00 -07:00
4e923445eb Remove executable bits 2018-03-29 14:50:40 -07:00
80243acc37 Fix running node tests 2018-03-29 14:49:36 -07:00
646df20d70 Fix a typo when running commands 2018-03-29 12:26:42 -07:00
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
0bd54480c6 Split out the AST and codegen into the wasm-bindgen-backend crate 2018-03-29 09:14:32 -07:00
3ed363ae39 feat(enum): object.freeze the enum 2018-03-29 17:30:28 +02:00
393841779a Rename directories to remove "wasm-bindgen-" prefix in sub-crates 2018-03-29 08:28:25 -07:00
ae51c3b6f7 feat(node): support node enums 2018-03-29 17:11:28 +02:00
256b34736e feat(node): support node classes 2018-03-29 16:08:50 +02:00
a0bfb8103b Generate node.js require directives for --nodejs 2018-03-29 01:47:44 -07:00
7cc8ef58bd Cli: Fix browser flag 2018-03-28 17:26:46 +02:00
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
930219fc53 Fix some JS == → === and != → !== occurrences
These are the ones my linter complained about in particular
2018-03-25 12:15:34 +02:00
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
d258ea4e2a The schema has definitely changed now 2018-03-22 19:07:20 -07:00
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
30936a6b22 Allow specifying getter/setter properties
Should help with style clashes!
2018-03-22 18:21:41 -07:00
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
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
fc81d8f6d3 Add From/Into JsValue for imported types 2018-03-21 12:37:10 -07:00
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
8b3ca9b85c Remove a stray println! 2018-03-21 10:00:07 -07:00
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
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
89a00bee29 Support passing custom types by value into JS imports 2018-03-16 00:09:18 +00:00
37146395c9 Bump wasm-bindgen-cli-support to 0.1.3 2018-03-14 10:50:46 -07:00
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
9825b7a7c9 Bump wasm-bindgen-cli-support to 0.1.2 2018-03-09 16:10:08 -08:00
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
92436069bd wasm-bindgen-macro: Formalize building literals with a trait 2018-03-07 16:29:25 -08:00
c2e9a4b71e Implement quote::ToTokens for AST types
They were already implemented, just without the formalization ;)
2018-03-07 14:49:40 -08:00
9e24dabe9c test-support: Add ability to add new local dependencies to Cargo.toml 2018-03-07 10:06:25 -08:00
1a9e031ed0 Bump wasm-bindgen-cli to 0.1.1 2018-03-07 08:52:19 -08:00
8296e7feee Bump wasm-bindgen-cli-support to 0.1.1 2018-03-07 08:51:40 -08:00
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
800376010d Bump wasm-bindgen-macro to 0.1.1 2018-03-06 13:50:45 -08:00
3ad3123882 Disambiguate generated wrappers 2018-03-06 13:45:44 -08:00
46f1b5680f Add the wasm category to wasm-bindgen-cli 2018-03-05 20:28:45 -08:00
f58c436f77 Prep work for the 0.1 release 2018-03-05 20:24:35 -08:00
98030e0e4a Switch from version strings to schema versions
Should help reduce some churn a bit!
2018-03-05 20:05:44 -08:00