This commit is contained in:
		| @@ -115,7 +115,7 @@ class BaseConverter { | ||||
| 		virtual ox::Result<ox::UPtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept = 0; | ||||
|  | ||||
| 		virtual ox::Result<ox::UPtr<Wrap>> convertBuffToPtr( | ||||
| 				keel::Context &ctx, ox::BufferView const&srcBuff) const noexcept = 0; | ||||
| 				Context &ctx, ox::BufferView const&srcBuff) const noexcept = 0; | ||||
|  | ||||
| 		[[nodiscard]] | ||||
| 		constexpr bool matches( | ||||
| @@ -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 { | ||||
| @@ -137,8 +137,8 @@ class ConverterFunc: public BaseConverter { | ||||
| 			using Dst = DstType; | ||||
| 		}; | ||||
|  | ||||
| 		template<typename S, typename D> | ||||
| 		static ParamPack<S, D> extractParams(ox::Error (*)(Context&, S&, D&)) { | ||||
| 		template<typename Src, typename Dst> | ||||
| 		static ParamPack<Src, Dst> extractParams(ox::Error (*)(Context&, Src&, Dst&)) { | ||||
| 			return {}; | ||||
| 		} | ||||
|  | ||||
| @@ -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 { | ||||
| 				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 { | ||||
| 				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(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]] | ||||
| @@ -256,20 +256,20 @@ ox::Result<DstType> convertObjToObj( | ||||
| } | ||||
|  | ||||
| template<typename DstType> | ||||
| ox::Result<DstType> convert(keel::Context &ctx, ox::BufferView const&src) noexcept { | ||||
| ox::Result<DstType> convert(Context &ctx, ox::BufferView const&src) noexcept { | ||||
| 	OX_REQUIRE(out, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>)); | ||||
| 	return std::move(wrapCast<DstType>(out)); | ||||
| } | ||||
|  | ||||
| template<typename DstType> | ||||
| ox::Error convert(keel::Context &ctx, ox::BufferView const&buff, DstType &outObj) noexcept { | ||||
| ox::Error convert(Context &ctx, ox::BufferView const&buff, DstType &outObj) noexcept { | ||||
| 	OX_REQUIRE(out, convert(ctx, buff, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>)); | ||||
| 	outObj = std::move(wrapCast<DstType>(*out)); | ||||
| 	return {}; | ||||
| } | ||||
|  | ||||
| template<typename DstType> | ||||
| ox::Error convertObjToObj(keel::Context &ctx, auto &src, DstType &outObj) noexcept { | ||||
| ox::Error convertObjToObj(Context &ctx, auto &src, DstType &outObj) noexcept { | ||||
| 	OX_REQUIRE(outPtr, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>)); | ||||
| 	outObj = std::move(wrapCast<DstType>(*outPtr)); | ||||
| 	return {}; | ||||
| @@ -277,13 +277,13 @@ ox::Error convertObjToObj(keel::Context &ctx, auto &src, DstType &outObj) noexce | ||||
|  | ||||
| template<typename DstType> | ||||
| ox::Result<ox::Buffer> convertBuffToBuff( | ||||
| 		keel::Context &ctx, ox::BufferView const&src, ox::ClawFormat const fmt) noexcept { | ||||
| 		Context &ctx, ox::BufferView const&src, ox::ClawFormat const fmt) noexcept { | ||||
| 	OX_REQUIRE(out, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>)); | ||||
| 	return ox::writeClaw<DstType>(wrapCast<DstType>(*out), fmt); | ||||
| } | ||||
|  | ||||
| template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal> | ||||
| ox::Result<bool> transformRule(keel::Context &ctx, ox::Buffer &buff, ox::StringViewCR typeId) noexcept { | ||||
| ox::Result<bool> transformRule(Context &ctx, ox::Buffer &buff, ox::StringViewCR typeId) noexcept { | ||||
| 	if (typeId == ox::ModelTypeId_v<From>) { | ||||
| 		OX_RETURN_ERROR(keel::convertBuffToBuff<To>(ctx, buff, fmt).moveTo(buff)); | ||||
| 		return true; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user