jc/math/module.jai

25 lines
556 B
Text

#module_parameters(
UNITS: enum { radians; degrees; turns; } = .turns,
RUN_TESTS := false
);
#load "vec.jai";
#load "mat.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);
}
}
basic :: #import "Basic";
#if RUN_TESTS {
test :: #import,file "../test/module.jai";
}