1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-04-02 10:21:07 +00:00

fixed value types in Atomics methods

This commit is contained in:
ibaryshnikov 2019-04-24 00:25:25 +08:00
parent 1071457c3d
commit f1eaefdf0d

@ -438,7 +438,6 @@ extern "C" {
pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
}
// SharedArrayBuffer
#[wasm_bindgen]
extern "C" {
@ -504,9 +503,21 @@ extern "C" {
pub fn values(this: &Array) -> Iterator;
}
// Atomics
#[wasm_bindge]
extern "C" {
/// The `Atomics` object provides atomic operations as static methods.
/// They are used with `SharedArrayBuffer` objects.
///
/// The Atomic operations are installed on an `Atomics` module. Unlike
/// the other global objects, Atomics is not a constructor. You cannot
/// use it with a new operator or invoke the `Atomics` object as a
/// function. All properties and methods of `Atomics` are static
/// (as is the case with the Math object, for example).
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
#[allow(non_snake_case)]
pub mod Atomics {
use super::*;
#[wasm_bindgen]
extern "C" {
#[derive(Clone, Debug)]
#[wasm_bindgen(extends = Object)]
pub type Atomics;
@ -518,7 +529,7 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn add(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn add(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
/// The static `Atomics.and()` method computes a bitwise AND with a given
/// value at a given position in the array, and returns the old value
@ -528,7 +539,7 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn and(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn and(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
/// The static `Atomics.compareExchange()` method exchanges a given
/// replacement value at a given position in the array, if a given expected
@ -542,9 +553,9 @@ extern "C" {
pub fn compare_exchange(
typed_array: &JsValue,
index: u32,
expected_value: &JsValue,
replacement_value: &JsValue,
) -> Result<JsValue, JsValue>;
expected_value: f32,
replacement_value: f32,
) -> Result<f32, JsValue>;
/// The static `Atomics.exchange()` method stores a given value at a given
/// position in the array and returns the old value at that position.
@ -553,7 +564,7 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn exchange(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn exchange(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
/// The static `Atomics.isLockFree()` method is used to determine
/// whether to use locks or atomic operations. It returns true,
@ -569,7 +580,7 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn load(typed_array: &JsValue, index: u32) -> Result<JsValue, JsValue>;
pub fn load(typed_array: &JsValue, index: u32) -> Result<f32, JsValue>;
/// The static `Atomics.notify()` method notifies up some agents that
/// are sleeping in the wait queue.
@ -577,7 +588,7 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn notify(typed_array: &JsValue, index: u32, count: u32) -> Result<JsValue, JsValue>;
pub fn notify(typed_array: &JsValue, index: u32, count: u32) -> Result<u32, JsValue>;
/// The static `Atomics.or()` method computes a bitwise OR with a given value
/// at a given position in the array, and returns the old value at that position.
@ -586,14 +597,14 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn or(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn or(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
/// The static `Atomics.store()` method stores a given value at the given
/// position in the array and returns that value.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn store(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn store(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
/// The static `Atomics.sub()` method substracts a given value at a
/// given position in the array and returns the old value at that position.
@ -602,7 +613,7 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn sub(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn sub(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
/// The static `Atomics.wait()` method verifies that a given
/// position in an `Int32Array` still contains a given value
@ -613,13 +624,18 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn wait(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn wait(typed_array: &JsValue, index: u32, value: i32) -> Result<JsValue, JsValue>;
/// Like `wait()`, but with timeout
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn wait_with_timeout(typed_array: &JsValue, index: u32, value: JsValue, timeout: u32) -> Result<JsValue, JsValue>;
pub fn wait_with_timeout(
typed_array: &JsValue,
index: u32,
value: i32,
timeout: f32,
) -> Result<JsValue, JsValue>;
/// The static `Atomics.xor()` method computes a bitwise XOR
/// with a given value at a given position in the array,
@ -629,7 +645,8 @@ extern "C" {
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
#[wasm_bindgen(static_method_of = Atomics, catch)]
pub fn xor(typed_array: &JsValue, index: u32, value: JsValue) -> Result<JsValue, JsValue>;
pub fn xor(typed_array: &JsValue, index: u32, value: f32) -> Result<f32, JsValue>;
}
}
// Boolean