#[macro_export]
macro_rules! tl_genparams {
( $($lt:lifetime),* ; $($ty:ty),* ; $($const_p:expr),* ) => ({
#[allow(unused_imports)]
use $crate::{
abi_stability::{
stable_abi_trait::SharedStableAbi,
type_layout::GenericParams
},
std_types::StaticStr,
};
GenericParams::new(
&[$( StaticStr::new( stringify!($lt) ) ,)*],
&[$( <$ty as SharedStableAbi>::S_LAYOUT ,)*],
&[$( StaticStr::new( stringify!($const_p) ) ,)*],
)
})
}
#[macro_export]
macro_rules! rtry {
($expr:expr) => {{
use $crate::result::{RErr, ROk};
match $expr.into() {
ROk(x) => x,
RErr(x) => return RErr(From::from(x)),
}
}};
}
#[macro_export]
macro_rules! rtry_opt {
($expr:expr) => {{
use $crate::option::{RNone, RSome};
match $expr.into() {
RSome(x) => x,
RNone => return RNone,
}
}};
}
macro_rules! make_rve_utypeid {
($ty:ty) => (
$crate::return_value_equality::ReturnValueEquality{
function:$crate::std_types::utypeid::new_utypeid::<$ty>
}
)
}
#[macro_export]
macro_rules! extern_fn_panic_handling {
( $($fn_contents:tt)* ) => ({
use std::panic::{self,AssertUnwindSafe};
let result=panic::catch_unwind(AssertUnwindSafe(move||{
$($fn_contents)*
}));
match result {
Ok(x)=>x,
Err(_)=>$crate::utils::ffi_panic_message(file!(),line!()),
}
})
}
#[macro_export]
macro_rules! impl_get_type_info {
(
$type:ident $([$($params:tt)*])?
) => (
{
use std::mem;
use $crate::{
erased_types::type_info::TypeInfo,
version::{VersionStrings},
std_types::{StaticStr,utypeid::new_utypeid},
return_value_equality::ReturnValueEquality,
};
&TypeInfo{
size:mem::size_of::<Self>(),
alignment:mem::align_of::<Self>(),
uid:ReturnValueEquality{
function:new_utypeid::<Self>
},
name:StaticStr::new(stringify!($type)),
file:StaticStr::new(file!()),
package:StaticStr::new(env!("CARGO_PKG_NAME")),
package_version:VersionStrings{
major:StaticStr::new(env!("CARGO_PKG_VERSION_MAJOR")),
minor:StaticStr::new(env!("CARGO_PKG_VERSION_MINOR")),
patch:StaticStr::new(env!("CARGO_PKG_VERSION_PATCH")),
},
_private_field:(),
}
}
)
}