From a7e7455c577ecf0e7a6f6b824b91de5dc65beb21 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Tue, 24 Sep 2024 20:59:01 +0100 Subject: [PATCH] Add macros for include_s3m and include_mod --- tracker/agb-xm/src/lib.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tracker/agb-xm/src/lib.rs b/tracker/agb-xm/src/lib.rs index 97a43d4d..22b2aef0 100644 --- a/tracker/agb-xm/src/lib.rs +++ b/tracker/agb-xm/src/lib.rs @@ -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> { - Ok(XmModule::load(file_content)?.to_module()) -}