[ox] Fix for Windows

This commit is contained in:
Gary Talent 2022-12-17 13:36:18 -06:00
parent ad412177ab
commit 4077f0bddc
5 changed files with 33 additions and 6 deletions

View File

@ -15,4 +15,6 @@
namespace ox { namespace ox {
template class ModelHandlerInterface<MetalClawWriter>;
} }

View File

@ -106,6 +106,22 @@ class MetalClawWriter {
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion, constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
const Vector<String>& = {}, int fields = ModelFieldCount_v<T>) noexcept; const Vector<String>& = {}, int fields = ModelFieldCount_v<T>) 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]] [[nodiscard]]
constexpr std::size_t size() const noexcept; constexpr std::size_t size() const noexcept;
@ -134,6 +150,8 @@ class MetalClawWriter {
}; };
extern template class ModelHandlerInterface<MetalClawWriter>;
constexpr MetalClawWriter::MetalClawWriter(uint8_t *buff, std::size_t buffLen, int unionIdx) noexcept: constexpr MetalClawWriter::MetalClawWriter(uint8_t *buff, std::size_t buffLen, int unionIdx) noexcept:
m_fieldPresence(buff, buffLen), m_fieldPresence(buff, buffLen),
m_unionIdx(unionIdx), m_unionIdx(unionIdx),
@ -284,7 +302,7 @@ constexpr Error MetalClawWriter::field(const char*, T *val) noexcept {
bool fieldSet = false; bool fieldSet = false;
if (val && (m_unionIdx == -1 || m_unionIdx == m_field)) { if (val && (m_unionIdx == -1 || m_unionIdx == m_field)) {
MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt); MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt);
ModelHandlerInterface handler{&writer}; ModelHandlerInterface<MetalClawWriter> handler{&writer};
oxReturnError(model(&handler, val)); oxReturnError(model(&handler, val));
if (static_cast<std::size_t>(writer.m_fieldPresence.getMaxLen()) < writer.m_buffIt) { if (static_cast<std::size_t>(writer.m_fieldPresence.getMaxLen()) < writer.m_buffIt) {
m_buffIt += writer.m_buffIt; m_buffIt += writer.m_buffIt;

View File

@ -57,9 +57,14 @@ target_compile_definitions(
$<$<BOOL:${OX_NODEBUG}>:OX_NODEBUG> $<$<BOOL:${OX_NODEBUG}>:OX_NODEBUG>
) )
target_link_libraries( if(NOT WIN32)
target_link_libraries(
OxStd PUBLIC OxStd PUBLIC
$<$<CXX_COMPILER_ID:GNU>:$<$<BOOL:${OX_USE_STDLIB}>:dl>> $<$<CXX_COMPILER_ID:GNU>:$<$<BOOL:${OX_USE_STDLIB}>:dl>>
)
endif()
target_link_libraries(
OxStd PUBLIC
$<$<CXX_COMPILER_ID:GNU>:gcc> $<$<CXX_COMPILER_ID:GNU>:gcc>
OxTraceHook OxTraceHook
) )

View File

@ -153,9 +153,9 @@ template<std::size_t segementCnt>
[[nodiscard]] [[nodiscard]]
constexpr Fmt<segementCnt> fmtSegments(StringView fmt) noexcept { constexpr Fmt<segementCnt> fmtSegments(StringView fmt) noexcept {
Fmt<segementCnt> out; Fmt<segementCnt> out;
const auto prev = [fmt](std::size_t i) -> char { const auto prev = [fmt](int i) -> char {
if (i > 0) { if (i > 0) {
return fmt[i - 1]; return fmt[static_cast<std::size_t>(i) - 1];
} else { } else {
return '\0'; return '\0';
} }

View File

@ -9,8 +9,10 @@
#if defined(OX_USE_STDLIB) && __has_include(<unistd.h>) #if defined(OX_USE_STDLIB) && __has_include(<unistd.h>)
#include <iostream> #include <iostream>
#if __has_include_next(<execinfo.h>)
#include <execinfo.h> #include <execinfo.h>
#include <dlfcn.h> #include <dlfcn.h>
#endif
#if __has_include(<cxxabi.h>) #if __has_include(<cxxabi.h>)
#include <cxxabi.h> #include <cxxabi.h>
@ -30,7 +32,7 @@ static auto symbolicate([[maybe_unused]]char **frames,
[[maybe_unused]]const char *linePrefix) { [[maybe_unused]]const char *linePrefix) {
using StrT = BasicString<100>; using StrT = BasicString<100>;
Vector<StrT, 30> out; Vector<StrT, 30> out;
#if __has_include(<cxxabi.h>) #if __has_include(<cxxabi.h>) && __has_include_next(<execinfo.h>)
for (auto i = 0u; i < symbolsLen; ++i) { for (auto i = 0u; i < symbolsLen; ++i) {
Dl_info info; Dl_info info;
if (dladdr(frames[i], &info) && info.dli_sname) { 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(<unistd.h>) #endif // defined(OX_USE_STDLIB) && __has_include(<unistd.h>)
void printStackTrace([[maybe_unused]]unsigned shave) noexcept { void printStackTrace([[maybe_unused]]unsigned shave) noexcept {
#if defined(OX_USE_STDLIB) && __has_include(<unistd.h>) #if defined(OX_USE_STDLIB) && __has_include(<unistd.h>) && __has_include_next(<execinfo.h>)
constexpr auto FrameCnt = 100; constexpr auto FrameCnt = 100;
Vector<void*, FrameCnt> frames(FrameCnt); Vector<void*, FrameCnt> frames(FrameCnt);
frames.resize(static_cast<std::size_t>(backtrace(frames.data(), static_cast<int>(frames.size())))); frames.resize(static_cast<std::size_t>(backtrace(frames.data(), static_cast<int>(frames.size()))));