First 0.7 update, removing all deprecated features.

This commit is contained in:
Christoffer Lerno
2025-02-27 14:16:36 +01:00
committed by Christoffer Lerno
parent cff6697818
commit 2a895ec7be
1589 changed files with 2635 additions and 115363 deletions

View File

@@ -90,33 +90,33 @@ fault MatrixError
MATRIX_INVERSE_DOESNT_EXIST,
}
def Complexf = Complex(<float>);
def Complex = Complex(<double>);
def COMPLEX_IDENTITY = complex::IDENTITY(<double>) @builtin;
def COMPLEXF_IDENTITY = complex::IDENTITY(<float>) @builtin;
def Complexf = Complex{float};
def Complex = Complex{double};
def COMPLEX_IDENTITY = complex::IDENTITY{double} @builtin;
def COMPLEXF_IDENTITY = complex::IDENTITY{float} @builtin;
def Quaternionf = Quaternion(<float>);
def Quaternion = Quaternion(<double>);
def QUATERNION_IDENTITY = quaternion::IDENTITY(<double>) @builtin;
def QUATERNIONF_IDENTITY = quaternion::IDENTITY(<float>) @builtin;
def Quaternionf = Quaternion{float};
def Quaternion = Quaternion{double};
def QUATERNION_IDENTITY = quaternion::IDENTITY{double} @builtin;
def QUATERNIONF_IDENTITY = quaternion::IDENTITY{float} @builtin;
def Matrix2f = Matrix2x2(<float>);
def Matrix2 = Matrix2x2(<double>);
def Matrix3f = Matrix3x3(<float>);
def Matrix3 = Matrix3x3(<double>);
def Matrix4f = Matrix4x4(<float>);
def Matrix4 = Matrix4x4(<double>);
def matrix4_ortho = matrix::ortho(<double>) @builtin;
def matrix4_perspective = matrix::perspective(<double>) @builtin;
def matrix4f_ortho = matrix::ortho(<float>) @builtin;
def matrix4f_perspective = matrix::perspective(<float>) @builtin;
def Matrix2f = Matrix2x2{float};
def Matrix2 = Matrix2x2{double};
def Matrix3f = Matrix3x3{float};
def Matrix3 = Matrix3x3{double};
def Matrix4f = Matrix4x4{float};
def Matrix4 = Matrix4x4{double};
def matrix4_ortho = matrix::ortho{double} @builtin;
def matrix4_perspective = matrix::perspective{double} @builtin;
def matrix4f_ortho = matrix::ortho{float} @builtin;
def matrix4f_perspective = matrix::perspective{float} @builtin;
def MATRIX2_IDENTITY = matrix::IDENTITY2(<double>) @builtin;
def MATRIX2F_IDENTITY = matrix::IDENTITY2(<float>) @builtin;
def MATRIX3_IDENTITY = matrix::IDENTITY3(<double>) @builtin;
def MATRIX3F_IDENTITY = matrix::IDENTITY3(<float>) @builtin;
def MATRIX4_IDENTITY = matrix::IDENTITY4(<double>) @builtin;
def MATRIX4F_IDENTITY = matrix::IDENTITY4(<float>) @builtin;
def MATRIX2_IDENTITY = matrix::IDENTITY2{double} @builtin;
def MATRIX2F_IDENTITY = matrix::IDENTITY2{float} @builtin;
def MATRIX3_IDENTITY = matrix::IDENTITY3{double} @builtin;
def MATRIX3F_IDENTITY = matrix::IDENTITY3{float} @builtin;
def MATRIX4_IDENTITY = matrix::IDENTITY4{double} @builtin;
def MATRIX4F_IDENTITY = matrix::IDENTITY4{float} @builtin;
<*

View File

@@ -1,4 +1,4 @@
module std::math::complex(<Real>);
module std::math::complex{Real};
union Complex
{

View File

@@ -1,4 +1,4 @@
module std::math::matrix(<Real>);
module std::math::matrix{Real};
import std::math::vector;
struct Matrix2x2

View File

@@ -1,15 +1,15 @@
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _fabs(double x) @weak @extern("fabs") @nostrip
{
ulong ix = bitcast(x, ulong);
ix &= ~(1ul << 63);
return bitcast(ix, double);
}
fn float _fabsf(float x) @weak @extern("fabsf") @nostrip
{
uint ix = bitcast(x, uint);
ix &= 0x7fffffff;
return bitcast(ix, float);
}
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _fabs(double x) @weak @extern("fabs") @nostrip
{
ulong ix = bitcast(x, ulong);
ix &= ~(1ul << 63);
return bitcast(ix, double);
}
fn float _fabsf(float x) @weak @extern("fabsf") @nostrip
{
uint ix = bitcast(x, uint);
ix &= 0x7fffffff;
return bitcast(ix, float);
}

View File

@@ -1,59 +1,59 @@
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double frexp(double x, int* exp) @extern("frexp")
{
uint hx = x.high_word();
uint ix = hx & 0x7fffffff;
uint lx = x.low_word();
if (ix >= 0x7ff00000 || (ix | lx) == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((ix >> 20) & 0x7ff);
if (e == 0)
{
// subnormal number
x *= 0x1p64;
hx = x.high_word();
e = (int)((hx >> 20) & 0x7ff) - 64;
}
*exp = e - 1022;
// set exponent to -1 (fraction in [0.5, 1))
hx = (hx & 0x800fffff) | 0x3fe00000;
{
ulong rep = ((ulong)hx << 32) | lx;
return bitcast(rep, double);
}
}
fn float frexpf(float x, int* exp) @extern("frexpf")
{
uint ix = x.word();
uint hx = ix & 0x7fffffff;
if (hx >= 0x7f800000 || hx == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((hx >> 23) & 0xff);
if (e == 0)
{
// subnormal number
x *= 0x1p64f;
ix = x.word();
e = (int)((ix >> 23) & 0xff) - 64;
}
*exp = e - 126;
// set exponent to -1 (fraction in [0.5, 1))
ix = (ix & 0x807fffff) | 0x3f000000;
return bitcast(ix, float);
}
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double frexp(double x, int* exp) @extern("frexp")
{
uint hx = x.high_word();
uint ix = hx & 0x7fffffff;
uint lx = x.low_word();
if (ix >= 0x7ff00000 || (ix | lx) == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((ix >> 20) & 0x7ff);
if (e == 0)
{
// subnormal number
x *= 0x1p64;
hx = x.high_word();
e = (int)((hx >> 20) & 0x7ff) - 64;
}
*exp = e - 1022;
// set exponent to -1 (fraction in [0.5, 1))
hx = (hx & 0x800fffff) | 0x3fe00000;
{
ulong rep = ((ulong)hx << 32) | lx;
return bitcast(rep, double);
}
}
fn float frexpf(float x, int* exp) @extern("frexpf")
{
uint ix = x.word();
uint hx = ix & 0x7fffffff;
if (hx >= 0x7f800000 || hx == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((hx >> 23) & 0xff);
if (e == 0)
{
// subnormal number
x *= 0x1p64f;
ix = x.word();
e = (int)((ix >> 23) & 0xff) - 64;
}
*exp = e - 126;
// set exponent to -1 (fraction in [0.5, 1))
ix = (ix & 0x807fffff) | 0x3f000000;
return bitcast(ix, float);
}

View File

@@ -1,67 +1,67 @@
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double ldexp(double x, int exp) @extern("ldexp")
{
uint hx = x.high_word();
int hexp = (int)((hx & 0x7ff00000) >> 20);
if (hexp == 0x7ff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64;
hx = x.high_word();
hexp = (int)((hx & 0x7ff00000) >> 20) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0x7fe) return x * double.inf;
if (hexp < 1)
{
x *= 0x1p-1022;
hexp += 1022;
if (hexp < 1) x *= 0x1p-1022;
return x;
}
// set new exponent
hx = ((ulong)hx & 0x800fffff) | ((ulong)hexp << 20);
{
ulong rep = ((ulong)hx << 32) | x.low_word();
return bitcast(rep, double);
}
}
fn float ldexpf(float x, int exp) @extern("ldexpf")
{
uint ix = x.word();
int hexp = (int)((ix & 0x7f800000) >> 23);
if (hexp == 0xff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64f;
ix = x.word();
hexp = (int)((ix & 0x7f800000) >> 23) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0xfe) return x * float.inf;
if (hexp < 1)
{
x *= 0x1p-126f;
hexp += 126;
if (hexp < 1) x *= 0x1p-126f;
return x;
}
// set new exponent
ix = (ix & 0x807fffff) | (hexp << 23);
return bitcast(ix, float);
}
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double ldexp(double x, int exp) @extern("ldexp")
{
uint hx = x.high_word();
int hexp = (int)((hx & 0x7ff00000) >> 20);
if (hexp == 0x7ff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64;
hx = x.high_word();
hexp = (int)((hx & 0x7ff00000) >> 20) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0x7fe) return x * double.inf;
if (hexp < 1)
{
x *= 0x1p-1022;
hexp += 1022;
if (hexp < 1) x *= 0x1p-1022;
return x;
}
// set new exponent
hx = ((ulong)hx & 0x800fffff) | ((ulong)hexp << 20);
{
ulong rep = ((ulong)hx << 32) | x.low_word();
return bitcast(rep, double);
}
}
fn float ldexpf(float x, int exp) @extern("ldexpf")
{
uint ix = x.word();
int hexp = (int)((ix & 0x7f800000) >> 23);
if (hexp == 0xff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64f;
ix = x.word();
hexp = (int)((ix & 0x7f800000) >> 23) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0xfe) return x * float.inf;
if (hexp < 1)
{
x *= 0x1p-126f;
hexp += 126;
if (hexp < 1) x *= 0x1p-126f;
return x;
}
// set new exponent
ix = (ix & 0x807fffff) | (hexp << 23);
return bitcast(ix, float);
}

View File

@@ -1,4 +1,4 @@
module std::math::quaternion(<Real>);
module std::math::quaternion{Real};
import std::math::vector;
union Quaternion
{

View File

@@ -66,8 +66,8 @@ fn Vec3 Vec3.refract(self, Vec3 n, double r) => refract3(self, n, r);
fn void ortho_normalize(Vec3f* v1, Vec3f* v2) => ortho_normalize3(v1, v2);
fn void ortho_normalized(Vec3* v1, Vec3* v2) => ortho_normalize3(v1, v2);
fn Matrix4f matrix4f_look_at(Vec3f eye, Vec3f target, Vec3f up) @deprecated => matrix::look_at(<float>)(eye, target, up);
fn Matrix4 matrix4_look_at(Vec3 eye, Vec3 target, Vec3 up) @deprecated => matrix::look_at(<double>)(eye, target, up);
fn Matrix4f matrix4f_look_at(Vec3f eye, Vec3f target, Vec3f up) @deprecated => matrix::look_at{float}(eye, target, up);
fn Matrix4 matrix4_look_at(Vec3 eye, Vec3 target, Vec3 up) @deprecated => matrix::look_at{double}(eye, target, up);
fn Vec3f Vec3f.rotate_quat(self, Quaternionf q) => rotate_by_quat3(self, q);
fn Vec3 Vec3.rotate_quat(self, Quaternion q) => rotate_by_quat3(self, q);

View File

@@ -35,7 +35,7 @@ fn usz! Uuid.to_format(&self, Formatter* formatter) @dynamic
(*self)[10], (*self)[11], (*self)[12], (*self)[13], (*self)[14], (*self)[15]);
}
fn String Uuid.to_string(&self, Allocator allocator) @dynamic
fn String Uuid.to_string(&self, Allocator allocator)
{
return string::new_format("%s", *self, allocator: allocator);
return string::format(allocator, "%s", *self);
}