Rename anyref to externref across the board
This commit is contained in:
@@ -18,12 +18,12 @@ pub(crate) enum ExternHost {
|
||||
}
|
||||
|
||||
impl wasm_extern_t {
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
match &self.which {
|
||||
ExternHost::Func(f) => f.anyref(),
|
||||
ExternHost::Global(f) => f.anyref(),
|
||||
ExternHost::Memory(f) => f.anyref(),
|
||||
ExternHost::Table(f) => f.anyref(),
|
||||
ExternHost::Func(f) => f.externref(),
|
||||
ExternHost::Global(f) => f.externref(),
|
||||
ExternHost::Memory(f) => f.externref(),
|
||||
ExternHost::Table(f) => f.externref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ impl wasm_func_t {
|
||||
}
|
||||
}
|
||||
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.func().anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.func().externref()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ impl wasm_global_t {
|
||||
}
|
||||
}
|
||||
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.global().anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.global().externref()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ impl wasm_instance_t {
|
||||
}
|
||||
}
|
||||
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.instance.anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.instance.externref()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ impl wasm_memory_t {
|
||||
}
|
||||
}
|
||||
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.memory().anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.memory().externref()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ pub struct wasm_module_t {
|
||||
wasmtime_c_api_macros::declare_ref!(wasm_module_t);
|
||||
|
||||
impl wasm_module_t {
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.module.anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.module.externref()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::HostInfoState;
|
||||
use std::os::raw::c_void;
|
||||
use wasmtime::AnyRef;
|
||||
use wasmtime::ExternRef;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone)]
|
||||
pub struct wasm_ref_t {
|
||||
pub(crate) r: AnyRef,
|
||||
pub(crate) r: ExternRef,
|
||||
}
|
||||
|
||||
wasmtime_c_api_macros::declare_own!(wasm_ref_t);
|
||||
@@ -20,7 +20,7 @@ pub extern "C" fn wasm_ref_same(a: &wasm_ref_t, b: &wasm_ref_t) -> bool {
|
||||
a.r.ptr_eq(&b.r)
|
||||
}
|
||||
|
||||
pub(crate) fn get_host_info(r: &AnyRef) -> *mut c_void {
|
||||
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(),
|
||||
@@ -37,7 +37,7 @@ pub extern "C" fn wasm_ref_get_host_info(a: &wasm_ref_t) -> *mut c_void {
|
||||
}
|
||||
|
||||
pub(crate) fn set_host_info(
|
||||
r: &AnyRef,
|
||||
r: &ExternRef,
|
||||
info: *mut c_void,
|
||||
finalizer: Option<extern "C" fn(*mut c_void)>,
|
||||
) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{handle_result, wasm_func_t, wasm_ref_t, wasmtime_error_t};
|
||||
use crate::{wasm_extern_t, wasm_store_t, wasm_tabletype_t, ExternHost};
|
||||
use std::ptr;
|
||||
use wasmtime::{AnyRef, HostRef, Table, Val};
|
||||
use wasmtime::{ExternRef, HostRef, Table, Val};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[repr(transparent)]
|
||||
@@ -28,8 +28,8 @@ impl wasm_table_t {
|
||||
}
|
||||
}
|
||||
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.table().anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.table().externref()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ pub extern "C" fn wasm_table_new(
|
||||
) -> Option<Box<wasm_table_t>> {
|
||||
let init: Val = match init {
|
||||
Some(init) => init.r.into(),
|
||||
None => Val::AnyRef(AnyRef::Null),
|
||||
None => Val::ExternRef(ExternRef::Null),
|
||||
};
|
||||
let table = Table::new(&store.store.borrow(), tt.ty().ty.clone(), init).ok()?;
|
||||
Some(Box::new(wasm_table_t {
|
||||
@@ -60,7 +60,7 @@ pub extern "C" fn wasmtime_funcref_table_new(
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
let init: Val = match init {
|
||||
Some(val) => Val::FuncRef(val.func().borrow().clone()),
|
||||
None => Val::AnyRef(AnyRef::Null),
|
||||
None => Val::ExternRef(ExternRef::Null),
|
||||
};
|
||||
handle_result(
|
||||
Table::new(&store.store.borrow(), tt.ty().ty.clone(), init),
|
||||
@@ -84,7 +84,7 @@ pub extern "C" fn wasm_table_type(t: &wasm_table_t) -> Box<wasm_tabletype_t> {
|
||||
pub extern "C" fn wasm_table_get(t: &wasm_table_t, index: wasm_table_size_t) -> *mut wasm_ref_t {
|
||||
match t.table().borrow().get(index) {
|
||||
Some(val) => into_funcref(val),
|
||||
None => into_funcref(Val::AnyRef(AnyRef::Null)),
|
||||
None => into_funcref(Val::ExternRef(ExternRef::Null)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ pub extern "C" fn wasmtime_funcref_table_get(
|
||||
*ptr = match val {
|
||||
// TODO: what do do about creating new `HostRef` handles here?
|
||||
Val::FuncRef(f) => Box::into_raw(Box::new(HostRef::new(f).into())),
|
||||
Val::AnyRef(AnyRef::Null) => ptr::null_mut(),
|
||||
Val::ExternRef(ExternRef::Null) => ptr::null_mut(),
|
||||
_ => return false,
|
||||
};
|
||||
}
|
||||
@@ -127,20 +127,20 @@ pub extern "C" fn wasmtime_funcref_table_set(
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
let val = match val {
|
||||
Some(val) => Val::FuncRef(val.func().borrow().clone()),
|
||||
None => Val::AnyRef(AnyRef::Null),
|
||||
None => Val::ExternRef(ExternRef::Null),
|
||||
};
|
||||
handle_result(t.table().borrow().set(index, val), |()| {})
|
||||
}
|
||||
|
||||
fn into_funcref(val: Val) -> *mut wasm_ref_t {
|
||||
if let Val::AnyRef(AnyRef::Null) = val {
|
||||
if let Val::ExternRef(ExternRef::Null) = val {
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let anyref = match val.anyref() {
|
||||
Some(anyref) => anyref,
|
||||
let externref = match val.externref() {
|
||||
Some(externref) => externref,
|
||||
None => return ptr::null_mut(),
|
||||
};
|
||||
let r = Box::new(wasm_ref_t { r: anyref });
|
||||
let r = Box::new(wasm_ref_t { r: externref });
|
||||
Box::into_raw(r)
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ unsafe fn from_funcref(r: *mut wasm_ref_t) -> Val {
|
||||
if !r.is_null() {
|
||||
Box::from_raw(r).r.into()
|
||||
} else {
|
||||
Val::AnyRef(AnyRef::Null)
|
||||
Val::ExternRef(ExternRef::Null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ pub extern "C" fn wasmtime_funcref_table_grow(
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
let val = match init {
|
||||
Some(val) => Val::FuncRef(val.func().borrow().clone()),
|
||||
None => Val::AnyRef(AnyRef::Null),
|
||||
None => Val::ExternRef(ExternRef::Null),
|
||||
};
|
||||
handle_result(t.table().borrow().grow(delta, val), |prev| {
|
||||
if let Some(ptr) = prev_size {
|
||||
|
||||
@@ -17,8 +17,8 @@ impl wasm_trap_t {
|
||||
}
|
||||
}
|
||||
|
||||
fn anyref(&self) -> wasmtime::AnyRef {
|
||||
self.trap.anyref()
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.trap.externref()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ pub const WASM_I32: wasm_valkind_t = 0;
|
||||
pub const WASM_I64: wasm_valkind_t = 1;
|
||||
pub const WASM_F32: wasm_valkind_t = 2;
|
||||
pub const WASM_F64: wasm_valkind_t = 3;
|
||||
pub const WASM_ANYREF: wasm_valkind_t = 128;
|
||||
pub const WASM_EXTERNREF: wasm_valkind_t = 128;
|
||||
pub const WASM_FUNCREF: wasm_valkind_t = 129;
|
||||
|
||||
#[no_mangle]
|
||||
@@ -34,7 +34,7 @@ pub(crate) fn into_valtype(kind: wasm_valkind_t) -> ValType {
|
||||
WASM_I64 => ValType::I64,
|
||||
WASM_F32 => ValType::F32,
|
||||
WASM_F64 => ValType::F64,
|
||||
WASM_ANYREF => ValType::AnyRef,
|
||||
WASM_EXTERNREF => ValType::ExternRef,
|
||||
WASM_FUNCREF => ValType::FuncRef,
|
||||
_ => panic!("unexpected kind: {}", kind),
|
||||
}
|
||||
@@ -46,7 +46,7 @@ pub(crate) fn from_valtype(ty: &ValType) -> wasm_valkind_t {
|
||||
ValType::I64 => WASM_I64,
|
||||
ValType::F32 => WASM_F32,
|
||||
ValType::F64 => WASM_F64,
|
||||
ValType::AnyRef => WASM_ANYREF,
|
||||
ValType::ExternRef => WASM_EXTERNREF,
|
||||
ValType::FuncRef => WASM_FUNCREF,
|
||||
_ => panic!("wasm_valkind_t has no known conversion for {:?}", ty),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user