Skip to content

Commit d2f9315

Browse files
authored
fix ABI for raw pointers (#3655)
1 parent 46f52e9 commit d2f9315

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* @param {number} input
5+
* @returns {number}
6+
*/
7+
export function const_pointer(input: number): number;
8+
/**
9+
* @param {number} input
10+
* @returns {number}
11+
*/
12+
export function mut_pointer(input: number): number;
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
let wasm;
2+
export function __wbg_set_wasm(val) {
3+
wasm = val;
4+
}
5+
6+
/**
7+
* @param {number} input
8+
* @returns {number}
9+
*/
10+
export function const_pointer(input) {
11+
const ret = wasm.const_pointer(input);
12+
return ret >>> 0;
13+
}
14+
15+
/**
16+
* @param {number} input
17+
* @returns {number}
18+
*/
19+
export function mut_pointer(input) {
20+
const ret = wasm.mut_pointer(input);
21+
return ret >>> 0;
22+
}
23+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use wasm_bindgen::prelude::*;
2+
3+
#[wasm_bindgen]
4+
pub fn const_pointer(input: *const u8) -> *const u8 {
5+
u32::MAX as *const _
6+
}
7+
8+
#[wasm_bindgen]
9+
pub fn mut_pointer(input: *mut u8) -> *mut u8 {
10+
u32::MAX as *mut _
11+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module
2+
(type (;0;) (func (param i32) (result i32)))
3+
(func $const_pointer (;0;) (type 0) (param i32) (result i32))
4+
(func $mut_pointer (;1;) (type 0) (param i32) (result i32))
5+
(memory (;0;) 17)
6+
(export "memory" (memory 0))
7+
(export "const_pointer" (func $const_pointer))
8+
(export "mut_pointer" (func $mut_pointer))
9+
)

src/describe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ cfg_if! {
104104

105105
impl<T> WasmDescribe for *const T {
106106
fn describe() {
107-
inform(I32)
107+
inform(U32)
108108
}
109109
}
110110

111111
impl<T> WasmDescribe for *mut T {
112112
fn describe() {
113-
inform(I32)
113+
inform(U32)
114114
}
115115
}
116116

0 commit comments

Comments
 (0)