Commit Graph

375 Commits

Author SHA1 Message Date
Alex Crichton
133706fc5c Remove debug sections by default
The changes on master Rust insert debug sections now (yay!) but this means that
wasm binaries by default pick up debug sections from the standard library, so
let's remove them by default in wasm-bindgen unless `--debug` is passed
2018-07-13 08:12:12 -07:00
Stephan Wolski
5520da1ef6
webidl: update enum test to unwrap constructor results
Update the enum test to match the new constructor return values
2018-07-11 16:17:56 -04:00
Stephan Wolski
fac73a2ea4
webidl: make from_js_value visible for enums
Make from_js_value match the visibility of the enum it's associated with
2018-07-11 15:36:41 -04:00
Stephan Wolski
4c7b130872
Merge branch 'master' into feat/basic-enum-support 2018-07-11 15:34:00 -04:00
Nick Fitzgerald
f8949acbe0
Merge pull request #457 from fitzgen/turn-throws-extended-attribute-into-catch
webidl: Turn the `[Throws]` extended attributes into `Result<T, JsValue>`
2018-07-11 11:37:57 -07:00
Nick Fitzgerald
3cdb6ef03a webidl: Turn the [Throws] extended attributes into Result<T, JsValue>
This sets the `catch` flag on the emitted AST when an operation/attribute has
the `[Throws]` extended attribute on it.

