Commit Graph

1010 Commits

Author SHA1 Message Date
54b2482d03 doc(readme) Add links to doc & clean
This patch adds a link to the crate's documentation. It also removes a reference to #275, which is closed now.
2018-09-21 10:08:11 +02:00
a2d6a8ff53 Use anyref helper to reduce some code duplication 2018-09-20 17:26:49 -07:00
8c720bee50 Purge a number of Mozilla-specific WebIDL
Did a bunch of grepping for `moz*` and searched for "moz" in rustdoc,
deleting anything that looked mozilla-specific. Now there's nothing left
with the "moz" prefix in rustdoc!
2018-09-20 17:19:36 -07:00
3efe51eb8b Reorganize and rewrite examples
This commit is a large-ish scale reorganization of our examples. The
main goal here is to have a dedicated section of the guide for example,
and all examples will be listed there. Each example's `README` is now
just boilerplate pointing at the guide along with a blurb about how to
run it.

Some examples like `math` and `smorgasboard` have been deleted as they
didn't really serve much purpose, and others like `closures` have been
rewritten with `web-sys` instead of hand-bound bindings.

Overall it's hoped that this puts us in a good and consistent state for
our examples, with all of them being described in the guide, excerpts
are in the guide, and they're all relatively idiomatically using
`web-sys`.
2018-09-20 16:45:30 -07:00
f808594efa Add String.raw 2018-09-20 00:40:14 +03:00
e9212cfa43 Merge pull request #853 from alexcrichton/clone
Add `#[derive(Clone, Debug)]` to all web-sys types
2018-09-19 13:20:40 -07:00
f7b511588b Add binding for Object.entries() 2018-09-19 21:32:05 +02:00
326e4c0262 Add binding for Object.getPrototypeOf() 2018-09-19 21:10:40 +02:00
76969bd1e3 Add binding for Object.getOwnPropertySymbols() 2018-09-19 20:58:46 +02:00
3f68c43d06 Add #[derive(Clone, Debug)] to all web-sys types
They're all cloneable and debuggable!
2018-09-19 11:54:32 -07:00
4e18493fd7 Add binding for Object.getOwnPropertyNames() 2018-09-19 20:43:50 +02:00
5832ff3ca1 Merge pull request #847 from alexcrichton/fix-window
Move all methods on `Window` back to methods
2018-09-18 16:59:46 -07:00
a83d561bb3 Add js_sys::global 2018-09-18 15:40:49 -07:00
300aca38c2 Squelch warnings in webidl tests 2018-09-18 14:30:24 -07:00
604ecd9529 Squelch warnings in webidl tests 2018-09-18 14:30:01 -07:00
bbc46f92c6 Fix web-sys Location test 2018-09-18 14:16:01 -07:00
7cf4213283 Allow returning Result from functions
This commit adds support for exporting a function defined in Rust that returns a
`Result`, translating the `Ok` variant to the actual return value and the `Err`
variant to an exception that's thrown in JS.

The support for return types and descriptors was rejiggered a bit to be a bit
more abstract and more well suited for this purpose. We no longer distinguish
between functions with a return value and those without a return value.
Additionally a new trait, `ReturnWasmAbi`, is used for converting return values.
This trait is an internal implementation detail, however, and shouldn't surface
itself to users much (if at all).

Closes #841
2018-09-18 13:13:59 -07:00
fe31615ca1 Fix webidl-tests fallout 2018-09-17 17:36:53 -07:00
f24828a16b Add a top-level web_sys::window function
Returns `Option<Window>` and can be used as a convenience to get a handle to the
global `window` object.
2018-09-17 17:36:53 -07:00
99e1b352e5 Translate the WindowProxy type to Window.
This is roughly defined by
https://html.spec.whatwg.org/multipage/window-object.html#windowproxy and
otherwise fits the bill how otherwise only `interface WindowProxy;` exists in
the WebIDL.
2018-09-17 17:36:53 -07:00
8cf9da4981 Translate the Global attribute to "structural"
All APIs on `Windows` are tagged where `Window` has `[Global]`, and they all
need to be structurally accessed rather than through a prototype.
2018-09-17 17:36:53 -07:00
c67582a315 Remove support for scoped static methods
This is intended to address #834 where we don't actually want methods scoped
like this! Instead we'll provide one unique accessor for the `window` object
itself.
2018-09-17 17:36:53 -07:00
a37fa45100 Merge pull request #845 from alexcrichton/more-webidl
Uncommented some WebIDL TODO
2018-09-17 15:29:49 -07:00
b38b9da499 Merge pull request #846 from alexcrichton/no-modules
Remove `Module` node from the backend AST
2018-09-17 15:19:57 -07:00
6ce5e6e1dd Merge pull request #831 from alexcrichton/more-webidl-types
Add bindings for a few more "long long" types
2018-09-17 15:17:17 -07:00
9daa11592a Remove Module node from the backend AST
This is a roundabout way to say that this addresses the last comment on #23,
namely if you only use the `console` submodule from `web_sys` it doesn't
actually link correctly!

