Commit Graph

87 Commits

Author SHA1 Message Date
Alex Crichton
269c491380
Gate web-sys APIs on activated features (#790)
* Gate `web-sys` APIs on activated features

Currently the compile times of `web-sys` are unfortunately prohibitive,
increasing the barrier to using it. This commit updates the crate to instead
have all APIs gated by a set of Cargo features which affect what bindings are
generated at compile time (and which are then compiled by rustc). It's
significantly faster to activate only a handful of features vs all thousand of
them!

A magical env var is added to print the list of all features that should be
generated, and then necessary logic is added to ferry features from the build
script to the webidl crate which then uses that as a filter to remove items
after parsing. Currently parsing is pretty speedy so we'll unconditionally parse
all WebIDL files, but this may change in the future!

For now this will make the `web-sys` crate a bit less ergonomic to use as lots
of features will need to be specified, but it should make it much more
approachable in terms of first-user experience with compile times.

* Fix AppVeyor testing web-sys

* FIx a typo

* Udpate feature listings from rebase conflicts

* Add some crate docs and such
2018-09-05 12:55:30 -07:00
Alex Crichton
c6d3011cff
Merge pull request #785 from afdw/master
Add initial support for unions in return types, add more fixes for case of identifiers
2018-09-05 09:26:42 -07:00
Bradlee Speice
0965b77af8 Remove --wasm2js flag entirely 2018-09-03 13:56:55 -04:00
Bradlee Speice
c69833f253 Fix some references I missed 2018-09-02 22:32:19 -04:00
Anton Danilkin
14c2c04ccd Fix canvas test 2018-09-02 20:51:37 +03:00
Alex Crichton
14cb2dd4cf Fix fetch example ... again? 2018-08-30 14:26:22 -07:00
Alex Crichton
90fce8c9d4 Fix audio example 2018-08-30 13:45:42 -07:00
Alex Crichton
e283093997 Fix the console_log example 2018-08-30 12:55:21 -07:00
Alex Crichton
dd3dba9285 Delete lots of now-unused code 2018-08-30 12:54:54 -07:00
Alex Crichton
b9dc937d73 Refactor WebIDL code generation
This commit refactors WebIDL code generation to walk over the fields of
`FirstPassRecord` instead of walking the AST again. This helps remove
redundancies like checking `is_chrome_only` as well as revisiting partial
interfaces and such. This should make it more clear that the first pass's job is
to walk the AST and collect all relevant information, while the codegen pass is
purely about appending items to a `Program`.

Additionally this refactoring will also soon be used to prepare different data
structures for operation overloadings, avoiding the need to walk those ASTs
twice.
2018-08-30 12:54:54 -07:00
Alex Crichton
36b854b69c web-sys: Add support for Global-scope methods
This commit adds further support for the `Global` attribute to not only emit
structural accessors but also emit functions that don't take `&self`. All
methods on a `[Global]` interface will not require `&self` and will call
functions and/or access properties on the global scope.

This should enable things like:

    Window::location() // returns `Location`
    Window::fetch(...) // invokes the `fetch` function

Closes #659
2018-08-28 17:20:31 -07:00
Alex Crichton
66d96aac11 Fix merge conflicts with fetch example 2018-08-20 11:23:02 -07:00
Alex Crichton
adcc0dd23e
Merge pull request #729 from eminence/fetch
Initial example for the Fetch API
2018-08-20 10:35:57 -07:00
Alex Crichton
92b7de3d3d Skip args in overloaded method names if all same
This commit updates how we name overloaded methods. Previously all argument
names were concatenated, but after this commit it only concatenates argument
names where at least one possibility has a different type. Otherwise if all
possibilities have the same type name it in theory isn't adding too much more
information!

Additionally this commit also switches to using `_with_` consistently everywhere
instead of `_with_` for constructors and `_using_` for methods.

Closes #712
2018-08-20 10:30:02 -07:00
Andrew Chin
e4093eb178 No more use_extern_macros feature! 2018-08-20 13:19:00 -04:00
Andrew Chin
2c72eabea1 Make the list of examples alphabetical, and add webaudio and fetch examples 2018-08-19 18:41:02 -04:00
Andrew Chin
9d7c0af08f Initial example for the Fetch API 2018-08-19 18:41:02 -04:00
Alex Crichton
4c1bf937f2 Move the unsize feature behind a nightly Cargo feature
This should fully stabilize the `wasm-bindgen` crate, preparing us for stable
Rust!
2018-08-19 14:45:59 -07:00
Alex Crichton
305ecb7910 Remove nll feature from webaudio example 2018-08-19 14:42:25 -07:00
Alex Crichton
d4297ad2d3 Remove use_extern_macros features
This has now been stabilized!
2018-08-19 14:33:01 -07:00
Andrew Chin
4a994da904 Show how to use web-sys::console::log from the console_log example 2018-08-17 22:54:59 -04:00
Andrew Chin
4f18e21659 Initial example of using the WebAudio APIs from web-sys
Part of #443
2018-08-17 07:02:48 -04:00
Nick Fitzgerald
34363aff12 example: Add an example of drawing a smiley face with canvas
Adapted from https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes
2018-08-15 17:40:39 -07:00
Nick Fitzgerald
b1e3101fd4 guide: Add examples for number slices 2018-08-14 17:42:47 -07:00
Nick Fitzgerald
fea41b4a87 guide: also allow Option<bool> 2018-08-14 17:34:16 -07:00
Nick Fitzgerald
9c9e53485a guide: Add examples of boxed number slices 2018-08-14 17:15:01 -07:00
Nick Fitzgerald
8043baac69 guide: Add examples for working with numbers to types section 2018-08-14 15:45:25 -07:00
Nick Fitzgerald
602b63c1b0 guide: Add working with pointers example to types section 2018-08-14 15:24:43 -07:00
Nick Fitzgerald
d1b2299340 guide: Add Box<[JsValue]> example to supported types section 2018-08-13 17:08:18 -07:00
Nick Fitzgerald
60307e81f9 guide: Add JsValue example to supported types section 2018-08-13 16:57:29 -07:00
Nick Fitzgerald
fedd1a5440 guide: Add bool example to supported types section 2018-08-13 16:55:05 -07:00
Nick Fitzgerald
975a122d6d guide: Add a char example to the supported types section 2018-08-13 16:24:39 -07:00
Nick Fitzgerald
74dc8874e1 guide: add String example usage to supported types 2018-08-13 16:20:25 -07:00
Nick Fitzgerald
fa72afe286 guide: Add str examples to supported types section 2018-08-13 16:12:58 -07:00
Nick Fitzgerald
8e19645006 guide: Add exported rust type examples to reference 2018-08-13 16:03:02 -07:00
Nick Fitzgerald
e87498e939 guide: Start adding example usage to "supported types" section 2018-08-10 16:56:40 -07:00
Nick Fitzgerald
64591ef403 Js sys use &str arguments (#555)
* js-sys: imports should take &str parameters instead of &JsString

* js-sys: Imports should take Option<&str> instead of Option<String>
2018-07-25 18:50:30 -05:00
Nick Fitzgerald
61fc8d2567 Js sys once over (#550)
* js-sys: Return `f64` instead of `Number`

* js-sys: remove trailing whitespace

* js-sys: Ensure that all imported types derive Clone and Debug

* js-sys: Imported functions should always take JS object arguments by-ref
2018-07-25 16:33:44 -05: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
Alex Crichton
13cee9e264 Fix closures example 2018-07-20 12:09:30 -07:00
Alex Crichton
6eef5f7b52
Move the js module to a js_sys crate (#512)
* Move the `js` module to a `js_sys` crate

* Update js-sys tests to pass again

* Update binding_to_unimplemented_apis_doesnt_break_everything

Remove its dependency on the `js` module

* Update metadata for js-sys

* Fix the `closures` example
2018-07-19 14:30:58 -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
Richard Dodd (dodj)
07d16ec892
fix link 2018-07-15 18:33:28 +00:00
Marcin Baraniecki
a5b8c45d28 adds julia set example (#419)
* adds julia set example

* fixes indentation in *.js files

* fixes *.js formatting

* fixes a typo in function arguments signature
2018-07-08 10:57:19 -05:00
Frank Hassanabad
6561fba947 Applied eslint from main .eslintrc to examples (#418)
* Changed eslintrc to be JSON file (Most projects use JSON version)
  * Added .eslintignore to ingore node_modules from subdirectories such as examples
  * Ran eslint --fix examples to fix all examples
  * Added npm script for running eslint against examples
  * Added npm script for running eslint against generated *out* code
  * Hooked npm scripts into travis ci to prevent examples from becoming inconsistent with future PR's
2018-07-08 01:02:10 -05:00
limira
04e29db588 Correct link to WebIDL issue (#402) 2018-07-06 11:09:48 -05:00
konstin
66096804ce Fix the constructor explanation in the guide (#372) 2018-07-03 09:24:43 -05:00
R. Andrew Ohana
9127a0419f rustfmt all the things 2018-06-27 22:42:34 -07:00
Sendil Kumar
ef27cb6392 Add date constructor 2018-06-26 16:55:40 +02:00