diff --git a/src/convert/slices.rs b/src/convert/slices.rs index d99fbbbf7..a3cb6ec90 100644 --- a/src/convert/slices.rs +++ b/src/convert/slices.rs @@ -123,7 +123,7 @@ macro_rules! vectors { } vectors! { - u8 i8 u16 i16 u32 i32 u64 i64 f32 f64 + u8 i8 u16 i16 u32 i32 u64 i64 usize isize f32 f64 } if_std! { diff --git a/tests/wasm/slice.js b/tests/wasm/slice.js index 7ec7ee8fd..373e3859d 100644 --- a/tests/wasm/slice.js +++ b/tests/wasm/slice.js @@ -24,10 +24,12 @@ exports.js_export = () => { i32[0] = 1; i32[1] = 2; assert.deepStrictEqual(wasm.export_i32(i32), i32); + assert.deepStrictEqual(wasm.export_isize(i32), i32); const u32 = new Uint32Array(2); u32[0] = 1; u32[1] = 2; assert.deepStrictEqual(wasm.export_u32(u32), u32); + assert.deepStrictEqual(wasm.export_usize(u32), u32); const f32 = new Float32Array(2); f32[0] = 1; @@ -73,6 +75,7 @@ exports.import_js_i32 = a => { assert.strictEqual(a[1], 2); return a; }; +exports.import_js_isize = exports.import_js_i32; exports.import_js_u32 = a => { assert.strictEqual(a.length, 2); @@ -80,6 +83,7 @@ exports.import_js_u32 = a => { assert.strictEqual(a[1], 2); return a; }; +exports.import_js_usize = exports.import_js_u32; exports.import_js_f32 = a => { assert.strictEqual(a.length, 2); @@ -118,10 +122,12 @@ exports.js_import = () => { i32[0] = 1; i32[1] = 2; assert.deepStrictEqual(wasm.import_rust_i32(i32), i32); + assert.deepStrictEqual(wasm.import_rust_isize(i32), i32); const u32 = new Uint32Array(2); u32[0] = 1; u32[1] = 2; assert.deepStrictEqual(wasm.import_rust_u32(u32), u32); + assert.deepStrictEqual(wasm.import_rust_usize(u32), u32); const f32 = new Float32Array(2); f32[0] = 1; @@ -140,6 +146,8 @@ exports.js_pass_array = () => { wasm.pass_array_rust_u16([1, 2]); wasm.pass_array_rust_i32([1, 2]); wasm.pass_array_rust_u32([1, 2]); + wasm.pass_array_rust_isize([1, 2]); + wasm.pass_array_rust_usize([1, 2]); wasm.pass_array_rust_f32([1, 2]); wasm.pass_array_rust_f64([1, 2]); }; @@ -158,6 +166,8 @@ exports.import_mut_js_i16 = import_mut_foo; exports.import_mut_js_u16 = import_mut_foo; exports.import_mut_js_i32 = import_mut_foo; exports.import_mut_js_u32 = import_mut_foo; +exports.import_mut_js_isize = import_mut_foo; +exports.import_mut_js_usize = import_mut_foo; exports.import_mut_js_f32 = import_mut_foo; exports.import_mut_js_f64 = import_mut_foo; @@ -182,6 +192,8 @@ exports.js_export_mut = () => { export_mut_run(new Uint16Array(3), wasm.export_mut_u16); export_mut_run(new Int32Array(3), wasm.export_mut_i32); export_mut_run(new Uint32Array(3), wasm.export_mut_u32); + export_mut_run(new Int32Array(3), wasm.export_mut_isize); + export_mut_run(new Uint32Array(3), wasm.export_mut_usize); export_mut_run(new Float32Array(3), wasm.export_mut_f32); export_mut_run(new Float64Array(3), wasm.export_mut_f64); }; diff --git a/tests/wasm/slice.rs b/tests/wasm/slice.rs index e14ed1875..8e299c0fe 100644 --- a/tests/wasm/slice.rs +++ b/tests/wasm/slice.rs @@ -40,6 +40,8 @@ export_macro! { (u16, export_u16) (i32, export_i32) (u32, export_u32) + (isize, export_isize) + (usize, export_usize) (f32, export_f32) (f64, export_f64) } @@ -73,6 +75,8 @@ import_macro! { (import_rust_u16, import_js_u16, u16) (import_rust_i32, import_js_i32, i32) (import_rust_u32, import_js_u32, u32) + (import_rust_isize, import_js_isize, isize) + (import_rust_usize, import_js_usize, usize) (import_rust_f32, import_js_f32, f32) (import_rust_f64, import_js_f64, f64) } @@ -100,6 +104,8 @@ pass_array_marco! { (pass_array_rust_u16, u16) (pass_array_rust_i32, i32) (pass_array_rust_u32, u32) + (pass_array_rust_isize, isize) + (pass_array_rust_usize, usize) (pass_array_rust_f32, f32) (pass_array_rust_f64, f64) } @@ -169,6 +175,8 @@ export_mut_macro! { (u16, export_mut_u16) (i32, export_mut_i32) (u32, export_mut_u32) + (isize, export_mut_isize) + (usize, export_mut_usize) (f32, export_mut_f32) (f64, export_mut_f64) }