jc/math/module.jai
2025-05-25 17:00:42 -06:00

44 lines
1.3 KiB
Text

#module_parameters(
UNITS: enum { radians; degrees; turns; } = .turns,
RUN_TESTS := false
);
// @todo(judah): dumb we can't use meta.range_for here.
U8_Min, U8_Max :: #run meta.lo_for(u8), #run meta.hi_for(u8);
U16_Min, U16_Max :: #run meta.lo_for(u16), #run meta.hi_for(u16);
U32_Min, U32_Max :: #run meta.lo_for(u32), #run meta.hi_for(u32);
U64_Min, U64_Max :: #run meta.lo_for(u64), #run meta.hi_for(u64);
S8_Min, S8_Max :: #run meta.lo_for(s8), #run meta.hi_for(s8);
S16_Min, S16_Max :: #run meta.lo_for(s16), #run meta.hi_for(s16);
S32_Min, S32_Max :: #run meta.lo_for(s32), #run meta.hi_for(s32);
S64_Min, S64_Max :: #run meta.lo_for(s64), #run meta.hi_for(s64);
F32_Min, F32_Max :: #run meta.lo_for(float32), #run meta.hi_for(float32);
F64_Min, F64_Max :: #run meta.lo_for(float64), #run meta.hi_for(float64);
#load "vec.jai";
#load "mat.jai";
#load "ease.jai";
#scope_module;
bounds_check_index :: ($$idx: int, $count: int, loc := #caller_location) #expand {
#if is_constant(idx) {
#assert (idx >= 0 && idx < count) "bounds check failed";
}
else {
basic.assert(idx >= 0 && idx < count, "bounds check failed! index: % (min: 0, max: %)", idx, count, loc = loc);
}
}
#if RUN_TESTS {
test :: #import "jc/test";
}
#scope_file;
meta :: #import "jc/meta";
basic :: #import "Basic"; // @future