[ox] Fix some template issue that come up with some versions of Clang, fix empty string read in OC

This commit is contained in:
2023-12-13 22:44:54 -06:00
parent 1b93b2038f
commit 960889749d
13 changed files with 45 additions and 57 deletions

View File

@@ -22,7 +22,7 @@ template<typename PlatSpec, typename T>
constexpr std::size_t sizeOf(const T *t) noexcept;
template<typename PlatSpec>
struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>, OpType::Reflect> {
std::size_t biggestAlignment = 1;
template<typename T>
@@ -64,11 +64,6 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
return {};
}
[[nodiscard]]
static constexpr auto opType() noexcept {
return ox::OpType::Reflect;
}
};
}

View File

@@ -13,6 +13,7 @@
namespace ox {
struct NativePlatSpec {
static constexpr std::size_t RomStart = 1024;
using PtrType = uintptr_t;
using size_t = std::size_t;

View File

@@ -6,4 +6,6 @@
namespace ox {
template class Preloader<NativePlatSpec>;
}

View File

@@ -15,7 +15,6 @@
#include <ox/std/units.hpp>
#include <ox/model/modelhandleradaptor.hpp>
#include "preloader.hpp"
#include "platspecs.hpp"
namespace ox {
@@ -24,7 +23,7 @@ template<typename PlatSpec>
class Preloader;
template<typename PlatSpec>
class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
class Preloader: public ModelHandlerBase<Preloader<PlatSpec>, OpType::Reflect> {
private:
using PtrType = typename PlatSpec::PtrType;
static constexpr auto PtrSize = sizeof(PtrType);
@@ -115,11 +114,6 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
return m_buff;
}
[[nodiscard]]
static constexpr auto opType() noexcept {
return ox::OpType::Write;
}
template<typename T>
constexpr ox::Error pad(const T*) noexcept;
@@ -272,7 +266,7 @@ constexpr ox::Error Preloader<PlatSpec>::endAlloc() noexcept {
return m_writer.seekp(0, ox::ios_base::end);
}
const auto &si = *m_allocStack.back().unwrap();
oxReturnError(m_writer.seekp(si.restore, si.seekdir));
oxReturnError(m_writer.seekp(static_cast<ox::ssize_t>(si.restore), si.seekdir));
m_allocStack.pop_back();
return {};
}
@@ -364,4 +358,6 @@ constexpr ox::Error preload(Preloader<PlatSpec> *pl, ox::CommonPtrWith<T> auto *
return pl->pad(obj);
}
extern template class Preloader<NativePlatSpec>;
}

View File

@@ -24,7 +24,7 @@ template<typename PlatSpec, typename T>
constexpr std::size_t sizeOf(const T *t) noexcept;
template<typename PlatSpec>
class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>, OpType::Reflect> {
private:
std::size_t m_size = 0;
@@ -61,11 +61,6 @@ class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
return m_size;
}
[[nodiscard]]
static constexpr auto opType() noexcept {
return ox::OpType::Reflect;
}
private:
constexpr void pad(const auto *val) noexcept;
};

View File

@@ -14,7 +14,7 @@
namespace ox {
template<typename PlatSpec>
class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>, OpType::Reflect> {
private:
std::size_t m_size = 0;
@@ -55,11 +55,6 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
return m_size;
}
[[nodiscard]]
static constexpr auto opType() noexcept {
return ox::OpType::Reflect;
}
private:
template<typename T, std::size_t SmallVecSize>
constexpr ox::Error fieldStr(CRStringView, const ox::BasicString<SmallVecSize> *val) noexcept;