Virtual_machine/
Registrable.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

use std::os::raw::c_void;

pub type Function_pointer = *mut c_void;

#[macro_export]
macro_rules! Function_descriptor {
    ($Function:ident) => {
        $crate::Function_descriptor_type {
            Name: stringify!($Function),
            Pointer: $Function as *mut std::ffi::c_void,
        }
    };
}

#[macro_export]
macro_rules! Function_descriptors {
    ($($Function:ident),*) => {
        [$(
            $crate::Function_descriptor!($Function),
        )*]
    };
}

pub struct Function_descriptor_type {
    pub Name: &'static str,
    pub Pointer: Function_pointer,
}
pub trait Registrable_trait {
    fn Get_functions(&self) -> &[Function_descriptor_type];

    fn Is_XIP(&self) -> bool {
        false
    }

    fn Get_binary(&self) -> Option<&'static [u8]> {
        None
    }

    fn Get_name(&self) -> &'static str;
}