Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/shims/sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ pub struct ShimSig<'tcx, const ARGS: usize> {

/// Construct a `ShimSig` with convenient syntax:
/// ```rust,ignore
/// shim_sig!(this, extern "C" fn (*const T, i32) -> usize)
/// shim_sig!(extern "C" fn (*const T, i32) -> usize)
/// ```
#[macro_export]
macro_rules! shim_sig {
(extern $abi:literal fn($($arg:ty),*) -> $ret:ty) => {
(extern $abi:literal fn($($arg:ty),* $(,)?) -> $ret:ty) => {
|this| $crate::shims::sig::ShimSig {
abi: std::str::FromStr::from_str($abi).expect("incorrect abi specified"),
args: [$(shim_sig_arg!(this, $arg)),*],
Expand Down Expand Up @@ -53,7 +53,9 @@ macro_rules! shim_sig_arg {
"*const _" => $this.machine.layouts.const_raw_ptr.ty,
"*mut _" => $this.machine.layouts.mut_raw_ptr.ty,
ty if let Some(libc_ty) = ty.strip_prefix("libc::") => $this.libc_ty_layout(libc_ty).ty,
ty => panic!("unsupported signature type {ty:?}"),
ty if let Some(win_ty) = ty.strip_prefix("winapi::") =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is shorthand for a longer path used by the windows_ty_layout function, I thought this made usage a lot nicer and more readable.

$this.windows_ty_layout(win_ty).ty,
ty => helpers::path_ty_layout($this, &ty.split("::").collect::<Vec<_>>()).ty,
}
}};
}
Expand Down
Loading