[keel] Improve correctness
All checks were successful
Build / build (push) Successful in 1m16s

This commit is contained in:
Gary Talent 2025-04-17 01:12:05 -05:00
parent 477834ac04
commit 61844e9d9c

View File

@ -129,7 +129,7 @@ class BaseConverter {
template<auto Func>
class ConverterFunc: public BaseConverter {
class ConverterFunc final: public BaseConverter {
private:
template<typename SrcType, typename DstType>
struct ParamPack {
@ -147,17 +147,17 @@ class ConverterFunc: public BaseConverter {
using DstType = typename decltype(extractParams(Func))::Dst;
[[nodiscard]]
constexpr ox::StringView srcTypeName() const noexcept final {
constexpr ox::StringView srcTypeName() const noexcept override {
return ox::ModelTypeName_v<SrcType>;
}
[[nodiscard]]
constexpr int srcTypeVersion() const noexcept final {
constexpr int srcTypeVersion() const noexcept override {
return ox::ModelTypeVersion_v<SrcType>;
}
[[nodiscard]]
constexpr bool srcMatches(ox::StringViewCR pSrcTypeName, int pSrcTypeVersion) const noexcept final {
constexpr bool srcMatches(ox::StringViewCR pSrcTypeName, int pSrcTypeVersion) const noexcept override {
constexpr auto SrcTypeName = ox::requireModelTypeName<SrcType>();
constexpr auto SrcTypeVersion = ox::requireModelTypeVersion<SrcType>();
return pSrcTypeName == SrcTypeName
@ -165,7 +165,7 @@ class ConverterFunc: public BaseConverter {
}
[[nodiscard]]
constexpr bool dstMatches(ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept final {
constexpr bool dstMatches(ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept override {
constexpr auto DstTypeName = ox::StringView{ox::requireModelTypeName<DstType>()};
constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
return dstTypeName == DstTypeName
@ -173,14 +173,14 @@ class ConverterFunc: public BaseConverter {
}
ox::Result<ox::UPtr<Wrap>> convertPtrToPtr(
keel::Context &ctx, Wrap &src) const noexcept final {
keel::Context &ctx, Wrap &src) const noexcept override {
ox::Result<ox::UPtr<Wrap>> dst{makeWrap<DstType>()};
OX_RETURN_ERROR(convert(ctx, wrapCast<SrcType>(src), wrapCast<DstType>(*dst.value)));
return dst;
}
ox::Result<ox::UPtr<Wrap>> convertBuffToPtr(
keel::Context &ctx, ox::BufferView const&srcBuff) const noexcept final {
keel::Context &ctx, ox::BufferView const&srcBuff) const noexcept override {
OX_REQUIRE_M(src, readAsset<SrcType>(srcBuff));
ox::Result<ox::UPtr<Wrap>> dst{makeWrap<DstType>()};
OX_RETURN_ERROR(convert(ctx, src, wrapCast<DstType>(*dst.value)));
@ -188,7 +188,7 @@ class ConverterFunc: public BaseConverter {
}
protected:
ox::Error convert(keel::Context &ctx, SrcType &src, DstType &dst) const noexcept {
static ox::Error convert(keel::Context &ctx, SrcType &src, DstType &dst) noexcept {
return Func(ctx, src, dst);
}
@ -200,14 +200,14 @@ class Converter {
BaseConverter *m_conv{};
public:
template<auto Func>
static Converter make() {
static Converter make() noexcept {
Converter out;
static_assert(sizeof(ConverterFunc<Func>) <= sizeof(out.m_buff));
out.m_conv = new (out.m_buff.data()) ConverterFunc<Func>{};
return out;
}
constexpr Converter() {}
Converter(Converter const &other):
Converter(Converter const &other) noexcept:
m_buff{other.m_buff},
m_conv{m_buff.data()} {}
[[nodiscard]]