[ox/std] Fix packed errors
This commit is contained in:
		
							
								
								
									
										30
									
								
								deps/ox/src/ox/std/assert.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								deps/ox/src/ox/std/assert.cpp
									
									
									
									
										vendored
									
									
								
							| @@ -6,17 +6,19 @@ | ||||
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||
|  */ | ||||
|  | ||||
| #if defined(OX_USE_STDLIB) | ||||
| #include <bitset> | ||||
| #include <iostream> | ||||
| #endif | ||||
|  | ||||
| #include <ox/__buildinfo/defines.hpp> | ||||
|  | ||||
| #if defined(OX_USE_STDLIB) | ||||
|  | ||||
| #include <iostream> | ||||
|  | ||||
| #endif | ||||
| #include "assert.hpp" | ||||
|  | ||||
| namespace ox { | ||||
|  | ||||
| void _assert([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) { | ||||
| template<> | ||||
| void _assert<bool>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) { | ||||
| #if defined(OX_USE_STDLIB) | ||||
| 	if (!pass) { | ||||
| 		std::cerr << "\033[31;1;1mASSERT FAILURE:\033[0m (" << file << ':' << line << "): " << msg << std::endl; | ||||
| @@ -25,4 +27,20 @@ void _assert([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe | ||||
| #endif | ||||
| } | ||||
|  | ||||
| template<> | ||||
| void _assert<Error>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg) { | ||||
| #if defined(OX_USE_STDLIB) | ||||
| 	if (err) { | ||||
| 		auto ei = ErrorInfo(err); | ||||
| 		std::cerr << "\033[31;1;1mASSERT FAILURE:\033[0m (" << file << ':' << line << "): " << msg << '\n'; | ||||
| 		std::cerr <<  "\tError Info: " << ei.errCode; | ||||
| 		if (ei.file != nullptr) { | ||||
| 			std::cerr << " (" << reinterpret_cast<const char*>(ei.file) << ':' << ei.line << ')'; | ||||
| 		} | ||||
| 		std::cerr << std::endl; | ||||
| 		std::abort(); | ||||
| 	} | ||||
| #endif | ||||
| } | ||||
|  | ||||
| } | ||||
|   | ||||
							
								
								
									
										20
									
								
								deps/ox/src/ox/std/assert.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								deps/ox/src/ox/std/assert.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -8,14 +8,30 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #if defined(OX_USE_STDLIB) | ||||
| #include <iostream> | ||||
| #endif | ||||
|  | ||||
| #include <ox/__buildinfo/defines.hpp> | ||||
|  | ||||
| #include "types.hpp" | ||||
|  | ||||
| namespace ox { | ||||
|  | ||||
| void _assert(const char *file, int line, bool pass, const char *msg); | ||||
| template<typename T> | ||||
| void _assert(const char*, int, T, const char*) { | ||||
| } | ||||
|  | ||||
| template<> | ||||
| void _assert<bool>(const char *file, int line, bool pass, const char *msg); | ||||
|  | ||||
| template<> | ||||
| void _assert<Error>(const char *file, int line, Error err, const char*); | ||||
|  | ||||
| } | ||||
|  | ||||
| #ifndef NDEBUG | ||||
| #define oxAssert(pass, msg) ox::_assert(__FILE__, __LINE__, pass, msg) | ||||
| #define oxAssert(pass, msg) ox::_assert<decltype(pass)>(__FILE__, __LINE__, pass, msg) | ||||
| #else | ||||
| #define oxAssert(pass, msg) | ||||
| #endif | ||||
|   | ||||
							
								
								
									
										7
									
								
								deps/ox/src/ox/std/bitops.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								deps/ox/src/ox/std/bitops.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -20,9 +20,14 @@ template<typename T> | ||||
| constexpr T onMask(int bits) { | ||||
| 	T out = 0; | ||||
| 	for (auto i = 0; i < bits; i++) { | ||||
| 		out |= 1 << i; | ||||
| 		out |= static_cast<T>(1) << i; | ||||
| 	} | ||||
| 	return out; | ||||
| } | ||||
|  | ||||
| static_assert(onMask<int>(1) == 1); | ||||
| static_assert(onMask<int>(2) == 3); | ||||
| static_assert(onMask<int>(3) == 7); | ||||
| static_assert(onMask<int>(4) == 15); | ||||
|  | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								deps/ox/src/ox/std/types.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								deps/ox/src/ox/std/types.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -65,15 +65,15 @@ struct ErrorInfo { | ||||
|  | ||||
| 	ErrorInfo(Error err) { | ||||
| 		this->file = reinterpret_cast<const char*>(err & onMask<Error>(48)); | ||||
| 		this->line = static_cast<int>((err >> 48) & onMask<Error>(5)); | ||||
| 		this->errCode = (err >> 59) & onMask<Error>(11); | ||||
| 		this->line = static_cast<int>((err >> 48) & onMask<Error>(11)); | ||||
| 		this->errCode = (err >> 58) & onMask<Error>(5); | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| constexpr Error ErrorTags(Error line, Error errCode) { | ||||
| 	line &= onMask<Error>(5); | ||||
| 	line &= onMask<Error>(11); | ||||
| 	line <<= 48; | ||||
| 	errCode &= onMask<Error>(11); | ||||
| 	errCode &= onMask<Error>(5); | ||||
| 	errCode <<= 59; | ||||
| 	return errCode | line; | ||||
| } | ||||
| @@ -81,7 +81,7 @@ constexpr Error ErrorTags(Error line, Error errCode) { | ||||
| } | ||||
|  | ||||
| #ifdef DEBUG | ||||
| #define OxError(x) reinterpret_cast<uint64_t>(__FILE__) | ErrorTags(__LINE__, x) | ||||
| #define OxError(x) x ? reinterpret_cast<uint64_t>(__FILE__) | ErrorTags(__LINE__, x) : 0 | ||||
| #else | ||||
| #define OxError(x) x | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user