diff --git a/macros/src/kernel.rs b/macros/src/kernel.rs deleted file mode 100644 index 9a42095..0000000 --- a/macros/src/kernel.rs +++ /dev/null @@ -1,16 +0,0 @@ -use proc_macro2::{Span, TokenStream}; -use quote::ToTokens; -use syn::{parse_quote, Error, Path}; - -pub fn render() -> syn::Result { - let ty: Path = if cfg!(fw = "1100") { - parse_quote!(okf_1100::Kernel) - } else { - return Err(Error::new( - Span::call_site(), - "invalid `fw` configuration, see okf README for the instructions", - )); - }; - - Ok(ty.into_token_stream()) -} diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 1411b2b..7dca902 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -2,7 +2,6 @@ use proc_macro::TokenStream; use syn::{parse_macro_input, Error, ItemStruct, LitInt, TraitItem}; mod derive; -mod kernel; mod offset; #[proc_macro_derive(MappedKernel)] @@ -14,17 +13,6 @@ pub fn derive_mapped_kernel(item: TokenStream) -> TokenStream { .into() } -/// Renders kernel type based on `fw` configuration. -/// -/// This macro was designed to be used by the application. Use trait bound with `okf::Kernel` -/// instead if you are building a library. -#[proc_macro] -pub fn kernel(_: TokenStream) -> TokenStream { - self::kernel::render() - .unwrap_or_else(Error::into_compile_error) - .into() -} - #[proc_macro_attribute] pub fn offset(args: TokenStream, item: TokenStream) -> TokenStream { let args = parse_macro_input!(args as LitInt); diff --git a/src/lib.rs b/src/lib.rs index 10b5cbb..e3a179d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,14 @@ pub mod thread; pub mod ucred; pub mod uio; +#[cfg(fw = "1100")] +#[macro_export] +macro_rules! kernel { + () => { + okf_1100::Kernel + }; +} + /// Provides methods to access the PS4 kernel for a specific version. /// /// Most methods here are a direct call to the kernel so most of them are unsafe and hard to use.