Additionally, constructors aren't annotated with `[Throws]` but can still throw
exceptions, so we must conservatively assume *every* constructor can throw an
error.
2018-07-11 11:07:03 -07:00
Michael Hoffmann
77b86f481e Add helper function to preconfigure project for web-sys (#455) 2018-07-11 09:27:27 -05:00
Stephan Wolski
6608828d72
webidl: use JSValue::from in IntoWasmAbi for enums 2018-07-10 20:28:34 -04:00
Stephan Wolski
c56b1b0189
webidl: replace From trait with from_js_value method for enums
* Remove From<JSValue> for ENUM
* Add `from_js_value` method which returns an Option<ENUM>
2018-07-10 20:28:34 -04:00
Stephan Wolski
a981dfd507
webidl: initial enum support
Add enum support to the WebIDL interface generator.
2018-07-10 20:28:34 -04:00
Nick Fitzgerald
eabbe0e56e
Merge pull request #452 from brisad/add-fetch-api-response
Add Response interface part of fetch API
2018-07-10 15:22:12 -07:00
Michael Hoffmann
717e260a99 Add Response interface part of fetch API 2018-07-10 23:49:14 +02:00
Nick Fitzgerald
92dd8e859f Move webidl tests to the webidl crate's test suite (#451)
* webidl: Remove exact-output tests

These have not been as effective, nor as easy to write and maintain, as the
project()-based integration tests.

* tests: Move webidl tests into the webidl crate's test suite
2018-07-10 16:17:33 -05:00
Robert Masen
1d826e96de fix reformatting for new syntax 2018-07-10 08:42:35 -05:00
Robert Masen
c7d98b9ee1 add js doc @param and @returns annotations 2018-07-10 08:42:34 -05:00
Nick Fitzgerald
f2f2d7231a
Create the web-sys crate mechanically from WebIDL (#409)
* Create a new `web-sys` crate

This will eventually contain all the WebIDL-generated bindings to Web APIs.

* ci: Test the new `web-sys` crate in CI

* web-sys: Add a small README

* web-sys: Vendor all the WebIDL files from mozilla-central

* backend: Add a pass to remove AST items that use undefined imports

This is necessary for the WebIDL frontend, which can't translate many WebIDL
constructs into equivalent wasm-bindgen AST things yet. It lets us make
incremental progress: we can generate bindings to methods we can support right
now even though there might be methods on the same interface that we can't
support yet.

* webidl: Add a bunch of missing semicolons

* webidl: Make parsing private

It was only `pub` so that we could test it, but we ended up moving towards
integration tests rather than unit tests that assert particular ASTs are parsed
from WebIDL files.

* webidl: Remove uses of undefined import types

* test-project-builder: Build projects in "very verbose" mode

This helps for debugging failing WebIDL-related tests.

* test-project-builder: Add more profiling timers

* test-project-builder: Detect when webpack-dev-server fails

Instead of going into an infinite loop, detect when webpack-dev-server fails to
start up and early exit the test.

* webidl: Specify version for dev-dependency on wasm-bindgen-backend

Instead of only a relative path.

* guide: Add section about contributing to `web-sys`

* WIP enable Event.webidl

Still need to fix and finish the test.

* Update expected webidl output

* Start out a test's status as incomplete

That way if we don't fill it in the error message doesn't look quite so bizarre

* Fix onerror function in headless mode

Otherwise we don't see any output!

* Fix package.json/node_modules handling in project generation

Make sure these are looked up in the git project root rather than the crate root

* Avoid logging body text

This was meant for debugging and is otherwise pretty noisy

* Fix a relative path

* More expected test fixes

* Fix a typo

* test-project-builder: Allow asynchronous tests

* webidl: Convert [Unforgeable] attributes into `#[wasm_bindgen(structural)]`

Fixes #432

* test-project-builder: Print generated WebIDL bindings for debugging purposes

Helps debug bad WebIDL bindings generation inside tests.

* When we can't find a descriptor, say which one can't be found

This helps when debugging things that need to become structural.

* web-sys: Test bindings for Event

* ci: Use `--manifest-path dir` instead of `cd dir && ...`

* web-sys: Just move .webidl files isntead of symlinking to enable them

* tests: Polyfill Array.prototype.values for older browsers in CI

* test-project-builder: Don't panic on poisoned headless test mutex

We only use it to serialize headless tests so that we don't try to bind the port
concurrently. Its OK to run another headless test if an earlier one panicked.

* JsValue: Add {is,as}_{object,function} methods

Allows dynamically casting values to `js::Object` and `js::Function`.

* tidy: Fix whitespace and missing semicolons

* Allow for dynamic feature detection of methods

If we create bindings to a method that doesn't exist in this implementation,
then it shouldn't fail until if/when we actually try and invoke that missing
method.

* tests: Do feature detection in Array.prototype.values test

* Add JsValue::{is_string, as_js_string} methods

And document all the cast/convert/check methods for js value.

* eslint: allow backtick string literals

* Only generate a fallback import function for non-structural imports
2018-07-09 16:35:25 -07:00
Alex Crichton
ade4561eba Don't unwrap mutex lock in headless testing
We don't worry about poisoning and it causes too many test failures if it's
turned on!
2018-07-09 14:55:55 -07:00
Nick Fitzgerald
2b5dd430a8
Merge pull request #428 from alexcrichton/missing-docs
Fix some cases with `#[deny(missing_docs)]`
2018-07-09 11:01:05 -07:00
Alex Crichton
331a86a07a Simplify the reset_indentation function
This should fix a stack overflow reported on IRC by ensuring that the function
isn't recursive
2018-07-09 09:10:26 -07:00
Alex Crichton
b4c7a5c1e1 Fix some cases with #[deny(missing_docs)]
Generated functions by wasm-bindgen should either be `#[doc(hidden)]` or include
the docs on the original item!

Closes #425
2018-07-09 08:49:16 -07:00
Alex Crichton
3c38ba258c Fix tests 2018-07-09 08:49:00 -07:00
Alex Crichton
5e747c721b Remove a stray extern forgotten in #410 2018-07-09 08:13:03 -07:00
Alex Crichton
b66095bcff Avoid logging body text
This was meant for debugging and is otherwise pretty noisy
2018-07-08 08:20:21 -07:00
Alex Crichton
bc01d6cd61 Fix onerror function in headless mode
Otherwise we don't see any output!
2018-07-08 08:20:14 -07:00
Alex Crichton
3236bac3f6 Start out a test's status as incomplete
That way if we don't fill it in the error message doesn't look quite so bizarre
2018-07-08 08:20:06 -07:00
Marcin Baraniecki
d179503a63 uses (JS) const for stack and slab declarations (#415) 2018-07-07 13:36:05 -05:00
Alex Crichton
791e69a5c0
Generate normal Rust functions for imported bindings (#410)
* Generate normal Rust functions for imported bindings

No need to use the C ABI, it just mixes up the documentation!

* Update expected webidl output
2018-07-07 12:20:42 -05:00
R. Andrew Ohana
2d50d5209b Backend refactor (#411)
* remove BindgenAttrs from other backend::ast structs

This is primarily a tool for use with the macro crate. Most of
these attributes were ignored in the actual codegen, but a few
were still being used. This is confusing when trying to add
other sources for codegen (such as webidl and typescript).

* move parsing logic to macro crate

This makes the backend crate solely concerned with having an ast
for which we can generate code.
2018-07-07 12:20:31 -05:00
dependabot[bot]
37bb15baf6
Merge pull request #404 from rustwasm/dependabot/cargo/docopt-1.0 2018-07-06 19:43:25 +00:00
dependabot[bot]
ded378b92f
Update docopt requirement to 1.0
Updates the requirements on [docopt](https://github.com/docopt/docopt.rs) to permit the latest version.
- [Release notes](https://github.com/docopt/docopt.rs/releases)
- [Commits](https://github.com/docopt/docopt.rs/commits/1.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-07-06 16:55:11 +00:00
dependabot[bot]
178375a51b
Update wasmi requirement to 0.3
Updates the requirements on [wasmi](https://github.com/paritytech/wasmi) to permit the latest version.
- [Release notes](https://github.com/paritytech/wasmi/releases)
- [Commits](https://github.com/paritytech/wasmi/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-07-06 16:54:52 +00:00
Sendil Kumar N
142d7377e2
Merge pull request #400 from alexcrichton/derive-import
Forward attributes on `type` declaration to definition
2018-07-06 09:21:01 +02:00
Satoshi Amemiya
e6b2a0d98c Add support getter and setter for static props 2018-07-06 14:57:17 +09:00
Alex Crichton
f4b49226b6 Fix webidl crate 2018-07-05 21:25:40 -07:00
Alex Crichton
5a776c16b2 Forward attributes on type declaration to definition
This'll allow things like `#[derive(Clone)]` or `#[derive(Debug)]` to control
traits for these types.
2018-07-05 20:28:52 -07:00
Nick Fitzgerald
549e5a9be9 tests: Pull the project() builder out into its own crate
The WebIDL-based -sys crate will also use this, but I want its tests to be a
separate suite that we can run separately and in parallel in CI. Therefore, this
testing infrastructure code needs to be share-able between them :)
2018-07-05 14:27:26 -07:00
Alex Crichton
efa4a2b8fa
Speed up Travis by running Webpack in fewer tests (#381)
* Reorganize Travis configuration

* Add a `JOB` env var descriptor to all matrix entries. Not used anywhere but is
  useful when viewing the whole build on Travis's web interface.
* Reorganize where builds are located, moving slow builds first and fast ones
  last.
* Change checking the CLI builds from `cargo build` to `cargo check`
* Use YAML references to reduce some duplication

* Print some more timing statistics for each test

* Extract `Project` helper in tests to a module

This'll help make it a bit more extensible over time. At the same time the
methods are also slightly reorganized to read more clearly from top to bottom.

* Migrate all tests away from Webpack

Wepback can take a significant amount of time to execute and when it's
multiplied by hundreds of tests that adds up really quickly! After investigating
Node's `--experimental-modules` option it looks like it's suitable for our use
so this switches all tests to using JS files (moving away from TypeScript as
well) with `--experimental-modules` with Node.

Tests will be selectively re-enabled with webpack and node.js specific output
(that doesn't require `--experimental-modules`), coming in later commits.

* Restore the node test for node.js output

Ensures it's workable as-is

* Only generate typescript with webpack

* Only read wasm files for webpack

* Skip package.json/node_modules for now

* Only generate webpack config if needed

* Start a dedicated test module for typescript

Will hopefully verify the generated Typescript compiles OK.

* Remove unneeded `node` method

* Fixup some rebase conflicts

* Don't run asmjs example on travis

* Fixup generator tests

* Attempt to fix windows

* Comment windows fix

* More test fixes

* More exclusions

* More test fixes

* Relax eslint regex

Catch mjs modules as well

* Fix eslint

* Speed up travis on examples slightly
2018-07-04 22:37:09 -05:00
Alex Crichton
247ea628fb Don't import wasm in generated JS if it's not used
Mostly just an edge case
2018-07-04 08:50:48 -07:00
Alex Crichton
000970ee2c Remove extraneous exposure of uint64 memory
No longer needed!
2018-07-04 08:34:19 -07:00
Alex Crichton
67b9ce58aa Fix getArrayJsValueFromWasm exposing wrong function
This needs `getUint32Memory`, not `getArrayU32FromWasm`.
2018-07-04 08:30:18 -07:00
Alex Crichton
3510b20595 Fix a stray unused variable
Travis tests show hundreds of warning for `'y' is defined but never used` and
when investigating it looks like a mistake was introduced in 0938858aa
during #272, so hopefully this'll be an easy fix!
2018-07-04 08:16:09 -07:00
teovoinea
7cd3ca02a2 Update with masters and fix PR changes 2018-07-02 20:35:05 -07:00
Alex Crichton
4ceaf3e0f4
Some small cleanups (#366)
* No need for version deps in dev-deps

These are all internal so we can drop the version

* Remove wasm-bindgen-cli's parity-wasm dep

No longer needed

* Tweak file hierarchy in webidl tests

Use Cargo's conventions to avoid the need to define `[[test]]` sections

* Remove unused imports
2018-07-02 11:57:39 -05:00
Alex Crichton
e06255fba5 Don't generate JS bindings for unused imports
If a JS import's shim isn't actually imported that means that somewhere along
the way it was optimized out or it was never used in the first place! In that
case we can skip generation of the JS bindings for it as it's not needed.
2018-06-29 15:56:12 -07:00
Alex Crichton
e55af85edc
Support by-value self methods (#348)
Refactor slightly to use the same internal support that the other reference
conversions are using.

Closes #329
2018-06-28 20:09:11 -05:00
Alex Crichton
9a3ff77ea9
Support returning custom types in imports (#350)
Closes #320
2018-06-28 20:08:02 -05:00
Alex Crichton
4138583dff
Support wildcard arguments in foreign functions (#351)
No real reason to not support them!

Closes #346
2018-06-28 20:06:35 -05:00
R. Andrew Ohana
7626b55d00 fix up some strings that looked funky after rustfmt 2018-06-27 22:45:33 -07:00
R. Andrew Ohana
9127a0419f rustfmt all the things 2018-06-27 22:42:34 -07:00
xeqlol
2028efa76f Fix typo in backend crate 2018-06-26 13:17:40 +05:00