use crate::types::{TypeInfo};
use std::marker::PhantomData;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct FunctionDeclaration<'a, R = (), Args = ()> {
pub name: &'a str,
pub is_unsafe: bool,
pub location: Option<FunctionLocation>,
pub signature: SignatureDef<'a>,
pub return_type: PhantomData<fn() -> R>,
pub arg_types: PhantomData<fn(Args) -> ()>,
}
impl<'a, R, Args> FunctionDeclaration<'a, R, Args> {
#[inline]
pub fn has_known_location(&self) -> bool {
self.location.is_some()
}
#[inline]
pub fn erase(&'a self) -> &'a FunctionDeclaration<(), ()> {
unsafe { &*(self as *const Self as *const FunctionDeclaration<(), ()>) }
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct SignatureDef<'tp> {
pub argument_types: &'tp [TypeInfo<'tp>],
pub return_type: &'tp TypeInfo<'tp>,
pub calling_convention: CallingConvention
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum CallingConvention {
StandardC,
}
impl Default for CallingConvention {
#[inline]
fn default() -> Self {
CallingConvention::StandardC
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum FunctionLocation {
DynamicallyLinked {
link_name: Option<&'static str>
},
AbsoluteAddress(*const ()),
}