Commit Graph

67 Commits

Author SHA1 Message Date
Nick Fitzgerald
2fcc74e226 guide: refactor and update testing instructions for contributing 2018-08-08 15:33:56 -07:00
Alex Crichton
5b935526ff
Merge pull request #640 from alexcrichton/jscast
Implement RFC #2 - casting hierarchy between JS values
2018-08-07 17:26:37 -05:00
Nick Fitzgerald
43636977ae
Merge pull request #664 from fitzgen/guide-serde-arbitrary-data
Guide serde arbitrary data
2018-08-07 14:48:45 -07:00
Nick Fitzgerald
1d92784e07 guide: add indexing_{getter,setter,deleter} attribute page 2018-08-07 14:42:13 -07:00
Nick Fitzgerald
2e7620e014 guide: Polish Serializing + Deserializing into/from JsValue with Serde section 2018-08-07 14:25:30 -07:00
Nick Fitzgerald
676611020e guide: Delete "Feature Reference" page
We now have a rather large section for feature reference, and I don't think
there is anything in this page that isn't covered elsewhere and in more detail
anymore.
2018-08-07 14:25:30 -07:00
Alex Crichton
bd15db40a0 Rebase fallout and review comments 2018-08-07 13:24:48 -07:00
Alex Crichton
37db88ebfa Implement #[wasm_bindgen(extends = ...)]
This commit implements the `extends` attribute for `#[wasm_bindgen]` to
statically draw the inheritance hierarchy in the generated bindings, generating
appropriate `AsRef`, `AsMut`, and `From` implementations.
2018-08-07 13:04:11 -07:00
Nick Fitzgerald
9d291187c5 guide: Fix alphabetizing of attributes 2018-08-07 11:14:00 -07:00
Nick Fitzgerald
451a2a8118 guide: Add small intro to Rust export attributes section 2018-08-07 11:13:41 -07:00
Nick Fitzgerald
e22ccb4d5d guide: Clean up passing rust closures to JS section; add passing JS closures to rust section 2018-08-07 11:09:19 -07:00
Nick Fitzgerald
33520d4828 guide: add exhuastive reference docs for #[wasm_bindgen] attributes 2018-08-07 11:09:19 -07:00
Alex Crichton
b6a6dee7f1
Merge pull request #652 from afdw/master
Add support for getters, setters and deleters
2018-08-06 21:43:53 -05:00
Anton Danilkin
86b5ba6431 Add missing indexing words 2018-08-07 02:45:08 +03:00
Anton Danilkin
f54d51e045 Add documentation 2018-08-07 01:49:45 +03:00
Alex Crichton
b2977a4262 Delete wasm-bindgen-test-project-builder
No more tests use it!
2018-08-06 11:48:34 -07:00
Alex Crichton
d5b81595ec Remove support for the version attribute
First added in #161 this never ended up panning out, so let's remove the
experimental suport which isn't actually used by anything today and hold off on
any other changes until an RFC happens.
2018-08-06 13:30:28 -05:00
Nick Fitzgerald
2b8e092f78 guide: Note that wasm-pack is preferred over using the wasm-bindgen CLI directly 2018-08-03 22:35:19 -05:00
Nick Fitzgerald
9b87e0c0b0 guide: clean up introduction to the supported types table 2018-08-03 22:35:19 -05:00
Nick Fitzgerald
1e1188d9e5 guide: Add String to "Supported Types" reference 2018-08-03 22:35:19 -05:00
Nick Fitzgerald
93b3216014 guide: Add imported and exported types to "supported types" reference 2018-08-03 22:35:19 -05:00
Nick Fitzgerald
536bf5e0d7 guide: Rename "Type Reference" section to "Supported Types" 2018-08-03 22:35:19 -05:00
Nick Fitzgerald
9e03dba413 guide: Overhaul the CLI reference content
* Add missing documentation for a couple existing flags.

* Make each flag its own header, so it gets an anchor, and can be permalinked
  to.

