mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 06:02:13 +00:00
Run rustfmt
This commit is contained in:
parent
a20dd26dde
commit
513285f73d
@ -456,10 +456,7 @@ impl TryToTokens for ast::Export {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(
|
(quote! { #syn_ret }, quote! { #ret })
|
||||||
quote! { #syn_ret },
|
|
||||||
quote! { #ret },
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
let projection = quote! { <#ret_ty as wasm_bindgen::convert::ReturnWasmAbi> };
|
let projection = quote! { <#ret_ty as wasm_bindgen::convert::ReturnWasmAbi> };
|
||||||
let convert_ret = quote! { #projection::return_abi(#ret_expr) };
|
let convert_ret = quote! { #projection::return_abi(#ret_expr) };
|
||||||
|
@ -198,7 +198,7 @@ fn shared_function<'a>(func: &'a ast::Function, _intern: &'a Interner) -> Functi
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, arg)| {
|
.map(|(idx, arg)| {
|
||||||
if let syn::Pat::Ident(x) = &*arg.pat {
|
if let syn::Pat::Ident(x) = &*arg.pat {
|
||||||
return x.ident.to_string()
|
return x.ident.to_string();
|
||||||
}
|
}
|
||||||
format!("arg{}", idx)
|
format!("arg{}", idx)
|
||||||
})
|
})
|
||||||
|
@ -520,9 +520,7 @@ fn check_standard_import(import: &AuxImport) -> Result<(), Error> {
|
|||||||
| AuxImport::Value(AuxValue::ClassSetter(js, name)) => {
|
| AuxImport::Value(AuxValue::ClassSetter(js, name)) => {
|
||||||
format!("field access of `{}` for {}", name, desc_js(js))
|
format!("field access of `{}` for {}", name, desc_js(js))
|
||||||
}
|
}
|
||||||
AuxImport::ValueWithThis(js, method) => {
|
AuxImport::ValueWithThis(js, method) => format!("method `{}.{}`", desc_js(js), method),
|
||||||
format!("method `{}.{}`", desc_js(js), method)
|
|
||||||
}
|
|
||||||
AuxImport::Instanceof(js) => format!("instance of check of {}", desc_js(js)),
|
AuxImport::Instanceof(js) => format!("instance of check of {}", desc_js(js)),
|
||||||
AuxImport::Static(js) => format!("static js value {}", desc_js(js)),
|
AuxImport::Static(js) => format!("static js value {}", desc_js(js)),
|
||||||
AuxImport::StructuralMethod(name) => format!("structural method `{}`", name),
|
AuxImport::StructuralMethod(name) => format!("structural method `{}`", name),
|
||||||
|
@ -29,45 +29,37 @@ fn to_rust(arr: &Array) -> Vec<JsValue> {
|
|||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn from_iter() {
|
fn from_iter() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_rust(&vec![
|
to_rust(
|
||||||
JsValue::from("a"),
|
&vec![JsValue::from("a"), JsValue::from("b"), JsValue::from("c"),]
|
||||||
JsValue::from("b"),
|
.into_iter()
|
||||||
JsValue::from("c"),
|
.collect()
|
||||||
].into_iter().collect()),
|
),
|
||||||
vec!["a", "b", "c"],
|
vec!["a", "b", "c"],
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_rust(&vec![
|
to_rust(
|
||||||
JsValue::from("a"),
|
&vec![JsValue::from("a"), JsValue::from("b"), JsValue::from("c"),]
|
||||||
JsValue::from("b"),
|
.iter()
|
||||||
JsValue::from("c"),
|
.collect()
|
||||||
].iter().collect()),
|
),
|
||||||
vec!["a", "b", "c"],
|
vec!["a", "b", "c"],
|
||||||
);
|
);
|
||||||
|
|
||||||
let array = js_array![1u32, 2u32, 3u32];
|
let array = js_array![1u32, 2u32, 3u32];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_rust(&vec![
|
to_rust(&vec![array.clone(),].into_iter().collect()),
|
||||||
array.clone(),
|
|
||||||
].into_iter().collect()),
|
|
||||||
vec![JsValue::from(array.clone())],
|
vec![JsValue::from(array.clone())],
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_rust(&vec![
|
to_rust(&vec![array.clone(),].iter().collect()),
|
||||||
array.clone(),
|
|
||||||
].iter().collect()),
|
|
||||||
vec![JsValue::from(array)],
|
vec![JsValue::from(array)],
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_rust(&vec![
|
to_rust(&vec![5, 10, 20,].into_iter().map(JsValue::from).collect()),
|
||||||
5,
|
|
||||||
10,
|
|
||||||
20,
|
|
||||||
].into_iter().map(JsValue::from).collect()),
|
|
||||||
vec![5, 10, 20],
|
vec![5, 10, 20],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -80,11 +72,7 @@ fn from_iter() {
|
|||||||
vec!["a", "b", "c"],
|
vec!["a", "b", "c"],
|
||||||
);
|
);
|
||||||
|
|
||||||
let v = vec![
|
let v = vec!["a", "b", "c"];
|
||||||
"a",
|
|
||||||
"b",
|
|
||||||
"c",
|
|
||||||
];
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_rust(&Array::from_iter(v.into_iter().map(|s| JsValue::from(s)))),
|
to_rust(&Array::from_iter(v.into_iter().map(|s| JsValue::from(s)))),
|
||||||
|
@ -1019,8 +1019,7 @@ impl MacroParse<()> for syn::ItemEnum {
|
|||||||
attrs: _,
|
attrs: _,
|
||||||
lit: syn::Lit::Int(int_lit),
|
lit: syn::Lit::Int(int_lit),
|
||||||
}),
|
}),
|
||||||
)) => {
|
)) => match int_lit.base10_digits().parse::<u32>() {
|
||||||
match int_lit.base10_digits().parse::<u32>() {
|
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
bail_span!(
|
bail_span!(
|
||||||
@ -1029,8 +1028,7 @@ impl MacroParse<()> for syn::ItemEnum {
|
|||||||
numbers that can be represented as u32"
|
numbers that can be represented as u32"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
None => i as u32,
|
None => i as u32,
|
||||||
Some((_, expr)) => bail_span!(
|
Some((_, expr)) => bail_span!(
|
||||||
expr,
|
expr,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use js_sys::Promise;
|
use js_sys::Promise;
|
||||||
use std::task::{Poll, Context};
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
use std::task::{Context, Poll};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use std::future::Future;
|
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
|
|
||||||
pub struct Timeout {
|
pub struct Timeout {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::time::Duration;
|
|
||||||
use sample::Timeout;
|
use sample::Timeout;
|
||||||
|
use std::time::Duration;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
|
@ -33,20 +33,58 @@ fn test_html_element() {
|
|||||||
element.set_hidden(true);
|
element.set_hidden(true);
|
||||||
assert!(element.hidden(), "Should be hidden");
|
assert!(element.hidden(), "Should be hidden");
|
||||||
|
|
||||||
assert_eq!(element.class_list().get(0), None, "Shouldn't have class at index 0");
|
assert_eq!(
|
||||||
|
element.class_list().get(0),
|
||||||
|
None,
|
||||||
|
"Shouldn't have class at index 0"
|
||||||
|
);
|
||||||
element.class_list().add_2("a", "b").unwrap();
|
element.class_list().add_2("a", "b").unwrap();
|
||||||
assert_eq!(element.class_list().get(0).unwrap(), "a", "Should have class at index 0");
|
assert_eq!(
|
||||||
assert_eq!(element.class_list().get(1).unwrap(), "b", "Should have class at index 1");
|
element.class_list().get(0).unwrap(),
|
||||||
assert_eq!(element.class_list().get(2), None, "Shouldn't have class at index 2");
|
"a",
|
||||||
|
"Should have class at index 0"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
element.class_list().get(1).unwrap(),
|
||||||
|
"b",
|
||||||
|
"Should have class at index 1"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
element.class_list().get(2),
|
||||||
|
None,
|
||||||
|
"Shouldn't have class at index 2"
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(element.dataset().get("id"), None, "Shouldn't have data-id");
|
assert_eq!(element.dataset().get("id"), None, "Shouldn't have data-id");
|
||||||
element.dataset().set("id", "123").unwrap();
|
element.dataset().set("id", "123").unwrap();
|
||||||
assert_eq!(element.dataset().get("id").unwrap(), "123", "Should have data-id");
|
assert_eq!(
|
||||||
|
element.dataset().get("id").unwrap(),
|
||||||
|
"123",
|
||||||
|
"Should have data-id"
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(element.style().get(0), None, "Shouldn't have style property name at index 0");
|
assert_eq!(
|
||||||
element.style().set_property("background-color", "red").unwrap();
|
element.style().get(0),
|
||||||
assert_eq!(element.style().get(0).unwrap(), "background-color", "Should have style property at index 0");
|
None,
|
||||||
assert_eq!(element.style().get_property_value("background-color").unwrap(), "red", "Should have style property");
|
"Shouldn't have style property name at index 0"
|
||||||
|
);
|
||||||
|
element
|
||||||
|
.style()
|
||||||
|
.set_property("background-color", "red")
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
element.style().get(0).unwrap(),
|
||||||
|
"background-color",
|
||||||
|
"Should have style property at index 0"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
element
|
||||||
|
.style()
|
||||||
|
.get_property_value("background-color")
|
||||||
|
.unwrap(),
|
||||||
|
"red",
|
||||||
|
"Should have style property"
|
||||||
|
);
|
||||||
|
|
||||||
// TODO add a click handler here
|
// TODO add a click handler here
|
||||||
element.click();
|
element.click();
|
||||||
|
@ -62,11 +62,19 @@ async fn exchange_sdps(
|
|||||||
) -> (RtcPeerConnection, RtcPeerConnection) {
|
) -> (RtcPeerConnection, RtcPeerConnection) {
|
||||||
let offer = JsFuture::from(p1.create_offer()).await.unwrap();
|
let offer = JsFuture::from(p1.create_offer()).await.unwrap();
|
||||||
let offer = offer.unchecked_into::<RtcSessionDescriptionInit>();
|
let offer = offer.unchecked_into::<RtcSessionDescriptionInit>();
|
||||||
JsFuture::from(p1.set_local_description(&offer)).await.unwrap();
|
JsFuture::from(p1.set_local_description(&offer))
|
||||||
JsFuture::from(p2.set_remote_description(&offer)).await.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
|
JsFuture::from(p2.set_remote_description(&offer))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let answer = JsFuture::from(p2.create_answer()).await.unwrap();
|
let answer = JsFuture::from(p2.create_answer()).await.unwrap();
|
||||||
let answer = answer.unchecked_into::<RtcSessionDescriptionInit>();
|
let answer = answer.unchecked_into::<RtcSessionDescriptionInit>();
|
||||||
JsFuture::from(p2.set_local_description(&answer)).await.unwrap();
|
JsFuture::from(p2.set_local_description(&answer))
|
||||||
JsFuture::from(p1.set_remote_description(&answer)).await.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
|
JsFuture::from(p1.set_remote_description(&answer))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
(p1, p2)
|
(p1, p2)
|
||||||
}
|
}
|
||||||
|
@ -585,11 +585,13 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
// otherwise be marked with catch).
|
// otherwise be marked with catch).
|
||||||
match ret_ty {
|
match ret_ty {
|
||||||
IdlType::Nullable(_) => ret_ty,
|
IdlType::Nullable(_) => ret_ty,
|
||||||
ref ty @ _ => if catch {
|
ref ty @ _ => {
|
||||||
|
if catch {
|
||||||
ret_ty
|
ret_ty
|
||||||
} else {
|
} else {
|
||||||
IdlType::Nullable(Box::new(ty.clone()))
|
IdlType::Nullable(Box::new(ty.clone()))
|
||||||
},
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret_ty
|
ret_ty
|
||||||
|
@ -820,9 +820,9 @@ pub fn function_table() -> JsValue {
|
|||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod __rt {
|
pub mod __rt {
|
||||||
|
use crate::JsValue;
|
||||||
use core::cell::{Cell, UnsafeCell};
|
use core::cell::{Cell, UnsafeCell};
|
||||||
use core::ops::{Deref, DerefMut};
|
use core::ops::{Deref, DerefMut};
|
||||||
use crate::JsValue;
|
|
||||||
|
|
||||||
pub extern crate core;
|
pub extern crate core;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
@ -8,7 +8,9 @@ extern "C" {
|
|||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
async fn smoke() {
|
async fn smoke() {
|
||||||
wasm_bindgen_futures::JsFuture::from(call_exports()).await.unwrap();
|
wasm_bindgen_futures::JsFuture::from(call_exports())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen::{JsCast, intern, unintern};
|
use wasm_bindgen::{intern, unintern, JsCast};
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
#[wasm_bindgen(module = "tests/wasm/simple.js")]
|
#[wasm_bindgen(module = "tests/wasm/simple.js")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user