Skip to content

Commit 0921c4f

Browse files
committed
Bindings for TypedArray subclasses
1 parent 9d27b44 commit 0921c4f

File tree

2 files changed

+447
-88
lines changed

2 files changed

+447
-88
lines changed

src/js.rs

+173-19
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,6 @@ extern "C" {
106106
pub fn parse_float(text: &str) -> f64;
107107
}
108108

109-
// UInt8Array
110-
#[wasm_bindgen]
111-
extern "C" {
112-
pub type Uint8Array;
113-
114-
/// The `Uint8Array()` constructor creates an array of unsigned 8-bit integers.
115-
///
116-
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
117-
#[wasm_bindgen(constructor)]
118-
pub fn new(constructor_arg: JsValue) -> Uint8Array;
119-
120-
/// The fill() method fills all the elements of an array from a start index
121-
/// to an end index with a static value. The end index is not included.
122-
///
123-
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
124-
#[wasm_bindgen(method)]
125-
pub fn fill(this: &Uint8Array, value: JsValue, start: u32, end: u32) -> Uint8Array;
126-
}
127-
128109
// Array
129110
#[wasm_bindgen]
130111
extern "C" {
@@ -590,6 +571,44 @@ extern "C" {
590571
pub fn to_string(this: &Error) -> JsString;
591572
}
592573

574+
// Float32Array
575+
#[wasm_bindgen]
576+
extern "C" {
577+
pub type Float32Array;
578+
579+
/// The `Float32Array()` constructor creates an array of 32-bit floats.
580+
///
581+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
582+
#[wasm_bindgen(constructor)]
583+
pub fn new(constructor_arg: JsValue) -> Float32Array;
584+
585+
/// The fill() method fills all the elements of an array from a start index
586+
/// to an end index with a static value. The end index is not included.
587+
///
588+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
589+
#[wasm_bindgen(method)]
590+
pub fn fill(this: &Float32Array, value: JsValue, start: u32, end: u32) -> Float32Array;
591+
}
592+
593+
// Float64Array
594+
#[wasm_bindgen]
595+
extern "C" {
596+
pub type Float64Array;
597+
598+
/// The `Float64Array()` constructor creates an array of 64-bit floats.
599+
///
600+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
601+
#[wasm_bindgen(constructor)]
602+
pub fn new(constructor_arg: JsValue) -> Float64Array;
603+
604+
/// The fill() method fills all the elements of an array from a start index
605+
/// to an end index with a static value. The end index is not included.
606+
///
607+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
608+
#[wasm_bindgen(method)]
609+
pub fn fill(this: &Float64Array, value: JsValue, start: u32, end: u32) -> Float64Array;
610+
}
611+
593612
// Function
594613
#[wasm_bindgen]
595614
extern "C" {
@@ -671,6 +690,63 @@ extern {
671690
pub fn throw(this: &Generator, error: &Error) -> Result<JsValue, JsValue>;
672691
}
673692

693+
// Int8Array
694+
#[wasm_bindgen]
695+
extern "C" {
696+
pub type Int8Array;
697+
698+
/// The `Int8Array()` constructor creates an array of signed 8-bit integers.
699+
///
700+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
701+
#[wasm_bindgen(constructor)]
702+
pub fn new(constructor_arg: JsValue) -> Int8Array;
703+
704+
/// The fill() method fills all the elements of an array from a start index
705+
/// to an end index with a static value. The end index is not included.
706+
///
707+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
708+
#[wasm_bindgen(method)]
709+
pub fn fill(this: &Int8Array, value: JsValue, start: u32, end: u32) -> Int8Array;
710+
}
711+
712+
// Int16Array
713+
#[wasm_bindgen]
714+
extern "C" {
715+
pub type Int16Array;
716+
717+
/// The `Int16Array()` constructor creates an array of signed 16-bit integers.
718+
///
719+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
720+
#[wasm_bindgen(constructor)]
721+
pub fn new(constructor_arg: JsValue) -> Int16Array;
722+
723+
/// The fill() method fills all the elements of an array from a start index
724+
/// to an end index with a static value. The end index is not included.
725+
///
726+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
727+
#[wasm_bindgen(method)]
728+
pub fn fill(this: &Int16Array, value: JsValue, start: u32, end: u32) -> Int16Array;
729+
}
730+
731+
// Int32Array
732+
#[wasm_bindgen]
733+
extern "C" {
734+
pub type Int32Array;
735+
736+
/// The `Int32Array()` constructor creates an array of signed 32-bit integers.
737+
///
738+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
739+
#[wasm_bindgen(constructor)]
740+
pub fn new(constructor_arg: JsValue) -> Int32Array;
741+
742+
/// The fill() method fills all the elements of an array from a start index
743+
/// to an end index with a static value. The end index is not included.
744+
///
745+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
746+
#[wasm_bindgen(method)]
747+
pub fn fill(this: &Int32Array, value: JsValue, start: u32, end: u32) -> Int32Array;
748+
}
749+
674750
// Map
675751
#[wasm_bindgen]
676752
extern {
@@ -1737,6 +1813,84 @@ extern {
17371813
pub fn values(set: &Set) -> SetIterator;
17381814
}
17391815

1816+
// Uint8Array
1817+
#[wasm_bindgen]
1818+
extern "C" {
1819+
pub type Uint8Array;
1820+
1821+
/// The `Uint8Array()` constructor creates an array of unsigned 8-bit integers.
1822+
///
1823+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
1824+
#[wasm_bindgen(constructor)]
1825+
pub fn new(constructor_arg: JsValue) -> Uint8Array;
1826+
1827+
/// The fill() method fills all the elements of an array from a start index
1828+
/// to an end index with a static value. The end index is not included.
1829+
///
1830+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
1831+
#[wasm_bindgen(method)]
1832+
pub fn fill(this: &Uint8Array, value: JsValue, start: u32, end: u32) -> Uint8Array;
1833+
}
1834+
1835+
// Uint8ClampedArray
1836+
#[wasm_bindgen]
1837+
extern "C" {
1838+
pub type Uint8ClampedArray;
1839+
1840+
/// The `Uint8ClampedArray()` constructor creates an array of unsigned 8-bit integers clamped
1841+
/// to 0-255; if you specified a value that is out of the range of [0,255], 0 or 255 will be
1842+
/// set instead.
1843+
///
1844+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
1845+
#[wasm_bindgen(constructor)]
1846+
pub fn new(constructor_arg: JsValue) -> Uint8ClampedArray;
1847+
1848+
/// The fill() method fills all the elements of an array from a start index
1849+
/// to an end index with a static value. The end index is not included.
1850+
///
1851+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
1852+
#[wasm_bindgen(method)]
1853+
pub fn fill(this: &Uint8ClampedArray, value: JsValue, start: u32, end: u32) -> Uint8ClampedArray;
1854+
}
1855+
1856+
// Uint16Array
1857+
#[wasm_bindgen]
1858+
extern "C" {
1859+
pub type Uint16Array;
1860+
1861+
/// The `Uint16Array()` constructor creates an array of unsigned 16-bit integers.
1862+
///
1863+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
1864+
#[wasm_bindgen(constructor)]
1865+
pub fn new(constructor_arg: JsValue) -> Uint16Array;
1866+
1867+
/// The fill() method fills all the elements of an array from a start index
1868+
/// to an end index with a static value. The end index is not included.
1869+
///
1870+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
1871+
#[wasm_bindgen(method)]
1872+
pub fn fill(this: &Uint16Array, value: JsValue, start: u32, end: u32) -> Uint16Array;
1873+
}
1874+
1875+
// Uint32Array
1876+
#[wasm_bindgen]
1877+
extern "C" {
1878+
pub type Uint32Array;
1879+
1880+
/// The `Uint32Array()` constructor creates an array of unsigned 32-bit integers.
1881+
///
1882+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
1883+
#[wasm_bindgen(constructor)]
1884+
pub fn new(constructor_arg: JsValue) -> Uint32Array;
1885+
1886+
/// The fill() method fills all the elements of an array from a start index
1887+
/// to an end index with a static value. The end index is not included.
1888+
///
1889+
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
1890+
#[wasm_bindgen(method)]
1891+
pub fn fill(this: &Uint32Array, value: JsValue, start: u32, end: u32) -> Uint32Array;
1892+
}
1893+
17401894
// WeakMap
17411895
#[wasm_bindgen]
17421896
extern "C" {

0 commit comments

Comments
 (0)