virtual_machine/
registrable.rs

1use core::ffi::c_void;
2
3pub type FunctionPointer = *mut c_void;
4
5#[macro_export]
6macro_rules! Function_descriptor {
7    ($Function:ident) => {
8        $crate::Function_descriptor_type {
9            Name: stringify!($Function),
10            Pointer: $Function as *mut std::ffi::c_void,
11        }
12    };
13}
14
15#[macro_export]
16macro_rules! Function_descriptors {
17    ($($Function:ident),*) => {
18        [$(
19            $crate::Function_descriptor!($Function),
20        )*]
21    };
22}
23
24pub struct FunctionDescriptor {
25    pub name: &'static str,
26    pub pointer: FunctionPointer,
27}
28pub trait Registrable {
29    fn get_functions(&self) -> &[FunctionDescriptor];
30
31    fn is_xip(&self) -> bool {
32        false
33    }
34
35    fn get_binary(&self) -> Option<&'static [u8]> {
36        None
37    }
38
39    fn get_name(&self) -> &'static str;
40}