[ox] Fix Xcode build errors
This commit is contained in:
parent
4549569746
commit
7bccfc8a00
2
deps/ox/src/ox/fs/CMakeLists.txt
vendored
2
deps/ox/src/ox/fs/CMakeLists.txt
vendored
@ -1,6 +1,8 @@
|
||||
|
||||
add_library(
|
||||
OxFS
|
||||
ptrarith/nodebuffer.hpp
|
||||
ptrarith/ptr.hpp
|
||||
filestore/filestoretemplate.cpp
|
||||
filesystem/filelocation.cpp
|
||||
filesystem/pathiterator.cpp
|
||||
|
@ -75,25 +75,25 @@ class FileStoreTemplate {
|
||||
public:
|
||||
FileStoreTemplate() = default;
|
||||
|
||||
FileStoreTemplate(void *buff, size_t buffSize);
|
||||
FileStoreTemplate(void *buff, std::size_t buffSize);
|
||||
|
||||
static Error format(void *buffer, size_t bufferSize);
|
||||
static Error format(void *buffer, std::size_t bufferSize);
|
||||
|
||||
Error setSize(InodeId_t buffSize);
|
||||
Error setSize(std::size_t buffSize);
|
||||
|
||||
Error incLinks(InodeId_t id);
|
||||
Error incLinks(uint64_t id);
|
||||
|
||||
Error decLinks(InodeId_t id);
|
||||
Error decLinks(uint64_t id);
|
||||
|
||||
Error write(InodeId_t id, const void *data, FsSize_t dataSize, uint8_t fileType = 0);
|
||||
Error write(uint64_t id64, const void *data, FsSize_t dataSize, uint8_t fileType = 0);
|
||||
|
||||
Error remove(InodeId_t id);
|
||||
Error remove(uint64_t id);
|
||||
|
||||
Error read(InodeId_t id, void *out, FsSize_t outSize, FsSize_t *size = nullptr) const;
|
||||
Error read(uint64_t id, void *out, FsSize_t outSize, FsSize_t *size = nullptr) const;
|
||||
|
||||
Error read(InodeId_t id, FsSize_t readStart, FsSize_t readSize, void *data, FsSize_t *size = nullptr) const;
|
||||
Error read(uint64_t id, FsSize_t readStart, FsSize_t readSize, void *data, FsSize_t *size = nullptr) const;
|
||||
|
||||
ptrarith::Ptr<uint8_t, std::size_t> read(InodeId_t id) const;
|
||||
ptrarith::Ptr<uint8_t, std::size_t> read(uint64_t id) const;
|
||||
|
||||
/**
|
||||
* Reads the "file" at the given id. You are responsible for freeing
|
||||
@ -106,11 +106,11 @@ class FileStoreTemplate {
|
||||
* @return 0 if read is a success
|
||||
*/
|
||||
template<typename T>
|
||||
Error read(InodeId_t id, FsSize_t readStart,
|
||||
Error read(uint64_t id, FsSize_t readStart,
|
||||
FsSize_t readSize, T *data,
|
||||
FsSize_t *size) const;
|
||||
|
||||
Result<StatInfo> stat(InodeId_t id) const;
|
||||
Result<StatInfo> stat(uint64_t id) const;
|
||||
|
||||
Error resize();
|
||||
|
||||
@ -185,23 +185,23 @@ class FileStoreTemplate {
|
||||
*/
|
||||
ItemPtr rootInode();
|
||||
|
||||
bool canWrite(ItemPtr existing, size_t size);
|
||||
bool canWrite(ItemPtr existing, std::size_t size);
|
||||
|
||||
};
|
||||
|
||||
template<typename size_t>
|
||||
FileStoreTemplate<size_t>::FileStoreTemplate(void *buff, size_t buffSize) {
|
||||
m_buffSize = buffSize;
|
||||
FileStoreTemplate<size_t>::FileStoreTemplate(void *buff, std::size_t buffSize) {
|
||||
m_buffSize = static_cast<size_t>(buffSize);
|
||||
m_buffer = reinterpret_cast<ptrarith::NodeBuffer<size_t, FileStoreItem<size_t>>*>(buff);
|
||||
if (!m_buffer->valid(buffSize)) {
|
||||
if (!m_buffer->valid(m_buffSize)) {
|
||||
m_buffSize = 0;
|
||||
m_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::format(void *buffer, size_t bufferSize) {
|
||||
auto nb = new (buffer) Buffer(bufferSize);
|
||||
Error FileStoreTemplate<size_t>::format(void *buffer, std::size_t bufferSize) {
|
||||
auto nb = new (buffer) Buffer(static_cast<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");
|
||||
@ -213,27 +213,27 @@ Error FileStoreTemplate<size_t>::format(void *buffer, size_t bufferSize) {
|
||||
return OxError(1, "Could not read data section of FileStoreData");
|
||||
}
|
||||
new (data) FileStoreData;
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::setSize(InodeId_t size) {
|
||||
Error FileStoreTemplate<size_t>::setSize(std::size_t size) {
|
||||
if (m_buffSize >= size) {
|
||||
return m_buffer->setSize(size);
|
||||
return m_buffer->setSize(static_cast<size_t>(size));
|
||||
}
|
||||
return OxError(1);
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::incLinks(InodeId_t id) {
|
||||
oxRequireM(item, find(id).validate());
|
||||
Error FileStoreTemplate<size_t>::incLinks(uint64_t id) {
|
||||
oxRequireM(item, find(static_cast<size_t>(id)).validate());
|
||||
item->links++;
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::decLinks(InodeId_t id) {
|
||||
oxRequireM(item, find(id).validate());
|
||||
Error FileStoreTemplate<size_t>::decLinks(uint64_t id) {
|
||||
oxRequireM(item, find(static_cast<size_t>(id)).validate());
|
||||
item->links--;
|
||||
if (item->links == 0) {
|
||||
oxReturnError(remove(item));
|
||||
@ -242,7 +242,8 @@ Error FileStoreTemplate<size_t>::decLinks(InodeId_t id) {
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::write(InodeId_t id, const void *data, FsSize_t dataSize, uint8_t fileType) {
|
||||
Error FileStoreTemplate<size_t>::write(uint64_t id64, const void *data, FsSize_t dataSize, uint8_t fileType) {
|
||||
const auto id = static_cast<size_t>(id64);
|
||||
oxTracef("ox::fs::FileStoreTemplate::write", "Attempting to write to inode {}", id);
|
||||
auto existing = find(id);
|
||||
if (!canWrite(existing, dataSize)) {
|
||||
@ -308,14 +309,14 @@ Error FileStoreTemplate<size_t>::write(InodeId_t id, const void *data, FsSize_t
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::remove(InodeId_t id) {
|
||||
return remove(find(id));
|
||||
Error FileStoreTemplate<size_t>::remove(uint64_t id) {
|
||||
return remove(find(static_cast<size_t>(id)));
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::read(InodeId_t id, void *out, FsSize_t outSize, FsSize_t *size) const {
|
||||
Error FileStoreTemplate<size_t>::read(uint64_t id, void *out, FsSize_t outSize, FsSize_t *size) const {
|
||||
oxTracef("ox::fs::FileStoreTemplate::read", "Attempting to read from inode {}", id);
|
||||
auto src = find(id);
|
||||
auto src = find(static_cast<size_t>(id));
|
||||
// error check
|
||||
if (!src.valid()) {
|
||||
oxTracef("ox::fs::FileStoreTemplate::read::fail", "Could not find requested item: {}", id);
|
||||
@ -344,9 +345,9 @@ Error FileStoreTemplate<size_t>::read(InodeId_t id, void *out, FsSize_t outSize,
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::read(InodeId_t id, FsSize_t readStart, FsSize_t readSize, void *out, FsSize_t *size) const {
|
||||
Error FileStoreTemplate<size_t>::read(uint64_t id, FsSize_t readStart, FsSize_t readSize, void *out, FsSize_t *size) const {
|
||||
oxTracef("ox::fs::FileStoreTemplate::read", "Attempting to read from inode {}", id);
|
||||
auto src = find(id);
|
||||
auto src = find(static_cast<size_t>(id));
|
||||
// error check
|
||||
if (!src.valid()) {
|
||||
oxTracef("ox::fs::FileStoreTemplate::read::fail", "Could not find requested item: {}", id);
|
||||
@ -376,10 +377,10 @@ Error FileStoreTemplate<size_t>::read(InodeId_t id, FsSize_t readStart, FsSize_t
|
||||
|
||||
template<typename size_t>
|
||||
template<typename T>
|
||||
Error FileStoreTemplate<size_t>::read(InodeId_t id, FsSize_t readStart,
|
||||
Error FileStoreTemplate<size_t>::read(uint64_t id, FsSize_t readStart,
|
||||
FsSize_t readSize, T *out, FsSize_t *size) const {
|
||||
oxTracef("ox::fs::FileStoreTemplate::read", "Attempting to read from inode {}", id);
|
||||
auto src = find(id);
|
||||
auto src = find(static_cast<size_t>(id));
|
||||
// error check
|
||||
if (!src.valid()) {
|
||||
oxTracef("ox::fs::FileStoreTemplate::read::fail", "Could not find requested item: {}", id);
|
||||
@ -408,8 +409,8 @@ Error FileStoreTemplate<size_t>::read(InodeId_t id, FsSize_t readStart,
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
ptrarith::Ptr<uint8_t, std::size_t> FileStoreTemplate<size_t>::read(InodeId_t id) const {
|
||||
auto item = find(id);
|
||||
ptrarith::Ptr<uint8_t, std::size_t> FileStoreTemplate<size_t>::read(uint64_t id) const {
|
||||
auto item = find(static_cast<size_t>(id));
|
||||
if (item.valid()) {
|
||||
return item->data();
|
||||
} else {
|
||||
@ -432,17 +433,17 @@ Error FileStoreTemplate<size_t>::resize(std::size_t size, void *newBuff) {
|
||||
if (m_buffer->size() > size) {
|
||||
return OxError(1);
|
||||
}
|
||||
m_buffSize = size;
|
||||
m_buffSize = static_cast<size_t>(size);
|
||||
if (newBuff) {
|
||||
m_buffer = reinterpret_cast<Buffer*>(newBuff);
|
||||
oxReturnError(m_buffer->setSize(size));
|
||||
oxReturnError(m_buffer->setSize(static_cast<size_t>(size)));
|
||||
}
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Result<StatInfo> FileStoreTemplate<size_t>::stat(InodeId_t id) const {
|
||||
oxRequire(inode, find(id).validate());
|
||||
Result<StatInfo> FileStoreTemplate<size_t>::stat(uint64_t id) const {
|
||||
oxRequire(inode, find(static_cast<size_t>(id)).validate());
|
||||
return StatInfo {
|
||||
id,
|
||||
inode->links,
|
||||
@ -486,8 +487,8 @@ Result<typename FileStoreTemplate<size_t>::InodeId_t> FileStoreTemplate<size_t>:
|
||||
return OxError(1);
|
||||
}
|
||||
for (auto i = 0; i < 100; i++) {
|
||||
auto inode = fsData->random.gen() % MaxValue<InodeId_t>;
|
||||
if (inode > ReservedInodeEnd && !find(inode).valid()) {
|
||||
auto inode = static_cast<typename FileStoreTemplate<size_t>::InodeId_t>(fsData->random.gen() % MaxValue<InodeId_t>);
|
||||
if (inode > ReservedInodeEnd && !find(static_cast<size_t>(inode)).valid()) {
|
||||
return inode;
|
||||
}
|
||||
}
|
||||
@ -511,7 +512,7 @@ Error FileStoreTemplate<size_t>::compact() {
|
||||
if (fsData && oldAddr == fsData->rootNode) {
|
||||
fsData->rootNode = item.offset();
|
||||
}
|
||||
auto parent = findParent(rootInode(), item->id, oldAddr);
|
||||
auto parent = findParent(rootInode(), item->id, static_cast<size_t>(oldAddr));
|
||||
oxAssert(parent.valid() || rootInode() == item.offset(),
|
||||
"Parent inode not found for item that should have parent.");
|
||||
if (parent.valid()) {
|
||||
@ -753,8 +754,9 @@ typename FileStoreTemplate<size_t>::ItemPtr FileStoreTemplate<size_t>::rootInode
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
bool FileStoreTemplate<size_t>::canWrite(ItemPtr existing, size_t size) {
|
||||
return existing.size() >= size || m_buffer->spaceNeeded(size) <= m_buffer->available();
|
||||
bool FileStoreTemplate<size_t>::canWrite(ItemPtr existing, std::size_t size) {
|
||||
const auto sz = static_cast<size_t>(size);
|
||||
return existing.size() >= sz || m_buffer->spaceNeeded(sz) <= m_buffer->available();
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
|
19
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
19
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -72,7 +72,7 @@ struct OX_PACKED DirectoryEntry {
|
||||
return fullSize() - sizeof(*this);
|
||||
}
|
||||
|
||||
void setSize(InodeId_t) {
|
||||
void setSize(std::size_t) {
|
||||
// ignore set value
|
||||
}
|
||||
|
||||
@ -94,9 +94,9 @@ class Directory {
|
||||
FileStore m_fs;
|
||||
|
||||
public:
|
||||
Directory() = default;
|
||||
Directory() noexcept = default;
|
||||
|
||||
Directory(FileStore fs, InodeId_t inode);
|
||||
Directory(FileStore fs, uint64_t inode) noexcept;
|
||||
|
||||
/**
|
||||
* Initializes Directory.
|
||||
@ -108,24 +108,26 @@ class Directory {
|
||||
/**
|
||||
* @param parents indicates the operation should create non-existent directories in the path, like mkdir -p
|
||||
*/
|
||||
Error write(PathIterator path, InodeId_t inode, FileName *nameBuff = nullptr) noexcept;
|
||||
Error write(PathIterator path, uint64_t inode64, FileName *nameBuff = nullptr) noexcept;
|
||||
|
||||
Error remove(PathIterator path, FileName *nameBuff = nullptr) noexcept;
|
||||
|
||||
template<typename F>
|
||||
Error ls(F cb) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
Result<typename FileStore::InodeId_t> findEntry(const FileName &name) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
Result<typename FileStore::InodeId_t> find(PathIterator name, FileName *nameBuff = nullptr) const noexcept;
|
||||
|
||||
};
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Directory<FileStore, InodeId_t>::Directory(FileStore fs, InodeId_t inodeId) {
|
||||
Directory<FileStore, InodeId_t>::Directory(FileStore fs, uint64_t inodeId) noexcept {
|
||||
m_fs = fs;
|
||||
m_inodeId = inodeId;
|
||||
auto buff = m_fs.read(inodeId).template to<Buffer>();
|
||||
m_inodeId = static_cast<InodeId_t>(inodeId);
|
||||
auto buff = m_fs.read(static_cast<InodeId_t>(inodeId)).template to<Buffer>();
|
||||
if (buff.valid()) {
|
||||
m_size = buff.size();
|
||||
}
|
||||
@ -192,7 +194,8 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, Fi
|
||||
}
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode, FileName *nameBuff) noexcept {
|
||||
Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64, FileName *nameBuff) noexcept {
|
||||
const auto inode = static_cast<InodeId_t>(inode64);
|
||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||
if (nameBuff == nullptr) {
|
||||
nameBuff = new (ox_alloca(sizeof(FileName))) FileName;
|
||||
|
41
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
41
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
@ -25,7 +25,7 @@ class OX_PACKED NodeBuffer {
|
||||
LittleEndian<size_t> firstItem = 0;
|
||||
};
|
||||
|
||||
using ItemPtr = Ptr<Item, size_t, sizeof(Header)>;
|
||||
using ItemPtr = Ptr<Item, size_t, sizeof(Header)>;
|
||||
|
||||
class Iterator {
|
||||
private:
|
||||
@ -97,9 +97,9 @@ class OX_PACKED NodeBuffer {
|
||||
Header m_header;
|
||||
|
||||
public:
|
||||
NodeBuffer(const NodeBuffer &other, size_t size) noexcept;
|
||||
NodeBuffer(const NodeBuffer &other, std::size_t size) noexcept;
|
||||
|
||||
explicit NodeBuffer(size_t size) noexcept;
|
||||
explicit NodeBuffer(std::size_t size) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
const Iterator iterator() const noexcept;
|
||||
@ -129,7 +129,7 @@ class OX_PACKED NodeBuffer {
|
||||
|
||||
ItemPtr ptr(size_t offset) noexcept;
|
||||
|
||||
Result<ItemPtr> malloc(size_t size) noexcept;
|
||||
Result<ItemPtr> malloc(std::size_t size) noexcept;
|
||||
|
||||
Error free(ItemPtr item) noexcept;
|
||||
|
||||
@ -139,7 +139,7 @@ class OX_PACKED NodeBuffer {
|
||||
/**
|
||||
* Set size, capacity.
|
||||
*/
|
||||
Error setSize(size_t size) noexcept;
|
||||
Error setSize(std::size_t size) noexcept;
|
||||
|
||||
/**
|
||||
* Get size, capacity.
|
||||
@ -159,7 +159,7 @@ class OX_PACKED NodeBuffer {
|
||||
* bytes
|
||||
*/
|
||||
[[nodiscard]]
|
||||
static size_t spaceNeeded(size_t size) noexcept;
|
||||
static size_t spaceNeeded(std::size_t size) noexcept;
|
||||
|
||||
template<typename F>
|
||||
Error compact(F cb = [](uint64_t, ItemPtr) {}) noexcept;
|
||||
@ -171,14 +171,14 @@ class OX_PACKED NodeBuffer {
|
||||
};
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
NodeBuffer<size_t, Item>::NodeBuffer(size_t size) noexcept {
|
||||
m_header.size = size;
|
||||
NodeBuffer<size_t, Item>::NodeBuffer(std::size_t size) noexcept {
|
||||
m_header.size = static_cast<size_t>(size);
|
||||
ox_memset(this + 1, 0, size - sizeof(*this));
|
||||
oxTrace("ox::NodeBuffer::constructor") << m_header.firstItem;
|
||||
}
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
NodeBuffer<size_t, Item>::NodeBuffer(const NodeBuffer &other, size_t size) noexcept {
|
||||
NodeBuffer<size_t, Item>::NodeBuffer(const NodeBuffer &other, std::size_t size) noexcept {
|
||||
oxTracef("ox::ptrarith::NodeBuffer::copy", "other.m_header.firstItem: {}", other.m_header.firstItem.get());
|
||||
ox_memset(this + 1, 0, size - sizeof(*this));
|
||||
ox_memcpy(this, &other, size);
|
||||
@ -265,9 +265,10 @@ typename NodeBuffer<size_t, Item>::ItemPtr NodeBuffer<size_t, Item>::ptr(size_t
|
||||
}
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
Result<typename NodeBuffer<size_t, Item>::ItemPtr> NodeBuffer<size_t, Item>::malloc(size_t size) noexcept {
|
||||
oxTracef("ox::ptrarith::NodeBuffer::malloc", "Size: {}", size);
|
||||
size_t fullSize = size + sizeof(Item);
|
||||
Result<typename NodeBuffer<size_t, Item>::ItemPtr> NodeBuffer<size_t, Item>::malloc(std::size_t size) noexcept {
|
||||
const auto sz = static_cast<std::size_t>(size);
|
||||
oxTracef("ox::ptrarith::NodeBuffer::malloc", "Size: {}", sz);
|
||||
size_t fullSize = static_cast<size_t>(sz + sizeof(Item));
|
||||
if (m_header.size - m_header.bytesUsed >= fullSize) {
|
||||
auto last = lastItem();
|
||||
size_t addr;
|
||||
@ -277,7 +278,7 @@ Result<typename NodeBuffer<size_t, Item>::ItemPtr> NodeBuffer<size_t, Item>::mal
|
||||
// there is no first item, so this must be the first item
|
||||
if (!m_header.firstItem) {
|
||||
oxTrace("ox::ptrarith::NodeBuffer::malloc", "No first item, initializing.");
|
||||
m_header.firstItem = sizeof(m_header);
|
||||
m_header.firstItem = static_cast<size_t>(sizeof(m_header));
|
||||
addr = m_header.firstItem;
|
||||
} else {
|
||||
oxTrace("ox::ptrarith::NodeBuffer::malloc::fail", "NodeBuffer is in invalid state.");
|
||||
@ -292,7 +293,7 @@ Result<typename NodeBuffer<size_t, Item>::ItemPtr> NodeBuffer<size_t, Item>::mal
|
||||
}
|
||||
ox_memset(out, 0, fullSize);
|
||||
new (out) Item;
|
||||
out->setSize(size);
|
||||
out->setSize(sz);
|
||||
|
||||
auto first = firstItem();
|
||||
auto oldLast = last;
|
||||
@ -355,7 +356,7 @@ Error NodeBuffer<size_t, Item>::free(ItemPtr item) noexcept {
|
||||
}
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
Error NodeBuffer<size_t, Item>::setSize(size_t size) noexcept {
|
||||
Error NodeBuffer<size_t, Item>::setSize(std::size_t size) noexcept {
|
||||
oxTracef("ox::ptrarith::NodeBuffer::setSize", "{} to {}", m_header.size.get(), size);
|
||||
auto last = lastItem();
|
||||
auto end = last.valid() ? last.end() : sizeof(m_header);
|
||||
@ -364,7 +365,7 @@ Error NodeBuffer<size_t, Item>::setSize(size_t size) noexcept {
|
||||
// resizing to less than buffer size
|
||||
return OxError(1);
|
||||
} else {
|
||||
m_header.size = size;
|
||||
m_header.size = static_cast<size_t>(size);
|
||||
auto data = reinterpret_cast<uint8_t*>(this) + end;
|
||||
ox_memset(data, 0, size - end);
|
||||
return OxError(0);
|
||||
@ -387,8 +388,8 @@ size_t NodeBuffer<size_t, Item>::available() const noexcept {
|
||||
}
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
size_t NodeBuffer<size_t, Item>::spaceNeeded(size_t size) noexcept {
|
||||
return sizeof(Item) + size;
|
||||
size_t NodeBuffer<size_t, Item>::spaceNeeded(std::size_t size) noexcept {
|
||||
return static_cast<size_t>(sizeof(Item) + size);
|
||||
}
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
@ -442,8 +443,8 @@ struct OX_PACKED Item {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void setSize(size_t size) {
|
||||
m_size = size;
|
||||
void setSize(std::size_t size) {
|
||||
m_size = static_cast<size_t>(size);
|
||||
}
|
||||
};
|
||||
|
||||
|
26
deps/ox/src/ox/fs/ptrarith/ptr.hpp
vendored
26
deps/ox/src/ox/fs/ptrarith/ptr.hpp
vendored
@ -29,7 +29,13 @@ class [[nodiscard]] Ptr {
|
||||
|
||||
constexpr Ptr(std::nullptr_t) noexcept;
|
||||
|
||||
constexpr Ptr(void *dataStart, size_t dataSize, size_t itemStart, size_t itemSize = sizeof(T), size_t itemTypeSize = sizeof(T), bool prevalidated = false) noexcept;
|
||||
constexpr Ptr(
|
||||
void *pDataStart,
|
||||
std::size_t pDataSize,
|
||||
std::size_t pItemStart,
|
||||
std::size_t pItemSize = sizeof(T),
|
||||
std::size_t pItemTypeSize = sizeof(T),
|
||||
bool pPrevalidated = false) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool valid() const noexcept;
|
||||
@ -86,17 +92,27 @@ constexpr Ptr<T, size_t, minOffset>::Ptr(std::nullptr_t) noexcept {
|
||||
}
|
||||
|
||||
template<typename T, typename size_t, size_t minOffset>
|
||||
constexpr Ptr<T, size_t, minOffset>::Ptr(void *dataStart, size_t dataSize, size_t itemStart, size_t itemSize, size_t itemTypeSize, bool prevalidated) noexcept {
|
||||
constexpr Ptr<T, size_t, minOffset>::Ptr(
|
||||
void *pDataStart,
|
||||
std::size_t pDataSize,
|
||||
std::size_t pItemStart,
|
||||
std::size_t pItemSize,
|
||||
std::size_t pItemTypeSize,
|
||||
bool pPrevalidated) noexcept {
|
||||
const auto dataSize = static_cast<size_t>(pDataSize);
|
||||
const auto itemStart = static_cast<size_t>(pItemStart);
|
||||
const auto itemSize = static_cast<size_t>(pItemSize);
|
||||
const auto itemTypeSize = static_cast<size_t>(pItemTypeSize);
|
||||
// do some sanity checks before assuming this is valid
|
||||
if (itemSize >= itemTypeSize &&
|
||||
dataStart &&
|
||||
pDataStart &&
|
||||
itemStart >= minOffset &&
|
||||
itemStart + itemSize <= dataSize) {
|
||||
m_dataStart = reinterpret_cast<uint8_t*>(dataStart);
|
||||
m_dataStart = reinterpret_cast<uint8_t*>(pDataStart);
|
||||
m_dataSize = dataSize;
|
||||
m_itemOffset = itemStart;
|
||||
m_itemSize = itemSize;
|
||||
m_validated = prevalidated;
|
||||
m_validated = pPrevalidated;
|
||||
}
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/mc/read.hpp
vendored
2
deps/ox/src/ox/mc/read.hpp
vendored
@ -565,7 +565,7 @@ template<auto HandlerMaker>
|
||||
[[nodiscard]]
|
||||
constexpr int MetalClawReaderTemplate<HandlerMaker>::whichFieldPresent(const char*, const ModelUnion &u) const noexcept {
|
||||
FieldBitmapReader<const uint8_t*> p(m_buff + m_buffIt, m_buffLen - m_buffIt);
|
||||
p.setFields(u.fieldCount());
|
||||
p.setFields(static_cast<int>(u.fieldCount()));
|
||||
for (auto i = 0u; i < u.fieldCount(); ++i) {
|
||||
if (p.get(i)) {
|
||||
return static_cast<int>(i);
|
||||
|
2
deps/ox/src/ox/oc/read.hpp
vendored
2
deps/ox/src/ox/oc/read.hpp
vendored
@ -205,7 +205,7 @@ Error OrganicClawReader::field(const char *key, BasicString<L> *val) noexcept {
|
||||
|
||||
template<std::size_t L>
|
||||
Error OrganicClawReader::field(const char *key, BString<L> *val) noexcept {
|
||||
return field(key, SerStr(val->data(), val->cap()));
|
||||
return field(key, SerStr(val->data(), static_cast<int>(val->cap())));
|
||||
}
|
||||
|
||||
// array handler
|
||||
|
Loading…
Reference in New Issue
Block a user