wasmtime: Rip out incomplete/incorrect externref "host info" support
Better to be loud that we don't support attaching arbitrary host info to `externref`s than to limp along and pretend we do support it. Supporting it properly won't reuse any of this code anyways.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use crate::HostInfoState;
|
||||
use std::os::raw::c_void;
|
||||
use wasmtime::ExternRef;
|
||||
|
||||
@@ -24,47 +23,23 @@ pub extern "C" fn wasm_ref_same(a: &wasm_ref_t, b: &wasm_ref_t) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_host_info(r: &ExternRef) -> *mut c_void {
|
||||
let host_info = match r.host_info() {
|
||||
Some(info) => info,
|
||||
None => return std::ptr::null_mut(),
|
||||
};
|
||||
let host_info = host_info.borrow();
|
||||
match host_info.downcast_ref::<HostInfoState>() {
|
||||
Some(state) => state.info,
|
||||
None => std::ptr::null_mut(),
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_ref_get_host_info(_ref: &wasm_ref_t) -> *mut c_void {
|
||||
std::ptr::null_mut()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_ref_get_host_info(a: &wasm_ref_t) -> *mut c_void {
|
||||
a.r.as_ref()
|
||||
.map_or(std::ptr::null_mut(), |r| get_host_info(r))
|
||||
}
|
||||
|
||||
pub(crate) fn set_host_info(
|
||||
r: &ExternRef,
|
||||
info: *mut c_void,
|
||||
finalizer: Option<extern "C" fn(*mut c_void)>,
|
||||
) {
|
||||
let info = if info.is_null() && finalizer.is_none() {
|
||||
None
|
||||
} else {
|
||||
Some(Box::new(crate::HostInfoState { info, finalizer }) as Box<dyn std::any::Any>)
|
||||
};
|
||||
r.set_host_info(info);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_ref_set_host_info(a: &wasm_ref_t, info: *mut c_void) {
|
||||
a.r.as_ref().map(|r| set_host_info(r, info, None));
|
||||
pub extern "C" fn wasm_ref_set_host_info(_ref: &wasm_ref_t, _info: *mut c_void) {
|
||||
eprintln!("`wasm_ref_set_host_info` is not implemented");
|
||||
std::process::abort();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_ref_set_host_info_with_finalizer(
|
||||
a: &wasm_ref_t,
|
||||
info: *mut c_void,
|
||||
finalizer: Option<extern "C" fn(*mut c_void)>,
|
||||
_ref: &wasm_ref_t,
|
||||
_info: *mut c_void,
|
||||
_finalizer: Option<extern "C" fn(*mut c_void)>,
|
||||
) {
|
||||
a.r.as_ref().map(|r| set_host_info(r, info, finalizer));
|
||||
eprintln!("`wasm_ref_set_host_info_with_finalizer` is not implemented");
|
||||
std::process::abort();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user