2023-04-08 12:25:51 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
|
2023-04-24 08:11:38 +00:00
|
|
|
use crate::helpers::{parse_generics, Generics};
|
|
|
|
use proc_macro::TokenStream;
|
2023-04-08 12:25:51 +00:00
|
|
|
|
|
|
|
pub(crate) fn pin_data(args: TokenStream, input: TokenStream) -> TokenStream {
|
|
|
|
// This proc-macro only does some pre-parsing and then delegates the actual parsing to
|
|
|
|
// `kernel::__pin_data!`.
|
|
|
|
|
2023-04-24 08:11:38 +00:00
|
|
|
let (
|
|
|
|
Generics {
|
|
|
|
impl_generics,
|
|
|
|
ty_generics,
|
|
|
|
},
|
|
|
|
mut rest,
|
|
|
|
) = parse_generics(input);
|
2023-04-08 12:25:51 +00:00
|
|
|
// This should be the body of the struct `{...}`.
|
|
|
|
let last = rest.pop();
|
|
|
|
quote!(::kernel::__pin_data! {
|
|
|
|
parse_input:
|
|
|
|
@args(#args),
|
|
|
|
@sig(#(#rest)*),
|
|
|
|
@impl_generics(#(#impl_generics)*),
|
|
|
|
@ty_generics(#(#ty_generics)*),
|
|
|
|
@body(#last),
|
|
|
|
})
|
|
|
|
}
|