1use crate::{
2 wasm_extern_t,
3 wasm_foreign_t,
4 wasm_func_t,
5 wasm_global_t,
6 wasm_instance_t,
7 wasm_memory_t,
8 wasm_module_t,
9 wasm_table_t,
10 wasm_trap_t,
11};
12use alloc::boxed::Box;
13use core::{ffi::c_void, ptr, unimplemented};
14use wasmi::Ref;
15
16#[derive(Clone)]
29pub struct wasm_ref_t {
30 pub(crate) inner: Ref,
31}
32
33wasmi_c_api_macros::declare_own!(wasm_ref_t);
34
35impl wasm_ref_t {
36 pub(crate) fn new(r: Ref) -> Option<Box<wasm_ref_t>> {
38 if r.is_null() || !r.is_func() {
39 None
40 } else {
41 Some(Box::new(wasm_ref_t { inner: r }))
42 }
43 }
44}
45
46#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
50#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
51pub extern "C" fn wasm_ref_copy(r: Option<&wasm_ref_t>) -> Option<Box<wasm_ref_t>> {
52 r.map(|r| Box::new(r.clone()))
53}
54
55#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
61#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
62pub extern "C" fn wasm_ref_same(_a: Option<&wasm_ref_t>, _b: Option<&wasm_ref_t>) -> bool {
63 unimplemented!("wasm_ref_same")
66}
67
68#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
74#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
75pub extern "C" fn wasm_ref_get_host_info(_ref: Option<&wasm_ref_t>) -> *mut c_void {
76 ptr::null_mut()
77}
78
79#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
85#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
86pub extern "C" fn wasm_ref_set_host_info(_ref: Option<&wasm_ref_t>, _info: *mut c_void) {
87 unimplemented!("wasm_ref_set_host_info")
88}
89
90#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
98#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
99pub extern "C" fn wasm_ref_set_host_info_with_finalizer(
100 _ref: Option<&wasm_ref_t>,
101 _info: *mut c_void,
102 _finalizer: Option<extern "C" fn(*mut c_void)>,
103) {
104 unimplemented!("wasm_ref_set_host_info_with_finalizer")
105}
106
107#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
113#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
114pub extern "C" fn wasm_ref_as_extern(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_extern_t> {
115 unimplemented!("wasm_ref_as_extern")
116}
117
118#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
124#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
125pub extern "C" fn wasm_ref_as_extern_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_extern_t> {
126 unimplemented!("wasm_ref_as_extern_const")
127}
128
129#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
135#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
136pub extern "C" fn wasm_ref_as_foreign(
137 _ref: Option<&mut wasm_ref_t>,
138) -> Option<&mut wasm_foreign_t> {
139 unimplemented!("wasm_ref_as_foreign")
140}
141
142#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
148#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
149pub extern "C" fn wasm_ref_as_foreign_const(
150 _ref: Option<&wasm_ref_t>,
151) -> Option<&crate::wasm_foreign_t> {
152 unimplemented!("wasm_ref_as_foreign_const")
153}
154
155#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
161#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
162pub extern "C" fn wasm_ref_as_func(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_func_t> {
163 unimplemented!("wasm_ref_as_func")
164}
165
166#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
172#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
173pub extern "C" fn wasm_ref_as_func_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_func_t> {
174 unimplemented!("wasm_ref_as_func_const")
175}
176
177#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
183#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
184pub extern "C" fn wasm_ref_as_global(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_global_t> {
185 unimplemented!("wasm_ref_as_global")
186}
187
188#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
194#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
195pub extern "C" fn wasm_ref_as_global_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_global_t> {
196 unimplemented!("wasm_ref_as_global_const")
197}
198
199#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
205#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
206pub extern "C" fn wasm_ref_as_instance(
207 _ref: Option<&mut wasm_ref_t>,
208) -> Option<&mut wasm_instance_t> {
209 unimplemented!("wasm_ref_as_instance")
210}
211
212#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
218#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
219pub extern "C" fn wasm_ref_as_instance_const(
220 _ref: Option<&wasm_ref_t>,
221) -> Option<&wasm_instance_t> {
222 unimplemented!("wasm_ref_as_instance_const")
223}
224
225#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
231#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
232pub extern "C" fn wasm_ref_as_memory(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_memory_t> {
233 unimplemented!("wasm_ref_as_memory")
234}
235
236#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
242#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
243pub extern "C" fn wasm_ref_as_memory_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_memory_t> {
244 unimplemented!("wasm_ref_as_memory_const")
245}
246
247#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
253#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
254pub extern "C" fn wasm_ref_as_module(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_module_t> {
255 unimplemented!("wasm_ref_as_module")
256}
257
258#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
264#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
265pub extern "C" fn wasm_ref_as_module_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_module_t> {
266 unimplemented!("wasm_ref_as_module_const")
267}
268
269#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
275#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
276pub extern "C" fn wasm_ref_as_table(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_table_t> {
277 unimplemented!("wasm_ref_as_table")
278}
279
280#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
286#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
287pub extern "C" fn wasm_ref_as_table_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_table_t> {
288 unimplemented!("wasm_ref_as_table_const")
289}
290
291#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
297#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
298pub extern "C" fn wasm_ref_as_trap(_ref: Option<&mut wasm_ref_t>) -> Option<&mut wasm_trap_t> {
299 unimplemented!("wasm_ref_as_trap")
300}
301
302#[cfg_attr(not(feature = "prefix-symbols"), unsafe(no_mangle))]
308#[cfg_attr(feature = "prefix-symbols", wasmi_c_api_macros::prefix_symbol)]
309pub extern "C" fn wasm_ref_as_trap_const(_ref: Option<&wasm_ref_t>) -> Option<&wasm_trap_t> {
310 unimplemented!("wasm_ref_as_trap_const")
311}