[ox] Make model system's setTypeInfo return an Error

This commit is contained in:
2023-06-09 20:49:36 -05:00
parent 7c3aaf99c2
commit e22743961a
28 changed files with 137 additions and 74 deletions

View File

@@ -93,19 +93,23 @@ class OrganicClawReader {
std::size_t stringLength(const char *name) noexcept;
template<typename T = void>
constexpr void setTypeInfo() noexcept {
constexpr ox::Error setTypeInfo() noexcept {
return {};
}
template<typename T = void>
constexpr void setTypeInfo(const char*) noexcept {
constexpr ox::Error setTypeInfo(const char*) noexcept {
return {};
}
template<typename T = void>
constexpr void setTypeInfo(const char*, int, const Vector<String>& = {}) noexcept {
constexpr ox::Error setTypeInfo(const char*, int, const Vector<String>& = {}) noexcept {
return {};
}
template<typename T = void>
constexpr void setTypeInfo(const char*, int, const Vector<String>& = {}, std::size_t = {}) noexcept {
constexpr ox::Error setTypeInfo(const char*, int, const Vector<String>& = {}, std::size_t = {}) noexcept {
return {};
}
/**

View File

@@ -74,7 +74,7 @@ struct TestStruct {
};
constexpr ox::Error model(auto *io, ox::CommonPtrWith<TestUnion> auto *obj) noexcept {
io->template setTypeInfo<TestUnion>();
oxReturnError(io->template setTypeInfo<TestUnion>());
oxReturnError(io->field("Bool", &obj->Bool));
oxReturnError(io->field("Int", &obj->Int));
oxReturnError(io->fieldCString("String", &obj->String));
@@ -82,7 +82,7 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith<TestUnion> auto *obj) noex
}
constexpr ox::Error model(auto *io, ox::CommonPtrWith<TestStructNest> auto *obj) noexcept {
io->template setTypeInfo<TestStructNest>();
oxReturnError(io->template setTypeInfo<TestStructNest>());
oxReturnError(io->field("Bool", &obj->Bool));
oxReturnError(io->field("Int", &obj->Int));
oxReturnError(io->field("String", &obj->String));
@@ -90,7 +90,7 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith<TestStructNest> auto *obj)
}
constexpr ox::Error model(auto *io, ox::CommonPtrWith<TestStruct> auto *obj) noexcept {
io->template setTypeInfo<TestStruct>();
oxReturnError(io->template setTypeInfo<TestStruct>());
oxReturnError(io->field("Bool", &obj->Bool));
oxReturnError(io->field("Int", &obj->Int));
oxReturnError(io->field("Int1", &obj->Int1));

View File

@@ -184,9 +184,13 @@ class OrganicClawWriter {
template<typename T>
Error field(const char*, T *val) noexcept;
template<typename T = void>
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {
template<typename T>
constexpr ox::Error setTypeInfo(
const char* = T::TypeName,
int = T::TypeVersion,
const Vector<String>& = {},
std::size_t = ModelFieldCount_v<T>) noexcept {
return {};
}
static constexpr auto opType() noexcept {