Don't assume agb-tracker-interop dependency

This commit is contained in:
Gwilym Inzani 2023-07-13 00:04:41 +01:00
parent a8d751a0ef
commit 86db9d15bf
2 changed files with 18 additions and 28 deletions

View file

@ -52,14 +52,12 @@ impl<'a> quote::ToTokens for Track<'a> {
tokens.append_all(quote! { tokens.append_all(quote! {
{ {
use agb_tracker_interop::*; const SAMPLES: &[agb_tracker::__private::agb_tracker_interop::Sample<'static>] = &[#(#samples),*];
const PATTERN_DATA: &[agb_tracker::__private::agb_tracker_interop::PatternSlot] = &[#(#pattern_data),*];
const SAMPLES: &[Sample<'static>] = &[#(#samples),*]; const PATTERNS: &[agb_tracker::__private::agb_tracker_interop::Pattern] = &[#(#patterns),*];
const PATTERN_DATA: &[PatternSlot] = &[#(#pattern_data),*];
const PATTERNS: &[Pattern] = &[#(#patterns),*];
const PATTERNS_TO_PLAY: &[usize] = &[#(#patterns_to_play),*]; const PATTERNS_TO_PLAY: &[usize] = &[#(#patterns_to_play),*];
Track { agb_tracker::Track {
samples: SAMPLES, samples: SAMPLES,
pattern_data: PATTERN_DATA, pattern_data: PATTERN_DATA,
patterns: PATTERNS, patterns: PATTERNS,
@ -95,13 +93,11 @@ impl<'a> quote::ToTokens for Sample<'a> {
tokens.append_all(quote! { tokens.append_all(quote! {
{ {
use agb_tracker_interop::*;
#[repr(align(4))] #[repr(align(4))]
struct AlignmentWrapper<const N: usize>([u8; N]); struct AlignmentWrapper<const N: usize>([u8; N]);
const SAMPLE_DATA: &[u8] = &AlignmentWrapper(*#samples).0; const SAMPLE_DATA: &[u8] = &AlignmentWrapper(*#samples).0;
agb_tracker_interop::Sample { data: SAMPLE_DATA, should_loop: #should_loop } agb_tracker::__private::agb_tracker_interop::Sample { data: SAMPLE_DATA, should_loop: #should_loop }
} }
}); });
} }
@ -124,16 +120,11 @@ impl quote::ToTokens for PatternSlot {
let panning = panning.to_raw(); let panning = panning.to_raw();
tokens.append_all(quote! { tokens.append_all(quote! {
{ agb_tracker::__private::agb_tracker_interop::PatternSlot {
use agb_tracker::__private::*; volume: agb_tracker::__private::Num::from_raw(#volume),
use agb::fixnum::Num; speed: agb_tracker::__private::Num::from_raw(#speed),
panning: agb_tracker::__private::Num::from_raw(#panning),
PatternSlot { sample: #sample,
volume: Num::from_raw(#volume),
speed: Num::from_raw(#speed),
panning: Num::from_raw(#panning),
sample: #sample,
}
} }
}); });
} }
@ -150,13 +141,9 @@ impl quote::ToTokens for Pattern {
} = self; } = self;
tokens.append_all(quote! { tokens.append_all(quote! {
{ agb_tracker::__private::agb_tracker_interop::Pattern {
use agb_tracker_interop::*; length: #length,
start_position: #start_position,
Pattern {
length: #length,
start_position: #start_position,
}
} }
}) })
} }

View file

@ -14,9 +14,12 @@ use agb::sound::mixer::{ChannelId, Mixer, SoundChannel};
#[cfg(feature = "xm")] #[cfg(feature = "xm")]
pub use agb_xm::import_xm; pub use agb_xm::import_xm;
pub use agb_tracker_interop as __private; pub mod __private {
pub use agb::fixnum::Num;
pub use agb_tracker_interop;
}
pub use __private::Track; pub use agb_tracker_interop::Track;
pub struct Tracker { pub struct Tracker {
track: &'static Track<'static>, track: &'static Track<'static>,