Merge pull request #1645 from derekdreery/fix_futures_0_3_hack

Add in (unsafe and incorrect) impls of Send/Sync that are now required.
This commit is contained in:
Alex Crichton 2019-07-08 12:04:43 -05:00 committed by GitHub
commit 604c036111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 18 deletions

View File

@ -130,8 +130,7 @@ impl<'a, 'b> Builder<'a, 'b> {
// returning data through.
if binding.return_via_outptr.is_some() {
drop(webidl_params.next());
self.args_prelude
.push_str("const retptr = 8;\n");
self.args_prelude.push_str("const retptr = 8;\n");
arg_names.push("retptr".to_string());
}

View File

@ -26,8 +26,8 @@ use wasm_bindgen::prelude::*;
pub struct JsFuture {
resolved: oneshot::Receiver<JsValue>,
rejected: oneshot::Receiver<JsValue>,
_cb_resolve: Closure<FnMut(JsValue)>,
_cb_reject: Closure<FnMut(JsValue)>,
_cb_resolve: Closure<dyn FnMut(JsValue)>,
_cb_reject: Closure<dyn FnMut(JsValue)>,
}
impl fmt::Debug for JsFuture {
@ -143,6 +143,10 @@ where
is_queued: Cell<bool>,
}
// TODO This is only safe because JS is currently single-threaded
unsafe impl Send for Task {}
unsafe impl Sync for Task {}
impl Task {
#[inline]
fn new<F>(future: F) -> Arc<Self>

View File

@ -1079,7 +1079,6 @@ extern "C" {
#[wasm_bindgen(method, js_name = bind)]
pub fn bind(this: &Function, context: &JsValue) -> Function;
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
/// with a given sequence of arguments preceding any provided when the new function is called.
///
@ -1092,23 +1091,14 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
#[wasm_bindgen(method, js_name = bind)]
pub fn bind1(
this: &Function,
context: &JsValue,
arg1: &JsValue,
) -> Function;
pub fn bind1(this: &Function, context: &JsValue, arg1: &JsValue) -> Function;
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
/// with a given sequence of arguments preceding any provided when the new function is called.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
#[wasm_bindgen(method, js_name = bind)]
pub fn bind2(
this: &Function,
context: &JsValue,
arg1: &JsValue,
arg2: &JsValue,
) -> Function;
pub fn bind2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Function;
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
/// with a given sequence of arguments preceding any provided when the new function is called.

View File

@ -90,7 +90,12 @@ fn bind2() {
#[wasm_bindgen_test]
fn bind3() {
let a_list = list();
let prepended_list = a_list.bind3(&JsValue::NULL, &JsValue::from(2), &JsValue::from(3), &JsValue::from(4));
let prepended_list = a_list.bind3(
&JsValue::NULL,
&JsValue::from(2),
&JsValue::from(3),
&JsValue::from(4),
);
let arr = Array::from(&call_function(&prepended_list));

View File

@ -4,8 +4,8 @@ use std::prelude::v1::*;
use core::slice;
use core::str;
use crate::convert::{FromWasmAbi, IntoWasmAbi, RefFromWasmAbi, RefMutFromWasmAbi, WasmAbi};
use crate::convert::OptionIntoWasmAbi;
use crate::convert::{FromWasmAbi, IntoWasmAbi, RefFromWasmAbi, RefMutFromWasmAbi, WasmAbi};
if_std! {
use core::mem;