mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2025-01-02 08:33:05 +03:00
Merge pull request #734 from alexcrichton/stabilize
Remove `use_extern_macros` features
This commit is contained in:
commit
6d49c76bc4
@ -56,6 +56,7 @@ matrix:
|
||||
- cargo test
|
||||
# Run the main body of the test suite
|
||||
- cargo test --target wasm32-unknown-unknown
|
||||
- cargo test --target wasm32-unknown-unknown --features nightly
|
||||
# Rerun the test suite but disable `--debug` in generated JS
|
||||
- WASM_BINDGEN_NO_DEBUG=1 cargo test --target wasm32-unknown-unknown
|
||||
# Make sure our serde tests work
|
||||
|
@ -21,6 +21,7 @@ default = ["spans", "std"]
|
||||
spans = ["wasm-bindgen-macro/spans"]
|
||||
std = []
|
||||
serde-serialize = ["serde", "serde_json", "std"]
|
||||
nightly = []
|
||||
|
||||
# This is only for debugging wasm-bindgen! No stability guarantees, so enable
|
||||
# this at your own peril!
|
||||
|
@ -13,8 +13,6 @@
|
||||
Import JavaScript things into Rust and export Rust things to JavaScript.
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
@ -33,8 +33,6 @@
|
||||
//! `Promise`.
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! #![feature(use_extern_macros)]
|
||||
//!
|
||||
//! extern crate futures;
|
||||
//! extern crate js_sys;
|
||||
//! extern crate wasm_bindgen;
|
||||
@ -104,7 +102,6 @@
|
||||
//! ```
|
||||
|
||||
#![deny(missing_docs)]
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate futures;
|
||||
extern crate wasm_bindgen;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate futures;
|
||||
|
@ -17,7 +17,6 @@
|
||||
//! bindings.
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
#![feature(use_extern_macros)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
extern crate js_sys;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: error parsing #[wasm_bindgen] attribute options: failed to parse anything
|
||||
--> $DIR/attribute-fails-to-parse.rs:7:16
|
||||
--> $DIR/attribute-fails-to-parse.rs:5:16
|
||||
|
|
||||
7 | #[wasm_bindgen(nonsense)]
|
||||
5 | #[wasm_bindgen(nonsense)]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,19 +1,19 @@
|
||||
error: cannot return a borrowed ref with #[wasm_bindgen]
|
||||
--> $DIR/bad-signatures.rs:8:17
|
||||
--> $DIR/bad-signatures.rs:6:17
|
||||
|
|
||||
8 | pub fn foo() -> &u32 {}
|
||||
6 | pub fn foo() -> &u32 {}
|
||||
| ^^^^
|
||||
|
||||
error: unsupported pattern in #[wasm_bindgen] imported function
|
||||
--> $DIR/bad-signatures.rs:12:12
|
||||
--> $DIR/bad-signatures.rs:10:12
|
||||
|
|
||||
12 | fn foo(Foo(x): Foo);
|
||||
10 | fn foo(Foo(x): Foo);
|
||||
| ^^^^^^
|
||||
|
||||
error: cannot return references in #[wasm_bindgen] imports yet
|
||||
--> $DIR/bad-signatures.rs:14:17
|
||||
--> $DIR/bad-signatures.rs:12:17
|
||||
|
|
||||
14 | fn foo() -> &u32;
|
||||
12 | fn foo() -> &u32;
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,19 +1,19 @@
|
||||
error: error parsing #[wasm_bindgen] attribute options: failed to parse anything
|
||||
--> $DIR/invalid-attr.rs:7:16
|
||||
--> $DIR/invalid-attr.rs:5:16
|
||||
|
|
||||
7 | #[wasm_bindgen(x)]
|
||||
5 | #[wasm_bindgen(x)]
|
||||
| ^
|
||||
|
||||
error: error parsing #[wasm_bindgen] attribute options: failed to parse anything
|
||||
--> $DIR/invalid-attr.rs:12:20
|
||||
--> $DIR/invalid-attr.rs:10:20
|
||||
|
|
||||
12 | #[wasm_bindgen(y)]
|
||||
10 | #[wasm_bindgen(y)]
|
||||
| ^
|
||||
|
||||
error: malformed #[wasm_bindgen] attribute
|
||||
--> $DIR/invalid-attr.rs:15:5
|
||||
--> $DIR/invalid-attr.rs:13:5
|
||||
|
|
||||
15 | #[wasm_bindgen { }]
|
||||
13 | #[wasm_bindgen { }]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,25 +1,25 @@
|
||||
error: only public enums are allowed with #[wasm_bindgen]
|
||||
--> $DIR/invalid-enums.rs:8:1
|
||||
--> $DIR/invalid-enums.rs:6:1
|
||||
|
|
||||
8 | enum A {}
|
||||
6 | enum A {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: only C-Style enums allowed with #[wasm_bindgen]
|
||||
--> $DIR/invalid-enums.rs:12:6
|
||||
--> $DIR/invalid-enums.rs:10:6
|
||||
|
|
||||
12 | D(u32),
|
||||
10 | D(u32),
|
||||
| ^^^^^
|
||||
|
||||
error: enums with #[wasm_bidngen] may only have number literal values
|
||||
--> $DIR/invalid-enums.rs:17:9
|
||||
--> $DIR/invalid-enums.rs:15:9
|
||||
|
|
||||
17 | X = 1 + 3,
|
||||
15 | X = 1 + 3,
|
||||
| ^^^^^
|
||||
|
||||
error: enums with #[wasm_bindgen] can only support numbers that can be represented as u32
|
||||
--> $DIR/invalid-enums.rs:22:9
|
||||
--> $DIR/invalid-enums.rs:20:9
|
||||
|
|
||||
22 | X = 4294967296,
|
||||
20 | X = 4294967296,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,91 +1,91 @@
|
||||
error: it is currently not sound to use lifetimes in function signatures
|
||||
--> $DIR/invalid-imports.rs:11:16
|
||||
|
|
||||
11 | fn f() -> &'static u32;
|
||||
| ^^^^^^^
|
||||
--> $DIR/invalid-imports.rs:9:16
|
||||
|
|
||||
9 | fn f() -> &'static u32;
|
||||
| ^^^^^^^
|
||||
|
||||
error: imported methods must have at least one argument
|
||||
--> $DIR/invalid-imports.rs:14:5
|
||||
--> $DIR/invalid-imports.rs:12:5
|
||||
|
|
||||
14 | fn f1();
|
||||
12 | fn f1();
|
||||
| ^^^^^^^^
|
||||
|
||||
error: first argument of method must be a shared reference
|
||||
--> $DIR/invalid-imports.rs:16:14
|
||||
--> $DIR/invalid-imports.rs:14:14
|
||||
|
|
||||
16 | fn f2(x: u32);
|
||||
14 | fn f2(x: u32);
|
||||
| ^^^
|
||||
|
||||
error: first argument of method must be a path
|
||||
--> $DIR/invalid-imports.rs:18:14
|
||||
--> $DIR/invalid-imports.rs:16:14
|
||||
|
|
||||
18 | fn f3(x: &&u32);
|
||||
16 | fn f3(x: &&u32);
|
||||
| ^^^^^
|
||||
|
||||
error: multi-segment paths are not supported yet
|
||||
--> $DIR/invalid-imports.rs:20:15
|
||||
--> $DIR/invalid-imports.rs:18:15
|
||||
|
|
||||
20 | fn f4(x: &foo::Bar);
|
||||
18 | fn f4(x: &foo::Bar);
|
||||
| ^^^^^^^^
|
||||
|
||||
error: global paths are not supported yet
|
||||
--> $DIR/invalid-imports.rs:20:15
|
||||
|
|
||||
20 | fn f4(x: &::Bar);
|
||||
| ^^^^^
|
||||
|
||||
error: paths with type parameters are not supported yet
|
||||
--> $DIR/invalid-imports.rs:22:15
|
||||
|
|
||||
22 | fn f4(x: &::Bar);
|
||||
| ^^^^^
|
||||
22 | fn f4(x: &Bar<T>);
|
||||
| ^^^^^^
|
||||
|
||||
error: paths with type parameters are not supported yet
|
||||
--> $DIR/invalid-imports.rs:24:15
|
||||
|
|
||||
24 | fn f4(x: &Bar<T>);
|
||||
| ^^^^^^
|
||||
|
||||
error: paths with type parameters are not supported yet
|
||||
--> $DIR/invalid-imports.rs:26:15
|
||||
|
|
||||
26 | fn f4(x: &Fn(T));
|
||||
24 | fn f4(x: &Fn(T));
|
||||
| ^^^^^
|
||||
|
||||
error: constructor returns must be bare types
|
||||
--> $DIR/invalid-imports.rs:29:5
|
||||
--> $DIR/invalid-imports.rs:27:5
|
||||
|
|
||||
29 | fn f();
|
||||
27 | fn f();
|
||||
| ^^^^^^^
|
||||
|
||||
error: global paths are not supported yet
|
||||
--> $DIR/invalid-imports.rs:31:15
|
||||
--> $DIR/invalid-imports.rs:29:15
|
||||
|
|
||||
31 | fn f() -> ::Bar;
|
||||
29 | fn f() -> ::Bar;
|
||||
| ^^^^^
|
||||
|
||||
error: return value of constructor must be a bare path
|
||||
--> $DIR/invalid-imports.rs:33:5
|
||||
--> $DIR/invalid-imports.rs:31:5
|
||||
|
|
||||
33 | fn f() -> &Bar;
|
||||
31 | fn f() -> &Bar;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: must be Result<...>
|
||||
--> $DIR/invalid-imports.rs:34:15
|
||||
|
|
||||
34 | fn f() -> u32;
|
||||
| ^^^
|
||||
|
||||
error: must be Result<...>
|
||||
--> $DIR/invalid-imports.rs:36:15
|
||||
|
|
||||
36 | fn f() -> u32;
|
||||
| ^^^
|
||||
|
||||
error: must be Result<...>
|
||||
--> $DIR/invalid-imports.rs:38:15
|
||||
|
|
||||
38 | fn f() -> &u32;
|
||||
36 | fn f() -> &u32;
|
||||
| ^^^^
|
||||
|
||||
error: must have at least one generic parameter
|
||||
--> $DIR/invalid-imports.rs:40:15
|
||||
--> $DIR/invalid-imports.rs:38:15
|
||||
|
|
||||
40 | fn f() -> Result<>;
|
||||
38 | fn f() -> Result<>;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: it is currently not sound to use lifetimes in function signatures
|
||||
--> $DIR/invalid-imports.rs:42:22
|
||||
--> $DIR/invalid-imports.rs:40:22
|
||||
|
|
||||
42 | fn f() -> Result<'a>;
|
||||
40 | fn f() -> Result<'a>;
|
||||
| ^^
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,67 +1,67 @@
|
||||
error: can only #[wasm_bindgen] public functions
|
||||
--> $DIR/invalid-items.rs:8:1
|
||||
--> $DIR/invalid-items.rs:6:1
|
||||
|
|
||||
8 | fn foo() {}
|
||||
6 | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: can only #[wasm_bindgen] safe functions
|
||||
--> $DIR/invalid-items.rs:11:5
|
||||
|
|
||||
11 | pub unsafe fn foo1() {}
|
||||
| ^^^^^^
|
||||
--> $DIR/invalid-items.rs:9:5
|
||||
|
|
||||
9 | pub unsafe fn foo1() {}
|
||||
| ^^^^^^
|
||||
|
||||
error: can only #[wasm_bindgen] non-const functions
|
||||
--> $DIR/invalid-items.rs:14:5
|
||||
--> $DIR/invalid-items.rs:12:5
|
||||
|
|
||||
14 | pub const fn foo2() {}
|
||||
12 | pub const fn foo2() {}
|
||||
| ^^^^^
|
||||
|
||||
error: structs with #[wasm_bindgen] cannot have lifetime or type parameters currently
|
||||
--> $DIR/invalid-items.rs:17:11
|
||||
--> $DIR/invalid-items.rs:15:11
|
||||
|
|
||||
17 | struct Foo<T>(T);
|
||||
15 | struct Foo<T>(T);
|
||||
| ^^^
|
||||
|
||||
error: cannot import mutable globals yet
|
||||
--> $DIR/invalid-items.rs:21:12
|
||||
--> $DIR/invalid-items.rs:19:12
|
||||
|
|
||||
21 | static mut FOO: u32;
|
||||
19 | static mut FOO: u32;
|
||||
| ^^^
|
||||
|
||||
error: can't #[wasm_bindgen] variadic functions
|
||||
--> $DIR/invalid-items.rs:23:25
|
||||
--> $DIR/invalid-items.rs:21:25
|
||||
|
|
||||
23 | pub fn foo3(x: i32, ...);
|
||||
21 | pub fn foo3(x: i32, ...);
|
||||
| ^^^
|
||||
|
||||
error: only foreign mods with the `C` ABI are allowed
|
||||
--> $DIR/invalid-items.rs:27:8
|
||||
--> $DIR/invalid-items.rs:25:8
|
||||
|
|
||||
27 | extern "system" {
|
||||
25 | extern "system" {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
||||
--> $DIR/invalid-items.rs:29:12
|
||||
|
|
||||
29 | pub fn foo4<T>() {}
|
||||
| ^^^
|
||||
|
||||
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
||||
--> $DIR/invalid-items.rs:31:12
|
||||
|
|
||||
31 | pub fn foo4<T>() {}
|
||||
| ^^^
|
||||
31 | pub fn foo5<'a>() {}
|
||||
| ^^^^
|
||||
|
||||
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
||||
--> $DIR/invalid-items.rs:33:12
|
||||
|
|
||||
33 | pub fn foo5<'a>() {}
|
||||
| ^^^^
|
||||
|
||||
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
||||
--> $DIR/invalid-items.rs:35:12
|
||||
|
|
||||
35 | pub fn foo6<'a, T>() {}
|
||||
33 | pub fn foo6<'a, T>() {}
|
||||
| ^^^^^^^
|
||||
|
||||
error: #[wasm_bindgen] can only be applied to a function, struct, enum, impl, or extern block
|
||||
--> $DIR/invalid-items.rs:38:1
|
||||
--> $DIR/invalid-items.rs:36:1
|
||||
|
|
||||
38 | trait X {}
|
||||
36 | trait X {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,61 +1,61 @@
|
||||
error: #[wasm_bindgen] default impls are not supported
|
||||
--> $DIR/invalid-methods.rs:11:1
|
||||
|
|
||||
11 | default impl A {
|
||||
| ^^^^^^^
|
||||
--> $DIR/invalid-methods.rs:9:1
|
||||
|
|
||||
9 | default impl A {
|
||||
| ^^^^^^^
|
||||
|
||||
error: #[wasm_bindgen] unsafe impls are not supported
|
||||
--> $DIR/invalid-methods.rs:15:1
|
||||
--> $DIR/invalid-methods.rs:13:1
|
||||
|
|
||||
15 | unsafe impl A {
|
||||
13 | unsafe impl A {
|
||||
| ^^^^^^
|
||||
|
||||
error: #[wasm_bindgen] trait impls are not supported
|
||||
--> $DIR/invalid-methods.rs:19:6
|
||||
--> $DIR/invalid-methods.rs:17:6
|
||||
|
|
||||
19 | impl Clone for A {
|
||||
17 | impl Clone for A {
|
||||
| ^^^^^
|
||||
|
||||
error: #[wasm_bindgen] generic impls aren't supported
|
||||
--> $DIR/invalid-methods.rs:23:5
|
||||
--> $DIR/invalid-methods.rs:21:5
|
||||
|
|
||||
23 | impl<T> A {
|
||||
21 | impl<T> A {
|
||||
| ^^^
|
||||
|
||||
error: unsupported self type in #[wasm_bindgen] impl
|
||||
--> $DIR/invalid-methods.rs:27:6
|
||||
--> $DIR/invalid-methods.rs:25:6
|
||||
|
|
||||
27 | impl &'static A {
|
||||
25 | impl &'static A {
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: const definitions aren't supported with #[wasm_bindgen]
|
||||
--> $DIR/invalid-methods.rs:34:5
|
||||
--> $DIR/invalid-methods.rs:32:5
|
||||
|
|
||||
34 | const X: u32 = 3;
|
||||
32 | const X: u32 = 3;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type definitions in impls aren't supported with #[wasm_bindgen]
|
||||
--> $DIR/invalid-methods.rs:35:5
|
||||
--> $DIR/invalid-methods.rs:33:5
|
||||
|
|
||||
35 | type Y = u32;
|
||||
33 | type Y = u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: macros in impls aren't supported
|
||||
--> $DIR/invalid-methods.rs:36:5
|
||||
--> $DIR/invalid-methods.rs:34:5
|
||||
|
|
||||
36 | x!();
|
||||
34 | x!();
|
||||
| ^^^^^
|
||||
|
||||
error: can only #[wasm_bindgen] non-const functions
|
||||
--> $DIR/invalid-methods.rs:41:9
|
||||
--> $DIR/invalid-methods.rs:39:9
|
||||
|
|
||||
41 | pub const fn foo() {}
|
||||
39 | pub const fn foo() {}
|
||||
| ^^^^^
|
||||
|
||||
error: can only bindgen safe functions
|
||||
--> $DIR/invalid-methods.rs:42:9
|
||||
--> $DIR/invalid-methods.rs:40:9
|
||||
|
|
||||
42 | pub unsafe fn foo() {}
|
||||
40 | pub unsafe fn foo() {}
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: can only #[wasm_bindgen] public functions
|
||||
--> $DIR/non-public-function.rs:8:1
|
||||
--> $DIR/non-public-function.rs:6:1
|
||||
|
|
||||
8 | fn foo() {}
|
||||
6 | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -38,8 +38,6 @@ ton of documentation just yet, but a taste of how it works is:
|
||||
|
||||
```rust
|
||||
// in tests/wasm.rs
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
|
||||
use wasm_bindgen_test::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate futures;
|
||||
extern crate js_sys;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate futures;
|
||||
extern crate sample;
|
||||
extern crate wasm_bindgen;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate futures;
|
||||
extern crate sample;
|
||||
extern crate wasm_bindgen;
|
||||
|
@ -2,7 +2,6 @@
|
||||
//!
|
||||
//! More documentation can be found in the README for this crate!
|
||||
|
||||
#![feature(use_extern_macros)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
extern crate console_error_panic_hook;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate futures;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate js_sys;
|
||||
extern crate wasm_bindgen;
|
||||
extern crate wasm_bindgen_test;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate js_sys;
|
||||
extern crate wasm_bindgen;
|
||||
extern crate web_sys;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -7,5 +7,5 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = { path = "../.." }
|
||||
wasm-bindgen = { path = "../..", features = ['nightly'] }
|
||||
js-sys = { path = "../../crates/js-sys" }
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate web_sys;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
#![allow(unused_variables, dead_code)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate humantime;
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros, nll)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate web_sys;
|
||||
|
||||
@ -45,13 +43,20 @@ impl FmOsc {
|
||||
// TODO, how to throw from a constructor?
|
||||
|
||||
let ctx = web_sys::AudioContext::new().unwrap();
|
||||
let base: &BaseAudioContext = ctx.as_ref();
|
||||
let primary;
|
||||
let fm_osc;
|
||||
let gain;
|
||||
let fm_gain;
|
||||
|
||||
// create our web audio objects
|
||||
let primary = base.create_oscillator().unwrap();
|
||||
let fm_osc = base.create_oscillator().unwrap();
|
||||
let gain = base.create_gain().unwrap();
|
||||
let fm_gain = base.create_gain().unwrap();
|
||||
{
|
||||
let base: &BaseAudioContext = ctx.as_ref();
|
||||
|
||||
// create our web audio objects
|
||||
primary = base.create_oscillator().unwrap();
|
||||
fm_osc = base.create_oscillator().unwrap();
|
||||
gain = base.create_gain().unwrap();
|
||||
fm_gain = base.create_gain().unwrap();
|
||||
}
|
||||
|
||||
// some initial settings:
|
||||
primary.set_type(OscillatorType::Sine);
|
||||
@ -63,27 +68,30 @@ impl FmOsc {
|
||||
|
||||
|
||||
// Create base class references:
|
||||
let primary_node: &AudioNode = primary.as_ref();
|
||||
let gain_node: &AudioNode = gain.as_ref();
|
||||
let fm_osc_node: &AudioNode = fm_osc.as_ref();
|
||||
let fm_gain_node: &AudioNode = fm_gain.as_ref();
|
||||
let destination = base.destination();
|
||||
let destination_node: &AudioNode = destination.as_ref();
|
||||
{
|
||||
let primary_node: &AudioNode = primary.as_ref();
|
||||
let gain_node: &AudioNode = gain.as_ref();
|
||||
let fm_osc_node: &AudioNode = fm_osc.as_ref();
|
||||
let fm_gain_node: &AudioNode = fm_gain.as_ref();
|
||||
let base: &BaseAudioContext = ctx.as_ref();
|
||||
let destination = base.destination();
|
||||
let destination_node: &AudioNode = destination.as_ref();
|
||||
|
||||
|
||||
// connect them up:
|
||||
// connect them up:
|
||||
|
||||
// The primary oscillator is routed through the gain node, so that it can control the overall output volume
|
||||
primary_node.connect_with_destination_and_output_and_input_using_destination(gain.as_ref());
|
||||
// Then connect the gain node to the AudioContext destination (aka your speakers)
|
||||
gain_node.connect_with_destination_and_output_and_input_using_destination(destination_node);
|
||||
// The primary oscillator is routed through the gain node, so that it can control the overall output volume
|
||||
primary_node.connect_with_destination_and_output_and_input_using_destination(gain.as_ref());
|
||||
// Then connect the gain node to the AudioContext destination (aka your speakers)
|
||||
gain_node.connect_with_destination_and_output_and_input_using_destination(destination_node);
|
||||
|
||||
// the FM oscillator is connected to its own gain node, so it can control the amount of modulation
|
||||
fm_osc_node.connect_with_destination_and_output_and_input_using_destination(fm_gain.as_ref());
|
||||
// the FM oscillator is connected to its own gain node, so it can control the amount of modulation
|
||||
fm_osc_node.connect_with_destination_and_output_and_input_using_destination(fm_gain.as_ref());
|
||||
|
||||
// Connect the FM oscillator to the frequency parameter of the main oscillator, so that the
|
||||
// FM node can modulate its frequency
|
||||
fm_gain_node.connect_with_destination_and_output_using_destination(&primary.frequency());
|
||||
// Connect the FM oscillator to the frequency parameter of the main oscillator, so that the
|
||||
// FM node can modulate its frequency
|
||||
fm_gain_node.connect_with_destination_and_output_using_destination(&primary.frequency());
|
||||
}
|
||||
|
||||
|
||||
// start the oscillators!
|
||||
@ -144,4 +152,4 @@ impl FmOsc {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ wasm-bindgen = "0.2"
|
||||
Next up our actual code! We'll write this in `src/lib.rs`:
|
||||
|
||||
```rust,ignore
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
@ -5,8 +5,6 @@ can also [explore this code online](https://webassembly.studio/?f=t61j18noqz):
|
||||
|
||||
```rust,ignore
|
||||
// src/lib.rs
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#![allow(const_err)] // FIXME(rust-lang/rust#52603)
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
#[cfg(feature = "nightly")]
|
||||
use std::marker::Unsize;
|
||||
use std::mem::{self, ManuallyDrop};
|
||||
use std::prelude::v1::*;
|
||||
@ -90,6 +91,7 @@ impl<T> Closure<T>
|
||||
///
|
||||
/// This is unfortunately pretty restrictive for now but hopefully some of
|
||||
/// these restrictions can be lifted in the future!
|
||||
#[cfg(feature = "nightly")]
|
||||
pub fn new<F>(t: F) -> Closure<T>
|
||||
where F: Unsize<T> + 'static
|
||||
{
|
||||
|
@ -5,9 +5,9 @@
|
||||
//! this crate and this crate also provides JS bindings through the `JsValue`
|
||||
//! interface.
|
||||
|
||||
#![feature(use_extern_macros, unsize)]
|
||||
#![no_std]
|
||||
#![doc(html_root_url = "https://docs.rs/wasm-bindgen/0.2")]
|
||||
#![cfg_attr(feature = "nightly", feature(unsize))]
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
extern crate serde;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
extern crate wasm_bindgen;
|
||||
|
@ -4,7 +4,6 @@
|
||||
//! This doesn't actually run any tests, it's mostly a compile-time verification
|
||||
//! that things work.
|
||||
|
||||
#![feature(use_extern_macros)]
|
||||
#![no_std]
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -2,7 +2,6 @@
|
||||
//! `wasm-bindgen` is compiled itself with the `std` feature and everything
|
||||
//! works out just fine.
|
||||
|
||||
#![feature(use_extern_macros)]
|
||||
#![no_std]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg(feature = "nightly")]
|
||||
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use std::cell::Cell;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
extern crate wasm_bindgen;
|
||||
|
Loading…
Reference in New Issue
Block a user