mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Add macros for include_s3m and include_mod
This commit is contained in:
parent
2d69b2a7a4
commit
a7e7455c57
|
@ -5,12 +5,27 @@ use proc_macro::TokenStream;
|
|||
use proc_macro_error::{abort, proc_macro_error};
|
||||
use quote::quote;
|
||||
use syn::LitStr;
|
||||
use xmrs::{module::Module, xm::xmmodule::XmModule};
|
||||
use xmrs::{
|
||||
amiga::amiga_module::AmigaModule, module::Module, s3m::s3m_module::S3mModule,
|
||||
xm::xmmodule::XmModule,
|
||||
};
|
||||
|
||||
#[proc_macro_error]
|
||||
#[proc_macro]
|
||||
pub fn include_xm(args: TokenStream) -> TokenStream {
|
||||
agb_xm_core(args, parse_xm)
|
||||
agb_xm_core(args, |content| Ok(XmModule::load(content)?.to_module()))
|
||||
}
|
||||
|
||||
#[proc_macro_error]
|
||||
#[proc_macro]
|
||||
pub fn include_s3m(args: TokenStream) -> TokenStream {
|
||||
agb_xm_core(args, |content| Ok(S3mModule::load(content)?.to_module()))
|
||||
}
|
||||
|
||||
#[proc_macro_error]
|
||||
#[proc_macro]
|
||||
pub fn include_mod(args: TokenStream) -> TokenStream {
|
||||
agb_xm_core(args, |content| Ok(AmigaModule::load(content)?.to_module()))
|
||||
}
|
||||
|
||||
fn agb_xm_core(
|
||||
|
@ -50,7 +65,3 @@ fn agb_xm_core(
|
|||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
fn parse_xm(file_content: &[u8]) -> Result<Module, Box<dyn Error>> {
|
||||
Ok(XmModule::load(file_content)?.to_module())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue