Support C++98; Make some facilities standard-dependent; Don't implement one-line functions in seperate files; Remove restr; Update optimisation flags; Use reference for value in fil and srh; Qualify template parameters correctly; Update template typings; Make all C++ functions (except cpy, equ, isconsteval, fil, and srh) run-time; Implement some functions in C again; Add private header directory; Add function for filling strings: strfil; Don't always define nulptrtyp; Mind the digraphs; Combine tests; Support C90; Don't use C++-style comments; Fix typings of constants; Remove pair type (replace with divmodres); Remove member functions from vector classes; Don't implement mathematical functions as templates in C++; Update naming convention for vector functions; Add more trigonometric functions; Temporarily remove fmt;
This commit is contained in:
parent
30735cc158
commit
937463e5ec
102 changed files with 1406 additions and 1579 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@
|
|||
/build
|
||||
/install
|
||||
/test
|
||||
|
||||
/tmp
|
||||
|
|
|
@ -84,6 +84,31 @@
|
|||
|
||||
* Clean up makefile;
|
||||
|
||||
* Support C++98;
|
||||
* Make some facilities standard-dependent;
|
||||
* Don't implement one-line functions in seperate files;
|
||||
* Remove restr;
|
||||
* Update optimisation flags;
|
||||
* Use reference for value in fil and srh;
|
||||
* Qualify template parameters correctly;
|
||||
* Update template typings;
|
||||
* Make all C++ functions (except cpy, equ, isconsteval, fil, and srh) run-time;
|
||||
* Implement some functions in C again;
|
||||
* Add private header directory;
|
||||
* Add function for filling strings: strfil;
|
||||
* Don't always define nulptrtyp;
|
||||
* Mind the digraphs;
|
||||
* Combine tests;
|
||||
* Support C90;
|
||||
* Don't use C++-style comments;
|
||||
* Fix typings of constants;
|
||||
* Remove pair type (replace with divmodres);
|
||||
* Remove member functions from vector classes;
|
||||
* Don't implement mathematical functions as templates in C++;
|
||||
* Update naming convention for vector functions;
|
||||
* Add more trigonometric functions;
|
||||
* Temporarily remove fmt;
|
||||
|
||||
# 0.0.2
|
||||
|
||||
* Migrate to CMake;
|
||||
|
|
223
rttest.cc
223
rttest.cc
|
@ -1,223 +0,0 @@
|
|||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <source_location>
|
||||
#include <typeinfo>
|
||||
#include <zp/mem>
|
||||
#include <zp/mth>
|
||||
#include <zp/str>
|
||||
|
||||
int main() {
|
||||
int unsigned num;
|
||||
int unsigned numerr = 0x0u;
|
||||
|
||||
auto const tst = [&num](char const * const cmp) noexcept {
|
||||
::std::cout << "\n\x1B[38;5;75mtesting\x1B[0m " << cmp << "\n\n";
|
||||
|
||||
num = 0x0;
|
||||
};
|
||||
|
||||
auto const cmp = [&num,&numerr]<typename ltyp,typename rtyp>(ltyp const & lvalref,rtyp const & rvalref,::std::source_location const srcloc = ::std::source_location::current()) {
|
||||
char const * const ltypnm = typeid (ltyp).name();
|
||||
char const * const rtypnm = typeid (rtyp).name();
|
||||
|
||||
auto const getval = []<typename typ>(typ const & valref) {
|
||||
if constexpr (::zp::ischr<typ>::val) {return static_cast<::zp::i02m>(valref);}
|
||||
else if constexpr (::zp::isptr<typ>::val) {return reinterpret_cast<void *>(valref);}
|
||||
else {return valref;}
|
||||
};
|
||||
|
||||
auto const lval = getval(lvalref);
|
||||
auto const rval = getval(rvalref);
|
||||
|
||||
::std::cout << " " << num++ << ". comparing " << ltypnm << " (" << lval << ") vs. " << rtypnm << " (" << rval << ")... ";
|
||||
|
||||
if (lval != rval) {
|
||||
::std::cout << "\x1B[38;5;161munequal\x1B[0m (at #" << srcloc.line() << ")\n";
|
||||
//throw ::std::exception {};
|
||||
++numerr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
::std::cout << "\x1B[38;5;77mequal\x1B[0m\n";
|
||||
};
|
||||
|
||||
::std::cout << "zp " << ::zp::ver << "." << ::zp::extver << ", run-time test\n";
|
||||
|
||||
try {
|
||||
[&] {
|
||||
tst("vectors");
|
||||
|
||||
::zp::vec2<int> const lvec2 = {
|
||||
.x = +0x1,
|
||||
.y = -0x3,
|
||||
};
|
||||
::zp::vec2<int> const rvec2 = {
|
||||
.x = +0x2,
|
||||
.y = -0x4,
|
||||
};
|
||||
cmp(::zp::dot(lvec2,rvec2),0xE);
|
||||
|
||||
::zp::vec3<int> const lvec3 = {
|
||||
.x = +0x1,
|
||||
.y = -0x3,
|
||||
.z = +0x5,
|
||||
};
|
||||
::zp::vec3<int> const rvec3 = {
|
||||
.x = +0x2,
|
||||
.y = -0x4,
|
||||
.z = +0x6,
|
||||
};
|
||||
cmp(::zp::dot(lvec3,rvec3),0x2C);
|
||||
|
||||
::zp::vec4<int> const lvec4 = {
|
||||
.x = +0x1,
|
||||
.y = -0x3,
|
||||
.z = +0x5,
|
||||
.w = -0x7,
|
||||
};
|
||||
::zp::vec4<int> const rvec4 = {
|
||||
.x = +0x2,
|
||||
.y = -0x4,
|
||||
.z = +0x6,
|
||||
.w = -0x8,
|
||||
};
|
||||
cmp(::zp::dot(lvec4,rvec4),0x64);
|
||||
|
||||
auto const avec2 = ::zp::vadd(lvec2,rvec2);
|
||||
auto const svec2 = ::zp::vsub(lvec2,rvec2);
|
||||
cmp(avec2.x,+0x3);
|
||||
cmp(avec2.y,-0x7);
|
||||
cmp(svec2.x,-0x1);
|
||||
cmp(svec2.y,+0x1);
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("special numbers");
|
||||
|
||||
cmp(zp_isnanf( zp_nanf), true);
|
||||
cmp(zp_isnand( zp_nand), true);
|
||||
cmp(zp_isnanld(zp_nanld),true);
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("memory sequences");
|
||||
|
||||
::zp::i04 filbuf;
|
||||
|
||||
cmp(::zp::memfil(&filbuf,0xFFu,0x8u),reinterpret_cast<unsigned char *>(&filbuf)+0x8u);
|
||||
cmp(::zp::memfil(&filbuf,0x7Fu,0x4u),reinterpret_cast<unsigned char *>(&filbuf)+0x4u);
|
||||
cmp(::zp::memfil(&filbuf,0x3Fu,0x2u),reinterpret_cast<unsigned char *>(&filbuf)+0x2u);
|
||||
cmp(::zp::memfil(&filbuf,0x1Fu,0x1u),reinterpret_cast<unsigned char *>(&filbuf)+0x1u);
|
||||
|
||||
cmp(filbuf,0xFFFFFFFF7F7F3F1Fu);
|
||||
|
||||
::zp::i04 cpybuf;
|
||||
::zp::memcpy(&cpybuf,&filbuf,0x8u);
|
||||
|
||||
cmp(cpybuf,filbuf);
|
||||
|
||||
cmp(::zp::memsrh(&cpybuf,0x1Fu,0x8u),reinterpret_cast<unsigned char *>(&cpybuf));
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("strings");
|
||||
|
||||
char str[] = "Hello there!";
|
||||
wchar_t wstr[] = L"Hello there!";
|
||||
char32_t str02[] = U"Hello there!";
|
||||
|
||||
::zp::sz const len = ::zp_strlen( str);
|
||||
::zp::sz const wlen = ::zp_wstrlen( wstr);
|
||||
::zp::sz const len02 = ::zp_utf32len(str02);
|
||||
|
||||
cmp(len, 0xCu);
|
||||
cmp(wlen, 0xCu);
|
||||
cmp(len02,0xCu);
|
||||
|
||||
auto const buf = new char[ len];
|
||||
auto const wbuf = new wchar_t[ wlen];
|
||||
auto const buf02 = new char32_t[len02];
|
||||
|
||||
cmp(::zp_strcpy( buf, str), len);
|
||||
cmp(::zp_wstrcpy( wbuf, wstr), wlen);
|
||||
cmp(::zp_utf32cpy(buf02,str02),len02);
|
||||
|
||||
delete[] buf;
|
||||
delete[] wbuf;
|
||||
delete[] buf02;
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("UTF-8");
|
||||
|
||||
char32_t const src[] = U"\U0001F480";
|
||||
|
||||
::zp::sz const buf8len = ::zp_utf8enclen(src);
|
||||
cmp(buf8len,0x4u);
|
||||
|
||||
char8_t * buf8 = new char8_t[buf8len+0x1u];
|
||||
|
||||
::zp_utf8enc(buf8,src);
|
||||
|
||||
cmp(buf8[0x0u],0xF0u);
|
||||
cmp(buf8[0x1u],0x9Fu);
|
||||
cmp(buf8[0x2u],0x92u);
|
||||
cmp(buf8[0x3u],0x80u);
|
||||
cmp(buf8[0x4u],0x00u);
|
||||
|
||||
::zp::sz const buf02len = ::zp_utf8declen(buf8);
|
||||
cmp(buf02len,0x1u);
|
||||
|
||||
char32_t * buf02 = new char32_t[buf02len+0x1u];
|
||||
|
||||
::zp_utf8dec(buf02,buf8);
|
||||
|
||||
cmp(buf02[0x0u],0x1F480u);
|
||||
cmp(buf02[0x1u],0x0u);
|
||||
|
||||
delete[] buf8;
|
||||
delete[] buf02;
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("UTF-16");
|
||||
|
||||
char32_t const src[] = U"\U0001F480\u00F0";
|
||||
|
||||
::zp::sz const buf01len = ::zp_utf16enclen(src);
|
||||
cmp(buf01len,0x3u);
|
||||
|
||||
char16_t * buf01 = new char16_t[buf01len+0x1u];
|
||||
|
||||
::zp_utf16enc(buf01,src);
|
||||
|
||||
cmp(buf01[0x0u],0xD83Du);
|
||||
cmp(buf01[0x1u],0xDC80u);
|
||||
cmp(buf01[0x2u],0x00F0u);
|
||||
cmp(buf01[0x3u],0x0000u);
|
||||
|
||||
::zp::sz const buf02len = ::zp_utf16declen(buf01);
|
||||
cmp(buf02len,0x2u);
|
||||
|
||||
char32_t * buf02 = new char32_t[buf02len+0x1u];
|
||||
|
||||
::zp_utf16dec(buf02,buf01);
|
||||
|
||||
cmp(buf02[0x0u],0x1F480u);
|
||||
cmp(buf02[0x1u],0xF0u);
|
||||
cmp(buf02[0x2u],0x0u);
|
||||
|
||||
delete[] buf01;
|
||||
delete[] buf02;
|
||||
}();
|
||||
}
|
||||
catch (::std::exception const &) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
::std::cout << "\nDone \u2212 " << numerr << " error(s)\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
450
test.cc
450
test.cc
|
@ -1,139 +1,351 @@
|
|||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <zp/mth>
|
||||
#include <source_location>
|
||||
#include <typeinfo>
|
||||
#include <zp/mem>
|
||||
#include <zp/mth>
|
||||
#include <zp/str>
|
||||
|
||||
int main() {
|
||||
static_assert([] {
|
||||
static_assert(::zp::isptr<int>::val == false);
|
||||
static_assert(::zp::isptr<int *>::val == true);
|
||||
static_assert(::zp::isptr<int const *>::val == true);
|
||||
static_assert(::zp::isptr<int volatile *>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile *>::val == true);
|
||||
static_assert(::zp::isptr<int * const>::val == true);
|
||||
static_assert(::zp::isptr<int const * const>::val == true);
|
||||
static_assert(::zp::isptr<int volatile * const>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile * const>::val == true);
|
||||
static_assert(::zp::isptr<int * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int volatile * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int volatile * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int>::val == false);
|
||||
static_assert(::zp::isptr<int *>::val == true);
|
||||
static_assert(::zp::isptr<int const *>::val == true);
|
||||
static_assert(::zp::isptr<int volatile *>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile *>::val == true);
|
||||
static_assert(::zp::isptr<int * const>::val == true);
|
||||
static_assert(::zp::isptr<int const * const>::val == true);
|
||||
static_assert(::zp::isptr<int volatile * const>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile * const>::val == true);
|
||||
static_assert(::zp::isptr<int * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int volatile * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile * volatile>::val == true);
|
||||
static_assert(::zp::isptr<int * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int volatile * const volatile>::val == true);
|
||||
static_assert(::zp::isptr<int const volatile * const volatile>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<int,int>::val == true);
|
||||
static_assert(::zp::typequ<int,long>::val == false);
|
||||
static_assert(::zp::typequ<int,int>::val == true);
|
||||
static_assert(::zp::typequ<int,long>::val == false);
|
||||
|
||||
static_assert(::zp::typequ<::zp::sgn<int>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::sgn<int unsigned>::typ,int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::sgn<int>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::sgn<int unsigned>::typ,int>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<::zp::usgn<int unsigned>::typ,int unsigned>::val == true);
|
||||
static_assert(::zp::typequ<::zp::usgn<int>::typ, int unsigned>::val == true);
|
||||
static_assert(::zp::typequ<::zp::usgn<int unsigned>::typ,int unsigned>::val == true);
|
||||
static_assert(::zp::typequ<::zp::usgn<int>::typ, int unsigned>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<::zp::remqual<int volatile>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int const volatile>::typ,int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int volatile>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int const volatile>::typ,int>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<::zp::remqual<int>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int const>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int volatile>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int const volatile>::typ,int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int const>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int volatile>::typ, int>::val == true);
|
||||
static_assert(::zp::typequ<::zp::remqual<int const volatile>::typ,int>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<::zp::nulptrtyp,::std::nullptr_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::nulptrtyp,::std::nullptr_t>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<::zp::i8m, ::std::uint_least8_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i8ms, ::std::int_least8_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i01m, ::std::uint_least16_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i01ms,::std::int_least16_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i02m, ::std::uint_least32_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i02ms,::std::int_least32_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i04m, ::std::uint_least64_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i04ms,::std::int_least64_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i8m, ::std::uint_least8_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i8ms, ::std::int_least8_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i01m, ::std::uint_least16_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i01ms,::std::int_least16_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i02m, ::std::uint_least32_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i02ms,::std::int_least32_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i04m, ::std::uint_least64_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::i04ms,::std::int_least64_t>::val == true);
|
||||
|
||||
static_assert(::zp::typequ<::zp::intptr,::std::uintptr_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::sz, ::std::size_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::intptr,::std::uintptr_t>::val == true);
|
||||
static_assert(::zp::typequ<::zp::sz, ::std::size_t>::val == true);
|
||||
|
||||
static_assert(::zp::isusgn<char>::val == ::std::is_unsigned_v<char>);
|
||||
static_assert(::zp::isusgn<char16_t>::val == ::std::is_unsigned_v<char16_t>);
|
||||
static_assert(::zp::isusgn<char32_t>::val == ::std::is_unsigned_v<char32_t>);
|
||||
static_assert(::zp::isusgn<char8_t>::val == ::std::is_unsigned_v<char8_t>);
|
||||
static_assert(::zp::isusgn<double>::val == ::std::is_unsigned_v<double>);
|
||||
static_assert(::zp::isusgn<float>::val == ::std::is_unsigned_v<float>);
|
||||
static_assert(::zp::isusgn<int>::val == ::std::is_unsigned_v<int>);
|
||||
static_assert(::zp::isusgn<long>::val == ::std::is_unsigned_v<long>);
|
||||
static_assert(::zp::isusgn<long double>::val == ::std::is_unsigned_v<long double>);
|
||||
static_assert(::zp::isusgn<long long>::val == ::std::is_unsigned_v<long long>);
|
||||
static_assert(::zp::isusgn<short>::val == ::std::is_unsigned_v<short>);
|
||||
static_assert(::zp::isusgn<char signed>::val == ::std::is_unsigned_v<char signed>);
|
||||
static_assert(::zp::isusgn<char unsigned>::val == ::std::is_unsigned_v<char unsigned>);
|
||||
static_assert(::zp::isusgn<int unsigned>::val == ::std::is_unsigned_v<int unsigned>);
|
||||
static_assert(::zp::isusgn<long unsigned>::val == ::std::is_unsigned_v<long unsigned>);
|
||||
static_assert(::zp::isusgn<long long unsigned>::val == ::std::is_unsigned_v<long long unsigned>);
|
||||
static_assert(::zp::isusgn<short unsigned>::val == ::std::is_unsigned_v<short unsigned>);
|
||||
static_assert(::zp::isusgn<wchar_t>::val == ::std::is_unsigned_v<wchar_t>);
|
||||
static_assert(::zp::isusgn<char>::val == ::std::is_unsigned<char>::value);
|
||||
static_assert(::zp::isusgn<char16_t>::val == ::std::is_unsigned<char16_t>::value);
|
||||
static_assert(::zp::isusgn<char32_t>::val == ::std::is_unsigned<char32_t>::value);
|
||||
static_assert(::zp::isusgn<char8_t>::val == ::std::is_unsigned<char8_t>::value);
|
||||
static_assert(::zp::isusgn<double>::val == ::std::is_unsigned<double>::value);
|
||||
static_assert(::zp::isusgn<float>::val == ::std::is_unsigned<float>::value);
|
||||
static_assert(::zp::isusgn<int>::val == ::std::is_unsigned<int>::value);
|
||||
static_assert(::zp::isusgn<long>::val == ::std::is_unsigned<long>::value);
|
||||
static_assert(::zp::isusgn<long double>::val == ::std::is_unsigned<long double>::value);
|
||||
static_assert(::zp::isusgn<long long>::val == ::std::is_unsigned<long long>::value);
|
||||
static_assert(::zp::isusgn<short>::val == ::std::is_unsigned<short>::value);
|
||||
static_assert(::zp::isusgn<char signed>::val == ::std::is_unsigned<char signed>::value);
|
||||
static_assert(::zp::isusgn<char unsigned>::val == ::std::is_unsigned<char unsigned>::value);
|
||||
static_assert(::zp::isusgn<int unsigned>::val == ::std::is_unsigned<int unsigned>::value);
|
||||
static_assert(::zp::isusgn<long unsigned>::val == ::std::is_unsigned<long unsigned>::value);
|
||||
static_assert(::zp::isusgn<long long unsigned>::val == ::std::is_unsigned<long long unsigned>::value);
|
||||
static_assert(::zp::isusgn<short unsigned>::val == ::std::is_unsigned<short unsigned>::value);
|
||||
static_assert(::zp::isusgn<wchar_t>::val == ::std::is_unsigned<wchar_t>::value);
|
||||
|
||||
static_assert(::zp::issgn<char>::val == ::std::is_signed_v<char>);
|
||||
static_assert(::zp::issgn<double>::val == ::std::is_signed_v<double>);
|
||||
static_assert(::zp::issgn<float>::val == ::std::is_signed_v<float>);
|
||||
static_assert(::zp::issgn<int>::val == ::std::is_signed_v<int>);
|
||||
static_assert(::zp::issgn<long>::val == ::std::is_signed_v<long>);
|
||||
static_assert(::zp::issgn<long double>::val == ::std::is_signed_v<long double>);
|
||||
static_assert(::zp::issgn<long long>::val == ::std::is_signed_v<long long>);
|
||||
static_assert(::zp::issgn<short>::val == ::std::is_signed_v<short>);
|
||||
static_assert(::zp::issgn<char signed>::val == ::std::is_signed_v<char signed>);
|
||||
static_assert(::zp::issgn<char unsigned>::val == ::std::is_signed_v<char unsigned>);
|
||||
static_assert(::zp::issgn<int unsigned>::val == ::std::is_signed_v<int unsigned>);
|
||||
static_assert(::zp::issgn<long unsigned>::val == ::std::is_signed_v<long unsigned>);
|
||||
static_assert(::zp::issgn<long long unsigned>::val == ::std::is_signed_v<long long unsigned>);
|
||||
static_assert(::zp::issgn<short unsigned>::val == ::std::is_signed_v<short unsigned>);
|
||||
static_assert(::zp::issgn<wchar_t>::val == ::std::is_signed_v<wchar_t>);
|
||||
static_assert(::zp::issgn<char>::val == ::std::is_signed<char>::value);
|
||||
static_assert(::zp::issgn<double>::val == ::std::is_signed<double>::value);
|
||||
static_assert(::zp::issgn<float>::val == ::std::is_signed<float>::value);
|
||||
static_assert(::zp::issgn<int>::val == ::std::is_signed<int>::value);
|
||||
static_assert(::zp::issgn<long>::val == ::std::is_signed<long>::value);
|
||||
static_assert(::zp::issgn<long double>::val == ::std::is_signed<long double>::value);
|
||||
static_assert(::zp::issgn<long long>::val == ::std::is_signed<long long>::value);
|
||||
static_assert(::zp::issgn<short>::val == ::std::is_signed<short>::value);
|
||||
static_assert(::zp::issgn<char signed>::val == ::std::is_signed<char signed>::value);
|
||||
static_assert(::zp::issgn<char unsigned>::val == ::std::is_signed<char unsigned>::value);
|
||||
static_assert(::zp::issgn<int unsigned>::val == ::std::is_signed<int unsigned>::value);
|
||||
static_assert(::zp::issgn<long unsigned>::val == ::std::is_signed<long unsigned>::value);
|
||||
static_assert(::zp::issgn<long long unsigned>::val == ::std::is_signed<long long unsigned>::value);
|
||||
static_assert(::zp::issgn<short unsigned>::val == ::std::is_signed<short unsigned>::value);
|
||||
static_assert(::zp::issgn<wchar_t>::val == ::std::is_signed<wchar_t>::value);
|
||||
|
||||
static_assert(::zp::bytelen == CHAR_BIT);
|
||||
static_assert(::zp::bytelen == CHAR_BIT);
|
||||
|
||||
static_assert(::zp::minval<bool>::val == ::std::numeric_limits<bool>::lowest());
|
||||
static_assert(::zp::minval<char>::val == ::std::numeric_limits<char>::lowest());
|
||||
static_assert(::zp::minval<char16_t>::val == ::std::numeric_limits<char16_t>::lowest());
|
||||
static_assert(::zp::minval<char32_t>::val == ::std::numeric_limits<char32_t>::lowest());
|
||||
static_assert(::zp::minval<char8_t>::val == ::std::numeric_limits<char8_t>::lowest());
|
||||
static_assert(::zp::minval<double>::val == ::std::numeric_limits<double>::lowest());
|
||||
static_assert(::zp::minval<float>::val == ::std::numeric_limits<float>::lowest());
|
||||
static_assert(::zp::minval<int>::val == ::std::numeric_limits<int>::lowest());
|
||||
static_assert(::zp::minval<long>::val == ::std::numeric_limits<long>::lowest());
|
||||
static_assert(::zp::minval<long double>::val == ::std::numeric_limits<long double>::lowest());
|
||||
static_assert(::zp::minval<long long>::val == ::std::numeric_limits<long long>::lowest());
|
||||
static_assert(::zp::minval<short>::val == ::std::numeric_limits<short>::lowest());
|
||||
static_assert(::zp::minval<char signed>::val == ::std::numeric_limits<char signed>::lowest());
|
||||
static_assert(::zp::minval<char unsigned>::val == ::std::numeric_limits<char unsigned>::lowest());
|
||||
static_assert(::zp::minval<short unsigned>::val == ::std::numeric_limits<short unsigned>::lowest());
|
||||
static_assert(::zp::minval<int unsigned>::val == ::std::numeric_limits<int unsigned>::lowest());
|
||||
static_assert(::zp::minval<long unsigned>::val == ::std::numeric_limits<long unsigned>::lowest());
|
||||
static_assert(::zp::minval<long long unsigned>::val == ::std::numeric_limits<long long unsigned>::lowest());
|
||||
static_assert(::zp::minval<wchar_t>::val == ::std::numeric_limits<wchar_t>::lowest());
|
||||
static_assert(::zp::minval<bool>::val == ::std::numeric_limits<bool>::lowest());
|
||||
static_assert(::zp::minval<char>::val == ::std::numeric_limits<char>::lowest());
|
||||
static_assert(::zp::minval<char16_t>::val == ::std::numeric_limits<char16_t>::lowest());
|
||||
static_assert(::zp::minval<char32_t>::val == ::std::numeric_limits<char32_t>::lowest());
|
||||
static_assert(::zp::minval<char8_t>::val == ::std::numeric_limits<char8_t>::lowest());
|
||||
static_assert(::zp::minval<double>::val == ::std::numeric_limits<double>::lowest());
|
||||
static_assert(::zp::minval<float>::val == ::std::numeric_limits<float>::lowest());
|
||||
static_assert(::zp::minval<int>::val == ::std::numeric_limits<int>::lowest());
|
||||
static_assert(::zp::minval<long>::val == ::std::numeric_limits<long>::lowest());
|
||||
static_assert(::zp::minval<long double>::val == ::std::numeric_limits<long double>::lowest());
|
||||
static_assert(::zp::minval<long long>::val == ::std::numeric_limits<long long>::lowest());
|
||||
static_assert(::zp::minval<short>::val == ::std::numeric_limits<short>::lowest());
|
||||
static_assert(::zp::minval<char signed>::val == ::std::numeric_limits<char signed>::lowest());
|
||||
static_assert(::zp::minval<char unsigned>::val == ::std::numeric_limits<char unsigned>::lowest());
|
||||
static_assert(::zp::minval<short unsigned>::val == ::std::numeric_limits<short unsigned>::lowest());
|
||||
static_assert(::zp::minval<int unsigned>::val == ::std::numeric_limits<int unsigned>::lowest());
|
||||
static_assert(::zp::minval<long unsigned>::val == ::std::numeric_limits<long unsigned>::lowest());
|
||||
static_assert(::zp::minval<long long unsigned>::val == ::std::numeric_limits<long long unsigned>::lowest());
|
||||
static_assert(::zp::minval<wchar_t>::val == ::std::numeric_limits<wchar_t>::lowest());
|
||||
|
||||
static_assert(::zp::maxval<bool>::val == ::std::numeric_limits<bool>::max());
|
||||
static_assert(::zp::maxval<char>::val == ::std::numeric_limits<char>::max());
|
||||
static_assert(::zp::maxval<char16_t>::val == ::std::numeric_limits<char16_t>::max());
|
||||
static_assert(::zp::maxval<char32_t>::val == ::std::numeric_limits<char32_t>::max());
|
||||
static_assert(::zp::maxval<char8_t>::val == ::std::numeric_limits<char8_t>::max());
|
||||
static_assert(::zp::maxval<double>::val == ::std::numeric_limits<double>::max());
|
||||
static_assert(::zp::maxval<float>::val == ::std::numeric_limits<float>::max());
|
||||
static_assert(::zp::maxval<int>::val == ::std::numeric_limits<int>::max());
|
||||
static_assert(::zp::maxval<long>::val == ::std::numeric_limits<long>::max());
|
||||
static_assert(::zp::maxval<long double>::val == ::std::numeric_limits<long double>::max());
|
||||
static_assert(::zp::maxval<long long>::val == ::std::numeric_limits<long long>::max());
|
||||
static_assert(::zp::maxval<short>::val == ::std::numeric_limits<short>::max());
|
||||
static_assert(::zp::maxval<char signed>::val == ::std::numeric_limits<char signed>::max());
|
||||
static_assert(::zp::maxval<char unsigned>::val == ::std::numeric_limits<char unsigned>::max());
|
||||
static_assert(::zp::maxval<short unsigned>::val == ::std::numeric_limits<short unsigned>::max());
|
||||
static_assert(::zp::maxval<int unsigned>::val == ::std::numeric_limits<int unsigned>::max());
|
||||
static_assert(::zp::maxval<long unsigned>::val == ::std::numeric_limits<long unsigned>::max());
|
||||
static_assert(::zp::maxval<long long unsigned>::val == ::std::numeric_limits<long long unsigned>::max());
|
||||
static_assert(::zp::maxval<wchar_t>::val == ::std::numeric_limits<wchar_t>::max());
|
||||
static_assert(::zp::maxval<bool>::val == ::std::numeric_limits<bool>::max());
|
||||
static_assert(::zp::maxval<char>::val == ::std::numeric_limits<char>::max());
|
||||
static_assert(::zp::maxval<char16_t>::val == ::std::numeric_limits<char16_t>::max());
|
||||
static_assert(::zp::maxval<char32_t>::val == ::std::numeric_limits<char32_t>::max());
|
||||
static_assert(::zp::maxval<char8_t>::val == ::std::numeric_limits<char8_t>::max());
|
||||
static_assert(::zp::maxval<double>::val == ::std::numeric_limits<double>::max());
|
||||
static_assert(::zp::maxval<float>::val == ::std::numeric_limits<float>::max());
|
||||
static_assert(::zp::maxval<int>::val == ::std::numeric_limits<int>::max());
|
||||
static_assert(::zp::maxval<long>::val == ::std::numeric_limits<long>::max());
|
||||
static_assert(::zp::maxval<long double>::val == ::std::numeric_limits<long double>::max());
|
||||
static_assert(::zp::maxval<long long>::val == ::std::numeric_limits<long long>::max());
|
||||
static_assert(::zp::maxval<short>::val == ::std::numeric_limits<short>::max());
|
||||
static_assert(::zp::maxval<char signed>::val == ::std::numeric_limits<char signed>::max());
|
||||
static_assert(::zp::maxval<char unsigned>::val == ::std::numeric_limits<char unsigned>::max());
|
||||
static_assert(::zp::maxval<short unsigned>::val == ::std::numeric_limits<short unsigned>::max());
|
||||
static_assert(::zp::maxval<int unsigned>::val == ::std::numeric_limits<int unsigned>::max());
|
||||
static_assert(::zp::maxval<long unsigned>::val == ::std::numeric_limits<long unsigned>::max());
|
||||
static_assert(::zp::maxval<long long unsigned>::val == ::std::numeric_limits<long long unsigned>::max());
|
||||
static_assert(::zp::maxval<wchar_t>::val == ::std::numeric_limits<wchar_t>::max());
|
||||
|
||||
return true;
|
||||
}());
|
||||
int main() {
|
||||
int unsigned num;
|
||||
int unsigned numerr = 0x0u;
|
||||
|
||||
auto const tst = [&num](char const * const cmp) noexcept {
|
||||
::std::cout <<"\n\x1B[38;5;75mtesting\x1B[0m " <<cmp <<"\n\n";
|
||||
|
||||
num = 0x0;
|
||||
};
|
||||
|
||||
auto const cmp = [&num,&numerr]<typename ltyp,typename rtyp>(ltyp const & lvalref,rtyp const & rvalref,::std::source_location const srcloc = ::std::source_location::current()) {
|
||||
char const * const ltypnm = typeid (ltyp).name();
|
||||
char const * const rtypnm = typeid (rtyp).name();
|
||||
|
||||
auto const getval = []<typename typ>(typ const & valref) {
|
||||
if constexpr (::zp::ischr<typ>::val) {return static_cast<::zp::i02m>(valref);}
|
||||
else if constexpr (::zp::isptr<typ>::val) {return reinterpret_cast<void *>(valref);}
|
||||
else {return valref;}
|
||||
};
|
||||
|
||||
auto const lval = getval(lvalref);
|
||||
auto const rval = getval(rvalref);
|
||||
|
||||
::std::cout <<" " <<num++ <<". comparing " <<ltypnm <<" (" <<lval <<") vs. " <<rtypnm <<" (" <<rval <<")... ";
|
||||
|
||||
if (lval != rval) {
|
||||
::std::cout <<"\x1B[38;5;161munequal\x1B[0m (at #" <<srcloc.line() <<")\n";
|
||||
//throw ::std::exception {};
|
||||
++numerr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
::std::cout <<"\x1B[38;5;77mequal\x1B[0m\n";
|
||||
};
|
||||
|
||||
::std::cout <<"zp " <<::zp::ver <<"." <<::zp::extver <<", run-time test\n";
|
||||
|
||||
try {
|
||||
/*[&] {
|
||||
tst("vectors");
|
||||
|
||||
::zp::vec2<int> const lvec2 = {
|
||||
.x = +0x1,
|
||||
.y = -0x3,
|
||||
};
|
||||
::zp::vec2<int> const rvec2 = {
|
||||
.x = +0x2,
|
||||
.y = -0x4,
|
||||
};
|
||||
cmp(::zp::dot(lvec2,rvec2),0xE);
|
||||
|
||||
::zp::vec3<int> const lvec3 = {
|
||||
.x = +0x1,
|
||||
.y = -0x3,
|
||||
.z = +0x5,
|
||||
};
|
||||
::zp::vec3<int> const rvec3 = {
|
||||
.x = +0x2,
|
||||
.y = -0x4,
|
||||
.z = +0x6,
|
||||
};
|
||||
cmp(::zp::dot(lvec3,rvec3),0x2C);
|
||||
|
||||
::zp::vec4<int> const lvec4 = {
|
||||
.x = +0x1,
|
||||
.y = -0x3,
|
||||
.z = +0x5,
|
||||
.w = -0x7,
|
||||
};
|
||||
::zp::vec4<int> const rvec4 = {
|
||||
.x = +0x2,
|
||||
.y = -0x4,
|
||||
.z = +0x6,
|
||||
.w = -0x8,
|
||||
};
|
||||
cmp(::zp::dot(lvec4,rvec4),0x64);
|
||||
|
||||
auto const avec2 = ::zp::vadd(lvec2,rvec2);
|
||||
auto const svec2 = ::zp::vsub(lvec2,rvec2);
|
||||
cmp(avec2.x,+0x3);
|
||||
cmp(avec2.y,-0x7);
|
||||
cmp(svec2.x,-0x1);
|
||||
cmp(svec2.y,+0x1);
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("special numbers");
|
||||
|
||||
cmp(zp_isnanf( zp_nanf), true);
|
||||
cmp(zp_isnand( zp_nand), true);
|
||||
cmp(zp_isnanld(zp_nanld),true);
|
||||
}();*/
|
||||
|
||||
[&] {
|
||||
tst("memory sequences");
|
||||
|
||||
::zp::i04 filbuf;
|
||||
|
||||
cmp(::zp::memfil(&filbuf,0xFFu,0x8u),reinterpret_cast<char unsigned *>(&filbuf)+0x8u);
|
||||
cmp(::zp::memfil(&filbuf,0x7Fu,0x4u),reinterpret_cast<char unsigned *>(&filbuf)+0x4u);
|
||||
cmp(::zp::memfil(&filbuf,0x3Fu,0x2u),reinterpret_cast<char unsigned *>(&filbuf)+0x2u);
|
||||
cmp(::zp::memfil(&filbuf,0x1Fu,0x1u),reinterpret_cast<char unsigned *>(&filbuf)+0x1u);
|
||||
|
||||
cmp(filbuf,0xFFFFFFFF7F7F3F1Fu);
|
||||
|
||||
::zp::i04 cpybuf;
|
||||
::zp::memcpy(&cpybuf,&filbuf,0x8u);
|
||||
|
||||
cmp(cpybuf,filbuf);
|
||||
|
||||
cmp(::zp::memsrh(&cpybuf,0x1Fu,0x8u),reinterpret_cast<char unsigned *>(&cpybuf));
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("strings");
|
||||
|
||||
char str[] = "Hello there!";
|
||||
wchar_t wstr[] = L"Hello there!";
|
||||
char32_t str02[] = U"Hello there!";
|
||||
|
||||
::zp::sz const len = ::zp_strlen( str);
|
||||
::zp::sz const wlen = ::zp_wstrlen( wstr);
|
||||
::zp::sz const len02 = ::zp_utf32len(str02);
|
||||
|
||||
cmp(len, 0xCu);
|
||||
cmp(wlen, 0xCu);
|
||||
cmp(len02,0xCu);
|
||||
|
||||
auto const buf = new char[ len];
|
||||
auto const wbuf = new wchar_t[ wlen];
|
||||
auto const buf02 = new char32_t[len02];
|
||||
|
||||
cmp(::zp_strcpy( buf, str), len);
|
||||
cmp(::zp_wstrcpy( wbuf, wstr), wlen);
|
||||
cmp(::zp_utf32cpy(buf02,str02),len02);
|
||||
|
||||
delete[] buf;
|
||||
delete[] wbuf;
|
||||
delete[] buf02;
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("UTF-8");
|
||||
|
||||
char32_t const src[] = U"\U0001F480";
|
||||
|
||||
::zp::sz const buf8len = ::zp_utf8enclen(src);
|
||||
cmp(buf8len,0x4u);
|
||||
|
||||
char8_t * buf8 = new char8_t[buf8len+0x1];
|
||||
|
||||
::zp_utf8enc(buf8,src);
|
||||
|
||||
cmp(buf8[0x0],0xF0u);
|
||||
cmp(buf8[0x1],0x9Fu);
|
||||
cmp(buf8[0x2],0x92u);
|
||||
cmp(buf8[0x3],0x80u);
|
||||
cmp(buf8[0x4],0x00u);
|
||||
|
||||
::zp::sz const buf02len = ::zp_utf8declen(buf8);
|
||||
cmp(buf02len,0x1u);
|
||||
|
||||
char32_t * buf02 = new char32_t[buf02len+0x1];
|
||||
|
||||
::zp_utf8dec(buf02,buf8);
|
||||
|
||||
cmp(buf02[0x0],0x1F480u);
|
||||
cmp(buf02[0x1],0x0u);
|
||||
|
||||
delete[] buf8;
|
||||
delete[] buf02;
|
||||
}();
|
||||
|
||||
[&] {
|
||||
tst("UTF-16");
|
||||
|
||||
char32_t const src[] = U"\U0001F480\u00F0";
|
||||
|
||||
::zp::sz const buf01len = ::zp_utf16enclen(src);
|
||||
cmp(buf01len,0x3u);
|
||||
|
||||
char16_t * buf01 = new char16_t[buf01len+0x1];
|
||||
|
||||
::zp_utf16enc(buf01,src);
|
||||
|
||||
cmp(buf01[0x0],0xD83Du);
|
||||
cmp(buf01[0x1],0xDC80u);
|
||||
cmp(buf01[0x2],0x00F0u);
|
||||
cmp(buf01[0x3],0x0000u);
|
||||
|
||||
::zp::sz const buf02len = ::zp_utf16declen(buf01);
|
||||
cmp(buf02len,0x2u);
|
||||
|
||||
char32_t * buf02 = new char32_t[buf02len+0x1];
|
||||
|
||||
::zp_utf16dec(buf02,buf01);
|
||||
|
||||
cmp(buf02[0x0],0x1F480u);
|
||||
cmp(buf02[0x1],0xF0u);
|
||||
cmp(buf02[0x2],0x0u);
|
||||
|
||||
delete[] buf01;
|
||||
delete[] buf02;
|
||||
}();
|
||||
}
|
||||
catch (::std::exception const &) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
::std::cout <<"\nDone \u2212 " <<numerr <<" error(s)\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
147
zp/GNUmakefile
147
zp/GNUmakefile
|
@ -17,11 +17,11 @@ AS := nasm -felf32
|
|||
endif
|
||||
|
||||
ifeq "$(stdc)" ""
|
||||
stdc := c99
|
||||
stdc := c90
|
||||
endif
|
||||
|
||||
ifeq "$(stdcxx)" ""
|
||||
stdcxx := c++11
|
||||
stdcxx := c++98
|
||||
endif
|
||||
|
||||
OBJ_BS_TRP := source/any/bs/trp.o
|
||||
|
@ -31,16 +31,17 @@ OBJ_MEM_MEMEQU := source/any/mem/memequ.o
|
|||
OBJ_MEM_MEMFIL := source/any/mem/memfil.o
|
||||
OBJ_MEM_MEMSRH := source/any/mem/memsrh.o
|
||||
|
||||
OBJ_MTH_ABS := source/any/mth/abs.o
|
||||
OBJ_MTH_DIVMOD := source/any/mth/divmod.o
|
||||
OBJ_MTH_DOT := source/any/mth/dot.o
|
||||
OBJ_MTH_VADD := source/any/mth/vadd.o
|
||||
OBJ_MTH_VSUB := source/any/mth/vsub.o
|
||||
#OBJ_MTH_ABS := source/any/mth/abs.o
|
||||
#OBJ_MTH_DIVMOD := source/any/mth/divmod.o
|
||||
#OBJ_MTH_DOT := source/any/mth/dot.o
|
||||
#OBJ_MTH_VADD := source/any/mth/vadd.o
|
||||
#OBJ_MTH_VSUB := source/any/mth/vsub.o
|
||||
|
||||
OBJ_STR_FMT := source/any/str/fmt.o
|
||||
OBJ_STR_FMTLEN := source/any/str/fmtlen.o
|
||||
OBJ_STR_STRCPY := source/any/str/strcpy.o
|
||||
OBJ_STR_STREQU := source/any/str/strequ.o
|
||||
OBJ_STR_STRFIL := source/any/str/strfil.o
|
||||
OBJ_STR_STRLEN := source/any/str/strlen.o
|
||||
OBJ_STR_STRSRH := source/any/str/strsrh.o
|
||||
OBJ_STR_UTF16DEC := source/any/str/utf16dec.o
|
||||
|
@ -49,6 +50,7 @@ OBJ_STR_UTF16ENC := source/any/str/utf16enc.o
|
|||
OBJ_STR_UTF16ENCLEN := source/any/str/utf16enclen.o
|
||||
OBJ_STR_UTF32CPY := source/any/str/utf32cpy.o
|
||||
OBJ_STR_UTF32EQU := source/any/str/utf32equ.o
|
||||
OBJ_STR_UTF32FIL := source/any/str/utf32fil.o
|
||||
OBJ_STR_UTF32LEN := source/any/str/utf32len.o
|
||||
OBJ_STR_UTF32SRH := source/any/str/utf32srh.o
|
||||
OBJ_STR_UTF8DEC := source/any/str/utf8dec.o
|
||||
|
@ -59,6 +61,7 @@ OBJ_STR_WIN1252DEC := source/any/str/win1252dec.o
|
|||
OBJ_STR_WIN1252ENC := source/any/str/win1252enc.o
|
||||
OBJ_STR_WSTRCPY := source/any/str/wstrcpy.o
|
||||
OBJ_STR_WSTREQU := source/any/str/wstrequ.o
|
||||
OBJ_STR_WSTRFIL := source/any/str/wstrfil.o
|
||||
OBJ_STR_WSTRLEN := source/any/str/wstrlen.o
|
||||
OBJ_STR_WSTRSRH := source/any/str/wstrsrh.o
|
||||
|
||||
|
@ -106,6 +109,7 @@ OBJS := \
|
|||
$(OBJ_STR_FMTLEN) \
|
||||
$(OBJ_STR_STRCPY) \
|
||||
$(OBJ_STR_STREQU) \
|
||||
$(OBJ_STR_STRFIL) \
|
||||
$(OBJ_STR_STRLEN) \
|
||||
$(OBJ_STR_STRSRH) \
|
||||
$(OBJ_STR_UTF16DEC) \
|
||||
|
@ -114,6 +118,7 @@ OBJS := \
|
|||
$(OBJ_STR_UTF16ENCLEN) \
|
||||
$(OBJ_STR_UTF32CPY) \
|
||||
$(OBJ_STR_UTF32EQU) \
|
||||
$(OBJ_STR_UTF32FIL) \
|
||||
$(OBJ_STR_UTF32LEN) \
|
||||
$(OBJ_STR_UTF32SRH) \
|
||||
$(OBJ_STR_UTF8DEC) \
|
||||
|
@ -124,6 +129,7 @@ OBJS := \
|
|||
$(OBJ_STR_WIN1252ENC) \
|
||||
$(OBJ_STR_WSTRCPY) \
|
||||
$(OBJ_STR_WSTREQU) \
|
||||
$(OBJ_STR_WSTRFIL) \
|
||||
$(OBJ_STR_WSTRLEN) \
|
||||
$(OBJ_STR_WSTRSRH)
|
||||
|
||||
|
@ -140,88 +146,83 @@ LIB := libzp.a
|
|||
endif
|
||||
|
||||
HDRS := \
|
||||
include/zp/bs \
|
||||
include/zp/bs.h \
|
||||
include/zp/mem \
|
||||
include/zp/mem.h \
|
||||
include/zp/mth \
|
||||
include/zp/mth.h \
|
||||
include/zp/str \
|
||||
include/zp/str.h \
|
||||
include/zp/bs.d/isconsteval.ii \
|
||||
include/zp/bs.d/syscl.ii \
|
||||
include/zp/bs.d/trp.ii \
|
||||
include/zp/bs.d/urch.ii \
|
||||
include/zp/mem.d/cpy.ii \
|
||||
include/zp/mem.d/equ.ii \
|
||||
include/zp/mem.d/fil.ii \
|
||||
include/zp/mem.d/memcpy.ii \
|
||||
include/zp/mem.d/memequ.ii \
|
||||
include/zp/mem.d/memfil.ii \
|
||||
include/zp/mem.d/memsrh.ii \
|
||||
include/zp/mem.d/srh.ii \
|
||||
include/zp/mth.d/abs.ii \
|
||||
include/zp/mth.d/dist.ii \
|
||||
include/zp/mth.d/divmod.ii \
|
||||
include/zp/mth.d/dot.ii \
|
||||
include/zp/mth.d/exp.ii \
|
||||
include/zp/mth.d/isnan.ii \
|
||||
include/zp/mth.d/vadd.ii \
|
||||
include/zp/mth.d/vsub.ii \
|
||||
include/zp/mth.d/pair/cpair.ii \
|
||||
include/zp/mth.d/vec2/cvec.ii \
|
||||
include/zp/mth.d/vec3/cvec.ii \
|
||||
include/zp/mth.d/vec4/cvec.ii \
|
||||
include/zp/prv/arc.h \
|
||||
include/zp/prv/chr.h \
|
||||
include/zp/prv/flt.h \
|
||||
include/zp/prv/imp.h \
|
||||
include/zp/prv/int.h \
|
||||
include/zp/prv/std.h \
|
||||
include/zp/prv/sys.h \
|
||||
include/zp/str.d/fmt.ii \
|
||||
include/zp/str.d/fmtlen.ii \
|
||||
include/zp/str.d/numdig.ii \
|
||||
include/zp/str.d/strcpy.ii \
|
||||
include/zp/str.d/strequ.ii \
|
||||
include/zp/str.d/strlen.ii \
|
||||
include/zp/str.d/strsrh.ii \
|
||||
include/zp/str.d/utf16dec.ii \
|
||||
include/zp/str.d/utf16declen.ii \
|
||||
include/zp/str.d/utf16enc.ii \
|
||||
include/zp/str.d/utf16enclen.ii \
|
||||
include/zp/str.d/utf8dec.ii \
|
||||
include/zp/str.d/utf8declen.ii \
|
||||
include/zp/str.d/utf8enc.ii \
|
||||
include/zp/str.d/utf8enclen.ii \
|
||||
include/zp/str.d/win1252dec.ii \
|
||||
include/zp/str.d/win1252enc.ii
|
||||
include/zp/bs \
|
||||
include/zp/bs.h \
|
||||
include/zp/mem \
|
||||
include/zp/mem.h \
|
||||
include/zp/mth \
|
||||
include/zp/mth.h \
|
||||
include/zp/str \
|
||||
include/zp/str.h \
|
||||
include/zp/bs.d/isconsteval.ii \
|
||||
include/zp/mem.d/cpy.ii \
|
||||
include/zp/mem.d/equ.ii \
|
||||
include/zp/mem.d/fil.ii \
|
||||
include/zp/mem.d/memcpy.ii \
|
||||
include/zp/mem.d/srh.ii \
|
||||
include/zp/prv/arc.h \
|
||||
include/zp/prv/chr.h \
|
||||
include/zp/prv/flt.h \
|
||||
include/zp/prv/imp.h \
|
||||
include/zp/prv/int.h \
|
||||
include/zp/prv/std.h \
|
||||
include/zp/prv/sys.h \
|
||||
include/zp/str.d/fmt.ii \
|
||||
include/zp/str.d/fmtlen.ii \
|
||||
include/zp/str.d/numdig.ii \
|
||||
include-private/zp/prv.d/strcpy.ii \
|
||||
include-private/zp/prv.d/strequ.ii \
|
||||
include-private/zp/prv.d/strfil.ii \
|
||||
include-private/zp/prv.d/strlen.ii \
|
||||
include-private/zp/prv.d/strsrh.ii
|
||||
|
||||
CXXFLAGS := \
|
||||
-Dzp_prv_nconsteval \
|
||||
CFLAGS := \
|
||||
-Iinclude \
|
||||
-Oz \
|
||||
-Iinclude-private \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-ffreestanding \
|
||||
-fno-exceptions \
|
||||
-fshort-enums \
|
||||
-nostdlib \
|
||||
-pipe \
|
||||
-std=$(stdc)
|
||||
|
||||
CXXFLAGS := \
|
||||
-Iinclude \
|
||||
-Iinclude-private \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-ffreestanding \
|
||||
-fno-exceptions \
|
||||
-fshort-enums \
|
||||
-nostdlib \
|
||||
-pipe \
|
||||
-std=$(stdcxx)
|
||||
|
||||
ifeq "$(shrlib)" "true"
|
||||
CFLAGS := \
|
||||
$(CFLAGS) \
|
||||
-Ofast \
|
||||
-g
|
||||
|
||||
CXXFLAGS := \
|
||||
$(CXXFLAGS) \
|
||||
-Ofast \
|
||||
-g
|
||||
|
||||
LDFLAGS := \
|
||||
$(LDFLAGS) \
|
||||
-shared
|
||||
else
|
||||
CFLAGS := \
|
||||
$(CFLAGS) \
|
||||
-Oz
|
||||
|
||||
CXXFLAGS := \
|
||||
$(CXXFLAGS) \
|
||||
-Oz
|
||||
endif
|
||||
|
||||
.PHONY: clean install purge
|
||||
|
@ -239,18 +240,12 @@ $(OBJS): $(HDRS)
|
|||
install: $(LIB)
|
||||
mkdir -pvm755 "$(HDRDIR)/zp/priv"
|
||||
mkdir -pvm755 "$(HDRDIR)/zp/"{"bs","mem","str"}".d"
|
||||
mkdir -pvm755 "$(HDRDIR)/zp/mth.d/"{"pair","vec2","vec3","vec4"}
|
||||
mkdir -pvm755 "$(LIBDIR)"
|
||||
install -vm644 "include/zp/"{"bs","mem","mth","str"}{"",".h"} "$(HDRDIR)/zp"
|
||||
install -vm644 "include/zp/prv/"{"arc","chr","flt","imp","int","std","sys"}".h" "$(HDRDIR)/zp/priv"
|
||||
install -vm644 "include/zp/bs.d/"{"isconsteval","syscl","trp","urch"}".ii" "$(HDRDIR)/zp/bs.d"
|
||||
install -vm644 "include/zp/mem.d/"{"cpy","equ","fil","memcpy","memequ","memfil","memsrh","srh"}".ii" "$(HDRDIR)/zp/mem.d"
|
||||
install -vm644 "include/zp/mth.d/"{"abs","dist","divmod","dot","exp","isnan","vadd","vsub"}".ii" "$(HDRDIR)/zp/mth.d"
|
||||
install -vm644 "include/zp/mth.d/pair/cpair.ii" "$(HDRDIR)/zp/mth.d/pair"
|
||||
install -vm644 "include/zp/mth.d/vec2/cvec.ii" "$(HDRDIR)/zp/mth.d/vec2"
|
||||
install -vm644 "include/zp/mth.d/vec3/cvec.ii" "$(HDRDIR)/zp/mth.d/vec3"
|
||||
install -vm644 "include/zp/mth.d/vec4/cvec.ii" "$(HDRDIR)/zp/mth.d/vec4"
|
||||
install -vm644 "include/zp/str.d/"{"fmt","fmtlen","numdig","strcpy","strequ","strlen","strsrh","utf16dec","utf16declen","utf16enc","utf16enclen","utf8dec","utf8declen","utf8enc","utf8enclen","win1252dec","win1252enc"}".ii" "$(HDRDIR)/zp/str.d"
|
||||
install -vm644 "include/zp/bs.d/"isconsteval".ii" "$(HDRDIR)/zp/bs.d"
|
||||
install -vm644 "include/zp/mem.d/"{"cpy","equ","fil","memcpy","srh"}".ii" "$(HDRDIR)/zp/mem.d"
|
||||
install -vm644 "include/zp/str.d/numdig.ii" "$(HDRDIR)/zp/str.d"
|
||||
install -vm755 "$(LIB)" "$(LIBDIR)"
|
||||
|
||||
clean:
|
||||
|
|
29
zp/include-private/zp/prv
Normal file
29
zp/include-private/zp/prv
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#ifndef zp_prv_cxxhdr_prv
|
||||
#define zp_prv_cxxhdr_prv
|
||||
|
||||
#include <zp/bs>
|
||||
#include <zp/prv.h>
|
||||
|
||||
namespace zp {
|
||||
namespace det {
|
||||
template<typename typ> zp_nthrw ::zp::sz strcpy(typ * dst, typ const * src);
|
||||
template<typename typ> zp_nthrw bool strequ(typ const * lstr,typ const * rsrc);
|
||||
template<typename typ> zp_nthrw ::zp::sz strfil(typ * dst, typ chr);
|
||||
template<typename typ> zp_nthrw ::zp::sz strlen(typ const * str);
|
||||
template<typename typ> zp_nthrw typ * strsrh(typ const * str, typ chr);
|
||||
}
|
||||
}
|
||||
|
||||
#include <zp/prv.d/strcpy.ii>
|
||||
#include <zp/prv.d/strequ.ii>
|
||||
#include <zp/prv.d/strfil.ii>
|
||||
#include <zp/prv.d/strlen.ii>
|
||||
#include <zp/prv.d/strsrh.ii>
|
||||
|
||||
#endif
|
15
zp/include-private/zp/prv.d/strcpy.ii
Normal file
15
zp/include-private/zp/prv.d/strcpy.ii
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_nthrw ::zp::sz zp::det::strcpy(typ * dst,typ const * src) {
|
||||
//static_assert(::zp::ischr<typ>::val,"type must be a character type");
|
||||
|
||||
typ * const dstsrt = dst;
|
||||
|
||||
while (*src != typ (0x0)) {*dst++ = *src++;}
|
||||
|
||||
return static_cast< ::zp::sz>(dst-dstsrt); /* Number of values copied. */
|
||||
}
|
|
@ -4,12 +4,12 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::strequ(typ const * lstr,typ const * rstr) zp_prv_nthrw -> bool {
|
||||
static_assert(::zp::ischr<typ>::val,"type must be a character type");
|
||||
template<typename typ> zp_nthrw bool zp::det::strequ(typ const * lstr,typ const * rstr) {
|
||||
//static_assert(::zp::ischr<typ>::val,"type must be a character type");
|
||||
|
||||
for (;;++lstr,++rstr) {
|
||||
zp_lik (*lstr != *rstr) {return false;}
|
||||
zp_ulik (*lstr == typ {0x0}) {break;}
|
||||
zp_ulik (*lstr == typ (0x0)) {break;}
|
||||
}
|
||||
|
||||
return true;
|
15
zp/include-private/zp/prv.d/strfil.ii
Normal file
15
zp/include-private/zp/prv.d/strfil.ii
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_nthrw ::zp::sz zp::det::strfil(typ * str,typ const chr) {
|
||||
//static_assert(::zp::ischr<typ>::val,"type must be a character type"); /* If the string format uses multiple values per character, the number of these values is returned (use utfXdeclen if the number of characters is needed). */
|
||||
|
||||
typ * const srt = str;
|
||||
|
||||
while (*str != typ (0x0)) {*str++ = chr;}
|
||||
|
||||
return static_cast< ::zp::sz>(str-srt)-0x1u;
|
||||
}
|
15
zp/include-private/zp/prv.d/strlen.ii
Normal file
15
zp/include-private/zp/prv.d/strlen.ii
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_nthrw ::zp::sz zp::det::strlen(typ const * str) {
|
||||
//static_assert(::zp::ischr<typ>::val,"type must be a character type"); /* If the string format uses multiple values per character, the number of these values is returned (use utfXdeclen if the number of characters is needed). */
|
||||
|
||||
typ const * const srt = str;
|
||||
|
||||
while (*str++ != typ (0x0)) {}
|
||||
|
||||
return static_cast< ::zp::sz>(str-srt)-0x1u;
|
||||
}
|
18
zp/include-private/zp/prv.d/strsrh.ii
Normal file
18
zp/include-private/zp/prv.d/strsrh.ii
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_nthrw typ * zp::det::strsrh(typ const * str,typ const chr) {
|
||||
//static_assert(::zp::ischr<typ>::val,"type must be a character type");
|
||||
|
||||
for (;;++str) {
|
||||
typ const curchr = *str;
|
||||
|
||||
zp_ulik (curchr == chr) {return const_cast<typ *>(str);}
|
||||
zp_ulik (curchr == typ (0x0)) {break;}
|
||||
}
|
||||
|
||||
return zp_nulptr;
|
||||
}
|
|
@ -4,6 +4,13 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
inline auto ::zp::trp() zp_prv_nthrw -> void {
|
||||
::zp_trp();
|
||||
}
|
||||
#ifndef zp_prv_hdr_prv
|
||||
#define zp_prv_hdr_prv
|
||||
|
||||
#include <zp/bs.h>
|
||||
|
||||
zp_prv_cdecl
|
||||
|
||||
zp_prv_cdeclend
|
||||
|
||||
#endif
|
325
zp/include/zp/bs
325
zp/include/zp/bs
|
@ -8,298 +8,315 @@
|
|||
#define zp_prv_cxxhdr_bs
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error C++ header included from C!
|
||||
#error C++ header included from C
|
||||
#endif
|
||||
|
||||
#include <zp/bs.h>
|
||||
|
||||
#if zp_std_cxx14 // C++11 doesn't support void as a return type for translation-time functions.
|
||||
#define zp_prv_constexpr constexpr
|
||||
#elif zp_std_cxx
|
||||
#define zp_prv_constexpr inline
|
||||
#endif
|
||||
|
||||
#if zp_std_cxx11
|
||||
#define zp_prv_nthrw noexcept
|
||||
#elif zp_std_cxx
|
||||
#define zp_prv_nthrw
|
||||
#define zp_prv_ttval(typ) constexpr static typ
|
||||
#else
|
||||
#define zp_prv_ttval(typ) static typ const
|
||||
#endif
|
||||
|
||||
namespace zp {
|
||||
using i8m = ::zp_i8m;
|
||||
using i8ms = ::zp_i8ms;
|
||||
typedef ::zp_i8m i8m;
|
||||
typedef ::zp_i8ms i8ms;
|
||||
|
||||
using i01m = ::zp_i01m;
|
||||
using i01ms = ::zp_i01ms;
|
||||
typedef ::zp_i01m i01m;
|
||||
typedef ::zp_i01ms i01ms;
|
||||
|
||||
using i02m = ::zp_i02m;
|
||||
using i02ms = ::zp_i02ms;
|
||||
typedef ::zp_i02m i02m;
|
||||
typedef ::zp_i02ms i02ms;
|
||||
|
||||
using i04m = ::zp_i04m;
|
||||
using i04ms = ::zp_i04ms;
|
||||
typedef ::zp_i04m i04m;
|
||||
typedef ::zp_i04ms i04ms;
|
||||
|
||||
#if zp_fixint8
|
||||
using i8 = ::zp_i8;
|
||||
using i8s = ::zp_i8s;
|
||||
typedef ::zp_i8 i8;
|
||||
typedef ::zp_i8s i8s;
|
||||
#endif
|
||||
#if zp_fixint01
|
||||
using i01 = ::zp_i01;
|
||||
using i01s = ::zp_i01s;
|
||||
typedef ::zp_i01 i01;
|
||||
typedef ::zp_i01s i01s;
|
||||
#endif
|
||||
#if zp_fixint02
|
||||
using i02 = ::zp_i02;
|
||||
using i02s = ::zp_i02s;
|
||||
typedef ::zp_i02 i02;
|
||||
typedef ::zp_i02s i02s;
|
||||
#endif
|
||||
#if zp_fixint04
|
||||
using i04 = ::zp_i04;
|
||||
using i04s = ::zp_i04s;
|
||||
typedef ::zp_i04 i04;
|
||||
typedef ::zp_i04s i04s;
|
||||
#endif
|
||||
#if zp_fixint08
|
||||
using i08 = ::zp_i08;
|
||||
using i08s = ::zp_i08s;
|
||||
typedef ::zp_i08 i08;
|
||||
typedef ::zp_i08s i08s;
|
||||
#endif
|
||||
#if zp_fixint08
|
||||
using i08 = ::zp_i08;
|
||||
using i08s = ::zp_i08s;
|
||||
typedef ::zp_i08 i08;
|
||||
typedef ::zp_i08s i08s;
|
||||
#endif
|
||||
|
||||
using intptr = ::zp_intptr;
|
||||
using sz = ::zp_sz;
|
||||
typedef ::zp_intptr intptr;
|
||||
typedef ::zp_sz sz;
|
||||
|
||||
#if zp_fixflt01
|
||||
using f01 = ::zp_f01;
|
||||
typedef ::zp_f01 f01;
|
||||
#endif
|
||||
#if zp_fixflt02
|
||||
using f02 = ::zp_f02;
|
||||
typedef ::zp_f02 f02;
|
||||
#endif
|
||||
#if zp_fixflt04
|
||||
using f04 = ::zp_f04;
|
||||
typedef ::zp_f04 f04;
|
||||
#endif
|
||||
#if zp_fixflt08
|
||||
using f08 = ::zp_f08;
|
||||
typedef ::zp_f08 f08;
|
||||
#endif
|
||||
|
||||
using wchr = ::zp_wchr;
|
||||
using c8 = ::zp_c8;
|
||||
using c01 = ::zp_c01;
|
||||
using c02 = ::zp_c02;
|
||||
typedef ::zp_wchr wchr;
|
||||
typedef ::zp_c8 c8;
|
||||
typedef ::zp_c01 c01;
|
||||
typedef ::zp_c02 c02;
|
||||
|
||||
using sysclid = ::zp_sysclid;
|
||||
using sysclres = ::zp_sysclres;
|
||||
typedef ::zp_sysclid sysclid;
|
||||
typedef ::zp_sysclres sysclres;
|
||||
|
||||
#if zp_std_cxx11
|
||||
using nulptrtyp = ::zp_nulptrtyp;
|
||||
#endif
|
||||
|
||||
template<typename typ> struct minval {constexpr static typ val = {};};
|
||||
#if zp_std_cxx11
|
||||
template<typename typ> struct minval {constexpr static auto val = {};};
|
||||
|
||||
template<> struct minval<bool> {constexpr static auto val = false;};
|
||||
template<> struct minval<char> {constexpr static auto val = zp_minvalc;};
|
||||
template<> struct minval<char16_t> {constexpr static auto val = zp_minvalc01;};
|
||||
template<> struct minval<char32_t> {constexpr static auto val = zp_minvalc02;};
|
||||
template<> struct minval<double> {constexpr static auto val = zp_minvald;};
|
||||
template<> struct minval<float> {constexpr static auto val = zp_minvalf;};
|
||||
template<> struct minval<int> {constexpr static auto val = zp_minvali;};
|
||||
template<> struct minval<long> {constexpr static auto val = zp_minvall;};
|
||||
template<> struct minval<long double> {constexpr static auto val = zp_minvalld;};
|
||||
template<> struct minval<long long> {constexpr static auto val = zp_minvalll;};
|
||||
template<> struct minval<short> {constexpr static auto val = zp_minvals;};
|
||||
template<> struct minval<char signed> {constexpr static auto val = zp_minvalcs;};
|
||||
template<> struct minval<char unsigned> {constexpr static auto val = zp_minvalcu;};
|
||||
template<> struct minval<int unsigned> {constexpr static auto val = zp_minvaliu;};
|
||||
template<> struct minval<long unsigned> {constexpr static auto val = zp_minvallu;};
|
||||
template<> struct minval<long long unsigned> {constexpr static auto val = zp_minvalllu;};
|
||||
template<> struct minval<short unsigned> {constexpr static auto val = zp_minvalsu;};
|
||||
template<> struct minval<wchar_t> {constexpr static auto val = zp_minvalw;};
|
||||
#if __cpp_char8_t >= 201811
|
||||
template<> struct minval<char8_t> {constexpr static auto val = zp_minvalc8;};
|
||||
#endif
|
||||
#if zp_std_cxx11
|
||||
template<> struct minval<char16_t> {constexpr static auto val = zp_minvalc01;};
|
||||
template<> struct minval<char32_t> {constexpr static auto val = zp_minvalc02;};
|
||||
template<> struct minval<long long> {constexpr static auto val = zp_minvalll;};
|
||||
template<> struct minval<long long unsigned> {constexpr static auto val = zp_minvalllu;};
|
||||
#endif
|
||||
|
||||
template<typename typ> struct maxval {constexpr static typ val = {};};
|
||||
template<typename typ> struct maxval {constexpr static auto val = {};};
|
||||
|
||||
template<> struct maxval<bool> {constexpr static auto val = true;};
|
||||
template<> struct maxval<char> {constexpr static auto val = zp_maxvalc;};
|
||||
template<> struct maxval<char16_t> {constexpr static auto val = zp_maxvalc01;};
|
||||
template<> struct maxval<char32_t> {constexpr static auto val = zp_maxvalc02;};
|
||||
template<> struct maxval<double> {constexpr static auto val = zp_maxvald;};
|
||||
template<> struct maxval<float> {constexpr static auto val = zp_maxvalf;};
|
||||
template<> struct maxval<int> {constexpr static auto val = zp_maxvali;};
|
||||
template<> struct maxval<long> {constexpr static auto val = zp_maxvall;};
|
||||
template<> struct maxval<long double> {constexpr static auto val = zp_maxvalld;};
|
||||
template<> struct maxval<long long> {constexpr static auto val = zp_maxvalll;};
|
||||
template<> struct maxval<short> {constexpr static auto val = zp_maxvals;};
|
||||
template<> struct maxval<char signed> {constexpr static auto val = zp_maxvalcs;};
|
||||
template<> struct maxval<char unsigned> {constexpr static auto val = zp_maxvalcu;};
|
||||
template<> struct maxval<int unsigned> {constexpr static auto val = zp_maxvaliu;};
|
||||
template<> struct maxval<long unsigned> {constexpr static auto val = zp_maxvallu;};
|
||||
template<> struct maxval<long long unsigned> {constexpr static auto val = zp_maxvalllu;};
|
||||
template<> struct maxval<short unsigned> {constexpr static auto val = zp_maxvalsu;};
|
||||
template<> struct maxval<wchar_t> {constexpr static auto val = zp_maxvalw;};
|
||||
#if __cpp_char8_t >= 201811
|
||||
template<> struct maxval<char8_t> {constexpr static auto val = zp_maxvalc8;};
|
||||
#endif
|
||||
#if zp_std_cxx11
|
||||
template<> struct maxval<char16_t> {constexpr static auto val = zp_maxvalc01;};
|
||||
template<> struct maxval<char32_t> {constexpr static auto val = zp_maxvalc02;};
|
||||
template<> struct maxval<long long> {constexpr static auto val = zp_maxvalll;};
|
||||
template<> struct maxval<long long unsigned> {constexpr static auto val = zp_maxvalllu;};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template<typename ityp> struct sgn {using typ = ityp;};
|
||||
template<typename ityp> struct sgn {typedef ityp typ;};
|
||||
|
||||
template<> struct sgn<char unsigned> {using typ = char signed;};
|
||||
template<> struct sgn<int unsigned> {using typ = int;};
|
||||
template<> struct sgn<long unsigned> {using typ = long;};
|
||||
template<> struct sgn<long long unsigned> {using typ = long long;};
|
||||
template<> struct sgn<short unsigned> {using typ = short;};
|
||||
template<> struct sgn<char unsigned> {typedef char signed typ;};
|
||||
template<> struct sgn<int unsigned> {typedef int typ;};
|
||||
template<> struct sgn<long unsigned> {typedef long typ;};
|
||||
template<> struct sgn<short unsigned> {typedef short typ;};
|
||||
#if zp_std_cxx11
|
||||
template<> struct sgn<long long unsigned> {typedef long long typ;};
|
||||
#endif
|
||||
|
||||
template<typename ityp> struct usgn {using typ = ityp;};
|
||||
template<typename ityp> struct usgn {typedef ityp typ;};
|
||||
|
||||
template<> struct usgn<char signed> {using typ = char unsigned;};
|
||||
template<> struct usgn<int> {using typ = int unsigned;};
|
||||
template<> struct usgn<long> {using typ = long unsigned;};
|
||||
template<> struct usgn<long long> {using typ = long long unsigned;};
|
||||
template<> struct usgn<short> {using typ = short unsigned;};
|
||||
template<> struct usgn<char signed> {typedef char unsigned typ;};
|
||||
template<> struct usgn<int> {typedef int unsigned typ;};
|
||||
template<> struct usgn<long> {typedef long unsigned typ;};
|
||||
template<> struct usgn<short> {typedef short unsigned typ;};
|
||||
#if zp_std_cxx11
|
||||
template<> struct usgn<long long> {typedef long long unsigned typ;};
|
||||
#endif
|
||||
|
||||
template<typename ityp> struct remqual {using typ = ityp;};
|
||||
template<typename ityp> struct remqual {typedef ityp typ;};
|
||||
|
||||
template<typename ityp> struct remqual<ityp const> {using typ = ityp;};
|
||||
template<typename ityp> struct remqual<ityp volatile> {using typ = ityp;};
|
||||
template<typename ityp> struct remqual<ityp const volatile> {using typ = ityp;};
|
||||
template<typename ityp> struct remqual<ityp const> {typedef ityp typ;};
|
||||
template<typename ityp> struct remqual<ityp volatile> {typedef ityp typ;};
|
||||
template<typename ityp> struct remqual<ityp const volatile> {typedef ityp typ;};
|
||||
|
||||
template<typename ltyp,typename rtyp> struct typequ {constexpr static bool val = false;};
|
||||
template<typename ltyp,typename rtyp> struct typequ {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<typename typ> struct typequ<typ,typ> {constexpr static auto val = true;};
|
||||
template<typename typ> struct typequ<typ,typ> {zp_prv_ttval(bool) val = true;};
|
||||
|
||||
template<typename typ> struct isptr {constexpr static bool val = false;};
|
||||
template<typename typ> struct isptr {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<typename typ> struct isptr<typ *> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const *> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ volatile *> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile *> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ * const> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const * const> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ volatile * const> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile * const> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ * volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const * volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ volatile * volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile * volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ * const volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const * const volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ volatile * const volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile * const volatile> {constexpr static auto val = true;};
|
||||
template<typename typ> struct isptr<typ *> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const *> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ volatile *> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile *> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ * const> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const * const> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ volatile * const> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile * const> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ * volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const * volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ volatile * volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile * volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ * const volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const * const volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ volatile * const volatile> {zp_prv_ttval(bool) val = true;};
|
||||
template<typename typ> struct isptr<typ const volatile * const volatile> {zp_prv_ttval(bool) val = true;};
|
||||
|
||||
template<typename typ> struct isusgn {constexpr static bool val = false;};
|
||||
template<typename typ> struct isusgn {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<> struct isusgn<char16_t> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<char32_t> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<char unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<int unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<long unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<long long unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<short unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<char unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isusgn<int unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isusgn<long unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isusgn<short unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
#if __cpp_char8_t >= 201811
|
||||
template<> struct isusgn<char8_t> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<char8_t> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if zp_std_cxx11
|
||||
template<> struct isusgn<char16_t> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isusgn<char32_t> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isusgn<long long unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if zp_uchr
|
||||
template<> struct isusgn<char> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<char> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if zp_uwchr
|
||||
template<> struct isusgn<wchar_t> {constexpr static auto val = true;};
|
||||
template<> struct isusgn<wchar_t> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
|
||||
template<typename typ> struct issgn {constexpr static bool val = false;};
|
||||
template<typename typ> struct issgn {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<> struct issgn<double> {constexpr static auto val = true;};
|
||||
template<> struct issgn<float> {constexpr static auto val = true;};
|
||||
template<> struct issgn<int> {constexpr static auto val = true;};
|
||||
template<> struct issgn<long> {constexpr static auto val = true;};
|
||||
template<> struct issgn<long double> {constexpr static auto val = true;};
|
||||
template<> struct issgn<long long> {constexpr static auto val = true;};
|
||||
template<> struct issgn<short> {constexpr static auto val = true;};
|
||||
template<> struct issgn<char signed> {constexpr static auto val = true;};
|
||||
template<> struct issgn<double> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct issgn<float> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct issgn<int> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct issgn<long> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct issgn<long double> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct issgn<short> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct issgn<char signed> {zp_prv_ttval(bool) val = true;};
|
||||
#if __STDCPP_BFLOAT16_T__
|
||||
template<> struct issgn<decltype (0.0bf16)> {constexpr static auto val = true;};
|
||||
template<> struct issgn<decltype (0.0bf16)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT128_T__
|
||||
template<> struct issgn<decltype (0.0f128)> {constexpr static auto val = true;};
|
||||
template<> struct issgn<decltype (0.0f128)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT16_T__
|
||||
template<> struct issgn<decltype (0.0f16)> {constexpr static auto val = true;};
|
||||
template<> struct issgn<decltype (0.0f16)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT32_T__
|
||||
template<> struct issgn<decltype (0.0f32)> {constexpr static auto val = true;};
|
||||
template<> struct issgn<decltype (0.0f32)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT64_T__
|
||||
template<> struct issgn<decltype (0.0f64)> {constexpr static auto val = true;};
|
||||
template<> struct issgn<decltype (0.0f64)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if zp_std_cxx11
|
||||
template<> struct issgn<long long> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if !zp_uchr
|
||||
template<> struct issgn<char> {constexpr static auto val = true;};
|
||||
template<> struct issgn<char> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if !zp_uwchr
|
||||
template<> struct issgn<wchar_t> {constexpr static auto val = true;};
|
||||
template<> struct issgn<wchar_t> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
|
||||
template<typename typ> struct isflt {constexpr static bool val = false;};
|
||||
template<typename typ> struct isflt {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<> struct isflt<double> {constexpr static auto val = true;};
|
||||
template<> struct isflt<float> {constexpr static auto val = true;};
|
||||
template<> struct isflt<long double> {constexpr static auto val = true;};
|
||||
template<> struct isflt<double> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isflt<float> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isflt<long double> {zp_prv_ttval(bool) val = true;};
|
||||
#if __STDCPP_BFLOAT16_T__
|
||||
template<> struct isflt<decltype (0.0bf16)> {constexpr static auto val = true;};
|
||||
template<> struct isflt<decltype (0.0bf16)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT128_T__
|
||||
template<> struct isflt<decltype (0.0f128)> {constexpr static auto val = true;};
|
||||
template<> struct isflt<decltype (0.0f128)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT16_T__
|
||||
template<> struct isflt<decltype (0.0f16)> {constexpr static auto val = true;};
|
||||
template<> struct isflt<decltype (0.0f16)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT32_T__
|
||||
template<> struct isflt<decltype (0.0f32)> {constexpr static auto val = true;};
|
||||
template<> struct isflt<decltype (0.0f32)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if __STDCPP_FLOAT64_T__
|
||||
template<> struct isflt<decltype (0.0f64)> {constexpr static auto val = true;};
|
||||
template<> struct isflt<decltype (0.0f64)> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
|
||||
template<typename typ> struct isint {constexpr static bool val = false;};
|
||||
template<typename typ> struct isint {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<> struct isint<int> {constexpr static auto val = true;};
|
||||
template<> struct isint<long> {constexpr static auto val = true;};
|
||||
template<> struct isint<long long> {constexpr static auto val = true;};
|
||||
template<> struct isint<short> {constexpr static auto val = true;};
|
||||
template<> struct isint<char signed> {constexpr static auto val = true;};
|
||||
template<> struct isint<char unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isint<int unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isint<long unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isint<long long unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isint<short unsigned> {constexpr static auto val = true;};
|
||||
template<> struct isint<int> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<long> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<short> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<char signed> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<char unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<int unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<long unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<short unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
#if zp_std_cxx11
|
||||
template<> struct isint<long long> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct isint<long long unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
|
||||
template<typename typ> struct isari {constexpr static bool val = ::zp::isflt<typ>::val || ::zp::isint<typ>::val;};
|
||||
template<typename typ> struct isari {zp_prv_ttval(bool) val = ::zp::isflt<typ>::val || ::zp::isint<typ>::val;};
|
||||
|
||||
template<typename typ> struct ischr {constexpr static bool val = false;};
|
||||
template<typename typ> struct ischr {zp_prv_ttval(bool) val = false;};
|
||||
|
||||
template<> struct ischr<char> {constexpr static auto val = true;};
|
||||
template<> struct ischr<char unsigned> {constexpr static auto val = true;};
|
||||
template<> struct ischr<char16_t> {constexpr static auto val = true;};
|
||||
template<> struct ischr<char32_t> {constexpr static auto val = true;};
|
||||
template<> struct ischr<wchar_t> {constexpr static auto val = true;};
|
||||
template<> struct ischr<char> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct ischr<char unsigned> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct ischr<wchar_t> {zp_prv_ttval(bool) val = true;};
|
||||
#if __cpp_char8_t >= 201811
|
||||
template<> struct ischr<char8_t> {constexpr static auto val = true;};
|
||||
template<> struct ischr<char8_t> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
#if zp_std_cxx11
|
||||
template<> struct ischr<char16_t> {zp_prv_ttval(bool) val = true;};
|
||||
template<> struct ischr<char32_t> {zp_prv_ttval(bool) val = true;};
|
||||
#endif
|
||||
|
||||
constexpr auto ver = zp_ver;
|
||||
constexpr auto extver = zp_extver;
|
||||
zp_prv_ttval(::zp::i04m) ver = zp_ver;
|
||||
zp_prv_ttval(::zp::i04m) extver = zp_extver;
|
||||
|
||||
constexpr auto bytelen = zp_bytelen;
|
||||
zp_prv_ttval(::zp::sz) bytelen = zp_bytelen;
|
||||
|
||||
constexpr auto nopos = zp_nopos;
|
||||
zp_prv_ttval(::zp::sz) nopos = zp_nopos;
|
||||
|
||||
constexpr auto unimax = zp_unimax;
|
||||
zp_prv_ttval(::zp::c02) unimax = zp_unimax;
|
||||
|
||||
zp_iln constexpr auto isconsteval() zp_prv_nthrw -> bool;
|
||||
#if zp_std_cxx11
|
||||
zp_iln constexpr auto isconsteval() noexcept -> bool;
|
||||
#endif
|
||||
|
||||
[[noreturn]] zp_iln inline auto trp() zp_prv_nthrw -> void;
|
||||
[[noreturn]] zp_iln inline auto urch() zp_prv_nthrw -> void;
|
||||
zp_iln zp_nret zp_nthrw inline void trp() {::zp_trp();}
|
||||
zp_iln zp_nret zp_nthrw inline void urch() {zp_urch();}
|
||||
|
||||
template<typename... typs> zp_iln inline auto syscl(::zp::sysclid id,typs const &... args) zp_prv_nthrw -> ::zp::sysclres;
|
||||
#if zp_std_cxx11
|
||||
template<typename... typs> zp_iln inline auto syscl(::zp::sysclid id,typs const &... args) noexcept -> ::zp::sysclres {return ::zp_syscl(id,args...);}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if zp_std_cxx11
|
||||
#include <zp/bs.d/isconsteval.ii>
|
||||
#include <zp/bs.d/syscl.ii>
|
||||
#include <zp/bs.d/trp.ii>
|
||||
#include <zp/bs.d/urch.ii>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
constexpr auto ::zp::isconsteval() zp_prv_nthrw -> bool {
|
||||
#if zp_prv_hasbuiltin(__builtin_is_constant_evaluated)
|
||||
constexpr auto zp::isconsteval() noexcept -> bool {
|
||||
#if zp_prv_hasbltin(__builtin_is_constant_evaluated)
|
||||
return __builtin_is_constant_evaluated();
|
||||
#elif __cpp_if_consteval >= 202106
|
||||
if consteval {return true;}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
// All identifiers in the "priv" namespaces are,
|
||||
// well, private, and may not be used by any
|
||||
// program (causes UB or something).
|
||||
/* All identifiers in the "priv" namespaces are, */
|
||||
/* well, private, and may not be used by any */
|
||||
/* program (causes UB or something). */
|
||||
|
||||
/*
|
||||
Greater Header Dependencies:
|
||||
|
@ -19,8 +19,6 @@
|
|||
#ifndef zp_prv_hdr_bs
|
||||
#define zp_prv_hdr_bs
|
||||
|
||||
// C99: long long
|
||||
|
||||
/*
|
||||
Sources for pre-defined macros:
|
||||
|
||||
|
@ -68,7 +66,7 @@
|
|||
that doesn't result in ANY "broken" code, such
|
||||
as just always returning true in isconsteval,
|
||||
which would break if we returned false, as
|
||||
this could lead to reaching non-zp_prv_constexpr
|
||||
this could lead to reaching non-constexpr
|
||||
friendly code.
|
||||
|
||||
For types that have their own built-in type in
|
||||
|
@ -104,62 +102,68 @@
|
|||
#endif
|
||||
|
||||
#ifdef __has_builtin
|
||||
#define zp_prv_hasbuiltin(builtin) __has_builtin(builtin)
|
||||
#define zp_prv_hasbltin(bltin) __has_builtin(bltin)
|
||||
#else
|
||||
#define zp_prv_hasbuiltin(builtin) (0x0)
|
||||
#define zp_prv_hasbltin(bltin) (0x0)
|
||||
#endif
|
||||
|
||||
#ifdef __has_attribute
|
||||
#define zp_prv_hasattr(attr) __has_attribute(attr)
|
||||
#define zp_prv_hasatr(atr) __has_attribute(atr)
|
||||
#else
|
||||
#define zp_prv_hasattr(attr) (0x0)
|
||||
#define zp_prv_hasatr(atr) (0x0)
|
||||
#endif
|
||||
|
||||
// ext: GCC complains when we use __int128 without using "__extension__".
|
||||
/* ext: GCC complains when we use __int128 without using "__extension__". */
|
||||
#if zp_imp_gcc
|
||||
#define zp_prv_ext __extension__
|
||||
#else
|
||||
#define zp_prv_ext
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifndef zp_std_c23
|
||||
/*
|
||||
Currently, we guarantee the "bool" type (and
|
||||
its macros) to be present, regardles of the
|
||||
current standard. In C99, the type is defineed
|
||||
as the built-in type _Bool. In C23 and C++,
|
||||
these are keywords and are not defined by us.
|
||||
In C90, we define it using an unsigned integral
|
||||
type with the same requirements (size and
|
||||
alignement) as the platform's boolean type. If
|
||||
the platform doesn't implement C99 or C++, we
|
||||
define the type to char unsigned.
|
||||
*/
|
||||
#if !zp_std_cxx && !zp_std_c23
|
||||
/*
|
||||
Valid, because:
|
||||
|
||||
ISO/IEC 9899:1999 7.16.4 "Notwithstanding the
|
||||
provisions of 7.1.3, a program may undefine and
|
||||
perhaps then redefine the macros bool, true,
|
||||
ISO/IEC 9899:1999 7.16.4 "Notwithstanding the
|
||||
provisions of 7.1.3, a program may undefine and
|
||||
perhaps then redefine the macros bool, true,
|
||||
and false."
|
||||
|
||||
In C23 (and later), these are keywords (or
|
||||
predefined macros), and we therefore don't need
|
||||
to define these macros to be sure they are
|
||||
present. We could also define our own boolean
|
||||
type (zp_bool), but this is... better. :)
|
||||
type (zp_bool), but this is... better...
|
||||
*/
|
||||
|
||||
#undef bool
|
||||
#undef false
|
||||
#undef true
|
||||
|
||||
#define bool _Bool
|
||||
#define false (0x0)
|
||||
#define true (0x1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if zp_imp_gcc
|
||||
#define zp_restr __restrict__
|
||||
#elif zp_imp_msvc
|
||||
#define zp_restr __restrict
|
||||
#elif zp_std_c99
|
||||
#define zp_restr restrict
|
||||
#if zp_std_c99
|
||||
#define bool _Bool
|
||||
#else
|
||||
#define zp_restr
|
||||
typedef char unsigned zp_prv_bool;
|
||||
#define bool zp_prv_bool
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasbuiltin(__builtin_expect)
|
||||
#define false ((bool)+0x0u)
|
||||
#define true ((bool)+0x1u)
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasbltin(__builtin_expect)
|
||||
#define zp_lik(expr) if (__builtin_expect((expr),0x1))
|
||||
#define zp_ulik(expr) if (__builtin_expect((expr),0x0))
|
||||
#elif zp_std_cxx20
|
||||
|
@ -170,7 +174,7 @@
|
|||
#define zp_ulik(expr) if ((expr))
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasattr(__noreturn__)
|
||||
#if zp_prv_hasatr(__noreturn__)
|
||||
#define zp_nret __attribute__ ((__noreturn__))
|
||||
#elif zp_imp_msvc
|
||||
#define zp_nret __declspec (noreturn)
|
||||
|
@ -182,13 +186,13 @@
|
|||
#define zp_nret
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasattr(__always_inline__)
|
||||
#if zp_prv_hasatr(__always_inline__)
|
||||
#define zp_iln __attribute__ ((__always_inline__))
|
||||
#else
|
||||
#define zp_iln
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasattr(__nothrow__)
|
||||
#if zp_prv_hasatr(__nothrow__)
|
||||
#define zp_nthrw __attribute__ ((__nothrow__))
|
||||
#elif zp_imp_msvc
|
||||
#define zp_nthrw __declspec (nothrow)
|
||||
|
@ -196,7 +200,7 @@
|
|||
#define zp_nthrw
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasattr(__const__)
|
||||
#if zp_prv_hasatr(__const__)
|
||||
#define zp_useq __attribute__ ((__const__))
|
||||
#elif zp_std_c23
|
||||
#define zp_useq [[unsequenced]]
|
||||
|
@ -204,7 +208,7 @@
|
|||
#define zp_useq
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasattr(__unused__)
|
||||
#if zp_prv_hasatr(__unused__)
|
||||
#define zp_nuse __attribute__ ((__unused__))
|
||||
#elif zp_std_c23 || zp_std_cxx
|
||||
#define zp_nuse [[maybe_unused]]
|
||||
|
@ -212,7 +216,7 @@
|
|||
#define zp_nuse
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasbuiltin(__builtin_unreachable)
|
||||
#if zp_prv_hasbltin(__builtin_unreachable)
|
||||
#define zp_urch() ((void)__builtin_unreachable())
|
||||
#elif zp_imp_msvc
|
||||
#define zp_urch() ((void)__assume(0x0))
|
||||
|
@ -220,7 +224,7 @@
|
|||
#define zp_urch() (zp_trp())
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasattr(__warn_unused_result__)
|
||||
#if zp_prv_hasatr(__warn_unused_result__)
|
||||
#define zp_useres __attribute__ ((warn_unused_result))
|
||||
#elif zp_std_c23 || zp_std_cxx17
|
||||
#define zp_useres [[nodiscard]]
|
||||
|
@ -265,45 +269,24 @@ typedef long unsigned zp_sysclid;
|
|||
typedef long unsigned zp_sysclres;
|
||||
#endif
|
||||
|
||||
/*
|
||||
nullptrtyp: The strange type.
|
||||
|
||||
In C23 and C++11, the nullptr_t type is a sui
|
||||
generis (distinct) type: It is not an
|
||||
arithmetic type and has only one valid value,
|
||||
yet it may be converted to pointer types and
|
||||
bool, the result of which is the null-pointer
|
||||
value of that pointer type or false.
|
||||
|
||||
However, we define it a little differently: We
|
||||
define it as the type of our constant nullptr,
|
||||
which may be the standard nullptr_t, but may
|
||||
also be a pointer-to-void type (C) or an
|
||||
integral type (before C++11). Therefore, we
|
||||
don't assert the same limitations/guarantees as
|
||||
the standard, except that it may be cast to any
|
||||
pointer type, and that such casts results in
|
||||
the null-pointer value for that pointer type.
|
||||
*/
|
||||
|
||||
#if zp_std_c23
|
||||
typedef typeof (nullptr) zp_nulptrtyp;
|
||||
#elif zp_std_cxx
|
||||
#elif zp_std_cxx11
|
||||
typedef decltype (nullptr) zp_nulptrtyp;
|
||||
#else
|
||||
typedef void * zp_nulptrtyp;
|
||||
#endif
|
||||
|
||||
#define zp_ver ((zp_i04m)+0x1u) // Programs expecting this version will still compile with the current extension version.
|
||||
#define zp_extver ((zp_i04m)+0x0u) // The extension versions adds functionality without breaking the existing ones.
|
||||
// The patch version is not public as it only changes implementation details.
|
||||
#define zp_ver ((zp_i04m)+0x1u) /* Programs expecting this version will still compile with the current extension version. */
|
||||
#define zp_extver ((zp_i04m)+0x0u) /* The extension versions adds functionality without breaking the existing ones. */
|
||||
/* The patch version is not public as it only changes implementation details. */
|
||||
|
||||
#define zp_bytelen ((zp_sz)+0x8u)
|
||||
|
||||
#define zp_nopos zp_maxvalz
|
||||
|
||||
#if zp_std_c23 || zp_std_cxx
|
||||
#if zp_std_c23 || zp_std_cxx11
|
||||
#define zp_nulptr (nullptr)
|
||||
#elif zp_std_cxx
|
||||
#define zp_nulptr (0x0u)
|
||||
#else
|
||||
#define zp_nulptr ((void *)0x0u)
|
||||
#endif
|
||||
|
|
|
@ -16,32 +16,26 @@ namespace zp {
|
|||
srctyp * src;
|
||||
};
|
||||
|
||||
template<typename dsttyp,typename srctyp> zp_iln inline auto memcpy(dsttyp * zp_restr dst,srctyp const * zp_restr src,::zp::sz const num) zp_prv_nthrw -> ::zp::cpyres<dsttyp,srctyp>;
|
||||
template<typename dsttyp,typename srctyp> zp_iln zp_nthrw inline ::zp::cpyres<dsttyp,srctyp> memcpy(dsttyp * dst, srctyp const * src, ::zp::sz const num);
|
||||
template<typename ltyp, typename rtyp> zp_useres zp_iln zp_nthrw inline bool memequ(ltyp const * lbuf,rtyp const * rbuf,::zp::sz const num) {return ::zp_memequ(lbuf,rbuf,num);}
|
||||
template<typename typ> zp_iln zp_nthrw inline typ * memfil(typ * dst, char unsigned val, ::zp::sz const num) {return static_cast<typ *>(::zp_memfil(dst,val,num));}
|
||||
template<typename typ> zp_useres zp_nthrw zp_iln inline typ * memsrh(typ * buf, char unsigned val, ::zp::sz const num) {return static_cast<typ *>(::zp_memsrh(buf,val,num));}
|
||||
template<typename typ> zp_useres zp_nthrw zp_iln inline typ const * memsrh(typ const * buf, char unsigned val, ::zp::sz const num) {return const_cast<typ const *>(static_cast<typ *>(::zp_memsrh(buf,val,num)));}
|
||||
|
||||
template<typename ltyp,typename rtyp> zp_useres zp_iln inline auto memequ(ltyp const * lbuf,rtyp const * rbuf,::zp::sz const num) zp_prv_nthrw -> bool;
|
||||
|
||||
template<typename typ> zp_iln inline auto memfil(typ * dst,char unsigned val,::zp::sz const num) zp_prv_nthrw -> typ *;
|
||||
|
||||
template<typename typ> zp_useres zp_iln inline auto memsrh(typ * buf,char unsigned val,::zp::sz const num) zp_prv_nthrw -> typ *;
|
||||
template<typename typ> zp_useres zp_iln inline auto memsrh(typ const * buf,char unsigned val,::zp::sz const num) zp_prv_nthrw -> typ const *;
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto cpy(typ * zp_restr dst,typ const * zp_restr src,::zp::sz const num) zp_prv_nthrw -> ::zp::cpyres<typ,typ>;
|
||||
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto equ(typ const * lbuf,typ const * rbuf,::zp::sz const num) zp_prv_nthrw -> bool;
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto fil(typ * dst,typ const val,::zp::sz const num) zp_prv_nthrw -> typ *;
|
||||
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto srh(typ * buf,typ const val,::zp::sz const num) zp_prv_nthrw -> typ *;
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto srh(typ const * buf,typ const val,::zp::sz const num) zp_prv_nthrw -> typ const *;
|
||||
#if zp_std_cxx14
|
||||
template<typename ltyp, typename rtyp> constexpr auto cpy(ltyp * dst, rtyp * src, ::zp::sz num) noexcept -> ::zp::cpyres<ltyp,rtyp>;
|
||||
template<typename ltyp, typename rtyp> constexpr auto equ(ltyp * lbuf,rtyp * rbuf,::zp::sz num) noexcept -> bool;
|
||||
template<typename buftyp,typename valtyp> constexpr auto fil(buftyp * buf, valtyp & val, ::zp::sz num) noexcept -> buftyp *;
|
||||
template<typename buftyp,typename valtyp> constexpr auto srh(buftyp * buf, valtyp & val, ::zp::sz num) noexcept -> buftyp *;
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <zp/mem.d/memcpy.ii>
|
||||
#if zp_std_cxx14
|
||||
#include <zp/mem.d/cpy.ii>
|
||||
#include <zp/mem.d/equ.ii>
|
||||
#include <zp/mem.d/fil.ii>
|
||||
#include <zp/mem.d/memcpy.ii>
|
||||
#include <zp/mem.d/memequ.ii>
|
||||
#include <zp/mem.d/memfil.ii>
|
||||
#include <zp/mem.d/memsrh.ii>
|
||||
#include <zp/mem.d/srh.ii>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::cpy(typ * zp_restr dst,typ const * zp_restr src,::zp::sz const num) zp_prv_nthrw -> ::zp::cpyres<typ,typ> {
|
||||
typ * const zp_restr stp = dst+num;
|
||||
template<typename ltyp,typename rtyp> constexpr auto zp::cpy(ltyp * dst,rtyp * src,::zp::sz const num) noexcept -> ::zp::cpyres<ltyp,rtyp> {
|
||||
ltyp * const stp = dst+num;
|
||||
while (dst != stp) {*dst++ = *src++;}
|
||||
|
||||
return ::zp::cpyres<typ,typ> {dst,const_cast<typ *>(src),};
|
||||
return ::zp::cpyres<ltyp,rtyp> {dst,src,};
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::equ(typ const * lbuf,typ const * rbuf,::zp::sz const num) zp_prv_nthrw -> bool {
|
||||
typ const * const stp = lbuf+num;
|
||||
template<typename ltyp,typename rtyp> constexpr auto zp::equ(ltyp * lbuf,rtyp * rbuf,::zp::sz const num) noexcept -> bool {
|
||||
ltyp const * const stp = lbuf+num;
|
||||
|
||||
while (lbuf != stp) {
|
||||
zp_lik (*lbuf++ != *rbuf++) {return false;}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::fil(typ * dst,typ const val,::zp::sz const num) zp_prv_nthrw -> typ * {
|
||||
typ * const stp = dst+num;
|
||||
while (dst != stp) {*dst++ = val;}
|
||||
template<typename buftyp,typename valtyp> constexpr auto zp::fil(buftyp * buf,valtyp & val,::zp::sz const num) noexcept -> buftyp * {
|
||||
buftyp * const stp = buf+num;
|
||||
while (buf != stp) {*buf++ = val;}
|
||||
|
||||
return stp;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename dsttyp,typename srctyp> inline auto ::zp::memcpy(dsttyp * zp_restr dst,srctyp const * zp_restr src,::zp::sz const num) zp_prv_nthrw -> ::zp::cpyres<dsttyp,srctyp> {
|
||||
template<typename dsttyp,typename srctyp> zp_nthrw inline ::zp::cpyres<dsttyp,srctyp> zp::memcpy(dsttyp * dst,srctyp const * src,::zp::sz const num) {
|
||||
::zp_cpyres const cpyres = ::zp_memcpy(dst,src,num);
|
||||
|
||||
return ::zp::cpyres<dsttyp,srctyp> {static_cast<dsttyp *>(cpyres.dst),static_cast<srctyp *>(cpyres.src),};
|
||||
return ::zp::cpyres<dsttyp,srctyp> (static_cast<dsttyp *>(cpyres.dst),static_cast<srctyp *>(cpyres.src));
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename ltyp,typename rtyp> inline auto ::zp::memequ(ltyp const * lbuf,rtyp const * rbuf,::zp::sz const num) zp_prv_nthrw -> bool {
|
||||
return ::zp_memequ(lbuf,rbuf,num);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> inline auto ::zp::memfil(typ * dst,char unsigned const val,::zp::sz const num) zp_prv_nthrw -> typ * {
|
||||
return static_cast<typ *>(::zp_memfil(dst,val,num));
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> inline auto ::zp::memsrh(typ * buf,char unsigned const val,::zp::sz const num) zp_prv_nthrw -> typ * {
|
||||
return static_cast<typ *>(::zp_memsrh(buf,val,num));
|
||||
}
|
||||
|
||||
template<typename typ> inline auto ::zp::memsrh(typ const * buf,char unsigned const val,::zp::sz const num) zp_prv_nthrw -> typ const * {
|
||||
return const_cast<typ const *>(static_cast<typ *>(::zp_memsrh(buf,val,num)));
|
||||
}
|
|
@ -4,15 +4,11 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::srh(typ * buf,typ val,::zp::sz const num) zp_prv_nthrw -> typ * {
|
||||
return const_cast<typ *>(::zp::srh(const_cast<typ const *>(buf),val,num));
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::srh(typ const * buf,typ const val,::zp::sz const num) zp_prv_nthrw -> typ const * {
|
||||
typ const * const stp = buf+num;
|
||||
template<typename buftyp,typename valtyp> constexpr auto zp::srh(buftyp * buf,valtyp & val,::zp::sz const num) noexcept -> buftyp * {
|
||||
buftyp * const stp = buf+num;
|
||||
|
||||
while (buf != stp) {
|
||||
typ const * addr = buf++;
|
||||
buftyp * const addr = buf++;
|
||||
zp_ulik (*addr == val) {return addr;}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ struct zp_cpyres {
|
|||
void * src;
|
||||
};
|
||||
|
||||
zp_nthrw struct zp_cpyres zp_memcpy(void * zp_restr dst, void const * zp_restr src, zp_sz num);
|
||||
zp_nthrw struct zp_cpyres zp_memcpy(void * dst, void const * src, zp_sz num);
|
||||
zp_nthrw zp_useres bool zp_memequ(void const * lbuf,void const * rbuf,zp_sz num);
|
||||
zp_nthrw void * zp_memfil(void * dst, char unsigned val, zp_sz num);
|
||||
zp_nthrw zp_useres void * zp_memsrh(void const * buf, char unsigned val, zp_sz num);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <zp/mth.h>
|
||||
|
||||
namespace zp {
|
||||
#if zp_std_cxx11
|
||||
template<typename typ> struct inf {constexpr static auto val = ::zp::maxval<typ>::val;};
|
||||
|
||||
template<> struct inf<double> {constexpr static auto val = zp_inff;};
|
||||
|
@ -22,142 +23,179 @@ namespace zp {
|
|||
template<> struct nan<double> {constexpr static auto val = zp_nanf;};
|
||||
template<> struct nan<float> {constexpr static auto val = zp_nand;};
|
||||
template<> struct nan<long double> {constexpr static auto val = zp_nanld;};
|
||||
#endif
|
||||
|
||||
namespace prv {
|
||||
template<typename ityp> struct cpairtyp {using typ = void;};
|
||||
|
||||
template<> struct cpairtyp<char signed> {using typ = ::zp_pairsc;};
|
||||
template<> struct cpairtyp<short> {using typ = ::zp_pairs;};
|
||||
template<> struct cpairtyp<int> {using typ = ::zp_pairi;};
|
||||
template<> struct cpairtyp<long> {using typ = ::zp_pairl;};
|
||||
template<> struct cpairtyp<long long> {using typ = ::zp_pairll;};
|
||||
}
|
||||
|
||||
template<typename typ> class pair {
|
||||
public:
|
||||
using ctyp = typename ::zp::prv::cpairtyp<typ>::typ;
|
||||
|
||||
template<typename typ> struct divmodres {
|
||||
typ lval;
|
||||
typ rval;
|
||||
|
||||
zp_prv_constexpr auto cpair() const zp_prv_nthrw -> ctyp;
|
||||
};
|
||||
|
||||
namespace det {
|
||||
template<typename ityp> struct cvec2typ {using typ = void;};
|
||||
|
||||
template<> struct cvec2typ<double> {using typ = ::zp_vec2d;};
|
||||
template<> struct cvec2typ<float> {using typ = ::zp_vec2f;};
|
||||
template<> struct cvec2typ<long double> {using typ = ::zp_vec2ld;};
|
||||
|
||||
template<typename ityp> struct cvec3typ {using typ = void;};
|
||||
|
||||
template<> struct cvec3typ<double> {using typ = ::zp_vec3d;};
|
||||
template<> struct cvec3typ<float> {using typ = ::zp_vec3f;};
|
||||
template<> struct cvec3typ<long double> {using typ = ::zp_vec3ld;};
|
||||
|
||||
template<typename ityp> struct cvec4typ {using typ = void;};
|
||||
|
||||
template<> struct cvec4typ<double> {using typ = ::zp_vec4d;};
|
||||
template<> struct cvec4typ<float> {using typ = ::zp_vec4f;};
|
||||
template<> struct cvec4typ<long double> {using typ = ::zp_vec4ld;};
|
||||
}
|
||||
|
||||
template<typename typ> class vec2 {
|
||||
public:
|
||||
using ctyp = typename ::zp::det::cvec2typ<typ>::typ;
|
||||
|
||||
template<typename typ> struct vec2 {
|
||||
typ x;
|
||||
typ y;
|
||||
|
||||
zp_prv_constexpr auto cvec() const zp_prv_nthrw -> ctyp;
|
||||
};
|
||||
template<typename typ> class vec3 {
|
||||
public:
|
||||
using ctyp = typename ::zp::det::cvec3typ<typ>::typ;
|
||||
|
||||
template<typename typ> struct vec3 {
|
||||
typ x;
|
||||
typ y;
|
||||
typ z;
|
||||
|
||||
zp_prv_constexpr auto cvec() const zp_prv_nthrw -> ctyp;
|
||||
};
|
||||
template<typename typ> class vec4 {
|
||||
public:
|
||||
using ctyp = typename ::zp::det::cvec4typ<typ>::typ;
|
||||
|
||||
template<typename typ> struct vec4 {
|
||||
typ x;
|
||||
typ y;
|
||||
typ z;
|
||||
typ w;
|
||||
|
||||
zp_prv_constexpr auto cvec() const zp_prv_nthrw -> ctyp;
|
||||
};
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto abs(typ val) zp_prv_nthrw -> typename ::zp::usgn<typ>::typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float abs(float val) {return ::zp_absf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double abs(double val) {return ::zp_absd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double abs(long double val) {return ::zp_absld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto acos(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float acos(float val) {return ::zp_acosf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double acos(double val) {return ::zp_acosd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double acos(long double val) {return ::zp_acosld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto asin(typ val) zp_prv_nthrw -> typ;
|
||||
/* arccotangent */
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float zp_acot(float val) {return ::zp_acotf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double zp_acot(double val) {return ::zp_acotd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double zp_acot(long double val) {return ::zp_acotld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto atan(typ val) zp_prv_nthrw -> typ;
|
||||
/* arccosecant */
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float zp_acsc(float val) {return ::zp_acscf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double zp_acsc(double val) {return ::zp_acscd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double zp_acsc(long double val) {return ::zp_acscld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto cbrt(typ val) zp_prv_nthrw -> typ;
|
||||
/* arcsecant */
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float asec(float val) {return ::zp_asecf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double asec(double val) {return ::zp_asecd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double asec(long double val) {return ::zp_asecld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto cos(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float asin(float val) {return ::zp_asinf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double asin(double val) {return ::zp_asind( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double asin(long double val) {return ::zp_asinld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto dist(typ x,typ y) zp_prv_nthrw -> typ;
|
||||
template<typename typ> zp_prv_constexpr auto dist(typ x,typ y,typ z) zp_prv_nthrw -> typ;
|
||||
template<typename typ> zp_prv_constexpr auto dist(typ x,typ y,typ z,typ w) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float atan(float val) {return ::zp_atanf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double atan(double val) {return ::zp_atand( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double atan(long double val) {return ::zp_atanld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto divmod(typ num,typ den) zp_prv_nthrw -> ::zp::pair<typ>;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float atan2(float y,float x) {return ::zp_atan2f( y,x);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double atan2(double y,double x) {return ::zp_atan2d( y,x);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double atan2(long double y,long double x) {return ::zp_atan2ld(y,x);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto dot(::zp::vec2<typ> lvec,::zp::vec2<typ> rvec) zp_prv_nthrw -> typ;
|
||||
template<typename typ> zp_prv_constexpr auto dot(::zp::vec3<typ> lvec,::zp::vec3<typ> rvec) zp_prv_nthrw -> typ;
|
||||
template<typename typ> zp_prv_constexpr auto dot(::zp::vec4<typ> lvec,::zp::vec4<typ> rvec) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float cbrt(float val) {return ::zp_cbrtf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double cbrt(double val) {return ::zp_cbrtd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double cbrt(long double val) {return ::zp_cbrtld(val);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto exp(typ val,typ n) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float cos(float ang) {return ::zp_cosf( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double cos(double ang) {return ::zp_cosd( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double cos(long double ang) {return ::zp_cosld(ang);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto isnan(typ val) zp_prv_nthrw -> bool;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float cot(float ang) {return ::zp_cotf( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double cot(double ang) {return ::zp_cotd( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double cot(long double ang) {return ::zp_cotld(ang);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto lb(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float csc(float ang) {return ::zp_cscf( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double csc(double ang) {return ::zp_cscd( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double csc(long double ang) {return ::zp_cscld(ang);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto lg(typ val) zp_prv_nthrw -> typ;
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ln(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float dist2(float x,float y) {return ::zp_dist2f( x,y);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double dist2(double x,double y) {return ::zp_dist2d( x,y);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double dist2(long double x,long double y) {return ::zp_dist2ld(x,y);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto log(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float dist3(float x,float y,float z) {return ::zp_dist3f( x,y,z);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double dist3(double x,double y,double z) {return ::zp_dist3d( x,y,z);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double dist3(long double x,long double y,long double z) {return ::zp_dist3ld(x,y,z);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto nrt(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float dist4(float x,float y,float z,float w) {return ::zp_dist4f( x,y,z,w);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double dist4(double x,double y,double z,double w) {return ::zp_dist4d( x,y,z,w);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double dist4(long double x,long double y,long double z,long double w) {return ::zp_dist4ld(x,y,z,w);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto sin(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::divmodres<char signed> divmod(char signed num,char signed den);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::divmodres<short> divmod(short num,short den);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::divmodres<int> divmod(int num,int den);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::divmodres<long> divmod(long num,long den);
|
||||
#if zp_std_c99 || zp_std_cxx11
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::divmodres<long long> divmodl(long long num,long long den);
|
||||
#endif
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto sqrt(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float dot2(::zp::vec2<float> lvec,::zp::vec2<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double dot2(::zp::vec2<double> lvec,::zp::vec2<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double dot2(::zp::vec2<long double> lvec,::zp::vec2<long double> rvec);
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto tan(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float dot3(::zp::vec3<float> lvec,::zp::vec3<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double dot3(::zp::vec3<double> lvec,::zp::vec3<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double dot3(::zp::vec3<long double> lvec,::zp::vec3<long double> rvec);
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto tsrt(typ val) zp_prv_nthrw -> typ;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float dot4(::zp::vec4<float> lvec,::zp::vec4<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double dot4(::zp::vec4<double> lvec,::zp::vec4<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double dot4(::zp::vec4<long double> lvec,::zp::vec4<long double> rvec);
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto vadd(::zp::vec2<typ> lvec,::zp::vec2<typ> rvec) zp_prv_nthrw -> ::zp::vec2<typ>;
|
||||
template<typename typ> zp_prv_constexpr auto vadd(::zp::vec3<typ> lvec,::zp::vec3<typ> rvec) zp_prv_nthrw -> ::zp::vec3<typ>;
|
||||
template<typename typ> zp_prv_constexpr auto vadd(::zp::vec4<typ> lvec,::zp::vec4<typ> rvec) zp_prv_nthrw -> ::zp::vec4<typ>;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float exp(float val,float n) {return ::zp_expf( val,n);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double exp(double val,double n) {return ::zp_expd( val,n);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double exp(long double val,long double n) {return ::zp_expld(val,n);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto vsub(::zp::vec2<typ> lvec,::zp::vec2<typ> rvec) zp_prv_nthrw -> ::zp::vec2<typ>;
|
||||
template<typename typ> zp_prv_constexpr auto vsub(::zp::vec3<typ> lvec,::zp::vec3<typ> rvec) zp_prv_nthrw -> ::zp::vec3<typ>;
|
||||
template<typename typ> zp_prv_constexpr auto vsub(::zp::vec4<typ> lvec,::zp::vec4<typ> rvec) zp_prv_nthrw -> ::zp::vec4<typ>;
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float lb(float val) {return ::zp_lbf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double lb(double val) {return ::zp_lbd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double lb(long double val) {return ::zp_lbld(val);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float lg(float val) {return ::zp_lgf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double lg(double val) {return ::zp_lgd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double lg(long double val) {return ::zp_lgld(val);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float ln(float val) {return ::zp_lnf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double ln(double val) {return ::zp_lnd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double ln(long double val) {return ::zp_lnld(val);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float log(float val,float n) {return ::zp_logf( val,n);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double log(double val,double n) {return ::zp_logd( val,n);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double log(long double val,long double n) {return ::zp_logld(val,n);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float nrt(float val,float n) {return ::zp_nrtf( val,n);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double nrt(double val,double n) {return ::zp_nrtd( val,n);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double nrt(long double val,long double n) {return ::zp_nrtld(val,n);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float sec(float ang) {return ::zp_secf( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double sec(double ang) {return ::zp_secd( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double sec(long double ang) {return ::zp_secld(ang);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float sin(float ang) {return ::zp_sinf( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double sin(double ang) {return ::zp_sind( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double sin(long double ang) {return ::zp_sinld(ang);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float sqrt(float val) {return ::zp_sqrtf( val);;}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double sqrt(double val) {return ::zp_sqrtd( val);;}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double sqrt(long double val) {return ::zp_sqrtld(val);;}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float tan(float ang) {return ::zp_tanf( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double tan(double ang) {return ::zp_tand( ang);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double tan(long double ang) {return ::zp_tanld(ang);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline float tsrt(float val) {return ::zp_tsrtf( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline double tsrt(double val) {return ::zp_tsrtd( val);}
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline long double tsrt(long double val) {return ::zp_tsrtld(val);}
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec2<float> vadd2f( ::zp::vec2<float> lvec,::zp::vec2<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec2<double> vadd2d( ::zp::vec2<double> lvec,::zp::vec2<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec2<long double> vadd2ld(::zp::vec2<long double> lvec,::zp::vec2<long double> rvec);
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec3<float> vadd3f( ::zp::vec3<float> lvec,::zp::vec3<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec3<double> vadd3d( ::zp::vec3<double> lvec,::zp::vec3<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec3<long double> vadd3ld(::zp::vec3<long double> lvec,::zp::vec3<long double> rvec);
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec4<float> vadd4f( ::zp::vec4<float> lvec,::zp::vec4<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec4<double> vadd4d( ::zp::vec4<double> lvec,::zp::vec4<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec4<long double> vadd4ld(::zp::vec4<long double> lvec,::zp::vec4<long double> rvec);
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec2<float> vsub2f( ::zp::vec2<float> lvec,::zp::vec2<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec2<double> vsub2d( ::zp::vec2<double> lvec,::zp::vec2<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec2<long double> vsub2ld(::zp::vec2<long double> lvec,::zp::vec2<long double> rvec);
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec3<float> vsub3f( ::zp::vec3<float> lvec,::zp::vec3<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec3<double> vsub3d( ::zp::vec3<double> lvec,::zp::vec3<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec3<long double> vsub3ld(::zp::vec3<long double> lvec,::zp::vec3<long double> rvec);
|
||||
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec4<float> vsub4f( ::zp::vec4<float> lvec,::zp::vec4<float> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec4<double> vsub4d( ::zp::vec4<double> lvec,::zp::vec4<double> rvec);
|
||||
zp_iln zp_nthrw zp_useq zp_useres inline ::zp::vec4<long double> vsub4ld(::zp::vec4<long double> lvec,::zp::vec4<long double> rvec);
|
||||
}
|
||||
|
||||
#include <zp/mth.d/pair/cpair.ii>
|
||||
#include <zp/mth.d/vec2/cvec.ii>
|
||||
#include <zp/mth.d/vec3/cvec.ii>
|
||||
#include <zp/mth.d/vec4/cvec.ii>
|
||||
#include <zp/mth.d/abs.ii>
|
||||
#include <zp/mth.d/dist.ii>
|
||||
#include <zp/mth.d/divmod.ii>
|
||||
#include <zp/mth.d/dot.ii>
|
||||
#include <zp/mth.d/exp.ii>
|
||||
#include <zp/mth.d/isnan.ii>
|
||||
#include <zp/mth.d/vadd.ii>
|
||||
#include <zp/mth.d/vsub.ii>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::abs(typ const val) zp_prv_nthrw -> typename ::zp::usgn<typ>::typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
using newtyp = typename ::zp::usgn<typ>::typ; // If a floating-point type was used, the new type would be identical.
|
||||
|
||||
if (val > typ {0x0}) return static_cast<newtyp>(val);
|
||||
|
||||
return typ {0x0}-static_cast<newtyp>(val);
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
/*template<typename typ> zp_prv_constexpr auto ::zp::dist(typ const x,typ const y) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::sqrt(x*x+y*y);
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::dist(typ const x,typ const y,typ const z) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::cbrt(x*x+y*y+z*z);
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::dist(typ const x,typ const y,typ const z,typ const w) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::tsrt(x*x+y*y+z*z+w*w);
|
||||
}*/
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::divmod(typ const num,typ const den) zp_prv_nthrw -> ::zp::pair<typ> {
|
||||
static_assert(::zp::isint<typ>::val,"type must be an integral type");
|
||||
|
||||
::zp::pair<typ> pair;
|
||||
|
||||
zp_ulik (den == 0x0) {
|
||||
pair.lval = ::zp::inf<typ>::val;
|
||||
pair.rval = pair.lval;
|
||||
|
||||
return pair;
|
||||
}
|
||||
|
||||
for (pair = ::zp::pair<typ> {typ {0x0},num};pair.rval >= den;++pair.lval,pair.rval -= den);
|
||||
|
||||
return pair;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::dot(::zp::vec2<typ> const lvec,::zp::vec2<typ> const rvec) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return lvec.x*rvec.x+lvec.y*rvec.y;
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::dot(::zp::vec3<typ> const lvec,::zp::vec3<typ> const rvec) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return lvec.x*rvec.x+lvec.y*rvec.y+lvec.z*rvec.z;
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::dot(::zp::vec4<typ> const lvec,::zp::vec4<typ> const rvec) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return lvec.x*rvec.x+lvec.y*rvec.y+lvec.z*rvec.z+lvec.w*rvec.w;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::exp(typ const val,typ const n) zp_prv_nthrw -> typ {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
zp_ulik (n == typ {0x0}) {
|
||||
return typ {0x1};
|
||||
}
|
||||
|
||||
zp_ulik (val == typ {0x0}) {
|
||||
return typ {0x0};
|
||||
}
|
||||
|
||||
typ exp = val;
|
||||
for (typ i = typ {0x1};i < n;++i) exp *= val;
|
||||
|
||||
return exp;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::isnan(typ const val) zp_prv_nthrw -> bool {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
if (::zp::isint<typ>::val) {return false;}
|
||||
|
||||
return val != val;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::pair<typ>::cpair() const zp_prv_nthrw -> ::zp::pair<typ>::ctyp {
|
||||
return ::zp::pair<typ>::ctyp {
|
||||
this->lval,
|
||||
this->rval,
|
||||
};
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vadd(::zp::vec2<typ> const lvec,::zp::vec2<typ> const rvec) zp_prv_nthrw -> ::zp::vec2<typ> {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::vec2<typ> {
|
||||
lvec.x+rvec.x,
|
||||
lvec.y+rvec.y,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vadd(::zp::vec3<typ> const lvec,::zp::vec3<typ> const rvec) zp_prv_nthrw -> ::zp::vec3<typ> {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::vec3<typ> {
|
||||
lvec.x+rvec.x,
|
||||
lvec.y+rvec.y,
|
||||
lvec.z+rvec.z,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vadd(::zp::vec4<typ> const lvec,::zp::vec4<typ> const rvec) zp_prv_nthrw -> ::zp::vec4<typ> {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::vec4<typ> {
|
||||
lvec.x+rvec.x,
|
||||
lvec.y+rvec.y,
|
||||
lvec.z+rvec.z,
|
||||
lvec.w+rvec.w,
|
||||
};
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vec2<typ>::cvec() const zp_prv_nthrw -> ::zp::vec2<typ>::ctyp {
|
||||
return typename ::zp::vec2<typ>::ctyp {
|
||||
this->x,
|
||||
this->y,
|
||||
};
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vec3<typ>::cvec() const zp_prv_nthrw -> ::zp::vec3<typ>::ctyp {
|
||||
return typename ::zp::vec3<typ>::ctyp {
|
||||
this->x,
|
||||
this->y,
|
||||
this->z,
|
||||
};
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vec4<typ>::cvec() const zp_prv_nthrw -> ::zp::vec4<typ>::ctyp {
|
||||
return typename ::zp::vec4<typ>::ctyp {
|
||||
this->x,
|
||||
this->y,
|
||||
this->z,
|
||||
this->w,
|
||||
};
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vsub(::zp::vec2<typ> const lvec,::zp::vec2<typ> const rvec) zp_prv_nthrw -> ::zp::vec2<typ> {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::vec2<typ> {
|
||||
lvec.x-rvec.x,
|
||||
lvec.y-rvec.y,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vsub(::zp::vec3<typ> const lvec,::zp::vec3<typ> const rvec) zp_prv_nthrw -> ::zp::vec3<typ> {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::vec3<typ> {
|
||||
lvec.x-rvec.x,
|
||||
lvec.y-rvec.y,
|
||||
lvec.z-rvec.z,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::vsub(::zp::vec4<typ> const lvec,::zp::vec4<typ> const rvec) zp_prv_nthrw -> ::zp::vec4<typ> {
|
||||
static_assert(::zp::isari<typ>::val,"type must be an arithmetic type");
|
||||
|
||||
return ::zp::vec4<typ> {
|
||||
lvec.x-rvec.x,
|
||||
lvec.y-rvec.y,
|
||||
lvec.z-rvec.z,
|
||||
lvec.w-rvec.w,
|
||||
};
|
||||
}
|
|
@ -11,58 +11,60 @@
|
|||
|
||||
zp_prv_cdecl
|
||||
|
||||
#if zp_prv_hasbuiltin(__builtin_huge_val)
|
||||
#if zp_prv_hasbltin(__builtin_huge_val)
|
||||
#define zp_infd (__builtin_huge_val())
|
||||
#else
|
||||
#define zp_infd (0.0);
|
||||
#endif
|
||||
#if zp_prv_hasbuiltin(__builtin_huge_valf)
|
||||
#if zp_prv_hasbltin(__builtin_huge_valf)
|
||||
#define zp_inff (__builtin_huge_valf())
|
||||
#else
|
||||
#define zp_inff (0.0f);
|
||||
#endif
|
||||
#if zp_prv_hasbuiltin(__builtin_huge_vall)
|
||||
#if zp_prv_hasbltin(__builtin_huge_vall)
|
||||
#define zp_infld (__builtin_huge_vall())
|
||||
#else
|
||||
#define zp_infld (0.0l);
|
||||
#endif
|
||||
|
||||
#if zp_prv_hasbuiltin(__builtin_nan)
|
||||
#if zp_prv_hasbltin(__builtin_nan)
|
||||
#define zp_nand (__builtin_nan(""))
|
||||
#else
|
||||
#define zp_nand (0.0);
|
||||
#endif
|
||||
#if zp_prv_hasbuiltin(__builtin_nanf)
|
||||
#if zp_prv_hasbltin(__builtin_nanf)
|
||||
#define zp_nanf (__builtin_nanf(""))
|
||||
#else
|
||||
#define zp_nanf (0.0f);
|
||||
#endif
|
||||
#if zp_prv_hasbuiltin(__builtin_nanl)
|
||||
#if zp_prv_hasbltin(__builtin_nanl)
|
||||
#define zp_nanld (__builtin_nanl(""))
|
||||
#else
|
||||
#define zp_nanld (0.0l);
|
||||
#endif
|
||||
|
||||
struct zp_pairsc {
|
||||
struct divmodressc {
|
||||
char signed lval;
|
||||
char signed rval;
|
||||
};
|
||||
struct zp_pairs {
|
||||
struct divmodress {
|
||||
short lval;
|
||||
short rval;
|
||||
};
|
||||
struct zp_pairi {
|
||||
struct divmodresi {
|
||||
int lval;
|
||||
int rval;
|
||||
};
|
||||
struct zp_pairl {
|
||||
struct divmodresl {
|
||||
long lval;
|
||||
long rval;
|
||||
};
|
||||
struct zp_pairll {
|
||||
#if zp_std_c99 || zp_std_cxx11
|
||||
struct divmodresll {
|
||||
long long lval;
|
||||
long long rval;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct zp_vec2d {
|
||||
double x;
|
||||
|
@ -112,164 +114,191 @@ struct zp_vec4ld {
|
|||
long double w;
|
||||
};
|
||||
|
||||
// is not-a-number
|
||||
/* is not-a-number */
|
||||
#define zp_isnand( val) ((bool)((val) != (val)))
|
||||
#define zp_isnanf( val) ((bool)((val) != (val)))
|
||||
#define zp_isnanld(val) ((bool)((val) != (val)))
|
||||
|
||||
// absolute
|
||||
/* absolute */
|
||||
zp_nthrw zp_useq zp_useres float zp_absf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_absd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_absld(long double val);
|
||||
|
||||
// arc cosine
|
||||
/* arccosine */
|
||||
zp_nthrw zp_useq zp_useres float zp_acosf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_acosd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_acosld(long double val);
|
||||
|
||||
// arc sine
|
||||
/* arccotangent */
|
||||
zp_nthrw zp_useq zp_useres float zp_acotf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_acotd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_acotld(long double val);
|
||||
|
||||
/* arccosecant */
|
||||
zp_nthrw zp_useq zp_useres float zp_acscf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_acscd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_acscld(long double val);
|
||||
|
||||
/* arcsecant */
|
||||
zp_nthrw zp_useq zp_useres float zp_asecf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_asecd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_asecld(long double val);
|
||||
|
||||
/* arcsine */
|
||||
zp_nthrw zp_useq zp_useres float zp_asinf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_asind( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_asinld(long double val);
|
||||
|
||||
// arc tangens
|
||||
/* arctangens */
|
||||
zp_nthrw zp_useq zp_useres float zp_atanf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_atand( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_atanld(long double val);
|
||||
|
||||
// cube root
|
||||
/* arctangens 2 */
|
||||
zp_nthrw zp_useq zp_useres float zp_atan2f( float y,float x);
|
||||
zp_nthrw zp_useq zp_useres double zp_atan2d( double y,double x);
|
||||
zp_nthrw zp_useq zp_useres long double zp_atan2ld(long double y,long double x);
|
||||
|
||||
/* cube root */
|
||||
zp_nthrw zp_useq zp_useres float zp_cbrtf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_cbrtd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_cbrtld(long double val);
|
||||
|
||||
// cosine
|
||||
/* cosine */
|
||||
zp_nthrw zp_useq zp_useres float zp_cosf( float ang);
|
||||
zp_nthrw zp_useq zp_useres double zp_cosd( double ang);
|
||||
zp_nthrw zp_useq zp_useres long double zp_cosld(long double ang);
|
||||
|
||||
// two-space distance
|
||||
/* cotangent */
|
||||
zp_nthrw zp_useq zp_useres float zp_cotf( float ang);
|
||||
zp_nthrw zp_useq zp_useres double zp_cotd( double ang);
|
||||
zp_nthrw zp_useq zp_useres long double zp_cotld(long double ang);
|
||||
|
||||
/* cosecant */
|
||||
zp_nthrw zp_useq zp_useres float zp_cscf( float ang);
|
||||
zp_nthrw zp_useq zp_useres double zp_cscd( double ang);
|
||||
zp_nthrw zp_useq zp_useres long double zp_cscld(long double ang);
|
||||
|
||||
/* two-space distance */
|
||||
zp_nthrw zp_useq zp_useres float zp_dist2f( float x,float y);
|
||||
zp_nthrw zp_useq zp_useres double zp_dist2d( double x,double y);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dist2ld(long double x,long double y);
|
||||
|
||||
// three-space distance
|
||||
/* three-space distance */
|
||||
zp_nthrw zp_useq zp_useres float zp_dist3f( float x,float y,float z);
|
||||
zp_nthrw zp_useq zp_useres double zp_dist3d( double x,double y,double z);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dist3ld(long double x,long double y,long double z);
|
||||
|
||||
// four-space distance
|
||||
/* four-space distance */
|
||||
zp_nthrw zp_useq zp_useres float zp_dist4f( float x,float y,float z,float w);
|
||||
zp_nthrw zp_useq zp_useres double zp_dist4d( double x,double y,double z,double w);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dist4ld(long double x,long double y,long double z,long double w);
|
||||
|
||||
// division-modulo
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairsc zp_divmodsc(char signed num,char signed den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairs zp_divmods( short num,short den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairi zp_divmodi( int num,int den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairl zp_divmodl( long num,long den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairll zp_divmodll(long long num,long long den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairsc zp_divmodsc(char signed num,char signed den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairs zp_divmods( short num,short den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairi zp_divmodi( int num,int den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairl zp_divmodl( long num,long den);
|
||||
zp_nthrw zp_useq zp_useres struct zp_pairll zp_divmodll(long long num,long long den);
|
||||
/* division-modulo */
|
||||
zp_nthrw zp_useq zp_useres struct divmodressc zp_divmodsc(char signed num,char signed den);
|
||||
zp_nthrw zp_useq zp_useres struct divmodress zp_divmods( short num,short den);
|
||||
zp_nthrw zp_useq zp_useres struct divmodresi zp_divmodi( int num,int den);
|
||||
zp_nthrw zp_useq zp_useres struct divmodresl zp_divmodl( long num,long den);
|
||||
#if zp_std_c99 || zp_std_cxx11
|
||||
zp_nthrw zp_useq zp_useres struct divmodresll zp_divmodll(long long num,long long den);
|
||||
#endif
|
||||
|
||||
// two-space dot product
|
||||
/* two-space dot product */
|
||||
zp_nthrw zp_useq zp_useres float zp_dot2f( zp_vec2f lvec,zp_vec2f rvec);
|
||||
zp_nthrw zp_useq zp_useres double zp_dot2d( zp_vec2d lvec,zp_vec2d rvec);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dot2ld(zp_vec2ld lvec,zp_vec2ld rvec);
|
||||
|
||||
// three-space dot product
|
||||
/* three-space dot product */
|
||||
zp_nthrw zp_useq zp_useres float zp_dot3f( zp_vec3f lvec,zp_vec3f rvec);
|
||||
zp_nthrw zp_useq zp_useres double zp_dot3d( zp_vec3d lvec,zp_vec3d rvec);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dot3ld(zp_vec3ld lvec,zp_vec3ld rvec);
|
||||
|
||||
// four-space dot product
|
||||
/* four-space dot product */
|
||||
zp_nthrw zp_useq zp_useres float zp_dot4f( zp_vec4f lvec,zp_vec4f rvec);
|
||||
zp_nthrw zp_useq zp_useres double zp_dot4d( zp_vec4d lvec,zp_vec4d rvec);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dot4ld(zp_vec4ld lvec,zp_vec4ld rvec);
|
||||
|
||||
// two-space dot product
|
||||
zp_nthrw zp_useq zp_useres float zp_dotf( float x,float y);
|
||||
zp_nthrw zp_useq zp_useres double zp_dotd( double x,double y);
|
||||
zp_nthrw zp_useq zp_useres long double zp_dotld(long double x,long double y);
|
||||
|
||||
// exponentation
|
||||
/* exponentation */
|
||||
zp_nthrw zp_useq zp_useres float zp_expd( float val,float n);
|
||||
zp_nthrw zp_useq zp_useres double zp_expf( double val,double n);
|
||||
zp_nthrw zp_useq zp_useres long double zp_expld(long double val,long double n);
|
||||
|
||||
// binary logarithm
|
||||
/* binary logarithm */
|
||||
zp_nthrw zp_useq zp_useres float zp_lbf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_lbd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_lbld(long double val);
|
||||
|
||||
// common logarithm
|
||||
/* common logarithm */
|
||||
zp_nthrw zp_useq zp_useres float zp_lgf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_lgd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_lgld(long double val);
|
||||
|
||||
// natual logarithm
|
||||
/* natual logarithm */
|
||||
zp_nthrw zp_useq zp_useres float zp_lnf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_lnd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_lnld(long double val);
|
||||
|
||||
// logarithm
|
||||
/* logarithm */
|
||||
zp_nthrw zp_useq zp_useres float zp_logf( float val,float n);
|
||||
zp_nthrw zp_useq zp_useres double zp_logd( double val,double n);
|
||||
zp_nthrw zp_useq zp_useres long double zp_logld(long double val,long double n);
|
||||
|
||||
// nth root
|
||||
/* nth root */
|
||||
zp_nthrw zp_useq zp_useres float zp_nrtf( float val,float n);
|
||||
zp_nthrw zp_useq zp_useres double zp_nrtd( double val,double n);
|
||||
zp_nthrw zp_useq zp_useres long double zp_nrtld(long double val,long double n);
|
||||
|
||||
// sine
|
||||
/* secant */
|
||||
zp_nthrw zp_useq zp_useres float zp_secf( float ang);
|
||||
zp_nthrw zp_useq zp_useres double zp_secd( double ang);
|
||||
zp_nthrw zp_useq zp_useres long double zp_secld(long double ang);
|
||||
|
||||
/* sine */
|
||||
zp_nthrw zp_useq zp_useres float zp_sinf( float ang);
|
||||
zp_nthrw zp_useq zp_useres double zp_sind( double ang);
|
||||
zp_nthrw zp_useq zp_useres long double zp_sinld(long double ang);
|
||||
|
||||
// square root
|
||||
/* square root */
|
||||
zp_nthrw zp_useq zp_useres float zp_sqrtf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_sqrtd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_sqrtld(long double val);
|
||||
|
||||
// tangens
|
||||
/* tangens */
|
||||
zp_nthrw zp_useq zp_useres float zp_tanf( float ang);
|
||||
zp_nthrw zp_useq zp_useres double zp_tand( double ang);
|
||||
zp_nthrw zp_useq zp_useres long double zp_tanld(long double ang);
|
||||
|
||||
// "tesseract" (fourth) root
|
||||
/* "tesseract" (fourth) root */
|
||||
zp_nthrw zp_useq zp_useres float zp_tsrtf( float val);
|
||||
zp_nthrw zp_useq zp_useres double zp_tsrtd( double val);
|
||||
zp_nthrw zp_useq zp_useres long double zp_tsrtld(long double val);
|
||||
|
||||
// two-space vector addition
|
||||
zp_nthrw zp_useq zp_useres zp_vec2f zp_v2addf( zp_vec2f lvec,zp_vec2f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2d zp_v2addd( zp_vec2d lvec,zp_vec2d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2ld zp_v2addld(zp_vec2ld lvec,zp_vec2ld rvec);
|
||||
/* two-space vector addition */
|
||||
zp_nthrw zp_useq zp_useres zp_vec2f zp_vadd2f( zp_vec2f lvec,zp_vec2f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2d zp_vadd2d( zp_vec2d lvec,zp_vec2d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2ld zp_vadd2ld(zp_vec2ld lvec,zp_vec2ld rvec);
|
||||
|
||||
// three-space vector addition
|
||||
zp_nthrw zp_useq zp_useres zp_vec3f zp_v3addf( zp_vec3f lvec,zp_vec3f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3d zp_v3addd( zp_vec3d lvec,zp_vec3d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3ld zp_v3addld(zp_vec3ld lvec,zp_vec3ld rvec);
|
||||
/* three-space vector addition */
|
||||
zp_nthrw zp_useq zp_useres zp_vec3f zp_vadd3f( zp_vec3f lvec,zp_vec3f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3d zp_vadd3d( zp_vec3d lvec,zp_vec3d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3ld zp_vadd3ld(zp_vec3ld lvec,zp_vec3ld rvec);
|
||||
|
||||
// four-space vector addition
|
||||
/* four-space vector addition */
|
||||
zp_nthrw zp_useq zp_useres zp_vec4f zp_v4addf( zp_vec4f lvec,zp_vec4f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec4d zp_v4addd( zp_vec4d lvec,zp_vec4d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec4ld zp_v4addld(zp_vec4ld lvec,zp_vec4ld rvec);
|
||||
|
||||
// two-space vector subtraction
|
||||
zp_nthrw zp_useq zp_useres zp_vec2f zp_v2subf( zp_vec2f lvec,zp_vec2f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2d zp_v2subd( zp_vec2d lvec,zp_vec2d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2ld zp_v2subld(zp_vec2ld lvec,zp_vec2ld rvec);
|
||||
/* two-space vector subtraction */
|
||||
zp_nthrw zp_useq zp_useres zp_vec2f zp_vsub2f( zp_vec2f lvec,zp_vec2f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2d zp_vsub2d( zp_vec2d lvec,zp_vec2d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec2ld zp_vsub2ld(zp_vec2ld lvec,zp_vec2ld rvec);
|
||||
|
||||
// three-space vector subtraction
|
||||
zp_nthrw zp_useq zp_useres zp_vec3f zp_v3subf( zp_vec3f lvec,zp_vec3f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3d zp_v3subd( zp_vec3d lvec,zp_vec3d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3ld zp_v3subld(zp_vec3ld lvec,zp_vec3ld rvec);
|
||||
/* three-space vector subtraction */
|
||||
zp_nthrw zp_useq zp_useres zp_vec3f zp_vsub3f( zp_vec3f lvec,zp_vec3f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3d zp_vsub3d( zp_vec3d lvec,zp_vec3d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec3ld zp_vsub3ld(zp_vec3ld lvec,zp_vec3ld rvec);
|
||||
|
||||
// four-space vector subtraction
|
||||
/* four-space vector subtraction */
|
||||
zp_nthrw zp_useq zp_useres zp_vec4f zp_v4subf( zp_vec4f lvec,zp_vec4f rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec4d zp_v4subd( zp_vec4d lvec,zp_vec4d rvec);
|
||||
zp_nthrw zp_useq zp_useres zp_vec4ld zp_v4subld(zp_vec4ld lvec,zp_vec4ld rvec);
|
||||
|
|
|
@ -82,7 +82,7 @@ typedef char unsigned zp_c8;
|
|||
|
||||
#define zp_minvalc01 ((zp_c01)+zp_minvali01m)
|
||||
#define zp_maxvalc01 ((zp_c01)+zp_maxvali01m)
|
||||
#ifdef zp_std_cxx
|
||||
#ifdef zp_std_cxx11
|
||||
typedef char16_t zp_c01;
|
||||
#else
|
||||
typedef zp_i01m zp_c01;
|
||||
|
@ -90,7 +90,7 @@ typedef zp_i01m zp_c01;
|
|||
|
||||
#define zp_minvalc02 ((zp_c02)+zp_minvali02m)
|
||||
#define zp_maxvalc02 ((zp_c02)+zp_maxvali02m)
|
||||
#ifdef zp_std_cxx
|
||||
#ifdef zp_std_cxx11
|
||||
typedef char32_t zp_c02;
|
||||
#else
|
||||
typedef zp_i02m zp_c02;
|
||||
|
|
|
@ -91,7 +91,7 @@ typedef float zp_prv_f02;
|
|||
typedef double zp_prv_f04;
|
||||
|
||||
#if \
|
||||
zp_arc_arm64 // x86 jealous :(
|
||||
zp_arc_arm64 /* x86 jealous :( */
|
||||
|
||||
#define zp_fixflt08 (0x1)
|
||||
typedef long double zp_prv_f08;
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
#define zp_maxvalll ((long long) +0x7FFFFFFFFFFFFFFFll)
|
||||
|
||||
#define zp_minvalp ((zp_intptr)+0x0u)
|
||||
#define zp_minvalz ((zp_sz) +0x0u)
|
||||
#define zp_minvalz ((zp_sz) +0x0u)
|
||||
|
||||
#define zp_fixint8 (0x1)
|
||||
#define zp_minvali8 zp_minvalcu
|
||||
|
@ -95,7 +95,7 @@ typedef short zp_i01s;
|
|||
#if \
|
||||
zp_arc_arm
|
||||
|
||||
// For some reason long.
|
||||
/* For some reason long. */
|
||||
|
||||
#define zp_fixint02 (0x1)
|
||||
#define zp_minvali02 zp_minvallu
|
||||
|
@ -165,9 +165,9 @@ typedef zp_i04s zp_i04ms;
|
|||
zp_arc_amd64 \
|
||||
|| zp_arc_arm64
|
||||
|
||||
#define zp_minvall ((long) -0x8000000000000000ll)
|
||||
#define zp_maxvallu ((long unsigned)+0xFFFFFFFFFFFFFFFFllu)
|
||||
#define zp_maxvall ((long) +0x7FFFFFFFFFFFFFFFll)
|
||||
#define zp_minvall ((long) -0x8000000000000000l)
|
||||
#define zp_maxvallu ((long unsigned)+0xFFFFFFFFFFFFFFFFlu)
|
||||
#define zp_maxvall ((long) +0x7FFFFFFFFFFFFFFFl)
|
||||
|
||||
#define zp_fixint04 (0x1)
|
||||
#define zp_minvali04 zp_minvallu
|
||||
|
@ -225,7 +225,20 @@ zp_prv_ext typedef __int128 zp_i08s;
|
|||
|| zp_arc_arm64
|
||||
|
||||
#if \
|
||||
zp_sys_win
|
||||
zp_sys_dos
|
||||
|
||||
#if \
|
||||
zp_imp_msvc
|
||||
|
||||
#define zp_maxvalp ((zp_intptr)+0xFFFFFFFFFFFFFFFFu)
|
||||
typedef __int64 unsigned zp_intptr;
|
||||
|
||||
#define zp_maxvalz ((zp_sz)+0xFFFFFFFFFFFFFFFFu)
|
||||
typedef __int64 unsigned zp_sz;
|
||||
|
||||
#elif \
|
||||
zp_std_c99
|
||||
|| zp_std_cxx11
|
||||
|
||||
#define zp_maxvalp ((zp_intptr)+zp_maxvalllu)
|
||||
typedef long long unsigned zp_intptr;
|
||||
|
@ -233,6 +246,10 @@ typedef long long unsigned zp_intptr;
|
|||
#define zp_maxvalz ((zp_sz)+zp_maxvalllu)
|
||||
typedef long long unsigned zp_sz;
|
||||
|
||||
#else
|
||||
#error unable to implement types: calling convention uses long long, but no equivalent is supported
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define zp_maxvalp zp_maxvallu
|
||||
|
|
|
@ -12,48 +12,49 @@
|
|||
|
||||
namespace zp {
|
||||
namespace prv {
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto numdig(typ val,::zp::i8m bs) zp_prv_nthrw -> ::zp::sz;
|
||||
template<typename typ> zp_nthrw zp_useres ::zp::sz numdig(typ val,::zp::i8m bs);
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto strcpy(typ * dst, typ const * src) zp_prv_nthrw -> ::zp::sz;
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto strequ(typ const * lstr,typ const * rstr) zp_prv_nthrw -> bool;
|
||||
template<typename typ> zp_prv_constexpr auto strlen(typ const * str) zp_prv_nthrw -> ::zp::sz;
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto strsrh(typ * str, typ chr) zp_prv_nthrw -> typ *;
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto strsrh(typ const * str, typ chr) zp_prv_nthrw -> typ const *;
|
||||
zp_iln zp_nthrw inline ::zp::sz strcpy(char * dst, char const * src) {return ::zp_strcpy(dst,src);}
|
||||
zp_iln zp_nthrw zp_useres inline bool strequ(char const * lstr,char const * rstr) {return ::zp_strequ(lstr,rstr);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz strfil(char * str,char chr) {return ::zp_strfil(str,chr);}
|
||||
zp_iln zp_nthrw inline ::zp::sz strlen(char const * str) {return ::zp_strlen(str);}
|
||||
zp_iln zp_nthrw zp_useres inline char * strsrh(char * str, char chr) {return ::zp_strsrh(str,chr);}
|
||||
zp_iln zp_nthrw zp_useres inline char const * strsrh(char const * str, char chr) {return const_cast<char const *>(::zp_strsrh(str,chr));}
|
||||
|
||||
zp_useres zp_prv_constexpr auto utf8enclen( ::zp::c02 const * str) zp_prv_nthrw -> ::zp::sz;
|
||||
zp_useres zp_prv_constexpr auto utf8declen( ::zp::c8 const * str) zp_prv_nthrw -> ::zp::sz;
|
||||
zp_useres zp_prv_constexpr auto utf16enclen(::zp::c02 const * str) zp_prv_nthrw -> ::zp::sz;
|
||||
zp_useres zp_prv_constexpr auto utf16declen(::zp::c01 const * str) zp_prv_nthrw -> ::zp::sz;
|
||||
zp_iln zp_nthrw inline ::zp::sz wstrcpy(wchar_t * dst, wchar_t const * src) {return ::zp_wstrcpy(dst,src);}
|
||||
zp_iln zp_nthrw zp_useres inline bool wstrequ(wchar_t const * lstr,wchar_t const * rstr) {return ::zp_wstrequ(lstr,rstr);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz wstrfil(wchar_t * str,wchar_t chr) {return ::zp_wstrfil(str,chr);}
|
||||
zp_iln zp_nthrw inline ::zp::sz wstrlen(wchar_t const * str) {return ::zp_wstrlen(str);}
|
||||
zp_iln zp_nthrw zp_useres inline wchar_t * wstrsrh(wchar_t * str, wchar_t chr) {return ::zp_wstrsrh(str,chr);}
|
||||
zp_iln zp_nthrw zp_useres inline wchar_t const * wstrsrh(wchar_t const * str, wchar_t chr) {return const_cast<wchar_t const *>(::zp_wstrsrh(str,chr));}
|
||||
|
||||
zp_prv_constexpr auto utf8enc( ::zp::c8 * dst,::zp::c02 const * src) zp_prv_nthrw -> void;
|
||||
zp_prv_constexpr auto utf8dec( ::zp::c02 * dst,::zp::c8 const * src) zp_prv_nthrw -> void;
|
||||
zp_prv_constexpr auto utf16enc( ::zp::c01 * dst,::zp::c02 const * src) zp_prv_nthrw -> void;
|
||||
zp_prv_constexpr auto utf16dec( ::zp::c02 * dst,::zp::c01 const * src) zp_prv_nthrw -> void;
|
||||
zp_prv_constexpr auto win1252enc(::zp::c8 * dst,::zp::c02 const * src) zp_prv_nthrw -> void;
|
||||
zp_prv_constexpr auto win1252dec(::zp::c02 * dst,::zp::c8 const * src) zp_prv_nthrw -> void;
|
||||
zp_iln zp_nthrw inline ::zp::sz utf32cpy(::zp::c02 * dst, ::zp::c02 const * src) {return ::zp_utf32cpy(dst,src);}
|
||||
zp_iln zp_nthrw zp_useres inline bool utf32equ(::zp::c02 const * lstr,::zp::c02 const * rstr) {return ::zp_utf32equ(lstr,rstr);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz utf32fil(::zp::c02 * str, ::zp::c02 chr) {return ::zp_utf32fil(str,chr);}
|
||||
zp_iln zp_nthrw inline ::zp::sz utf32len(::zp::c02 const * str) {return ::zp_utf32len(str);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::c02 * utf32srh(::zp::c02 * str, ::zp::c02 chr) {return ::zp_utf32srh(str,chr);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::c02 const * utf32srh(::zp::c02 const * str, ::zp::c02 chr) {return const_cast< ::zp::c02 const *>(::zp_utf32srh(str,chr));}
|
||||
|
||||
template<typename typ> zp_useres zp_prv_constexpr auto fmtlen(typ val,::zp::i8m bs) zp_prv_nthrw -> ::zp::sz; // Including (potential) decorations.
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz utf8enclen( ::zp::c02 const * str) {return ::zp_utf8enclen(str);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz utf8declen( ::zp::c8 const * str) {return ::zp_utf8declen(str);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz utf16enclen(::zp::c02 const * str) {return ::zp_utf16enclen(str);}
|
||||
zp_iln zp_nthrw zp_useres inline ::zp::sz utf16declen(::zp::c01 const * str) {return ::zp_utf16declen(str);}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto fmt(::zp::c02 * buf,typ val,::zp::i8m bs,bool rtl = false) zp_prv_nthrw -> void;
|
||||
zp_iln zp_nthrw inline void utf8enc( ::zp::c8 * dst,::zp::c02 const * src) {return ::zp_utf8enc(dst,src);}
|
||||
zp_iln zp_nthrw inline void utf8dec( ::zp::c02 * dst,::zp::c8 const * src) {return ::zp_utf8dec(dst,src);}
|
||||
zp_iln zp_nthrw inline void utf16enc( ::zp::c01 * dst,::zp::c02 const * src) {return ::zp_utf16enc(dst,src);}
|
||||
zp_iln zp_nthrw inline void utf16dec( ::zp::c02 * dst,::zp::c01 const * src) {return ::zp_utf16dec(dst,src);}
|
||||
zp_iln zp_nthrw inline void win1252enc(::zp::c8 * dst,::zp::c02 const * src) {return ::zp_win1252enc(dst,src);}
|
||||
zp_iln zp_nthrw inline void win1252dec(::zp::c02 * dst,::zp::c8 const * src) {return ::zp_win1252dec(dst,src);}
|
||||
|
||||
//template<typename typ> zp_nthrw zp_useres ::zp::sz fmtlen(typ val,::zp::i8m bs); /* Including (potential) decorations. */
|
||||
|
||||
//template<typename typ> zp_nthrw void fmt(::zp::c02 * buf,typ val,::zp::i8m bs,bool rtl = false);
|
||||
}
|
||||
|
||||
#include <zp/str.d/fmt.ii>
|
||||
#include <zp/str.d/fmtlen.ii>
|
||||
//#include <zp/str.d/fmt.ii>
|
||||
//#include <zp/str.d/fmtlen.ii>
|
||||
#include <zp/str.d/numdig.ii>
|
||||
#include <zp/str.d/strcpy.ii>
|
||||
#include <zp/str.d/strequ.ii>
|
||||
#include <zp/str.d/strlen.ii>
|
||||
#include <zp/str.d/strsrh.ii>
|
||||
#include <zp/str.d/utf16dec.ii>
|
||||
#include <zp/str.d/utf16declen.ii>
|
||||
#include <zp/str.d/utf16enc.ii>
|
||||
#include <zp/str.d/utf16enclen.ii>
|
||||
#include <zp/str.d/utf8dec.ii>
|
||||
#include <zp/str.d/utf8declen.ii>
|
||||
#include <zp/str.d/utf8enc.ii>
|
||||
#include <zp/str.d/utf8enclen.ii>
|
||||
#include <zp/str.d/win1252dec.ii>
|
||||
#include <zp/str.d/win1252enc.ii>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename sgntyp> zp_prv_constexpr auto ::zp::fmt(::zp::c02 * buf,sgntyp sgnval,::zp::i8m const bs,bool const rtl) zp_prv_nthrw -> void {
|
||||
template<typename sgntyp> constexpr auto zp::fmt(::zp::c02 * buf,sgntyp sgnval,::zp::i8m const bs,bool const rtl) noexcept -> void {
|
||||
using typ = typename ::zp::usgn<sgntyp>::typ;
|
||||
|
||||
::zp::c02 const * digs = U"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
@ -20,10 +20,10 @@ template<typename sgntyp> zp_prv_constexpr auto ::zp::fmt(::zp::c02 * buf,sgntyp
|
|||
if (rtl) {
|
||||
buf += ::zp::prv::numdig(val,bs)-0x1u;
|
||||
|
||||
for (;val > 0x0u;val /= bs) *buf-- = digs[static_cast<::zp::sz>(val % static_cast<typ>(bs))];
|
||||
for (;val > 0x0u;val /= bs) *buf-- = digs[static_cast< ::zp::sz>(val % static_cast<typ>(bs))];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (;val > 0x0u;val /= bs) *buf++ = digs[static_cast<::zp::sz>(val % static_cast<typ>(bs))];
|
||||
for (;val > 0x0u;val /= bs) *buf++ = digs[static_cast< ::zp::sz>(val % static_cast<typ>(bs))];
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::fmtlen(typ val,::zp::i8m const bs) zp_prv_nthrw -> ::zp::sz {
|
||||
template<typename typ> constexpr auto zp::fmtlen(typ val,::zp::i8m const bs) noexcept -> ::zp::sz {
|
||||
static_assert(::zp::isint<typ>::val,"type must be an integral type");
|
||||
|
||||
::zp::sz len = 0x0u;
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::prv::numdig(typ fmtval,::zp::i8m const bs) zp_prv_nthrw -> ::zp::sz {
|
||||
static_assert(::zp::isint<typ>::val,"type must be an integral type");
|
||||
template<typename typ> zp_nthrw ::zp::sz zp::prv::numdig(typ fmtval,::zp::i8m const bs) {
|
||||
//static_assert(::zp::isint<typ>::val,"type must be an integral type");
|
||||
|
||||
if (fmtval == typ {0x0}) return 0x1u;
|
||||
if (fmtval == typ (0x0)) return 0x1u;
|
||||
|
||||
::zp::sz len = 0x0u;
|
||||
|
||||
for (typ val = fmtval;val > typ {0x0};val /= static_cast<typ>(bs)) {++len;}
|
||||
for (typ val = fmtval;val > typ (0x0);val /= static_cast<typ>(bs)) {++len;}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::strcpy(typ * dst,typ const * src) zp_prv_nthrw -> ::zp::sz {
|
||||
static_assert(::zp::ischr<typ>::val,"type must be a character type");
|
||||
|
||||
auto const dstsrt = dst;
|
||||
|
||||
while (*src != typ {0x0}) {*dst++ = *src++;}
|
||||
|
||||
return static_cast<::zp::sz>(dst-dstsrt); // Number of values copied.
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::strlen(typ const * str) zp_prv_nthrw -> ::zp::sz {
|
||||
static_assert(::zp::ischr<typ>::val,"type must be a character type"); // If the string format uses multiple values per character, the number of these values is returned (use utfXdeclen if the number of characters is needed).
|
||||
|
||||
auto const srt = str;
|
||||
|
||||
while (*str++ != typ {0x0}) {}
|
||||
|
||||
return static_cast<::zp::sz>(str-srt)-0x1u;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::strsrh(typ * str,typ const chr) zp_prv_nthrw -> typ * {
|
||||
return const_cast<typ *>(::zp::strsrh(const_cast<typ const *>(str),chr));
|
||||
}
|
||||
|
||||
template<typename typ> zp_prv_constexpr auto ::zp::strsrh(typ const * str,typ const chr) zp_prv_nthrw -> typ const * {
|
||||
static_assert(::zp::ischr<typ>::val,"type must be a character type");
|
||||
|
||||
for (;;++str) {
|
||||
auto const curchr = *str;
|
||||
|
||||
zp_ulik (curchr == chr) {return str;}
|
||||
zp_ulik (curchr == typ {0x0}) {break;}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf8dec(::zp::c02 * dst,::zp::c8 const * src) zp_prv_nthrw -> void {
|
||||
for (;;++dst) {
|
||||
auto const oct = *src++;
|
||||
|
||||
if (oct >= 0xF0u) { /* Four octets. */
|
||||
::zp::c02 chr = (static_cast<::zp::c02>(oct)^0xF0u)<<0x12u;
|
||||
|
||||
chr |= (static_cast<::zp::c02>(*src++)^0b10000000u)<<0xCu;
|
||||
chr |= (static_cast<::zp::c02>(*src++)^0b10000000u)<<0x6u;
|
||||
chr |= static_cast<::zp::c02>(*src++)^0b10000000u;
|
||||
|
||||
*dst = chr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oct >= 0xE0u) { /* Three octets. */
|
||||
::zp::c02 chr = (static_cast<::zp::c02>(oct)^0b11100000u)<<0xCu;
|
||||
|
||||
chr |= (static_cast<::zp::c02>(*src++)^0b10000000u)<<0x6u;
|
||||
chr |= static_cast<::zp::c02>(*src++)^0b10000000u;
|
||||
|
||||
*dst = chr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oct >= 0xC0u) { /* Two octets. */
|
||||
::zp::c02 chr = (static_cast<::zp::c02>(oct)^0b11000000u)<<0x6u;
|
||||
|
||||
chr |= static_cast<::zp::c02>(*src++)^0b10000000u;
|
||||
|
||||
*dst = chr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* One octet. */
|
||||
*dst = oct;
|
||||
++src;
|
||||
|
||||
zp_ulik (oct == 0x0u) {break;}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf8enc(::zp::c8 * dst,::zp::c02 const * src) zp_prv_nthrw -> void {
|
||||
for (;;++src) {
|
||||
auto const chr = *src;
|
||||
|
||||
if (chr > 0xFFFFu) { /* Four octets. */
|
||||
*dst++ = (chr>>0x12u) |0b11110000u;
|
||||
*dst++ = (chr>>0xCu &0b00111111u)|0b10000000u;
|
||||
*dst++ = (chr>>0x6u &0b00111111u)|0b10000000u;
|
||||
*dst++ = (chr &0b00111111u)|0b10000000u;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chr >= 0x7FFu) { /* Three octets. */
|
||||
*dst++ = (chr>>0xCu) |0b11100000u;
|
||||
*dst++ = (chr>>0x6u&0b00111111u)|0b10000000u;
|
||||
*dst++ = (chr &0b00111111u)|0b10000000u;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chr >= 0x7Fu) { /* Two octets. */
|
||||
*dst++ = (chr>>0x6u) |0b11000000u;
|
||||
*dst++ = (chr &0b00111111u)|0b10000000u;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* One octet. */
|
||||
*dst++ = chr;
|
||||
|
||||
zp_ulik (chr == 0x0u) {break;}
|
||||
}
|
||||
}
|
|
@ -13,16 +13,19 @@ zp_prv_cdecl
|
|||
|
||||
zp_nthrw zp_sz zp_strcpy(char * dst, char const * src);
|
||||
zp_nthrw zp_useres bool zp_strequ(char const * lstr,char const * rstr);
|
||||
zp_nthrw zp_sz zp_strfil(char * str, char chr);
|
||||
zp_nthrw zp_sz zp_strlen(char const * str);
|
||||
zp_nthrw char * zp_strsrh(char const * str, char chr);
|
||||
|
||||
zp_nthrw zp_sz zp_wstrcpy(zp_wchr * dst, zp_wchr const * src);
|
||||
zp_nthrw zp_useres bool zp_wstrequ(zp_wchr const * lstr,zp_wchr const * rstr);
|
||||
zp_nthrw zp_sz zp_wstrfil(zp_wchr * str, zp_wchr chr);
|
||||
zp_nthrw zp_sz zp_wstrlen(zp_wchr const * str);
|
||||
zp_nthrw zp_wchr * zp_wstrsrh(zp_wchr const * str, zp_wchr chr);
|
||||
|
||||
zp_nthrw zp_sz zp_utf32cpy(zp_c02 * dst, zp_c02 const * src);
|
||||
zp_nthrw zp_useres bool zp_utf32equ(zp_c02 const * lstr,zp_c02 const * rstr);
|
||||
zp_nthrw zp_sz zp_utf32fil(zp_c02 * str, zp_c02 chr);
|
||||
zp_nthrw zp_sz zp_utf32len(zp_c02 const * str);
|
||||
zp_nthrw zp_c02 * zp_utf32srh(zp_c02 const * str, zp_c02 chr);
|
||||
|
||||
|
@ -31,34 +34,38 @@ zp_nthrw zp_useres zp_sz zp_utf8declen( zp_c8 const * str);
|
|||
zp_nthrw zp_useres zp_sz zp_utf16enclen(zp_c02 const * str);
|
||||
zp_nthrw zp_useres zp_sz zp_utf16declen(zp_c01 const * str);
|
||||
|
||||
zp_nthrw void zp_utf8enc( zp_c8 * zp_restr dst,zp_c02 const * zp_restr src);
|
||||
zp_nthrw void zp_utf8dec( zp_c02 * zp_restr dst,zp_c8 const * zp_restr src);
|
||||
zp_nthrw void zp_utf16enc( zp_c01 * zp_restr dst,zp_c02 const * zp_restr src);
|
||||
zp_nthrw void zp_utf16dec( zp_c02 * zp_restr dst,zp_c01 const * zp_restr src);
|
||||
zp_nthrw void zp_win1252enc(zp_c8 * zp_restr dst,zp_c02 const * zp_restr src);
|
||||
zp_nthrw void zp_win1252dec(zp_c02 * zp_restr dst,zp_c8 const * zp_restr src);
|
||||
zp_nthrw void zp_utf8enc( zp_c8 * dst,zp_c02 const * src);
|
||||
zp_nthrw void zp_utf8dec( zp_c02 * dst,zp_c8 const * src);
|
||||
zp_nthrw void zp_utf16enc( zp_c01 * dst,zp_c02 const * src);
|
||||
zp_nthrw void zp_utf16dec( zp_c02 * dst,zp_c01 const * src);
|
||||
zp_nthrw void zp_win1252enc(zp_c8 * dst,zp_c02 const * src);
|
||||
zp_nthrw void zp_win1252dec(zp_c02 * dst,zp_c8 const * src);
|
||||
|
||||
zp_nthrw zp_useres zp_sz zp_fmtleni( int val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenl( long val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenll( long long val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlens( short val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlensc( char signed val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenuc( char unsigned val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenui( int unsigned val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenul( long unsigned val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenull(long long unsigned val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenus( short unsigned val,zp_i8m bs);
|
||||
#if zp_std_c99 || zp_std_cxx11
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenll( long long val,zp_i8m bs);
|
||||
zp_nthrw zp_useres zp_sz zp_fmtlenull(long long unsigned val,zp_i8m bs);
|
||||
#endif
|
||||
|
||||
zp_nthrw void zp_fmti( zp_c02 * buf,int val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtl( zp_c02 * buf,long val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtll( zp_c02 * buf,long long val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmts( zp_c02 * buf,short val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtsc( zp_c02 * buf,char signed val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtuc( zp_c02 * buf,char unsigned val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtui( zp_c02 * buf,int unsigned val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtul( zp_c02 * buf,long unsigned val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtull(zp_c02 * buf,long long unsigned val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtus( zp_c02 * buf,short unsigned val,zp_i8m bs,bool rtl);
|
||||
#if zp_std_c99 || zp_std_cxx11
|
||||
zp_nthrw void zp_fmtll( zp_c02 * buf,long long val,zp_i8m bs,bool rtl);
|
||||
zp_nthrw void zp_fmtull(zp_c02 * buf,long long unsigned val,zp_i8m bs,bool rtl);
|
||||
#endif
|
||||
|
||||
zp_prv_cdeclend
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ zp_memcpy:
|
|||
; int unsigned128_t val01;
|
||||
; int unsigned256_t val02;
|
||||
|
||||
.big02cpy: ; big02cpy:; // We assume AVX.
|
||||
.big02cpy: ; big02cpy:; /* We assume AVX. */
|
||||
cmp rdx,0x20
|
||||
jl short .big01cpy ; if (rem < 0x20u) goto big01cpy;
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
inline auto ::zp::urch() zp_prv_nthrw -> void {
|
||||
zp_urch();
|
||||
#include <zp/bs.h>
|
||||
|
||||
zp_sysclres zp_syscl(zp_nuse zp_sysclid id,...) {
|
||||
zp_urch(); /* Unsupported. */
|
||||
}
|
|
@ -4,10 +4,10 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/bs>
|
||||
#include <zp/bs.h>
|
||||
|
||||
extern "C" void zp_trp() {
|
||||
#if zp_prv_hasbuiltin(__builtin_trap)
|
||||
void zp_trp(void) {
|
||||
#if zp_prv_hasbltin(__builtin_trap)
|
||||
__builtin_trap();
|
||||
#endif
|
||||
for (;;) {}
|
23
zp/source/any/mem/memcpy.c
Normal file
23
zp/source/any/mem/memcpy.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem.h>
|
||||
|
||||
zp_nthrw struct zp_cpyres zp_memcpy(void * const dstptr,void const * const srcptr,zp_sz const num) {
|
||||
struct zp_cpyres res;
|
||||
|
||||
char unsigned * dst = dstptr;
|
||||
char unsigned const * src = srcptr;
|
||||
|
||||
char unsigned * const stp = dst+num;
|
||||
|
||||
while (dst != stp) {*dst++ = *src++;}
|
||||
|
||||
res.dst = dst;
|
||||
res.src = (char unsigned *)src;
|
||||
|
||||
return res;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem>
|
||||
|
||||
extern "C" zp_nthrw auto zp_memcpy(void * const zp_restr dst,void const * const zp_restr src,zp_sz const num) -> struct zp_cpyres {
|
||||
auto const ret = ::zp::cpy(static_cast<char unsigned *>(dst),static_cast<char unsigned const *>(src),num);
|
||||
|
||||
return ::zp_cpyres {
|
||||
ret.dst,
|
||||
ret.src,
|
||||
};
|
||||
}
|
20
zp/source/any/mem/memequ.c
Normal file
20
zp/source/any/mem/memequ.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem.h>
|
||||
|
||||
bool zp_memequ(void const * const lbufptr,void const * const rbufptr,zp_sz const num) {
|
||||
char unsigned const * lbuf = lbufptr;
|
||||
char unsigned const * rbuf = rbufptr;
|
||||
|
||||
char unsigned const * const stp = lbuf+num;
|
||||
|
||||
while (lbuf != stp) {
|
||||
zp_lik (*lbuf++ != *rbuf++) {return false;}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem>
|
||||
|
||||
extern "C" zp_nthrw auto zp_memequ(void const * const lbuf,void const * const rbuf,::zp::sz const num) -> bool {
|
||||
return ::zp::equ(static_cast<char unsigned const *>(lbuf),static_cast<char unsigned const *>(rbuf),num);
|
||||
}
|
|
@ -4,6 +4,14 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
template<typename... typs> inline auto ::zp::syscl(::zp::sysclid const id,typs const &... args) zp_prv_nthrw -> ::zp::sysclres {
|
||||
return ::zp_syscl(id,args...);
|
||||
#include <zp/mem.h>
|
||||
|
||||
void * zp_memfil(void * const bufptr,char unsigned const val,zp_sz const num) {
|
||||
char unsigned * buf = bufptr;
|
||||
|
||||
char unsigned * const stp = buf+num;
|
||||
|
||||
while (buf != stp) {*buf++ = val;}
|
||||
|
||||
return stp;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem>
|
||||
|
||||
extern "C" zp_nthrw auto zp_memfil(void * const dst,char unsigned const val,::zp::sz const num) -> void * {
|
||||
return ::zp::fil(static_cast<char unsigned *>(dst),val,num);
|
||||
}
|
21
zp/source/any/mem/memsrh.c
Normal file
21
zp/source/any/mem/memsrh.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem.h>
|
||||
|
||||
void * zp_memsrh(void const * const bufptr,char unsigned const val,zp_sz const num) {
|
||||
char unsigned const * buf = bufptr;
|
||||
|
||||
char unsigned const * const stp = buf+num;
|
||||
|
||||
while (buf != stp) {
|
||||
char unsigned const * const addr = buf++;
|
||||
|
||||
zp_ulik (*addr == val) {return (char unsigned *)addr;}
|
||||
}
|
||||
|
||||
return zp_nulptr;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/mem>
|
||||
|
||||
extern "C" zp_nthrw auto zp_memsrh(void const * const buf,char unsigned const val,::zp::sz const num) -> void * {
|
||||
return const_cast<char unsigned *>(::zp::srh(static_cast<char unsigned const *>(buf),val,num));
|
||||
}
|
|
@ -7,9 +7,9 @@
|
|||
#include <zp/mth>
|
||||
|
||||
extern "C" {
|
||||
zp_nthrw auto zp_divmodsc(char signed const num,char signed const den) -> ::zp_pairsc {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmods( short const num,short const den) -> ::zp_pairs {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodi( int const num,int const den) -> ::zp_pairi {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodl( long const num,long const den) -> ::zp_pairl {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodll(long long const num,long long const den) -> ::zp_pairll {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodsc(char signed const num,char signed const den) -> ::divmodressc {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmods( short const num,short const den) -> ::divmodress {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodi( int const num,int const den) -> ::divmodresi {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodl( long const num,long const den) -> ::divmodresl {return ::zp::divmod(num,den).cpair();}
|
||||
zp_nthrw auto zp_divmodll(long long const num,long long const den) -> ::divmodresll {return ::zp::divmod(num,den).cpair();}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#include <zp/mth>
|
||||
|
||||
extern "C" {
|
||||
zp_nthrw auto zp_v2addf( ::zp_vec2f const lvec,::zp_vec2f const rvec) -> ::zp_vec2f {return ::zp::vadd(::zp::vec2<float> {lvec.x,lvec.y,},::zp::vec2<float> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_v2addd( ::zp_vec2d const lvec,::zp_vec2d const rvec) -> ::zp_vec2d {return ::zp::vadd(::zp::vec2<double> {lvec.x,lvec.y,},::zp::vec2<double> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_v2addld(::zp_vec2ld const lvec,::zp_vec2ld const rvec) -> ::zp_vec2ld {return ::zp::vadd(::zp::vec2<long double> {lvec.x,lvec.y,},::zp::vec2<long double> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_vadd2f( ::zp_vec2f const lvec,::zp_vec2f const rvec) -> ::zp_vec2f {return ::zp::vadd(::zp::vec2<float> {lvec.x,lvec.y,},::zp::vec2<float> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_vadd2d( ::zp_vec2d const lvec,::zp_vec2d const rvec) -> ::zp_vec2d {return ::zp::vadd(::zp::vec2<double> {lvec.x,lvec.y,},::zp::vec2<double> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_vadd2ld(::zp_vec2ld const lvec,::zp_vec2ld const rvec) -> ::zp_vec2ld {return ::zp::vadd(::zp::vec2<long double> {lvec.x,lvec.y,},::zp::vec2<long double> {rvec.x,rvec.y,}).cvec();}
|
||||
|
||||
zp_nthrw auto zp_v3addf( ::zp_vec3f const lvec,::zp_vec3f const rvec) -> ::zp_vec3f {return ::zp::vadd(::zp::vec3<float> {lvec.x,lvec.y,lvec.z,},::zp::vec3<float> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_v3addd( ::zp_vec3d const lvec,::zp_vec3d const rvec) -> ::zp_vec3d {return ::zp::vadd(::zp::vec3<double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_v3addld(::zp_vec3ld const lvec,::zp_vec3ld const rvec) -> ::zp_vec3ld {return ::zp::vadd(::zp::vec3<long double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<long double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_vadd3f( ::zp_vec3f const lvec,::zp_vec3f const rvec) -> ::zp_vec3f {return ::zp::vadd(::zp::vec3<float> {lvec.x,lvec.y,lvec.z,},::zp::vec3<float> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_vadd3d( ::zp_vec3d const lvec,::zp_vec3d const rvec) -> ::zp_vec3d {return ::zp::vadd(::zp::vec3<double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_vadd3ld(::zp_vec3ld const lvec,::zp_vec3ld const rvec) -> ::zp_vec3ld {return ::zp::vadd(::zp::vec3<long double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<long double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
|
||||
zp_nthrw auto zp_v4addf( ::zp_vec4f const lvec,::zp_vec4f const rvec) -> ::zp_vec4f {return ::zp::vadd(::zp::vec4<float> {lvec.x,lvec.y,lvec.z,lvec.w,},::zp::vec4<float> {rvec.x,rvec.y,rvec.z,rvec.w,}).cvec();}
|
||||
zp_nthrw auto zp_v4addd( ::zp_vec4d const lvec,::zp_vec4d const rvec) -> ::zp_vec4d {return ::zp::vadd(::zp::vec4<double> {lvec.x,lvec.y,lvec.z,lvec.w,},::zp::vec4<double> {rvec.x,rvec.y,rvec.z,rvec.w,}).cvec();}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#include <zp/mth>
|
||||
|
||||
extern "C" {
|
||||
zp_nthrw auto zp_v2subf( ::zp_vec2f const lvec,::zp_vec2f const rvec) -> ::zp_vec2f {return ::zp::vsub(::zp::vec2<float> {lvec.x,lvec.y,},::zp::vec2<float> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_v2subd( ::zp_vec2d const lvec,::zp_vec2d const rvec) -> ::zp_vec2d {return ::zp::vsub(::zp::vec2<double> {lvec.x,lvec.y,},::zp::vec2<double> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_v2subld(::zp_vec2ld const lvec,::zp_vec2ld const rvec) -> ::zp_vec2ld {return ::zp::vsub(::zp::vec2<long double> {lvec.x,lvec.y,},::zp::vec2<long double> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_vsub2f( ::zp_vec2f const lvec,::zp_vec2f const rvec) -> ::zp_vec2f {return ::zp::vsub(::zp::vec2<float> {lvec.x,lvec.y,},::zp::vec2<float> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_vsub2d( ::zp_vec2d const lvec,::zp_vec2d const rvec) -> ::zp_vec2d {return ::zp::vsub(::zp::vec2<double> {lvec.x,lvec.y,},::zp::vec2<double> {rvec.x,rvec.y,}).cvec();}
|
||||
zp_nthrw auto zp_vsub2ld(::zp_vec2ld const lvec,::zp_vec2ld const rvec) -> ::zp_vec2ld {return ::zp::vsub(::zp::vec2<long double> {lvec.x,lvec.y,},::zp::vec2<long double> {rvec.x,rvec.y,}).cvec();}
|
||||
|
||||
zp_nthrw auto zp_v3subf( ::zp_vec3f const lvec,::zp_vec3f const rvec) -> ::zp_vec3f {return ::zp::vsub(::zp::vec3<float> {lvec.x,lvec.y,lvec.z,},::zp::vec3<float> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_v3subd( ::zp_vec3d const lvec,::zp_vec3d const rvec) -> ::zp_vec3d {return ::zp::vsub(::zp::vec3<double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_v3subld(::zp_vec3ld const lvec,::zp_vec3ld const rvec) -> ::zp_vec3ld {return ::zp::vsub(::zp::vec3<long double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<long double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_vsub3f( ::zp_vec3f const lvec,::zp_vec3f const rvec) -> ::zp_vec3f {return ::zp::vsub(::zp::vec3<float> {lvec.x,lvec.y,lvec.z,},::zp::vec3<float> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_vsub3d( ::zp_vec3d const lvec,::zp_vec3d const rvec) -> ::zp_vec3d {return ::zp::vsub(::zp::vec3<double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
zp_nthrw auto zp_vsub3ld(::zp_vec3ld const lvec,::zp_vec3ld const rvec) -> ::zp_vec3ld {return ::zp::vsub(::zp::vec3<long double> {lvec.x,lvec.y,lvec.z,},::zp::vec3<long double> {rvec.x,rvec.y,rvec.z,}).cvec();}
|
||||
|
||||
zp_nthrw auto zp_v4subf( ::zp_vec4f const lvec,::zp_vec4f const rvec) -> ::zp_vec4f {return ::zp::vsub(::zp::vec4<float> {lvec.x,lvec.y,lvec.z,lvec.w,},::zp::vec4<float> {rvec.x,rvec.y,rvec.z,rvec.w,}).cvec();}
|
||||
zp_nthrw auto zp_v4subd( ::zp_vec4d const lvec,::zp_vec4d const rvec) -> ::zp_vec4d {return ::zp::vsub(::zp::vec4<double> {lvec.x,lvec.y,lvec.z,lvec.w,},::zp::vec4<double> {rvec.x,rvec.y,rvec.z,rvec.w,}).cvec();}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" {
|
||||
/*extern "C" {
|
||||
zp_nthrw auto zp_fmti( char32_t * const buf,int const val,::zp::i8m const bs,bool const rtl) -> void {return ::zp::fmt(buf,val,bs,rtl);}
|
||||
zp_nthrw auto zp_fmtl( char32_t * const buf,long const val,::zp::i8m const bs,bool const rtl) -> void {return ::zp::fmt(buf,val,bs,rtl);}
|
||||
zp_nthrw auto zp_fmtll( char32_t * const buf,long long const val,::zp::i8m const bs,bool const rtl) -> void {return ::zp::fmt(buf,val,bs,rtl);}
|
||||
|
@ -17,4 +17,4 @@ extern "C" {
|
|||
zp_nthrw auto zp_fmtul( char32_t * const buf,long unsigned const val,::zp::i8m const bs,bool const rtl) -> void {return ::zp::fmt(buf,val,bs,rtl);}
|
||||
zp_nthrw auto zp_fmtull(char32_t * const buf,long long unsigned const val,::zp::i8m const bs,bool const rtl) -> void {return ::zp::fmt(buf,val,bs,rtl);}
|
||||
zp_nthrw auto zp_fmtus( char32_t * const buf,short unsigned const val,::zp::i8m const bs,bool const rtl) -> void {return ::zp::fmt(buf,val,bs,rtl);}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <zp/mth>
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" {
|
||||
/* extern "C" {
|
||||
zp_nthrw auto zp_fmtleni( int const val,::zp::i8m const bs) -> ::zp::sz {return ::zp::fmtlen(val,bs);}
|
||||
zp_nthrw auto zp_fmtlenl( long const val,::zp::i8m const bs) -> ::zp::sz {return ::zp::fmtlen(val,bs);}
|
||||
zp_nthrw auto zp_fmtlenll( long long const val,::zp::i8m const bs) -> ::zp::sz {return ::zp::fmtlen(val,bs);}
|
||||
|
@ -18,4 +18,4 @@ extern "C" {
|
|||
zp_nthrw auto zp_fmtlenul( long unsigned const val,::zp::i8m const bs) -> ::zp::sz {return ::zp::fmtlen(val,bs);}
|
||||
zp_nthrw auto zp_fmtlenull(long long unsigned const val,::zp::i8m const bs) -> ::zp::sz {return ::zp::fmtlen(val,bs);}
|
||||
zp_nthrw auto zp_fmtlenus( short unsigned const val,::zp::i8m const bs) -> ::zp::sz {return ::zp::fmtlen(val,bs);}
|
||||
}
|
||||
} */
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_strcpy(char * const dst,char const * const src) -> ::zp::sz {
|
||||
return ::zp::strcpy(dst,src);
|
||||
extern "C" zp_nthrw ::zp::sz zp_strcpy(char * const dst,char const * const src) {
|
||||
return ::zp::det::strcpy(dst,src);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_strequ(char const * const lstr,char const * const rstr) -> bool {
|
||||
return ::zp::strequ(lstr,rstr);
|
||||
extern "C" zp_nthrw bool zp_strequ(char const * const lstr,char const * const rstr) {
|
||||
return ::zp::det::strequ(lstr,rstr);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/bs>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" ::zp::sysclres zp_syscl(zp_nuse ::zp::sysclid id,...) {
|
||||
::zp::urch(); // Unsupported.
|
||||
extern "C" zp_nthrw bool zp_strfil(char * const str,char const chr) {
|
||||
return ::zp::det::strfil(str,chr);
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_strlen(char const * const str) -> ::zp::sz {
|
||||
return ::zp::strlen(str);
|
||||
extern "C" zp_nthrw ::zp::sz zp_strlen(char const * const str) {
|
||||
return ::zp::det::strlen(str);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_strsrh(char const * const str,char const chr) -> char * {
|
||||
return const_cast<char *>(::zp::strsrh(str,chr));
|
||||
extern "C" zp_nthrw char * zp_strsrh(char const * const str,char const chr) {
|
||||
return ::zp::det::strsrh(str,chr);
|
||||
}
|
||||
|
|
|
@ -4,14 +4,16 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf16dec(::zp::c02 * dst,::zp::c01 const * src) zp_prv_nthrw -> void {
|
||||
#include <zp/str.h>
|
||||
|
||||
void zp_utf16dec(zp_c02 * dst,zp_c01 const * src) {
|
||||
for (;;++dst) {
|
||||
auto const hex = *src++;
|
||||
zp_c01 const hex = *src++;
|
||||
|
||||
if (hex >= 0xD800u && hex < 0xDC00u) {
|
||||
::zp::c02 chr = (static_cast<::zp::c02>(hex)^0b1101100000000000u)<<0xAu;
|
||||
zp_c02 chr = ((zp_c02)hex^0xD800u)<<0xAu;
|
||||
|
||||
chr |= static_cast<::zp::c02>(*src++)^0b1101110000000000u;
|
||||
chr |= (zp_c02)(*src++)^0xDC00u;
|
||||
|
||||
*dst = chr+0x10000u;
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf16dec(::zp::c02 * const dst,::zp::c01 const * const src) -> void {
|
||||
return ::zp::utf16dec(dst,src);
|
||||
}
|
|
@ -4,18 +4,20 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf16declen(::zp::c01 const * str) zp_prv_nthrw -> ::zp::sz {
|
||||
::zp::sz len = 0x0u;
|
||||
#include <zp/str.h>
|
||||
|
||||
zp_sz zp_utf16declen(zp_c01 const * str) {
|
||||
zp_sz len = 0x0u;
|
||||
|
||||
for (;;++len) {
|
||||
auto const chr = *str;
|
||||
zp_c01 const hex = *str;
|
||||
|
||||
if (chr >= 0xD800u && chr < 0xDC00u) {
|
||||
if (hex >= 0xD800u && hex < 0xDC00u) {
|
||||
str += 0x2u;
|
||||
continue;
|
||||
}
|
||||
|
||||
zp_ulik (chr == 0x0u) {break;}
|
||||
zp_ulik (hex == 0x0u) {break;}
|
||||
|
||||
++str;
|
||||
}
|
|
@ -4,15 +4,17 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf16enc(::zp::c01 * dst,::zp::c02 const * src) zp_prv_nthrw -> void {
|
||||
#include <zp/str.h>
|
||||
|
||||
void zp_utf16enc(zp_c01 * dst,zp_c02 const * src) {
|
||||
for (;;++src) {
|
||||
auto const chr = *src;
|
||||
zp_c02 const chr = *src;
|
||||
|
||||
if (chr > 0xFFFFu) { /* Two hextets. */
|
||||
::zp::c02 const tmp = chr-0x10000u;
|
||||
zp_c02 const tmp = chr-0x10000u;
|
||||
|
||||
*dst++ = (tmp>>0xAu) |0b1101100000000000u;
|
||||
*dst++ = (tmp &0b0000001111111111u)|0b1101110000000000u;
|
||||
*dst++ = (tmp>>0xAu) |0xD800u;
|
||||
*dst++ = (tmp &0x3FFu)|0xDC00u;
|
||||
|
||||
continue;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf16enc(::zp::c01 * const dst,::zp::c02 const * const src) -> void {
|
||||
return ::zp::utf16enc(dst,src);
|
||||
}
|
|
@ -4,11 +4,13 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf16enclen(::zp::c02 const * str) zp_prv_nthrw -> ::zp::sz {
|
||||
::zp::sz len = 0x0u;
|
||||
#include <zp/str.h>
|
||||
|
||||
zp_sz zp_utf16enclen(zp_c02 const * str) {
|
||||
zp_sz len = 0x0u;
|
||||
|
||||
for (;;++str) {
|
||||
auto const chr = *str;
|
||||
zp_c02 const chr = *str;
|
||||
|
||||
if (chr > 0xFFFFu) {
|
||||
len += 0x2u;
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf32cpy(::zp::c02 * const dst,::zp::c02 const * const src) -> ::zp::sz {
|
||||
return ::zp::strcpy(dst,src);
|
||||
extern "C" zp_nthrw ::zp::sz zp_utf32cpy(::zp::c02 * const dst,::zp::c02 const * const src) {
|
||||
return ::zp::det::strcpy(dst,src);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf32equ(::zp::c02 const * const lstr,::zp::c02 const * const rstr) -> bool {
|
||||
return ::zp::strequ(lstr,rstr);
|
||||
extern "C" zp_nthrw bool zp_utf32equ(::zp::c02 const * const lstr,::zp::c02 const * const rstr) {
|
||||
return ::zp::det::strequ(lstr,rstr);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf16declen(::zp::c01 const * const str) -> ::zp::sz {
|
||||
return ::zp::utf16declen(str);
|
||||
extern "C" zp_nthrw bool zp_utf32fil(::zp::c02 * const str,::zp::c02 const chr) {
|
||||
return ::zp::det::strfil(str,chr);
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf32len(::zp::c02 const * const str) -> ::zp::sz {
|
||||
return ::zp::strlen(str);
|
||||
extern "C" zp_nthrw ::zp::sz zp_utf32len(::zp::c02 const * const str) {
|
||||
return ::zp::det::strlen(str);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf32srh(::zp::c02 const * const str,::zp::c02 const chr) -> ::zp::c02 * {
|
||||
return const_cast<::zp::c02 *>(::zp::strsrh(str,chr));
|
||||
extern "C" zp_nthrw ::zp::c02 * zp_utf32srh(::zp::c02 const * const str,::zp::c02 const chr) {
|
||||
return ::zp::det::strsrh(str,chr);
|
||||
}
|
||||
|
|
52
zp/source/any/str/utf8dec.c
Normal file
52
zp/source/any/str/utf8dec.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str.h>
|
||||
|
||||
void zp_utf8dec(zp_c02 * dst,zp_c8 const * src) {
|
||||
for (;;++dst) {
|
||||
zp_c8 const oct = *src++;
|
||||
|
||||
if (oct >= 0xF0u) { /* Four octets. */
|
||||
zp_c02 chr = ((zp_c02)oct^0xF0u)<<0x12u;
|
||||
|
||||
chr |= ((zp_c02)(*src++)^0x80u)<<0xCu;
|
||||
chr |= ((zp_c02)(*src++)^0x80u)<<0x6u;
|
||||
chr |= (zp_c02)(*src++)^0x80u;
|
||||
|
||||
*dst = chr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oct >= 0xE0u) { /* Three octets. */
|
||||
zp_c02 chr = ((zp_c02)oct^0xE0u)<<0xCu;
|
||||
|
||||
chr |= ((zp_c02)(*src++)^0x80u)<<0x6u;
|
||||
chr |= (zp_c02)(*src++)^0x80u;
|
||||
|
||||
*dst = chr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oct >= 0xC0u) { /* Two octets. */
|
||||
zp_c02 chr = ((zp_c02)oct^0xC0u)<<0x6u;
|
||||
|
||||
chr |= (zp_c02)(*src++)^0x80u;
|
||||
|
||||
*dst = chr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* One octet. */
|
||||
*dst = oct;
|
||||
++src;
|
||||
|
||||
zp_ulik (oct == 0x0u) {break;}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf8dec(::zp::c02 * const dst,::zp::c8 const * const src) -> void {
|
||||
return ::zp::utf8dec(dst,src);
|
||||
}
|
|
@ -4,11 +4,13 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf8declen(::zp::c8 const * str) zp_prv_nthrw -> ::zp::sz {
|
||||
::zp::sz len = 0x0u;
|
||||
#include <zp/str.h>
|
||||
|
||||
zp_sz zp_utf8declen(zp_c8 const * str) {
|
||||
zp_sz len = 0x0u;
|
||||
|
||||
for (;;++len) {
|
||||
auto const oct = *str;
|
||||
zp_c8 const oct = *str;
|
||||
|
||||
zp_ulik (oct == 0x0u) {break;}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf8declen(::zp::c8 const * const str) -> ::zp::sz {
|
||||
return ::zp::utf8declen(str);
|
||||
}
|
42
zp/source/any/str/utf8enc.c
Normal file
42
zp/source/any/str/utf8enc.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str.h>
|
||||
|
||||
void zp_utf8enc(zp_c8 * dst,zp_c02 const * src) {
|
||||
for (;;++src) {
|
||||
zp_c02 const chr = *src;
|
||||
|
||||
if (chr > 0xFFFFu) { /* Four octets. */
|
||||
*dst++ = (chr>>0x12u) |0xF0u;
|
||||
*dst++ = (chr>>0xCu &0x3Fu)|0x80u;
|
||||
*dst++ = (chr>>0x6u &0x3Fu)|0x80u;
|
||||
*dst++ = (chr &0x3Fu)|0x80u;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chr >= 0x7FFu) { /* Three octets. */
|
||||
*dst++ = (chr>>0xCu) |0xE0u;
|
||||
*dst++ = (chr>>0x6u&0x3Fu)|0x80u;
|
||||
*dst++ = (chr &0x3Fu)|0x80u;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chr >= 0x7Fu) { /* Two octets. */
|
||||
*dst++ = (chr>>0x6u) |0xC0u;
|
||||
*dst++ = (chr &0x3Fu)|0x80u;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* One octet. */
|
||||
*dst++ = chr;
|
||||
|
||||
zp_ulik (chr == 0x0u) {break;}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf8enc(::zp::c8 * const dst,::zp::c02 const * const src) -> void {
|
||||
return ::zp::utf8enc(dst,src);
|
||||
}
|
|
@ -4,11 +4,13 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::utf8enclen(::zp::c02 const * str) zp_prv_nthrw -> ::zp::sz {
|
||||
::zp::sz len = 0x0u;
|
||||
#include <zp/str.h>
|
||||
|
||||
zp_sz zp_utf8enclen(zp_c02 const * str) {
|
||||
zp_sz len = 0x0u;
|
||||
|
||||
for (;;++str) {
|
||||
auto const chr = *str;
|
||||
zp_c02 const chr = *str;
|
||||
|
||||
if (chr >= 0x10000u) {
|
||||
len += 0x4u;
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf8enclen(::zp::c02 const * const str) -> ::zp::sz {
|
||||
return ::zp::utf8enclen(str);
|
||||
}
|
|
@ -4,9 +4,11 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::win1252dec(::zp::c02 * dst,::zp::c8 const * src) zp_prv_nthrw -> void {
|
||||
#include <zp/str.h>
|
||||
|
||||
void zp_win1252dec(zp_c02 * dst,zp_c8 const * src) {
|
||||
for (;;++src,++dst) {
|
||||
::zp::c8 const chr = *src;
|
||||
zp_c8 const chr = *src;
|
||||
|
||||
switch (chr) {
|
||||
default:
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_win1252dec(::zp::c02 * const dst,::zp::c8 const * const src) -> void {
|
||||
return ::zp::win1252dec(dst,src);
|
||||
}
|
|
@ -4,11 +4,13 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
zp_prv_constexpr auto ::zp::win1252enc(::zp::c8 * dst,::zp::c02 const * src) zp_prv_nthrw -> void {
|
||||
for (;;++src,++dst) {
|
||||
::zp::c02 const chr = *src;
|
||||
#include <zp/str.h>
|
||||
|
||||
constexpr ::zp::c8 bad = 0x3Fu;
|
||||
void zp_win1252enc(zp_c8 * dst,zp_c02 const * src) {
|
||||
for (;;++src,++dst) {
|
||||
zp_c02 const chr = *src;
|
||||
|
||||
zp_c8 const bad = 0x3Fu;
|
||||
|
||||
switch (chr) {
|
||||
default:
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
Copyright 2022-2023 Gabriel Jensen.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
|
||||
extern "C" zp_nthrw auto zp_win1252enc(::zp::c8 * const dst,::zp::c02 const * const src) -> void {
|
||||
return ::zp::win1252enc(dst,src);
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_wstrcpy(::zp::wchr * const dst,::zp::wchr const * const src) -> ::zp::sz {
|
||||
return ::zp::strcpy(dst,src);
|
||||
extern "C" zp_nthrw ::zp::sz zp_wstrcpy(::zp::wchr * const dst,::zp::wchr const * const src) {
|
||||
return ::zp::det::strcpy(dst,src);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_wstrequ(::zp::wchr const * const lstr,::zp::wchr const * const rstr) -> bool {
|
||||
return ::zp::strequ(lstr,rstr);
|
||||
extern "C" zp_nthrw bool zp_wstrequ(::zp::wchr const * const lstr,::zp::wchr const * const rstr) {
|
||||
return ::zp::det::strequ(lstr,rstr);;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_utf16enclen(::zp::c02 const * const str) -> ::zp::sz {
|
||||
return ::zp::utf16enclen(str);
|
||||
extern "C" zp_nthrw bool zp_wstrfil(::zp::wchr * const str,::zp::wchr const chr) {
|
||||
return ::zp::det::strfil(str,chr);
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#include <zp/str>
|
||||
#include <zp/prv>
|
||||
|
||||
extern "C" zp_nthrw auto zp_wstrlen(::zp::wchr const * const str) -> ::zp::sz {
|
||||
return ::zp::strlen(str);
|
||||
extern "C" zp_nthrw ::zp::sz zp_wstrlen(::zp::wchr const * const str) {
|
||||
return ::zp::det::strlen(str);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue