From 345fb0385772beea7597a68361360dcf075beb46 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 13 Dec 2024 22:06:47 -0600 Subject: [PATCH] [ox] Remove OxError --- deps/ox/src/ox/claw/read.cpp | 20 +++--- deps/ox/src/ox/claw/read.hpp | 8 +-- deps/ox/src/ox/claw/test/tests.cpp | 14 ++-- deps/ox/src/ox/claw/write.hpp | 6 +- deps/ox/src/ox/event/signal.hpp | 8 +-- deps/ox/src/ox/event/test/tests.cpp | 8 +-- .../src/ox/fs/filestore/filestoretemplate.hpp | 70 +++++++++---------- deps/ox/src/ox/fs/filesystem/directory.hpp | 22 +++--- deps/ox/src/ox/fs/filesystem/filelocation.hpp | 4 +- deps/ox/src/ox/fs/filesystem/filesystem.cpp | 14 ++-- deps/ox/src/ox/fs/filesystem/filesystem.hpp | 18 ++--- .../ox/src/ox/fs/filesystem/passthroughfs.cpp | 44 ++++++------ .../ox/src/ox/fs/filesystem/passthroughfs.hpp | 4 +- deps/ox/src/ox/fs/filesystem/pathiterator.cpp | 20 +++--- deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp | 26 +++---- deps/ox/src/ox/fs/ptrarith/ptr.hpp | 2 +- deps/ox/src/ox/fs/test/tests.cpp | 26 +++---- deps/ox/src/ox/fs/tool.cpp | 16 ++--- deps/ox/src/ox/logconn/circularbuff.hpp | 8 +-- deps/ox/src/ox/logconn/logconn.cpp | 4 +- deps/ox/src/ox/mc/presenceindicator.hpp | 4 +- deps/ox/src/ox/mc/read.hpp | 24 +++---- deps/ox/src/ox/mc/test/tests.cpp | 34 ++++----- deps/ox/src/ox/mc/write.hpp | 14 ++-- deps/ox/src/ox/model/def.hpp | 2 +- deps/ox/src/ox/model/desctypes.hpp | 2 +- deps/ox/src/ox/model/descwrite.hpp | 14 ++-- deps/ox/src/ox/model/fieldcounter.hpp | 8 +-- deps/ox/src/ox/model/modelhandleradaptor.hpp | 4 +- deps/ox/src/ox/model/modelops.hpp | 30 ++++---- deps/ox/src/ox/model/modelvalue.cpp | 4 +- deps/ox/src/ox/model/modelvalue.hpp | 24 +++---- deps/ox/src/ox/model/test/tests.cpp | 2 +- deps/ox/src/ox/model/typenamecatcher.hpp | 12 ++-- deps/ox/src/ox/model/typestore.hpp | 4 +- deps/ox/src/ox/model/walk.hpp | 4 +- deps/ox/src/ox/oc/read.cpp | 22 +++--- deps/ox/src/ox/oc/read.hpp | 36 +++++----- deps/ox/src/ox/oc/test/tests.cpp | 14 ++-- deps/ox/src/ox/oc/write.cpp | 2 +- deps/ox/src/ox/oc/write.hpp | 24 +++---- deps/ox/src/ox/std/assert.hpp | 4 +- deps/ox/src/ox/std/buffer.hpp | 18 ++--- deps/ox/src/ox/std/error.hpp | 7 +- deps/ox/src/ox/std/hashmap.hpp | 4 +- deps/ox/src/ox/std/heapmgr.cpp | 4 +- deps/ox/src/ox/std/istring.hpp | 6 +- deps/ox/src/ox/std/new.hpp | 6 +- deps/ox/src/ox/std/reader.cpp | 12 ++-- deps/ox/src/ox/std/smallmap.hpp | 4 +- deps/ox/src/ox/std/string.hpp | 2 +- deps/ox/src/ox/std/stringview.hpp | 2 +- deps/ox/src/ox/std/strops.hpp | 2 +- deps/ox/src/ox/std/test/tests.cpp | 42 +++++------ deps/ox/src/ox/std/uuid.cpp | 2 +- deps/ox/src/ox/std/uuid.hpp | 8 +-- deps/ox/src/ox/std/vector.hpp | 18 ++--- 57 files changed, 383 insertions(+), 384 deletions(-) diff --git a/deps/ox/src/ox/claw/read.cpp b/deps/ox/src/ox/claw/read.cpp index eb489be6..806ff7e1 100644 --- a/deps/ox/src/ox/claw/read.cpp +++ b/deps/ox/src/ox/claw/read.cpp @@ -18,7 +18,7 @@ ox::Result readClawTypeId(ox::BufferView buff) noexcept { size_t outSz{}; const auto s1End = ox::strchr(buffRaw, ';', buffLen); if (!s1End) { - return OxError(1, "Could not read Claw header"); + return ox::Error(1, "Could not read Claw header"); } auto const fmtSz = static_cast(s1End - buffRaw) + 1; buffRaw += fmtSz; @@ -26,7 +26,7 @@ ox::Result readClawTypeId(ox::BufferView buff) noexcept { outSz += fmtSz; auto const s2End = ox::strchr(buffRaw, ';', buffLen); if (!s2End) { - return OxError(2, "Could not read Claw header"); + return ox::Error(2, "Could not read Claw header"); } auto const s2Size = static_cast(s2End - buffRaw) + 1; buffRaw += s2Size; @@ -34,7 +34,7 @@ ox::Result readClawTypeId(ox::BufferView buff) noexcept { outSz += s2Size; auto const s3End = ox::strchr(buffRaw, ';', buffLen) + 1; if (!s3End) { - return OxError(3, "Could not read Claw header"); + return ox::Error(3, "Could not read Claw header"); } auto const s3Size = static_cast(s3End - buffRaw); buffRaw += s3Size; @@ -48,7 +48,7 @@ Result readClawHeader(ox::BufferView buff) noexcept { auto buffLen = buff.size(); const auto s1End = ox::strchr(buffRaw, ';', buffLen); if (!s1End) { - return OxError(1, "Could not read Claw header"); + return ox::Error(1, "Could not read Claw header"); } auto const s1Size = static_cast(s1End - buffRaw); StringView const fmt(buffRaw, s1Size); @@ -57,7 +57,7 @@ Result readClawHeader(ox::BufferView buff) noexcept { auto const s2End = ox::strchr(buffRaw, ';', buffLen); if (!s2End) { - return OxError(2, "Could not read Claw header"); + return ox::Error(2, "Could not read Claw header"); } auto const s2Size = static_cast(s2End - buffRaw); StringView const typeName(buffRaw, s2Size); @@ -66,7 +66,7 @@ Result readClawHeader(ox::BufferView buff) noexcept { auto const s3End = ox::strchr(buffRaw, ';', buffLen); if (!s3End) { - return OxError(3, "Could not read Claw header"); + return ox::Error(3, "Could not read Claw header"); } auto const s3Size = static_cast(s3End - buffRaw); StringView const versionStr(buffRaw, s3Size); @@ -78,7 +78,7 @@ Result readClawHeader(ox::BufferView buff) noexcept { } else if (fmt == "O1") { hdr.fmt = ClawFormat::Organic; } else { - return OxError(4, "Claw format does not match any supported format/version combo"); + return ox::Error(4, "Claw format does not match any supported format/version combo"); } hdr.typeName = typeName; std::ignore = ox::atoi(versionStr).copyTo(hdr.typeVersion); @@ -97,7 +97,7 @@ Result readClaw(TypeStore &ts, BufferView buff) noexcept { auto const [t, tdErr] = ts.getLoad( header.typeName, header.typeVersion, header.typeParams); if (tdErr) { - return OxError(3, "Could not load type descriptor"); + return ox::Error(3, "Could not load type descriptor"); } ModelObject obj; oxReturnError(obj.setType(t)); @@ -122,9 +122,9 @@ Result readClaw(TypeStore &ts, BufferView buff) noexcept { #endif } case ClawFormat::None: - return OxError(1); + return ox::Error(1); } - return OxError(1); + return ox::Error(1); } } diff --git a/deps/ox/src/ox/claw/read.hpp b/deps/ox/src/ox/claw/read.hpp index c625ee22..4ec1b09c 100644 --- a/deps/ox/src/ox/claw/read.hpp +++ b/deps/ox/src/ox/claw/read.hpp @@ -42,10 +42,10 @@ template Error readClaw(ox::BufferView buff, T &val) { oxRequire(header, readClawHeader(buff)); if (header.typeName != getModelTypeName()) { - return OxError(Error_ClawTypeMismatch, "Claw Read: Type mismatch"); + return ox::Error(Error_ClawTypeMismatch, "Claw Read: Type mismatch"); } if (header.typeVersion != getModelTypeVersion()) { - return OxError(Error_ClawTypeVersionMismatch, "Claw Read: Type Version mismatch"); + return ox::Error(Error_ClawTypeVersionMismatch, "Claw Read: Type Version mismatch"); } switch (header.fmt) { case ClawFormat::Metal: @@ -65,9 +65,9 @@ Error readClaw(ox::BufferView buff, T &val) { #endif } case ClawFormat::None: - return OxError(1); + return ox::Error(1); } - return OxError(1); + return ox::Error(1); } template diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index 90c1bffd..c37d662a 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -66,7 +66,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) { oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->fieldCString("String", &obj->String)); - return OxError(0); + return ox::Error(0); } template @@ -75,7 +75,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) { oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->field("String", &obj->String)); - return OxError(0); + return ox::Error(0); } template @@ -100,7 +100,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) { oxReturnError(io->field("List", obj->List, 4)); oxReturnError(io->field("EmptyStruct", &obj->EmptyStruct)); oxReturnError(io->field("Struct", &obj->Struct)); - return OxError(0); + return ox::Error(0); } static std::map tests = { @@ -114,7 +114,7 @@ static std::map tests = { oxAssert(ch.fmt == ox::ClawFormat::Organic, "Format wrong"); oxAssert(ch.typeName == "com.drinkingtea.ox.claw.test.Header", "Type name wrong"); oxAssert(ch.typeVersion == 2, "Type version wrong"); - return OxError(0); + return ox::Error(0); } }, { @@ -126,7 +126,7 @@ static std::map tests = { oxAssert(ch.fmt == ox::ClawFormat::Metal, "Format wrong"); oxAssert(ch.typeName == "com.drinkingtea.ox.claw.test.Header2", "Type name wrong"); oxAssert(ch.typeVersion == 3, "Type version wrong"); - return OxError(0); + return ox::Error(0); } }, { @@ -146,7 +146,7 @@ static std::map tests = { // doesn't segfault TestStruct ts; oxReturnError(ox::writeClaw(ts, ox::ClawFormat::Metal)); - return OxError(0); + return ox::Error(0); } }, { @@ -191,7 +191,7 @@ static std::map tests = { oxAssert(testIn.Struct.String == testOut.Struct.String, "Struct.String value mismatch"); oxAssert(testIn.Struct.Bool == testOut.Struct.Bool, "Struct.Bool value mismatch"); - return OxError(0); + return ox::Error(0); } }, } diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index ba0890ef..1e163c35 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -39,7 +39,7 @@ struct TypeInfoCatcher { } constexpr Error field(...) noexcept { - return OxError(0); + return ox::Error(0); } static constexpr auto opType() { @@ -82,7 +82,7 @@ ox::Error writeClawHeader(Writer_c auto &writer, const T *t, ClawFormat fmt) noe oxReturnError(write(writer, "O1;")); break; default: - return OxError(1); + return ox::Error(1); } oxReturnError(write(writer, detail::getTypeName(t))); oxReturnError(writer.put(';')); @@ -112,7 +112,7 @@ Result writeClaw( } #else if (fmt != ClawFormat::Metal) { - return OxError(1, "OC is not supported in this build"); + return ox::Error(1, "OC is not supported in this build"); } oxReturnError(writeMC(bw, t)); #endif diff --git a/deps/ox/src/ox/event/signal.hpp b/deps/ox/src/ox/event/signal.hpp index fe1c2ab0..bb947b0b 100644 --- a/deps/ox/src/ox/event/signal.hpp +++ b/deps/ox/src/ox/event/signal.hpp @@ -197,7 +197,7 @@ Error Signal::disconnectObject(const void *receiver) const noexcept { --i; } } - return OxError(1, "Signal::disconnectObject: Receiver was not found among this Signal's slots"); + return ox::Error(1, "Signal::disconnectObject: Receiver was not found among this Signal's slots"); } template @@ -213,7 +213,7 @@ Error Signal::emitCheckError(Args... args) const noexcept { for (auto &f : m_slots) { f->call(args...); } - return OxError(0); + return ox::Error(0); } catch (const ox::Exception &ex) { return ox::Error(ex.file, ex.line, ex.errCode, ex.msg); } @@ -385,7 +385,7 @@ Error Signal::disconnectObject(const void *receiver) const noexc --i; } } - return OxError(1, "Signal::disconnectObject: Receiver was not found among this Signal's slots"); + return ox::Error(1, "Signal::disconnectObject: Receiver was not found among this Signal's slots"); } template @@ -400,7 +400,7 @@ Error Signal::emitCheckError(Args... args) const noexcept { for (auto &f : m_slots) { oxReturnError(f->call(ox::forward(args)...)); } - return OxError(0); + return ox::Error(0); } } diff --git a/deps/ox/src/ox/event/test/tests.cpp b/deps/ox/src/ox/event/test/tests.cpp index 10045879..975609fa 100644 --- a/deps/ox/src/ox/event/test/tests.cpp +++ b/deps/ox/src/ox/event/test/tests.cpp @@ -17,7 +17,7 @@ struct TestStruct: public ox::SignalHandler { int value = 0; ox::Error method(int i) noexcept { value = i; - return OxError(0); + return ox::Error(0); } }; @@ -27,13 +27,13 @@ std::map> tests = { [] { ox::Signal signal; signal.connect([](int i) -> ox::Error { - return OxError(i != 5); + return ox::Error(i != 5); }); TestStruct ts; signal.connect(&ts, &TestStruct::method); oxReturnError(signal.emitCheckError(5)); - oxReturnError(OxError(ts.value != 5)); - return OxError(0); + oxReturnError(ox::Error(ts.value != 5)); + return ox::Error(0); } }, }; diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp index 12367e48..b6407e9d 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp @@ -207,12 +207,12 @@ Error FileStoreTemplate::format(void *buffer, std::size_t bufferSize) { auto fsData = nb->malloc(sizeof(FileStoreData)).value; if (!fsData.valid()) { oxTrace("ox.fs.FileStoreTemplate.format.fail", "Could not read data section of FileStoreData"); - return OxError(1, "Could not read data section of FileStoreData"); + return ox::Error(1, "Could not read data section of FileStoreData"); } auto data = nb->template dataOf(fsData); if (!data.valid()) { oxTrace("ox.fs.FileStoreTemplate.format.fail", "Could not read data section of FileStoreData"); - return OxError(1, "Could not read data section of FileStoreData"); + return ox::Error(1, "Could not read data section of FileStoreData"); } new (data) FileStoreData; return {}; @@ -223,14 +223,14 @@ Error FileStoreTemplate::setSize(std::size_t size) { if (m_buffSize >= size) { return m_buffer->setSize(static_cast(size)); } - return OxError(1); + return ox::Error(1); } template Error FileStoreTemplate::incLinks(uint64_t id) { oxRequireM(item, find(static_cast(id)).validate()); ++item->links; - return OxError(0); + return ox::Error(0); } template @@ -240,7 +240,7 @@ Error FileStoreTemplate::decLinks(uint64_t id) { if (item->links == 0) { oxReturnError(remove(item)); } - return OxError(0); + return ox::Error(0); } template @@ -298,7 +298,7 @@ Error FileStoreTemplate::write(uint64_t id64, const void *data, FsSize_t dest->id.get(), dest.offset(), destData.size()); fsData->rootNode = dest.offset(); oxTracef("ox.fs.FileStoreTemplate.write", "Root inode: {}", dest->id.get()); - return OxError(0); + return ox::Error(0); } } else { oxTrace("ox.fs.FileStoreTemplate.write.fail", "Could not place item due to absence of FileStore header."); @@ -307,7 +307,7 @@ Error FileStoreTemplate::write(uint64_t id64, const void *data, FsSize_t } oxReturnError(m_buffer->free(dest)); } - return OxError(1); + return ox::Error(1); } template @@ -322,7 +322,7 @@ Error FileStoreTemplate::read(uint64_t id, void *out, FsSize_t outSize, // error check if (!src.valid()) { oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not find requested item: {}", id); - return OxError(1, "Could not find requested item"); + return ox::Error(1, "Could not find requested item"); } auto srcData = m_buffer->template dataOf(src); @@ -335,7 +335,7 @@ Error FileStoreTemplate::read(uint64_t id, void *out, FsSize_t outSize, oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not read data section of item: {}", id); oxTracef("ox.fs.FileStoreTemplate.read.fail", "Item data section size: {}, Expected size: {}", srcData.size(), outSize); - return OxError(1, "Invalid inode"); + return ox::Error(1, "Invalid inode"); } ox::memcpy(out, srcData, srcData.size()); @@ -353,7 +353,7 @@ Error FileStoreTemplate::read(uint64_t id, FsSize_t readStart, FsSize_t // error check if (!src.valid()) { oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not find requested item: {}", id); - return OxError(1); + return ox::Error(1); } auto srcData = m_buffer->template dataOf(src); @@ -366,7 +366,7 @@ Error FileStoreTemplate::read(uint64_t id, FsSize_t readStart, FsSize_t oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not read data section of item: {}", id); oxTracef("ox.fs.FileStoreTemplate.read.fail", "Item data section size: {}, Expected size: {}", srcData.size(), readSize); - return OxError(1); + return ox::Error(1); } ox::memcpy(out, srcData.get() + readStart, readSize); @@ -386,7 +386,7 @@ Error FileStoreTemplate::read(uint64_t id, FsSize_t readStart, // error check if (!src.valid()) { oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not find requested item: {}", id); - return OxError(1); + return ox::Error(1); } auto srcData = m_buffer->template dataOf(src); @@ -399,7 +399,7 @@ Error FileStoreTemplate::read(uint64_t id, FsSize_t readStart, oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not read data section of item: {}", id); oxTracef("ox.fs.FileStoreTemplate.read.fail", "Item data section size: {}, Expected size: {}", srcData.size(), readSize); - return OxError(1); + return ox::Error(1); } ox::memcpy(out, srcData.get() + readStart, readSize); @@ -427,20 +427,20 @@ Error FileStoreTemplate::resize() { oxTracef("ox.fs.FileStoreTemplate.resize", "resize to: {}", newSize); oxReturnError(m_buffer->setSize(newSize)); oxTracef("ox.fs.FileStoreTemplate.resize", "resized to: {}", m_buffer->size()); - return OxError(0); + return ox::Error(0); } template Error FileStoreTemplate::resize(std::size_t size, void *newBuff) { if (m_buffer->size() > size) { - return OxError(1); + return ox::Error(1); } m_buffSize = static_cast(size); if (newBuff) { m_buffer = reinterpret_cast(newBuff); oxReturnError(m_buffer->setSize(static_cast(size))); } - return OxError(0); + return ox::Error(0); } template @@ -479,14 +479,14 @@ Error FileStoreTemplate::walk(Error(*cb)(uint8_t, uint64_t, uint64_t)) { for (auto i = m_buffer->iterator(); i.valid(); i.next()) { oxReturnError(cb(i->fileType, i.ptr().offset(), i.ptr().end())); } - return OxError(0); + return ox::Error(0); } template Result::InodeId_t> FileStoreTemplate::generateInodeId() { auto fsData = fileStoreData(); if (!fsData) { - return OxError(1); + return ox::Error(1); } for (auto i = 0; i < 100; i++) { auto inode = static_cast::InodeId_t>(fsData->random.gen() % MaxValue); @@ -494,7 +494,7 @@ Result::InodeId_t> FileStoreTemplate: return inode; } } - return OxError(2); + return ox::Error(2); } template @@ -503,10 +503,10 @@ Error FileStoreTemplate::compact() { return m_buffer->compact([this, &isFirstItem](uint64_t oldAddr, ItemPtr item) -> Error { if (isFirstItem) { isFirstItem = false; - return OxError(0); + return ox::Error(0); } if (!item.valid()) { - return OxError(1); + return ox::Error(1); } oxTracef("ox.fs.FileStoreTemplate.compact.moveItem", "Moving Item: {} from {} to {}", item->id.get(), oldAddr, item.offset()); // update rootInode if this is it @@ -524,7 +524,7 @@ Error FileStoreTemplate::compact() { parent->right = item; } } - return OxError(0); + return ox::Error(0); }); } @@ -544,7 +544,7 @@ template Error FileStoreTemplate::placeItem(ItemPtr item) { auto fsData = fileStoreData(); if (!fsData) { - return OxError(1); + return ox::Error(1); } oxRequireM(root, m_buffer->ptr(fsData->rootNode).validate()); if (root->id == item->id) { @@ -552,7 +552,7 @@ Error FileStoreTemplate::placeItem(ItemPtr item) { item->left = root->left; item->right = root->right; oxTracef("ox.fs.FileStoreTemplate.placeItem", "Overwrote Root Item: {}", item->id.get()); - return OxError(0); + return ox::Error(0); } else { return placeItem(root, item); } @@ -562,7 +562,7 @@ template Error FileStoreTemplate::placeItem(ItemPtr root, ItemPtr item, int depth) { if (depth > 5000) { oxTrace("ox.fs.FileStoreTemplate.placeItem.fail", "Excessive recursion depth, stopping before stack overflow."); - return OxError(2); + return ox::Error(2); } if (item->id > root->id) { auto right = m_buffer->ptr(root->right); @@ -573,7 +573,7 @@ Error FileStoreTemplate::placeItem(ItemPtr root, ItemPtr item, int depth item->right = right->right; } oxTracef("ox.fs.FileStoreTemplate.placeItem", "Placed Item: {}", item->id.get()); - return OxError(0); + return ox::Error(0); } else { return placeItem(right, item, depth + 1); } @@ -586,13 +586,13 @@ Error FileStoreTemplate::placeItem(ItemPtr root, ItemPtr item, int depth item->right = left->right; } oxTracef("ox.fs.FileStoreTemplate.placeItem", "Placed Item: {}", item->id.get()); - return OxError(0); + return ox::Error(0); } else { return placeItem(left, item, depth + 1); } } else { oxTrace("ox.fs.FileStoreTemplate.placeItem.fail", "Cannot insert an item on itself."); - return OxError(1, "Cannot insert an item on itself."); + return ox::Error(1, "Cannot insert an item on itself."); } } @@ -600,7 +600,7 @@ template Error FileStoreTemplate::unplaceItem(ItemPtr item) { auto fsData = fileStoreData(); if (!fsData) { - return OxError(1); + return ox::Error(1); } oxRequireM(root, m_buffer->ptr(fsData->rootNode).validate()); if (root->id == item->id) { @@ -624,7 +624,7 @@ Error FileStoreTemplate::unplaceItem(ItemPtr item) { } else { fsData->rootNode = 0; } - return OxError(0); + return ox::Error(0); } else { return unplaceItem(root, item); } @@ -634,7 +634,7 @@ template Error FileStoreTemplate::unplaceItem(ItemPtr root, ItemPtr item, int depth) { if (depth >= 5000) { oxTrace("ox.fs.FileStoreTemplate.unplaceItem.fail", "Excessive recursion depth, stopping before stack overflow."); - return OxError(1, "Excessive recursion depth, stopping before stack overflow."); + return ox::Error(1, "Excessive recursion depth, stopping before stack overflow."); } if (item->id > root->id) { auto right = m_buffer->ptr(root->right); @@ -653,7 +653,7 @@ Error FileStoreTemplate::unplaceItem(ItemPtr root, ItemPtr item, int dep return unplaceItem(left, item, depth + 1); } } else { - return OxError(1); + return ox::Error(1); } if (item->right) { oxReturnError(placeItem(m_buffer->ptr(item->right))); @@ -661,7 +661,7 @@ Error FileStoreTemplate::unplaceItem(ItemPtr root, ItemPtr item, int dep if (item->left) { oxReturnError(placeItem(m_buffer->ptr(item->left))); } - return OxError(0); + return ox::Error(0); } template @@ -669,9 +669,9 @@ Error FileStoreTemplate::remove(ItemPtr item) { if (item.valid()) { oxReturnError(unplaceItem(item)); oxReturnError(m_buffer->free(item)); - return OxError(0); + return ox::Error(0); } - return OxError(1); + return ox::Error(1); } template diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index 2dde5603..068e6498 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -55,7 +55,7 @@ struct OX_PACKED DirectoryEntry { ox::strncpy(d->name, name.data(), ox::min(maxStrSz, name.len())); return {}; } - return OxError(1); + return ox::Error(1); } ptrarith::Ptr data() noexcept { @@ -145,7 +145,7 @@ Error Directory::init() noexcept { auto buff = m_fs.read(m_inodeId).template to(); if (!buff.valid()) { m_size = 0; - return OxError(1); + return ox::Error(1); } new (buff) Buffer(Size); m_size = Size; @@ -164,7 +164,7 @@ Error Directory::mkdir(PathIterator path, bool parents) { // if this is not the last item in the path and parents is disabled, // return an error if (!parents && path.hasNext()) { - return OxError(1); + return ox::Error(1); } childInode = m_fs.generateInodeId(); oxTracef("ox.fs.Directory.mkdir", "Generated Inode ID: {}", childInode.value); @@ -203,7 +203,7 @@ Error Directory::write(PathIterator path, uint64_t inode64 return Directory(m_fs, nextChild).write(path.next(), inode); } else { oxTracef("ox.fs.Directory.write", "{} not found and not allowed to create it.", name); - return OxError(1, "File not found and not allowed to create it."); + return ox::Error(1, "File not found and not allowed to create it."); } } else { oxTrace("ox.fs.Directory.write", path.fullPath()); @@ -217,7 +217,7 @@ Error Directory::write(PathIterator path, uint64_t inode64 auto old = m_fs.read(m_inodeId).template to(); if (!old.valid()) { oxTrace("ox.fs.Directory.write.fail", "Could not read existing version of Directory"); - return OxError(1, "Could not read existing version of Directory"); + return ox::Error(1, "Could not read existing version of Directory"); } const auto pathSize = name.len() + 1; const auto entryDataSize = DirectoryEntry::DirectoryEntryData::spaceNeeded(pathSize); @@ -225,13 +225,13 @@ Error Directory::write(PathIterator path, uint64_t inode64 auto cpy = ox_malloca(newSize, Buffer, *old, oldStat.size); if (cpy == nullptr) { oxTrace("ox.fs.Directory.write.fail", "Could not allocate memory for copy of Directory"); - return OxError(1, "Could not allocate memory for copy of Directory"); + return ox::Error(1, "Could not allocate memory for copy of Directory"); } oxReturnError(cpy->setSize(newSize)); auto val = cpy->malloc(entryDataSize).value; if (!val.valid()) { oxTrace("ox.fs.Directory.write.fail", "Could not allocate memory for new directory entry"); - return OxError(1, "Could not allocate memory for new directory entry"); + return ox::Error(1, "Could not allocate memory for new directory entry"); } oxTracef("ox.fs.Directory.write", "Attempting to write Directory entry: {}", name); oxReturnError(val->init(inode, name, val.size())); @@ -259,7 +259,7 @@ Error Directory::remove(PathIterator path) noexcept { } } else { oxTrace("ox.fs.Directory.remove.fail", "Could not find directory buffer"); - return OxError(1, "Could not find directory buffer"); + return ox::Error(1, "Could not find directory buffer"); } return {}; } @@ -271,7 +271,7 @@ Error Directory::ls(F cb) noexcept { auto buff = m_fs.read(m_inodeId).template to(); if (!buff.valid()) { oxTrace("ox.fs.Directory.ls.fail", "Could not directory buffer"); - return OxError(1, "Could not directory buffer"); + return ox::Error(1, "Could not directory buffer"); } oxTrace("ox.fs.Directory.ls", "Found directory buffer."); for (auto i = buff->iterator(); i.valid(); i.next()) { @@ -291,7 +291,7 @@ Result Directory::findEntry auto buff = m_fs.read(m_inodeId).template to(); if (!buff.valid()) { oxTrace("ox.fs.Directory.findEntry.fail", "Could not findEntry directory buffer"); - return OxError(2, "Could not findEntry directory buffer"); + return ox::Error(2, "Could not findEntry directory buffer"); } oxTracef("ox.fs.Directory.findEntry", "Found directory buffer, size: {}", buff.size()); for (auto i = buff->iterator(); i.valid(); i.next()) { @@ -307,7 +307,7 @@ Result Directory::findEntry } } oxTrace("ox.fs.Directory.findEntry.fail", "Entry not present"); - return OxError(1, "Entry not present"); + return ox::Error(1, "Entry not present"); } template diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.hpp b/deps/ox/src/ox/fs/filesystem/filelocation.hpp index 99944ad8..ac6c8628 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.hpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.hpp @@ -89,7 +89,7 @@ class FileAddress { case FileAddressType::Inode: return m_data.inode; default: - return OxError(1); + return ox::Error(1); } } @@ -100,7 +100,7 @@ class FileAddress { case FileAddressType::ConstPath: return ox::CStringView(m_data.constPath); default: - return OxError(1); + return ox::Error(1); } } diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.cpp b/deps/ox/src/ox/fs/filesystem/filesystem.cpp index 5b9b7718..e3e4e3af 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.cpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.cpp @@ -21,7 +21,7 @@ Result MemFS::directAccess(const FileAddress &addr) const noexcept case FileAddressType::Path: return directAccess(StringView(addr.getPath().value)); default: - return OxError(1); + return ox::Error(1); } } @@ -33,7 +33,7 @@ Error FileSystem::read(const FileAddress &addr, void *buffer, std::size_t size) case FileAddressType::Path: return readFilePath(StringView(addr.getPath().value), buffer, size); default: - return OxError(1); + return ox::Error(1); } } @@ -57,9 +57,9 @@ Error FileSystem::read(const FileAddress &addr, std::size_t readStart, std::size return read(addr.getInode().value, readStart, readSize, buffer, size); case FileAddressType::ConstPath: case FileAddressType::Path: - return OxError(2, "Unsupported for path lookups"); + return ox::Error(2, "Unsupported for path lookups"); default: - return OxError(1); + return ox::Error(1); } } @@ -71,7 +71,7 @@ Error FileSystem::remove(const FileAddress &addr, bool recursive) noexcept { case FileAddressType::Path: return remove(StringView(addr.getPath().value), recursive); default: - return OxError(1); + return ox::Error(1); } } @@ -83,7 +83,7 @@ Error FileSystem::write(const FileAddress &addr, const void *buffer, uint64_t si case FileAddressType::Path: return writeFilePath(StringView(addr.getPath().value), buffer, size, fileType); default: - return OxError(1); + return ox::Error(1); } } @@ -95,7 +95,7 @@ Result FileSystem::stat(const FileAddress &addr) const noexcept { case FileAddressType::Path: return statPath(StringView(addr.getPath().value)); default: - return OxError(1); + return ox::Error(1); } } diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index a8c6110c..a0235736 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -298,10 +298,10 @@ Error FileSystemTemplate::format(void *buff, uint64_t buff if (!fs.read(fd.rootDirInode).valid()) { oxTrace("ox.fs.FileSystemTemplate.format.error", "FileSystemTemplate::format did not correctly create root directory"); - return OxError(1); + return ox::Error(1); } - return OxError(0); + return ox::Error(0); } template @@ -318,7 +318,7 @@ Error FileSystemTemplate::move(StringViewCR src, StringVie oxRequireM(inode, rootDir.find(src)); oxReturnError(rootDir.write(dest, inode)); oxReturnError(rootDir.remove(src)); - return OxError(0); + return ox::Error(0); } template @@ -328,7 +328,7 @@ Error FileSystemTemplate::readFilePath(StringViewCR path, Directory rootDir(m_fs, fd.rootDirInode); oxRequire(s, stat(path)); if (s.size > buffSize) { - return OxError(1, "Buffer to small to load file"); + return ox::Error(1, "Buffer to small to load file"); } return readFileInodeRange(s.inode, 0, static_cast(s.size), buffer, &buffSize); } @@ -346,7 +346,7 @@ Error FileSystemTemplate::readFileInode(uint64_t inode, vo oxTracef("ox.fs.FileSystemTemplate.readFileInode", "{}", inode); oxRequire(s, stat(inode)); if (s.size > buffSize) { - return OxError(1, "Buffer to small to load file"); + return ox::Error(1, "Buffer to small to load file"); } return readFileInodeRange(inode, 0, static_cast(s.size), buffer, &buffSize); } @@ -360,7 +360,7 @@ template Result FileSystemTemplate::directAccessInode(uint64_t inode) const noexcept { auto data = m_fs.read(inode); if (!data.valid()) { - return OxError(1, "Data not valid"); + return ox::Error(1, "Data not valid"); } return reinterpret_cast(data.get()); } @@ -370,7 +370,7 @@ Result> FileSystemTemplate::ls(StringViewCR Vector out; oxReturnError(ls(path, [&out](StringViewCR name, typename FileStore::InodeId_t) { out.emplace_back(name); - return OxError(0); + return ox::Error(0); })); return out; } @@ -398,9 +398,9 @@ Error FileSystemTemplate::remove(StringViewCR path, bool r } } else { oxTrace("FileSystemTemplate.remove.fail", "Tried to remove directory without recursive setting."); - return OxError(1); + return ox::Error(1); } - return OxError(0); + return ox::Error(0); } template diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp index 1fd7080b..ef6a3d63 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp @@ -39,7 +39,7 @@ Error PassThroughFS::mkdir(StringViewCR path, bool recursive) noexcept { success = true; } else { success = std::filesystem::create_directories(p, ec); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: mkdir failed")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: mkdir failed")); } } else { std::error_code ec; @@ -48,26 +48,26 @@ Error PassThroughFS::mkdir(StringViewCR path, bool recursive) noexcept { success = true; } else { success = std::filesystem::create_directory(p, ec); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: mkdir failed")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: mkdir failed")); } } - return OxError(success ? 0 : 1); + return ox::Error(success ? 0 : 1); } Error PassThroughFS::move(StringViewCR src, StringViewCR dest) noexcept { std::error_code ec; std::filesystem::rename(m_path / stripSlash(src), m_path / stripSlash(dest), ec); if (ec.value()) { - return OxError(1); + return ox::Error(1); } - return OxError(0); + return ox::Error(0); } Result> PassThroughFS::ls(StringViewCR dir) const noexcept { Vector out; std::error_code ec; const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: ls failed")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: ls failed")); for (const auto &p : di) { const auto u8p = p.path().filename().u8string(); out.emplace_back(reinterpret_cast(u8p.c_str())); @@ -77,20 +77,20 @@ Result> PassThroughFS::ls(StringViewCR dir) const noexcept { Error PassThroughFS::remove(StringViewCR path, bool recursive) noexcept { if (recursive) { - return OxError(std::filesystem::remove_all(m_path / stripSlash(path)) != 0); + return ox::Error(std::filesystem::remove_all(m_path / stripSlash(path)) != 0); } else { - return OxError(std::filesystem::remove(m_path / stripSlash(path)) != 0); + return ox::Error(std::filesystem::remove(m_path / stripSlash(path)) != 0); } } Error PassThroughFS::resize(uint64_t, void*) noexcept { // unsupported - return OxError(1, "resize is not supported by PassThroughFS"); + return ox::Error(1, "resize is not supported by PassThroughFS"); } Result PassThroughFS::statInode(uint64_t) const noexcept { // unsupported - return OxError(1, "statInode(uint64_t) is not supported by PassThroughFS"); + return ox::Error(1, "statInode(uint64_t) is not supported by PassThroughFS"); } Result PassThroughFS::statPath(StringViewCR path) const noexcept { @@ -101,7 +101,7 @@ Result PassThroughFS::statPath(StringViewCR path) const noexcept { oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path); const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec); oxTracef("ox.fs.PassThroughFS.statInode.size", "{} {}", path, size); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: stat failed")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: stat failed")); return FileStat{0, 0, size, type}; } @@ -112,14 +112,14 @@ uint64_t PassThroughFS::spaceNeeded(uint64_t size) const noexcept { Result PassThroughFS::available() const noexcept { std::error_code ec; const auto s = std::filesystem::space(m_path, ec); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: could not get FS size")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: could not get FS size")); return s.available; } Result PassThroughFS::size() const noexcept { std::error_code ec; const auto s = std::filesystem::space(m_path, ec); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: could not get FS size")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: could not get FS size")); return s.capacity; } @@ -128,7 +128,7 @@ char *PassThroughFS::buff() noexcept { } Error PassThroughFS::walk(Error(*)(uint8_t, uint64_t, uint64_t)) noexcept { - return OxError(1, "walk(Error(*)(uint8_t, uint64_t, uint64_t)) is not supported by PassThroughFS"); + return ox::Error(1, "walk(Error(*)(uint8_t, uint64_t, uint64_t)) is not supported by PassThroughFS"); } bool PassThroughFS::valid() const noexcept { @@ -147,24 +147,24 @@ Error PassThroughFS::readFilePath(StringViewCR path, void *buffer, std::size_t b file.seekg(0, std::ios::beg); if (size > buffSize) { oxTracef("ox.fs.PassThroughFS.read.error", "Read failed: Buffer too small: {}", path); - return OxError(1); + return ox::Error(1); } file.read(static_cast(buffer), static_cast(buffSize)); } catch (const std::fstream::failure &f) { oxTracef("ox.fs.PassThroughFS.read.error", "Read of {} failed: {}", path, f.what()); - return OxError(2); + return ox::Error(2); } - return OxError(0); + return ox::Error(0); } Error PassThroughFS::readFileInode(uint64_t, void*, std::size_t) noexcept { // unsupported - return OxError(1, "readFileInode(uint64_t, void*, std::size_t) is not supported by PassThroughFS"); + return ox::Error(1, "readFileInode(uint64_t, void*, std::size_t) is not supported by PassThroughFS"); } Error PassThroughFS::readFileInodeRange(uint64_t, std::size_t, std::size_t, void*, std::size_t*) noexcept { // unsupported - return OxError(1, "read(uint64_t, std::size_t, std::size_t, void*, std::size_t*) is not supported by PassThroughFS"); + return ox::Error(1, "read(uint64_t, std::size_t, std::size_t, void*, std::size_t*) is not supported by PassThroughFS"); } Error PassThroughFS::writeFilePath(StringViewCR path, const void *buffer, uint64_t size, FileType) noexcept { @@ -174,14 +174,14 @@ Error PassThroughFS::writeFilePath(StringViewCR path, const void *buffer, uint64 f.write(static_cast(buffer), static_cast(size)); } catch (const std::fstream::failure &f) { oxTracef("ox.fs.PassThroughFS.read.error", "Write of {} failed: {}", path, f.what()); - return OxError(1); + return ox::Error(1); } - return OxError(0); + return ox::Error(0); } Error PassThroughFS::writeFileInode(uint64_t, const void*, uint64_t, FileType) noexcept { // unsupported - return OxError(1, "writeFileInode(uint64_t, void*, uint64_t, uint8_t) is not supported by PassThroughFS"); + return ox::Error(1, "writeFileInode(uint64_t, void*, uint64_t, uint8_t) is not supported by PassThroughFS"); } std::string_view PassThroughFS::stripSlash(StringView path) noexcept { diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp index abe6dae9..ffd0d38b 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp @@ -92,11 +92,11 @@ template Error PassThroughFS::ls(StringViewCR dir, F cb) const noexcept { std::error_code ec; const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec); - oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: ls failed")); + oxReturnError(ox::Error(static_cast(ec.value()), "PassThroughFS: ls failed")); for (auto &p : di) { oxReturnError(cb(p.path().filename().c_str(), 0)); } - return OxError(0); + return ox::Error(0); } } diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp index 77d40502..cf6f237e 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp @@ -36,9 +36,9 @@ Error PathIterator::dirPath(char *out, std::size_t outSize) { if (idx >= 0 && size < outSize) { ox::memcpy(out, m_path, size); out[size] = 0; - return OxError(0); + return ox::Error(0); } else { - return OxError(1); + return ox::Error(1); } } @@ -47,11 +47,11 @@ Error PathIterator::get(StringView &fileName) { std::size_t size = 0; if (m_iterator >= m_maxSize) { oxTracef("ox.fs.PathIterator.get", "m_iterator ({}) >= m_maxSize ({})", m_iterator, m_maxSize); - return OxError(1); + return ox::Error(1); } if (!ox::strlen(&m_path[m_iterator])) { oxTrace("ox.fs.PathIterator.get", "!ox::strlen(&m_path[m_iterator])"); - return OxError(1); + return ox::Error(1); } auto start = m_iterator; if (m_path[start] == '/') { @@ -67,7 +67,7 @@ Error PathIterator::get(StringView &fileName) { size = end - start; // cannot fit the output in the output parameter if (size >= MaxFileNameLength || size == 0) { - return OxError(1); + return ox::Error(1); } fileName = ox::substr(m_path, start, start + size); // truncate trailing / @@ -83,9 +83,9 @@ Error PathIterator::get(StringView &fileName) { */ Error PathIterator::next(StringView &fileName) { std::size_t size = 0; - auto retval = OxError(1); + auto retval = ox::Error(1); if (m_iterator < m_maxSize && ox::strlen(&m_path[m_iterator])) { - retval = OxError(0); + retval = ox::Error(0); if (m_path[m_iterator] == '/') { m_iterator++; } @@ -100,7 +100,7 @@ Error PathIterator::next(StringView &fileName) { size = end - start; // cannot fit the output in the output parameter if (size >= MaxFileNameLength) { - return OxError(1); + return ox::Error(1); } fileName = ox::substr(m_path, start, start + size); // truncate trailing / @@ -115,10 +115,10 @@ Error PathIterator::next(StringView &fileName) { Result PathIterator::nextSize() const { std::size_t size = 0; - auto retval = OxError(1); + auto retval = ox::Error(1); auto it = m_iterator; if (it < m_maxSize && ox::strlen(&m_path[it])) { - retval = OxError(0); + retval = ox::Error(0); if (m_path[it] == '/') { it++; } diff --git a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp index 358a7985..6030a18e 100644 --- a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp +++ b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp @@ -284,14 +284,14 @@ Result::ItemPtr> NodeBuffer::mal addr = m_header.firstItem; } else { oxTrace("ox.ptrarith.NodeBuffer.malloc.fail", "NodeBuffer is in invalid state."); - return OxError(1, "NodeBuffer is in invalid state."); + return ox::Error(1, "NodeBuffer is in invalid state."); } } oxTracef("ox.ptrarith.NodeBuffer.malloc", "buffer size: {}; addr: {}; fullSize: {}", m_header.size.get(), addr, fullSize); auto out = ItemPtr(this, m_header.size, addr, fullSize); if (!out.valid()) { oxTrace("ox.ptrarith.NodeBuffer.malloc.fail", "Unknown"); - return OxError(1, "NodeBuffer::malloc: unknown failure"); + return ox::Error(1, "NodeBuffer::malloc: unknown failure"); } ox::memset(out, 0, fullSize); new (out) Item; @@ -304,7 +304,7 @@ Result::ItemPtr> NodeBuffer::mal first->prev = out.offset(); } else { oxTrace("ox.ptrarith.NodeBuffer.malloc.fail", "NodeBuffer malloc failed due to invalid first element pointer."); - return OxError(1, "NodeBuffer malloc failed due to invalid first element pointer."); + return ox::Error(1, "NodeBuffer malloc failed due to invalid first element pointer."); } if (oldLast.valid()) { @@ -314,7 +314,7 @@ Result::ItemPtr> NodeBuffer::mal if (out.offset() != first.offset()) { // if this is not the first allocation, there should be an oldLast oxTrace("ox.ptrarith.NodeBuffer.malloc.fail", "NodeBuffer malloc failed due to invalid last element pointer."); - return OxError(1, "NodeBuffer malloc failed due to invalid last element pointer."); + return ox::Error(1, "NodeBuffer malloc failed due to invalid last element pointer."); } out->prev = out.offset(); } @@ -323,7 +323,7 @@ Result::ItemPtr> NodeBuffer::mal return out; } oxTracef("ox.ptrarith.NodeBuffer.malloc.fail", "Insufficient space: {} needed, {} available", fullSize, available()); - return OxError(1); + return ox::Error(1); } template @@ -346,15 +346,15 @@ Error NodeBuffer::free(ItemPtr item) noexcept { } else { if (!prev.valid()) { oxTracef("ox.ptrarith.NodeBuffer.free.fail", "NodeBuffer free failed due to invalid prev element pointer: {}", prev.offset()); - return OxError(1); + return ox::Error(1); } if (!next.valid()) { oxTracef("ox.ptrarith.NodeBuffer.free.fail", "NodeBuffer free failed due to invalid next element pointer: {}", next.offset()); - return OxError(1); + return ox::Error(1); } } m_header.bytesUsed -= item.size(); - return OxError(0); + return ox::Error(0); } template @@ -365,12 +365,12 @@ Error NodeBuffer::setSize(std::size_t size) noexcept { oxTracef("ox.ptrarith.NodeBuffer.setSize", "end: {}", end); if (end > size) { // resizing to less than buffer size - return OxError(1); + return ox::Error(1); } else { m_header.size = static_cast(size); auto data = reinterpret_cast(this) + end; ox::memset(data, 0, size - end); - return OxError(0); + return ox::Error(0); } } @@ -401,10 +401,10 @@ Error NodeBuffer::compact(F cb) noexcept { auto dest = ptr(sizeof(*this)); while (dest.offset() <= src.offset()) { if (!src.valid()) { - return OxError(1); + return ox::Error(1); } if (!dest.valid()) { - return OxError(2); + return ox::Error(2); } // move node ox::memcpy(dest, src, src->fullSize()); @@ -422,7 +422,7 @@ Error NodeBuffer::compact(F cb) noexcept { src = ptr(dest->next); dest = uninitializedPtr(dest.offset() + dest->fullSize()); } - return OxError(0); + return ox::Error(0); } template diff --git a/deps/ox/src/ox/fs/ptrarith/ptr.hpp b/deps/ox/src/ox/fs/ptrarith/ptr.hpp index 5e0efac2..c12bb500 100644 --- a/deps/ox/src/ox/fs/ptrarith/ptr.hpp +++ b/deps/ox/src/ox/fs/ptrarith/ptr.hpp @@ -254,7 +254,7 @@ constexpr Result> Ptr::validate( if (valid()) { return *this; } - return OxError(1); + return ox::Error(1); } } diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index f5b6db98..ec66ee32 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -52,7 +52,7 @@ const std::map> tests = oxAssert(buffer->free(a1), "Free failed."); oxAssert(buffer->free(a2), "Free failed."); oxAssert(buffer->setSize(buffer->size() - buffer->available()), "Resize failed."); - return OxError(0); + return ox::Error(0); } }, { @@ -64,7 +64,7 @@ const std::map> tests = oxAssert(it.next(buff) == 0 && buff == "usr", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "share", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "charset.gbag", "PathIterator shows wrong next"); - return OxError(0); + return ox::Error(0); } }, { @@ -77,7 +77,7 @@ const std::map> tests = oxExpect(buff, "usr"); oxAssert(it.next(buff), "PathIterator::next returned error"); oxExpect(buff, "share"); - return OxError(0); + return ox::Error(0); } }, { @@ -87,7 +87,7 @@ const std::map> tests = ox::PathIterator it(path.c_str(), path.len()); ox::StringView buff; oxAssert(it.next(buff) == 0 && buff == "\0", "PathIterator shows wrong next"); - return OxError(0); + return ox::Error(0); } }, { @@ -99,7 +99,7 @@ const std::map> tests = oxAssert(it.next(buff) == 0 && buff == "usr", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "share", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "charset.gbag", "PathIterator shows wrong next"); - return OxError(0); + return ox::Error(0); } }, { @@ -110,7 +110,7 @@ const std::map> tests = ox::StringView buff; oxAssert(it.next(buff) == 0 && buff == "usr", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "share", "PathIterator shows wrong next"); - return OxError(0); + return ox::Error(0); } }, { @@ -120,7 +120,7 @@ const std::map> tests = ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); oxAssert(it.dirPath(buff, path.len()) == 0 && ox::strcmp(buff, "/usr/share/") == 0, "PathIterator shows incorrect dir path"); - return OxError(0); + return ox::Error(0); } }, { @@ -130,7 +130,7 @@ const std::map> tests = ox::PathIterator it(path, ox::strlen(path)); oxAssert(it.hasNext(), "PathIterator shows incorrect hasNext"); oxAssert(!it.next().hasNext(), "PathIterator shows incorrect hasNext"); - return OxError(0); + return ox::Error(0); } }, { @@ -142,7 +142,7 @@ const std::map> tests = auto subPtr = p.subPtr(50); oxAssert(subPtr.valid(), "Ptr::subPtr: Ptr subPtr is invalid."); - return OxError(0); + return ox::Error(0); } }, { @@ -155,7 +155,7 @@ const std::map> tests = auto first = list->firstItem(); oxAssert(first.valid(), "NodeBuffer::insert: Could not access first item"); oxAssert(first->size() == 50, "NodeBuffer::insert: First item size invalid"); - return OxError(0); + return ox::Error(0); } }, { @@ -176,7 +176,7 @@ const std::map> tests = size_t str1ReadSize = 0; oxAssert(fileStore.read(4, reinterpret_cast(str1Read), str1Len, &str1ReadSize), "FileStore::read 1 failed."); - return OxError(0); + return ox::Error(0); } }, { @@ -203,7 +203,7 @@ const std::map> tests = oxTrace("ox.fs.test.Directory") << "write 3"; oxAssert(dir.write("/file2", 2), "Directory write of file2 failed"); - return OxError(0); + return ox::Error(0); } }, { @@ -220,7 +220,7 @@ const std::map> tests = oxAssert(fs.stat("/l1d1/l2d1/l3d1").error, "mkdir failed"); oxAssert(fs.mkdir("/l1d1/l2d2", true), "mkdir failed"); oxAssert(fs.stat("/l1d1/l2d2").error, "mkdir failed"); - return OxError(0); + return ox::Error(0); } }, }, diff --git a/deps/ox/src/ox/fs/tool.cpp b/deps/ox/src/ox/fs/tool.cpp index c65819fb..479aa070 100644 --- a/deps/ox/src/ox/fs/tool.cpp +++ b/deps/ox/src/ox/fs/tool.cpp @@ -20,7 +20,7 @@ static ox::Result loadFsBuff(const char *path) noexcept { std::ifstream file(path, std::ios::binary | std::ios::ate); if (!file.good()) { oxErrorf("Could not find OxFS file: {}", path); - return OxError(1, "Could not find OxFS file"); + return ox::Error(1, "Could not find OxFS file"); } try { const auto size = static_cast(file.tellg()); @@ -30,7 +30,7 @@ static ox::Result loadFsBuff(const char *path) noexcept { return Buff{buff, size}; } catch (const std::ios_base::failure &e) { oxErrorf("Could not read OxFS file: {}", e.what()); - return OxError(2, "Could not read OxFS file"); + return ox::Error(2, "Could not read OxFS file"); } } @@ -42,29 +42,29 @@ static ox::Result> loadFs(const char *path) noexce static ox::Error runLs(ox::FileSystem *fs, ox::Span args) noexcept { if (args.size() < 2) { oxErr("Must provide a directory to ls\n"); - return OxError(1); + return ox::Error(1); } oxRequire(files, fs->ls(args[1])); for (const auto &file : files) { oxOutf("{}\n", file); } - return OxError(0); + return ox::Error(0); } static ox::Error runRead(ox::FileSystem *fs, ox::Span args) noexcept { if (args.size() < 2) { oxErr("Must provide a path to a file to read\n"); - return OxError(1); + return ox::Error(1); } oxRequire(buff, fs->read(ox::StringView(args[1]))); std::ignore = fwrite(buff.data(), sizeof(decltype(buff)::value_type), buff.size(), stdout); - return OxError(0); + return ox::Error(0); } static ox::Error run(int argc, const char **argv) noexcept { if (argc < 3) { oxErr("OxFS file and subcommand arguments are required\n"); - return OxError(1); + return ox::Error(1); } auto const args = ox::Span{argv, static_cast(argc)}; auto const fsPath = args[1]; @@ -75,7 +75,7 @@ static ox::Error run(int argc, const char **argv) noexcept { } else if (subCmd == "read") { return runRead(fs.get(), args + 2); } - return OxError(1); + return ox::Error(1); } int main(int argc, const char **argv) { diff --git a/deps/ox/src/ox/logconn/circularbuff.hpp b/deps/ox/src/ox/logconn/circularbuff.hpp index 1100c10a..802ab3a7 100644 --- a/deps/ox/src/ox/logconn/circularbuff.hpp +++ b/deps/ox/src/ox/logconn/circularbuff.hpp @@ -34,7 +34,7 @@ class CirculerBuffer { constexpr ox::Error put(char v) noexcept { return write(&v, 1); if (1 > avail()) { - return OxError(1, "Insufficient space in buffer"); + return ox::Error(1, "Insufficient space in buffer"); } m_buff[m_writePt] = v; ++m_writePt; @@ -43,7 +43,7 @@ class CirculerBuffer { constexpr ox::Error write(const char *buff, std::size_t sz) noexcept { if (sz > avail()) { - return OxError(1, "Insufficient space in buffer"); + return ox::Error(1, "Insufficient space in buffer"); } OX_ALLOW_UNSAFE_BUFFERS_BEGIN // write seg 1 @@ -63,7 +63,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END constexpr ox::Error seekp(std::size_t bytesFwd) noexcept { if (bytesFwd > avail()) { - return OxError(1, "Insufficient space in buffer to seek that far ahead"); + return ox::Error(1, "Insufficient space in buffer to seek that far ahead"); } m_writePt += bytesFwd; if (m_writePt > m_buff.size()) { @@ -73,7 +73,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END } constexpr ox::Error seekp(int, ios_base::seekdir) noexcept { - return OxError(1, "Unimplemented"); + return ox::Error(1, "Unimplemented"); } [[nodiscard]] diff --git a/deps/ox/src/ox/logconn/logconn.cpp b/deps/ox/src/ox/logconn/logconn.cpp index dfe91a47..2b4e6ba9 100644 --- a/deps/ox/src/ox/logconn/logconn.cpp +++ b/deps/ox/src/ox/logconn/logconn.cpp @@ -64,7 +64,7 @@ ox::Error LoggerConn::initConn(ox::StringViewCR appName) noexcept { addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr.sin_port = htons(5590); m_socket = static_cast(socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)); - oxReturnError(OxError(static_cast(connect(static_cast(m_socket), reinterpret_cast(&addr), sizeof(addr))))); + oxReturnError(ox::Error(static_cast(connect(static_cast(m_socket), reinterpret_cast(&addr), sizeof(addr))))); return sendInit({.appName = ox::BasicString<128>(appName)}); } @@ -75,7 +75,7 @@ ox::Error LoggerConn::send(const char *buff, std::size_t len) const noexcept { const auto sent = ::send(static_cast(m_socket), buff, static_cast(len), 0); if (sent < 0) { std::ignore = std::fprintf(stderr, "Could not send msg\n"); - return OxError(1, "Could not send msg"); + return ox::Error(1, "Could not send msg"); } totalSent += static_cast(sent); } diff --git a/deps/ox/src/ox/mc/presenceindicator.hpp b/deps/ox/src/ox/mc/presenceindicator.hpp index f9f02c9e..44a17a84 100644 --- a/deps/ox/src/ox/mc/presenceindicator.hpp +++ b/deps/ox/src/ox/mc/presenceindicator.hpp @@ -110,7 +110,7 @@ constexpr Result FieldBitmapWriterBase::get(std::size_t i) const noexce if (i / 8 < m_mapLen) { return (m_map[i / 8] >> (i % 8)) & 1; } else { - return OxError(McPresenceMapOverflow); + return ox::Error(McPresenceMapOverflow); } } @@ -156,7 +156,7 @@ OX_ALLOW_UNSAFE_BUFFERS_BEGIN OX_ALLOW_UNSAFE_BUFFERS_END return {}; } else { - return OxError(McPresenceMapOverflow); + return ox::Error(McPresenceMapOverflow); } } diff --git a/deps/ox/src/ox/mc/read.hpp b/deps/ox/src/ox/mc/read.hpp index e0534d06..2e849fb0 100644 --- a/deps/ox/src/ox/mc/read.hpp +++ b/deps/ox/src/ox/mc/read.hpp @@ -197,7 +197,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, bool *val) n oxReturnError(result); } ++m_field; - return OxError(0); + return ox::Error(0); } // array handler @@ -220,7 +220,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END } } else { oxTracef("ox.mc.read.field(T)", "{}, length: {}", name, valLen); - return OxError(McOutputBuffEnded); + return ox::Error(McOutputBuffEnded); } } } @@ -256,7 +256,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, HashMap @@ -280,7 +280,7 @@ constexpr Error MetalClawReaderTemplate::field(const char *name, T *val) if (m_fieldPresence.get(static_cast(m_field))) { oxRequire(len, arrayLength(name, false)); if (len > val->size()) { - return OxError(1, "Input array is too long"); + return ox::Error(1, "Input array is too long"); } } return field(name, val->data(), val->size()); @@ -330,7 +330,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, BasicString< } } ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -361,7 +361,7 @@ constexpr Error MetalClawReaderTemplate::fieldCString(const char*, char std::size_t bytesRead = 0; oxRequire(size, mc::decodeInteger(m_reader, &bytesRead)); if (size > buffLen) { - return OxError(McOutputBuffEnded); + return ox::Error(McOutputBuffEnded); } // re-allocate in case too small auto data = val; @@ -370,7 +370,7 @@ constexpr Error MetalClawReaderTemplate::fieldCString(const char*, char data[size] = 0; } ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -388,7 +388,7 @@ constexpr Error MetalClawReaderTemplate::fieldCString(const char*, char data[size] = 0; } ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -416,7 +416,7 @@ constexpr Error MetalClawReaderTemplate::fieldCString(const char*, char } } ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -433,7 +433,7 @@ constexpr Result MetalClawReaderTemplate::arrayLength(const return out; } } - return OxError(1); + return ox::Error(1); } template @@ -464,7 +464,7 @@ constexpr Error MetalClawReaderTemplate::readInteger(I *val) noexcept { } } ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -487,7 +487,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, CB cb) noexc } } ++m_field; - return OxError(0); + return ox::Error(0); } template diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index 08c4a0fe..4e4b4f19 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -66,7 +66,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexcep oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->fieldCString("CString", &obj->CString)); - return OxError(0); + return ox::Error(0); } oxModelBegin(TestStructNest) @@ -102,7 +102,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexce oxReturnError(io->field("Map", &obj->Map)); oxReturnError(io->field("Struct", &obj->Struct)); oxReturnError(io->field("EmptyStruct", &obj->EmptyStruct)); - return OxError(0); + return ox::Error(0); } std::map tests = { @@ -116,7 +116,7 @@ std::map tests = { TestStruct ts; oxReturnError(ox::writeMC(buff.data(), buff.size(), ts)); oxReturnError(ox::writeMC(ts)); - return OxError(0); + return ox::Error(0); } }, @@ -176,7 +176,7 @@ std::map tests = { oxAssert(testIn.Struct.Int == testOut.Struct.Int, "Struct.Int value mismatch"); oxAssert(testIn.Struct.IString == testOut.Struct.IString, "Struct.IString value mismatch"); oxAssert(testIn.Struct.Bool == testOut.Struct.Bool, "Struct.Bool value mismatch"); - return OxError(0); + return ox::Error(0); } }, @@ -189,28 +189,28 @@ std::map tests = { static constexpr auto check = [](McInt val, const ox::Vector &expected) { if (val.length != expected.size()) { std::cout << "val.length: " << val.length << ", expected: " << expected.size() << '\n'; - return OxError(1); + return ox::Error(1); } for (std::size_t i = 0; i < expected.size(); i++) { if (expected[i] != val.data[i]) { std::cout << "decoded: " << static_cast(val.data[i]) << ", expected: " << static_cast(expected[i]) << '\n'; std::cout << "decoded: " << i << ": " << static_cast(val.data[i]) << '\n'; - return OxError(1); + return ox::Error(1); } } - return OxError(0); + return ox::Error(0); }; constexpr auto check64 = [](McInt val, auto expected) { if (val.length != 9) { std::cout << "val.length: " << val.length << '\n'; - return OxError(1); + return ox::Error(1); } ox::LittleEndian decoded = *reinterpret_cast(&val.data[1]); if (expected != decoded) { std::cout << "decoded: " << decoded << ", expected: " << expected << '\n'; - return OxError(1); + return ox::Error(1); } - return OxError(0); + return ox::Error(0); }; // signed positive oxAssert(check(encodeInteger(int64_t(1)), {0b000'0001'0}), "Encode 1 fail"); @@ -247,7 +247,7 @@ std::map tests = { // code deduplication oxAssert(check64(encodeInteger(MaxValue), MaxValue), "Encode MaxValue fail"); oxAssert(check64(encodeInteger(MaxValue), MaxValue), "Encode MaxValue fail"); - return OxError(0); + return ox::Error(0); } }, @@ -263,9 +263,9 @@ std::map tests = { oxReturnError(result.error); if (result.value != val) { std::cout << "Bad value: " << result.value << ", expected: " << val << '\n'; - return OxError(1); + return ox::Error(1); } - return OxError(0); + return ox::Error(0); }; oxAssert(check(uint32_t(14)), "Decode of 14 failed."); oxAssert(check(int8_t(-1)), "Decode of -1 failed."); @@ -291,7 +291,7 @@ std::map tests = { oxAssert(check(0xffffffff), "Decode of 0xffffffff failed."); oxAssert(check(0xffffffffffff), "Decode of 0xffffffffffff failed."); oxAssert(check(0xffffffffffffffff), "Decode of U64 max failed."); - return OxError(0); + return ox::Error(0); } }, @@ -344,7 +344,7 @@ std::map tests = { oxAssert(testOutStructCopy.at("IString").unwrap()->get() == testIn.Struct.IString.c_str(), "testOut.Struct.IString (copy) failed"); oxAssert(testOutListCopy[0].get() == testIn.List[0], "testOut.Struct.List[0] (copy) failed"); oxAssert(testOutListCopy[1].get() == testIn.List[1], "testOut.Struct.List[1] (copy) failed"); - return OxError(0); + return ox::Error(0); } }, @@ -454,10 +454,10 @@ std::map tests = { case ox::PrimitiveType::Union: break; } - return OxError(0); + return ox::Error(0); } )); - return OxError(0); + return ox::Error(0); } }, } diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index b63480ef..ffbfd022 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -122,7 +122,7 @@ class MetalClawWriter { } oxReturnError(m_fieldPresence.set(static_cast(m_field), fieldSet)); ++m_field; - return OxError(0); + return ox::Error(0); } }; @@ -184,7 +184,7 @@ constexpr Error MetalClawWriter::field(const char*, const bool *val) noe oxReturnError(m_fieldPresence.set(static_cast(m_field), *val)); } ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -201,7 +201,7 @@ constexpr Error MetalClawWriter::field(const char*, const BasicString(m_field), fieldSet)); ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -224,7 +224,7 @@ constexpr Error MetalClawWriter::fieldCString(const char*, const char *c } oxReturnError(m_fieldPresence.set(static_cast(m_field), fieldSet)); ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -250,7 +250,7 @@ constexpr Error MetalClawWriter::fieldCString(const char*, const char *v } oxReturnError(m_fieldPresence.set(static_cast(m_field), fieldSet)); ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -314,7 +314,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END } oxReturnError(m_fieldPresence.set(static_cast(m_field), fieldSet)); ++m_field; - return OxError(0); + return ox::Error(0); } template @@ -351,7 +351,7 @@ constexpr Error MetalClawWriter::field(const char*, const HashMap(m_field), fieldSet)); ++m_field; - return OxError(0); + return ox::Error(0); } template diff --git a/deps/ox/src/ox/model/def.hpp b/deps/ox/src/ox/model/def.hpp index f4f042fd..ce8647d8 100644 --- a/deps/ox/src/ox/model/def.hpp +++ b/deps/ox/src/ox/model/def.hpp @@ -13,7 +13,7 @@ // oxModelFwdDecl is necessary because Apple-Clang is broken... #define oxModelFwdDecl(modelName) constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *o) noexcept #define oxModelBegin(modelName) constexpr ox::Error model(auto *io, [[maybe_unused]] ox::CommonPtrWith auto *o) noexcept { oxReturnError(io->template setTypeInfo()); -#define oxModelEnd() return OxError(0); } +#define oxModelEnd() return ox::Error(0); } #define oxModelField(fieldName) oxReturnError(io->field(#fieldName, &o->fieldName)); #define oxModelFieldRename(objFieldName, serFieldName) oxReturnError(io->field(#serFieldName, &o->objFieldName)); #define oxModelFriend(modelName) friend constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *o) noexcept diff --git a/deps/ox/src/ox/model/desctypes.hpp b/deps/ox/src/ox/model/desctypes.hpp index 045cc86b..d04008d7 100644 --- a/deps/ox/src/ox/model/desctypes.hpp +++ b/deps/ox/src/ox/model/desctypes.hpp @@ -244,7 +244,7 @@ constexpr Error model(TypeDescReader *io, CommonPtrWith auto // defaultValue is unused now, but placeholder for backwards compatibility int defaultValue = 0; oxReturnError(io->field("defaultValue", &defaultValue)); - return OxError(0); + return ox::Error(0); } #endif diff --git a/deps/ox/src/ox/model/descwrite.hpp b/deps/ox/src/ox/model/descwrite.hpp index 8e50f501..29245a34 100644 --- a/deps/ox/src/ox/model/descwrite.hpp +++ b/deps/ox/src/ox/model/descwrite.hpp @@ -205,9 +205,9 @@ constexpr Error TypeDescWriter::field(StringViewCR name, T const*, std::size_t, const auto t = type(p); oxAssert(t != nullptr, "field(const char *name, T *val, std::size_t): Type not found or generated"); m_type->fieldList.emplace_back(t, String(name), detail::indirectionLevels_v + 1, subscriptStack, buildTypeId(*t)); - return OxError(0); + return ox::Error(0); } - return OxError(1); + return ox::Error(1); } // array handler @@ -220,9 +220,9 @@ constexpr Error TypeDescWriter::field(StringViewCR name, T const*, std::size_t) auto const lvls = detail::indirectionLevels_v + 1; SubscriptStack subscriptStack{lvls}; m_type->fieldList.emplace_back(t, String(name), lvls, subscriptStack, buildTypeId(*t)); - return OxError(0); + return ox::Error(0); } - return OxError(1); + return ox::Error(1); } template @@ -231,9 +231,9 @@ constexpr Error TypeDescWriter::field(StringViewCR name, UnionView val const auto t = type(val); oxAssert(t != nullptr, "field(const char *name, T val): Type not found or generated"); m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, ox::String(t->typeName)); - return OxError(0); + return ox::Error(0); } - return OxError(1); + return ox::Error(1); } template @@ -254,7 +254,7 @@ constexpr Error TypeDescWriter::field(StringViewCR name, const T *val) noexcept return {}; } } - return OxError(1); + return ox::Error(1); } template diff --git a/deps/ox/src/ox/model/fieldcounter.hpp b/deps/ox/src/ox/model/fieldcounter.hpp index 55bd25f0..b39397d2 100644 --- a/deps/ox/src/ox/model/fieldcounter.hpp +++ b/deps/ox/src/ox/model/fieldcounter.hpp @@ -31,25 +31,25 @@ class FieldCounter { template constexpr ox::Error field(StringViewCR, U) noexcept { ++fields; - return OxError(0); + return ox::Error(0); } template constexpr ox::Error field(StringViewCR, U, std::size_t) noexcept { ++fields; - return OxError(0); + return ox::Error(0); } template constexpr Error field(StringViewCR, Handler) { ++fields; - return OxError(0); + return ox::Error(0); } template constexpr Error fieldCString(Args&&...) noexcept { ++fields; - return OxError(0); + return ox::Error(0); } static constexpr auto opType() noexcept { diff --git a/deps/ox/src/ox/model/modelhandleradaptor.hpp b/deps/ox/src/ox/model/modelhandleradaptor.hpp index 854c5415..2853b758 100644 --- a/deps/ox/src/ox/model/modelhandleradaptor.hpp +++ b/deps/ox/src/ox/model/modelhandleradaptor.hpp @@ -135,8 +135,8 @@ class ModelHandlerInterface { return m_handler->field(name, &v->template get()); } oxErrf("invalid type: {}: {}\n", name, static_cast(v->type())); - oxPanic(OxError(1), "invalid type"); - return OxError(1, "invalid type"); + oxPanic(ox::Error(1), "invalid type"); + return ox::Error(1, "invalid type"); } // array handler, with callback to allow handling individual elements diff --git a/deps/ox/src/ox/model/modelops.hpp b/deps/ox/src/ox/model/modelops.hpp index e8c4ad06..f40f678e 100644 --- a/deps/ox/src/ox/model/modelops.hpp +++ b/deps/ox/src/ox/model/modelops.hpp @@ -56,19 +56,19 @@ class MemberList { template constexpr Error field(const char*, T *v) noexcept { vars[m_i++] = static_cast(v); - return OxError(0); + return ox::Error(0); } template constexpr Error field(const char*, T *v, int) noexcept { vars[m_i++] = static_cast(v); - return OxError(0); + return ox::Error(0); } template constexpr Error field(const char*, UnionView u) noexcept { vars[m_i++] = static_cast(u.get()); - return OxError(0); + return ox::Error(0); } template @@ -107,7 +107,7 @@ class Copier { auto &dst = *cbit_cast(m_dst->vars[m_i]); dst = src; ++m_i; - return OxError(0); + return ox::Error(0); } } @@ -119,7 +119,7 @@ class Copier { dst = src; } ++m_i; - return OxError(0); + return ox::Error(0); } template @@ -128,7 +128,7 @@ class Copier { auto &src = *u.get(); dst = src; ++m_i; - return OxError(0); + return ox::Error(0); } template @@ -168,7 +168,7 @@ class Mover { dst = std::move(src); src = FT{}; ++m_i; - return OxError(0); + return ox::Error(0); } } @@ -181,7 +181,7 @@ class Mover { src = FT{}; } ++m_i; - return OxError(0); + return ox::Error(0); } template @@ -190,7 +190,7 @@ class Mover { auto &src = *u.get(); dst = std::move(src); ++m_i; - return OxError(0); + return ox::Error(0); } template @@ -228,10 +228,10 @@ class Equals { const auto &dst = std::bit_cast(*m_other->vars[m_i]); ++m_i; if (dst == src) { - return OxError(0); + return ox::Error(0); } else { this->value = false; - return OxError(1); + return ox::Error(1); } } @@ -242,11 +242,11 @@ class Equals { const auto &dst = cbit_cast(m_other->vars[m_i])[i]; if (!(dst == src)) { this->value = false; - return OxError(1); + return ox::Error(1); } } ++m_i; - return OxError(0); + return ox::Error(0); } template @@ -255,10 +255,10 @@ class Equals { const auto &src = *u.get(); ++m_i; if (dst == src) { - return OxError(0); + return ox::Error(0); } else { this->value = false; - return OxError(1); + return ox::Error(1); } } diff --git a/deps/ox/src/ox/model/modelvalue.cpp b/deps/ox/src/ox/model/modelvalue.cpp index 9adf591e..eef8a8a2 100644 --- a/deps/ox/src/ox/model/modelvalue.cpp +++ b/deps/ox/src/ox/model/modelvalue.cpp @@ -14,10 +14,10 @@ static_assert([]() -> ox::Error { ox::ModelValue v; oxReturnError(v.setType()); if (v.type() != ModelValue::Type::SignedInteger32) { - return OxError(1, "type is wrong"); + return ox::Error(1, "type is wrong"); } //oxReturnError(v.set(5)); return {}; -}() == OxError(0)); +}() == ox::Error(0)); } diff --git a/deps/ox/src/ox/model/modelvalue.hpp b/deps/ox/src/ox/model/modelvalue.hpp index 84dc58b1..0a37fc2d 100644 --- a/deps/ox/src/ox/model/modelvalue.hpp +++ b/deps/ox/src/ox/model/modelvalue.hpp @@ -168,7 +168,7 @@ class ModelValue { constexpr const auto &get() const noexcept { constexpr auto type = getType(); if (m_type != type) [[unlikely]] { - oxPanic(OxError(1), "invalid cast"); + oxPanic(ox::Error(1), "invalid cast"); } return getValue(*this); } @@ -178,7 +178,7 @@ class ModelValue { constexpr auto &get() noexcept { constexpr auto type = getType(); if (m_type != type) [[unlikely]] { - oxPanic(OxError(1), "invalid cast"); + oxPanic(ox::Error(1), "invalid cast"); } return getValue(*this); } @@ -634,7 +634,7 @@ class ModelObject { if (m_fields.contains(k)) { return *m_fields.at(k).value; } - return OxError(1); + return ox::Error(1); } template @@ -670,7 +670,7 @@ class ModelObject { constexpr Error setType(const DescriptorType *type) noexcept { if (type->primitiveType != PrimitiveType::Struct && type->primitiveType != PrimitiveType::Union) { - return OxError(1, "Cannot load a non-struct type to ModelObject"); + return ox::Error(1, "Cannot load a non-struct type to ModelObject"); } m_type = type; for (const auto &f : type->fieldList) { @@ -790,7 +790,7 @@ class ModelUnion { constexpr Error setType(const DescriptorType *type) noexcept { if (type->primitiveType != PrimitiveType::Struct && type->primitiveType != PrimitiveType::Union) { - return OxError(1, "Cannot load a non-struct type to ModelUnion"); + return ox::Error(1, "Cannot load a non-struct type to ModelUnion"); } m_fields.clear(); m_fieldsOrder.clear(); @@ -972,7 +972,7 @@ constexpr Error model(auto *h, CommonPtrWith auto *obj) noexcept { for (auto &f : obj->m_fieldsOrder) { oxReturnError(h->field(f->name.c_str(), &f->value)); } - return OxError(0); + return ox::Error(0); } constexpr Error model(auto *h, CommonPtrWith auto *obj) noexcept { @@ -981,7 +981,7 @@ constexpr Error model(auto *h, CommonPtrWith auto *obj) noexcept { for (auto &f : obj->m_fieldsOrder) { oxReturnError(h->field(f->name.c_str(), &f->value)); } - return OxError(0); + return ox::Error(0); } constexpr ModelValue::ModelValue(const ModelValue &other) noexcept { @@ -1129,7 +1129,7 @@ constexpr Error ModelValue::setType( oxReturnError(m_data.uni->setType(type)); } oxAssert(m_type != Type::Undefined, "No type set"); - return OxError(0); + return ox::Error(0); } template @@ -1176,7 +1176,7 @@ template constexpr Error ModelValue::set(const T &v) noexcept { constexpr auto type = getType(); if (m_type != type) [[unlikely]] { - return OxError(1, "type mismatch"); + return ox::Error(1, "type mismatch"); } auto &value = getValue(*this); if constexpr(type == Type::Vector || type == Type::Object || @@ -1184,14 +1184,14 @@ constexpr Error ModelValue::set(const T &v) noexcept { safeDelete(&value); } value = v; - return OxError(0); + return ox::Error(0); } template constexpr Error ModelValue::set(T &&v) noexcept { constexpr auto type = getType(); if (m_type != type) [[unlikely]] { - return OxError(1, "type mismatch"); + return ox::Error(1, "type mismatch"); } auto &value = getValue(*this); if constexpr(type == Type::Vector || type == Type::Object || @@ -1199,7 +1199,7 @@ constexpr Error ModelValue::set(T &&v) noexcept { safeDelete(&value); } value = std::move(v); - return OxError(0); + return ox::Error(0); } constexpr ModelValue &ModelValue::operator=(ModelValue &other) noexcept { diff --git a/deps/ox/src/ox/model/test/tests.cpp b/deps/ox/src/ox/model/test/tests.cpp index 610cae98..79d59c3a 100644 --- a/deps/ox/src/ox/model/test/tests.cpp +++ b/deps/ox/src/ox/model/test/tests.cpp @@ -41,7 +41,7 @@ std::map tests = { oxReturnError(v.setType()); //v.m_type = ox::ModelValue::getType(); if (v.type() != ox::ModelValue::Type::SignedInteger32) { - return OxError(1, "type is wrong"); + return ox::Error(1, "type is wrong"); } oxReturnError(v.set(5)); return ox::Error{}; diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index 0a4b49a2..870ae6e5 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -38,17 +38,17 @@ struct TypeNameCatcher { template constexpr Error field(const char*, T*, std::size_t) noexcept { - return OxError(0); + return ox::Error(0); } template constexpr Error field(const char*, T) noexcept { - return OxError(0); + return ox::Error(0); } template constexpr Error fieldCString(Args&&...) noexcept { - return OxError(0); + return ox::Error(0); } static constexpr auto opType() noexcept { @@ -77,17 +77,17 @@ struct TypeInfoCatcher { template constexpr Error field(const char*, T*, std::size_t) noexcept { - return OxError(0); + return ox::Error(0); } template constexpr Error field(const char*, T) noexcept { - return OxError(0); + return ox::Error(0); } template constexpr Error fieldCString(const char*, T) noexcept { - return OxError(0); + return ox::Error(0); } static constexpr auto opType() noexcept { diff --git a/deps/ox/src/ox/model/typestore.hpp b/deps/ox/src/ox/model/typestore.hpp index 4f39ea77..6aca7516 100644 --- a/deps/ox/src/ox/model/typestore.hpp +++ b/deps/ox/src/ox/model/typestore.hpp @@ -64,7 +64,7 @@ class TypeStore { out = std::move(dt); return out.get(); } else { - return OxError(1, "Type not available"); + return ox::Error(1, "Type not available"); } } return val->get(); @@ -102,7 +102,7 @@ class TypeStore { protected: virtual Result> loadDescriptor(ox::StringView) noexcept { - return OxError(1); + return ox::Error(1); } Result> loadDescriptor(ox::StringViewCR name, int version, diff --git a/deps/ox/src/ox/model/walk.hpp b/deps/ox/src/ox/model/walk.hpp index 784bddc7..707efe92 100644 --- a/deps/ox/src/ox/model/walk.hpp +++ b/deps/ox/src/ox/model/walk.hpp @@ -127,7 +127,7 @@ static constexpr Error parseField(const DescriptorField &field, Reader *rdr, Dat } } walker->popNamePath(); - return OxError(0); + return ox::Error(0); } template @@ -141,7 +141,7 @@ constexpr Error model(Reader *rdr, DataWalker *walker) noexcept { for (const auto &field : fields) { oxReturnError(parseField(field, rdr, walker)); } - return OxError(0); + return ox::Error(0); } template diff --git a/deps/ox/src/ox/oc/read.cpp b/deps/ox/src/ox/oc/read.cpp index fb5ef3f6..14fb4366 100644 --- a/deps/ox/src/ox/oc/read.cpp +++ b/deps/ox/src/ox/oc/read.cpp @@ -37,7 +37,7 @@ OrganicClawReader::OrganicClawReader(Json::Value json, int unionIdx) noexcept: } Error OrganicClawReader::field(const char *key, bool *val) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); if (targetValid()) { const auto &jv = value(key); if (jv.empty()) { @@ -45,7 +45,7 @@ Error OrganicClawReader::field(const char *key, bool *val) noexcept { } else if (jv.isBool()) { *val = jv.asBool(); } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -53,7 +53,7 @@ Error OrganicClawReader::field(const char *key, bool *val) noexcept { } Error OrganicClawReader::fieldCString(const char *key, char *val, std::size_t buffLen) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); const char *begin = nullptr, *end = nullptr; const auto &jv = value(key); if (targetValid()) { @@ -67,13 +67,13 @@ Error OrganicClawReader::fieldCString(const char *key, char *val, std::size_t bu const auto strSize = static_cast(end - begin); auto data = val; if (strSize >= buffLen) { - err = OxError(2, "String size exceeds capacity of destination"); + err = ox::Error(2, "String size exceeds capacity of destination"); } else { ox::memcpy(data, begin, static_cast(strSize)); data[strSize] = 0; } } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -81,7 +81,7 @@ Error OrganicClawReader::fieldCString(const char *key, char *val, std::size_t bu } Error OrganicClawReader::fieldCString(const char *key, char **val) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); const char *begin = nullptr, *end = nullptr; const auto &jv = value(key); auto &data = *val; @@ -98,7 +98,7 @@ Error OrganicClawReader::fieldCString(const char *key, char **val) noexcept { ox::memcpy(data, begin, static_cast(strSize)); data[strSize] = 0; } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -106,7 +106,7 @@ Error OrganicClawReader::fieldCString(const char *key, char **val) noexcept { } Error OrganicClawReader::fieldCString(const char *key, char **val, std::size_t buffLen) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); const char *begin = nullptr, *end = nullptr; const auto &jv = value(key); if (targetValid()) { @@ -126,7 +126,7 @@ Error OrganicClawReader::fieldCString(const char *key, char **val, std::size_t b ox::memcpy(data, begin, static_cast(strSize)); data[strSize] = nullptr; } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -147,7 +147,7 @@ Result OrganicClawReader::arrayLength(const char *key, bool) noexce if (jv.isArray()) { return jv.size(); } - return OxError(1, "Type mismatch"); + return ox::Error(1, "Type mismatch"); } [[nodiscard]] @@ -161,7 +161,7 @@ std::size_t OrganicClawReader::stringLength(const char *key) noexcept { jv.getString(&begin, &end); return static_cast(end - begin); } - return OxError(1, "Type mismatch"); + return ox::Error(1, "Type mismatch"); } OrganicClawReader OrganicClawReader::child(const char *key, int unionIdx) noexcept { diff --git a/deps/ox/src/ox/oc/read.hpp b/deps/ox/src/ox/oc/read.hpp index 9f220c3d..c0d9145e 100644 --- a/deps/ox/src/ox/oc/read.hpp +++ b/deps/ox/src/ox/oc/read.hpp @@ -133,7 +133,7 @@ class OrganicClawReader { template Error OrganicClawReader::field(const char *key, T *val) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); try { if constexpr (is_integer_v) { if (targetValid()) { @@ -146,7 +146,7 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept { } else if (rightType) { *val = static_cast(jv.asUInt()); } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } } else if constexpr (isVector_v) { @@ -158,7 +158,7 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept { const auto&srcVal = value(key); const auto srcSize = srcVal.size(); if (srcSize > val->size()) { - err = OxError(1, "Input array is too long"); + err = ox::Error(1, "Input array is too long"); } else { err = field(key, val->data(), val->size()); } @@ -169,11 +169,11 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept { ModelHandlerInterface handler(&reader); err = model(&handler, val); } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } } catch (Json::LogicError const&) { - err = OxError(1, "error reading JSON data"); + err = ox::Error(1, "error reading JSON data"); } ++m_fieldIt; return err; @@ -181,7 +181,7 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept { template Error OrganicClawReader::field(const char *key, UnionView val) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); if (targetValid()) { const auto &jv = value(key); if (jv.empty() || jv.isObject()) { @@ -189,7 +189,7 @@ Error OrganicClawReader::field(const char *key, UnionView val) noexcep ModelHandlerInterface handler(&reader); err = model(&handler, val.get()); } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -198,7 +198,7 @@ Error OrganicClawReader::field(const char *key, UnionView val) noexcep template Error OrganicClawReader::field(const char *key, BasicString *val) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); if (targetValid()) { const auto &jv = value(key); if (jv.empty()) { @@ -206,7 +206,7 @@ Error OrganicClawReader::field(const char *key, BasicString *val) noexcept { } else if (jv.isString()) { *val = jv.asString().c_str(); } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -215,7 +215,7 @@ Error OrganicClawReader::field(const char *key, BasicString *val) noexcept { template Error OrganicClawReader::field(const char *key, IString *val) noexcept { - auto err = OxError(0); + auto err = ox::Error(0); if (targetValid()) { const auto &jv = value(key); if (jv.empty()) { @@ -223,7 +223,7 @@ Error OrganicClawReader::field(const char *key, IString *val) noexcept { } else if (jv.isString()) { *val = jv.asString().c_str(); } else { - err = OxError(1, "Type mismatch"); + err = ox::Error(1, "Type mismatch"); } } ++m_fieldIt; @@ -235,11 +235,11 @@ template Error OrganicClawReader::field(const char *key, T *val, std::size_t valLen) noexcept { const auto &srcVal = value(key); if (!srcVal.isNull() && !srcVal.isArray()) { - return OxError(1, "Type mismatch"); + return ox::Error(1, "Type mismatch"); } auto srcSize = srcVal.size(); if (srcSize > valLen) { - return OxError(1); + return ox::Error(1); } OrganicClawReader r(srcVal); ModelHandlerInterface handler{&r}; @@ -248,14 +248,14 @@ OX_ALLOW_UNSAFE_BUFFERS_BEGIN oxReturnError(handler.field("", &val[i])); OX_ALLOW_UNSAFE_BUFFERS_END } - return OxError(0); + return ox::Error(0); } template Error OrganicClawReader::field(const char *key, HashMap *val) noexcept { const auto &srcVal = value(key); if (!srcVal.isObject()) { - return OxError(1, "Type mismatch"); + return ox::Error(1, "Type mismatch"); } auto keys = srcVal.getMemberNames(); auto srcSize = srcVal.size(); @@ -265,7 +265,7 @@ Error OrganicClawReader::field(const char *key, HashMap *val) noexcep const auto k = keys[i].c_str(); oxReturnError(handler.field(k, &val->operator[](k))); } - return OxError(0); + return ox::Error(0); } Error readOC(BufferView buff, auto &val) noexcept { @@ -277,7 +277,7 @@ Error readOC(BufferView buff, auto &val) noexcept { OX_ALLOW_UNSAFE_BUFFERS_BEGIN if (!parser->parse(buff.data(), buff.data() + buff.size(), &doc, nullptr)) { OX_ALLOW_UNSAFE_BUFFERS_END - return OxError(1, "Could not parse JSON"); + return ox::Error(1, "Could not parse JSON"); } OrganicClawReader reader(buff.data(), buff.size()); ModelHandlerInterface handler(&reader); @@ -285,7 +285,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END } catch (const Error &err) { return err; } catch (...) { - return OxError(1, "Unknown Error"); + return ox::Error(1, "Unknown Error"); } } diff --git a/deps/ox/src/ox/oc/test/tests.cpp b/deps/ox/src/ox/oc/test/tests.cpp index 13747d50..bf3d69d3 100644 --- a/deps/ox/src/ox/oc/test/tests.cpp +++ b/deps/ox/src/ox/oc/test/tests.cpp @@ -78,7 +78,7 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *obj) noex oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->fieldCString("String", &obj->String)); - return OxError(0); + return ox::Error(0); } constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *obj) noexcept { @@ -86,7 +86,7 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *obj) oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->field("String", &obj->String)); - return OxError(0); + return ox::Error(0); } constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *obj) noexcept { @@ -112,7 +112,7 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *obj) noe oxReturnError(io->field("Map", &obj->Map)); oxReturnError(io->field("EmptyStruct", &obj->EmptyStruct)); oxReturnError(io->field("Struct", &obj->Struct)); - return OxError(0); + return ox::Error(0); } TestStruct::TestStruct(TestStruct &&other) noexcept { @@ -184,7 +184,7 @@ const std::map tests = { oxAssert(testIn.Struct.String == testOut.Struct.String, "Struct.String value mismatch"); oxAssert(testIn.Struct.Bool == testOut.Struct.Bool, "Struct.Bool value mismatch"); - return OxError(0); + return ox::Error(0); } }, @@ -234,7 +234,7 @@ const std::map tests = { oxAssert(testOutStructCopy.get("String").unwrap()->get() == testIn.Struct.String.c_str(), "testOut.Struct.String (copy) failed"); oxAssert(testOutListCopy[0].get() == testIn.List[0], "testOut.Struct.List[0] (copy) failed"); oxAssert(testOutListCopy[1].get() == testIn.List[1], "testOut.Struct.List[1] (copy) failed"); - return OxError(0); + return ox::Error(0); } }, @@ -341,10 +341,10 @@ const std::map tests = { case ox::PrimitiveType::Union: break; } - return OxError(0); + return ox::Error(0); } )); - return OxError(0); + return ox::Error(0); } }, } diff --git a/deps/ox/src/ox/oc/write.cpp b/deps/ox/src/ox/oc/write.cpp index 13f99b85..88e44176 100644 --- a/deps/ox/src/ox/oc/write.cpp +++ b/deps/ox/src/ox/oc/write.cpp @@ -23,7 +23,7 @@ Error OrganicClawWriter::fieldCString(const char *key, const char *const*val, in value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error OrganicClawWriter::fieldCString(const char *key, const char *const*val) noexcept { diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index d87b0f7d..749af136 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -42,7 +42,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(const char *key, const int16_t *val) noexcept { @@ -50,7 +50,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(const char *key, const int32_t *val) noexcept { @@ -58,7 +58,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(const char *key, const int64_t *val) noexcept { @@ -66,7 +66,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } @@ -75,7 +75,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(const char *key, const uint16_t *val) noexcept { @@ -83,7 +83,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(const char *key, const uint32_t *val) noexcept { @@ -91,7 +91,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(const char *key, const uint64_t *val) noexcept { @@ -99,7 +99,7 @@ class OrganicClawWriter { value(key) = *val; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error field(char const*key, bool const*val) noexcept { @@ -147,7 +147,7 @@ class OrganicClawWriter { value(key) = val->c_str(); } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Error fieldCString(const char*, const char *const*val, int len) noexcept; @@ -207,7 +207,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END value(key) = w.m_json; } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } template @@ -233,7 +233,7 @@ Error OrganicClawWriter::field(const char *key, const T *val) noexcept { } } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } template @@ -247,7 +247,7 @@ Error OrganicClawWriter::field(const char *key, UnionView val) noexcep } } ++m_fieldIt; - return OxError(0); + return ox::Error(0); } Result writeOC(const auto &val) noexcept { diff --git a/deps/ox/src/ox/std/assert.hpp b/deps/ox/src/ox/std/assert.hpp index b9873b9d..dd95982b 100644 --- a/deps/ox/src/ox/std/assert.hpp +++ b/deps/ox/src/ox/std/assert.hpp @@ -22,9 +22,9 @@ namespace ox { -void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = OxError(0)) noexcept; +void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = ox::Error(0)) noexcept; -constexpr void constexprPanic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = OxError(0)) noexcept { +constexpr void constexprPanic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = ox::Error(0)) noexcept { if (!std::is_constant_evaluated()) { panic(file, line, panicMsg, err); } else { diff --git a/deps/ox/src/ox/std/buffer.hpp b/deps/ox/src/ox/std/buffer.hpp index b33b7bee..d6b9a3d2 100644 --- a/deps/ox/src/ox/std/buffer.hpp +++ b/deps/ox/src/ox/std/buffer.hpp @@ -53,7 +53,7 @@ class BufferWriter { base = static_cast>(m_it); break; default: - return OxError(1, "Invalid seekdir"); + return ox::Error(1, "Invalid seekdir"); } m_it = static_cast(base + off); return {}; @@ -125,7 +125,7 @@ class CharBuffWriter { base = static_cast>(m_it); break; default: - return OxError(1, "Invalid seekdir"); + return ox::Error(1, "Invalid seekdir"); } m_it = static_cast(base + off); return {}; @@ -138,7 +138,7 @@ class CharBuffWriter { constexpr ox::Error put(char val) noexcept { if (m_it >= m_cap) [[unlikely]] { - return OxError(1, "Buffer overrun"); + return ox::Error(1, "Buffer overrun"); } m_buff[m_it] = val; ++m_it; @@ -149,7 +149,7 @@ class CharBuffWriter { constexpr ox::Error write(const char *buff, std::size_t cnt) noexcept { const auto end = m_it + cnt; if (end > m_cap) [[unlikely]] { - return OxError(1, "Buffer overrun"); + return ox::Error(1, "Buffer overrun"); } if (buff) { for (auto i = 0u; i < cnt; ++i) { @@ -179,7 +179,7 @@ class BufferReader { constexpr ox::Result peek() const noexcept { if (m_it >= m_size) [[unlikely]] { - return OxError(1, "Peek failed: buffer overrun"); + return ox::Error(1, "Peek failed: buffer overrun"); } return m_buff[m_it]; } @@ -187,7 +187,7 @@ class BufferReader { constexpr ox::Result read(void *v, std::size_t sz) noexcept { sz = ox::min(sz, m_size - m_it); if (m_it + sz > m_size) [[unlikely]] { - return OxError(1, "Read failed: Buffer overrun"); + return ox::Error(1, "Read failed: Buffer overrun"); } ox::memcpy(v, &m_buff[m_it], sz); m_it += sz; @@ -196,7 +196,7 @@ class BufferReader { constexpr ox::Error seekg(std::size_t p) noexcept { if (p > m_size) [[unlikely]] { - return OxError(1, "Seek failed: Buffer overrun"); + return ox::Error(1, "Seek failed: Buffer overrun"); } m_it = p; return {}; @@ -215,11 +215,11 @@ class BufferReader { base = static_cast>(m_it); break; default: - return OxError(1, "Invalid seekdir"); + return ox::Error(1, "Invalid seekdir"); } auto const newIt = static_cast(base + off); if (newIt > m_size) [[unlikely]] { - return OxError(1, "Seek failed: Buffer overrun"); + return ox::Error(1, "Seek failed: Buffer overrun"); } m_it = newIt; return {}; diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 3110feba..c0fdf05f 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -30,7 +30,6 @@ class exception { #include "typetraits.hpp" #include "utility.hpp" -#define OxError(...) ox::Error(__FILE__, __LINE__, __VA_ARGS__) #define OxException(...) ox::Exception(__FILE__, __LINE__, __VA_ARGS__) namespace ox { @@ -165,10 +164,10 @@ struct [[nodiscard]] Result { constexpr Result(const Error &error) noexcept: value(), error(error) { } - constexpr Result(const type &value, const Error &error = OxError(0)) noexcept: value(value), error(error) { + constexpr Result(const type &value, const Error &error = ox::Error(0)) noexcept: value(value), error(error) { } - constexpr Result(type &&value, const Error &error = OxError(0)) noexcept: value(std::move(value)), error(error) { + constexpr Result(type &&value, const Error &error = ox::Error(0)) noexcept: value(std::move(value)), error(error) { } constexpr ~Result() noexcept = default; @@ -356,7 +355,7 @@ constexpr Error toError(const Result &r) noexcept { constexpr void primitiveAssert(const char *file, int line, bool pass, const char *msg) noexcept { if constexpr(ox::defines::Debug) { if (!pass) [[unlikely]] { - panic(file, line, msg, OxError(1)); + panic(file, line, msg, ox::Error(1)); } } } diff --git a/deps/ox/src/ox/std/hashmap.hpp b/deps/ox/src/ox/std/hashmap.hpp index 01334352..938add92 100644 --- a/deps/ox/src/ox/std/hashmap.hpp +++ b/deps/ox/src/ox/std/hashmap.hpp @@ -154,7 +154,7 @@ template constexpr Result HashMap::at(MaybeView_t const&k) noexcept { auto p = access(m_pairs, k); if (!p) { - return {nullptr, OxError(1, "value not found for given key")}; + return {nullptr, ox::Error(1, "value not found for given key")}; } return &p->value; } @@ -163,7 +163,7 @@ template constexpr Result HashMap::at(MaybeView_t const&k) const noexcept { auto p = access(m_pairs, k); if (!p) { - return {nullptr, OxError(1, "value not found for given key")}; + return {nullptr, ox::Error(1, "value not found for given key")}; } return &p->value; } diff --git a/deps/ox/src/ox/std/heapmgr.cpp b/deps/ox/src/ox/std/heapmgr.cpp index 9cdc358b..b73b5f81 100644 --- a/deps/ox/src/ox/std/heapmgr.cpp +++ b/deps/ox/src/ox/std/heapmgr.cpp @@ -77,7 +77,7 @@ static HeapSegment *findSegmentFor(std::size_t sz) noexcept { return s; } } - oxPanic(OxError(1), "malloc: could not find segment"); + oxPanic(ox::Error(1), "malloc: could not find segment"); return nullptr; } @@ -102,7 +102,7 @@ void free(void *ptr) noexcept { } else if (p.segment) { p.segment->inUse = false; } else { - oxPanic(OxError(1), "Bad heap free"); + oxPanic(ox::Error(1), "Bad heap free"); } } diff --git a/deps/ox/src/ox/std/istring.hpp b/deps/ox/src/ox/std/istring.hpp index 6df2caab..3108341e 100644 --- a/deps/ox/src/ox/std/istring.hpp +++ b/deps/ox/src/ox/std/istring.hpp @@ -174,7 +174,7 @@ constexpr Error IString::append(const char *str, std::size_t strLen) noe auto const currentLen = len(); if (cap() < currentLen + strLen) { strLen = cap() - currentLen; - err = OxError(1, "Insufficient space for full string"); + err = ox::Error(1, "Insufficient space for full string"); } OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage) ox::strncpy(m_buff.data() + currentLen, str, strLen); @@ -219,7 +219,7 @@ constexpr std::size_t IString::bytes() const noexcept { template constexpr ox::Error IString::resize(size_t sz) noexcept { if (sz > StrCap) [[unlikely]] { - return OxError(1, "Trying to extend IString beyond its cap"); + return ox::Error(1, "Trying to extend IString beyond its cap"); } for (auto i = m_size; i < sz; ++i) { m_buff[i] = 0; @@ -231,7 +231,7 @@ constexpr ox::Error IString::resize(size_t sz) noexcept { template constexpr ox::Error IString::unsafeResize(size_t sz) noexcept { if (sz > StrCap) [[unlikely]] { - return OxError(1, "Trying to extend IString beyond its cap"); + return ox::Error(1, "Trying to extend IString beyond its cap"); } m_size = sz; return {}; diff --git a/deps/ox/src/ox/std/new.hpp b/deps/ox/src/ox/std/new.hpp index e631d0c6..980d0a49 100644 --- a/deps/ox/src/ox/std/new.hpp +++ b/deps/ox/src/ox/std/new.hpp @@ -42,10 +42,10 @@ constexpr U *make(Args &&...args) noexcept { try { return new T(ox::forward(args)...); } catch (std::exception const&ex) { - oxPanic(OxError(1, ex.what()), ex.what()); + oxPanic(ox::Error(1, ex.what()), ex.what()); return nullptr; } catch (...) { - oxPanic(OxError(2, "Allocation or constructor failed"), "Allocation or constructor failed"); + oxPanic(ox::Error(2, "Allocation or constructor failed"), "Allocation or constructor failed"); return nullptr; } #else @@ -62,7 +62,7 @@ constexpr Result makeCatch(Args &&...args) noexcept { } catch (const ox::Exception &ex) { return ex.toError(); } catch (...) { - return OxError(1, "Allocation or constructor failed"); + return ox::Error(1, "Allocation or constructor failed"); } #else return new T(ox::forward(args)...); diff --git a/deps/ox/src/ox/std/reader.cpp b/deps/ox/src/ox/std/reader.cpp index 7733c2b9..01596006 100644 --- a/deps/ox/src/ox/std/reader.cpp +++ b/deps/ox/src/ox/std/reader.cpp @@ -34,11 +34,11 @@ ox::Result StreamReader::peek() const noexcept { m_strm.get(c); auto const ok = c != EOF; if (ok && m_strm.unget()) [[unlikely]] { - return OxError(1, "Unable to unget character"); + return ox::Error(1, "Unable to unget character"); } - return {static_cast(c), OxError(!ok, "File peek failed")}; + return {static_cast(c), ox::Error(!ok, "File peek failed")}; } catch (std::exception const&) { - return OxError(1, "peek failed"); + return ox::Error(1, "peek failed"); } } @@ -50,7 +50,7 @@ ox::Error StreamReader::seekg(std::size_t p) noexcept { try { m_strm.seekg(static_cast(p), std::ios_base::cur); } catch (std::exception const&) { - return OxError(1, "seekg failed"); + return ox::Error(1, "seekg failed"); } return {}; } @@ -59,14 +59,14 @@ ox::Error StreamReader::seekg(int64_t p, ios_base::seekdir sd) noexcept { try { m_strm.seekg(p, sdMap(sd)); } catch (std::exception const&) { - return OxError(1, "seekg failed"); + return ox::Error(1, "seekg failed"); } return {}; } ox::Result StreamReader::tellg() noexcept { const auto sz = m_strm.tellg(); - return {static_cast(sz), OxError(sz == -1)}; + return {static_cast(sz), ox::Error(sz == -1)}; } } diff --git a/deps/ox/src/ox/std/smallmap.hpp b/deps/ox/src/ox/std/smallmap.hpp index 66871cf3..bb482215 100644 --- a/deps/ox/src/ox/std/smallmap.hpp +++ b/deps/ox/src/ox/std/smallmap.hpp @@ -140,7 +140,7 @@ template constexpr Result SmallMap::at(MaybeView_t const&k) noexcept { auto p = access(m_pairs, k); if (!p) { - return {nullptr, OxError(1, "value not found for given key")}; + return {nullptr, ox::Error(1, "value not found for given key")}; } return &p->value; } @@ -149,7 +149,7 @@ template constexpr Result SmallMap::at(MaybeView_t const&k) const noexcept { auto p = access(m_pairs, k); if (!p) { - return {nullptr, OxError(1, "value not found for given key")}; + return {nullptr, ox::Error(1, "value not found for given key")}; } return &p->value; } diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index 93daefdf..88e23be3 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -182,7 +182,7 @@ class BasicString { // make sure last element is a null terminator m_buff[currentLen + strLen] = 0; // this can't fail, but it returns an Error to match BString::append - return OxError(0); + return ox::Error(0); } constexpr Error append(ox::StringView sv) noexcept { diff --git a/deps/ox/src/ox/std/stringview.hpp b/deps/ox/src/ox/std/stringview.hpp index b2c42940..03b7a3b3 100644 --- a/deps/ox/src/ox/std/stringview.hpp +++ b/deps/ox/src/ox/std/stringview.hpp @@ -109,7 +109,7 @@ constexpr ox::Result atoi(ox::StringViewCR str) noexcept { total += (str[s] - '0') * multiplier; multiplier *= 10; } else { - return OxError(1); + return ox::Error(1); } } return total; diff --git a/deps/ox/src/ox/std/strops.hpp b/deps/ox/src/ox/std/strops.hpp index 65e89004..0f341032 100644 --- a/deps/ox/src/ox/std/strops.hpp +++ b/deps/ox/src/ox/std/strops.hpp @@ -106,7 +106,7 @@ constexpr ox::Vector split(StringViewCR str, StringView [[nodiscard]] constexpr ox::Result lastIndexOf(ox::StringViewCR str, int character) noexcept { - ox::Result retval = OxError(1, "Character not found"); + ox::Result retval = ox::Error(1, "Character not found"); for (auto i = static_cast(str.bytes() - 1); i >= 0; --i) { if (str[static_cast(i)] == character) { retval = static_cast(i); diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index 4aecb7ce..634e3b01 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -126,7 +126,7 @@ OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage) OX_CLANG_NOWARN_END ox::heapmgr::free(a1); ox::heapmgr::free(a2); - return OxError(0); + return ox::Error(0); } }, { @@ -148,25 +148,25 @@ OX_CLANG_NOWARN_END { "ABCDEFG != HIJKLMN", []() { - return OxError(ox::memcmp("ABCDEFG", "HIJKLMN", 7) >= 0); + return ox::Error(ox::memcmp("ABCDEFG", "HIJKLMN", 7) >= 0); } }, { "HIJKLMN != ABCDEFG", []() { - return OxError(ox::memcmp("HIJKLMN", "ABCDEFG", 7) <= 0); + return ox::Error(ox::memcmp("HIJKLMN", "ABCDEFG", 7) <= 0); } }, { "ABCDEFG == ABCDEFG", []() { - return OxError(ox::memcmp("ABCDEFG", "ABCDEFG", 7) != 0); + return ox::Error(ox::memcmp("ABCDEFG", "ABCDEFG", 7) != 0); } }, { "ABCDEFGHI == ABCDEFG", []() { - return OxError(ox::memcmp("ABCDEFGHI", "ABCDEFG", 7) != 0); + return ox::Error(ox::memcmp("ABCDEFGHI", "ABCDEFG", 7) != 0); } }, { @@ -182,7 +182,7 @@ OX_CLANG_NOWARN_END oxAssert(s == "asdf", "String assign broken"); oxAssert(s != "aoeu", "String assign broken"); oxAssert(s.len() == 4, "String assign broken"); - return OxError(0); + return ox::Error(0); } }, { @@ -216,7 +216,7 @@ OX_CLANG_NOWARN_END oxAssert( ox::String(ox::StringView("Write")) == ox::StringView("Write"), "String / StringView comparison broken"); - return OxError(0); + return ox::Error(0); } }, { @@ -227,14 +227,14 @@ OX_CLANG_NOWARN_END oxAssert(v.empty(), "Vector::empty() is broken"); auto insertTest = [&v](int val, std::size_t size) { v.push_back(val); - oxReturnError(OxError(v.size() != size, "Vector size incorrect")); - oxReturnError(OxError(v[v.size() - 1] != val, "Vector value wrong")); - return OxError(0); + oxReturnError(ox::Error(v.size() != size, "Vector size incorrect")); + oxReturnError(ox::Error(v[v.size() - 1] != val, "Vector value wrong")); + return ox::Error(0); }; oxAssert(insertTest(42, 1), "Vector insertion failed"); oxAssert(insertTest(100, 2), "Vector insertion failed"); oxAssert(insertTest(102, 3), "Vector insertion failed"); - return OxError(0); + return ox::Error(0); } }, { @@ -246,7 +246,7 @@ OX_CLANG_NOWARN_END oxExpect(map.size(), 1u); oxExpect(map["aoeu"], ""); oxExpect(map.size(), 2u); - return OxError(0); + return ox::Error(0); } }, { @@ -262,7 +262,7 @@ OX_CLANG_NOWARN_END ii[5] = 100; oxAssert(ii[4] == 42, "4 != 42"); oxAssert(ii[5] == 100, "5 != 100"); - return OxError(0); + return ox::Error(0); } }, { @@ -278,7 +278,7 @@ OX_CLANG_NOWARN_END ii[5] = 100; oxAssert(ii[4] == 42, "4 != 42"); oxAssert(ii[5] == 100, "5 != 100"); - return OxError(0); + return ox::Error(0); } }, { @@ -319,7 +319,7 @@ OX_CLANG_NOWARN_END oxExpect(ox::serialize(257).unwrap(), BA({1, 1, 0, 0})); constexpr auto neg1 = static_cast(-1); // ARM64 Linux assumes -1 literals are ints... oxExpect(ox::serialize(0xffff'ffff).unwrap(), BA({neg1, neg1, neg1, neg1})); - return OxError(0); + return ox::Error(0); } }, { @@ -336,7 +336,7 @@ OX_CLANG_NOWARN_END oxAssert(w.write(qwerty.data(), qwerty.bytes()), "write failed"); oxExpect(b.size(), 14u); oxExpect(ox::StringView(b.data(), b.size()), "asdfaoeuqwerty"); - return OxError(0); + return ox::Error(0); } }, { @@ -359,7 +359,7 @@ OX_CLANG_NOWARN_END oxExpect(ox::detail::fromHex("a0").unwrap(), 0xa0); oxExpect(ox::detail::fromHex("93").unwrap(), 0x93); oxExpect(ox::detail::fromHex("40").unwrap(), 0x40); - return OxError(0); + return ox::Error(0); } }, { @@ -379,7 +379,7 @@ OX_CLANG_NOWARN_END oxExpect(ox::detail::toHex(0x93), "93"); oxExpect(ox::detail::toHex(0x40), "40"); oxExpect(ox::detail::toHex(0xf0), "f0"); - return OxError(0); + return ox::Error(0); } }, { @@ -390,7 +390,7 @@ OX_CLANG_NOWARN_END oxExpect(uuid.toString(), uuidStr); oxExpect(ox::UUID{}.isNull(), true); oxExpect(ox::UUID::fromString(uuidStr).value.isNull(), false); - return OxError(0); + return ox::Error(0); } }, { @@ -400,7 +400,7 @@ OX_CLANG_NOWARN_END oxExpect(ox::UUID::generate().unwrap().toString(), "5c3f4b5e-ccbf-4727-7f03-3053dedc8827"); oxExpect(ox::UUID::generate().unwrap().toString(), "90d0274a-2774-4afa-88e5-0c1d60ba3abf"); oxExpect(ox::UUID::generate().unwrap().toString(), "7df77910-841c-48ba-ea2e-44521ac47c2e"); - return OxError(0); + return ox::Error(0); } }, { @@ -467,7 +467,7 @@ OX_CLANG_NOWARN_END sv = ""; list = ox::split(sv, '.'); oxExpect(list.size(), 0u); - return OxError(0); + return ox::Error(0); } }, }; diff --git a/deps/ox/src/ox/std/uuid.cpp b/deps/ox/src/ox/std/uuid.cpp index 390717a4..4c6a47f9 100644 --- a/deps/ox/src/ox/std/uuid.cpp +++ b/deps/ox/src/ox/std/uuid.cpp @@ -21,7 +21,7 @@ void UUID::seedGenerator(const RandomSeed &seed) noexcept { // UUID v4 Result UUID::generate() noexcept { if (!s_seeded) { - return OxError(1, "UUID generator not seeded."); + return ox::Error(1, "UUID generator not seeded."); } UUID out; for (auto &v : out.m_value) { diff --git a/deps/ox/src/ox/std/uuid.hpp b/deps/ox/src/ox/std/uuid.hpp index 444a856a..ca32aeeb 100644 --- a/deps/ox/src/ox/std/uuid.hpp +++ b/deps/ox/src/ox/std/uuid.hpp @@ -56,10 +56,10 @@ constexpr ox::Result fromHex(ox::StringViewCR v) noexcept { return out; }(); if (!detail::isHexChar(v[0]) || !detail::isHexChar(v[1])) { - return OxError(1, "Invalid UUID"); + return ox::Error(1, "Invalid UUID"); } if (v.len() != 2) { - return OxError(2); + return ox::Error(2); } uint8_t out = 0; out += static_cast(valMap[static_cast(v[0])] * 16); @@ -130,7 +130,7 @@ class UUID { static constexpr ox::Result fromString(ox::StringViewCR s) noexcept { if (s.len() < 36) { - return OxError(1, "Insufficient data to contain a complete UUID"); + return ox::Error(1, "Insufficient data to contain a complete UUID"); } UUID out; auto valueI = 0u; @@ -141,7 +141,7 @@ class UUID { } const auto seg = substr(s, i, i + 2); if (seg.len() != 2) { - return OxError(1, "Invalid UUID"); + return ox::Error(1, "Invalid UUID"); } oxRequire(val, detail::fromHex(seg)); out.m_value[valueI] = val; diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index 7bdaf522..7c8b5e33 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -439,7 +439,7 @@ constexpr Result Vector::at(size_t i) noexcep if (i < size()) [[likely]] { return &operator[](i); } - return OxError(1, "Vector: Invalid index"); + return ox::Error(1, "Vector: Invalid index"); } template @@ -447,13 +447,13 @@ constexpr Result Vector::at(size_t i) c if (i < size()) [[likely]] { return &operator[](i); } - return OxError(1, "Vector: Invalid index"); + return ox::Error(1, "Vector: Invalid index"); } template constexpr Result Vector::front() noexcept { if (!m_size) { - return {nullptr, OxError(1)}; + return {nullptr, ox::Error(1)}; } return &m_items[0]; } @@ -461,7 +461,7 @@ constexpr Result Vector::front() noexcept { template constexpr Result Vector::front() const noexcept { if (!m_size) { - return {nullptr, OxError(1)}; + return {nullptr, ox::Error(1)}; } return &m_items[0]; } @@ -469,7 +469,7 @@ constexpr Result Vector::front() const template constexpr Result Vector::back() noexcept { if (!m_size) { - return {nullptr, OxError(1)}; + return {nullptr, ox::Error(1)}; } return &m_items[m_size - 1]; } @@ -477,7 +477,7 @@ constexpr Result Vector::back() noexcept { template constexpr Result Vector::back() const noexcept { if (!m_size) { - return {nullptr, OxError(1)}; + return {nullptr, ox::Error(1)}; } return &m_items[m_size - 1]; } @@ -634,7 +634,7 @@ template constexpr Result::template iterator> Vector::erase(std::size_t pos) noexcept(useNoexcept) { if (pos >= m_size) { - return OxError(1, "Vector::erase failed: pos is greater than Vector size"); + return ox::Error(1, "Vector::erase failed: pos is greater than Vector size"); } --m_size; for (auto i = pos; i < m_size; ++i) { @@ -648,12 +648,12 @@ template constexpr Error Vector::unordered_erase(std::size_t pos) noexcept(useNoexcept) { if (pos >= m_size) { - return OxError(1); + return ox::Error(1); } --m_size; m_items[pos] = std::move(m_items[m_size]); m_items[m_size].~T(); - return OxError(0); + return ox::Error(0); } template