[ox] Fix remaining implicit conversion issues
This commit is contained in:
parent
acf04665bc
commit
3fdfee33a9
5
deps/ox/src/ox/clargs/CMakeLists.txt
vendored
5
deps/ox/src/ox/clargs/CMakeLists.txt
vendored
@ -12,6 +12,11 @@ set_property(
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxClArgs PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxClArgs PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
OxClArgs PUBLIC
|
||||
OxStd
|
||||
|
8
deps/ox/src/ox/clargs/clargs.cpp
vendored
8
deps/ox/src/ox/clargs/clargs.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -12,7 +12,7 @@
|
||||
namespace ox {
|
||||
|
||||
ClArgs::ClArgs(int argc, const char **args) noexcept {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
for (auto i = 0u; i < static_cast<unsigned>(argc); ++i) {
|
||||
String arg = args[i];
|
||||
if (arg[0] == '-') {
|
||||
while (arg[0] == '-' && arg.len()) {
|
||||
@ -20,7 +20,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
|
||||
}
|
||||
m_bools[arg] = true;
|
||||
// parse additional arguments
|
||||
if (i < argc && args[i + 1]) {
|
||||
if (i < static_cast<unsigned>(argc) && args[i + 1]) {
|
||||
String val = args[i + 1];
|
||||
if (val.len() && val[i] != '-') {
|
||||
if (val == "false") {
|
||||
@ -30,7 +30,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
|
||||
if (auto r = ox_atoi(val.c_str()); r.error == 0) {
|
||||
m_ints[arg] = r.value;
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
deps/ox/src/ox/clargs/clargs.hpp
vendored
6
deps/ox/src/ox/clargs/clargs.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -26,13 +26,15 @@ class ClArgs {
|
||||
bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
String getString(ox::CRStringView argName, const char *defaultArg) const noexcept;
|
||||
String getString(ox::CRStringView argName, const char *defaultValue) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
int getInt(ox::CRStringView arg, int defaultValue) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
Result<bool> getBool(ox::CRStringView arg) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
Result<String> getString(ox::CRStringView argName) const noexcept;
|
||||
|
||||
Result<int> getInt(ox::CRStringView arg) const noexcept;
|
||||
|
5
deps/ox/src/ox/claw/CMakeLists.txt
vendored
5
deps/ox/src/ox/claw/CMakeLists.txt
vendored
@ -6,6 +6,11 @@ add_library(
|
||||
)
|
||||
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxClaw PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxClaw PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
OxClaw PUBLIC
|
||||
OxMetalClaw
|
||||
|
8
deps/ox/src/ox/claw/read.cpp
vendored
8
deps/ox/src/ox/claw/read.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -17,7 +17,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
|
||||
if (!s1End) {
|
||||
return OxError(1, "Could not read Claw header");
|
||||
}
|
||||
const auto s1Size = s1End - buff;
|
||||
const auto s1Size = static_cast<std::size_t>(s1End - buff);
|
||||
const String fmt(buff, s1Size);
|
||||
buff += s1Size + 1;
|
||||
buffLen -= s1Size + 1;
|
||||
@ -26,7 +26,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
|
||||
if (!s2End) {
|
||||
return OxError(2, "Could not read Claw header");
|
||||
}
|
||||
const auto s2Size = s2End - buff;
|
||||
const auto s2Size = static_cast<std::size_t>(s2End - buff);
|
||||
const String typeName(buff, s2Size);
|
||||
buff += s2Size + 1;
|
||||
buffLen -= s2Size + 1;
|
||||
@ -35,7 +35,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
|
||||
if (!s3End) {
|
||||
return OxError(3, "Could not read Claw header");
|
||||
}
|
||||
const auto s3Size = s3End - buff;
|
||||
const auto s3Size = static_cast<std::size_t>(s3End - buff);
|
||||
const String versionStr(buff, s3Size);
|
||||
buff += s3Size + 1;
|
||||
buffLen -= s3Size + 1;
|
||||
|
4
deps/ox/src/ox/claw/test/tests.cpp
vendored
4
deps/ox/src/ox/claw/test/tests.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -198,7 +198,7 @@ int main(int argc, const char **args) {
|
||||
if (argc > 0) {
|
||||
auto testName = args[1];
|
||||
if (tests.find(testName) != tests.end()) {
|
||||
retval = tests[testName]();
|
||||
retval = static_cast<int>(tests[testName]());
|
||||
} else {
|
||||
retval = 1;
|
||||
}
|
||||
|
4
deps/ox/src/ox/claw/write.hpp
vendored
4
deps/ox/src/ox/claw/write.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -27,7 +27,7 @@ struct TypeInfoCatcher {
|
||||
int version = 0;
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, int = 0) noexcept {
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, std::size_t = 0) noexcept {
|
||||
this->name = name;
|
||||
this->version = v;
|
||||
}
|
||||
|
1
deps/ox/src/ox/event/CMakeLists.txt
vendored
1
deps/ox/src/ox/event/CMakeLists.txt
vendored
@ -5,6 +5,7 @@ add_library(
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxEvent PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxEvent PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
if(NOT OX_BARE_METAL)
|
||||
|
4
deps/ox/src/ox/fs/CMakeLists.txt
vendored
4
deps/ox/src/ox/fs/CMakeLists.txt
vendored
@ -11,6 +11,10 @@ add_library(
|
||||
filesystem/passthroughfs.cpp
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxFS PRIVATE -Wsign-conversion)
|
||||
endif()
|
||||
|
||||
if(NOT OX_BARE_METAL)
|
||||
if(NOT APPLE AND NOT MSVC)
|
||||
target_link_libraries(
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -227,14 +227,14 @@ Error FileStoreTemplate<size_t>::setSize(std::size_t size) {
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::incLinks(uint64_t id) {
|
||||
oxRequireM(item, find(static_cast<size_t>(id)).validate());
|
||||
item->links++;
|
||||
++item->links;
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::decLinks(uint64_t id) {
|
||||
oxRequireM(item, find(static_cast<size_t>(id)).validate());
|
||||
item->links--;
|
||||
--item->links;
|
||||
if (item->links == 0) {
|
||||
oxReturnError(remove(item));
|
||||
}
|
||||
@ -421,7 +421,7 @@ ptrarith::Ptr<uint8_t, std::size_t> FileStoreTemplate<size_t>::read(uint64_t id)
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::resize() {
|
||||
oxReturnError(compact());
|
||||
const auto newSize = size() - available();
|
||||
const auto newSize = static_cast<std::size_t>(size() - available());
|
||||
oxTracef("ox::fs::FileStoreTemplate::resize", "resize to: {}", newSize);
|
||||
oxReturnError(m_buffer->setSize(newSize));
|
||||
oxTracef("ox::fs::FileStoreTemplate::resize", "resized to: {}", m_buffer->size());
|
||||
|
4
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
4
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -69,7 +69,7 @@ struct OX_PACKED DirectoryEntry {
|
||||
|
||||
[[nodiscard]]
|
||||
InodeId_t size() const {
|
||||
return fullSize() - sizeof(*this);
|
||||
return fullSize() - static_cast<InodeId_t>(sizeof(*this));
|
||||
}
|
||||
|
||||
void setSize(std::size_t) {
|
||||
|
6
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
6
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -39,14 +39,14 @@ Error FileSystem::read(const FileAddress &addr, void *buffer, std::size_t size)
|
||||
|
||||
Result<Buffer> FileSystem::read(const FileAddress &addr) noexcept {
|
||||
oxRequire(s, stat(addr));
|
||||
Buffer buff(s.size);
|
||||
Buffer buff(static_cast<std::size_t>(s.size));
|
||||
oxReturnError(read(addr, buff.data(), buff.size()));
|
||||
return buff;
|
||||
}
|
||||
|
||||
Result<Buffer> FileSystem::read(CRStringView path) noexcept {
|
||||
oxRequire(s, statPath(path));
|
||||
Buffer buff(s.size);
|
||||
Buffer buff(static_cast<std::size_t>(s.size));
|
||||
oxReturnError(readFilePath(path, buff.data(), buff.size()));
|
||||
return buff;
|
||||
}
|
||||
|
18
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
18
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -240,7 +240,7 @@ FileSystemTemplate<FileStore, Directory>::FileSystemTemplate(FileStore fs) noexc
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
FileSystemTemplate<FileStore, Directory>::FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(char*)) noexcept:
|
||||
m_fs(buffer, bufferSize),
|
||||
m_fs(buffer, static_cast<std::size_t>(bufferSize)),
|
||||
m_freeBuffer(freeBuffer) {
|
||||
}
|
||||
|
||||
@ -253,8 +253,8 @@ FileSystemTemplate<FileStore, Directory>::~FileSystemTemplate() noexcept {
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buffSize) noexcept {
|
||||
oxReturnError(FileStore::format(buff, buffSize));
|
||||
FileStore fs(buff, buffSize);
|
||||
oxReturnError(FileStore::format(buff, static_cast<size_t>(buffSize)));
|
||||
FileStore fs(buff, static_cast<size_t>(buffSize));
|
||||
|
||||
constexpr auto rootDirInode = MaxValue<typename FileStore::InodeId_t> / 2;
|
||||
Directory rootDir(fs, rootDirInode);
|
||||
@ -298,7 +298,7 @@ Error FileSystemTemplate<FileStore, Directory>::readFilePath(CRStringView path,
|
||||
if (s.size > buffSize) {
|
||||
return OxError(1, "Buffer to small to load file");
|
||||
}
|
||||
return readFileInodeRange(s.inode, 0, s.size, buffer, &buffSize);
|
||||
return readFileInodeRange(s.inode, 0, static_cast<size_t>(s.size), buffer, &buffSize);
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
@ -315,7 +315,7 @@ Error FileSystemTemplate<FileStore, Directory>::readFileInode(uint64_t inode, vo
|
||||
if (s.size > buffSize) {
|
||||
return OxError(1, "Buffer to small to load file");
|
||||
}
|
||||
return readFileInodeRange(inode, 0, s.size, buffer, &buffSize);
|
||||
return readFileInodeRange(inode, 0, static_cast<size_t>(s.size), buffer, &buffSize);
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
@ -377,7 +377,7 @@ Error FileSystemTemplate<FileStore, Directory>::resize() noexcept {
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::resize(uint64_t size, void *buffer) noexcept {
|
||||
oxReturnError(m_fs.resize(size, buffer));
|
||||
oxReturnError(m_fs.resize(static_cast<size_t>(size), buffer));
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ Error FileSystemTemplate<FileStore, Directory>::writeFilePath(CRStringView path,
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept {
|
||||
return m_fs.write(inode, buffer, size, static_cast<uint8_t>(fileType));
|
||||
return m_fs.write(inode, buffer, static_cast<size_t>(size), static_cast<uint8_t>(fileType));
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
@ -418,7 +418,7 @@ Result<FileStat> FileSystemTemplate<FileStore, Directory>::statPath(CRStringView
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
uint64_t FileSystemTemplate<FileStore, Directory>::spaceNeeded(uint64_t size) const noexcept {
|
||||
return m_fs.spaceNeeded(size);
|
||||
return m_fs.spaceNeeded(static_cast<size_t>(size));
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
|
16
deps/ox/src/ox/fs/filesystem/passthroughfs.cpp
vendored
16
deps/ox/src/ox/fs/filesystem/passthroughfs.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -39,7 +39,7 @@ Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept {
|
||||
success = true;
|
||||
} else {
|
||||
success = std::filesystem::create_directories(p, ec);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: mkdir failed"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: mkdir failed"));
|
||||
}
|
||||
} else {
|
||||
std::error_code ec;
|
||||
@ -48,7 +48,7 @@ Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept {
|
||||
success = true;
|
||||
} else {
|
||||
success = std::filesystem::create_directory(p, ec);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: mkdir failed"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: mkdir failed"));
|
||||
}
|
||||
}
|
||||
return OxError(success ? 0 : 1);
|
||||
@ -67,7 +67,7 @@ Result<Vector<String>> PassThroughFS::ls(CRStringView dir) const noexcept {
|
||||
Vector<String> out;
|
||||
std::error_code ec;
|
||||
const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: ls failed"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: ls failed"));
|
||||
for (const auto &p : di) {
|
||||
const auto u8p = p.path().filename().u8string();
|
||||
out.emplace_back(reinterpret_cast<const char*>(u8p.c_str()));
|
||||
@ -102,7 +102,7 @@ Result<FileStat> PassThroughFS::statPath(CRStringView path) const noexcept {
|
||||
const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec);
|
||||
oxTracef("ox::fs::PassThroughFS::statInode", "{} {}", ec.message(), path);
|
||||
oxTracef("ox::fs::PassThroughFS::statInode::size", "{} {}", path, size);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: stat failed"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: stat failed"));
|
||||
return FileStat{0, 0, size, type};
|
||||
}
|
||||
|
||||
@ -113,14 +113,14 @@ uint64_t PassThroughFS::spaceNeeded(uint64_t size) const noexcept {
|
||||
Result<uint64_t> PassThroughFS::available() const noexcept {
|
||||
std::error_code ec;
|
||||
const auto s = std::filesystem::space(m_path, ec);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: could not get FS size"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: could not get FS size"));
|
||||
return s.available;
|
||||
}
|
||||
|
||||
Result<uint64_t> PassThroughFS::size() const noexcept {
|
||||
std::error_code ec;
|
||||
const auto s = std::filesystem::space(m_path, ec);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: could not get FS size"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: could not get FS size"));
|
||||
return s.capacity;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ bool PassThroughFS::valid() const noexcept {
|
||||
Error PassThroughFS::readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept {
|
||||
try {
|
||||
std::ifstream file((m_path / stripSlash(path)), std::ios::binary | std::ios::ate);
|
||||
const std::size_t size = file.tellg();
|
||||
const std::size_t size = static_cast<std::size_t>(file.tellg());
|
||||
file.seekg(0, std::ios::beg);
|
||||
if (size > buffSize) {
|
||||
oxTracef("ox::fs::PassThroughFS::read::error", "Read failed: Buffer too small: {}", path);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -92,7 +92,7 @@ template<typename F>
|
||||
Error PassThroughFS::ls(CRStringView dir, F cb) const noexcept {
|
||||
std::error_code ec;
|
||||
const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec);
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: ls failed"));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: ls failed"));
|
||||
for (auto &p : di) {
|
||||
oxReturnError(cb(p.path().filename().c_str(), 0));
|
||||
}
|
||||
|
26
deps/ox/src/ox/fs/filesystem/pathiterator.cpp
vendored
26
deps/ox/src/ox/fs/filesystem/pathiterator.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -29,8 +29,8 @@ PathIterator::PathIterator(CRStringView path): PathIterator(path.data(), path.by
|
||||
* @return 0 if no error
|
||||
*/
|
||||
Error PathIterator::dirPath(char *out, std::size_t outSize) {
|
||||
int idx = ox_lastIndexOf(m_path, '/', m_maxSize);
|
||||
std::size_t size = idx + 1;
|
||||
const auto idx = ox_lastIndexOf(m_path, '/', m_maxSize);
|
||||
const auto size = static_cast<std::size_t>(idx + 1);
|
||||
if (idx >= 0 && size < outSize) {
|
||||
ox_memcpy(out, m_path, size);
|
||||
out[size] = 0;
|
||||
@ -47,7 +47,7 @@ Error PathIterator::fileName(char *out, std::size_t outSize) {
|
||||
auto idx = ox_lastIndexOf(m_path, '/', m_maxSize);
|
||||
if (idx >= 0) {
|
||||
idx++; // pass up the preceding /
|
||||
std::size_t fileNameSize = ox_strlen(&m_path[idx]);
|
||||
std::size_t fileNameSize = static_cast<size_t>(ox_strlen(&m_path[idx]));
|
||||
if (fileNameSize < outSize) {
|
||||
ox_memcpy(out, &m_path[idx], fileNameSize);
|
||||
out[fileNameSize] = 0;
|
||||
@ -81,7 +81,7 @@ Error PathIterator::get(char *pathOut, std::size_t pathOutSize) {
|
||||
if (!substr) {
|
||||
substr = ox_strchr(&m_path[start], 0, m_maxSize - start);
|
||||
}
|
||||
std::size_t end = substr - m_path;
|
||||
const auto end = static_cast<size_t>(substr - m_path);
|
||||
size = end - start;
|
||||
// cannot fit the output in the output parameter
|
||||
if (size >= pathOutSize || size == 0) {
|
||||
@ -105,14 +105,14 @@ Error PathIterator::next(char *pathOut, std::size_t pathOutSize) {
|
||||
if (m_path[m_iterator] == '/') {
|
||||
m_iterator++;
|
||||
}
|
||||
std::size_t start = m_iterator;
|
||||
const auto start = m_iterator;
|
||||
// end is at the next /
|
||||
const char *substr = ox_strchr(&m_path[start], '/', m_maxSize - start);
|
||||
// correct end if it is invalid, which happens if there is no next /
|
||||
if (!substr) {
|
||||
substr = ox_strchr(&m_path[start], 0, m_maxSize - start);
|
||||
}
|
||||
std::size_t end = substr - m_path;
|
||||
const auto end = static_cast<size_t>(substr - m_path);
|
||||
size = end - start;
|
||||
// cannot fit the output in the output parameter
|
||||
if (size >= pathOutSize) {
|
||||
@ -152,14 +152,14 @@ Result<std::size_t> PathIterator::nextSize() const {
|
||||
if (m_path[it] == '/') {
|
||||
it++;
|
||||
}
|
||||
std::size_t start = it;
|
||||
const auto start = it;
|
||||
// end is at the next /
|
||||
const char *substr = ox_strchr(&m_path[start], '/', m_maxSize - start);
|
||||
// correct end if it is invalid, which happens if there is no next /
|
||||
if (!substr) {
|
||||
substr = ox_strchr(&m_path[start], 0, m_maxSize - start);
|
||||
}
|
||||
std::size_t end = substr - m_path;
|
||||
const auto end = static_cast<std::size_t>(substr - m_path);
|
||||
size = end - start;
|
||||
}
|
||||
it += size;
|
||||
@ -179,7 +179,7 @@ bool PathIterator::hasNext() const {
|
||||
if (!substr) {
|
||||
substr = ox_strchr(&m_path[start], 0, m_maxSize - start);
|
||||
}
|
||||
std::size_t end = substr - m_path;
|
||||
const auto end = static_cast<std::size_t>(substr - m_path);
|
||||
size = end - start;
|
||||
}
|
||||
return size > 0;
|
||||
@ -196,18 +196,18 @@ PathIterator PathIterator::next() const {
|
||||
if (m_path[iterator] == '/') {
|
||||
iterator++;
|
||||
}
|
||||
std::size_t start = iterator;
|
||||
const auto start = iterator;
|
||||
// end is at the next /
|
||||
const char *substr = ox_strchr(&m_path[start], '/', m_maxSize - start);
|
||||
// correct end if it is invalid, which happens if there is no next /
|
||||
if (!substr) {
|
||||
substr = ox_strchr(&m_path[start], 0, m_maxSize - start);
|
||||
}
|
||||
std::size_t end = substr - m_path;
|
||||
const auto end = static_cast<std::size_t>(substr - m_path);
|
||||
size = end - start;
|
||||
}
|
||||
iterator += size;
|
||||
return PathIterator(m_path, m_maxSize, iterator + 1);
|
||||
return {m_path, m_maxSize, iterator + 1};
|
||||
}
|
||||
|
||||
const char *PathIterator::fullPath() const {
|
||||
|
6
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
6
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -174,7 +174,7 @@ template<typename size_t, typename Item>
|
||||
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;
|
||||
oxTracef("ox::NodeBuffer::constructor", "{}", m_header.firstItem.get());
|
||||
}
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
@ -191,7 +191,7 @@ const typename NodeBuffer<size_t, Item>::Iterator NodeBuffer<size_t, Item>::iter
|
||||
|
||||
template<typename size_t, typename Item>
|
||||
typename NodeBuffer<size_t, Item>::Iterator NodeBuffer<size_t, Item>::iterator() noexcept {
|
||||
oxTrace("ox::ptrarith::NodeBuffer::iterator::size") << m_header.size;
|
||||
oxTracef("ox::ptrarith::NodeBuffer::iterator::size", "{}", m_header.size.get());
|
||||
return Iterator(this, firstItem());
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/fs/ptrarith/ptr.hpp
vendored
2
deps/ox/src/ox/fs/ptrarith/ptr.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
4
deps/ox/src/ox/fs/tool.cpp
vendored
4
deps/ox/src/ox/fs/tool.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -26,7 +26,7 @@ static ox::Result<Buff> loadFsBuff(const char *path) noexcept {
|
||||
const auto size = static_cast<std::size_t>(file.tellg());
|
||||
file.seekg(0, std::ios::beg);
|
||||
const auto buff = new char[size];
|
||||
file.read(buff, size);
|
||||
file.read(buff, static_cast<std::streamsize>(size));
|
||||
return Buff{buff, size};
|
||||
} catch (const std::ios_base::failure &e) {
|
||||
oxErrorf("Could not read OxFS file: {}", e.what());
|
||||
|
4
deps/ox/src/ox/logconn/CMakeLists.txt
vendored
4
deps/ox/src/ox/logconn/CMakeLists.txt
vendored
@ -12,6 +12,10 @@ set_property(
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxLogConn PRIVATE -Wsign-conversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
OxLogConn PUBLIC
|
||||
OxStd
|
||||
|
4
deps/ox/src/ox/logconn/logconn.cpp
vendored
4
deps/ox/src/ox/logconn/logconn.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -40,7 +40,7 @@ ox::Error LoggerConn::initConn(const char *appName) noexcept {
|
||||
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr.sin_port = htons(5590);
|
||||
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
oxReturnError(OxError(connect(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr))));
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(connect(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)))));
|
||||
return sendInit({.appName = appName});
|
||||
}
|
||||
|
||||
|
1
deps/ox/src/ox/mc/CMakeLists.txt
vendored
1
deps/ox/src/ox/mc/CMakeLists.txt
vendored
@ -7,6 +7,7 @@ add_library(
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxMetalClaw PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxMetalClaw PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
|
8
deps/ox/src/ox/mc/presenceindicator.hpp
vendored
8
deps/ox/src/ox/mc/presenceindicator.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -11,6 +11,8 @@
|
||||
#include <ox/std/error.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
#include "err.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
template<typename T>
|
||||
@ -83,9 +85,9 @@ constexpr Error FieldBitmap::set(std::size_t i, bool on) noexcept {
|
||||
if (on) {
|
||||
m_map[i / 8] |= 1 << (i % 8);
|
||||
} else {
|
||||
m_map[i / 8] &= ~(1 << (i % 8));
|
||||
m_map[i / 8] &= ~static_cast<uint8_t>(1 << (i % 8));
|
||||
}
|
||||
return OxError(0);
|
||||
return {};
|
||||
} else {
|
||||
return OxError(MC_PRESENCEMASKOUTBOUNDS);
|
||||
}
|
||||
|
46
deps/ox/src/ox/mc/read.hpp
vendored
46
deps/ox/src/ox/mc/read.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -31,8 +31,8 @@ class MetalClawReaderTemplate {
|
||||
|
||||
private:
|
||||
FieldBitmapReader<const uint8_t*> m_fieldPresence;
|
||||
int m_fields = 0;
|
||||
int m_field = 0;
|
||||
std::size_t m_fields = 0;
|
||||
std::size_t m_field = 0;
|
||||
int m_unionIdx = -1;
|
||||
std::size_t m_buffIt = 0;
|
||||
std::size_t m_buffLen = 0;
|
||||
@ -100,7 +100,7 @@ class MetalClawReaderTemplate {
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
|
||||
const Vector<String>& = {}, int fields = ModelFieldCount_v<T>) noexcept;
|
||||
const Vector<String>& = {}, std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
|
||||
/**
|
||||
* Returns a MetalClawReader to parse a child object.
|
||||
@ -200,7 +200,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, uint64
|
||||
|
||||
template<auto HandlerMaker>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, bool *val) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
auto valErr = m_fieldPresence.get(static_cast<std::size_t>(m_field));
|
||||
*val = valErr.value;
|
||||
oxReturnError(valErr.error);
|
||||
@ -212,7 +212,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, bool *
|
||||
// array handler
|
||||
template<auto HandlerMaker>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, auto *val, std::size_t valLen) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -225,7 +225,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, a
|
||||
if (valLen >= len) {
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<int>(len));
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len));
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
oxReturnError(handler.field("", &val[i]));
|
||||
}
|
||||
@ -242,7 +242,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, a
|
||||
template<auto HandlerMaker>
|
||||
template<typename T>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, HashMap<String, T> *val) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -254,12 +254,12 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, HashMa
|
||||
// read the list
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<int>(len));
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len));
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
const auto keyLen = handler.stringLength(nullptr);
|
||||
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
||||
auto wkeyPtr = wkey.get();
|
||||
oxReturnError(handler.fieldCString("", &wkeyPtr, static_cast<int>(keyLen + 1)));
|
||||
oxReturnError(handler.fieldCString("", &wkeyPtr, keyLen + 1));
|
||||
oxReturnError(handler.field("", &val->operator[](wkey.get())));
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ template<auto HandlerMaker>
|
||||
template<typename T>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, T *val) noexcept {
|
||||
if constexpr(isVector_v<T>) {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
// set size of val if the field is present, don't worry about it if not
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
oxRequire(len, arrayLength(name, false));
|
||||
@ -283,7 +283,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, T
|
||||
++m_field;
|
||||
return {};
|
||||
} else if constexpr(isArray_v<T>) {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
// set size of val if the field is present, don't worry about it if not
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
oxRequire(len, arrayLength(name, false));
|
||||
@ -296,7 +296,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, T
|
||||
++m_field;
|
||||
return {};
|
||||
} else {
|
||||
if ((m_unionIdx == -1 || m_unionIdx == m_field) && val) {
|
||||
if ((m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) && val) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
@ -311,7 +311,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char *name, T
|
||||
template<auto HandlerMaker>
|
||||
template<typename U, bool force>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, UnionView<U, force> val) noexcept {
|
||||
if ((m_unionIdx == -1 || m_unionIdx == m_field) && val.get()) {
|
||||
if ((m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) && val.get()) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
auto reader = child("", val.idx());
|
||||
auto handler = HandlerMaker(&reader);
|
||||
@ -325,7 +325,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, UnionV
|
||||
template<auto HandlerMaker>
|
||||
template<std::size_t SmallStringSize>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, BasicString<SmallStringSize> *val) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -419,7 +419,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::fieldCString(const char*,
|
||||
|
||||
template<auto HandlerMaker>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::fieldCString(const char*, char **val, std::size_t buffLen) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -457,7 +457,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::fieldCString(const char*,
|
||||
|
||||
template<auto HandlerMaker>
|
||||
constexpr Result<ArrayLength> MetalClawReaderTemplate<HandlerMaker>::arrayLength(const char*, bool pass) noexcept {
|
||||
if ((m_unionIdx == -1 || m_unionIdx == m_field)) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -477,7 +477,7 @@ constexpr Result<ArrayLength> MetalClawReaderTemplate<HandlerMaker>::arrayLength
|
||||
template<auto HandlerMaker>
|
||||
template<typename I>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::readInteger(I *val) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
std::size_t bytesRead = 0;
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -499,7 +499,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::readInteger(I *val) noexc
|
||||
template<auto HandlerMaker>
|
||||
template<typename T, typename CB>
|
||||
constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, CB cb) noexcept {
|
||||
if (m_unionIdx == -1 || m_unionIdx == m_field) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
if (m_buffIt >= m_buffLen) {
|
||||
@ -512,7 +512,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, CB cb)
|
||||
// read the list
|
||||
auto reader = child("");
|
||||
auto handler = HandlerMaker(&reader);
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<int>(len));
|
||||
handler.setTypeInfo("List", 0, {}, static_cast<std::size_t>(len));
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
T val;
|
||||
oxReturnError(handler.field("", &val));
|
||||
@ -526,7 +526,7 @@ constexpr Error MetalClawReaderTemplate<HandlerMaker>::field(const char*, CB cb)
|
||||
|
||||
template<auto HandlerMaker>
|
||||
constexpr StringLength MetalClawReaderTemplate<HandlerMaker>::stringLength(const char*) noexcept {
|
||||
if ((m_unionIdx == -1 || m_unionIdx == m_field)) {
|
||||
if (m_unionIdx == -1 || static_cast<std::size_t>(m_unionIdx) == m_field) {
|
||||
if (m_fieldPresence.get(static_cast<std::size_t>(m_field))) {
|
||||
// read the length
|
||||
std::size_t bytesRead = 0;
|
||||
@ -539,10 +539,10 @@ constexpr StringLength MetalClawReaderTemplate<HandlerMaker>::stringLength(const
|
||||
|
||||
template<auto HandlerMaker>
|
||||
template<typename T>
|
||||
constexpr void MetalClawReaderTemplate<HandlerMaker>::setTypeInfo(const char*, int, const Vector<String>&, int fields) noexcept {
|
||||
constexpr void MetalClawReaderTemplate<HandlerMaker>::setTypeInfo(const char*, int, const Vector<String>&, std::size_t fields) noexcept {
|
||||
m_fields = fields;
|
||||
m_buffIt = static_cast<std::size_t>((fields / 8 + 1) - (fields % 8 == 0));
|
||||
m_fieldPresence.setFields(fields);
|
||||
m_fieldPresence.setFields(static_cast<int>(fields));
|
||||
m_fieldPresence.setMaxLen(static_cast<int>(m_buffIt));
|
||||
}
|
||||
|
||||
|
12
deps/ox/src/ox/mc/write.hpp
vendored
12
deps/ox/src/ox/mc/write.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -104,7 +104,7 @@ class MetalClawWriter {
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
|
||||
const Vector<String>& = {}, int fields = ModelFieldCount_v<T>) noexcept;
|
||||
const Vector<String>& = {}, std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
|
||||
/**
|
||||
* stringLength is not implemented in MetalClawWriter
|
||||
@ -342,7 +342,7 @@ constexpr Error MetalClawWriter::field(const char*, T *val, std::size_t len) noe
|
||||
|
||||
MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt);
|
||||
ModelHandlerInterface handler{&writer};
|
||||
handler.setTypeInfo<T>("List", 0, {}, static_cast<int>(len));
|
||||
handler.setTypeInfo<T>("List", 0, {}, static_cast<std::size_t>(len));
|
||||
|
||||
// write the array
|
||||
for (std::size_t i = 0; i < len; i++) {
|
||||
@ -400,9 +400,9 @@ constexpr Error MetalClawWriter::field(const char *name, HashMap<String, T> *val
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr void MetalClawWriter::setTypeInfo(const char*, int, const Vector<String>&, int fields) noexcept {
|
||||
m_fields = fields;
|
||||
m_fieldPresence.setFields(fields);
|
||||
constexpr void MetalClawWriter::setTypeInfo(const char*, int, const Vector<String>&, std::size_t fields) noexcept {
|
||||
m_fields = static_cast<int>(fields);
|
||||
m_fieldPresence.setFields(static_cast<int>(fields));
|
||||
m_buffIt = static_cast<std::size_t>(m_fieldPresence.getMaxLen());
|
||||
ox_memset(m_buff, 0, m_buffIt);
|
||||
}
|
||||
|
5
deps/ox/src/ox/model/CMakeLists.txt
vendored
5
deps/ox/src/ox/model/CMakeLists.txt
vendored
@ -5,6 +5,11 @@ add_library(
|
||||
modelvalue.cpp
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxModel PRIVATE -Wconversion)
|
||||
target_compile_options(OxModel PRIVATE -Wsign-conversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
OxModel PUBLIC
|
||||
OxStd
|
||||
|
6
deps/ox/src/ox/model/descwrite.hpp
vendored
6
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -94,7 +94,7 @@ class TypeDescWriter {
|
||||
constexpr void setTypeInfo(CRStringView name = T::TypeName,
|
||||
int version = T::TypeVersion,
|
||||
const TypeParamPack &typeParams = {},
|
||||
int fields = ModelFieldCount_v<T>) noexcept;
|
||||
std::size_t fields = ModelFieldCount_v<T>) noexcept;
|
||||
|
||||
template<typename T>
|
||||
constexpr Error field(CRStringView name, const T *val, std::size_t valLen,
|
||||
@ -179,7 +179,7 @@ constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeS
|
||||
|
||||
template<typename T>
|
||||
constexpr void TypeDescWriter::setTypeInfo(CRStringView typeName, int typeVersion,
|
||||
const TypeParamPack &typeParams, int) noexcept {
|
||||
const TypeParamPack &typeParams, std::size_t) noexcept {
|
||||
PrimitiveType pt;
|
||||
if constexpr(is_union_v<T>) {
|
||||
pt = PrimitiveType::Union;
|
||||
|
4
deps/ox/src/ox/model/fieldcounter.hpp
vendored
4
deps/ox/src/ox/model/fieldcounter.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -24,7 +24,7 @@ class FieldCounter {
|
||||
int fields = 0;
|
||||
|
||||
template<typename U = std::nullptr_t>
|
||||
constexpr void setTypeInfo(CRStringView = "", int = 0, const Vector<String>& = {}, int = 0) {
|
||||
constexpr void setTypeInfo(CRStringView = "", int = 0, const Vector<String>& = {}, std::size_t = 0) {
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
|
9
deps/ox/src/ox/model/modelhandleradaptor.hpp
vendored
9
deps/ox/src/ox/model/modelhandleradaptor.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -24,8 +24,11 @@ class ModelHandlerInterface {
|
||||
}
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
|
||||
const Vector<String> &typeParams = {}, int fields = ModelFieldCount_v<T>) noexcept {
|
||||
constexpr void setTypeInfo(
|
||||
const char *name = T::TypeName,
|
||||
int version = T::TypeVersion,
|
||||
const Vector<String> &typeParams = {},
|
||||
std::size_t fields = ModelFieldCount_v<T>) noexcept {
|
||||
m_handler->template setTypeInfo<T>(name, version, typeParams, fields);
|
||||
}
|
||||
|
||||
|
6
deps/ox/src/ox/model/modelops.hpp
vendored
6
deps/ox/src/ox/model/modelops.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -272,10 +272,6 @@ class Equals {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, const Vector<String>& = {}, int = T::Fields) noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static constexpr auto opType() noexcept {
|
||||
return OpType::Read;
|
||||
|
6
deps/ox/src/ox/model/modelvalue.hpp
vendored
6
deps/ox/src/ox/model/modelvalue.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -769,7 +769,7 @@ constexpr std::size_t alignOf(const ModelValue &t) noexcept {
|
||||
}
|
||||
|
||||
constexpr Error model(auto *h, CommonPtrWith<ModelObject> auto *obj) noexcept {
|
||||
h->template setTypeInfo<ModelObject>(obj->typeName().c_str(), obj->typeVersion(), {}, static_cast<int>(obj->m_fieldsOrder.size()));
|
||||
h->template setTypeInfo<ModelObject>(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size());
|
||||
for (auto &f : obj->m_fieldsOrder) {
|
||||
oxReturnError(h->field(f->name.c_str(), &f->value));
|
||||
}
|
||||
@ -777,7 +777,7 @@ constexpr Error model(auto *h, CommonPtrWith<ModelObject> auto *obj) noexcept {
|
||||
}
|
||||
|
||||
constexpr Error model(auto *h, CommonPtrWith<ModelUnion> auto *obj) noexcept {
|
||||
h->template setTypeInfo<ModelUnion>(obj->typeName().c_str(), obj->typeVersion(), {}, static_cast<int>(obj->m_fieldsOrder.size()));
|
||||
h->template setTypeInfo<ModelUnion>(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size());
|
||||
for (auto &f : obj->m_fieldsOrder) {
|
||||
oxReturnError(h->field(f->name.c_str(), &f->value));
|
||||
}
|
||||
|
6
deps/ox/src/ox/model/typenamecatcher.hpp
vendored
6
deps/ox/src/ox/model/typenamecatcher.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -25,7 +25,7 @@ struct TypeNameCatcher {
|
||||
constexpr TypeNameCatcher() noexcept = default;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, int = 0) noexcept {
|
||||
constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, std::size_t = 0) noexcept {
|
||||
this->name = n;
|
||||
this->version = v;
|
||||
}
|
||||
@ -59,7 +59,7 @@ struct TypeInfoCatcher {
|
||||
constexpr TypeInfoCatcher() noexcept = default;
|
||||
|
||||
template<typename T = std::nullptr_t>
|
||||
constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, int = 0) noexcept {
|
||||
constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, std::size_t = 0) noexcept {
|
||||
this->name = n;
|
||||
this->version = v;
|
||||
}
|
||||
|
2
deps/ox/src/ox/model/types.hpp
vendored
2
deps/ox/src/ox/model/types.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/model/walk.hpp
vendored
2
deps/ox/src/ox/model/walk.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
1
deps/ox/src/ox/oc/CMakeLists.txt
vendored
1
deps/ox/src/ox/oc/CMakeLists.txt
vendored
@ -6,6 +6,7 @@ add_library(
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxOrganicClaw PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxOrganicClaw PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
|
4
deps/ox/src/ox/oc/read.hpp
vendored
4
deps/ox/src/ox/oc/read.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -107,7 +107,7 @@ class OrganicClawReader {
|
||||
}
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char*, int, const Vector<String>& = {}, int = {}) noexcept {
|
||||
constexpr void setTypeInfo(const char*, int, const Vector<String>& = {}, std::size_t = {}) noexcept {
|
||||
}
|
||||
|
||||
/**
|
||||
|
6
deps/ox/src/ox/oc/test/tests.cpp
vendored
6
deps/ox/src/ox/oc/test/tests.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -332,7 +332,7 @@ const std::map<std::string_view, ox::Error(*)()> tests = {
|
||||
}
|
||||
case ox::PrimitiveType::String: {
|
||||
ox::Vector<char> v(rdr->stringLength(fieldName) + 1);
|
||||
oxAssert(rdr->field(fieldName, ox::SerStr(v.data(), v.size())), "Walking model failed.");
|
||||
oxAssert(rdr->field(fieldName, ox::SerStr(v.data(), static_cast<int>(v.size()))), "Walking model failed.");
|
||||
oxOutf("{}:\tstring:\t{}\n", fieldName, v.data());
|
||||
break;
|
||||
}
|
||||
@ -362,5 +362,5 @@ int main(int argc, const char **args) {
|
||||
oxErrorf("Test {} not found", testName);
|
||||
return 1;
|
||||
}
|
||||
return test();
|
||||
return static_cast<int>(test());
|
||||
}
|
||||
|
6
deps/ox/src/ox/oc/write.hpp
vendored
6
deps/ox/src/ox/oc/write.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -146,7 +146,7 @@ class OrganicClawWriter {
|
||||
|
||||
template<std::size_t L>
|
||||
Error 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())));
|
||||
}
|
||||
|
||||
template<std::size_t L>
|
||||
@ -180,7 +180,7 @@ class OrganicClawWriter {
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {
|
||||
}
|
||||
|
||||
static constexpr auto opType() noexcept {
|
||||
|
5
deps/ox/src/ox/preloader/CMakeLists.txt
vendored
5
deps/ox/src/ox/preloader/CMakeLists.txt
vendored
@ -4,6 +4,11 @@ add_library(
|
||||
preloader.cpp
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxPreloader PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxPreloader PRIVATE -Wconversion)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
OxPreloader PUBLIC
|
||||
OxClaw
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -27,7 +27,7 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(CRStringView name, const UnionView<T, force> val) noexcept {
|
||||
|
29
deps/ox/src/ox/preloader/preloader.hpp
vendored
29
deps/ox/src/ox/preloader/preloader.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -78,8 +78,11 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
|
||||
std::size_t sz = 0) noexcept;
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(ox::CRStringView = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
constexpr void setTypeInfo(
|
||||
ox::CRStringView = T::TypeName,
|
||||
int = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename U, bool force>
|
||||
constexpr ox::Error field(CRStringView, const ox::UnionView<U, force> val) noexcept;
|
||||
@ -276,7 +279,7 @@ template<typename PlatSpec>
|
||||
constexpr ox::Error Preloader<PlatSpec>::offsetPtrs(std::size_t offset) noexcept {
|
||||
for (const auto &p : m_ptrs) {
|
||||
oxReturnError(m_writer.seekp(p.loc));
|
||||
const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(p.value + offset);
|
||||
const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(static_cast<typename PlatSpec::PtrType>(p.value + offset));
|
||||
oxReturnError(ox::serialize(&m_writer, val));
|
||||
}
|
||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
||||
@ -307,18 +310,22 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView name, const ox
|
||||
|
||||
template<typename PlatSpec>
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView name, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept {
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
||||
CRStringView name, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept {
|
||||
// serialize the Vector
|
||||
ox::VectorMemMap<PlatSpec> vecVal{
|
||||
.smallVecSize = SmallVectorSize * sizeOf<PlatSpec>(static_cast<T*>(nullptr)),
|
||||
.size = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
.cap = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
.size = PlatSpec::correctEndianness(
|
||||
static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
.cap = PlatSpec::correctEndianness(
|
||||
static_cast<typename PlatSpec::size_t>(val->size())),
|
||||
};
|
||||
return fieldVector(name, val, vecVal);
|
||||
}
|
||||
|
||||
template<typename PlatSpec>
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept {
|
||||
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
||||
CRStringView, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept {
|
||||
oxReturnError(pad(&vecVal));
|
||||
const auto vecValPt = m_writer.tellp();
|
||||
// serialize the Vector elements
|
||||
@ -331,7 +338,8 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(CRStringView, const auto *v
|
||||
oxReturnError(this->interface()->field(nullptr, &val->operator[](i)));
|
||||
}
|
||||
m_unionIdx.pop_back();
|
||||
vecVal.items = PlatSpec::correctEndianness(p + PlatSpec::RomStart);
|
||||
vecVal.items = PlatSpec::correctEndianness(
|
||||
static_cast<typename PlatSpec::size_t>(p + PlatSpec::RomStart));
|
||||
oxReturnError(m_writer.seekp(vecValPt));
|
||||
} else {
|
||||
vecVal.items = 0;
|
||||
@ -349,7 +357,8 @@ constexpr bool Preloader<PlatSpec>::unionCheckAndIt() noexcept {
|
||||
}
|
||||
|
||||
template<typename PlatSpec, typename T>
|
||||
constexpr ox::Error preload(Preloader<PlatSpec> *pl, ox::CommonPtrWith<T> auto *obj) noexcept {
|
||||
constexpr ox::Error preload(
|
||||
Preloader<PlatSpec> *pl, ox::CommonPtrWith<T> auto *obj) noexcept {
|
||||
oxReturnError(model(pl->interface(), obj));
|
||||
return pl->pad(obj);
|
||||
}
|
||||
|
4
deps/ox/src/ox/preloader/sizecatcher.hpp
vendored
4
deps/ox/src/ox/preloader/sizecatcher.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -33,7 +33,7 @@ class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
|
||||
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(const char*, UnionView<T, force>) noexcept;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -21,7 +21,7 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
|
||||
public:
|
||||
template<typename T>
|
||||
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
|
||||
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
|
||||
const Vector<String>& = {}, std::size_t = ModelFieldCount_v<T>) noexcept {}
|
||||
|
||||
template<typename T, bool force>
|
||||
constexpr ox::Error field(CRStringView, const UnionView<T, force> val) noexcept {
|
||||
|
1
deps/ox/src/ox/std/CMakeLists.txt
vendored
1
deps/ox/src/ox/std/CMakeLists.txt
vendored
@ -43,6 +43,7 @@ add_library(
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxStd PRIVATE -Wsign-conversion)
|
||||
target_compile_options(OxStd PRIVATE -Wconversion)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_compile_options(OxStd PUBLIC -export-dynamic)
|
||||
#target_link_options(OxStd PUBLIC -W1,-E)
|
||||
|
57
deps/ox/src/ox/std/byteswap.hpp
vendored
57
deps/ox/src/ox/std/byteswap.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -24,7 +24,7 @@ constexpr T byteSwap(typename enable_if<sizeof(T) == 1, T>::type i) noexcept {
|
||||
template<typename T>
|
||||
[[nodiscard]]
|
||||
constexpr T byteSwap(typename enable_if<sizeof(T) == 2, T>::type i) noexcept {
|
||||
return (i << 8) | (i >> 8);
|
||||
return static_cast<T>(i << 8) | static_cast<T>(i >> 8);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -102,73 +102,54 @@ class OX_PACKED ByteSwapInteger {
|
||||
constexpr ByteSwapInteger(T value) noexcept: m_value(conditionalByteSwap<T, byteSwap>(value)) {
|
||||
}
|
||||
|
||||
constexpr const ByteSwapInteger &operator=(const ByteSwapInteger &other) noexcept {
|
||||
constexpr ByteSwapInteger &operator=(const ByteSwapInteger &other) noexcept {
|
||||
m_value = other.m_value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator=(I value) noexcept {
|
||||
constexpr ByteSwapInteger &operator=(T value) noexcept {
|
||||
m_value = conditionalByteSwap<T, byteSwap>(value);
|
||||
return value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr operator T() const noexcept {
|
||||
return conditionalByteSwap<T, byteSwap>(m_value);
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator+=(I other) noexcept {
|
||||
auto newVal = *this + other;
|
||||
constexpr ByteSwapInteger operator+=(T other) noexcept {
|
||||
const auto newVal = static_cast<T>(*this + other);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator-=(I other) noexcept {
|
||||
auto newVal = *this - other;
|
||||
constexpr ByteSwapInteger operator-=(T other) noexcept {
|
||||
const auto newVal = static_cast<T>(*this - other);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator*=(I other) noexcept {
|
||||
auto newVal = *this * other;
|
||||
constexpr ByteSwapInteger operator*=(T other) noexcept {
|
||||
const auto newVal = static_cast<T>(*this * other);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator/=(I other) noexcept {
|
||||
auto newVal = *this / other;
|
||||
constexpr ByteSwapInteger operator/=(T other) noexcept {
|
||||
const auto newVal = static_cast<T>(*this / other);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Prefix increment
|
||||
constexpr T operator++() noexcept {
|
||||
constexpr ByteSwapInteger operator++() noexcept {
|
||||
return operator+=(1);
|
||||
}
|
||||
|
||||
// Postfix increment
|
||||
constexpr T operator++(int) noexcept {
|
||||
auto old = *this;
|
||||
++*this;
|
||||
return old;
|
||||
}
|
||||
|
||||
// Prefix decrement
|
||||
constexpr T operator--() noexcept {
|
||||
constexpr ByteSwapInteger operator--() noexcept {
|
||||
return operator-=(1);
|
||||
}
|
||||
|
||||
// Postfix decrement
|
||||
constexpr T operator--(int) noexcept {
|
||||
auto old = *this;
|
||||
--*this;
|
||||
return old;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator&=(I other) noexcept {
|
||||
auto newVal = *this & other;
|
||||
|
6
deps/ox/src/ox/std/error.hpp
vendored
6
deps/ox/src/ox/std/error.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -51,7 +51,7 @@ struct [[nodiscard]] Error {
|
||||
|
||||
explicit constexpr Error(const char *file, uint32_t line, ErrorCode errCode, const char *msg = nullptr) noexcept {
|
||||
this->file = file;
|
||||
this->line = line;
|
||||
this->line = static_cast<uint16_t>(line);
|
||||
this->msg = msg;
|
||||
this->errCode = errCode;
|
||||
}
|
||||
@ -96,7 +96,7 @@ struct Exception: public std::exception {
|
||||
|
||||
explicit inline Exception(const char *file, uint32_t line, ErrorCode errCode, const char *msg = "") noexcept {
|
||||
this->file = file;
|
||||
this->line = line;
|
||||
this->line = static_cast<uint16_t>(line);
|
||||
this->msg = msg;
|
||||
this->errCode = errCode;
|
||||
}
|
||||
|
9
deps/ox/src/ox/std/hashmap.hpp
vendored
9
deps/ox/src/ox/std/hashmap.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -148,7 +148,8 @@ template<typename K, typename T>
|
||||
constexpr T &HashMap<K, T>::operator[](const K &k) {
|
||||
auto &p = access(m_pairs, k);
|
||||
if (p == nullptr) {
|
||||
if (m_pairs.size() * 0.7 < m_keys.size()) {
|
||||
if (static_cast<double>(m_pairs.size()) * 0.7 <
|
||||
static_cast<double>(m_keys.size())) {
|
||||
expand();
|
||||
}
|
||||
p = new Pair;
|
||||
@ -247,7 +248,7 @@ constexpr uint64_t HashMap<K, T>::hash(auto k) noexcept {
|
||||
|
||||
template<typename K, typename T>
|
||||
constexpr typename HashMap<K, T>::Pair *const&HashMap<K, T>::access(const Vector<Pair*> &pairs, const K &k) const {
|
||||
auto h = hash(k) % pairs.size();
|
||||
auto h = static_cast<std::size_t>(hash(k) % pairs.size());
|
||||
while (true) {
|
||||
const auto &p = pairs[h];
|
||||
if (p == nullptr || ox_strcmp(p->key, k) == 0) {
|
||||
@ -260,7 +261,7 @@ constexpr typename HashMap<K, T>::Pair *const&HashMap<K, T>::access(const Vector
|
||||
|
||||
template<typename K, typename T>
|
||||
constexpr typename HashMap<K, T>::Pair *&HashMap<K, T>::access(Vector<Pair*> &pairs, const K &k) {
|
||||
auto h = hash(k) % pairs.size();
|
||||
auto h = static_cast<std::size_t>(hash(k) % pairs.size());
|
||||
while (true) {
|
||||
auto &p = pairs[h];
|
||||
bool matches = [&] {
|
||||
|
2
deps/ox/src/ox/std/stringview.hpp
vendored
2
deps/ox/src/ox/std/stringview.hpp
vendored
@ -357,7 +357,7 @@ constexpr ox::Result<int> ox_atoi(ox::CRStringView str) noexcept {
|
||||
int total = 0;
|
||||
int multiplier = 1;
|
||||
for (auto i = static_cast<int64_t>(str.len()) - 1; i != -1; --i) {
|
||||
auto s = static_cast<uint64_t>(i);
|
||||
auto s = static_cast<std::size_t>(i);
|
||||
if (str[s] >= '0' && str[s] <= '9') {
|
||||
total += (str[s] - '0') * multiplier;
|
||||
multiplier *= 10;
|
||||
|
9
deps/ox/src/ox/std/strops.hpp
vendored
9
deps/ox/src/ox/std/strops.hpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -129,15 +129,16 @@ template<typename Integer, typename T>
|
||||
constexpr T ox_itoa(Integer v, T str) noexcept {
|
||||
if (v) {
|
||||
ox::ResizedInt_t<Integer, 64> mod = 1000000000000000000;
|
||||
ox::ResizedInt_t<Integer, 64> val = v;
|
||||
constexpr auto base = 10;
|
||||
auto it = 0;
|
||||
if (v < 0) {
|
||||
if (val < 0) {
|
||||
str[it] = '-';
|
||||
it++;
|
||||
}
|
||||
while (mod) {
|
||||
auto digit = v / mod;
|
||||
v %= mod;
|
||||
auto digit = val / mod;
|
||||
val %= mod;
|
||||
mod /= base;
|
||||
if (it || digit) {
|
||||
ox::ResizedInt_t<Integer, 64> start = '0';
|
||||
|
2
deps/ox/src/ox/std/uuid.hpp
vendored
2
deps/ox/src/ox/std/uuid.hpp
vendored
@ -57,7 +57,7 @@ constexpr ox::Result<uint8_t> fromHex(ox::CRStringView v) noexcept {
|
||||
return OxError(2);
|
||||
}
|
||||
uint8_t out = 0;
|
||||
out += valMap[static_cast<unsigned char>(v[0])] * 16u;
|
||||
out += static_cast<uint8_t>(valMap[static_cast<unsigned char>(v[0])] * 16);
|
||||
out += valMap[static_cast<unsigned char>(v[1])];
|
||||
return out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user