The problem here has to do with codegen units and the compiler. The compiler
will create a codegen unit for each `mod` in the source code. If a codegen unit
isn't actually used, then the codegen unit is removed from the final link step.
This causes problems for web-sys where the JSON description of our program was
part of the main CGU but not in each submodule, so when submodules were only
used the descriptor program in the main CGU was not included.

The fix in this commit is to instead generate a descriptor program in the
submodule itself instead of leaving it in the main CGU. By removing the `Module`
node in the AST this naturally happens as the descriptor is only generated in
the same module as all other associated items.
2018-09-17 13:50:26 -07:00
a02c4c1410 Uncommented some WebIDL TODO
This partially reverts commit 4b4bed5ce2 by
restoring a number of items to our WebIDL

Closes #839
2018-09-17 13:25:10 -07:00
1ee579093b Merge pull request #832 from myelin-ai/device-pixel-ratio
Add devicePixelRatio to Window
2018-09-17 10:12:43 -07:00
a897715f50 Merge pull request #838 from brisad/object-get-descriptors
Object get descriptors
2018-09-17 10:47:46 +02:00
2d91fa11b5 Add binding for Object.getOwnPropertyDescriptors() 2018-09-16 23:02:46 +02:00
b005e96fd9 Add binding for Object.getOwnPropertyDescriptor() 2018-09-16 22:55:15 +02:00
61eb7df0c8 Update weedle 2018-09-16 23:39:00 +03:00
df18c4b042 Update weedle: use special instead of specials 2018-09-16 21:19:20 +03:00
191e7dc1fb Add binding for Object.defineProperties() 2018-09-15 22:30:27 +02:00
170ac21473 Add devicePixelRatio attribute 2018-09-15 12:42:23 +02:00
ae60bb4ba8 Translate LongLong types to f64
Any LongLong still present after flattening now gets translated to a `f64` type
so we can bind these types. While not a true integral value or truely 64-bits of
integer precision, it's all JS has anyway!
2018-09-14 18:54:29 -07:00
941397745d Enable DOMTimeStamp as UnsignedLongLong
This is apparently how webidl defines it!
2018-09-14 18:44:38 -07:00
96a70c41be reset_indentation: Don't emit indentation on blank lines
This resulted in trailing whitespace in the generated file. In addition
to wasting space in a file that gets served over the wire, this also
gets highlighted as a problem when reviewing the generated file in an
editor that highlights trailing whitespace.
2018-09-13 22:13:07 -07:00
1c52fb1b2f Remove leading and trailing blanks from the --no-modules output
The output using modules already uses string formatting that carefully
avoids emitting leading and trailing blanks; adjust the --no-modules
output to match.
2018-09-13 22:10:59 -07:00
2fc499d66d Merge pull request #819 from fitzgen/webidl-interfaces-should-extend-object
webidl: All interfaces implicitly extend `Object`
2018-09-12 16:21:48 -07:00
e2e815a477 guide: Add documentation for testing with wasm-bindgen-test 2018-09-12 15:40:09 -07:00
93a510ef93 webidl: All interfaces implicitly extend Object
This information is embedded within the algorithm for constructing interfaces
and their prototypes in the section for ECMAScript glue in the WebIDL spec...

This really *should* make the `wasm_bindgen_backend::ast::ImportType::extends`
member from a `Vec<Ident>` into a `Vec<syn::Path>` so that we could use
`js_sys::Object` in the extends field, but that is a huge pain because then the
`ImportedTypes` trait needs to be changed, and all of its implementers, etc...
2018-09-12 15:25:09 -07:00
a59a10d6df Fix tests on nightly 2018-09-12 10:20:03 -07:00
e5af22ee4e Merge pull request #814 from brisad/object-define-property
Add binding for Object.defineProperty()
2018-09-12 09:13:03 -07:00
fe6ad5447e Add binding for Object.defineProperty() 2018-09-12 07:39:39 +02:00
9ca024a812 Merge pull request #792 from afdw/master
Add support for variadic arguments in WebIDL
2018-09-11 16:05:56 -07:00
096848199e Introduce a constant 2018-09-11 23:10:03 +03:00
f6b199cfb0 web-sys: Crate metadata should point to the web-sys section of the wasm-bindgen guide 2018-09-10 17:56:03 -07:00
9f4ed536df Use js_sys::Array, generate _n methods for ergonomics 2018-09-11 00:37:59 +03:00
8181f7fa95 Implement WebIDL callback interfaces
This commit implements callback interfaces for WebIDL, the final WebIDL
construct that we were unconditionally ignoring! Callback interfaces are
implemented as dictionaries of callbacks. Single-operation callback interfaces
are also expanded when flattening to accept a `Function` as well, in accordance
with the WebIDL spec.

New features have been added to `web-sys` for all the new callback interface
types. Additionally the `EventTarget.webidl` was tweaked to not have
`EventListener?` as this is required for all functional usage and there's no
need to keep that sort of web browser compat here.

Closes #258
2018-09-10 12:00:50 -07:00