[keel,studio] Add support for New Item templates
Some checks failed
Build / build (push) Failing after 1m3s

This commit is contained in:
2025-01-18 20:16:29 -06:00
parent b29b9a9b3a
commit 92e9d9cbfc
12 changed files with 341 additions and 93 deletions

View File

@ -20,6 +20,8 @@ class Wrap {
virtual ox::CStringView typeName() const noexcept = 0;
[[nodiscard]]
virtual int typeVersion() const noexcept = 0;
[[nodiscard]]
virtual ox::UAnyPtr moveToCopy() noexcept = 0;
};
template<typename T>
@ -27,6 +29,11 @@ class WrapT: public Wrap {
public:
[[nodiscard]]
virtual constexpr T &obj() noexcept = 0;
ox::UAnyPtr moveToCopy() noexcept final {
return new T{std::move(obj())};
}
};
template<typename T>
@ -184,7 +191,18 @@ ox::Result<ox::UPtr<Wrap>> convert(
auto &src,
ox::StringViewCR dstTypeName,
int const dstTypeVersion) noexcept {
return convert(ctx, WrapRef{src}, dstTypeName, dstTypeVersion);
WrapRef ref{src};
return convert(ctx, static_cast<Wrap&>(ref), dstTypeName, dstTypeVersion);
}
ox::Result<ox::UPtr<Wrap>> convert(
keel::Context &ctx,
auto const&src,
ox::StringViewCR dstTypeName,
int const dstTypeVersion) noexcept {
auto srcCpy = src;
WrapRef ref{srcCpy};
return convert(ctx, ref, dstTypeName, dstTypeVersion);
}
template<typename DstType>