use std::hash::Hash;
use proc_macro2::{Ident, TokenStream};
use syn::Type;
#[derive(Hash, PartialEq, Eq, Clone, Debug)]
pub enum Exceptions {
Primitive(Vec<Ident>),
NonPrimitive(Vec<Ident>),
}
#[derive(Hash, PartialEq, Eq, Clone, Debug)]
pub enum RustWrapperType {
Result(Box<WrapperType>, Box<WrapperType>),
Option(Box<WrapperType>),
Vector(Box<WrapperType>),
Shared,
Custom,
String,
Primitive,
Trait,
FieldlessEnum,
DataEnum,
Exceptions(Exceptions),
ExceptionTrait,
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct ReferenceParameters {
pub is_static: bool,
pub is_mut: bool,
}
impl ReferenceParameters {
pub fn shared() -> ReferenceParameters {
ReferenceParameters {
is_static: false,
is_mut: false,
}
}
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct WrapperType {
pub original_type_name: Type,
pub wrapper_name: String,
pub rust_type: RustWrapperType,
pub reference_parameters: Option<ReferenceParameters>,
}
impl WrapperType {
pub fn boxed(self) -> Box<WrapperType> {
Box::new(self)
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Arg {
pub arg_name: String,
pub typ: WrapperType,
}
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Function {
pub arguments: Vec<Arg>,
pub return_type: Option<WrapperType>,
pub name: String,
}
#[derive(Clone)]
pub struct ExternFunction {
pub arguments: Vec<WrapperType>,
pub return_type: Option<WrapperType>,
pub name: String,
pub tokens: TokenStream,
}