[ox] Fix remaining implicit conversion issues
This commit is contained in:
5
deps/ox/src/ox/preloader/CMakeLists.txt
vendored
5
deps/ox/src/ox/preloader/CMakeLists.txt
vendored
@@ -4,6 +4,11 @@ add_library(
|
||||
preloader.cpp
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxPreloader PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxPreloader PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
OxPreloader PUBLIC
|
||||
OxClaw
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -27,7 +27,7 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(CRStringView name, const UnionView<T, force> val) noexcept {
|
||||
|
29
deps/ox/src/ox/preloader/preloader.hpp
vendored
29
deps/ox/src/ox/preloader/preloader.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -78,8 +78,11 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
|
||||
std::size_t sz = 0) noexcept;
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(ox::CRStringView = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
constexpr void setTypeInfo(
|
||||
ox::CRStringView = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename U, bool force>
|
||||
constexpr ox::Error field(CRStringView, const ox::UnionView<U, force> val) noexcept;
|
||||
@@ -276,7 +279,7 @@ template<typename PlatSpec>
|
||||
constexpr ox::Error Preloader<PlatSpec>::offsetPtrs(std::size_t offset) noexcept {
|
||||
for (const auto &p : m_ptrs) {
|
||||
oxReturnError(m_writer.seekp(p.loc));
|
||||
const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(p.value + offset);
|
||||
const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(static_cast<typename PlatSpec::PtrType>(p.value + offset));
|
||||
oxReturnError(ox::serialize(&m_writer, val));
|
||||
}
|
||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
||||
@@ -307,18 +310,22 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView name, const ox
|
||||
|
||||
template<typename PlatSpec>
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView name, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept {
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
||||
CRStringView name, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept {
|
||||
// serialize the Vector
|
||||
ox::VectorMemMap<PlatSpec> vecVal{
|
||||
.smallVecSize = SmallVectorSize * sizeOf<PlatSpec>(static_cast<T*>(nullptr)),
|
||||
.size = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
.cap = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
.size = PlatSpec::correctEndianness(
|
||||
static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
.cap = PlatSpec::correctEndianness(
|
||||
static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
};
|
||||
return fieldVector(name, val, vecVal);
|
||||
}
|
||||
|
||||
template<typename PlatSpec>
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept {
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
||||
CRStringView, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept {
|
||||
oxReturnError(pad(&vecVal));
|
||||
const auto vecValPt = m_writer.tellp();
|
||||
// serialize the Vector elements
|
||||
@@ -331,7 +338,8 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView, const auto *v
|
||||
oxReturnError(this->interface()->field(nullptr, &val->operator[](i)));
|
||||
}
|
||||
m_unionIdx.pop_back();
|
||||
vecVal.items = PlatSpec::correctEndianness(p + PlatSpec::RomStart);
|
||||
vecVal.items = PlatSpec::correctEndianness(
|
||||
static_cast<typename PlatSpec::size_t>(p + PlatSpec::RomStart));
|
||||
oxReturnError(m_writer.seekp(vecValPt));
|
||||
} else {
|
||||
vecVal.items = 0;
|
||||
@@ -349,7 +357,8 @@ constexpr bool Preloader<PlatSpec>::unionCheckAndIt() noexcept {
|
||||
}
|
||||
|
||||
template<typename PlatSpec, typename T>
|
||||
constexpr ox::Error preload(Preloader<PlatSpec> *pl, ox::CommonPtrWith<T> auto *obj) noexcept {
|
||||
constexpr ox::Error preload(
|
||||
Preloader<PlatSpec> *pl, ox::CommonPtrWith<T> auto *obj) noexcept {
|
||||
oxReturnError(model(pl->interface(), obj));
|
||||
return pl->pad(obj);
|
||||
}
|
||||
|
4
deps/ox/src/ox/preloader/sizecatcher.hpp
vendored
4
deps/ox/src/ox/preloader/sizecatcher.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -33,7 +33,7 @@ class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(const char*, UnionView<T, force>) noexcept;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -21,7 +21,7 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
|
||||
public:
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(CRStringView, const UnionView<T, force> val) noexcept {
|
||||
|
Reference in New Issue
Block a user