From 4077f0bddc9d0d2e2ab81c314c162e234190eba2 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 17 Dec 2022 13:36:18 -0600 Subject: [PATCH] [ox] Fix for Windows --- deps/ox/src/ox/mc/write.cpp | 2 ++ deps/ox/src/ox/mc/write.hpp | 20 +++++++++++++++++++- deps/ox/src/ox/std/CMakeLists.txt | 7 ++++++- deps/ox/src/ox/std/fmt.hpp | 4 ++-- deps/ox/src/ox/std/stacktrace.cpp | 6 ++++-- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/deps/ox/src/ox/mc/write.cpp b/deps/ox/src/ox/mc/write.cpp index 698623a1..08887eb5 100644 --- a/deps/ox/src/ox/mc/write.cpp +++ b/deps/ox/src/ox/mc/write.cpp @@ -15,4 +15,6 @@ namespace ox { +template class ModelHandlerInterface; + } diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index 035b122c..6f005e4a 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -106,6 +106,22 @@ class MetalClawWriter { constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion, const Vector& = {}, int fields = ModelFieldCount_v) noexcept; + /** + * stringLength is not implemented in MetalClawWriter + */ + [[nodiscard]] + constexpr auto stringLength(const char*) noexcept { + return 0; + } + + /** + * stringLength is not implemented in MetalClawWriter + */ + [[nodiscard]] + constexpr auto arrayLength(const char*, bool = true) noexcept { + return 0; + } + [[nodiscard]] constexpr std::size_t size() const noexcept; @@ -134,6 +150,8 @@ class MetalClawWriter { }; +extern template class ModelHandlerInterface; + constexpr MetalClawWriter::MetalClawWriter(uint8_t *buff, std::size_t buffLen, int unionIdx) noexcept: m_fieldPresence(buff, buffLen), m_unionIdx(unionIdx), @@ -284,7 +302,7 @@ constexpr Error MetalClawWriter::field(const char*, T *val) noexcept { bool fieldSet = false; if (val && (m_unionIdx == -1 || m_unionIdx == m_field)) { MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt); - ModelHandlerInterface handler{&writer}; + ModelHandlerInterface handler{&writer}; oxReturnError(model(&handler, val)); if (static_cast(writer.m_fieldPresence.getMaxLen()) < writer.m_buffIt) { m_buffIt += writer.m_buffIt; diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index bda8b575..d0e7079a 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -57,9 +57,14 @@ target_compile_definitions( $<$:OX_NODEBUG> ) +if(NOT WIN32) + target_link_libraries( + OxStd PUBLIC + $<$:$<$:dl>> + ) +endif() target_link_libraries( OxStd PUBLIC - $<$:$<$:dl>> $<$:gcc> OxTraceHook ) diff --git a/deps/ox/src/ox/std/fmt.hpp b/deps/ox/src/ox/std/fmt.hpp index 6019adb3..e41fc197 100644 --- a/deps/ox/src/ox/std/fmt.hpp +++ b/deps/ox/src/ox/std/fmt.hpp @@ -153,9 +153,9 @@ template [[nodiscard]] constexpr Fmt fmtSegments(StringView fmt) noexcept { Fmt out; - const auto prev = [fmt](std::size_t i) -> char { + const auto prev = [fmt](int i) -> char { if (i > 0) { - return fmt[i - 1]; + return fmt[static_cast(i) - 1]; } else { return '\0'; } diff --git a/deps/ox/src/ox/std/stacktrace.cpp b/deps/ox/src/ox/std/stacktrace.cpp index 517620eb..d94a5236 100644 --- a/deps/ox/src/ox/std/stacktrace.cpp +++ b/deps/ox/src/ox/std/stacktrace.cpp @@ -9,8 +9,10 @@ #if defined(OX_USE_STDLIB) && __has_include() #include +#if __has_include_next() #include #include +#endif #if __has_include() #include @@ -30,7 +32,7 @@ static auto symbolicate([[maybe_unused]]char **frames, [[maybe_unused]]const char *linePrefix) { using StrT = BasicString<100>; Vector out; -#if __has_include() +#if __has_include() && __has_include_next() for (auto i = 0u; i < symbolsLen; ++i) { Dl_info info; if (dladdr(frames[i], &info) && info.dli_sname) { @@ -49,7 +51,7 @@ static auto symbolicate([[maybe_unused]]char **frames, #endif // defined(OX_USE_STDLIB) && __has_include() void printStackTrace([[maybe_unused]]unsigned shave) noexcept { -#if defined(OX_USE_STDLIB) && __has_include() +#if defined(OX_USE_STDLIB) && __has_include() && __has_include_next() constexpr auto FrameCnt = 100; Vector frames(FrameCnt); frames.resize(static_cast(backtrace(frames.data(), static_cast(frames.size()))));