Compare commits
	
		
			13 Commits
		
	
	
		
			release-d2
			...
			1ba64cb5d8
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1ba64cb5d8 | |||
| 462bebf6dd | |||
| e3f84c4e75 | |||
| 6837a0556d | |||
| ede2c8ca37 | |||
| f50367f7d5 | |||
| e758e03d2b | |||
| 835e3270ce | |||
| 480dd5ece4 | |||
| dba6bb5800 | |||
| 40a456e54a | |||
| bf5be00c12 | |||
| dc7c2559d6 | 
							
								
								
									
										2
									
								
								deps/ox/src/ox/event/signal.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								deps/ox/src/ox/event/signal.hpp
									
									
									
									
										vendored
									
									
								
							@@ -215,7 +215,7 @@ Error Signal<Args...>::emitCheckError(Args... args) const noexcept {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		return ox::Error(0);
 | 
							return ox::Error(0);
 | 
				
			||||||
	} catch (const ox::Exception &ex) {
 | 
						} catch (const ox::Exception &ex) {
 | 
				
			||||||
		return ox::Error(ex.file, ex.line, ex.errCode, ex.msg);
 | 
							return ox::Error(ex.errCode, ex.msg, ex.src);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								deps/ox/src/ox/logconn/def.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								deps/ox/src/ox/logconn/def.hpp
									
									
									
									
										vendored
									
									
								
							@@ -14,7 +14,7 @@
 | 
				
			|||||||
    { \
 | 
					    { \
 | 
				
			||||||
		const auto loggerErr = (loggerName).initConn(appName); \
 | 
							const auto loggerErr = (loggerName).initConn(appName); \
 | 
				
			||||||
		if (loggerErr) { \
 | 
							if (loggerErr) { \
 | 
				
			||||||
			oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.file, loggerErr.line); \
 | 
								oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.src.file_name(), loggerErr.src.line()); \
 | 
				
			||||||
		} else { \
 | 
							} else { \
 | 
				
			||||||
			ox::trace::setLogger(&(loggerName)); \
 | 
								ox::trace::setLogger(&(loggerName)); \
 | 
				
			||||||
		} \
 | 
							} \
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								deps/ox/src/ox/std/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								deps/ox/src/ox/std/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							@@ -109,6 +109,7 @@ install(
 | 
				
			|||||||
		error.hpp
 | 
							error.hpp
 | 
				
			||||||
		fmt.hpp
 | 
							fmt.hpp
 | 
				
			||||||
		hardware.hpp
 | 
							hardware.hpp
 | 
				
			||||||
 | 
							hash.hpp
 | 
				
			||||||
		hashmap.hpp
 | 
							hashmap.hpp
 | 
				
			||||||
		heapmgr.hpp
 | 
							heapmgr.hpp
 | 
				
			||||||
		ignore.hpp
 | 
							ignore.hpp
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								deps/ox/src/ox/std/assert.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								deps/ox/src/ox/std/assert.cpp
									
									
									
									
										vendored
									
									
								
							@@ -20,8 +20,8 @@ void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err)
 | 
				
			|||||||
		oxErrf("\tError Message:\t{}\n", err.msg);
 | 
							oxErrf("\tError Message:\t{}\n", err.msg);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	oxErrf("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
 | 
						oxErrf("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
 | 
				
			||||||
	if (err.file != nullptr) {
 | 
						if (err.src.file_name() != nullptr) {
 | 
				
			||||||
		oxErrf("\tError Location:\t{}:{}\n", err.file, err.line);
 | 
							oxErrf("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#ifdef OX_USE_STDLIB
 | 
					#ifdef OX_USE_STDLIB
 | 
				
			||||||
	printStackTrace(2);
 | 
						printStackTrace(2);
 | 
				
			||||||
@@ -56,8 +56,8 @@ void assertFailFuncRuntime(StringViewCR file, int line, [[maybe_unused]] const E
 | 
				
			|||||||
		msg += sfmt("\tError Message:\t{}\n", err.msg);
 | 
							msg += sfmt("\tError Message:\t{}\n", err.msg);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	msg += sfmt("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
 | 
						msg += sfmt("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
 | 
				
			||||||
	if (err.file != nullptr) {
 | 
						if (err.src.file_name() != nullptr) {
 | 
				
			||||||
		msg += sfmt("\tError Location:\t{}:{}\n", err.file, err.line);
 | 
							msg += sfmt("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	msg += genStackTrace(2);
 | 
						msg += genStackTrace(2);
 | 
				
			||||||
	oxErr(msg);
 | 
						oxErr(msg);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										40
									
								
								deps/ox/src/ox/std/error.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										40
									
								
								deps/ox/src/ox/std/error.hpp
									
									
									
									
										vendored
									
									
								
							@@ -36,28 +36,16 @@ using ErrorCode = uint16_t;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct [[nodiscard]] Error {
 | 
					struct [[nodiscard]] Error {
 | 
				
			||||||
 | 
						std::source_location src;
 | 
				
			||||||
	ox::CString msg = nullptr;
 | 
						ox::CString msg = nullptr;
 | 
				
			||||||
	ox::CString file = nullptr;
 | 
					 | 
				
			||||||
	uint16_t line = 0;
 | 
					 | 
				
			||||||
	ErrorCode errCode = 0;
 | 
						ErrorCode errCode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	constexpr Error() noexcept = default;
 | 
						constexpr Error() noexcept = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	explicit constexpr Error(
 | 
					 | 
				
			||||||
		ox::CString file,
 | 
					 | 
				
			||||||
		uint32_t const line,
 | 
					 | 
				
			||||||
		ErrorCode const errCode,
 | 
					 | 
				
			||||||
		ox::CString msg = nullptr) noexcept:
 | 
					 | 
				
			||||||
		msg{msg},
 | 
					 | 
				
			||||||
		file{file},
 | 
					 | 
				
			||||||
		line{static_cast<uint16_t>(line)},
 | 
					 | 
				
			||||||
		errCode{errCode} {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	explicit constexpr Error(
 | 
						explicit constexpr Error(
 | 
				
			||||||
		ErrorCode const errCode,
 | 
							ErrorCode const errCode,
 | 
				
			||||||
		std::source_location const&src = std::source_location::current()) noexcept:
 | 
							std::source_location const&src = std::source_location::current()) noexcept:
 | 
				
			||||||
		file{src.file_name()},
 | 
							src{src},
 | 
				
			||||||
		line{static_cast<uint16_t>(src.line())},
 | 
					 | 
				
			||||||
		errCode{errCode}
 | 
							errCode{errCode}
 | 
				
			||||||
	{}
 | 
						{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -65,9 +53,8 @@ struct [[nodiscard]] Error {
 | 
				
			|||||||
		ErrorCode const errCode,
 | 
							ErrorCode const errCode,
 | 
				
			||||||
		ox::CString msg,
 | 
							ox::CString msg,
 | 
				
			||||||
		std::source_location const&src = std::source_location::current()) noexcept:
 | 
							std::source_location const&src = std::source_location::current()) noexcept:
 | 
				
			||||||
 | 
							src{src},
 | 
				
			||||||
		msg{msg},
 | 
							msg{msg},
 | 
				
			||||||
		file{src.file_name()},
 | 
					 | 
				
			||||||
		line{static_cast<uint16_t>(src.line())},
 | 
					 | 
				
			||||||
		errCode{errCode}
 | 
							errCode{errCode}
 | 
				
			||||||
	{}
 | 
						{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -89,42 +76,31 @@ constexpr auto toStr(Error const&err) noexcept {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Exception: public std::exception {
 | 
					struct Exception: public std::exception {
 | 
				
			||||||
 | 
						std::source_location src;
 | 
				
			||||||
	ox::CString msg = nullptr;
 | 
						ox::CString msg = nullptr;
 | 
				
			||||||
	ox::CString file = nullptr;
 | 
					 | 
				
			||||||
	uint16_t line = 0;
 | 
					 | 
				
			||||||
	ErrorCode errCode = 0;
 | 
						ErrorCode errCode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	explicit inline Exception(ox::CString file, uint32_t line, ErrorCode errCode, char const*msg = "") noexcept {
 | 
					 | 
				
			||||||
		this->file = file;
 | 
					 | 
				
			||||||
		this->line = static_cast<uint16_t>(line);
 | 
					 | 
				
			||||||
		this->msg = msg;
 | 
					 | 
				
			||||||
		this->errCode = errCode;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	explicit inline Exception(
 | 
						explicit inline Exception(
 | 
				
			||||||
		ErrorCode const errCode,
 | 
							ErrorCode const errCode,
 | 
				
			||||||
		std::source_location const&src = std::source_location::current()) noexcept:
 | 
							std::source_location const&src = std::source_location::current()) noexcept:
 | 
				
			||||||
		file{src.file_name()},
 | 
							src{src},
 | 
				
			||||||
		line{static_cast<uint16_t>(src.line())},
 | 
					 | 
				
			||||||
		errCode{errCode} {}
 | 
							errCode{errCode} {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	explicit inline Exception(
 | 
						explicit inline Exception(
 | 
				
			||||||
		ErrorCode const errCode,
 | 
							ErrorCode const errCode,
 | 
				
			||||||
		ox::CString msg,
 | 
							ox::CString msg,
 | 
				
			||||||
		std::source_location const&src = std::source_location::current()) noexcept:
 | 
							std::source_location const&src = std::source_location::current()) noexcept:
 | 
				
			||||||
 | 
							src{src},
 | 
				
			||||||
		msg{msg},
 | 
							msg{msg},
 | 
				
			||||||
		file{src.file_name()},
 | 
					 | 
				
			||||||
		line{static_cast<uint16_t>(src.line())},
 | 
					 | 
				
			||||||
		errCode{errCode} {}
 | 
							errCode{errCode} {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	explicit inline Exception(Error const&err) noexcept:
 | 
						explicit inline Exception(Error const&err) noexcept:
 | 
				
			||||||
 | 
							src{err.src},
 | 
				
			||||||
		msg{err.msg ? err.msg : ""},
 | 
							msg{err.msg ? err.msg : ""},
 | 
				
			||||||
		file{err.file},
 | 
					 | 
				
			||||||
		line{err.line},
 | 
					 | 
				
			||||||
		errCode{err.errCode} {}
 | 
							errCode{err.errCode} {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	constexpr Error toError() const noexcept {
 | 
						constexpr Error toError() const noexcept {
 | 
				
			||||||
		return Error(file, line, errCode, msg);
 | 
							return Error(errCode, msg, src);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]]
 | 
						[[nodiscard]]
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								deps/ox/src/ox/std/reader.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								deps/ox/src/ox/std/reader.hpp
									
									
									
									
										vendored
									
									
								
							@@ -31,7 +31,6 @@ concept Reader_c = requires(T v) {
 | 
				
			|||||||
class Reader_v {
 | 
					class Reader_v {
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		virtual constexpr ~Reader_v() noexcept = default;
 | 
							virtual constexpr ~Reader_v() noexcept = default;
 | 
				
			||||||
		[[nodiscard]]
 | 
					 | 
				
			||||||
		virtual constexpr ox::Result<char> peek() const noexcept = 0;
 | 
							virtual constexpr ox::Result<char> peek() const noexcept = 0;
 | 
				
			||||||
		virtual constexpr ox::Result<std::size_t> read(char*, std::size_t) noexcept = 0;
 | 
							virtual constexpr ox::Result<std::size_t> read(char*, std::size_t) noexcept = 0;
 | 
				
			||||||
		virtual constexpr ox::Result<std::size_t> tellg() noexcept = 0;
 | 
							virtual constexpr ox::Result<std::size_t> tellg() noexcept = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								deps/ox/src/ox/std/test/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								deps/ox/src/ox/std/test/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							@@ -17,6 +17,7 @@ add_test("[ox/std] String" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "String")
 | 
				
			|||||||
add_test("[ox/std] SmallMap" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "SmallMap")
 | 
					add_test("[ox/std] SmallMap" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "SmallMap")
 | 
				
			||||||
add_test("[ox/std] SmallMap2" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "SmallMap2")
 | 
					add_test("[ox/std] SmallMap2" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "SmallMap2")
 | 
				
			||||||
add_test("[ox/std] Vector" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "Vector")
 | 
					add_test("[ox/std] Vector" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "Vector")
 | 
				
			||||||
 | 
					add_test("[ox/std] Vector::shrink_to_fit" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "Vector::shrink_to_fit")
 | 
				
			||||||
add_test("[ox/std] HashMap" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "HashMap")
 | 
					add_test("[ox/std] HashMap" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "HashMap")
 | 
				
			||||||
add_test("[ox/std] HeapMgr" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest malloc)
 | 
					add_test("[ox/std] HeapMgr" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest malloc)
 | 
				
			||||||
add_test("[ox/std] Serialize-Int" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "Serialize-Int")
 | 
					add_test("[ox/std] Serialize-Int" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "Serialize-Int")
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										30
									
								
								deps/ox/src/ox/std/test/tests.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								deps/ox/src/ox/std/test/tests.cpp
									
									
									
									
										vendored
									
									
								
							@@ -237,6 +237,36 @@ OX_CLANG_NOWARN_END
 | 
				
			|||||||
			return ox::Error(0);
 | 
								return ox::Error(0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"Vector::shrink_to_fit",
 | 
				
			||||||
 | 
							[] {
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									ox::Vector<ox::IString<8>> v;
 | 
				
			||||||
 | 
									v.reserve(50);
 | 
				
			||||||
 | 
									v.emplace_back("asdf");
 | 
				
			||||||
 | 
									v.emplace_back("aoeu");
 | 
				
			||||||
 | 
									auto const origData = v.data();
 | 
				
			||||||
 | 
									v.shrink_to_fit();
 | 
				
			||||||
 | 
									oxExpect(v[0], "asdf");
 | 
				
			||||||
 | 
									oxExpect(v[1], "aoeu");
 | 
				
			||||||
 | 
									oxExpect(v.capacity(), 2u);
 | 
				
			||||||
 | 
									oxAssert(origData != v.data(), "shrink_to_fit did not create a new allocation");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									ox::Vector<ox::IString<8>> v;
 | 
				
			||||||
 | 
									v.reserve(2);
 | 
				
			||||||
 | 
									v.emplace_back("asdf");
 | 
				
			||||||
 | 
									v.emplace_back("aoeu");
 | 
				
			||||||
 | 
									auto const origData = v.data();
 | 
				
			||||||
 | 
									v.shrink_to_fit();
 | 
				
			||||||
 | 
									oxExpect(v[0], "asdf");
 | 
				
			||||||
 | 
									oxExpect(v[1], "aoeu");
 | 
				
			||||||
 | 
									oxExpect(v.capacity(), 2u);
 | 
				
			||||||
 | 
									oxAssert(origData == v.data(), "shrink_to_fit inappropriately created a new allocation");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return ox::Error{};
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"SmallMap",
 | 
							"SmallMap",
 | 
				
			||||||
		[] {
 | 
							[] {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								deps/ox/src/ox/std/trace.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								deps/ox/src/ox/std/trace.hpp
									
									
									
									
										vendored
									
									
								
							@@ -269,8 +269,8 @@ using TraceStream = NullStream;
 | 
				
			|||||||
inline void logError(const char *file, int line, const char *fmt, const Error &err) noexcept {
 | 
					inline void logError(const char *file, int line, const char *fmt, const Error &err) noexcept {
 | 
				
			||||||
	if (err) {
 | 
						if (err) {
 | 
				
			||||||
		TraceStream trc(file, line, "ox::error");
 | 
							TraceStream trc(file, line, "ox::error");
 | 
				
			||||||
		if (err.file != nullptr) {
 | 
							if (err.src.file_name() != nullptr) {
 | 
				
			||||||
			trc << "Error: (" << err.file << ":" << err.line << "):";
 | 
								trc << "Error: (" << err.src.file_name() << ":" << err.src.line() << "):";
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			trc <<  "Error:";
 | 
								trc <<  "Error:";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -282,8 +282,8 @@ inline void logError(const char *file, int line, const Error &err) noexcept {
 | 
				
			|||||||
	if (err) {
 | 
						if (err) {
 | 
				
			||||||
		TraceStream trc(file, line, "ox::error");
 | 
							TraceStream trc(file, line, "ox::error");
 | 
				
			||||||
		trc <<  "Error:" << err;
 | 
							trc <<  "Error:" << err;
 | 
				
			||||||
		if (err.file != nullptr) {
 | 
							if (err.src.file_name() != nullptr) {
 | 
				
			||||||
			trc << "(" << err.file << ":" << err.line << ")";
 | 
								trc << "(" << err.src.file_name() << ":" << err.src.line() << ")";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								deps/ox/src/ox/std/vector.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								deps/ox/src/ox/std/vector.hpp
									
									
									
									
										vendored
									
									
								
							@@ -313,6 +313,8 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		constexpr void reserve(std::size_t cap) noexcept(useNoexcept);
 | 
							constexpr void reserve(std::size_t cap) noexcept(useNoexcept);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							constexpr void shrink_to_fit() noexcept(useNoexcept);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		constexpr void reserveInsert(
 | 
							constexpr void reserveInsert(
 | 
				
			||||||
				std::size_t cap, std::size_t pos, std::size_t offset = 1) noexcept(useNoexcept);
 | 
									std::size_t cap, std::size_t pos, std::size_t offset = 1) noexcept(useNoexcept);
 | 
				
			||||||
@@ -341,6 +343,7 @@ constexpr Vector<T, SmallVectorSize, Allocator>::Vector(std::size_t size) noexce
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
 | 
					template<typename T, std::size_t SmallVectorSize, typename Allocator>
 | 
				
			||||||
constexpr Vector<T, SmallVectorSize, Allocator>::Vector(std::initializer_list<T> list) noexcept {
 | 
					constexpr Vector<T, SmallVectorSize, Allocator>::Vector(std::initializer_list<T> list) noexcept {
 | 
				
			||||||
 | 
						reserve(list.size());
 | 
				
			||||||
	for (auto &item : list) {
 | 
						for (auto &item : list) {
 | 
				
			||||||
		emplace_back(std::move(item));
 | 
							emplace_back(std::move(item));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -675,6 +678,24 @@ constexpr void Vector<T, SmallVectorSize, Allocator>::reserve(std::size_t cap) n
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<typename T, std::size_t SmallVectorSize, typename Allocator>
 | 
				
			||||||
 | 
					constexpr void Vector<T, SmallVectorSize, Allocator>::shrink_to_fit() noexcept(useNoexcept)  {
 | 
				
			||||||
 | 
						if (m_size == m_cap) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						const auto oldItems = m_items;
 | 
				
			||||||
 | 
						const auto oldCap = m_cap;
 | 
				
			||||||
 | 
						m_cap = m_size;
 | 
				
			||||||
 | 
						this->allocate(&m_items, m_size);
 | 
				
			||||||
 | 
						if (oldItems) { // move over old items
 | 
				
			||||||
 | 
							for (std::size_t i = 0; i < m_size; ++i) {
 | 
				
			||||||
 | 
								std::construct_at(&m_items[i], std::move(oldItems[i]));
 | 
				
			||||||
 | 
								oldItems[i].~T();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							this->deallocate(oldItems, oldCap);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
 | 
					template<typename T, std::size_t SmallVectorSize, typename Allocator>
 | 
				
			||||||
constexpr void Vector<T, SmallVectorSize, Allocator>::reserveInsert(
 | 
					constexpr void Vector<T, SmallVectorSize, Allocator>::reserveInsert(
 | 
				
			||||||
		std::size_t cap,
 | 
							std::size_t cap,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,8 +102,6 @@ OX_MODEL_BEGIN(TileSheetSet)
 | 
				
			|||||||
	OX_MODEL_FIELD(entries)
 | 
						OX_MODEL_FIELD(entries)
 | 
				
			||||||
OX_MODEL_END()
 | 
					OX_MODEL_END()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void addEntry(TileSheetSet &set, ox::FileAddress path, int32_t begin = 0, int32_t size = -1) noexcept;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[nodiscard]]
 | 
					[[nodiscard]]
 | 
				
			||||||
int tileColumns(Context&) noexcept;
 | 
					int tileColumns(Context&) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,8 +48,8 @@ OX_ALLOW_UNSAFE_BUFFERS_END
 | 
				
			|||||||
		oxErrf("\tError Message:\t{}\n", err.msg);
 | 
							oxErrf("\tError Message:\t{}\n", err.msg);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	oxErrf("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
 | 
						oxErrf("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
 | 
				
			||||||
	if (err.file != nullptr) {
 | 
						if (err.src.file_name() != nullptr) {
 | 
				
			||||||
		oxErrf("\tError Location:\t{}:{}\n", err.file, err.line);
 | 
							oxErrf("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// disable all interrupt handling and IntrWait on no interrupts
 | 
						// disable all interrupt handling and IntrWait on no interrupts
 | 
				
			||||||
	REG_IE = 0;
 | 
						REG_IE = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ target_link_libraries(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
target_compile_definitions(
 | 
					target_compile_definitions(
 | 
				
			||||||
	NostalgiaStudio PUBLIC
 | 
						NostalgiaStudio PUBLIC
 | 
				
			||||||
		OLYMPIC_APP_VERSION="d2024.12.0"
 | 
							OLYMPIC_APP_VERSION="dev build"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install(
 | 
					install(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -196,15 +196,15 @@ class AssetManager {
 | 
				
			|||||||
		template<typename T>
 | 
							template<typename T>
 | 
				
			||||||
		class AssetTypeManager: public AssetTypeManagerBase {
 | 
							class AssetTypeManager: public AssetTypeManagerBase {
 | 
				
			||||||
			public:
 | 
								public:
 | 
				
			||||||
				using Loader = std::function<ox::Result<T>(ox::StringView assetId)>;
 | 
									using Loader = std::function<ox::Result<T>(ox::StringViewCR assetId)>;
 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
				Loader m_loader{};
 | 
									Loader m_loader{};
 | 
				
			||||||
				ox::HashMap<ox::String, ox::UPtr<AssetContainer<T>>> m_cache;
 | 
									ox::HashMap<ox::String, ox::UPtr<AssetContainer<T>>> m_cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			public:
 | 
								public:
 | 
				
			||||||
				AssetTypeManager(Loader loader) noexcept: m_loader(loader) {}
 | 
									AssetTypeManager(Loader &&loader) noexcept: m_loader(std::move(loader)) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				ox::Result<AssetRef<T>> getAsset(ox::StringView const assetId) const noexcept {
 | 
									ox::Result<AssetRef<T>> getAsset(ox::StringViewCR assetId) const noexcept {
 | 
				
			||||||
					OX_REQUIRE(out, m_cache.at(assetId));
 | 
										OX_REQUIRE(out, m_cache.at(assetId));
 | 
				
			||||||
					if (!out || !*out) {
 | 
										if (!out || !*out) {
 | 
				
			||||||
						return ox::Error(1, "asset is null");
 | 
											return ox::Error(1, "asset is null");
 | 
				
			||||||
@@ -212,7 +212,7 @@ class AssetManager {
 | 
				
			|||||||
					return AssetRef<T>(out->get());
 | 
										return AssetRef<T>(out->get());
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				ox::Result<AssetRef<T>> loadAsset(ox::StringView const assetId) noexcept {
 | 
									ox::Result<AssetRef<T>> loadAsset(ox::StringViewCR assetId) noexcept {
 | 
				
			||||||
					auto &p = m_cache[assetId];
 | 
										auto &p = m_cache[assetId];
 | 
				
			||||||
					OX_REQUIRE_M(obj, m_loader(assetId));
 | 
										OX_REQUIRE_M(obj, m_loader(assetId));
 | 
				
			||||||
					if (!p) {
 | 
										if (!p) {
 | 
				
			||||||
@@ -224,7 +224,7 @@ class AssetManager {
 | 
				
			|||||||
					return AssetRef<T>(p.get());
 | 
										return AssetRef<T>(p.get());
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				ox::Error reloadAsset(ox::StringView const assetId) noexcept {
 | 
									ox::Error reloadAsset(ox::StringViewCR assetId) noexcept {
 | 
				
			||||||
					auto &p = m_cache[assetId];
 | 
										auto &p = m_cache[assetId];
 | 
				
			||||||
					OX_REQUIRE_M(obj, m_loader(assetId));
 | 
										OX_REQUIRE_M(obj, m_loader(assetId));
 | 
				
			||||||
					if (!p) {
 | 
										if (!p) {
 | 
				
			||||||
@@ -247,7 +247,7 @@ class AssetManager {
 | 
				
			|||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ox::HashMap<ox::String, ox::UPtr<AssetTypeManagerBase>> m_assetTypeManagers;
 | 
							ox::HashMap<ox::String, ox::UPtr<AssetTypeManagerBase>> m_assetTypeManagers;
 | 
				
			||||||
		ox::HashMap<ox::String, ox::Signal<ox::Error(ox::StringView assetId)>> m_fileUpdated;
 | 
							ox::HashMap<ox::String, ox::Signal<ox::Error(ox::StringViewCR assetId)>> m_fileUpdated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		template<typename T>
 | 
							template<typename T>
 | 
				
			||||||
		ox::Result<AssetTypeManager<T>*> getTypeManager() noexcept {
 | 
							ox::Result<AssetTypeManager<T>*> getTypeManager() noexcept {
 | 
				
			||||||
@@ -273,18 +273,18 @@ class AssetManager {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		template<typename T>
 | 
							template<typename T>
 | 
				
			||||||
		ox::Result<AssetRef<T>> getAsset(ox::StringView assetId) noexcept {
 | 
							ox::Result<AssetRef<T>> getAsset(ox::StringViewCR assetId) noexcept {
 | 
				
			||||||
			OX_REQUIRE(m, getTypeManager<T>());
 | 
								OX_REQUIRE(m, getTypeManager<T>());
 | 
				
			||||||
			return m->getAsset(assetId);
 | 
								return m->getAsset(assetId);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ox::Error reloadAsset(ox::StringView assetId) noexcept {
 | 
							ox::Error reloadAsset(ox::StringViewCR assetId) noexcept {
 | 
				
			||||||
			m_fileUpdated[assetId].emit(assetId);
 | 
								m_fileUpdated[assetId].emit(assetId);
 | 
				
			||||||
			return {};
 | 
								return {};
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		template<typename T>
 | 
							template<typename T>
 | 
				
			||||||
		ox::Result<AssetRef<T>> loadAsset(ox::StringView assetId) noexcept {
 | 
							ox::Result<AssetRef<T>> loadAsset(ox::StringViewCR assetId) noexcept {
 | 
				
			||||||
			OX_REQUIRE(m, getTypeManager<T>());
 | 
								OX_REQUIRE(m, getTypeManager<T>());
 | 
				
			||||||
			OX_REQUIRE(out, m->loadAsset(assetId));
 | 
								OX_REQUIRE(out, m->loadAsset(assetId));
 | 
				
			||||||
			m_fileUpdated[assetId].connect(m, &AssetTypeManager<T>::reloadAsset);
 | 
								m_fileUpdated[assetId].connect(m, &AssetTypeManager<T>::reloadAsset);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,7 +66,9 @@ StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexce
 | 
				
			|||||||
				auto openFileErr = openFileActiveTab(f, config.activeTabItemName == f);
 | 
									auto openFileErr = openFileActiveTab(f, config.activeTabItemName == f);
 | 
				
			||||||
				if (openFileErr) {
 | 
									if (openFileErr) {
 | 
				
			||||||
					oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr));
 | 
										oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr));
 | 
				
			||||||
 | 
										continue;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									m_activeEditor = m_editors.back().value->get();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
@@ -75,7 +77,7 @@ StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexce
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			oxErrf(
 | 
								oxErrf(
 | 
				
			||||||
					"Could not open studio config file: {}: {} ({}:{})\n",
 | 
										"Could not open studio config file: {}: {} ({}:{})\n",
 | 
				
			||||||
					err.errCode, toStr(err), err.file, err.line);
 | 
										err.errCode, toStr(err), err.src.file_name(), err.src.line());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -200,13 +202,13 @@ void StudioUI::drawTabs() noexcept {
 | 
				
			|||||||
		auto const selected = m_activeEditorUpdatePending == e.get() ?  ImGuiTabItemFlags_SetSelected : 0;
 | 
							auto const selected = m_activeEditorUpdatePending == e.get() ?  ImGuiTabItemFlags_SetSelected : 0;
 | 
				
			||||||
		auto const flags = unsavedChanges | selected;
 | 
							auto const flags = unsavedChanges | selected;
 | 
				
			||||||
		if (ImGui::BeginTabItem(e->itemDisplayName().c_str(), &open, flags)) {
 | 
							if (ImGui::BeginTabItem(e->itemDisplayName().c_str(), &open, flags)) {
 | 
				
			||||||
			if (m_activeEditor != e.get()) {
 | 
								if (m_activeEditor != e.get()) [[unlikely]] {
 | 
				
			||||||
				m_activeEditor = e.get();
 | 
									m_activeEditor = e.get();
 | 
				
			||||||
				studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&](StudioConfig &config) {
 | 
									studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&](StudioConfig &config) {
 | 
				
			||||||
					config.activeTabItemName = m_activeEditor->itemPath();
 | 
										config.activeTabItemName = m_activeEditor->itemPath();
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
			}
 | 
								} else [[likely]] {
 | 
				
			||||||
			if (m_activeEditorUpdatePending == e.get()) {
 | 
									if (m_activeEditorUpdatePending == e.get()) [[unlikely]] {
 | 
				
			||||||
					m_activeEditorUpdatePending = nullptr;
 | 
										m_activeEditorUpdatePending = nullptr;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if (m_activeEditorOnLastDraw != e.get()) [[unlikely]] {
 | 
									if (m_activeEditorOnLastDraw != e.get()) [[unlikely]] {
 | 
				
			||||||
@@ -214,6 +216,7 @@ void StudioUI::drawTabs() noexcept {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				e->draw(m_sctx);
 | 
									e->draw(m_sctx);
 | 
				
			||||||
				m_activeEditorOnLastDraw = e.get();
 | 
									m_activeEditorOnLastDraw = e.get();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			ImGui::EndTabItem();
 | 
								ImGui::EndTabItem();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!open) {
 | 
							if (!open) {
 | 
				
			||||||
@@ -224,7 +227,7 @@ void StudioUI::drawTabs() noexcept {
 | 
				
			|||||||
			try {
 | 
								try {
 | 
				
			||||||
				OX_THROW_ERROR(m_editors.erase(it).moveTo(it));
 | 
									OX_THROW_ERROR(m_editors.erase(it).moveTo(it));
 | 
				
			||||||
			} catch (ox::Exception const&ex) {
 | 
								} catch (ox::Exception const&ex) {
 | 
				
			||||||
				oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line);
 | 
									oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.src.file_name(), ex.src.line());
 | 
				
			||||||
			} catch (std::exception const&ex) {
 | 
								} catch (std::exception const&ex) {
 | 
				
			||||||
				oxErrf("Editor tab deletion failed: {}\n", ex.what());
 | 
									oxErrf("Editor tab deletion failed: {}\n", ex.what());
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -376,7 +379,7 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab)
 | 
				
			|||||||
		if constexpr(!ox::defines::Debug) {
 | 
							if constexpr(!ox::defines::Debug) {
 | 
				
			||||||
			oxErrf("Could not open Editor: {}\n", toStr(err));
 | 
								oxErrf("Could not open Editor: {}\n", toStr(err));
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			oxErrf("Could not open Editor: {} ({}:{})\n", err.errCode, err.file, err.line);
 | 
								oxErrf("Could not open Editor: {} ({}:{})\n", err.errCode, err.src.file_name(), err.src.line());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -126,12 +126,12 @@ class SelectionTracker {
 | 
				
			|||||||
		constexpr Selection selection() const noexcept {
 | 
							constexpr Selection selection() const noexcept {
 | 
				
			||||||
			return {
 | 
								return {
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ox::min(m_pointA.x, m_pointB.x),
 | 
										ox::max(0, ox::min(m_pointA.x, m_pointB.x)),
 | 
				
			||||||
					ox::min(m_pointA.y, m_pointB.y),
 | 
										ox::max(0, ox::min(m_pointA.y, m_pointB.y)),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ox::max(m_pointA.x, m_pointB.x),
 | 
										ox::max(0, ox::max(m_pointA.x, m_pointB.x)),
 | 
				
			||||||
					ox::max(m_pointA.y, m_pointB.y),
 | 
										ox::max(0, ox::max(m_pointA.y, m_pointB.y)),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ namespace studio {
 | 
				
			|||||||
class NoChangesException: public ox::Exception {
 | 
					class NoChangesException: public ox::Exception {
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		inline NoChangesException(std::source_location sloc = std::source_location::current()):
 | 
							inline NoChangesException(std::source_location sloc = std::source_location::current()):
 | 
				
			||||||
				ox::Exception(sloc.file_name(), sloc.line(), 1, "Command makes no changes.") {}
 | 
									ox::Exception(1, "Command makes no changes.", sloc) {}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UndoCommand {
 | 
					class UndoCommand {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ void BaseEditor::save() noexcept {
 | 
				
			|||||||
		setUnsavedChanges(false);
 | 
							setUnsavedChanges(false);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if constexpr(ox::defines::Debug) {
 | 
							if constexpr(ox::defines::Debug) {
 | 
				
			||||||
			oxErrorf("Could not save file {}: {} ({}:{})", itemPath(), toStr(err), err.file, err.line);
 | 
								oxErrorf("Could not save file {}: {} ({}:{})", itemPath(), toStr(err), err.src.file_name(), err.src.line());
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			oxErrorf("Could not save file {}: {}", itemPath(), toStr(err));
 | 
								oxErrorf("Could not save file {}: {}", itemPath(), toStr(err));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user