* Streamline some content and descriptions.
2018-08-03 22:35:19 -05:00
Nick Fitzgerald
2b83f6aa9b guide: Clean up title and URL of CLI reference section 2018-08-03 22:35:19 -05:00
Nick Fitzgerald
39e576d0be guide: Organize docs into "Whirlwind Tour" and "Reference" sections
First part of #616
2018-08-03 15:16:22 -07:00
YUyz
7cc5dcf32d Fix link in the guide book (#609) 2018-08-02 08:12:18 -05:00
Alex Crichton
fcda44c967 Update that web-sys tests require --target now 2018-07-30 11:07:07 -07:00
Richard Dodd (dodj)
71255acf5d Try to enable all webidls (#573)
* Try to enable all webidls

* Separate out unavailable webidl files by reason.

* Create record of fully tested WebIDL files

* Update notes to reflect new situation with web-idl

* Make a blank ident fail, disable the necessary widls.

It turns out that all the blank idents came from blank enum variants,
which is allowed in webidl apparently.
2018-07-29 16:07:19 -07:00
Noumir Poutipou
fa4b636c25 Fix very small typo in guide (#575) 2018-07-28 09:36:23 -07:00
Nick Fitzgerald
decdbd92b8 Js sys contributing (#574)
* guide: js-sys testing page should refer to js-sys not web-sys

* guide: Use checklist for adding new js-sys APIs
2018-07-27 16:22:33 -07:00
Alex Crichton
55e2ce9b53 Note that new WebIDL may need TODO comments
We don't support all features just yet!

Closes #570
2018-07-27 08:50:41 -07:00
Alex Crichton
f90f53c540 Fix some links in the guide
Closes #569
2018-07-27 08:48:10 -07:00
Alex Crichton
00bb6736e3
Add guide documentation for the js-sys crate (#566) 2018-07-26 17:56:55 -07:00
Nick Fitzgerald
28cb007c1b guide: Also publish the test crates 2018-07-26 15:12:04 -07:00
Nick Fitzgerald
08a449f667 guide: Also tag the release commit and push it 2018-07-26 15:01:36 -07:00
Nick Fitzgerald
7a7d0d4097 guide: Allow dirty when publishing wasm-bindgen
Because we comment out the `[patch]` section and don't commit it.
2018-07-26 14:58:57 -07:00
Nick Fitzgerald
9a0470b1c4 Bump to 0.2.15 2018-07-26 14:53:59 -07:00
Alex Crichton
906cd7adcc Remove usage of wasm_import_module feature
This is now stabilized! Also tweak usage of it to the stable version.
2018-07-21 19:00:40 -07:00
David O'Connor
c174262cf0 Add documentation for passing arbitrary data (#531)
* Added passing-data readme entry

* Added the file

* Changed wording, and fixed hyperlinks

* Another attempt at fixing links

* Changed highlighting of key words

* Fixed typo
2018-07-21 13:57:03 -05:00
Alex Crichton
9753f9150b
Allow renaming exported functions into JS (#525)
Support the `js_name` attribute on exports as well as imports to allow exporting
types as camelCase instead of snake_case, for example.

Closes #221
2018-07-20 12:01:28 -05:00
Alex Crichton
61ef250dca
Add more documentation for --no-modules (#526)
Closes #211
2018-07-20 12:00:51 -05:00
Richard Dodd (dodj)
801d62ae68 Add some notes about viewing bindings output. (#521)
* Add some notes about viewing bindings output.

I found this helpful when debugging, so I thought others might too.

* Fix formatting

* Another formatting fix
2018-07-20 10:41:31 -05:00
Craig Disselkoen
ad5bc8fc8d Fix a few typos in guide 2018-07-19 16:41:35 -07:00
Alex Crichton
cbeb301371
Add support for optional slice types (#507)
* Shard the `convert.rs` module into sub-modules

Hopefully this'll make the organization a little nicer over time!

* Start adding support for optional types

This commit starts adding support for optional types to wasm-bindgen as
arguments/return values to functions. The strategy here is to add two new
traits, `OptionIntoWasmAbi` and `OptionFromWasmAbi`. These two traits are used
as a blanket impl to implement `IntoWasmAbi` and `FromWasmAbi` for `Option<T>`.

Some consequences of this design:

* It should be possible to ensure `Option<SomeForeignType>` implements to/from
  wasm traits. This is because the option-based traits can be implemented for
  foreign types.
* A specialized implementation is possible for all types, so there's no need for
  `Option<T>` to introduce unnecessary overhead.
* Two new traits is a bit unforutnate but I can't currently think of an
  alternative design that works for the above two constraints, although it
  doesn't mean one doesn't exist!
* The error messages for "can't use this type here" is actually halfway decent
  because it says these new traits need to be implemented, which provides a good
  place to document and talk about what's going on here!
* Nested references like `Option<&T>` can't implement `FromWasmAbi`. This means
  that you can't define a function in Rust which takes `Option<&str>`. It may be
  possible to do this one day but it'll likely require more trait trickery than
  I'm capable of right now.

* Add support for optional slices

This commit adds support for optional slice types, things like strings and
arrays. The null representation of these has a pointer value of 0, which should
never happen in normal Rust. Otherwise the various plumbing is done throughout
the tooling to enable these types in all locations.

* Fix `takeObject` on global sentinels

These don't have a reference count as they're always expected to work, so avoid
actually dropping a reference on them.

* Remove some no longer needed bindings

* Add support for optional anyref types

This commit adds support for optional imported class types. Each type imported
with `#[wasm_bindgen]` automatically implements the relevant traits and now
supports `Option<Foo>` in various argument/return positions.

* Fix building without the `std` feature

* Actually fix the build...

* Add support for optional types to WebIDL

Closes #502
2018-07-19 14:44:23 -05:00
Alex Crichton
a949482e3a
Remove usage of #[wasm_custom_section] (#509)
This has been stabilized on nightly as `#[link_section]`, so no need for an
unstable attribute any more. Yay!
2018-07-19 08:57:18 -05:00
Alex Crichton
ed05c7b945
Fix compile on latest nightly (#489) 2018-07-17 09:11:30 -05:00
Julius Rakow
2007fe6b9c guide: bump required nodejs version to 10 (#467) 2018-07-13 10:41:54 -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
frankhassanbad
0b3a17685f Changed https to http and make a link to it for ease of read 2018-07-07 14:38:29 -06:00
Marcin Baraniecki
d179503a63 uses (JS) const for stack and slab declarations (#415) 2018-07-07 13:36:05 -05:00