use crate::Float;
use bytemuck::cast_slice;

#[repr(C, align(16))]
struct AlignedData<const N: usize>(pub [u8; N]);

macro_rules! load_static_table {
    ($name:ident, $path:literal) => {
        pub static $name: &[Float] = {
            static RAW_DATA: AlignedData<{ include_bytes!($path).len() }> =
                AlignedData(*include_bytes!($path));

            unsafe {
                let bytes = &RAW_DATA.0;

                let stride = core::mem::size_of::<Float>();
                let len = bytes.len() / stride;
                debug_assert!(
                    bytes.len() % stride == 0,
                    "Data file size is not a multiple of Float size"
                );

                core::slice::from_raw_parts(bytes.as_ptr() as *const Float, len)
            }
        };
    };
}

load_static_table!(SRGB_SCALE, "../../data/srgb_scale.dat");
load_static_table!(SRGB_COEFFS, "../../data/srgb_coeffs.dat");

load_static_table!(DCI_P3_SCALE, "../../data/dcip3_scale.dat");
load_static_table!(DCI_P3_COEFFS, "../../data/dcip3_coeffs.dat");

load_static_table!(ACES_SCALE, "../../data/aces_scale.dat");
load_static_table!(ACES_COEFFS, "../../data/aces_coeffs.dat");

load_static_table!(REC2020_SCALE, "../../data/rec2020_scale.dat");
load_static_table!(REC2020_COEFFS, "../../data/rec2020_coeffs.dat");
