Squashed 'deps/nostalgia/' changes from b97d7d99..04f3d6b4
04f3d6b4 [keel] Fix some static const vars to be constexpr db2dc28f [keel] Remove use of removed ModelValue operator 74fb051e [ox] Remove panicing ModelValue operators 24fda7d5 [ox] Make serialize and allocate Writer_c functions take refs a60cdf0a Merge commit '9c712cc38ae706b021807b271899bce56c234fa5' 9a0a2fd4 Merge commit '56f9d7a4634c9de9b09df390c4385c67ab646607' 9c0acf1b Merge commit 'ace68f7c1d870ed53e69c55ba53709a9425388be' a41e93c5 Merge commit '8e0467ca5fdb3f983738a97c17cba742a0d233fd' dbcd37d7 Merge commit '0d61e5a064382a7076b62d32b25c70298ee0706e' 6a500345 Merge commit '057272347486efe5046691f32f51604e3a594e6a' f038b89a Merge commit 'cfc27a384b00388fc1ce30ac47c266ddd1f8e6f1' b9fddd47 Merge commit 'db978290f3465d2da30a27a98b12face50bbe091' 961ab756 Merge commit 'ae1f8ce11a81624f376be3a3dd56e80ba479dd89' d740609c Merge commit '6640e00ad9ee5b731a2ddb06da31436463c3ae65' 08be822b [ox/fs] Add FileAddress::operator==(FileAddress) git-subtree-dir: deps/nostalgia git-subtree-split: 04f3d6b491105a4f124d9738f612b9e0c505b2b0
This commit is contained in:
parent
9c712cc38a
commit
d6403991d4
32
deps/ox/src/ox/mc/test/tests.cpp
vendored
32
deps/ox/src/ox/mc/test/tests.cpp
vendored
@ -320,27 +320,27 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
|||||||
ox::ModelObject testOut;
|
ox::ModelObject testOut;
|
||||||
oxReturnError(testOut.setType(type));
|
oxReturnError(testOut.setType(type));
|
||||||
oxAssert(ox::readMC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed");
|
oxAssert(ox::readMC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed");
|
||||||
oxAssert(testOut["Int"].get<int>() == testIn.Int, "testOut.Int failed");
|
oxAssert(testOut.at("Int").unwrap()->get<int>() == testIn.Int, "testOut.Int failed");
|
||||||
oxAssert(testOut["Bool"].get<bool>() == testIn.Bool, "testOut.Bool failed");
|
oxAssert(testOut.at("Bool").unwrap()->get<bool>() == testIn.Bool, "testOut.Bool failed");
|
||||||
oxAssert(testOut["BString"].get<ox::String>() == testIn.BString.c_str(), "testOut.String failed");
|
oxAssert(testOut.at("BString").unwrap()->get<ox::String>() == testIn.BString.c_str(), "testOut.String failed");
|
||||||
oxAssert(testOut["String"].get<ox::String>() == testIn.String, "testOut.String failed");
|
oxAssert(testOut.at("String").unwrap()->get<ox::String>() == testIn.String, "testOut.String failed");
|
||||||
auto &testOutStruct = testOut["Struct"].get<ox::ModelObject>();
|
auto &testOutStruct = testOut.at("Struct").unwrap()->get<ox::ModelObject>();
|
||||||
auto &testOutUnion = testOut["Union"].get<ox::ModelUnion>();
|
auto &testOutUnion = testOut.at("Union").unwrap()->get<ox::ModelUnion>();
|
||||||
auto &testOutList = testOut["List"].get<ox::ModelValueVector>();
|
auto &testOutList = testOut.at("List").unwrap()->get<ox::ModelValueVector>();
|
||||||
auto testOutStructCopy = testOut["Struct"].get<ox::ModelObject>();
|
auto testOutStructCopy = testOut.at("Struct").unwrap()->get<ox::ModelObject>();
|
||||||
auto testOutUnionCopy = testOut["Union"].get<ox::ModelUnion>();
|
auto testOutUnionCopy = testOut.at("Union").unwrap()->get<ox::ModelUnion>();
|
||||||
auto testOutListCopy = testOut["List"].get<ox::ModelValueVector>();
|
auto testOutListCopy = testOut.at("List").unwrap()->get<ox::ModelValueVector>();
|
||||||
oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed");
|
oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed");
|
||||||
oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed");
|
oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed");
|
||||||
oxAssert(testOutStruct["Bool"].get<bool>() == testIn.Struct.Bool, "testOut.Struct.Bool failed");
|
oxAssert(testOutStruct.at("Bool").unwrap()->get<bool>() == testIn.Struct.Bool, "testOut.Struct.Bool failed");
|
||||||
oxAssert(testOutStruct["BString"].get<ox::String>() == testIn.Struct.BString.c_str(), "testOut.Struct.BString failed");
|
oxAssert(testOutStruct.at("BString").unwrap()->get<ox::String>() == testIn.Struct.BString.c_str(), "testOut.Struct.BString failed");
|
||||||
oxAssert(testOut["unionIdx"].get<int>() == testIn.unionIdx, "testOut.unionIdx failed");
|
oxAssert(testOut.at("unionIdx").unwrap()->get<int>() == testIn.unionIdx, "testOut.unionIdx failed");
|
||||||
oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong");
|
oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong");
|
||||||
oxAssert(testOutUnion["Int"].get<uint32_t>() == testIn.Union.Int, "testOut.Union.Int failed");
|
oxAssert(testOutUnion.at("Int").unwrap()->get<uint32_t>() == testIn.Union.Int, "testOut.Union.Int failed");
|
||||||
oxAssert(testOutList[0].get<uint32_t>() == testIn.List[0], "testOut.List[0] failed");
|
oxAssert(testOutList[0].get<uint32_t>() == testIn.List[0], "testOut.List[0] failed");
|
||||||
oxAssert(testOutList[1].get<uint32_t>() == testIn.List[1], "testOut.Struct.List[1] failed");
|
oxAssert(testOutList[1].get<uint32_t>() == testIn.List[1], "testOut.Struct.List[1] failed");
|
||||||
oxAssert(testOutStructCopy["Bool"].get<bool>() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed");
|
oxAssert(testOutStructCopy.at("Bool").unwrap()->get<bool>() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed");
|
||||||
oxAssert(testOutStructCopy["BString"].get<ox::String>() == testIn.Struct.BString.c_str(), "testOut.Struct.BString (copy) failed");
|
oxAssert(testOutStructCopy.at("BString").unwrap()->get<ox::String>() == testIn.Struct.BString.c_str(), "testOut.Struct.BString (copy) failed");
|
||||||
oxAssert(testOutListCopy[0].get<uint32_t>() == testIn.List[0], "testOut.Struct.List[0] (copy) failed");
|
oxAssert(testOutListCopy[0].get<uint32_t>() == testIn.List[0], "testOut.Struct.List[0] (copy) failed");
|
||||||
oxAssert(testOutListCopy[1].get<uint32_t>() == testIn.List[1], "testOut.Struct.List[1] (copy) failed");
|
oxAssert(testOutListCopy[1].get<uint32_t>() == testIn.List[1], "testOut.Struct.List[1] (copy) failed");
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
|
18
deps/ox/src/ox/model/modelvalue.hpp
vendored
18
deps/ox/src/ox/model/modelvalue.hpp
vendored
@ -642,12 +642,9 @@ class ModelObject {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto &operator[](StringView const&k) noexcept {
|
constexpr ox::Result<ModelValue*> at(StringView const&k) noexcept {
|
||||||
auto [v, err] = m_fields.at(k);
|
oxRequire(v, m_fields.at(k));
|
||||||
if (err) [[unlikely]] {
|
return *v;
|
||||||
oxPanic(err, ox::sfmt("field {} does not exist in type {}", k, buildTypeId(*m_type)).c_str());
|
|
||||||
}
|
|
||||||
return **v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto &operator[](const std::size_t i) noexcept {
|
constexpr auto &operator[](const std::size_t i) noexcept {
|
||||||
@ -731,12 +728,9 @@ class ModelUnion {
|
|||||||
return UniquePtr<ModelUnion>(new ModelUnion(other));
|
return UniquePtr<ModelUnion>(new ModelUnion(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto &operator[](StringView const&k) noexcept {
|
constexpr ox::Result<ModelValue*> at(StringView const&k) noexcept {
|
||||||
const auto [v, err] = m_fields.at(k);
|
oxRequire(v, m_fields.at(k));
|
||||||
if (err) [[unlikely]] {
|
return &(*v)->value;
|
||||||
oxPanic(err, ox::sfmt("field {} does not exist in type {}", k, buildTypeId(*m_type)).c_str());
|
|
||||||
}
|
|
||||||
return (*v)->value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto &operator[](const std::size_t i) noexcept {
|
constexpr auto &operator[](const std::size_t i) noexcept {
|
||||||
|
27
deps/ox/src/ox/preloader/preloader.hpp
vendored
27
deps/ox/src/ox/preloader/preloader.hpp
vendored
@ -174,12 +174,12 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const T *val)
|
|||||||
}
|
}
|
||||||
oxReturnError(pad(val));
|
oxReturnError(pad(val));
|
||||||
if constexpr(ox::is_integral_v<T>) {
|
if constexpr(ox::is_integral_v<T>) {
|
||||||
return ox::serialize(&m_writer, PlatSpec::correctEndianness(*val));
|
return ox::serialize(m_writer, PlatSpec::correctEndianness(*val));
|
||||||
} else if constexpr(ox::is_pointer_v<T>) {
|
} else if constexpr(ox::is_pointer_v<T>) {
|
||||||
const PtrType a = startAlloc(sizeOf<PlatSpec>(val), alignOf<PlatSpec>(*val), m_writer.tellp()) + PlatSpec::RomStart;
|
const PtrType a = startAlloc(sizeOf<PlatSpec>(val), alignOf<PlatSpec>(*val), m_writer.tellp()) + PlatSpec::RomStart;
|
||||||
oxReturnError(field(name, *val));
|
oxReturnError(field(name, *val));
|
||||||
oxReturnError(endAlloc());
|
oxReturnError(endAlloc());
|
||||||
return ox::serialize(&m_writer, PlatSpec::correctEndianness(a));
|
return ox::serialize(m_writer, PlatSpec::correctEndianness(a));
|
||||||
} else if constexpr(ox::isVector_v<T>) {
|
} else if constexpr(ox::isVector_v<T>) {
|
||||||
return fieldVector(name, val);
|
return fieldVector(name, val);
|
||||||
} else if constexpr(ox::is_same_v<T, ox::ModelValueVector>) {
|
} else if constexpr(ox::is_same_v<T, ox::ModelValueVector>) {
|
||||||
@ -212,7 +212,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::BasicStri
|
|||||||
const auto restore = m_writer.tellp();
|
const auto restore = m_writer.tellp();
|
||||||
std::size_t a = 0;
|
std::size_t a = 0;
|
||||||
if (sz && sz >= SmallStringSize) {
|
if (sz && sz >= SmallStringSize) {
|
||||||
oxReturnError(ox::allocate(&m_writer, sz).moveTo(a));
|
oxReturnError(ox::allocate(m_writer, sz).moveTo(a));
|
||||||
} else {
|
} else {
|
||||||
a = restore;
|
a = restore;
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::BasicStri
|
|||||||
oxReturnError(m_writer.seekp(a));
|
oxReturnError(m_writer.seekp(a));
|
||||||
oxReturnError(m_writer.write(val->data(), sz));
|
oxReturnError(m_writer.write(val->data(), sz));
|
||||||
oxReturnError(m_writer.seekp(restore));
|
oxReturnError(m_writer.seekp(restore));
|
||||||
oxReturnError(serialize(&m_writer, vecVal));
|
oxReturnError(serialize(m_writer, vecVal));
|
||||||
m_ptrs.emplace_back(restore + offsetof(VecMap, items), vecVal.items);
|
m_ptrs.emplace_back(restore + offsetof(VecMap, items), vecVal.items);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(size_t sz, siz
|
|||||||
m_allocStack.emplace_back(static_cast<typename PlatSpec::PtrType>(m_writer.tellp()));
|
m_allocStack.emplace_back(static_cast<typename PlatSpec::PtrType>(m_writer.tellp()));
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
||||||
const auto padding = m_writer.tellp() % align;
|
const auto padding = m_writer.tellp() % align;
|
||||||
oxRequireM(a, ox::allocate(&m_writer, sz + padding));
|
oxRequireM(a, ox::allocate(m_writer, sz + padding));
|
||||||
a += padding;
|
a += padding;
|
||||||
oxReturnError(m_writer.seekp(a));
|
oxReturnError(m_writer.seekp(a));
|
||||||
m_allocStart.push_back(a);
|
m_allocStart.push_back(a);
|
||||||
@ -274,11 +274,12 @@ constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(size_t sz, siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename PlatSpec>
|
template<typename PlatSpec>
|
||||||
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(std::size_t sz, size_t align, std::size_t restore) noexcept {
|
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(
|
||||||
|
std::size_t sz, size_t align, std::size_t restore) noexcept {
|
||||||
m_allocStack.emplace_back(restore, ox::ios_base::beg);
|
m_allocStack.emplace_back(restore, ox::ios_base::beg);
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
||||||
const auto padding = m_writer.tellp() % align;
|
const auto padding = m_writer.tellp() % align;
|
||||||
oxRequireM(a, ox::allocate(&m_writer, sz + padding));
|
oxRequireM(a, ox::allocate(m_writer, sz + padding));
|
||||||
a += padding;
|
a += padding;
|
||||||
oxReturnError(m_writer.seekp(a));
|
oxReturnError(m_writer.seekp(a));
|
||||||
m_allocStart.push_back(a);
|
m_allocStart.push_back(a);
|
||||||
@ -301,8 +302,9 @@ template<typename PlatSpec>
|
|||||||
constexpr ox::Error Preloader<PlatSpec>::offsetPtrs(std::size_t offset) noexcept {
|
constexpr ox::Error Preloader<PlatSpec>::offsetPtrs(std::size_t offset) noexcept {
|
||||||
for (const auto &p : m_ptrs) {
|
for (const auto &p : m_ptrs) {
|
||||||
oxReturnError(m_writer.seekp(p.loc));
|
oxReturnError(m_writer.seekp(p.loc));
|
||||||
const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(static_cast<typename PlatSpec::PtrType>(p.value + offset));
|
const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(
|
||||||
oxReturnError(ox::serialize(&m_writer, val));
|
static_cast<typename PlatSpec::PtrType>(p.value + offset));
|
||||||
|
oxReturnError(ox::serialize(m_writer, val));
|
||||||
}
|
}
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
||||||
return {};
|
return {};
|
||||||
@ -321,7 +323,8 @@ constexpr ox::Error Preloader<PlatSpec>::pad(const T *v) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename PlatSpec>
|
template<typename PlatSpec>
|
||||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView name, const ox::ModelValueVector *val) noexcept {
|
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
||||||
|
CRStringView name, const ox::ModelValueVector *val) noexcept {
|
||||||
// serialize the Vector
|
// serialize the Vector
|
||||||
ox::VectorMemMap<PlatSpec> vecVal{
|
ox::VectorMemMap<PlatSpec> vecVal{
|
||||||
.size = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
|
.size = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
|
||||||
@ -356,7 +359,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
|||||||
const auto align = alignOf<PlatSpec>((*val)[0]);
|
const auto align = alignOf<PlatSpec>((*val)[0]);
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
||||||
const auto padding = m_writer.tellp() % align;
|
const auto padding = m_writer.tellp() % align;
|
||||||
oxRequireM(p, ox::allocate(&m_writer, sz + padding));
|
oxRequireM(p, ox::allocate(m_writer, sz + padding));
|
||||||
p += padding;
|
p += padding;
|
||||||
oxReturnError(m_writer.seekp(p));
|
oxReturnError(m_writer.seekp(p));
|
||||||
m_unionIdx.emplace_back(-1);
|
m_unionIdx.emplace_back(-1);
|
||||||
@ -371,7 +374,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
|||||||
vecVal.items = 0;
|
vecVal.items = 0;
|
||||||
}
|
}
|
||||||
// serialize the Vector
|
// serialize the Vector
|
||||||
oxReturnError(serialize(&m_writer, vecVal));
|
oxReturnError(serialize(m_writer, vecVal));
|
||||||
m_ptrs.emplace_back(m_writer.tellp() - PtrSize, vecVal.items);
|
m_ptrs.emplace_back(m_writer.tellp() - PtrSize, vecVal.items);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
15
deps/ox/src/ox/std/reader.hpp
vendored
15
deps/ox/src/ox/std/reader.hpp
vendored
@ -78,19 +78,4 @@ class FileReader: public Reader_v {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates the specified amount of data at the end of the current read stream.
|
|
||||||
* @param reader
|
|
||||||
* @param sz
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
constexpr ox::Result<std::size_t> allocate(Reader_c auto *reader, std::size_t sz) noexcept {
|
|
||||||
const auto p = reader->tellg();
|
|
||||||
oxReturnError(reader->seekg(0, ios_base::end));
|
|
||||||
const auto out = reader->tellg();
|
|
||||||
oxReturnError(reader->read(nullptr, sz));
|
|
||||||
oxReturnError(reader->seekg(p));
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
26
deps/ox/src/ox/std/serialize.hpp
vendored
26
deps/ox/src/ox/std/serialize.hpp
vendored
@ -54,41 +54,41 @@ constexpr auto alignOf(const VectorMemMap<PlatSpec>&) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename PlatSpec, typename T>
|
template<typename PlatSpec, typename T>
|
||||||
constexpr ox::Error pad(Writer_c auto *w, const T *v) noexcept {
|
constexpr ox::Error pad(Writer_c auto &w, const T *v) noexcept {
|
||||||
const auto a = PlatSpec::alignOf(*v);
|
const auto a = PlatSpec::alignOf(*v);
|
||||||
const auto excess = w->tellp() % a;
|
const auto excess = w.tellp() % a;
|
||||||
if (excess) {
|
if (excess) {
|
||||||
return w->write(nullptr, a - excess);
|
return w.write(nullptr, a - excess);
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PlatSpec>
|
template<typename PlatSpec>
|
||||||
constexpr ox::Error serialize(Writer_c auto *buff, const VectorMemMap<PlatSpec> &vm) noexcept {
|
constexpr ox::Error serialize(Writer_c auto &w, const VectorMemMap<PlatSpec> &vm) noexcept {
|
||||||
oxReturnError(buff->write(nullptr, vm.smallVecSize));
|
oxReturnError(w.write(nullptr, vm.smallVecSize));
|
||||||
oxReturnError(serialize(buff, PlatSpec::correctEndianness(vm.allocator)));
|
oxReturnError(serialize(w, PlatSpec::correctEndianness(vm.allocator)));
|
||||||
oxReturnError(pad<PlatSpec>(buff, &vm.size));
|
oxReturnError(pad<PlatSpec>(w, &vm.size));
|
||||||
oxReturnError(serialize(buff, PlatSpec::correctEndianness(vm.size)));
|
oxReturnError(serialize(w, PlatSpec::correctEndianness(vm.size)));
|
||||||
oxReturnError(serialize(buff, PlatSpec::correctEndianness(vm.cap)));
|
oxReturnError(serialize(w, PlatSpec::correctEndianness(vm.cap)));
|
||||||
oxReturnError(serialize(buff, PlatSpec::correctEndianness(vm.items)));
|
oxReturnError(serialize(w, PlatSpec::correctEndianness(vm.items)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr ox::Error serialize(Writer_c auto *buff, T val) noexcept requires(is_integer_v<T>) {
|
constexpr ox::Error serialize(Writer_c auto &w, T val) noexcept requires(is_integer_v<T>) {
|
||||||
ox::Array<char, sizeof(T)> tmp;
|
ox::Array<char, sizeof(T)> tmp;
|
||||||
for (auto i = 0u; i < sizeof(T); ++i) {
|
for (auto i = 0u; i < sizeof(T); ++i) {
|
||||||
tmp[i] = static_cast<char>((val >> i * 8) & 255);
|
tmp[i] = static_cast<char>((val >> i * 8) & 255);
|
||||||
}
|
}
|
||||||
return buff->write(tmp.data(), tmp.size());
|
return w.write(tmp.data(), tmp.size());
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr ox::Result<ox::Array<char, sizeof(T)>> serialize(const T &in) noexcept {
|
constexpr ox::Result<ox::Array<char, sizeof(T)>> serialize(const T &in) noexcept {
|
||||||
ox::Array<char, sizeof(T)> out = {};
|
ox::Array<char, sizeof(T)> out = {};
|
||||||
CharBuffWriter w(out);
|
CharBuffWriter w(out);
|
||||||
oxReturnError(serialize(&w, in));
|
oxReturnError(serialize(w, in));
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
12
deps/ox/src/ox/std/writer.hpp
vendored
12
deps/ox/src/ox/std/writer.hpp
vendored
@ -72,12 +72,12 @@ class WriterT: public Writer_v {
|
|||||||
* @param sz
|
* @param sz
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
constexpr ox::Result<std::size_t> allocate(Writer_c auto *writer, std::size_t sz) noexcept {
|
constexpr ox::Result<std::size_t> allocate(Writer_c auto &writer, std::size_t sz) noexcept {
|
||||||
const auto p = writer->tellp();
|
const auto p = writer.tellp();
|
||||||
oxReturnError(writer->seekp(0, ios_base::end));
|
oxReturnError(writer.seekp(0, ios_base::end));
|
||||||
const auto out = writer->tellp();
|
const auto out = writer.tellp();
|
||||||
oxReturnError(writer->write(nullptr, sz));
|
oxReturnError(writer.write(nullptr, sz));
|
||||||
oxReturnError(writer->seekp(p));
|
oxReturnError(writer.seekp(p));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,16 +94,16 @@ class Converter: public BaseConverter {
|
|||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool srcMatches(ox::CRStringView pSrcTypeName, int pSrcTypeVersion) const noexcept final {
|
bool srcMatches(ox::CRStringView pSrcTypeName, int pSrcTypeVersion) const noexcept final {
|
||||||
static const auto SrcTypeName = ox::requireModelTypeName<SrcType>();
|
constexpr auto SrcTypeName = ox::requireModelTypeName<SrcType>();
|
||||||
static const auto SrcTypeVersion = ox::requireModelTypeVersion<SrcType>();
|
constexpr auto SrcTypeVersion = ox::requireModelTypeVersion<SrcType>();
|
||||||
return pSrcTypeName == SrcTypeName
|
return pSrcTypeName == SrcTypeName
|
||||||
&& pSrcTypeVersion == SrcTypeVersion;
|
&& pSrcTypeVersion == SrcTypeVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept final {
|
bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept final {
|
||||||
static const auto DstTypeName = ox::StringView(ox::requireModelTypeName<DstType>());
|
constexpr auto DstTypeName = ox::StringView(ox::requireModelTypeName<DstType>());
|
||||||
static const auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||||
return dstTypeName == DstTypeName
|
return dstTypeName == DstTypeName
|
||||||
&& dstTypeVersion == DstTypeVersion;
|
&& dstTypeVersion == DstTypeVersion;
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,15 @@ namespace keel {
|
|||||||
static ox::Error pathToInode(
|
static ox::Error pathToInode(
|
||||||
keel::Context &ctx, ox::FileSystem &dest, ox::ModelObject &obj) noexcept {
|
keel::Context &ctx, ox::FileSystem &dest, ox::ModelObject &obj) noexcept {
|
||||||
auto &o = obj;
|
auto &o = obj;
|
||||||
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
|
auto type = static_cast<ox::FileAddressType>(o.at("type").unwrap()->get<int8_t>());
|
||||||
auto &data = o["data"].get<ox::ModelUnion>();
|
auto &data = o.at("data").unwrap()->get<ox::ModelUnion>();
|
||||||
ox::String path;
|
ox::String path;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ox::FileAddressType::Path:
|
case ox::FileAddressType::Path:
|
||||||
path = data["path"].get<ox::String>();
|
path = data.at("path").unwrap()->get<ox::String>();
|
||||||
break;
|
break;
|
||||||
case ox::FileAddressType::ConstPath:
|
case ox::FileAddressType::ConstPath:
|
||||||
path = data["constPath"].get<ox::String>();
|
path = data.at("constPath").unwrap()->get<ox::String>();
|
||||||
break;
|
break;
|
||||||
case ox::FileAddressType::Inode:
|
case ox::FileAddressType::Inode:
|
||||||
case ox::FileAddressType::None:
|
case ox::FileAddressType::None:
|
||||||
@ -33,7 +33,7 @@ static ox::Error pathToInode(
|
|||||||
oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path));
|
oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path));
|
||||||
}
|
}
|
||||||
oxRequire(s, dest.stat(path));
|
oxRequire(s, dest.stat(path));
|
||||||
oxReturnError(o["type"].set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
oxReturnError(o.at("type").unwrap()->set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
||||||
oxOutf("path to inode: {} => {}\n", path, s.inode);
|
oxOutf("path to inode: {} => {}\n", path, s.inode);
|
||||||
return data.set(2, s.inode);
|
return data.set(2, s.inode);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user