[ox] Make model system's setTypeInfo return an Error
This commit is contained in:
parent
7c3aaf99c2
commit
e22743961a
6
deps/ox/src/ox/claw/test/tests.cpp
vendored
6
deps/ox/src/ox/claw/test/tests.cpp
vendored
@ -66,7 +66,7 @@ struct TestStruct {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestUnion> auto *obj) {
|
||||
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));
|
||||
@ -75,7 +75,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestUnion> auto *obj) {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStructNest> auto *obj) {
|
||||
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));
|
||||
@ -84,7 +84,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStructNest> auto *obj) {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStruct> auto *obj) {
|
||||
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));
|
||||
|
13
deps/ox/src/ox/claw/write.hpp
vendored
13
deps/ox/src/ox/claw/write.hpp
vendored
@ -27,14 +27,15 @@ struct TypeInfoCatcher {
|
||||
const char *name = nullptr;
|
||||
int version = 0;
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(
|
||||
const char *name = T::TypeName,
|
||||
int v = T::TypeVersion,
|
||||
template<typename T>
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *pName = T::TypeName,
|
||||
int pVersion = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = 0) noexcept {
|
||||
this->name = name;
|
||||
this->version = v;
|
||||
this->name = pName;
|
||||
this->version = pVersion;
|
||||
return {};
|
||||
}
|
||||
|
||||
constexpr Error field(...) noexcept {
|
||||
|
@ -145,7 +145,7 @@ constexpr const char *getModelTypeName<FileAddress>() noexcept {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, CommonPtrWith<FileAddress::Data> auto *obj) noexcept {
|
||||
io->template setTypeInfo<FileAddress::Data>();
|
||||
oxReturnError(io->template setTypeInfo<FileAddress::Data>());
|
||||
oxReturnError(io->fieldCString("path", &obj->path));
|
||||
oxReturnError(io->fieldCString("constPath", &obj->path));
|
||||
oxReturnError(io->field("inode", &obj->inode));
|
||||
@ -154,7 +154,7 @@ constexpr Error model(T *io, CommonPtrWith<FileAddress::Data> auto *obj) noexcep
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, CommonPtrWith<FileAddress> auto *fa) noexcept {
|
||||
io->template setTypeInfo<FileAddress>();
|
||||
oxReturnError(io->template setTypeInfo<FileAddress>());
|
||||
if constexpr(T::opType() == OpType::Reflect) {
|
||||
int8_t type = 0;
|
||||
oxReturnError(io->field("type", &type));
|
||||
|
17
deps/ox/src/ox/mc/read.hpp
vendored
17
deps/ox/src/ox/mc/read.hpp
vendored
@ -99,8 +99,11 @@ class MetalClawReaderTemplate {
|
||||
constexpr StringLength stringLength(const char *name) noexcept;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
|
||||
const Vector<String>& = {}, std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *name = T::TypeName,
|
||||
int version = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
|
||||
/**
|
||||
* Returns a MetalClawReader to parse a child object.
|
||||
@ -225,7 +228,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, a
|
||||
if (valLen >= len) {
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len));
|
||||
oxReturnError(handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len)));
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
oxReturnError(handler.field("", &val[i]));
|
||||
}
|
||||
@ -254,7 +257,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, HashMa
|
||||
// read the list
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len));
|
||||
oxReturnError(handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len)));
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
const auto keyLen = handler.stringLength(nullptr);
|
||||
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
||||
@ -512,7 +515,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, CB cb)
|
||||
// read the list
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len));
|
||||
oxReturnError(handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len)));
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
T val;
|
||||
oxReturnError(handler.field("", &val));
|
||||
@ -539,11 +542,13 @@ constexpr StringLength MetalClawReaderTemplate<HandlerMaker>::stringLength(const
|
||||
|
||||
template<auto HandlerMaker>
|
||||
template<typename T>
|
||||
constexpr void MetalClawReaderTemplate<HandlerMaker>::setTypeInfo(const char*, int, const Vector<String>&, std::size_t fields) noexcept {
|
||||
constexpr ox::Error MetalClawReaderTemplate<HandlerMaker>::setTypeInfo(
|
||||
const char*, int, const Vector<String>&, std::size_t fields) noexcept {
|
||||
m_fields = fields;
|
||||
m_buffIt = static_cast<std::size_t>((fields / 8 + 1) - (fields % 8 == 0));
|
||||
m_fieldPresence.setFields(static_cast<int>(fields));
|
||||
m_fieldPresence.setMaxLen(static_cast<int>(m_buffIt));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<auto HandlerMaker>
|
||||
|
4
deps/ox/src/ox/mc/test/tests.cpp
vendored
4
deps/ox/src/ox/mc/test/tests.cpp
vendored
@ -61,7 +61,7 @@ struct TestStruct {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *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("CString", &obj->CString));
|
||||
@ -76,7 +76,7 @@ oxModelEnd()
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStruct> auto *obj) noexcept {
|
||||
io->template setTypeInfo<TestStruct>();
|
||||
oxReturnError(io->template setTypeInfo<TestStruct>());
|
||||
oxReturnError(io->field("Vector", &obj->Vector));
|
||||
oxReturnError(io->field("Bool", &obj->Bool));
|
||||
oxReturnError(io->field("Int", &obj->Int));
|
||||
|
14
deps/ox/src/ox/mc/write.hpp
vendored
14
deps/ox/src/ox/mc/write.hpp
vendored
@ -103,8 +103,11 @@ class MetalClawWriter {
|
||||
constexpr Error field(const char*, UnionView<U, force> val) noexcept;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
|
||||
const Vector<String>& = {}, std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *name = T::TypeName,
|
||||
int version = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
|
||||
/**
|
||||
* stringLength is not implemented in MetalClawWriter
|
||||
@ -328,7 +331,7 @@ constexpr Error MetalClawWriter<Writer>::field(const char*, T *val, std::size_t
|
||||
oxReturnError(m_writer.write(reinterpret_cast<const char*>(arrLen.data), arrLen.length));
|
||||
MetalClawWriter<Writer> writer(m_writer);
|
||||
ModelHandlerInterface handler{&writer};
|
||||
handler.template setTypeInfo<T>("List", 0, {}, static_cast<std::size_t>(len));
|
||||
oxReturnError(handler.template setTypeInfo<T>("List", 0, {}, static_cast<std::size_t>(len)));
|
||||
// write the array
|
||||
for (std::size_t i = 0; i < len; i++) {
|
||||
oxReturnError(handler.field("", &val[i]));
|
||||
@ -355,7 +358,7 @@ constexpr Error MetalClawWriter<Writer>::field(const char*, const HashMap<String
|
||||
MetalClawWriter<Writer> writer(m_writer);
|
||||
ModelHandlerInterface handler{&writer};
|
||||
// double len for both key and value
|
||||
handler.setTypeInfo("Map", 0, {}, len * 2);
|
||||
oxReturnError(handler.setTypeInfo("Map", 0, {}, len * 2));
|
||||
// write the array
|
||||
for (std::size_t i = 0; i < len; i++) {
|
||||
const auto &key = keys[i];
|
||||
@ -382,7 +385,7 @@ constexpr Error MetalClawWriter<Writer>::field(const char *name, HashMap<String,
|
||||
|
||||
template<Writer_c Writer>
|
||||
template<typename T>
|
||||
constexpr void MetalClawWriter<Writer>::setTypeInfo(
|
||||
constexpr ox::Error MetalClawWriter<Writer>::setTypeInfo(
|
||||
const char*,
|
||||
int,
|
||||
const Vector<String>&,
|
||||
@ -393,6 +396,7 @@ constexpr void MetalClawWriter<Writer>::setTypeInfo(
|
||||
m_presenceMapBuff.resize(fieldPresenceLen);
|
||||
m_fieldPresence.setBuffer(m_presenceMapBuff.data(), m_presenceMapBuff.size());
|
||||
m_fieldPresence.setFields(static_cast<int>(fields));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<Writer_c Writer>
|
||||
|
2
deps/ox/src/ox/model/def.hpp
vendored
2
deps/ox/src/ox/model/def.hpp
vendored
@ -10,7 +10,7 @@
|
||||
|
||||
#include <ox/std/concepts.hpp>
|
||||
|
||||
#define oxModelBegin(modelName) constexpr ox::Error model(auto *io, [[maybe_unused]] ox::CommonPtrWith<modelName> auto *o) noexcept { io->template setTypeInfo<modelName>();
|
||||
#define oxModelBegin(modelName) constexpr ox::Error model(auto *io, [[maybe_unused]] ox::CommonPtrWith<modelName> auto *o) noexcept { oxReturnError(io->template setTypeInfo<modelName>());
|
||||
#define oxModelEnd() return OxError(0); }
|
||||
#define oxModelField(fieldName) oxReturnError(io->field(#fieldName, &o->fieldName));
|
||||
#define oxModelFieldRename(serFieldName, objFieldName) oxReturnError(io->field(#serFieldName, &o->objFieldName));
|
||||
|
6
deps/ox/src/ox/model/desctypes.hpp
vendored
6
deps/ox/src/ox/model/desctypes.hpp
vendored
@ -75,7 +75,7 @@ struct Subscript {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, CommonPtrWith<Subscript> auto *type) noexcept {
|
||||
io->template setTypeInfo<Subscript>();
|
||||
oxReturnError(io->template setTypeInfo<Subscript>());
|
||||
if constexpr(T::opType() == OpType::Reflect) {
|
||||
uint32_t st = 0;
|
||||
oxReturnError(io->field("subscriptType", &st));
|
||||
@ -183,7 +183,7 @@ constexpr auto buildTypeId(const DescriptorType &t) noexcept {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, CommonPtrWith<DescriptorType> auto *type) noexcept {
|
||||
io->template setTypeInfo<DescriptorType>();
|
||||
oxReturnError(io->template setTypeInfo<DescriptorType>());
|
||||
oxReturnError(io->field("typeName", &type->typeName));
|
||||
oxReturnError(io->field("typeVersion", &type->typeVersion));
|
||||
if constexpr(T::opType() == OpType::Reflect) {
|
||||
@ -206,7 +206,7 @@ constexpr Error model(T *io, CommonPtrWith<DescriptorType> auto *type) noexcept
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, CommonPtrWith<DescriptorField> auto *field) noexcept {
|
||||
io->template setTypeInfo<DescriptorField>();
|
||||
oxReturnError(io->template setTypeInfo<DescriptorField>());
|
||||
oxReturnError(io->field("typeId", &field->typeId));
|
||||
oxReturnError(io->field("fieldName", &field->fieldName));
|
||||
oxReturnError(io->field("subscriptLevels", &field->subscriptLevels));
|
||||
|
5
deps/ox/src/ox/model/descwrite.hpp
vendored
5
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -91,7 +91,7 @@ class TypeDescWriter {
|
||||
constexpr ~TypeDescWriter() noexcept = default;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(CRStringView name = T::TypeName,
|
||||
constexpr ox::Error setTypeInfo(CRStringView name = T::TypeName,
|
||||
int version = T::TypeVersion,
|
||||
const TypeParamPack &typeParams = {},
|
||||
std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
@ -175,7 +175,7 @@ class TypeDescWriter {
|
||||
constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeStore(typeStore) {}
|
||||
|
||||
template<typename T>
|
||||
constexpr void TypeDescWriter::setTypeInfo(CRStringView typeName, int typeVersion,
|
||||
constexpr ox::Error TypeDescWriter::setTypeInfo(CRStringView typeName, int typeVersion,
|
||||
const TypeParamPack &typeParams, std::size_t) noexcept {
|
||||
PrimitiveType pt;
|
||||
if constexpr(is_union_v<T>) {
|
||||
@ -187,6 +187,7 @@ constexpr void TypeDescWriter::setTypeInfo(CRStringView typeName, int typeVersio
|
||||
}
|
||||
m_type = m_typeStore->getInit(typeName, typeVersion, pt, typeParams);
|
||||
m_type->preloadable = preloadable<T>::value;
|
||||
return {};
|
||||
}
|
||||
|
||||
// array handler
|
||||
|
5
deps/ox/src/ox/model/fieldcounter.hpp
vendored
5
deps/ox/src/ox/model/fieldcounter.hpp
vendored
@ -21,10 +21,11 @@ namespace detail {
|
||||
template<typename T>
|
||||
class FieldCounter {
|
||||
public:
|
||||
int fields = 0;
|
||||
std::size_t fields = 0;
|
||||
|
||||
template<typename U = std::nullptr_t>
|
||||
constexpr void setTypeInfo(CRStringView = "", int = 0, const Vector<String>& = {}, std::size_t = 0) {
|
||||
constexpr ox::Error setTypeInfo(CRStringView = "", int = 0, const Vector<String>& = {}, std::size_t = 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
|
4
deps/ox/src/ox/model/modelhandleradaptor.hpp
vendored
4
deps/ox/src/ox/model/modelhandleradaptor.hpp
vendored
@ -24,12 +24,12 @@ class ModelHandlerInterface {
|
||||
}
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *name = T::TypeName,
|
||||
int version = T::TypeVersion,
|
||||
const Vector<String> &typeParams = {},
|
||||
std::size_t fields = ModelFieldCount_v<T>) noexcept {
|
||||
m_handler->template setTypeInfo<T>(name, version, typeParams, fields);
|
||||
return m_handler->template setTypeInfo<T>(name, version, typeParams, fields);
|
||||
}
|
||||
|
||||
template<std::size_t len>
|
||||
|
24
deps/ox/src/ox/model/modelops.hpp
vendored
24
deps/ox/src/ox/model/modelops.hpp
vendored
@ -71,9 +71,13 @@ class MemberList {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = ModelTypeVersion_v<T>,
|
||||
const Vector<String>& = {}, int = 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 {};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
@ -128,7 +132,12 @@ class Copier {
|
||||
}
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion, const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char* = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
int = ModelFieldCount_v<T>) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
@ -185,7 +194,12 @@ class Mover {
|
||||
}
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion, const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char* = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
int = ModelFieldCount_v<T>) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
|
4
deps/ox/src/ox/model/modelvalue.hpp
vendored
4
deps/ox/src/ox/model/modelvalue.hpp
vendored
@ -769,7 +769,7 @@ constexpr std::size_t alignOf(const ModelValue &t) noexcept {
|
||||
}
|
||||
|
||||
constexpr Error model(auto *h, CommonPtrWith<ModelObject> auto *obj) noexcept {
|
||||
h->template setTypeInfo<ModelObject>(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size());
|
||||
oxReturnError(h->template setTypeInfo<ModelObject>(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size()));
|
||||
for (auto &f : obj->m_fieldsOrder) {
|
||||
oxReturnError(h->field(f->name.c_str(), &f->value));
|
||||
}
|
||||
@ -777,7 +777,7 @@ constexpr Error model(auto *h, CommonPtrWith<ModelObject> auto *obj) noexcept {
|
||||
}
|
||||
|
||||
constexpr Error model(auto *h, CommonPtrWith<ModelUnion> auto *obj) noexcept {
|
||||
h->template setTypeInfo<ModelUnion>(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size());
|
||||
oxReturnError(h->template setTypeInfo<ModelUnion>(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size()));
|
||||
for (auto &f : obj->m_fieldsOrder) {
|
||||
oxReturnError(h->field(f->name.c_str(), &f->value));
|
||||
}
|
||||
|
17
deps/ox/src/ox/model/typenamecatcher.hpp
vendored
17
deps/ox/src/ox/model/typenamecatcher.hpp
vendored
@ -24,12 +24,18 @@ struct TypeNameCatcher {
|
||||
|
||||
constexpr TypeNameCatcher() noexcept = default;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, std::size_t = 0) noexcept {
|
||||
template<typename T>
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *n = T::TypeName,
|
||||
int v = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {
|
||||
this->name = n;
|
||||
this->version = v;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
constexpr Error field(const char*, T*, std::size_t) noexcept {
|
||||
return OxError(0);
|
||||
@ -59,9 +65,14 @@ struct TypeInfoCatcher {
|
||||
constexpr TypeInfoCatcher() noexcept = default;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, std::size_t = 0) noexcept {
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *n = T::TypeName,
|
||||
int v = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = 0) noexcept {
|
||||
this->name = n;
|
||||
this->version = v;
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
4
deps/ox/src/ox/model/walk.hpp
vendored
4
deps/ox/src/ox/model/walk.hpp
vendored
@ -89,7 +89,7 @@ static constexpr Error parseField(const DescriptorField &field, Reader *rdr, Dat
|
||||
// add array handling
|
||||
oxRequire(arrayLen, rdr->arrayLength(field.fieldName.c_str(), true));
|
||||
auto child = rdr->child(field.fieldName.c_str());
|
||||
child.setTypeInfo(field.type->typeName.c_str(), field.type->typeVersion, field.type->typeParams, arrayLen);
|
||||
oxReturnError(child.setTypeInfo(field.type->typeName.c_str(), field.type->typeVersion, field.type->typeParams, arrayLen));
|
||||
DescriptorField f(field); // create mutable copy
|
||||
--f.subscriptLevels;
|
||||
String subscript;
|
||||
@ -137,7 +137,7 @@ constexpr Error model(Reader *rdr, DataWalker<Reader, FH> *walker) noexcept {
|
||||
auto typeVersion = type->typeVersion;
|
||||
auto typeParams = type->typeParams;
|
||||
auto &fields = type->fieldList;
|
||||
rdr->setTypeInfo(typeName, typeVersion, typeParams, fields.size());
|
||||
oxReturnError(rdr->setTypeInfo(typeName, typeVersion, typeParams, fields.size()));
|
||||
for (const auto &field : fields) {
|
||||
oxReturnError(parseField(field, rdr, walker));
|
||||
}
|
||||
|
12
deps/ox/src/ox/oc/read.hpp
vendored
12
deps/ox/src/ox/oc/read.hpp
vendored
@ -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 {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
6
deps/ox/src/ox/oc/test/tests.cpp
vendored
6
deps/ox/src/ox/oc/test/tests.cpp
vendored
@ -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));
|
||||
|
10
deps/ox/src/ox/oc/write.hpp
vendored
10
deps/ox/src/ox/oc/write.hpp
vendored
@ -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 {
|
||||
|
@ -26,8 +26,13 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
|
||||
std::size_t biggestAlignment = 1;
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char* = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(CRStringView name, const UnionView<T, force> val) noexcept {
|
||||
|
8
deps/ox/src/ox/preloader/preloader.hpp
vendored
8
deps/ox/src/ox/preloader/preloader.hpp
vendored
@ -78,11 +78,13 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
|
||||
std::size_t sz = 0) noexcept;
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(
|
||||
ox::CRStringView = T::TypeName,
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char* = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename U, bool force>
|
||||
constexpr ox::Error field(CRStringView, const ox::UnionView<U, force> val) noexcept;
|
||||
|
9
deps/ox/src/ox/preloader/sizecatcher.hpp
vendored
9
deps/ox/src/ox/preloader/sizecatcher.hpp
vendored
@ -32,8 +32,13 @@ class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
|
||||
constexpr explicit SizeCatcher() noexcept = default;
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char* = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(const char*, UnionView<T, force>) noexcept;
|
||||
|
10
deps/ox/src/ox/preloader/unionsizecatcher.hpp
vendored
10
deps/ox/src/ox/preloader/unionsizecatcher.hpp
vendored
@ -19,9 +19,15 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
|
||||
std::size_t m_size = 0;
|
||||
|
||||
public:
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char* = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(CRStringView, const UnionView<T, force> val) noexcept {
|
||||
|
2
deps/ox/src/ox/std/bounds.hpp
vendored
2
deps/ox/src/ox/std/bounds.hpp
vendored
@ -126,7 +126,7 @@ constexpr void Bounds::set(const Point &pt1, const Point &pt2) noexcept {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<Bounds> auto *obj) noexcept {
|
||||
io->template setTypeInfo<Bounds>();
|
||||
oxReturnError(io->template setTypeInfo<Bounds>());
|
||||
oxReturnError(io->field("x", &obj->x));
|
||||
oxReturnError(io->field("y", &obj->y));
|
||||
oxReturnError(io->field("width", &obj->width));
|
||||
|
2
deps/ox/src/ox/std/point.hpp
vendored
2
deps/ox/src/ox/std/point.hpp
vendored
@ -186,7 +186,7 @@ constexpr bool Point::operator!=(const Point &p) const noexcept {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<Point> auto *obj) noexcept {
|
||||
io->template setTypeInfo<Point>();
|
||||
oxReturnError(io->template setTypeInfo<Point>());
|
||||
oxReturnError(io->field("x", &obj->x));
|
||||
oxReturnError(io->field("y", &obj->y));
|
||||
return {};
|
||||
|
2
deps/ox/src/ox/std/size.hpp
vendored
2
deps/ox/src/ox/std/size.hpp
vendored
@ -187,7 +187,7 @@ constexpr bool Size::operator!=(const Size &p) const noexcept {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<Size> auto *obj) noexcept {
|
||||
io->template setTypeInfo<Size>();
|
||||
oxReturnError(io->template setTypeInfo<Size>());
|
||||
oxReturnError(io->field("width", &obj->width));
|
||||
oxReturnError(io->field("height", &obj->height));
|
||||
return {};
|
||||
|
8
deps/ox/src/ox/std/trace.hpp
vendored
8
deps/ox/src/ox/std/trace.hpp
vendored
@ -48,7 +48,7 @@ struct TraceMsgRcv {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<TraceMsgRcv> auto *obj) noexcept {
|
||||
io->template setTypeInfo<TraceMsgRcv>();
|
||||
oxReturnError(io->template setTypeInfo<TraceMsgRcv>());
|
||||
oxReturnError(io->field("file", &obj->file));
|
||||
oxReturnError(io->field("line", &obj->line));
|
||||
oxReturnError(io->field("time", &obj->time));
|
||||
@ -69,7 +69,7 @@ struct TraceMsg {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<TraceMsg> auto *obj) noexcept {
|
||||
io->template setTypeInfo<TraceMsg>();
|
||||
oxReturnError(io->template setTypeInfo<TraceMsg>());
|
||||
oxReturnError(io->fieldCString("file", &obj->file));
|
||||
oxReturnError(io->field("line", &obj->line));
|
||||
oxReturnError(io->field("time", &obj->time));
|
||||
@ -87,7 +87,7 @@ struct InitTraceMsgRcv {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<InitTraceMsgRcv> auto *obj) noexcept {
|
||||
io->template setTypeInfo<InitTraceMsgRcv>();
|
||||
oxReturnError(io->template setTypeInfo<InitTraceMsgRcv>());
|
||||
oxReturnError(io->field("appName", &obj->appName));
|
||||
return {};
|
||||
}
|
||||
@ -101,7 +101,7 @@ struct InitTraceMsg {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<InitTraceMsg> auto *obj) noexcept {
|
||||
io->template setTypeInfo<InitTraceMsg>();
|
||||
oxReturnError(io->template setTypeInfo<InitTraceMsg>());
|
||||
oxReturnError(io->fieldCString("appName", &obj->appName));
|
||||
return {};
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/uuid.hpp
vendored
2
deps/ox/src/ox/std/uuid.hpp
vendored
@ -176,7 +176,7 @@ class UUID {
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<UUID> auto *obj) noexcept {
|
||||
io->template setTypeInfo<UUID>();
|
||||
oxReturnError(io->template setTypeInfo<UUID>());
|
||||
oxReturnError(io->field("value", &obj->m_value));
|
||||
return {};
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/vec.hpp
vendored
2
deps/ox/src/ox/std/vec.hpp
vendored
@ -262,7 +262,7 @@ using Vec2 = Vec<float>;
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::CommonPtrWith<Vec2> auto *obj) noexcept {
|
||||
io->template setTypeInfo<Vec2>();
|
||||
oxReturnError(io->template setTypeInfo<Vec2>());
|
||||
oxReturnError(io->field("x", &obj->x));
|
||||
oxReturnError(io->field("y", &obj->y));
|
||||
return {};
|
||||
|
Loading…
Reference in New Issue
Block a user