Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ABI for raw pointers #3655

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/cli/tests/reference/pointers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {number} input
* @returns {number}
*/
export function const_pointer(input: number): number;
/**
* @param {number} input
* @returns {number}
*/
export function mut_pointer(input: number): number;
23 changes: 23 additions & 0 deletions crates/cli/tests/reference/pointers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
let wasm;
export function __wbg_set_wasm(val) {
wasm = val;
}

/**
* @param {number} input
* @returns {number}
*/
export function const_pointer(input) {
const ret = wasm.const_pointer(input);
return ret >>> 0;
}

/**
* @param {number} input
* @returns {number}
*/
export function mut_pointer(input) {
const ret = wasm.mut_pointer(input);
return ret >>> 0;
}

11 changes: 11 additions & 0 deletions crates/cli/tests/reference/pointers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn const_pointer(input: *const u8) -> *const u8 {
u32::MAX as *const _
}

#[wasm_bindgen]
pub fn mut_pointer(input: *mut u8) -> *mut u8 {
u32::MAX as *mut _
}
9 changes: 9 additions & 0 deletions crates/cli/tests/reference/pointers.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(module
(type (;0;) (func (param i32) (result i32)))
(func $const_pointer (;0;) (type 0) (param i32) (result i32))
(func $mut_pointer (;1;) (type 0) (param i32) (result i32))
(memory (;0;) 17)
(export "memory" (memory 0))
(export "const_pointer" (func $const_pointer))
(export "mut_pointer" (func $mut_pointer))
)
4 changes: 2 additions & 2 deletions src/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ cfg_if! {

impl<T> WasmDescribe for *const T {
fn describe() {
inform(I32)
inform(U32)
}
}

impl<T> WasmDescribe for *mut T {
fn describe() {
inform(I32)
inform(U32)
}
}

Expand Down