Skip to content

Commit b05ae44

Browse files
author
ibaryshnikov
committed
changed f64 to i32 in static methods of Atomics, changed static_method_of to js_namespace, set typed_array type to Int32Array in notify and wait methods
1 parent 58245b0 commit b05ae44

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

crates/js-sys/src/lib.rs

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ extern "C" {
507507
/// They are used with `SharedArrayBuffer` objects.
508508
///
509509
/// The Atomic operations are installed on an `Atomics` module. Unlike
510-
/// the other global objects, Atomics is not a constructor. You cannot
510+
/// the other global objects, `Atomics` is not a constructor. You cannot
511511
/// use it with a new operator or invoke the `Atomics` object as a
512512
/// function. All properties and methods of `Atomics` are static
513513
/// (as is the case with the Math object, for example).
@@ -518,18 +518,14 @@ pub mod Atomics {
518518

519519
#[wasm_bindgen]
520520
extern "C" {
521-
#[derive(Clone, Debug)]
522-
#[wasm_bindgen(extends = Object)]
523-
pub type Atomics;
524-
525521
/// The static `Atomics.add()` method adds a given value at a given
526522
/// position in the array and returns the old value at that position.
527523
/// This atomic operation guarantees that no other write happens
528524
/// until the modified value is written back.
529525
///
530526
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
531-
#[wasm_bindgen(static_method_of = Atomics, catch)]
532-
pub fn add(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
527+
#[wasm_bindgen(js_namespace = Atomics, catch)]
528+
pub fn add(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
533529

534530
/// The static `Atomics.and()` method computes a bitwise AND with a given
535531
/// value at a given position in the array, and returns the old value
@@ -538,8 +534,8 @@ pub mod Atomics {
538534
/// until the modified value is written back.
539535
///
540536
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
541-
#[wasm_bindgen(static_method_of = Atomics, catch)]
542-
pub fn and(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
537+
#[wasm_bindgen(js_namespace = Atomics, catch)]
538+
pub fn and(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
543539

544540
/// The static `Atomics.compareExchange()` method exchanges a given
545541
/// replacement value at a given position in the array, if a given expected
@@ -549,71 +545,71 @@ pub mod Atomics {
549545
/// until the modified value is written back.
550546
///
551547
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
552-
#[wasm_bindgen(static_method_of = Atomics, catch, js_name = compareExchange)]
548+
#[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
553549
pub fn compare_exchange(
554550
typed_array: &JsValue,
555551
index: u32,
556-
expected_value: f64,
557-
replacement_value: f64,
558-
) -> Result<f64, JsValue>;
552+
expected_value: i32,
553+
replacement_value: i32,
554+
) -> Result<i32, JsValue>;
559555

560556
/// The static `Atomics.exchange()` method stores a given value at a given
561557
/// position in the array and returns the old value at that position.
562558
/// This atomic operation guarantees that no other write happens
563559
/// until the modified value is written back.
564560
///
565561
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
566-
#[wasm_bindgen(static_method_of = Atomics, catch)]
567-
pub fn exchange(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
562+
#[wasm_bindgen(js_namespace = Atomics, catch)]
563+
pub fn exchange(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
568564

569565
/// The static `Atomics.isLockFree()` method is used to determine
570566
/// whether to use locks or atomic operations. It returns true,
571567
/// if the given size is one of the `BYTES_PER_ELEMENT` property
572568
/// of integer `TypedArray` types.
573569
///
574570
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
575-
#[wasm_bindgen(static_method_of = Atomics, js_name = isLockFree)]
571+
#[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
576572
pub fn is_lock_free(size: u32) -> bool;
577573

578574
/// The static `Atomics.load()` method returns a value at a given
579575
/// position in the array.
580576
///
581577
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
582-
#[wasm_bindgen(static_method_of = Atomics, catch)]
583-
pub fn load(typed_array: &JsValue, index: u32) -> Result<f64, JsValue>;
578+
#[wasm_bindgen(js_namespace = Atomics, catch)]
579+
pub fn load(typed_array: &JsValue, index: u32) -> Result<i32, JsValue>;
584580

585581
/// The static `Atomics.notify()` method notifies up some agents that
586582
/// are sleeping in the wait queue.
587583
/// Note: This operation works with a shared `Int32Array` only.
588584
///
589585
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
590-
#[wasm_bindgen(static_method_of = Atomics, catch)]
591-
pub fn notify(typed_array: &JsValue, index: u32, count: u32) -> Result<u32, JsValue>;
586+
#[wasm_bindgen(js_namespace = Atomics, catch)]
587+
pub fn notify(typed_array: &Int32Array, index: u32, count: u32) -> Result<u32, JsValue>;
592588

593589
/// The static `Atomics.or()` method computes a bitwise OR with a given value
594590
/// at a given position in the array, and returns the old value at that position.
595591
/// This atomic operation guarantees that no other write happens
596592
/// until the modified value is written back.
597593
///
598594
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
599-
#[wasm_bindgen(static_method_of = Atomics, catch)]
600-
pub fn or(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
595+
#[wasm_bindgen(js_namespace = Atomics, catch)]
596+
pub fn or(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
601597

602598
/// The static `Atomics.store()` method stores a given value at the given
603599
/// position in the array and returns that value.
604600
///
605601
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
606-
#[wasm_bindgen(static_method_of = Atomics, catch)]
607-
pub fn store(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
602+
#[wasm_bindgen(js_namespace = Atomics, catch)]
603+
pub fn store(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
608604

609605
/// The static `Atomics.sub()` method substracts a given value at a
610606
/// given position in the array and returns the old value at that position.
611607
/// This atomic operation guarantees that no other write happens
612608
/// until the modified value is written back.
613609
///
614610
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
615-
#[wasm_bindgen(static_method_of = Atomics, catch)]
616-
pub fn sub(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
611+
#[wasm_bindgen(js_namespace = Atomics, catch)]
612+
pub fn sub(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
617613

618614
/// The static `Atomics.wait()` method verifies that a given
619615
/// position in an `Int32Array` still contains a given value
@@ -623,15 +619,15 @@ pub mod Atomics {
623619
/// and may not be allowed on the main thread.
624620
///
625621
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
626-
#[wasm_bindgen(static_method_of = Atomics, catch)]
627-
pub fn wait(typed_array: &JsValue, index: u32, value: i32) -> Result<JsString, JsValue>;
622+
#[wasm_bindgen(js_namespace = Atomics, catch)]
623+
pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
628624

629625
/// Like `wait()`, but with timeout
630626
///
631627
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
632-
#[wasm_bindgen(static_method_of = Atomics, catch, js_name = wait)]
628+
#[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
633629
pub fn wait_with_timeout(
634-
typed_array: &JsValue,
630+
typed_array: &Int32Array,
635631
index: u32,
636632
value: i32,
637633
timeout: f64,
@@ -644,8 +640,8 @@ pub mod Atomics {
644640
/// until the modified value is written back.
645641
///
646642
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
647-
#[wasm_bindgen(static_method_of = Atomics, catch)]
648-
pub fn xor(typed_array: &JsValue, index: u32, value: f64) -> Result<f64, JsValue>;
643+
#[wasm_bindgen(js_namespace = Atomics, catch)]
644+
pub fn xor(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
649645
}
650646
}
651647

0 commit comments

Comments
 (0)