Commit Graph

96 Commits

Author SHA1 Message Date
Anton Danilkin
b9cc8e1270 Use Cell instead of RefCell 2018-09-13 03:38:22 +03:00
Anton Danilkin
62b04e44c4 Add paint example 2018-09-13 02:10:36 +03:00
Nick Fitzgerald
4e86ecd2c5
Merge pull request #813 from fitzgen/duck-typed-interfaces
Duck typed interfaces
2018-09-12 11:20:26 -07:00
Alex Crichton
73e6191b60
Merge pull request #703 from lnicola/guide-publish-app
Guide: explain how to deploy the applicaton to a web server
2018-09-12 09:33:39 -07:00
Nick Fitzgerald
1872e84a8a guide: Add section on working with duck-typed interfaces 2018-09-11 16:40:32 -07:00
Nick Fitzgerald
a311c29f1d examples: Add an example of using duck-typed interfaces 2018-09-11 16:29:25 -07:00
Laurentiu Nicola
89005f3469 Examples: use html-webpack-plugin 2018-09-11 08:42:22 +03:00
Nick Fitzgerald
723ed6e856 examples(fetch): Tidy up the fetch example 2018-09-10 17:50:55 -07:00
Nick Fitzgerald
42ea38187f examples(webaudio): Tidy up the webaudio example 2018-09-10 17:50:34 -07:00
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