From 22e6299e90e85cb2b5ee814ebf2324b1a74d7091 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 24 Apr 2024 23:10:33 -0500 Subject: [PATCH] Squashed 'deps/nostalgia/' changes from 84205879..0c0ccd1a 0c0ccd1a [nostalgia/core/studio] Cleanup scratchpad code 1b629da8 [ox/std] Make Vector::contains always noexcept 32e4702d [ox] Improve hasing and MaybeView 6b47133c [nostalgia] Cleanup StudioModules 0764720f [nostalgia,olympic] Update for Ox changes 78955376 [glutils] Update for Ox changes a00a0bd2 [ox] Rename BString to IString ed4f0e1f [nostalgia,olympic] Replace oxIgnoreError with std::ignore ea1feb72 [ox] Remove oxIgnoreError e9a6a096 [ox] Run liccor d7f30975 Merge commit 'c0baf7efca0e4c3a86a018ad2564d9df7b07c133' eeb2a5a1 [olympic/studio] Add new ImGui util functions 453f2750 [nostalgia/core/studio] Cleanup context types 189ba4c5 [olympic/studio] Make studio::run static 05773808 [olympic] Change TypeId building to use constexpr globals 272eabc7 [nostalgia/core/opengl] Unbind vertex arrays when done with them a0256669 [glutils] Remove trailing whitespace 6808adc8 [ox/std] Replace ox::ignore with std::ignore abc076d6 [ox/std] Cleanup 1b790a34 [ox/std] Fix Signed_c and Unsigned_c 92202716 [nostalgia/core] Update pack transforms to use ModelTypeId_v 7941a514 [ox/model] Add constexpr ModelTypeId_v 0c09c530 [ox/std] Fix sfmt constexpr problems 3ff91af8 [ox/std] Sort of fix custom assert 79b42e1d [ox/std] Fix some Vector constexpr problems 5eec9085 [ox/std] Add nodiscard to some string functions af7c8956 [ox/std] Add ox::ignore git-subtree-dir: deps/nostalgia git-subtree-split: 0c0ccd1a692169d99beb8c238b8b2c466e81a13d --- .clang-tidy | 1 + deps/glutils/include/glutils/glutils.hpp | 2 +- deps/glutils/src/glutils.cpp | 2 +- deps/ox/.liccor.yml | 2 +- deps/ox/CMakeLists.txt | 1 + deps/ox/deps/cityhash/CMakeLists.txt | 30 + deps/ox/deps/cityhash/include/cityhash/city.h | 656 ++++++++++++++++++ deps/ox/src/ox/clargs/clargs.cpp | 2 +- deps/ox/src/ox/clargs/clargs.hpp | 2 +- deps/ox/src/ox/claw/claw.hpp | 2 +- deps/ox/src/ox/claw/format.hpp | 2 +- deps/ox/src/ox/claw/read.cpp | 2 +- deps/ox/src/ox/claw/read.hpp | 2 +- deps/ox/src/ox/claw/readclaw.cpp | 2 +- deps/ox/src/ox/claw/test/tests.cpp | 6 +- deps/ox/src/ox/claw/write.cpp | 2 +- deps/ox/src/ox/claw/write.hpp | 6 +- deps/ox/src/ox/event/event.hpp | 2 +- deps/ox/src/ox/event/signal.cpp | 2 +- deps/ox/src/ox/event/signal.hpp | 4 +- deps/ox/src/ox/event/test/tests.cpp | 2 +- .../src/ox/fs/filestore/filestoretemplate.cpp | 2 +- .../src/ox/fs/filestore/filestoretemplate.hpp | 2 +- deps/ox/src/ox/fs/filesystem/directory.cpp | 2 +- deps/ox/src/ox/fs/filesystem/directory.hpp | 2 +- deps/ox/src/ox/fs/filesystem/filelocation.cpp | 2 +- deps/ox/src/ox/fs/filesystem/filelocation.hpp | 2 +- deps/ox/src/ox/fs/filesystem/filesystem.cpp | 2 +- deps/ox/src/ox/fs/filesystem/filesystem.hpp | 2 +- .../ox/src/ox/fs/filesystem/passthroughfs.cpp | 2 +- .../ox/src/ox/fs/filesystem/passthroughfs.hpp | 2 +- deps/ox/src/ox/fs/filesystem/pathiterator.cpp | 6 +- deps/ox/src/ox/fs/filesystem/pathiterator.hpp | 4 +- deps/ox/src/ox/fs/filesystem/types.hpp | 2 +- deps/ox/src/ox/fs/fs.hpp | 2 +- deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp | 2 +- deps/ox/src/ox/fs/ptrarith/ptr.hpp | 2 +- deps/ox/src/ox/fs/test/tests.cpp | 4 +- deps/ox/src/ox/fs/tool.cpp | 2 +- deps/ox/src/ox/logconn/circularbuff.hpp | 2 +- deps/ox/src/ox/logconn/def.hpp | 2 +- deps/ox/src/ox/logconn/logconn.cpp | 4 +- deps/ox/src/ox/logconn/logconn.hpp | 2 +- deps/ox/src/ox/mc/err.hpp | 2 +- deps/ox/src/ox/mc/intops.hpp | 2 +- deps/ox/src/ox/mc/mc.hpp | 2 +- deps/ox/src/ox/mc/presenceindicator.cpp | 2 +- deps/ox/src/ox/mc/presenceindicator.hpp | 2 +- deps/ox/src/ox/mc/read.cpp | 2 +- deps/ox/src/ox/mc/read.hpp | 6 +- deps/ox/src/ox/mc/test/tests.cpp | 34 +- deps/ox/src/ox/mc/types.hpp | 2 +- deps/ox/src/ox/mc/write.cpp | 2 +- deps/ox/src/ox/mc/write.hpp | 6 +- deps/ox/src/ox/model/def.hpp | 2 +- deps/ox/src/ox/model/descread.hpp | 2 +- deps/ox/src/ox/model/desctypes.cpp | 2 +- deps/ox/src/ox/model/desctypes.hpp | 2 +- deps/ox/src/ox/model/descwrite.cpp | 2 +- deps/ox/src/ox/model/descwrite.hpp | 8 +- deps/ox/src/ox/model/fieldcounter.hpp | 2 +- deps/ox/src/ox/model/metadata.hpp | 4 +- deps/ox/src/ox/model/model.hpp | 2 +- deps/ox/src/ox/model/modelhandleradaptor.hpp | 2 +- deps/ox/src/ox/model/modelops.hpp | 14 +- deps/ox/src/ox/model/modelvalue.cpp | 2 +- deps/ox/src/ox/model/modelvalue.hpp | 6 +- deps/ox/src/ox/model/optype.hpp | 2 +- deps/ox/src/ox/model/test/tests.cpp | 2 +- deps/ox/src/ox/model/typenamecatcher.hpp | 21 +- deps/ox/src/ox/model/types.hpp | 4 +- deps/ox/src/ox/model/typestore.hpp | 2 +- deps/ox/src/ox/model/walk.hpp | 4 +- deps/ox/src/ox/oc/oc.hpp | 2 +- deps/ox/src/ox/oc/read.cpp | 2 +- deps/ox/src/ox/oc/read.hpp | 6 +- deps/ox/src/ox/oc/test/tests.cpp | 4 +- deps/ox/src/ox/oc/write.cpp | 2 +- deps/ox/src/ox/oc/write.hpp | 4 +- deps/ox/src/ox/preloader/alignmentcatcher.hpp | 2 +- deps/ox/src/ox/preloader/platspecs.hpp | 2 +- deps/ox/src/ox/preloader/preloader.cpp | 2 +- deps/ox/src/ox/preloader/preloader.hpp | 2 +- deps/ox/src/ox/preloader/sizecatcher.hpp | 2 +- deps/ox/src/ox/preloader/unionsizecatcher.hpp | 2 +- deps/ox/src/ox/std/CMakeLists.txt | 4 +- deps/ox/src/ox/std/algorithm.hpp | 2 +- deps/ox/src/ox/std/anyptr.hpp | 7 + deps/ox/src/ox/std/array.hpp | 2 +- deps/ox/src/ox/std/assert.cpp | 2 +- deps/ox/src/ox/std/assert.hpp | 2 +- deps/ox/src/ox/std/basestringview.hpp | 2 +- deps/ox/src/ox/std/bit.cpp | 2 +- deps/ox/src/ox/std/bit.hpp | 2 +- deps/ox/src/ox/std/bounds.hpp | 2 +- deps/ox/src/ox/std/buffer.cpp | 2 +- deps/ox/src/ox/std/buffer.hpp | 2 +- deps/ox/src/ox/std/buildinfo.cpp | 2 +- deps/ox/src/ox/std/buildinfo.hpp | 2 +- deps/ox/src/ox/std/byteswap.cpp | 2 +- deps/ox/src/ox/std/byteswap.hpp | 2 +- deps/ox/src/ox/std/concepts.cpp | 2 +- deps/ox/src/ox/std/concepts.hpp | 2 +- deps/ox/src/ox/std/cstringview.hpp | 6 +- deps/ox/src/ox/std/cstrops.hpp | 2 +- deps/ox/src/ox/std/def.hpp | 2 +- deps/ox/src/ox/std/defer.hpp | 2 +- deps/ox/src/ox/std/defines.hpp | 2 +- deps/ox/src/ox/std/error.hpp | 6 +- deps/ox/src/ox/std/fmt.cpp | 2 +- deps/ox/src/ox/std/fmt.hpp | 13 +- deps/ox/src/ox/std/hardware.hpp | 2 +- deps/ox/src/ox/std/hash.hpp | 170 +++++ deps/ox/src/ox/std/hashmap.hpp | 44 +- deps/ox/src/ox/std/heapmgr.cpp | 2 +- deps/ox/src/ox/std/heapmgr.hpp | 2 +- deps/ox/src/ox/std/ignore.hpp | 24 + deps/ox/src/ox/std/initializerlist.hpp | 2 +- .../src/ox/std/{bstring.hpp => istring.hpp} | 107 +-- deps/ox/src/ox/std/iterator.hpp | 2 +- deps/ox/src/ox/std/math.cpp | 2 +- deps/ox/src/ox/std/math.hpp | 2 +- deps/ox/src/ox/std/maybeview.hpp | 4 +- deps/ox/src/ox/std/memops.cpp | 2 +- deps/ox/src/ox/std/memops.hpp | 2 +- deps/ox/src/ox/std/memory.hpp | 2 +- deps/ox/src/ox/std/new.hpp | 2 +- deps/ox/src/ox/std/optional.hpp | 2 +- deps/ox/src/ox/std/point.hpp | 2 +- deps/ox/src/ox/std/random.cpp | 2 +- deps/ox/src/ox/std/random.hpp | 2 +- deps/ox/src/ox/std/range.hpp | 2 +- deps/ox/src/ox/std/ranges.hpp | 2 +- deps/ox/src/ox/std/reader.cpp | 2 +- deps/ox/src/ox/std/reader.hpp | 2 +- deps/ox/src/ox/std/realstd.hpp | 4 +- deps/ox/src/ox/std/serialize.hpp | 2 +- deps/ox/src/ox/std/size.hpp | 2 +- deps/ox/src/ox/std/span.hpp | 2 +- deps/ox/src/ox/std/stacktrace.cpp | 2 +- deps/ox/src/ox/std/stacktrace.hpp | 2 +- deps/ox/src/ox/std/std.hpp | 5 +- deps/ox/src/ox/std/stddef.hpp | 2 +- deps/ox/src/ox/std/string.cpp | 2 +- deps/ox/src/ox/std/string.hpp | 17 +- deps/ox/src/ox/std/stringliteral.hpp | 7 +- deps/ox/src/ox/std/stringview.cpp | 2 +- deps/ox/src/ox/std/stringview.hpp | 11 +- deps/ox/src/ox/std/strongint.hpp | 2 +- deps/ox/src/ox/std/strops.cpp | 2 +- deps/ox/src/ox/std/strops.hpp | 6 +- deps/ox/src/ox/std/substitutes.cpp | 2 +- deps/ox/src/ox/std/test/tests.cpp | 4 +- deps/ox/src/ox/std/trace.cpp | 4 +- deps/ox/src/ox/std/trace.hpp | 10 +- deps/ox/src/ox/std/tracehook.cpp | 2 +- deps/ox/src/ox/std/typeinfo.hpp | 2 +- deps/ox/src/ox/std/types.hpp | 2 +- deps/ox/src/ox/std/typetraits.cpp | 2 +- deps/ox/src/ox/std/typetraits.hpp | 16 +- deps/ox/src/ox/std/units.hpp | 2 +- deps/ox/src/ox/std/utility.hpp | 33 +- deps/ox/src/ox/std/uuid.cpp | 2 +- deps/ox/src/ox/std/uuid.hpp | 12 +- deps/ox/src/ox/std/vec.cpp | 2 +- deps/ox/src/ox/std/vec.hpp | 2 +- deps/ox/src/ox/std/vector.hpp | 81 +-- deps/ox/src/ox/std/writer.hpp | 2 +- developer-handbook.md | 15 +- src/nostalgia/modules/core/src/gba/panic.cpp | 6 +- .../modules/core/src/keel/keelmodule.cpp | 23 +- src/nostalgia/modules/core/src/opengl/gfx.cpp | 4 + .../studio/paletteeditor/paletteeditor.cpp | 14 +- .../modules/core/src/studio/studiomodule.cpp | 5 +- .../commands/palettechangecommand.cpp | 2 +- .../tilesheeteditor/tilesheeteditor-imgui.cpp | 17 +- .../tilesheeteditor/tilesheeteditor-imgui.hpp | 2 +- .../tilesheeteditor/tilesheeteditorview.cpp | 1 + .../modules/scene/src/keel/keelmodule.cpp | 5 +- .../modules/scene/src/studio/studiomodule.cpp | 5 +- .../keel/include/keel/assetmanager.hpp | 6 +- src/olympic/keel/include/keel/typeconv.hpp | 2 +- src/olympic/keel/src/keel.cpp | 2 +- src/olympic/studio/applib/src/main.cpp | 2 +- src/olympic/studio/applib/src/newmenu.hpp | 2 +- src/olympic/studio/applib/src/newproject.hpp | 2 +- src/olympic/studio/applib/src/studioapp.cpp | 4 +- .../modlib/include/studio/imguiutil.hpp | 87 +++ .../studio/modlib/src/filedialog_nfd.cpp | 2 +- src/olympic/studio/modlib/src/task.cpp | 4 +- src/olympic/studio/modlib/src/undostack.cpp | 2 +- src/olympic/turbine/src/glfw/gfx.cpp | 2 +- 192 files changed, 1440 insertions(+), 456 deletions(-) create mode 100644 deps/ox/deps/cityhash/CMakeLists.txt create mode 100644 deps/ox/deps/cityhash/include/cityhash/city.h create mode 100644 deps/ox/src/ox/std/hash.hpp create mode 100644 deps/ox/src/ox/std/ignore.hpp rename deps/ox/src/ox/std/{bstring.hpp => istring.hpp} (61%) diff --git a/.clang-tidy b/.clang-tidy index 4d5dbae..eace73e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -57,6 +57,7 @@ misc-*, readability-duplicate-include, -misc-non-private-member-variables-in-classes, -misc-no-recursion, +-misc-include-cleaner, bugprone-*, clang-analyzer-*, modernize-*, diff --git a/deps/glutils/include/glutils/glutils.hpp b/deps/glutils/include/glutils/glutils.hpp index bbeac25..6713e55 100644 --- a/deps/glutils/include/glutils/glutils.hpp +++ b/deps/glutils/include/glutils/glutils.hpp @@ -210,7 +210,7 @@ struct BufferSet { }; void sendVbo(BufferSet const&bs) noexcept; - + void sendEbo(BufferSet const&bs) noexcept; void clearScreen() noexcept; diff --git a/deps/glutils/src/glutils.cpp b/deps/glutils/src/glutils.cpp index f1eaf0c..6f80d66 100644 --- a/deps/glutils/src/glutils.cpp +++ b/deps/glutils/src/glutils.cpp @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include "glutils/glutils.hpp" diff --git a/deps/ox/.liccor.yml b/deps/ox/.liccor.yml index c911b89..b68fc72 100644 --- a/deps/ox/.liccor.yml +++ b/deps/ox/.liccor.yml @@ -2,7 +2,7 @@ source: - src copyright_notice: |- - Copyright 2015 - 2022 gary@drinkingtea.net + Copyright 2015 - 2024 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 diff --git a/deps/ox/CMakeLists.txt b/deps/ox/CMakeLists.txt index 244a0bc..cb286b0 100644 --- a/deps/ox/CMakeLists.txt +++ b/deps/ox/CMakeLists.txt @@ -82,4 +82,5 @@ if(OX_USE_STDLIB) set(JSONCPP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/jsoncpp/include") add_subdirectory(deps/jsoncpp) endif() +add_subdirectory(deps/cityhash) add_subdirectory(src) diff --git a/deps/ox/deps/cityhash/CMakeLists.txt b/deps/ox/deps/cityhash/CMakeLists.txt new file mode 100644 index 0000000..0521c3e --- /dev/null +++ b/deps/ox/deps/cityhash/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.19) +set(CMAKE_POLICY_DEFAULT_CMP0110 NEW) # requires CMake 3.19 + +project(CityHash CXX) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +set(NOSTALGIA_BUILD_PLAYER OFF) +set(NOSTALGIA_BUILD_STUDIO_APP OFF) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +if(APPLE) + set(CMAKE_MACOSX_RPATH OFF) +else() + if(UNIX) + set(BUILD_SHARED_LIBS ON) + endif() + set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +endif() + +add_library(CityHash INTERFACE) +target_include_directories(CityHash INTERFACE include) diff --git a/deps/ox/deps/cityhash/include/cityhash/city.h b/deps/ox/deps/cityhash/include/cityhash/city.h new file mode 100644 index 0000000..d24101b --- /dev/null +++ b/deps/ox/deps/cityhash/include/cityhash/city.h @@ -0,0 +1,656 @@ +// Copyright (c) 2011 Google, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// CityHash, by Geoff Pike and Jyrki Alakuijala +// +// http://code.google.com/p/cityhash/ +// +// This file provides a few functions for hashing strings. All of them are +// high-quality functions in the sense that they pass standard tests such +// as Austin Appleby's SMHasher. They are also fast. +// +// For 64-bit x86 code, on short strings, we don't know of anything faster than +// CityHash64 that is of comparable quality. We believe our nearest competitor +// is Murmur3. For 64-bit x86 code, CityHash64 is an excellent choice for hash +// tables and most other hashing (excluding cryptography). +// +// For 64-bit x86 code, on long strings, the picture is more complicated. +// On many recent Intel CPUs, such as Nehalem, Westmere, Sandy Bridge, etc., +// CityHashCrc128 appears to be faster than all competitors of comparable +// quality. CityHash128 is also good but not quite as fast. We believe our +// nearest competitor is Bob Jenkins' Spooky. We don't have great data for +// other 64-bit CPUs, but for long strings we know that Spooky is slightly +// faster than CityHash on some relatively recent AMD x86-64 CPUs, for example. +// Note that CityHashCrc128 is declared in citycrc.h. +// +// For 32-bit x86 code, we don't know of anything faster than CityHash32 that +// is of comparable quality. We believe our nearest competitor is Murmur3A. +// (On 64-bit CPUs, it is typically faster to use the other CityHash variants.) +// +// Functions in the CityHash family are not suitable for cryptography. +// +// Please see CityHash's README file for more details on our performance +// measurements and so on. +// +// WARNING: This code has been only lightly tested on big-endian platforms! +// It is known to work well on little-endian platforms that have a small penalty +// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs. +// It should work on all 32-bit and 64-bit platforms that allow unaligned reads; +// bug reports are welcome. +// +// By the way, for some hash functions, given strings a and b, the hash +// of a+b is easily derived from the hashes of a and b. This property +// doesn't hold for any hash functions in this file. + +#ifndef CITY_HASH_H_ +#define CITY_HASH_H_ + +#if __has_include() + +#include + +#else + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef unsigned uint_t; +#if defined(__arm__) || defined(__ppc__) +typedef long long int64_t; +typedef unsigned long long uint64_t; +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; +#else +typedef long int64_t; +typedef unsigned long uint64_t; +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; +#endif + +#if defined(_LP64) || defined(__ppc64__) || defined(__aarch64__) +typedef long intptr_t; +typedef unsigned long uintptr_t; +#elif defined(_WIN64) +typedef int64_t intptr_t; +typedef uint64_t uintptr_t; +#elif defined(_LP32) || defined(__ppc__) || defined(_WIN32) || defined(__arm__) +typedef int32_t intptr_t; +typedef uint32_t uintptr_t; +#else +#error intptr_t, and uintptr_t undefined +#endif + +#endif + + +using size_t = decltype(alignof(int)); + + + +#if __has_include() +#include +#endif + + + +namespace cityhash::detail { +template +struct pair { + T1 first{}; + T2 second{}; + constexpr pair() noexcept = default; + constexpr pair(T1 a, T2 b) noexcept: first(std::move(a)), second(std::move(b)) {} +}; +} + +namespace cityhash { + +using uint128 = cityhash::detail::pair; + +namespace detail { + +template +constexpr void swap(T &a, T &b) noexcept { + auto temp = std::move(a); + a = std::move(b); + b = std::move(temp); +} + +template +[[nodiscard]] +constexpr T byteSwap(T i) noexcept { + if constexpr(sizeof(T) == 1) { + return i; + } else if constexpr(sizeof(T) == 2) { + return static_cast(i << 8) | static_cast(i >> 8); + } else if constexpr(sizeof(T) == 4) { + return ((i >> 24) & 0x000000ff) | + ((i >> 8) & 0x0000ff00) | + ((i << 8) & 0x00ff0000) | + ((i << 24) & 0xff000000); + } else if constexpr(sizeof(T) == 8) { + return ((i >> 56) & 0x00000000000000ff) | + ((i >> 40) & 0x000000000000ff00) | + ((i >> 24) & 0x0000000000ff0000) | + ((i >> 8) & 0x00000000ff000000) | + ((i << 8) & 0x000000ff00000000) | + ((i << 24) & 0x0000ff0000000000) | + ((i << 40) & 0x00ff000000000000) | + ((i << 56) & 0xff00000000000000); + } +} + + +[[nodiscard]] +constexpr uint64_t Uint128Low64(const uint128& x) noexcept { return x.first; } +[[nodiscard]] +constexpr uint64_t Uint128High64(const uint128& x) noexcept { return x.second; } + +// Hash 128 input bits down to 64 bits of output. +// This is intended to be a reasonably good hash function. +[[nodiscard]] +constexpr uint64_t Hash128to64(const uint128& x) noexcept { + // Murmur-inspired hashing. + const uint64_t kMul = 0x9ddfea08eb382d69ULL; + uint64_t a = (detail::Uint128Low64(x) ^ detail::Uint128High64(x)) * kMul; + a ^= (a >> 47); + uint64_t b = (detail::Uint128High64(x) ^ a) * kMul; + b ^= (b >> 47); + b *= kMul; + return b; +} + +[[nodiscard]] +constexpr uint64_t UNALIGNED_LOAD64(const char *p) noexcept { + uint64_t result{}; + result |= static_cast(p[0]); + result |= static_cast(p[1]) << 8; + result |= static_cast(p[2]) << 16; + result |= static_cast(p[3]) << 24; + result |= static_cast(p[4]) << 32; + result |= static_cast(p[5]) << 40; + result |= static_cast(p[6]) << 48; + result |= static_cast(p[7]) << 56; + //memcpy(&result, p, sizeof(result)); + return result; +} + +[[nodiscard]] +constexpr uint32_t UNALIGNED_LOAD32(const char *p) noexcept { + uint32_t result{}; + result |= static_cast(p[0]); + result |= static_cast(p[1]) << 8; + result |= static_cast(p[2]) << 16; + result |= static_cast(p[3]) << 24; + //memcpy(&result, p, sizeof(result)); + return result; +} + +#ifdef WORDS_BIGENDIAN +#define uint32_in_expected_order(x) (detail::byteSwap(x)) +#define uint64_in_expected_order(x) (detail::byteSwap(x)) +#else +#define uint32_in_expected_order(x) (x) +#define uint64_in_expected_order(x) (x) +#endif + +#if !defined(LIKELY) +#if HAVE_BUILTIN_EXPECT +#define LIKELY(x) (__builtin_expect(!!(x), 1)) +#else +#define LIKELY(x) (x) +#endif +#endif + +[[nodiscard]] +constexpr uint64_t Fetch64(const char *p) noexcept { + return uint64_in_expected_order(UNALIGNED_LOAD64(p)); +} + +[[nodiscard]] +constexpr uint32_t Fetch32(const char *p) noexcept { + return uint32_in_expected_order(UNALIGNED_LOAD32(p)); +} + +// Some primes between 2^63 and 2^64 for various uses. +constexpr uint64_t k0 = 0xc3a5c85c97cb3127ULL; +constexpr uint64_t k1 = 0xb492b66fbe98f273ULL; +constexpr uint64_t k2 = 0x9ae16a3b2f90404fULL; + +// Magic numbers for 32-bit hashing. Copied from Murmur3. +constexpr uint32_t c1 = 0xcc9e2d51; +constexpr uint32_t c2 = 0x1b873593; + +// A 32-bit to 32-bit integer hash copied from Murmur3. +[[nodiscard]] +constexpr uint32_t fmix(uint32_t h) noexcept { + h ^= h >> 16; + h *= 0x85ebca6b; + h ^= h >> 13; + h *= 0xc2b2ae35; + h ^= h >> 16; + return h; +} + +[[nodiscard]] +constexpr uint32_t Rotate32(uint32_t val, int shift) noexcept { + // Avoid shifting by 32: doing so yields an undefined result. + return shift == 0 ? val : ((val >> shift) | (val << (32 - shift))); +} + +#undef PERMUTE3 +#define PERMUTE3(a, b, c) do { detail::swap(a, b); detail::swap(a, c); } while (0) + +[[nodiscard]] +constexpr uint32_t Mur(uint32_t a, uint32_t h) noexcept { + // Helper from Murmur3 for combining two 32-bit values. + a *= detail::c1; + a = Rotate32(a, 17); + a *= detail::c2; + h ^= a; + h = Rotate32(h, 19); + return h * 5 + 0xe6546b64; +} + +[[nodiscard]] +constexpr uint32_t Hash32Len13to24(const char *s, size_t len) noexcept { + uint32_t a = Fetch32(s - 4 + (len >> 1)); + uint32_t b = Fetch32(s + 4); + uint32_t c = Fetch32(s + len - 8); + uint32_t d = Fetch32(s + (len >> 1)); + uint32_t e = Fetch32(s); + uint32_t f = Fetch32(s + len - 4); + uint32_t h = static_cast(len); + + return detail::fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h))))))); +} + +[[nodiscard]] +constexpr uint32_t Hash32Len0to4(const char *s, size_t len) noexcept { + uint32_t b = 0; + uint32_t c = 9; + for (size_t i = 0; i < len; i++) { + signed char v = static_cast(s[i]); + b = b * detail::c1 + static_cast(v); + c ^= b; + } + return detail::fmix(Mur(b, Mur(static_cast(len), c))); +} + +[[nodiscard]] +constexpr uint32_t Hash32Len5to12(const char *s, size_t len) noexcept { + uint32_t a = static_cast(len), b = a * 5, c = 9, d = b; + a += Fetch32(s); + b += Fetch32(s + len - 4); + c += Fetch32(s + ((len >> 1) & 4)); + return detail::fmix(Mur(c, Mur(b, Mur(a, d)))); +} + +// Bitwise right rotate. Normally this will compile to a single +// instruction, especially if the shift is a manifest constant. +[[nodiscard]] +constexpr uint64_t Rotate(uint64_t val, int shift) noexcept { + // Avoid shifting by 64: doing so yields an undefined result. + return shift == 0 ? val : ((val >> shift) | (val << (64 - shift))); +} + +[[nodiscard]] +constexpr uint64_t ShiftMix(uint64_t val) noexcept { + return val ^ (val >> 47); +} + +[[nodiscard]] +constexpr uint64_t HashLen16(uint64_t u, uint64_t v) noexcept { + return Hash128to64(uint128(u, v)); +} + +[[nodiscard]] +constexpr uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) noexcept { + // Murmur-inspired hashing. + uint64_t a = (u ^ v) * mul; + a ^= (a >> 47); + uint64_t b = (v ^ a) * mul; + b ^= (b >> 47); + b *= mul; + return b; +} + +[[nodiscard]] +constexpr uint64_t HashLen0to16(const char *s, size_t len) noexcept { + if (len >= 8) { + uint64_t mul = detail::k2 + len * 2; + uint64_t a = detail::Fetch64(s) + detail::k2; + uint64_t b = detail::Fetch64(s + len - 8); + uint64_t c = detail::Rotate(b, 37) * mul + a; + uint64_t d = (detail::Rotate(a, 25) + b) * mul; + return HashLen16(c, d, mul); + } + if (len >= 4) { + uint64_t mul = detail::k2 + len * 2; + uint64_t a = Fetch32(s); + return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul); + } + if (len > 0) { + uint8_t a = static_cast(s[0]); + uint8_t b = static_cast(s[len >> 1]); + uint8_t c = static_cast(s[len - 1]); + uint32_t y = static_cast(a) + (static_cast(b) << 8); + uint32_t z = static_cast(len) + (static_cast(c) << 2); + return ShiftMix(y * detail::k2 ^ z * detail::k0) * detail::k2; + } + return detail::k2; +} + +// This probably works well for 16-byte strings as well, but it may be overkill +// in that case. +[[nodiscard]] +constexpr uint64_t HashLen17to32(const char *s, size_t len) noexcept { + uint64_t mul = detail::k2 + len * 2; + uint64_t a = detail::Fetch64(s) * detail::k1; + uint64_t b = detail::Fetch64(s + 8); + uint64_t c = detail::Fetch64(s + len - 8) * mul; + uint64_t d = detail::Fetch64(s + len - 16) * detail::k2; + return HashLen16(detail::Rotate(a + b, 43) + detail::Rotate(c, 30) + d, + a + detail::Rotate(b + detail::k2, 18) + c, mul); +} + +// Return a 16-byte hash for 48 bytes. Quick and dirty. +// Callers do best to use "random-looking" values for a and b. +[[nodiscard]] +constexpr detail::pair WeakHashLen32WithSeeds( + uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) noexcept { + a += w; + b = detail::Rotate(b + a + z, 21); + uint64_t c = a; + a += x; + a += y; + b += detail::Rotate(a, 44); + return detail::pair(a + z, b + c); +} + +// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. +[[nodiscard]] +constexpr detail::pair WeakHashLen32WithSeeds( + const char* s, uint64_t a, uint64_t b) noexcept { + return WeakHashLen32WithSeeds(detail::Fetch64(s), + detail::Fetch64(s + 8), + detail::Fetch64(s + 16), + detail::Fetch64(s + 24), + a, + b); +} + +// Return an 8-byte hash for 33 to 64 bytes. +[[nodiscard]] +constexpr uint64_t HashLen33to64(const char *s, size_t len) noexcept { + uint64_t mul = detail::k2 + len * 2; + uint64_t a = detail::Fetch64(s) * detail::k2; + uint64_t b = detail::Fetch64(s + 8); + uint64_t c = detail::Fetch64(s + len - 24); + uint64_t d = detail::Fetch64(s + len - 32); + uint64_t e = detail::Fetch64(s + 16) * detail::k2; + uint64_t f = detail::Fetch64(s + 24) * 9; + uint64_t g = detail::Fetch64(s + len - 8); + uint64_t h = detail::Fetch64(s + len - 16) * mul; + uint64_t u = detail::Rotate(a + g, 43) + (detail::Rotate(b, 30) + c) * 9; + uint64_t v = ((a + g) ^ d) + f + 1; + uint64_t w = detail::byteSwap((u + v) * mul) + h; + uint64_t x = detail::Rotate(e + f, 42) + c; + uint64_t y = (detail::byteSwap((v + w) * mul) + g) * mul; + uint64_t z = e + f + c; + a = detail::byteSwap((x + z) * mul + y) + b; + b = ShiftMix((z + a) * mul + d + h) * mul; + return b + x; +} + +// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings +// of any length representable in signed long. Based on City and Murmur. +[[nodiscard]] +constexpr uint128 CityMurmur(const char *s, size_t len, uint128 seed) noexcept { + uint64_t a = detail::Uint128Low64(seed); + uint64_t b = detail::Uint128High64(seed); + uint64_t c = 0; + uint64_t d = 0; + if (len <= 16) { + a = ShiftMix(a * detail::k1) * detail::k1; + c = b * detail::k1 + HashLen0to16(s, len); + d = ShiftMix(a + (len >= 8 ? detail::Fetch64(s) : c)); + } else { + c = HashLen16(detail::Fetch64(s + len - 8) + detail::k1, a); + d = HashLen16(b + len, c + detail::Fetch64(s + len - 16)); + a += d; + // len > 16 here, so do...while is safe + do { + a ^= ShiftMix(detail::Fetch64(s) * detail::k1) * detail::k1; + a *= detail::k1; + b ^= a; + c ^= ShiftMix(detail::Fetch64(s + 8) * detail::k1) * detail::k1; + c *= detail::k1; + d ^= c; + s += 16; + len -= 16; + } while (len > 16); + } + a = HashLen16(a, c); + b = HashLen16(d, b); + return uint128(a ^ b, HashLen16(b, a)); +} + +} + + +[[nodiscard]] +constexpr uint32_t CityHash32(const char *s, size_t len) noexcept { + if (len <= 24) { + return len <= 12 ? + (len <= 4 ? detail::Hash32Len0to4(s, len) : detail::Hash32Len5to12(s, len)) : + detail::Hash32Len13to24(s, len); + } + + // len > 24 + uint32_t h = static_cast(len), g = detail::c1 * h, f = g; + uint32_t a0 = detail::Rotate32(detail::Fetch32(s + len - 4) * detail::c1, 17) * detail::c2; + uint32_t a1 = detail::Rotate32(detail::Fetch32(s + len - 8) * detail::c1, 17) * detail::c2; + uint32_t a2 = detail::Rotate32(detail::Fetch32(s + len - 16) * detail::c1, 17) * detail::c2; + uint32_t a3 = detail::Rotate32(detail::Fetch32(s + len - 12) * detail::c1, 17) * detail::c2; + uint32_t a4 = detail::Rotate32(detail::Fetch32(s + len - 20) * detail::c1, 17) * detail::c2; + h ^= a0; + h = detail::Rotate32(h, 19); + h = h * 5 + 0xe6546b64; + h ^= a2; + h = detail::Rotate32(h, 19); + h = h * 5 + 0xe6546b64; + g ^= a1; + g = detail::Rotate32(g, 19); + g = g * 5 + 0xe6546b64; + g ^= a3; + g = detail::Rotate32(g, 19); + g = g * 5 + 0xe6546b64; + f += a4; + f = detail::Rotate32(f, 19); + f = f * 5 + 0xe6546b64; + size_t iters = (len - 1) / 20; + do { + uint32_t a0 = detail::Rotate32(detail::Fetch32(s) * detail::c1, 17) * detail::c2; + uint32_t a1 = detail::Fetch32(s + 4); + uint32_t a2 = detail::Rotate32(detail::Fetch32(s + 8) * detail::c1, 17) * detail::c2; + uint32_t a3 = detail::Rotate32(detail::Fetch32(s + 12) * detail::c1, 17) * detail::c2; + uint32_t a4 = detail::Fetch32(s + 16); + h ^= a0; + h = detail::Rotate32(h, 18); + h = h * 5 + 0xe6546b64; + f += a1; + f = detail::Rotate32(f, 19); + f = f * detail::c1; + g += a2; + g = detail::Rotate32(g, 18); + g = g * 5 + 0xe6546b64; + h ^= a3 + a1; + h = detail::Rotate32(h, 19); + h = h * 5 + 0xe6546b64; + g ^= a4; + g = detail::byteSwap(g) * 5; + h += a4 * 5; + h = detail::byteSwap(h); + f += a0; + PERMUTE3(f, h, g); + s += 20; + } while (--iters != 0); + g = detail::Rotate32(g, 11) * detail::c1; + g = detail::Rotate32(g, 17) * detail::c1; + f = detail::Rotate32(f, 11) * detail::c1; + f = detail::Rotate32(f, 17) * detail::c1; + h = detail::Rotate32(h + g, 19); + h = h * 5 + 0xe6546b64; + h = detail::Rotate32(h, 17) * detail::c1; + h = detail::Rotate32(h + f, 19); + h = h * 5 + 0xe6546b64; + h = detail::Rotate32(h, 17) * detail::c1; + return h; +} + +[[nodiscard]] +constexpr uint64_t CityHash64(const char *s, size_t len) noexcept { + if (len <= 32) { + if (len <= 16) { + return detail::HashLen0to16(s, len); + } else { + return detail::HashLen17to32(s, len); + } + } else if (len <= 64) { + return detail::HashLen33to64(s, len); + } + + // For strings over 64 bytes we hash the end first, and then as we + // loop we keep 56 bytes of state: v, w, x, y, and z. + uint64_t x = detail::Fetch64(s + len - 40); + uint64_t y = detail::Fetch64(s + len - 16) + detail::Fetch64(s + len - 56); + uint64_t z = detail::HashLen16(detail::Fetch64(s + len - 48) + len, detail::Fetch64(s + len - 24)); + detail::pair v = detail::WeakHashLen32WithSeeds(s + len - 64, len, z); + detail::pair w = detail::WeakHashLen32WithSeeds(s + len - 32, y + detail::k1, x); + x = x * detail::k1 + detail::Fetch64(s); + + // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. + len = (len - 1) & ~static_cast(63); + do { + x = detail::Rotate(x + y + v.first + detail::Fetch64(s + 8), 37) * detail::k1; + y = detail::Rotate(y + v.second + detail::Fetch64(s + 48), 42) * detail::k1; + x ^= w.second; + y += v.first + detail::Fetch64(s + 40); + z = detail::Rotate(z + w.first, 33) * detail::k1; + v = detail::WeakHashLen32WithSeeds(s, v.second * detail::k1, x + w.first); + w = detail::WeakHashLen32WithSeeds(s + 32, z + w.second, y + detail::Fetch64(s + 16)); + detail::swap(z, x); + s += 64; + len -= 64; + } while (len != 0); + return detail::HashLen16(detail::HashLen16(v.first, w.first) + detail::ShiftMix(y) * detail::k1 + z, + detail::HashLen16(v.second, w.second) + x); +} + +[[nodiscard]] +constexpr uint64_t CityHash64WithSeeds(const char *s, size_t len, + uint64_t seed0, uint64_t seed1) noexcept { + return detail::HashLen16(CityHash64(s, len) - seed0, seed1); +} + +[[nodiscard]] +constexpr uint64_t CityHash64WithSeed(const char *s, size_t len, uint64_t seed) noexcept { + return CityHash64WithSeeds(s, len, detail::k2, seed); +} + +[[nodiscard]] +constexpr uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) noexcept { + if (len < 128) { + return detail::CityMurmur(s, len, seed); + } + + // We expect len >= 128 to be the common case. Keep 56 bytes of state: + // v, w, x, y, and z. + detail::pair v, w; + uint64_t x = detail::Uint128Low64(seed); + uint64_t y = detail::Uint128High64(seed); + uint64_t z = len * detail::k1; + v.first = detail::Rotate(y ^ detail::k1, 49) * detail::k1 + detail::Fetch64(s); + v.second = detail::Rotate(v.first, 42) * detail::k1 + detail::Fetch64(s + 8); + w.first = detail::Rotate(y + z, 35) * detail::k1 + x; + w.second = detail::Rotate(x + detail::Fetch64(s + 88), 53) * detail::k1; + + // This is the same inner loop as CityHash64(), manually unrolled. + do { + x = detail::Rotate(x + y + v.first + detail::Fetch64(s + 8), 37) * detail::k1; + y = detail::Rotate(y + v.second + detail::Fetch64(s + 48), 42) * detail::k1; + x ^= w.second; + y += v.first + detail::Fetch64(s + 40); + z = detail::Rotate(z + w.first, 33) * detail::k1; + v = detail::WeakHashLen32WithSeeds(s, v.second * detail::k1, x + w.first); + w = detail::WeakHashLen32WithSeeds(s + 32, z + w.second, y + detail::Fetch64(s + 16)); + detail::swap(z, x); + s += 64; + x = detail::Rotate(x + y + v.first + detail::Fetch64(s + 8), 37) * detail::k1; + y = detail::Rotate(y + v.second + detail::Fetch64(s + 48), 42) * detail::k1; + x ^= w.second; + y += v.first + detail::Fetch64(s + 40); + z = detail::Rotate(z + w.first, 33) * detail::k1; + v = detail::WeakHashLen32WithSeeds(s, v.second * detail::k1, x + w.first); + w = detail::WeakHashLen32WithSeeds(s + 32, z + w.second, y + detail::Fetch64(s + 16)); + detail::swap(z, x); + s += 64; + len -= 128; + } while (LIKELY(len >= 128)); + x += detail::Rotate(v.first + z, 49) * detail::k0; + y = y * detail::k0 + detail::Rotate(w.second, 37); + z = z * detail::k0 + detail::Rotate(w.first, 27); + w.first *= 9; + v.first *= detail::k0; + // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s. + for (size_t tail_done = 0; tail_done < len; ) { + tail_done += 32; + y = detail::Rotate(x + y, 42) * detail::k0 + v.second; + w.first += detail::Fetch64(s + len - tail_done + 16); + x = x * detail::k0 + w.first; + z += w.second + detail::Fetch64(s + len - tail_done); + w.second += v.first; + v = detail::WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second); + v.first *= detail::k0; + } + // At this point our 56 bytes of state should contain more than + // enough information for a strong 128-bit hash. We use two + // different 56-byte-to-8-byte hashes to get a 16-byte final result. + x = detail::HashLen16(x, v.first); + y = detail::HashLen16(y + z, w.first); + return uint128(detail::HashLen16(x + v.second, w.second) + y, + detail::HashLen16(x + w.second, y + v.second)); +} + +[[nodiscard]] +constexpr uint128 CityHash128(const char *s, size_t len) noexcept { + return len >= 16 ? + CityHash128WithSeed(s + 16, len - 16, + uint128(detail::Fetch64(s), detail::Fetch64(s + 8) + detail::k0)) : + CityHash128WithSeed(s, len, uint128(detail::k0, detail::k1)); +} + +} + +#endif // CITY_HASH_H_ diff --git a/deps/ox/src/ox/clargs/clargs.cpp b/deps/ox/src/ox/clargs/clargs.cpp index c6edb9c..b2bee89 100644 --- a/deps/ox/src/ox/clargs/clargs.cpp +++ b/deps/ox/src/ox/clargs/clargs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/clargs/clargs.hpp b/deps/ox/src/ox/clargs/clargs.hpp index c38125d..b0ab183 100644 --- a/deps/ox/src/ox/clargs/clargs.hpp +++ b/deps/ox/src/ox/clargs/clargs.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/claw.hpp b/deps/ox/src/ox/claw/claw.hpp index 7bed380..bb4f47c 100644 --- a/deps/ox/src/ox/claw/claw.hpp +++ b/deps/ox/src/ox/claw/claw.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/format.hpp b/deps/ox/src/ox/claw/format.hpp index 23dc345..7355073 100644 --- a/deps/ox/src/ox/claw/format.hpp +++ b/deps/ox/src/ox/claw/format.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/read.cpp b/deps/ox/src/ox/claw/read.cpp index c4e43c1..439ae51 100644 --- a/deps/ox/src/ox/claw/read.cpp +++ b/deps/ox/src/ox/claw/read.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/read.hpp b/deps/ox/src/ox/claw/read.hpp index 8737166..37d624e 100644 --- a/deps/ox/src/ox/claw/read.hpp +++ b/deps/ox/src/ox/claw/read.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/readclaw.cpp b/deps/ox/src/ox/claw/readclaw.cpp index 0186ccc..607dc5a 100644 --- a/deps/ox/src/ox/claw/readclaw.cpp +++ b/deps/ox/src/ox/claw/readclaw.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index bfcb833..17a801c 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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,7 +29,7 @@ struct TestStructNest { static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; - ox::BString<32> String = ""; + ox::IString<32> String = ""; }; struct TestStruct { @@ -47,7 +47,7 @@ struct TestStruct { int32_t Int8 = 0; int unionIdx = 1; TestUnion Union; - ox::BString<32> String = ""; + ox::IString<32> String = ""; uint32_t List[4] = {0, 0, 0, 0}; TestStructNest EmptyStruct; TestStructNest Struct; diff --git a/deps/ox/src/ox/claw/write.cpp b/deps/ox/src/ox/claw/write.cpp index 7f8c26b..ec8f7c5 100644 --- a/deps/ox/src/ox/claw/write.cpp +++ b/deps/ox/src/ox/claw/write.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index f2d45dc..ba0890e 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -61,14 +61,14 @@ struct type_version { template constexpr const char *getTypeName(const T *t) noexcept { TypeInfoCatcher tnc; - oxIgnoreError(model(&tnc, t)); + std::ignore = model(&tnc, t); return tnc.name; } template constexpr int getTypeVersion(const T *t) noexcept { TypeInfoCatcher tnc; - oxIgnoreError(model(&tnc, t)); + std::ignore = model(&tnc, t); return tnc.version; } diff --git a/deps/ox/src/ox/event/event.hpp b/deps/ox/src/ox/event/event.hpp index d69433d..abf3f3f 100644 --- a/deps/ox/src/ox/event/event.hpp +++ b/deps/ox/src/ox/event/event.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/event/signal.cpp b/deps/ox/src/ox/event/signal.cpp index 3dee2f4..e086cb7 100644 --- a/deps/ox/src/ox/event/signal.cpp +++ b/deps/ox/src/ox/event/signal.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/event/signal.hpp b/deps/ox/src/ox/event/signal.hpp index 8a543ac..dee2849 100644 --- a/deps/ox/src/ox/event/signal.hpp +++ b/deps/ox/src/ox/event/signal.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -391,7 +391,7 @@ Error Signal::disconnectObject(const void *receiver) const noexc template void Signal::emit(Args... args) const noexcept { for (auto &f : m_slots) { - oxIgnoreError(f->call(ox::forward(args)...)); + std::ignore = f->call(ox::forward(args)...); } } diff --git a/deps/ox/src/ox/event/test/tests.cpp b/deps/ox/src/ox/event/test/tests.cpp index bee9b49..1004587 100644 --- a/deps/ox/src/ox/event/test/tests.cpp +++ b/deps/ox/src/ox/event/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.cpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.cpp index 62522da..04274cd 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.cpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp index ef4706c..9241767 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/directory.cpp b/deps/ox/src/ox/fs/filesystem/directory.cpp index 415e1e4..f87f22a 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.cpp +++ b/deps/ox/src/ox/fs/filesystem/directory.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index ed67b75..4f9573e 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.cpp b/deps/ox/src/ox/fs/filesystem/filelocation.cpp index 15cd529..df5f8a1 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.cpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.hpp b/deps/ox/src/ox/fs/filesystem/filelocation.hpp index 436d6cf..4ce349f 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.hpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.cpp b/deps/ox/src/ox/fs/filesystem/filesystem.cpp index 9a8dd29..16c28cb 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.cpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index 1c8538e..5cef155 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp index e600e1b..57c0818 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp index 51e9208..22a8183 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp index 87885d6..1d330b0 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -132,14 +132,14 @@ Error PathIterator::next(char *pathOut, std::size_t pathOutSize) { /** * @return 0 if no error */ -Error PathIterator::get(BString *fileName) { +Error PathIterator::get(IString *fileName) { return get(fileName->data(), fileName->cap()); } /** * @return 0 if no error */ -Error PathIterator::next(BString *fileName) { +Error PathIterator::next(IString *fileName) { return next(fileName->data(), fileName->cap()); } diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.hpp b/deps/ox/src/ox/fs/filesystem/pathiterator.hpp index 1c0d5d0..127198a 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.hpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -13,7 +13,7 @@ namespace ox { constexpr std::size_t MaxFileNameLength = 255; -using FileName = BString; +using FileName = IString; class PathIterator { private: diff --git a/deps/ox/src/ox/fs/filesystem/types.hpp b/deps/ox/src/ox/fs/filesystem/types.hpp index 497cc4c..84ab161 100644 --- a/deps/ox/src/ox/fs/filesystem/types.hpp +++ b/deps/ox/src/ox/fs/filesystem/types.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/fs.hpp b/deps/ox/src/ox/fs/fs.hpp index df27f7e..6773dbc 100644 --- a/deps/ox/src/ox/fs/fs.hpp +++ b/deps/ox/src/ox/fs/fs.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp index e5ba4dd..b7d2f2d 100644 --- a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp +++ b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/ptrarith/ptr.hpp b/deps/ox/src/ox/fs/ptrarith/ptr.hpp index c09bab5..31b0085 100644 --- a/deps/ox/src/ox/fs/ptrarith/ptr.hpp +++ b/deps/ox/src/ox/fs/ptrarith/ptr.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index 154b0e0..b9bdc2d 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -34,7 +34,7 @@ const std::map> tests = using BuffPtr_t = uint32_t; ox::Vector buff(5 * ox::units::MB); auto buffer = new (buff.data()) ox::ptrarith::NodeBuffer>(buff.size()); - using String = ox::BString<6>; + using String = ox::IString<6>; auto a1 = buffer->malloc(sizeof(String)).value; auto a2 = buffer->malloc(sizeof(String)).value; oxAssert(a1.valid(), "Allocation 1 failed."); diff --git a/deps/ox/src/ox/fs/tool.cpp b/deps/ox/src/ox/fs/tool.cpp index 34fa0c5..3d52f34 100644 --- a/deps/ox/src/ox/fs/tool.cpp +++ b/deps/ox/src/ox/fs/tool.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/logconn/circularbuff.hpp b/deps/ox/src/ox/logconn/circularbuff.hpp index 32c0a3e..96e5fb8 100644 --- a/deps/ox/src/ox/logconn/circularbuff.hpp +++ b/deps/ox/src/ox/logconn/circularbuff.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/logconn/def.hpp b/deps/ox/src/ox/logconn/def.hpp index 6fab40b..2e8627c 100644 --- a/deps/ox/src/ox/logconn/def.hpp +++ b/deps/ox/src/ox/logconn/def.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/logconn/logconn.cpp b/deps/ox/src/ox/logconn/logconn.cpp index 9577cc4..b5c5912 100644 --- a/deps/ox/src/ox/logconn/logconn.cpp +++ b/deps/ox/src/ox/logconn/logconn.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -98,7 +98,7 @@ void LoggerConn::msgSend() noexcept { break; } //std::printf("LoggerConn: sending %lu bytes\n", read); - oxIgnoreError(send(tmp.data(), read)); + std::ignore = send(tmp.data(), read); } } } diff --git a/deps/ox/src/ox/logconn/logconn.hpp b/deps/ox/src/ox/logconn/logconn.hpp index 152005c..2655de5 100644 --- a/deps/ox/src/ox/logconn/logconn.hpp +++ b/deps/ox/src/ox/logconn/logconn.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/err.hpp b/deps/ox/src/ox/mc/err.hpp index 7f99b32..a27be39 100644 --- a/deps/ox/src/ox/mc/err.hpp +++ b/deps/ox/src/ox/mc/err.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/intops.hpp b/deps/ox/src/ox/mc/intops.hpp index 7f369ef..2376cdd 100644 --- a/deps/ox/src/ox/mc/intops.hpp +++ b/deps/ox/src/ox/mc/intops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/mc.hpp b/deps/ox/src/ox/mc/mc.hpp index 380f2e7..234ec94 100644 --- a/deps/ox/src/ox/mc/mc.hpp +++ b/deps/ox/src/ox/mc/mc.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/presenceindicator.cpp b/deps/ox/src/ox/mc/presenceindicator.cpp index 09cb2d6..a7ef0fd 100644 --- a/deps/ox/src/ox/mc/presenceindicator.cpp +++ b/deps/ox/src/ox/mc/presenceindicator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/presenceindicator.hpp b/deps/ox/src/ox/mc/presenceindicator.hpp index d946ad8..8a5b312 100644 --- a/deps/ox/src/ox/mc/presenceindicator.hpp +++ b/deps/ox/src/ox/mc/presenceindicator.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/read.cpp b/deps/ox/src/ox/mc/read.cpp index d52b375..8882978 100644 --- a/deps/ox/src/ox/mc/read.cpp +++ b/deps/ox/src/ox/mc/read.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/read.hpp b/deps/ox/src/ox/mc/read.hpp index 01e81b4..5133f11 100644 --- a/deps/ox/src/ox/mc/read.hpp +++ b/deps/ox/src/ox/mc/read.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -77,7 +77,7 @@ class MetalClawReaderTemplate: public ModelHandlerBase *val) noexcept; template - constexpr Error field(const char*, BString *val) noexcept; + constexpr Error field(const char*, IString *val) noexcept; constexpr Error fieldCString(const char*, char *val, std::size_t buffLen) noexcept; @@ -336,7 +336,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, BasicString< template template -constexpr Error MetalClawReaderTemplate::field(const char *name, BString *val) noexcept { +constexpr Error MetalClawReaderTemplate::field(const char *name, IString *val) noexcept { return fieldCString(name, val->data(), val->cap()); } diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index 8100366..24b66dc 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 TestStructNest { static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; - ox::BString<32> BString = ""; + ox::IString<32> IString = ""; }; struct TestStruct { @@ -46,7 +46,7 @@ struct TestStruct { int unionIdx = 1; TestUnion Union; ox::String String; - ox::BString<32> BString = ""; + ox::IString<32> IString = ""; uint32_t List[4] = {0, 0, 0, 0}; ox::Vector Vector = {1, 2, 3, 4, 5}; ox::Vector Vector2 = {1, 2, 3, 4, 5}; @@ -72,7 +72,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexcep oxModelBegin(TestStructNest) oxModelField(Bool) oxModelField(Int) - oxModelField(BString) + oxModelField(IString) oxModelEnd() template @@ -95,7 +95,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexce oxReturnError(io->field("Union", ox::UnionView{&obj->Union, obj->unionIdx})); } oxReturnError(io->field("String", &obj->String)); - oxReturnError(io->field("BString", &obj->BString)); + oxReturnError(io->field("IString", &obj->IString)); oxReturnError(io->field("List", obj->List, 4)); oxReturnError(io->field("Vector", &obj->Vector)); oxReturnError(io->field("Vector2", &obj->Vector2)); @@ -127,7 +127,7 @@ std::map tests = { TestStruct testIn, testOut; testIn.Bool = true; testIn.Int = 42; - testIn.BString = "Test String 1"; + testIn.IString = "Test String 1"; testIn.String = "Test String 2"; testIn.Vector = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, }; testIn.Vector2 = {}; @@ -137,7 +137,7 @@ std::map tests = { testIn.List[3] = 4; testIn.Struct.Bool = true; testIn.Struct.Int = 300; - testIn.Struct.BString = "Test String 3"; + testIn.Struct.IString = "Test String 3"; testIn.unionIdx = 1; testIn.Union.Int = 93; // run tests @@ -157,7 +157,7 @@ std::map tests = { oxAssert(testIn.Int8 == testOut.Int8, "Int8 value mismatch"); oxAssert(testIn.Union.Int == testOut.Union.Int, "Union.Int value mismatch"); oxAssert(testIn.String == testOut.String, "String value mismatch"); - oxAssert(testIn.BString == testOut.BString, "BString value mismatch"); + oxAssert(testIn.IString == testOut.IString, "IString value mismatch"); oxAssert(testIn.List[0] == testOut.List[0], "List[0] value mismatch"); oxAssert(testIn.List[1] == testOut.List[1], "List[1] value mismatch"); oxAssert(testIn.List[2] == testOut.List[2], "List[2] value mismatch"); @@ -171,9 +171,9 @@ std::map tests = { oxAssert(testIn.Map["aoeu"] == testOut.Map["aoeu"], "Map[\"aoeu\"] value mismatch"); oxAssert(testIn.EmptyStruct.Bool == testOut.EmptyStruct.Bool, "EmptyStruct.Bool value mismatch"); oxAssert(testIn.EmptyStruct.Int == testOut.EmptyStruct.Int, "EmptyStruct.Int value mismatch"); - oxAssert(testIn.EmptyStruct.BString == testOut.EmptyStruct.BString, "EmptyStruct.BString value mismatch"); + oxAssert(testIn.EmptyStruct.IString == testOut.EmptyStruct.IString, "EmptyStruct.IString value mismatch"); oxAssert(testIn.Struct.Int == testOut.Struct.Int, "Struct.Int value mismatch"); - oxAssert(testIn.Struct.BString == testOut.Struct.BString, "Struct.BString 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); } @@ -303,14 +303,14 @@ std::map tests = { TestStruct testIn; testIn.Bool = true; testIn.Int = 42; - testIn.BString = "Test String 1"; + testIn.IString = "Test String 1"; testIn.List[0] = 1; testIn.List[1] = 2; testIn.List[2] = 3; testIn.List[3] = 4; testIn.Struct.Bool = true; testIn.Struct.Int = 300; - testIn.Struct.BString = "Test String 2"; + testIn.Struct.IString = "Test String 2"; testIn.unionIdx = 1; testIn.Union.Int = 93; oxAssert(ox::writeMC(dataBuff.data(), dataBuff.size(), testIn), "Data generation failed"); @@ -322,7 +322,7 @@ std::map tests = { oxAssert(ox::readMC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed"); oxAssert(testOut.at("Int").unwrap()->get() == testIn.Int, "testOut.Int failed"); oxAssert(testOut.at("Bool").unwrap()->get() == testIn.Bool, "testOut.Bool failed"); - oxAssert(testOut.at("BString").unwrap()->get() == testIn.BString.c_str(), "testOut.String failed"); + oxAssert(testOut.at("IString").unwrap()->get() == testIn.IString.c_str(), "testOut.String failed"); oxAssert(testOut.at("String").unwrap()->get() == testIn.String, "testOut.String failed"); auto &testOutStruct = testOut.at("Struct").unwrap()->get(); auto &testOutUnion = testOut.at("Union").unwrap()->get(); @@ -333,14 +333,14 @@ std::map tests = { oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed"); oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed"); oxAssert(testOutStruct.at("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool failed"); - oxAssert(testOutStruct.at("BString").unwrap()->get() == testIn.Struct.BString.c_str(), "testOut.Struct.BString failed"); + oxAssert(testOutStruct.at("IString").unwrap()->get() == testIn.Struct.IString.c_str(), "testOut.Struct.IString failed"); oxAssert(testOut.at("unionIdx").unwrap()->get() == testIn.unionIdx, "testOut.unionIdx failed"); oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong"); oxAssert(testOutUnion.at("Int").unwrap()->get() == testIn.Union.Int, "testOut.Union.Int failed"); oxAssert(testOutList[0].get() == testIn.List[0], "testOut.List[0] failed"); oxAssert(testOutList[1].get() == testIn.List[1], "testOut.Struct.List[1] failed"); oxAssert(testOutStructCopy.at("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed"); - oxAssert(testOutStructCopy.at("BString").unwrap()->get() == testIn.Struct.BString.c_str(), "testOut.Struct.BString (copy) failed"); + 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); @@ -357,14 +357,14 @@ std::map tests = { TestStruct testIn, testOut; testIn.Bool = true; testIn.Int = 42; - testIn.BString = "Test String 1"; + testIn.IString = "Test String 1"; testIn.List[0] = 1; testIn.List[1] = 2; testIn.List[2] = 3; testIn.List[3] = 4; testIn.Struct.Bool = false; testIn.Struct.Int = 300; - testIn.Struct.BString = "Test String 2"; + testIn.Struct.IString = "Test String 2"; oxAssert(ox::writeMC(dataBuff, dataBuffLen, testIn), "Data generation failed"); ox::TypeStore typeStore; const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn); diff --git a/deps/ox/src/ox/mc/types.hpp b/deps/ox/src/ox/mc/types.hpp index 0e69130..1413e51 100644 --- a/deps/ox/src/ox/mc/types.hpp +++ b/deps/ox/src/ox/mc/types.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/write.cpp b/deps/ox/src/ox/mc/write.cpp index 973f2ae..70d9bcd 100644 --- a/deps/ox/src/ox/mc/write.cpp +++ b/deps/ox/src/ox/mc/write.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index b3453b6..fb1ed70 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -66,7 +66,7 @@ class MetalClawWriter { constexpr Error field(const char*, const BasicString *val) noexcept; template - constexpr Error field(const char*, const BString *val) noexcept; + constexpr Error field(const char*, const IString *val) noexcept; constexpr Error fieldCString(const char *name, const char *const*val, std::size_t buffLen) noexcept; @@ -206,7 +206,7 @@ constexpr Error MetalClawWriter::field(const char*, const BasicString template -constexpr Error MetalClawWriter::field(const char *name, const BString *val) noexcept { +constexpr Error MetalClawWriter::field(const char *name, const IString *val) noexcept { return fieldCString(name, val->data(), val->cap()); } diff --git a/deps/ox/src/ox/model/def.hpp b/deps/ox/src/ox/model/def.hpp index 50f8c95..7e131e0 100644 --- a/deps/ox/src/ox/model/def.hpp +++ b/deps/ox/src/ox/model/def.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/descread.hpp b/deps/ox/src/ox/model/descread.hpp index 2010f71..05b8fc1 100644 --- a/deps/ox/src/ox/model/descread.hpp +++ b/deps/ox/src/ox/model/descread.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/desctypes.cpp b/deps/ox/src/ox/model/desctypes.cpp index ba0cc40..380f245 100644 --- a/deps/ox/src/ox/model/desctypes.cpp +++ b/deps/ox/src/ox/model/desctypes.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/desctypes.hpp b/deps/ox/src/ox/model/desctypes.hpp index e1e6f0b..e2924d2 100644 --- a/deps/ox/src/ox/model/desctypes.hpp +++ b/deps/ox/src/ox/model/desctypes.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/descwrite.cpp b/deps/ox/src/ox/model/descwrite.cpp index 662f7d1..cebd026 100644 --- a/deps/ox/src/ox/model/descwrite.cpp +++ b/deps/ox/src/ox/model/descwrite.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/descwrite.hpp b/deps/ox/src/ox/model/descwrite.hpp index d60b810..e0bf984 100644 --- a/deps/ox/src/ox/model/descwrite.hpp +++ b/deps/ox/src/ox/model/descwrite.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include #include @@ -152,7 +152,7 @@ class TypeDescWriter { template [[nodiscard]] - constexpr const DescriptorType *type(const BString *val) const noexcept; + constexpr const DescriptorType *type(const IString *val) const noexcept; template [[nodiscard]] @@ -334,7 +334,7 @@ constexpr const DescriptorType *TypeDescWriter::type(const char*) const noexcept } template -constexpr const DescriptorType *TypeDescWriter::type(const BString*) const noexcept { +constexpr const DescriptorType *TypeDescWriter::type(const IString*) const noexcept { constexpr auto PT = PrimitiveType::String; return getType(types::BString, 0, PT, 0); } diff --git a/deps/ox/src/ox/model/fieldcounter.hpp b/deps/ox/src/ox/model/fieldcounter.hpp index 9477b83..caebc41 100644 --- a/deps/ox/src/ox/model/fieldcounter.hpp +++ b/deps/ox/src/ox/model/fieldcounter.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/metadata.hpp b/deps/ox/src/ox/model/metadata.hpp index 9e228a5..c11ebc5 100644 --- a/deps/ox/src/ox/model/metadata.hpp +++ b/deps/ox/src/ox/model/metadata.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/deps/ox/src/ox/model/model.hpp b/deps/ox/src/ox/model/model.hpp index 7a97fe6..07f6fb0 100644 --- a/deps/ox/src/ox/model/model.hpp +++ b/deps/ox/src/ox/model/model.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/modelhandleradaptor.hpp b/deps/ox/src/ox/model/modelhandleradaptor.hpp index 7bd4386..854c541 100644 --- a/deps/ox/src/ox/model/modelhandleradaptor.hpp +++ b/deps/ox/src/ox/model/modelhandleradaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/modelops.hpp b/deps/ox/src/ox/model/modelops.hpp index 1f8aca9..e8c4ad0 100644 --- a/deps/ox/src/ox/model/modelops.hpp +++ b/deps/ox/src/ox/model/modelops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -276,8 +276,8 @@ constexpr void moveModel(T *dst, T *src) noexcept { constexpr auto size = ModelFieldCount_v; detail::MemberList dstFields; detail::Mover mover(&dstFields); - oxIgnoreError(model(&dstFields, dst)); - oxIgnoreError(model(&mover, src)); + std::ignore = model(&dstFields, dst); + std::ignore = model(&mover, src); } template @@ -285,8 +285,8 @@ constexpr void copyModel(T *dst, const T *src) noexcept { constexpr auto size = ModelFieldCount_v; detail::MemberList dstFields; detail::Copier copier(&dstFields); - oxIgnoreError(model(&dstFields, dst)); - oxIgnoreError(model(&copier, src)); + std::ignore = model(&dstFields, dst); + std::ignore = model(&copier, src); } template @@ -295,8 +295,8 @@ constexpr bool equalsModel(T *a, T *b) noexcept { constexpr auto size = T::Fields; detail::MemberList aFields; detail::Equals equals(&aFields); - oxIgnoreError(model(&aFields, a)); - oxIgnoreError(model(&equals, b)); + std::ignore = model(&aFields, a); + std::ignore = model(&equals, b); return equals.value; } diff --git a/deps/ox/src/ox/model/modelvalue.cpp b/deps/ox/src/ox/model/modelvalue.cpp index 2d28fe7..9adf591 100644 --- a/deps/ox/src/ox/model/modelvalue.cpp +++ b/deps/ox/src/ox/model/modelvalue.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/modelvalue.hpp b/deps/ox/src/ox/model/modelvalue.hpp index 416c894..90088cf 100644 --- a/deps/ox/src/ox/model/modelvalue.hpp +++ b/deps/ox/src/ox/model/modelvalue.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -1057,13 +1057,13 @@ constexpr ModelValue::ModelValue(ModelValue &&other) noexcept { template constexpr ModelValue::ModelValue(const T &val) noexcept requires(!ox::is_same_v, ModelValue>) { - oxIgnoreError(set(val)); + std::ignore = set(val); } template constexpr ModelValue::ModelValue(T &&val) noexcept requires(!ox::is_same_v, ModelValue>) { - oxIgnoreError(set(ox::forward(val))); + std::ignore = set(ox::forward(val)); } constexpr ModelValue::~ModelValue() noexcept { diff --git a/deps/ox/src/ox/model/optype.hpp b/deps/ox/src/ox/model/optype.hpp index e0e1a85..f0e473b 100644 --- a/deps/ox/src/ox/model/optype.hpp +++ b/deps/ox/src/ox/model/optype.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/test/tests.cpp b/deps/ox/src/ox/model/test/tests.cpp index fbd50e6..610cae9 100644 --- a/deps/ox/src/ox/model/test/tests.cpp +++ b/deps/ox/src/ox/model/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index d2b555d..0c6234a 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -99,7 +99,7 @@ struct TypeInfoCatcher { template constexpr int getModelTypeVersion(T *val) noexcept { TypeInfoCatcher nc; - oxIgnoreError(model(&nc, val)); + std::ignore = model(&nc, val); return nc.version; } @@ -122,7 +122,7 @@ consteval int requireModelTypeVersion() noexcept { template constexpr Str getModelTypeName(T *val) noexcept { TypeNameCatcher nc; - oxIgnoreError(model(&nc, val)); + std::ignore = model(&nc, val); return nc.name; } @@ -147,4 +147,19 @@ constexpr auto ModelTypeName_v = getModelTypeName(); template constexpr auto ModelTypeVersion_v = requireModelTypeVersion(); +template +constexpr auto ModelTypeVersionStr_v = [] { + constexpr auto version = ModelTypeVersion_v; + constexpr auto versionStr = ox::sfmt("{}", version); + return ox::IString{versionStr}; +}; + +template +constexpr auto ModelTypeId_v = [] { + constexpr auto name = ModelTypeName_v; + constexpr auto version = ModelTypeVersion_v; + constexpr auto versionStr = ox::sfmt>("{}", version); + return ox::sfmt>("{};{}", name, versionStr); +}(); + } diff --git a/deps/ox/src/ox/model/types.hpp b/deps/ox/src/ox/model/types.hpp index 66c1d8f..5d54bfe 100644 --- a/deps/ox/src/ox/model/types.hpp +++ b/deps/ox/src/ox/model/types.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -21,7 +21,7 @@ #endif #include -#include +#include #include #include #include diff --git a/deps/ox/src/ox/model/typestore.hpp b/deps/ox/src/ox/model/typestore.hpp index 4a2a5da..2a8f1e1 100644 --- a/deps/ox/src/ox/model/typestore.hpp +++ b/deps/ox/src/ox/model/typestore.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/model/walk.hpp b/deps/ox/src/ox/model/walk.hpp index 386e5cc..784bddc 100644 --- a/deps/ox/src/ox/model/walk.hpp +++ b/deps/ox/src/ox/model/walk.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -64,7 +64,7 @@ constexpr Error DataWalker::read(const DescriptorField &f, Reader *rd template constexpr void DataWalker::pushNamePath(const FieldName &fn) noexcept { - m_path.push_back(fn); + m_path.emplace_back(fn); } template diff --git a/deps/ox/src/ox/oc/oc.hpp b/deps/ox/src/ox/oc/oc.hpp index 7bed380..bb4f47c 100644 --- a/deps/ox/src/ox/oc/oc.hpp +++ b/deps/ox/src/ox/oc/oc.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/oc/read.cpp b/deps/ox/src/ox/oc/read.cpp index a6d634f..d2b1ff9 100644 --- a/deps/ox/src/ox/oc/read.cpp +++ b/deps/ox/src/ox/oc/read.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/oc/read.hpp b/deps/ox/src/ox/oc/read.hpp index 15ecb7e..aa7b66c 100644 --- a/deps/ox/src/ox/oc/read.hpp +++ b/deps/ox/src/ox/oc/read.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -70,7 +70,7 @@ class OrganicClawReader { Error field(const char *key, BasicString *val) noexcept; template - Error field(const char *key, BString *val) noexcept; + Error field(const char *key, IString *val) noexcept; Error fieldCString(const char *key, char *val, std::size_t buffLen) noexcept; @@ -206,7 +206,7 @@ Error OrganicClawReader::field(const char *key, BasicString *val) noexcept { } template -Error OrganicClawReader::field(const char *key, BString *val) noexcept { +Error OrganicClawReader::field(const char *key, IString *val) noexcept { return fieldCString(key, val->data(), val->cap()); } diff --git a/deps/ox/src/ox/oc/test/tests.cpp b/deps/ox/src/ox/oc/test/tests.cpp index 0c98ae7..ec33c37 100644 --- a/deps/ox/src/ox/oc/test/tests.cpp +++ b/deps/ox/src/ox/oc/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -35,7 +35,7 @@ struct TestStructNest { static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; - ox::BString<32> String = ""; + ox::IString<32> String = ""; }; struct TestStruct { diff --git a/deps/ox/src/ox/oc/write.cpp b/deps/ox/src/ox/oc/write.cpp index ddec2ce..13f99b8 100644 --- a/deps/ox/src/ox/oc/write.cpp +++ b/deps/ox/src/ox/oc/write.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index b6e2223..af05040 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -132,7 +132,7 @@ class OrganicClawWriter { } template - Error field(char const*key, BString const*val) noexcept { + Error field(char const*key, IString const*val) noexcept { if (targetValid() && val->len()) { value(key) = val->c_str(); } diff --git a/deps/ox/src/ox/preloader/alignmentcatcher.hpp b/deps/ox/src/ox/preloader/alignmentcatcher.hpp index fdbe0b1..98ee847 100644 --- a/deps/ox/src/ox/preloader/alignmentcatcher.hpp +++ b/deps/ox/src/ox/preloader/alignmentcatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/preloader/platspecs.hpp b/deps/ox/src/ox/preloader/platspecs.hpp index dc5d656..5145fb5 100644 --- a/deps/ox/src/ox/preloader/platspecs.hpp +++ b/deps/ox/src/ox/preloader/platspecs.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/preloader/preloader.cpp b/deps/ox/src/ox/preloader/preloader.cpp index 2b90312..9540395 100644 --- a/deps/ox/src/ox/preloader/preloader.cpp +++ b/deps/ox/src/ox/preloader/preloader.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/preloader/preloader.hpp b/deps/ox/src/ox/preloader/preloader.hpp index 59b761b..1bc10e9 100644 --- a/deps/ox/src/ox/preloader/preloader.hpp +++ b/deps/ox/src/ox/preloader/preloader.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/preloader/sizecatcher.hpp b/deps/ox/src/ox/preloader/sizecatcher.hpp index 1164ff5..e9ca546 100644 --- a/deps/ox/src/ox/preloader/sizecatcher.hpp +++ b/deps/ox/src/ox/preloader/sizecatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/preloader/unionsizecatcher.hpp b/deps/ox/src/ox/preloader/unionsizecatcher.hpp index 40b9dff..9e2d8c0 100644 --- a/deps/ox/src/ox/preloader/unionsizecatcher.hpp +++ b/deps/ox/src/ox/preloader/unionsizecatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index 73c0057..6c88ca4 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -81,6 +81,7 @@ target_link_libraries( OxStd PUBLIC $<$:gcc> OxTraceHook + CityHash ) install( @@ -90,7 +91,7 @@ install( assert.hpp bit.hpp bounds.hpp - bstring.hpp + istring.hpp buffer.hpp buildinfo.hpp byteswap.hpp @@ -103,6 +104,7 @@ install( hardware.hpp hashmap.hpp heapmgr.hpp + ignore.hpp iterator.hpp math.hpp maybeview.hpp diff --git a/deps/ox/src/ox/std/algorithm.hpp b/deps/ox/src/ox/std/algorithm.hpp index a971e43..bc3d96e 100644 --- a/deps/ox/src/ox/std/algorithm.hpp +++ b/deps/ox/src/ox/std/algorithm.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/anyptr.hpp b/deps/ox/src/ox/std/anyptr.hpp index ac11e48..2eba974 100644 --- a/deps/ox/src/ox/std/anyptr.hpp +++ b/deps/ox/src/ox/std/anyptr.hpp @@ -1,3 +1,10 @@ +/* + * Copyright 2015 - 2024 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ #pragma once diff --git a/deps/ox/src/ox/std/array.hpp b/deps/ox/src/ox/std/array.hpp index bef35d0..d20a618 100644 --- a/deps/ox/src/ox/std/array.hpp +++ b/deps/ox/src/ox/std/array.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index 09c405b..3f5f68c 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/assert.hpp b/deps/ox/src/ox/std/assert.hpp index 6f62d42..879f3b2 100644 --- a/deps/ox/src/ox/std/assert.hpp +++ b/deps/ox/src/ox/std/assert.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/basestringview.hpp b/deps/ox/src/ox/std/basestringview.hpp index b111f0e..45ff062 100644 --- a/deps/ox/src/ox/std/basestringview.hpp +++ b/deps/ox/src/ox/std/basestringview.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/bit.cpp b/deps/ox/src/ox/std/bit.cpp index 7dcffa1..a9d1078 100644 --- a/deps/ox/src/ox/std/bit.cpp +++ b/deps/ox/src/ox/std/bit.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/bit.hpp b/deps/ox/src/ox/std/bit.hpp index f4b8d55..6573ab0 100644 --- a/deps/ox/src/ox/std/bit.hpp +++ b/deps/ox/src/ox/std/bit.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/bounds.hpp b/deps/ox/src/ox/std/bounds.hpp index 21ff361..78090a5 100644 --- a/deps/ox/src/ox/std/bounds.hpp +++ b/deps/ox/src/ox/std/bounds.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/buffer.cpp b/deps/ox/src/ox/std/buffer.cpp index 35a1772..e961c4f 100644 --- a/deps/ox/src/ox/std/buffer.cpp +++ b/deps/ox/src/ox/std/buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/buffer.hpp b/deps/ox/src/ox/std/buffer.hpp index 674a4a2..bcfccea 100644 --- a/deps/ox/src/ox/std/buffer.hpp +++ b/deps/ox/src/ox/std/buffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/buildinfo.cpp b/deps/ox/src/ox/std/buildinfo.cpp index 4db04b4..e3ea874 100644 --- a/deps/ox/src/ox/std/buildinfo.cpp +++ b/deps/ox/src/ox/std/buildinfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/buildinfo.hpp b/deps/ox/src/ox/std/buildinfo.hpp index a003f1e..1d960da 100644 --- a/deps/ox/src/ox/std/buildinfo.hpp +++ b/deps/ox/src/ox/std/buildinfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/byteswap.cpp b/deps/ox/src/ox/std/byteswap.cpp index f3074cb..a7dd59f 100644 --- a/deps/ox/src/ox/std/byteswap.cpp +++ b/deps/ox/src/ox/std/byteswap.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/byteswap.hpp b/deps/ox/src/ox/std/byteswap.hpp index 9f3c8a9..e29c49d 100644 --- a/deps/ox/src/ox/std/byteswap.hpp +++ b/deps/ox/src/ox/std/byteswap.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/concepts.cpp b/deps/ox/src/ox/std/concepts.cpp index 54198ce..043aa38 100644 --- a/deps/ox/src/ox/std/concepts.cpp +++ b/deps/ox/src/ox/std/concepts.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/concepts.hpp b/deps/ox/src/ox/std/concepts.hpp index 6b9f32b..ccc993b 100644 --- a/deps/ox/src/ox/std/concepts.hpp +++ b/deps/ox/src/ox/std/concepts.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/cstringview.hpp b/deps/ox/src/ox/std/cstringview.hpp index fd94ba4..47435c1 100644 --- a/deps/ox/src/ox/std/cstringview.hpp +++ b/deps/ox/src/ox/std/cstringview.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -9,7 +9,7 @@ #pragma once #include "basestringview.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "string.hpp" #include "stringliteral.hpp" @@ -27,7 +27,7 @@ class CStringView: public detail::BaseStringView { constexpr CStringView(BasicString const&str) noexcept: BaseStringView(str.data(), str.len()) {} template - constexpr CStringView(BString const&str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr CStringView(IString const&str) noexcept: BaseStringView(str.data(), str.len()) {} constexpr CStringView(std::nullptr_t) noexcept {} diff --git a/deps/ox/src/ox/std/cstrops.hpp b/deps/ox/src/ox/std/cstrops.hpp index 4b5b02c..ceac63c 100644 --- a/deps/ox/src/ox/std/cstrops.hpp +++ b/deps/ox/src/ox/std/cstrops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/def.hpp b/deps/ox/src/ox/std/def.hpp index 007cf06..790b005 100644 --- a/deps/ox/src/ox/std/def.hpp +++ b/deps/ox/src/ox/std/def.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/defer.hpp b/deps/ox/src/ox/std/defer.hpp index ab02903..593cc57 100644 --- a/deps/ox/src/ox/std/defer.hpp +++ b/deps/ox/src/ox/std/defer.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/defines.hpp b/deps/ox/src/ox/std/defines.hpp index 27467be..a655a4d 100644 --- a/deps/ox/src/ox/std/defines.hpp +++ b/deps/ox/src/ox/std/defines.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 978f107..1f53426 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -314,7 +314,3 @@ constexpr Error toError(const Result &r) noexcept { } } - -constexpr void oxIgnoreError(const ox::Error&) noexcept {} -template -constexpr void oxIgnoreError(const ox::Result&) noexcept {} diff --git a/deps/ox/src/ox/std/fmt.cpp b/deps/ox/src/ox/std/fmt.cpp index 5060263..32b1ea7 100644 --- a/deps/ox/src/ox/std/fmt.cpp +++ b/deps/ox/src/ox/std/fmt.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/fmt.hpp b/deps/ox/src/ox/std/fmt.hpp index b650bbe..2149337 100644 --- a/deps/ox/src/ox/std/fmt.hpp +++ b/deps/ox/src/ox/std/fmt.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -18,7 +18,8 @@ #include "realstd.hpp" #include "error.hpp" -#include "bstring.hpp" +#include "ignore.hpp" +#include "istring.hpp" #include "string.hpp" #include "strops.hpp" #include "types.hpp" @@ -38,7 +39,7 @@ constexpr StringView toStringView(const char *s) noexcept { } template -constexpr StringView toStringView(const BString &s) noexcept { +constexpr StringView toStringView(const IString &s) noexcept { return s.c_str(); } @@ -77,7 +78,7 @@ class FmtArg { char dataStr[10] = {}; template - static StringView sv(const T &v, char *dataStr) noexcept { + constexpr StringView sv(const T &v, char *dataStr) noexcept { if constexpr(is_bool_v) { return v ? "true" : "false"; } else if constexpr(is_integer_v) { @@ -191,12 +192,12 @@ constexpr StringType sfmt(StringView fmt, Args&&... args) noexcept { StringType out; const auto fmtSegments = ox::detail::fmtSegments(fmt); const auto &firstSegment = fmtSegments.segments[0]; - oxIgnoreError(out.append(firstSegment.str, firstSegment.length)); + std::ignore = out.append(firstSegment.str, firstSegment.length); const detail::FmtArg elements[sizeof...(args)] = {args...}; for (size_t i = 0; i < fmtSegments.size - 1; ++i) { out += elements[i].out; const auto &s = fmtSegments.segments[i + 1]; - oxIgnoreError(out.append(s.str, s.length)); + std::ignore = out.append(s.str, s.length); } return out; } diff --git a/deps/ox/src/ox/std/hardware.hpp b/deps/ox/src/ox/std/hardware.hpp index 5c9639b..0611a99 100644 --- a/deps/ox/src/ox/std/hardware.hpp +++ b/deps/ox/src/ox/std/hardware.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/hash.hpp b/deps/ox/src/ox/std/hash.hpp new file mode 100644 index 0000000..8f7e923 --- /dev/null +++ b/deps/ox/src/ox/std/hash.hpp @@ -0,0 +1,170 @@ +/* + * Copyright 2015 - 2024 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#if __has_include() +#include +#else +namespace std { +template +struct hash; +} +#endif + +#include + +#include "istring.hpp" +#include "string.hpp" +#include "stringview.hpp" +#include "types.hpp" + +namespace ox { + +template +struct hash { + [[nodiscard]] + constexpr size_t operator()(T const&v) const noexcept { + return std::hash{}(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(bool v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(char v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(short v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(int v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(long v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(long long v) const noexcept { + return static_cast(v); + } +}; + + + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(unsigned char v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(unsigned short v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(unsigned int v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(unsigned long v) const noexcept { + return static_cast(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(unsigned long long v) const noexcept { + return static_cast(v); + } +}; + + +[[nodiscard]] +constexpr auto hashString(ox::StringView const&v) noexcept { + if constexpr(sizeof(void*) == 8) { + return cityhash::CityHash64(v.data(), v.bytes()); + } else { + return cityhash::CityHash32(v.data(), v.bytes()); + } +} + + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(ox::StringView v) const noexcept { + return hashString(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(ox::StringView v) const noexcept { + return hashString(v); + } +}; + +template +struct hash> { + [[nodiscard]] + constexpr size_t operator()(ox::StringView v) const noexcept { + return hashString(v); + } +}; + +template<> +struct hash { + [[nodiscard]] + constexpr size_t operator()(ox::StringView v) const noexcept { + return hashString(v); + } +}; + +} diff --git a/deps/ox/src/ox/std/hashmap.hpp b/deps/ox/src/ox/std/hashmap.hpp index f1c0543..2475359 100644 --- a/deps/ox/src/ox/std/hashmap.hpp +++ b/deps/ox/src/ox/std/hashmap.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -9,6 +9,8 @@ #pragma once #include "algorithm.hpp" +#include "hash.hpp" +#include "ignore.hpp" #include "stringview.hpp" #include "strops.hpp" #include "vector.hpp" @@ -31,7 +33,7 @@ class HashMap { Vector m_pairs; public: - explicit constexpr HashMap(std::size_t size = 100); + explicit constexpr HashMap(std::size_t size = 127); constexpr HashMap(HashMap const&other); @@ -67,10 +69,6 @@ class HashMap { private: constexpr void expand(); - constexpr static uint64_t hash(Integral_c auto) noexcept; - - constexpr static uint64_t hash(StringView const&) noexcept; - template constexpr Pair *const&access(Vector const&pairs, KK const&key) const; @@ -171,17 +169,17 @@ constexpr void HashMap::erase(MaybeView_t const&k) { if (!contains(k)) { return; } - auto h = hash(k) % m_pairs.size(); + auto h = ox::hash>{}(k) % m_pairs.size(); while (true) { const auto &p = m_pairs[h]; if (p == nullptr || p->key == k) { - oxIgnoreError(m_pairs.erase(h)); + std::ignore = m_pairs.erase(h); break; } else { - h = hash(h) % m_pairs.size(); + h = ox::hash>{}(k) % m_pairs.size(); } } - oxIgnoreError(m_keys.erase(ox::find(m_keys.begin(), m_keys.end(), k))); + std::ignore = m_keys.erase(ox::find(m_keys.begin(), m_keys.end(), k)); } template @@ -205,7 +203,7 @@ constexpr void HashMap::clear() { delete m_pairs[i]; } m_pairs.clear(); - m_pairs.resize(100); + m_pairs.resize(127); } template @@ -218,30 +216,10 @@ constexpr void HashMap::expand() { m_pairs = std::move(r); } -template -constexpr uint64_t HashMap::hash(Integral_c auto k) noexcept { - uint64_t sum = 1; - for (auto i = 0u; i < sizeof(K); ++i) { - const auto shift = i * 8; - const auto v = static_cast(k >> shift & 0xff); - sum += (sum + v) * 7 * sum; - } - return sum; -} - -template -constexpr uint64_t HashMap::hash(StringView const&k) noexcept { - uint64_t sum = 1; - for (auto i = 0u; i < k.len(); ++i) { - sum += ((sum + static_cast(k[i])) * 7) * sum; - } - return sum; -} - template template constexpr typename HashMap::Pair *const&HashMap::access(Vector const&pairs, KK const&k) const { - auto h = static_cast(hash(k) % pairs.size()); + auto h = static_cast(ox::hash{}(k) % pairs.size()); while (true) { const auto &p = pairs[h]; if (p == nullptr || p->key == k) { @@ -255,7 +233,7 @@ constexpr typename HashMap::Pair *const&HashMap::access(Vector template constexpr typename HashMap::Pair *&HashMap::access(Vector &pairs, KK const&k) { - auto h = static_cast(hash(k) % pairs.size()); + auto h = static_cast(ox::hash{}(k) % pairs.size()); while (true) { auto &p = pairs[h]; if (p == nullptr || p->key == k) { diff --git a/deps/ox/src/ox/std/heapmgr.cpp b/deps/ox/src/ox/std/heapmgr.cpp index 623b9e7..e7ef055 100644 --- a/deps/ox/src/ox/std/heapmgr.cpp +++ b/deps/ox/src/ox/std/heapmgr.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/heapmgr.hpp b/deps/ox/src/ox/std/heapmgr.hpp index 5bbb4e4..f97deed 100644 --- a/deps/ox/src/ox/std/heapmgr.hpp +++ b/deps/ox/src/ox/std/heapmgr.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/ignore.hpp b/deps/ox/src/ox/std/ignore.hpp new file mode 100644 index 0000000..f806ebb --- /dev/null +++ b/deps/ox/src/ox/std/ignore.hpp @@ -0,0 +1,24 @@ +/* + * Copyright 2015 - 2024 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#if __has_include() + +#include + +#else + +namespace std { + +inline constexpr struct { + constexpr void operator=(auto&&) const noexcept {} +} ignore; + +} +#endif diff --git a/deps/ox/src/ox/std/initializerlist.hpp b/deps/ox/src/ox/std/initializerlist.hpp index 04e1a8f..bdddcab 100644 --- a/deps/ox/src/ox/std/initializerlist.hpp +++ b/deps/ox/src/ox/std/initializerlist.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/bstring.hpp b/deps/ox/src/ox/std/istring.hpp similarity index 61% rename from deps/ox/src/ox/std/bstring.hpp rename to deps/ox/src/ox/std/istring.hpp index d73585e..b7eef79 100644 --- a/deps/ox/src/ox/std/bstring.hpp +++ b/deps/ox/src/ox/std/istring.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -8,6 +8,7 @@ #pragma once +#include "ignore.hpp" #include "memops.hpp" #include "stringview.hpp" #include "strops.hpp" @@ -15,40 +16,41 @@ namespace ox { -// Bounded String +// Inline String template -class BString { +class IString { private: char m_buff[buffLen + 1]; + size_t m_size{}; public: - constexpr BString() noexcept; + constexpr IString() noexcept; - constexpr BString(StringView str) noexcept; + constexpr IString(StringView str) noexcept; - constexpr BString(const char *str) noexcept; + constexpr IString(const char *str) noexcept; - constexpr BString &operator=(CRStringView str) noexcept; + constexpr IString &operator=(CRStringView str) noexcept; - constexpr BString &operator=(const char *str) noexcept; + constexpr IString &operator=(const char *str) noexcept; - constexpr BString &operator=(char *str) noexcept; + constexpr IString &operator=(char *str) noexcept; - constexpr BString &operator=(Integer_c auto i) noexcept; + constexpr IString &operator=(Integer_c auto i) noexcept; - constexpr BString &operator+=(const char *str) noexcept; + constexpr IString &operator+=(const char *str) noexcept; - constexpr BString &operator+=(char *str) noexcept; + constexpr IString &operator+=(char *str) noexcept; - constexpr BString &operator+=(Integer_c auto i) noexcept; + constexpr IString &operator+=(Integer_c auto i) noexcept; - constexpr BString &operator+=(StringView s) noexcept; + constexpr IString &operator+=(StringView s) noexcept; - constexpr BString operator+(const char *str) const noexcept; + constexpr IString operator+(const char *str) const noexcept; - constexpr BString operator+(char *str) const noexcept; + constexpr IString operator+(char *str) const noexcept; - constexpr BString operator+(Integer_c auto i) const noexcept; + constexpr IString operator+(Integer_c auto i) const noexcept; constexpr bool operator==(const char *other) const noexcept; @@ -93,133 +95,135 @@ class BString { }; template -constexpr BString::BString() noexcept: m_buff{{0}} { +constexpr IString::IString() noexcept: m_buff{{0}} { } template -constexpr BString::BString(StringView str) noexcept: m_buff{{0}} { +constexpr IString::IString(StringView str) noexcept: m_buff{{0}} { operator=(str); } template -constexpr BString::BString(const char *str) noexcept: m_buff{{0}} { +constexpr IString::IString(const char *str) noexcept: m_buff{{0}} { operator=(str); } template -constexpr BString &BString::operator=(Integer_c auto i) noexcept { +constexpr IString &IString::operator=(Integer_c auto i) noexcept { char str[65] = {}; ox::itoa(i, str); return this->operator=(str); } template -constexpr BString &BString::operator=(ox::CRStringView str) noexcept { +constexpr IString &IString::operator=(ox::CRStringView str) noexcept { std::size_t strLen = str.bytes() + 1; if (cap() < strLen) { strLen = cap(); } - ox::memcpy(m_buff, str.data(), strLen); + m_size = strLen; + ox::listcpy(m_buff, str.data(), strLen); // make sure last element is a null terminator m_buff[strLen] = 0; return *this; } template -constexpr BString &BString::operator=(const char *str) noexcept { +constexpr IString &IString::operator=(const char *str) noexcept { std::size_t strLen = ox::strlen(str) + 1; if (cap() < strLen) { strLen = cap(); } - ox::memcpy(m_buff, str, strLen); + m_size = strLen; + ox::listcpy(m_buff, str, strLen); // make sure last element is a null terminator m_buff[cap()] = 0; return *this; } template -constexpr BString &BString::operator=(char *str) noexcept { +constexpr IString &IString::operator=(char *str) noexcept { return *this = static_cast(str); } template -constexpr BString &BString::operator+=(const char *str) noexcept { +constexpr IString &IString::operator+=(const char *str) noexcept { std::size_t strLen = ox::strlen(str) + 1; - oxIgnoreError(append(str, strLen)); + std::ignore = append(str, strLen); return *this; } template -constexpr BString &BString::operator+=(char *str) noexcept { +constexpr IString &IString::operator+=(char *str) noexcept { return *this += static_cast(str); } template -constexpr BString &BString::operator+=(Integer_c auto i) noexcept { +constexpr IString &IString::operator+=(Integer_c auto i) noexcept { char str[65] = {}; ox::itoa(i, str); return this->operator+=(str); } template -constexpr BString &BString::operator+=(StringView s) noexcept { +constexpr IString &IString::operator+=(StringView s) noexcept { std::size_t strLen = s.bytes(); - oxIgnoreError(append(s.data(), strLen)); + std::ignore = append(s.data(), strLen); return *this; } template -constexpr BString BString::operator+(const char *str) const noexcept { +constexpr IString IString::operator+(const char *str) const noexcept { auto out = *this; std::size_t strLen = ox::strlen(str) + 1; - oxIgnoreError(out.append(str, strLen)); + std::ignore = out.append(str, strLen); return out; } template -constexpr BString BString::operator+(char *str) const noexcept { +constexpr IString IString::operator+(char *str) const noexcept { return *this + static_cast(str); } template -constexpr BString BString::operator+(Integer_c auto i) const noexcept { +constexpr IString IString::operator+(Integer_c auto i) const noexcept { char str[65] = {}; ox::itoa(i, str); return this->operator+(str); } template -constexpr bool BString::operator==(const char *other) const noexcept { +constexpr bool IString::operator==(const char *other) const noexcept { return ox::StringView(*this) == other; } template -constexpr bool BString::operator==(const OxString_c auto &other) const noexcept { +constexpr bool IString::operator==(const OxString_c auto &other) const noexcept { return ox::StringView(*this) == ox::StringView(other); } template -constexpr bool BString::operator!=(const char *other) const noexcept { +constexpr bool IString::operator!=(const char *other) const noexcept { return !operator==(other); } template -constexpr bool BString::operator!=(const OxString_c auto &other) noexcept { +constexpr bool IString::operator!=(const OxString_c auto &other) noexcept { return !operator==(other); } template -constexpr char BString::operator[](std::size_t i) const noexcept { +constexpr char IString::operator[](std::size_t i) const noexcept { return m_buff[i]; } template -constexpr char &BString::operator[](std::size_t i) noexcept { +constexpr char &IString::operator[](std::size_t i) noexcept { return m_buff[i]; } template -constexpr Error BString::append(const char *str, std::size_t strLen) noexcept { +constexpr Error IString::append(const char *str, std::size_t strLen) noexcept { Error err; auto currentLen = len(); if (cap() < currentLen + strLen + 1) { @@ -233,23 +237,23 @@ constexpr Error BString::append(const char *str, std::size_t strLen) no } template -constexpr const char *BString::data() const noexcept { +constexpr const char *IString::data() const noexcept { return static_cast(m_buff); } template -constexpr char *BString::data() noexcept { +constexpr char *IString::data() noexcept { return static_cast(m_buff); } template -constexpr const char *BString::c_str() const noexcept { +constexpr const char *IString::c_str() const noexcept { return static_cast(m_buff); } template -constexpr std::size_t BString::len() const noexcept { +constexpr std::size_t IString::len() const noexcept { std::size_t length = 0; for (std::size_t i = 0; i < buffLen; i++) { uint8_t b = static_cast(m_buff[i]); @@ -267,15 +271,20 @@ constexpr std::size_t BString::len() const noexcept { } template -constexpr std::size_t BString::bytes() const noexcept { +constexpr std::size_t IString::bytes() const noexcept { std::size_t i = 0; for (i = 0; i < buffLen && m_buff[i]; i++); return i + 1; // add one for null terminator } template -constexpr std::size_t BString::cap() const noexcept { +constexpr std::size_t IString::cap() const noexcept { return buffLen; } +template +struct MaybeView> { + using type = ox::StringView; +}; + } diff --git a/deps/ox/src/ox/std/iterator.hpp b/deps/ox/src/ox/std/iterator.hpp index ec7126c..a93e75c 100644 --- a/deps/ox/src/ox/std/iterator.hpp +++ b/deps/ox/src/ox/std/iterator.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/math.cpp b/deps/ox/src/ox/std/math.cpp index 3313ffa..d1872dd 100644 --- a/deps/ox/src/ox/std/math.cpp +++ b/deps/ox/src/ox/std/math.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/math.hpp b/deps/ox/src/ox/std/math.hpp index b18d641..4c532ca 100644 --- a/deps/ox/src/ox/std/math.hpp +++ b/deps/ox/src/ox/std/math.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/maybeview.hpp b/deps/ox/src/ox/std/maybeview.hpp index e999239..149cd97 100644 --- a/deps/ox/src/ox/std/maybeview.hpp +++ b/deps/ox/src/ox/std/maybeview.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -15,7 +15,7 @@ namespace ox { // Maybe StringView. If T is a string type, MaybeType::type/MaybeView_t is a // StringView. This avoids creating unnecessary Strings when taking a // StringView or C string as a function argument. -template> +template struct MaybeView { using type = T; }; diff --git a/deps/ox/src/ox/std/memops.cpp b/deps/ox/src/ox/std/memops.cpp index c76dbf1..86789ea 100644 --- a/deps/ox/src/ox/std/memops.cpp +++ b/deps/ox/src/ox/std/memops.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/memops.hpp b/deps/ox/src/ox/std/memops.hpp index 470eebe..3c6e3ba 100644 --- a/deps/ox/src/ox/std/memops.hpp +++ b/deps/ox/src/ox/std/memops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/memory.hpp b/deps/ox/src/ox/std/memory.hpp index 4e751f3..a19c46b 100644 --- a/deps/ox/src/ox/std/memory.hpp +++ b/deps/ox/src/ox/std/memory.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/new.hpp b/deps/ox/src/ox/std/new.hpp index 228fa8c..df4a827 100644 --- a/deps/ox/src/ox/std/new.hpp +++ b/deps/ox/src/ox/std/new.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/optional.hpp b/deps/ox/src/ox/std/optional.hpp index 687fda4..f1c0022 100644 --- a/deps/ox/src/ox/std/optional.hpp +++ b/deps/ox/src/ox/std/optional.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/point.hpp b/deps/ox/src/ox/std/point.hpp index a4cad8e..ca6c57f 100644 --- a/deps/ox/src/ox/std/point.hpp +++ b/deps/ox/src/ox/std/point.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/random.cpp b/deps/ox/src/ox/std/random.cpp index d573686..cd7c035 100644 --- a/deps/ox/src/ox/std/random.cpp +++ b/deps/ox/src/ox/std/random.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/random.hpp b/deps/ox/src/ox/std/random.hpp index 7a1eeae..ac6bbf6 100644 --- a/deps/ox/src/ox/std/random.hpp +++ b/deps/ox/src/ox/std/random.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/range.hpp b/deps/ox/src/ox/std/range.hpp index 717fae5..4804b1e 100644 --- a/deps/ox/src/ox/std/range.hpp +++ b/deps/ox/src/ox/std/range.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/ranges.hpp b/deps/ox/src/ox/std/ranges.hpp index 1f2fc26..b945b74 100644 --- a/deps/ox/src/ox/std/ranges.hpp +++ b/deps/ox/src/ox/std/ranges.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/reader.cpp b/deps/ox/src/ox/std/reader.cpp index f650a19..5f21556 100644 --- a/deps/ox/src/ox/std/reader.cpp +++ b/deps/ox/src/ox/std/reader.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/reader.hpp b/deps/ox/src/ox/std/reader.hpp index 8a67a37..73e9ea4 100644 --- a/deps/ox/src/ox/std/reader.hpp +++ b/deps/ox/src/ox/std/reader.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/realstd.hpp b/deps/ox/src/ox/std/realstd.hpp index d4441a5..4d70318 100644 --- a/deps/ox/src/ox/std/realstd.hpp +++ b/deps/ox/src/ox/std/realstd.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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,5 +11,5 @@ #if __has_include() #include #else -#define assert(e) while (1); +#define assert(e) while (!(e)); #endif \ No newline at end of file diff --git a/deps/ox/src/ox/std/serialize.hpp b/deps/ox/src/ox/std/serialize.hpp index 23e3481..39b5de5 100644 --- a/deps/ox/src/ox/std/serialize.hpp +++ b/deps/ox/src/ox/std/serialize.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/size.hpp b/deps/ox/src/ox/std/size.hpp index e6ad409..3b03f53 100644 --- a/deps/ox/src/ox/std/size.hpp +++ b/deps/ox/src/ox/std/size.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/span.hpp b/deps/ox/src/ox/std/span.hpp index da9272f..4064458 100644 --- a/deps/ox/src/ox/std/span.hpp +++ b/deps/ox/src/ox/std/span.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/stacktrace.cpp b/deps/ox/src/ox/std/stacktrace.cpp index 0b7a2a6..8a23afc 100644 --- a/deps/ox/src/ox/std/stacktrace.cpp +++ b/deps/ox/src/ox/std/stacktrace.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/stacktrace.hpp b/deps/ox/src/ox/std/stacktrace.hpp index ec49c55..26555e5 100644 --- a/deps/ox/src/ox/std/stacktrace.hpp +++ b/deps/ox/src/ox/std/stacktrace.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/std.hpp b/deps/ox/src/ox/std/std.hpp index 9f55f50..be07312 100644 --- a/deps/ox/src/ox/std/std.hpp +++ b/deps/ox/src/ox/std/std.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -13,7 +13,7 @@ #include "assert.hpp" #include "bit.hpp" #include "bounds.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "byteswap.hpp" #include "concepts.hpp" #include "cstringview.hpp" @@ -26,6 +26,7 @@ #include "hardware.hpp" #include "hashmap.hpp" #include "heapmgr.hpp" +#include "ignore.hpp" #include "iterator.hpp" #include "math.hpp" #include "maybeview.hpp" diff --git a/deps/ox/src/ox/std/stddef.hpp b/deps/ox/src/ox/std/stddef.hpp index cd9041c..4f99881 100644 --- a/deps/ox/src/ox/std/stddef.hpp +++ b/deps/ox/src/ox/std/stddef.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/string.cpp b/deps/ox/src/ox/std/string.cpp index dc44f41..dca59e0 100644 --- a/deps/ox/src/ox/std/string.cpp +++ b/deps/ox/src/ox/std/string.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index af13780..c390868 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -13,6 +13,7 @@ #endif #include "algorithm.hpp" +#include "ignore.hpp" #include "memops.hpp" #include "serialize.hpp" #include "stringliteral.hpp" @@ -33,9 +34,6 @@ class BasicString { constexpr explicit BasicString(std::size_t cap) noexcept; - template - constexpr BasicString(char const (&str)[Sz]) noexcept; - constexpr explicit BasicString(const char *str) noexcept; constexpr explicit BasicString(const char8_t *str) noexcept; @@ -364,7 +362,7 @@ constexpr BasicString &BasicString::operat template constexpr BasicString &BasicString::operator+=(const char *str) noexcept { std::size_t strLen = ox::strlen(str); - oxIgnoreError(append(str, strLen)); + std::ignore = append(str, strLen); return *this; } @@ -389,13 +387,13 @@ constexpr BasicString &BasicString::operat template constexpr BasicString &BasicString::operator+=(StringView s) noexcept { std::size_t strLen = s.bytes(); - oxIgnoreError(append(s.data(), strLen)); + std::ignore = append(s.data(), strLen); return *this; } template constexpr BasicString &BasicString::operator+=(BasicString const&src) noexcept { - oxIgnoreError(append(src.c_str(), src.len())); + std::ignore = append(src.c_str(), src.len()); return *this; } @@ -591,4 +589,9 @@ constexpr auto alignOf(const ox::BasicString&) noexcept { return alignOf(&v); } +template +struct MaybeView> { + using type = ox::StringView; +}; + } diff --git a/deps/ox/src/ox/std/stringliteral.hpp b/deps/ox/src/ox/std/stringliteral.hpp index f777b5a..e6ddc4c 100644 --- a/deps/ox/src/ox/std/stringliteral.hpp +++ b/deps/ox/src/ox/std/stringliteral.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -30,10 +30,11 @@ class StringLiteral: public detail::BaseStringView { constexpr explicit StringLiteral(std::nullptr_t) noexcept {} - constexpr explicit StringLiteral(const char *str) noexcept: BaseStringView(str) {} - constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {} + constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral(str, ox::strlen(str)) { + } + constexpr auto &operator=(StringLiteral const&other) noexcept { if (&other != this) { set(other.data(), other.len()); diff --git a/deps/ox/src/ox/std/stringview.cpp b/deps/ox/src/ox/std/stringview.cpp index 7d053d4..b8a449b 100644 --- a/deps/ox/src/ox/std/stringview.cpp +++ b/deps/ox/src/ox/std/stringview.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/stringview.hpp b/deps/ox/src/ox/std/stringview.hpp index 06ca90f..63f57a9 100644 --- a/deps/ox/src/ox/std/stringview.hpp +++ b/deps/ox/src/ox/std/stringview.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -20,7 +20,7 @@ namespace ox { template -class BString; +class IString; template class BasicString; @@ -41,7 +41,7 @@ class StringView: public detail::BaseStringView { constexpr StringView(const BasicString &str) noexcept: BaseStringView(str.data(), str.len()) {} template - constexpr StringView(const BString &str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr StringView(const IString &str) noexcept: BaseStringView(str.data(), str.len()) {} constexpr StringView(std::nullptr_t) noexcept {} @@ -98,11 +98,6 @@ constexpr auto toStdStringView(CRStringView sv) noexcept { #endif -template -struct MaybeView { - using type = ox::StringView; -}; - constexpr ox::Result atoi(ox::CRStringView str) noexcept { int total = 0; int multiplier = 1; diff --git a/deps/ox/src/ox/std/strongint.hpp b/deps/ox/src/ox/std/strongint.hpp index a7c8593..6fc37dd 100644 --- a/deps/ox/src/ox/std/strongint.hpp +++ b/deps/ox/src/ox/std/strongint.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/strops.cpp b/deps/ox/src/ox/std/strops.cpp index 6396ddf..2bab557 100644 --- a/deps/ox/src/ox/std/strops.cpp +++ b/deps/ox/src/ox/std/strops.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/strops.hpp b/deps/ox/src/ox/std/strops.hpp index 84be901..afb650f 100644 --- a/deps/ox/src/ox/std/strops.hpp +++ b/deps/ox/src/ox/std/strops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -80,6 +80,7 @@ constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept { return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0; } +[[nodiscard]] constexpr std::size_t find(CRStringView str, char search) noexcept { std::size_t i = 0; for (; i < str.len(); ++i) { @@ -90,6 +91,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept { return i; } +[[nodiscard]] constexpr std::size_t find(CRStringView str, CRStringView search) noexcept { std::size_t i = 0; for (; i < str.len(); ++i) { @@ -101,6 +103,7 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept { } template +[[nodiscard]] constexpr ox::Vector split(CRStringView str, char del) noexcept { ox::Vector out; constexpr auto nextSeg = [](CRStringView current, char del) { @@ -117,6 +120,7 @@ constexpr ox::Vector split(CRStringView str, char del) } template +[[nodiscard]] constexpr ox::Vector split(CRStringView str, CRStringView del) noexcept { ox::Vector out; constexpr auto nextSeg = [](CRStringView current, CRStringView del) { diff --git a/deps/ox/src/ox/std/substitutes.cpp b/deps/ox/src/ox/std/substitutes.cpp index 3c5ff19..2adb2b3 100644 --- a/deps/ox/src/ox/std/substitutes.cpp +++ b/deps/ox/src/ox/std/substitutes.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index 14f8bdc..04a7363 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -68,7 +68,7 @@ static std::map tests = { { "BString", []() { - ox::BString<5> s; + ox::IString<5> s; s += "A"; s += "B"; s += 9; diff --git a/deps/ox/src/ox/std/trace.cpp b/deps/ox/src/ox/std/trace.cpp index 8354cf1..472c594 100644 --- a/deps/ox/src/ox/std/trace.cpp +++ b/deps/ox/src/ox/std/trace.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -37,7 +37,7 @@ void setLogger(Logger *logger) noexcept { } void send(const TraceMsg &msg) noexcept { - oxIgnoreError(logger->send(msg)); + std::ignore = logger->send(msg); } } diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index 6409ec7..de7c536 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ #include #endif -#include "bstring.hpp" +#include "istring.hpp" #include "def.hpp" #include "fmt.hpp" #include "hashmap.hpp" @@ -148,12 +148,12 @@ class OutStream { m_msg.line = line; m_msg.ch = ch; const auto &firstSegment = fmtSegments.segments[0]; - oxIgnoreError(m_msg.msg.append(firstSegment.str, firstSegment.length)); + std::ignore = m_msg.msg.append(firstSegment.str, firstSegment.length); //const detail::FmtArg elements[sizeof...(args)] = {args...}; for (size_t i = 0; auto const&e : std::initializer_list{elements...}) { m_msg.msg += e.out; const auto &s = fmtSegments.segments[i + 1]; - oxIgnoreError(m_msg.msg.append(s.str, s.length)); + std::ignore = m_msg.msg.append(s.str, s.length); ++i; } } @@ -182,7 +182,7 @@ class OutStream { } template - constexpr OutStream &operator<<(const BString &v) noexcept { + constexpr OutStream &operator<<(const IString &v) noexcept { return operator<<(v.c_str()); } diff --git a/deps/ox/src/ox/std/tracehook.cpp b/deps/ox/src/ox/std/tracehook.cpp index a0a0528..90743ec 100644 --- a/deps/ox/src/ox/std/tracehook.cpp +++ b/deps/ox/src/ox/std/tracehook.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/typeinfo.hpp b/deps/ox/src/ox/std/typeinfo.hpp index edfb6f7..b7d6df4 100644 --- a/deps/ox/src/ox/std/typeinfo.hpp +++ b/deps/ox/src/ox/std/typeinfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/types.hpp b/deps/ox/src/ox/std/types.hpp index 2361565..dcd2084 100644 --- a/deps/ox/src/ox/std/types.hpp +++ b/deps/ox/src/ox/std/types.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/typetraits.cpp b/deps/ox/src/ox/std/typetraits.cpp index 9fe9208..cfa0ba9 100644 --- a/deps/ox/src/ox/std/typetraits.cpp +++ b/deps/ox/src/ox/std/typetraits.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/typetraits.hpp b/deps/ox/src/ox/std/typetraits.hpp index fbc9270..3bfee6a 100644 --- a/deps/ox/src/ox/std/typetraits.hpp +++ b/deps/ox/src/ox/std/typetraits.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -143,7 +143,7 @@ template constexpr bool memberable(...) { return false; } template -struct is_class: integral_constant::value && memberable(0)> {}; +struct is_class: integral_constant && memberable(nullptr)> {}; namespace test { struct TestClass {int i;}; @@ -159,11 +159,11 @@ constexpr bool is_class_v = is_class(); template constexpr bool is_signed_v = integral_constant::value; -template -concept Signed_c = is_signed_v && sizeof(T) == 8 * bits; +template +concept Signed_c = is_signed_v && sizeof(T) == bits / 8; -template -concept Unsigned_c = !is_signed_v && sizeof(T) == 8 * bits; +template +concept Unsigned_c = !is_signed_v && sizeof(T) == bits / 8; template struct is_same: false_type {}; @@ -272,7 +272,7 @@ constexpr bool is_move_constructible_v = detail::is_move_constructible(0); template class BasicString; template -class BString; +class IString; class CStringView; class StringLiteral; class StringView; @@ -289,7 +289,7 @@ constexpr auto isOxString(const BasicString*) noexcept { } template -constexpr auto isOxString(const BString*) noexcept { +constexpr auto isOxString(const IString*) noexcept { return true; } diff --git a/deps/ox/src/ox/std/units.hpp b/deps/ox/src/ox/std/units.hpp index 1458a1c..6dc9b6b 100644 --- a/deps/ox/src/ox/std/units.hpp +++ b/deps/ox/src/ox/std/units.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/utility.hpp b/deps/ox/src/ox/std/utility.hpp index 42158c4..5a69405 100644 --- a/deps/ox/src/ox/std/utility.hpp +++ b/deps/ox/src/ox/std/utility.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -8,7 +8,27 @@ #pragma once +#if __has_include() +#include #include "typetraits.hpp" +#else +#include "typetraits.hpp" +namespace std { + +template +constexpr typename ox::remove_reference::type &&move(T &&t) noexcept { + return static_cast::type&&>(t); +} + +template +constexpr void swap(T &a, T &b) noexcept { + auto temp = std::move(a); + a = std::move(b); + b = std::move(temp); +} + +} +#endif namespace ox { @@ -30,14 +50,3 @@ constexpr T &&forward(remove_reference_t &&t) noexcept { } - -#if __has_include() -#include -#else -namespace std { -template -constexpr typename ox::remove_reference::type &&move(T &&t) noexcept { - return static_cast::type&&>(t); -} -} -#endif diff --git a/deps/ox/src/ox/std/uuid.cpp b/deps/ox/src/ox/std/uuid.cpp index d52178f..390717a 100644 --- a/deps/ox/src/ox/std/uuid.cpp +++ b/deps/ox/src/ox/std/uuid.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/uuid.hpp b/deps/ox/src/ox/std/uuid.hpp index 26fdccd..1d448ba 100644 --- a/deps/ox/src/ox/std/uuid.hpp +++ b/deps/ox/src/ox/std/uuid.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -9,7 +9,7 @@ #pragma once #include "array.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "buffer.hpp" #include "random.hpp" #include "ranges.hpp" @@ -17,7 +17,7 @@ namespace ox { -using UUIDStr = ox::BString<36>; +using UUIDStr = ox::IString<36>; namespace detail { @@ -61,7 +61,7 @@ constexpr ox::Result fromHex(ox::CRStringView v) noexcept { return out; } -constexpr ox::BString<2> toHex(uint8_t v) noexcept { +constexpr ox::IString<2> toHex(uint8_t v) noexcept { constexpr ox::Array valMap { '0', '1', @@ -155,7 +155,7 @@ class UUID { for (auto i = 0u; i < cnt; ++i) { const auto v = value[valueI]; const auto h = detail::toHex(v); - oxIgnoreError(writer.write(h.c_str(), h.len())); + std::ignore = writer.write(h.c_str(), h.len()); ++valueI; } }; @@ -175,7 +175,7 @@ class UUID { constexpr UUIDStr toString() const noexcept { UUIDStr out; ox::CharBuffWriter bw(out.data(), out.cap()); - oxIgnoreError(toString(bw)); + std::ignore = toString(bw); out[out.cap()] = 0; return out; } diff --git a/deps/ox/src/ox/std/vec.cpp b/deps/ox/src/ox/std/vec.cpp index d536966..6da9c75 100644 --- a/deps/ox/src/ox/std/vec.cpp +++ b/deps/ox/src/ox/std/vec.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/vec.hpp b/deps/ox/src/ox/std/vec.hpp index 35ecad9..1d22c69 100644 --- a/deps/ox/src/ox/std/vec.hpp +++ b/deps/ox/src/ox/std/vec.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index 05f377a..7d649c9 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 @@ -52,13 +52,15 @@ struct VectorAllocator { const std::size_t cap) noexcept { // this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM, // try removing it later - if (cap <= m_data.size() && count <= m_data.size()) { - for (auto i = 0u; i < count; ++i) { - const auto dstItem = reinterpret_cast(&m_data[i]); - const auto srcItem = reinterpret_cast(&src->m_data[i]); - std::construct_at(dstItem, std::move(*srcItem)); + if (!std::is_constant_evaluated()) { + if (cap <= m_data.size() && count <= m_data.size()) { + for (auto i = 0u; i < count; ++i) { + const auto dstItem = reinterpret_cast(&m_data[i]); + const auto srcItem = reinterpret_cast(&src->m_data[i]); + std::construct_at(dstItem, std::move(*srcItem)); + } + *items = reinterpret_cast(m_data.data()); } - *items = reinterpret_cast(m_data.data()); } } @@ -69,20 +71,24 @@ struct VectorAllocator { const std::size_t cap) noexcept { // this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM, // try removing it later - if (cap <= m_data.size() && count <= m_data.size()) { - for (std::size_t i = 0; i < count; ++i) { - const auto dstItem = reinterpret_cast(&m_data[i]); - const auto srcItem = reinterpret_cast(&src->m_data[i]); - *dstItem = std::move(*srcItem); + if (!std::is_constant_evaluated()) { + if (cap <= m_data.size() && count <= m_data.size()) { + for (std::size_t i = 0; i < count; ++i) { + const auto dstItem = reinterpret_cast(&m_data[i]); + const auto srcItem = reinterpret_cast(&src->m_data[i]); + *dstItem = std::move(*srcItem); + } + *items = reinterpret_cast(m_data.data()); } - *items = reinterpret_cast(m_data.data()); } } constexpr void deallocate(T *items, std::size_t cap) noexcept { // small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr - if (std::is_constant_evaluated() || (items && static_cast(items) != static_cast(m_data.data()))) { - m_allocator.deallocate(items, cap); + if (std::is_constant_evaluated()) { + if (items && static_cast(items) != static_cast(m_data.data())) { + m_allocator.deallocate(items, cap); + } } } @@ -263,12 +269,12 @@ class Vector: detail::VectorAllocator { } [[nodiscard]] - constexpr bool contains(MaybeView_t const&) const noexcept(useNoexcept); + constexpr bool contains(MaybeView_t const&) const noexcept; constexpr iterator insert( - std::size_t pos, std::size_t cnt, MaybeView_t const&val) noexcept(useNoexcept); + std::size_t pos, std::size_t cnt, T val) noexcept(useNoexcept); - constexpr iterator insert(std::size_t pos, MaybeView_t const&val) noexcept(useNoexcept); + constexpr iterator insert(std::size_t pos, T val) noexcept(useNoexcept); template constexpr iterator emplace(std::size_t pos, Args&&... args) noexcept(useNoexcept); @@ -276,9 +282,7 @@ class Vector: detail::VectorAllocator { template constexpr T &emplace_back(Args&&... args) noexcept(useNoexcept); - constexpr void push_back(T &&item) noexcept(useNoexcept); - - constexpr void push_back(MaybeView_t const&item) noexcept(useNoexcept); + constexpr void push_back(T item) noexcept(useNoexcept); constexpr void pop_back() noexcept(useNoexcept); @@ -516,8 +520,8 @@ constexpr void Vector::resize(std::size_t size) n } template -constexpr bool Vector::contains(MaybeView_t const&v) const noexcept(useNoexcept) { - for (std::size_t i = 0; i < m_size; i++) { +constexpr bool Vector::contains(MaybeView_t const&v) const noexcept { + for (std::size_t i = 0; i < m_size; ++i) { if (m_items[i] == v) { return true; } @@ -528,14 +532,14 @@ constexpr bool Vector::contains(MaybeView_t co template constexpr typename Vector::template iterator Vector::insert( - std::size_t pos, std::size_t cnt, MaybeView_t const&val) noexcept(useNoexcept) { + std::size_t pos, std::size_t cnt, T val) noexcept(useNoexcept) { if (m_size + cnt > m_cap) { reserveInsert(m_cap ? m_size + cnt : initialCap, pos, cnt); if (pos < m_size) { - m_items[pos] = val; + m_items[pos] = std::move(val); } else { for (auto i = 0u; i < cnt; ++i) { - std::construct_at(&m_items[pos + i], val); + std::construct_at(&m_items[pos + i], m_items[pos]); } } } else { @@ -543,10 +547,10 @@ Vector::insert( for (auto i = m_size + cnt - 1; i > pos; --i) { std::construct_at(&m_items[i], std::move(m_items[i - cnt])); } - m_items[pos] = val; + m_items[pos] = std::move(val); } else { for (auto i = 0u; i < cnt; ++i) { - std::construct_at(&m_items[pos + i], val); + std::construct_at(&m_items[pos + i], m_items[pos]); } } } @@ -556,22 +560,22 @@ Vector::insert( template constexpr typename Vector::template iterator -Vector::insert(std::size_t pos, MaybeView_t const&val) noexcept(useNoexcept) { +Vector::insert(std::size_t pos, T val) noexcept(useNoexcept) { if (m_size == m_cap) { reserveInsert(m_cap ? m_cap * 2 : initialCap, pos); if (pos < m_size) { - m_items[pos] = val; + m_items[pos] = std::move(val); } else { - std::construct_at(&m_items[pos], val); + std::construct_at(&m_items[pos], m_items[pos]); } } else { if (pos < m_size) { for (auto i = m_size; i > pos; --i) { std::construct_at(&m_items[i], std::move(m_items[i - 1])); } - m_items[pos] = val; + m_items[pos] = std::move(val); } else { - std::construct_at(&m_items[pos], val); + std::construct_at(&m_items[pos], m_items[pos]); } } ++m_size; @@ -613,7 +617,7 @@ constexpr T &Vector::emplace_back(Args&&... args) } template -constexpr void Vector::push_back(T &&item) noexcept(useNoexcept) { +constexpr void Vector::push_back(T item) noexcept(useNoexcept) { if (m_size == m_cap) { reserve(m_cap ? m_cap * 2 : initialCap); } @@ -621,15 +625,6 @@ constexpr void Vector::push_back(T &&item) noexce ++m_size; } -template -constexpr void Vector::push_back(MaybeView_t const&item) noexcept(useNoexcept) { - if (m_size == m_cap) { - reserve(m_cap ? m_cap * 2 : initialCap); - } - std::construct_at(&m_items[m_size], item); - ++m_size; -} - template constexpr void Vector::pop_back() noexcept(useNoexcept) { --m_size; diff --git a/deps/ox/src/ox/std/writer.hpp b/deps/ox/src/ox/std/writer.hpp index 53fbb7a..9f75cf0 100644 --- a/deps/ox/src/ox/std/writer.hpp +++ b/deps/ox/src/ox/std/writer.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2024 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 diff --git a/developer-handbook.md b/developer-handbook.md index a614205..58ebe61 100644 --- a/developer-handbook.md +++ b/developer-handbook.md @@ -222,8 +222,8 @@ int caller2() { ``` Lastly, there are a few macros available to help in passing ```ox::Error```s -back up the call stack, ```oxReturnError```, ```oxThrowError```, -```oxIgnoreError```, and ```oxRequire```. +back up the call stack, ```oxReturnError```, ```oxThrowError```, and +```oxRequire```. ```oxReturnError``` is by far the more helpful of the two. ```oxReturnError``` will return an ```ox::Error``` if it is not 0 and @@ -232,13 +232,10 @@ Because exceptions are disabled for GBA builds and thus cannot be used in the engine, ```oxThrowError``` is only really useful at the boundary between engine libraries and Nostalgia Studio. -```oxIgnoreError``` does what it says, it ignores the error. Since ```ox::Error``` is always nodiscard, you must do something with them. -In extremely rare cases, you may not have anything you can do with them or you -may know the code will never fail in that particular instance. -This should be used very sparingly. -At the time of this writing, it has only been used 4 times in 20,000 lines of -code. +In rare cases, you may not have anything you can do with them or you may know +the code will never fail in that particular instance. +This should be used sparingly. ```cpp @@ -257,7 +254,7 @@ ox::Error engineCode() noexcept { void anyCode() { auto [val, err] = foo(1); - oxIgnoreError(err); + std::ignore = err; doStuff(val); } ``` diff --git a/src/nostalgia/modules/core/src/gba/panic.cpp b/src/nostalgia/modules/core/src/gba/panic.cpp index d5c5537..67eaa70 100644 --- a/src/nostalgia/modules/core/src/gba/panic.cpp +++ b/src/nostalgia/modules/core/src/gba/panic.cpp @@ -28,11 +28,11 @@ void panic(const char *file, int line, const char *panicMsg, ox::Error const&err ox::heapmgr::initHeap(HEAP_BEGIN, HEAP_END); auto tctx = turbine::init(keel::loadRomFs("").unwrap(), "Nostalgia").unwrap(); auto ctx = init(*tctx).unwrap(); - oxIgnoreError(initGfx(*ctx, {})); - oxIgnoreError(initConsole(*ctx)); + std::ignore = initGfx(*ctx, {}); + std::ignore = initConsole(*ctx); setBgStatus(*ctx, 0, true); clearBg(*ctx, 0); - ox::BString<23> serr = "Error code: "; + ox::IString<23> serr = "Error code: "; serr += static_cast(err); puts(*ctx, 32 + 1, 1, "SADNESS..."); puts(*ctx, 32 + 1, 4, "UNEXPECTED STATE:"); diff --git a/src/nostalgia/modules/core/src/keel/keelmodule.cpp b/src/nostalgia/modules/core/src/keel/keelmodule.cpp index 7488528..cc59d50 100644 --- a/src/nostalgia/modules/core/src/keel/keelmodule.cpp +++ b/src/nostalgia/modules/core/src/keel/keelmodule.cpp @@ -14,7 +14,7 @@ namespace nostalgia::core { -class KeelModule: public keel::Module { +static class: public keel::Module { private: NostalgiaPaletteToPaletteV1Converter m_nostalgiaPaletteToPaletteV1Converter; PaletteV1ToPaletteV2Converter m_paletteV1ToPaletteV2Converter; @@ -62,11 +62,11 @@ class KeelModule: public keel::Module { oxRequire(hdr, keel::readAssetHeader(buff)); auto const typeId = ox::buildTypeId( hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); - if (typeId == ox::buildTypeId() || - typeId == ox::buildTypeId() || - typeId == ox::buildTypeId() || - typeId == ox::buildTypeId()) { - oxReturnError(keel::convertBuffToBuff( + if (typeId == ox::ModelTypeId_v || + typeId == ox::ModelTypeId_v || + typeId == ox::ModelTypeId_v || + typeId == ox::ModelTypeId_v) { + oxReturnError(keel::convertBuffToBuff( ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); } return {}; @@ -75,19 +75,18 @@ class KeelModule: public keel::Module { oxRequire(hdr, keel::readAssetHeader(buff)); auto const typeId = ox::buildTypeId( hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); - if (typeId == ox::buildTypeId() || - typeId == ox::buildTypeId()) { - oxReturnError(keel::convertBuffToBuff( + if (typeId == ox::ModelTypeId_v || + typeId == ox::ModelTypeId_v) { + oxReturnError(keel::convertBuffToBuff( ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); } return {}; }, }; } -}; +} mod; -static const KeelModule mod; -const keel::Module *keelModule() noexcept { +keel::Module const*keelModule() noexcept { return &mod; } diff --git a/src/nostalgia/modules/core/src/opengl/gfx.cpp b/src/nostalgia/modules/core/src/opengl/gfx.cpp index 2a5add0..5a220c3 100644 --- a/src/nostalgia/modules/core/src/opengl/gfx.cpp +++ b/src/nostalgia/modules/core/src/opengl/gfx.cpp @@ -239,6 +239,7 @@ static void initSpritesBufferset(Context &ctx) noexcept { glEnableVertexAttribArray(texCoordAttr); glVertexAttribPointer(texCoordAttr, 2, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float), std::bit_cast(uintptr_t{4 * sizeof(float)})); + glBindVertexArray(0); } static void initBackgroundBufferset( @@ -272,6 +273,7 @@ static void initBackgroundBufferset( glVertexAttribPointer( palBankAttr, 1, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float), std::bit_cast(uintptr_t{6 * sizeof(float)})); + glBindVertexArray(0); } static glutils::GLTexture createTexture( @@ -301,6 +303,7 @@ static void drawBackground(CBB &cbb) noexcept { } glBindTexture(GL_TEXTURE_2D, cbb.tex); glDrawElements(GL_TRIANGLES, static_cast(cbb.elements.size()), GL_UNSIGNED_INT, nullptr); + glBindVertexArray(0); } static void drawBackgrounds( @@ -354,6 +357,7 @@ static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept { // draw glBindTexture(GL_TEXTURE_2D, sb.tex); glDrawElements(GL_TRIANGLES, static_cast(sb.elements.size()), GL_UNSIGNED_INT, nullptr); + glBindVertexArray(0); } static void loadPalette( diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp index 9ecc7e6..e81b55c 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp @@ -19,7 +19,7 @@ void AddPageCommand::redo() noexcept { } void AddPageCommand::undo() noexcept { - oxIgnoreError(m_pal.pages.erase(static_cast(m_pal.pages.size() - 1))); + std::ignore = m_pal.pages.erase(static_cast(m_pal.pages.size() - 1)); } @@ -43,7 +43,7 @@ void DuplicatePageCommand::redo() noexcept { void DuplicatePageCommand::undo() noexcept { m_page = std::move(m_pal.pages[m_dstIdx]); - oxIgnoreError(m_pal.pages.erase(static_cast(m_dstIdx))); + std::ignore = m_pal.pages.erase(static_cast(m_dstIdx)); } size_t DuplicatePageCommand::insertIdx() const noexcept { @@ -62,7 +62,7 @@ int RemovePageCommand::commandId() const noexcept { void RemovePageCommand::redo() noexcept { m_page = std::move(m_pal.pages[m_idx]); - oxIgnoreError(m_pal.pages.erase(static_cast(m_idx))); + std::ignore = m_pal.pages.erase(static_cast(m_idx)); } void RemovePageCommand::undo() noexcept { @@ -86,7 +86,7 @@ void AddColorCommand::redo() noexcept { } void AddColorCommand::undo() noexcept { - oxIgnoreError(m_pal->pages[m_page].erase(static_cast(m_idx))); + std::ignore = m_pal->pages[m_page].erase(static_cast(m_idx)); } @@ -102,7 +102,7 @@ int RemoveColorCommand::commandId() const noexcept { } void RemoveColorCommand::redo() noexcept { - oxIgnoreError(m_pal->pages[m_page].erase(static_cast(m_idx))); + std::ignore = m_pal->pages[m_page].erase(static_cast(m_idx)); } void RemoveColorCommand::undo() noexcept { @@ -171,8 +171,8 @@ void MoveColorCommand::undo() noexcept { void MoveColorCommand::moveColor(int idx, int offset) noexcept { const auto c = m_pal->pages[m_page][static_cast(idx)]; - oxIgnoreError(m_pal->pages[m_page].erase(static_cast(idx))); + std::ignore = m_pal->pages[m_page].erase(static_cast(idx)); m_pal->pages[m_page].insert(static_cast(idx + offset), c); } -} \ No newline at end of file +} diff --git a/src/nostalgia/modules/core/src/studio/studiomodule.cpp b/src/nostalgia/modules/core/src/studio/studiomodule.cpp index 10c7610..bba778b 100644 --- a/src/nostalgia/modules/core/src/studio/studiomodule.cpp +++ b/src/nostalgia/modules/core/src/studio/studiomodule.cpp @@ -11,7 +11,7 @@ namespace nostalgia::core { -class StudioModule: public studio::Module { +static class: public studio::Module { ox::Vector editors(studio::StudioContext &ctx) const noexcept final { return { studio::editorMaker(ctx, FileExt_ng), @@ -25,9 +25,8 @@ class StudioModule: public studio::Module { out.emplace_back(ox::make>("Palette", "Palettes", FileExt_npal)); return out; } -}; +} mod; -static StudioModule mod; const studio::Module *studioModule() noexcept { return &mod; } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/palettechangecommand.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/palettechangecommand.cpp index 7c41bb4..4503eef 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/palettechangecommand.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/palettechangecommand.cpp @@ -13,7 +13,7 @@ core::PaletteChangeCommand::PaletteChangeCommand( m_img(img), m_idx(std::move(idx)), m_oldPalette(m_img.defaultPalette), - m_newPalette(ox::FileAddress(ox::sfmt>("uuid://{}", newPalette))) { + m_newPalette(ox::FileAddress(ox::sfmt>("uuid://{}", newPalette))) { } void PaletteChangeCommand::redo() noexcept { diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index ecfe439..a2c91f0 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -81,7 +81,7 @@ TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &sctx, ox::CRSt m_tctx(m_sctx.tctx), m_view(m_sctx, path, *undoStack()), m_model(m_view.model()) { - oxIgnoreError(setPaletteSelection()); + std::ignore = setPaletteSelection(); // connect signal/slots undoStack()->changeTriggered.connect(this, &TileSheetEditorImGui::markUnsavedChanges); m_subsheetEditor.inputSubmitted.connect(this, &TileSheetEditorImGui::updateActiveSubsheet); @@ -342,13 +342,14 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept { } else if (m_view.updated()) { m_view.ackUpdate(); } - glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); - // clear screen and draw - glViewport(0, 0, fbSizei.width, fbSizei.height); - m_view.draw(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + { + glutils::FrameBufferBind const frameBufferBind(m_framebuffer); + // clear screen and draw + glViewport(0, 0, fbSizei.width, fbSizei.height); + m_view.draw(); + } ImGui::Image( - std::bit_cast(uintptr_t{m_framebuffer.color.id}), + ig::toImTextureID(m_framebuffer.color.id), static_cast(fbSize), ImVec2(0, 1), ImVec2(1, 0)); @@ -439,7 +440,7 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept { ImGui::PushID(static_cast(i)); // Column: color idx ImGui::TableNextColumn(); - auto const label = ox::BString<8>() + (i + 1); + auto const label = ox::IString<8>() + (i + 1); auto const rowSelected = i == m_view.palIdx(); if (ImGui::Selectable(label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) { m_view.setPalIdx(i); diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp index 6a54587..dc9b2c0 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp @@ -28,7 +28,7 @@ class TileSheetEditorImGui: public studio::Editor { private: class SubSheetEditor { private: - ox::BString<100> m_name; + ox::IString<100> m_name; int m_cols = 0; int m_rows = 0; bool m_show = false; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp index ec618a5..666ce14 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp @@ -14,6 +14,7 @@ namespace nostalgia::core { TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack): m_model(sctx, path, undoStack), m_pixelsDrawer(m_model) { + glBindVertexArray(0); // build shaders oxThrowError(m_pixelsDrawer.buildShader()); oxThrowError(m_pixelGridDrawer.buildShader()); diff --git a/src/nostalgia/modules/scene/src/keel/keelmodule.cpp b/src/nostalgia/modules/scene/src/keel/keelmodule.cpp index ec542fb..534d584 100644 --- a/src/nostalgia/modules/scene/src/keel/keelmodule.cpp +++ b/src/nostalgia/modules/scene/src/keel/keelmodule.cpp @@ -10,7 +10,7 @@ namespace nostalgia::scene { -class SceneModule: public keel::Module { +static class: public keel::Module { private: SceneDocToSceneStaticConverter m_sceneDocToSceneStaticConverter; @@ -42,9 +42,8 @@ class SceneModule: public keel::Module { }; } -}; +} mod; -static const SceneModule mod; const keel::Module *keelModule() noexcept { return &mod; } diff --git a/src/nostalgia/modules/scene/src/studio/studiomodule.cpp b/src/nostalgia/modules/scene/src/studio/studiomodule.cpp index eb840ad..e622c5a 100644 --- a/src/nostalgia/modules/scene/src/studio/studiomodule.cpp +++ b/src/nostalgia/modules/scene/src/studio/studiomodule.cpp @@ -10,7 +10,7 @@ namespace nostalgia::scene { constexpr ox::StringLiteral FileExt_nscn("nscn"); -class StudioModule: public studio::Module { +static class: public studio::Module { public: ox::Vector editors(studio::StudioContext &ctx) const noexcept override { return { @@ -21,9 +21,8 @@ class StudioModule: public studio::Module { ox::Vector> out; return out; } -}; +} mod; -static StudioModule const mod; const studio::Module *studioModule() noexcept { return &mod; } diff --git a/src/olympic/keel/include/keel/assetmanager.hpp b/src/olympic/keel/include/keel/assetmanager.hpp index f27667f..b13a131 100644 --- a/src/olympic/keel/include/keel/assetmanager.hpp +++ b/src/olympic/keel/include/keel/assetmanager.hpp @@ -117,7 +117,7 @@ class AssetRef: public ox::SignalHandler { } if (m_ctr) { m_ctr->decRefs(); - oxIgnoreError(m_ctr->updated.disconnectObject(this)); + std::ignore = m_ctr->updated.disconnectObject(this); } m_ctr = h.m_ctr; if (m_ctr) { @@ -133,11 +133,11 @@ class AssetRef: public ox::SignalHandler { } if (m_ctr) { m_ctr->decRefs(); - oxIgnoreError(m_ctr->updated.disconnectObject(this)); + std::ignore = m_ctr->updated.disconnectObject(this); } m_ctr = h.m_ctr; if (m_ctr) { - oxIgnoreError(m_ctr->updated.disconnectObject(&h)); + std::ignore = m_ctr->updated.disconnectObject(&h); m_ctr->updated.connect(this, &AssetRef::emitUpdated); } h.m_ctr = nullptr; diff --git a/src/olympic/keel/include/keel/typeconv.hpp b/src/olympic/keel/include/keel/typeconv.hpp index aa9ca38..3523948 100644 --- a/src/olympic/keel/include/keel/typeconv.hpp +++ b/src/olympic/keel/include/keel/typeconv.hpp @@ -160,7 +160,7 @@ auto transformRule(keel::Context &ctx, ox::Buffer &buff) noexcept -> ox::Error { oxRequire(hdr, readAssetHeader(buff)); const auto typeId = ox::buildTypeId( hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); - if (typeId == ox::buildTypeId()) { + if (typeId == ox::ModelTypeId_v) { oxReturnError(keel::convertBuffToBuff(ctx, buff, fmt).moveTo(buff)); } return {}; diff --git a/src/olympic/keel/src/keel.cpp b/src/olympic/keel/src/keel.cpp index 1a5700d..894069f 100644 --- a/src/olympic/keel/src/keel.cpp +++ b/src/olympic/keel/src/keel.cpp @@ -11,7 +11,7 @@ ox::Error init( ox::UPtr &&fs, ox::CRStringView appName) noexcept { ctx.appName = appName; - oxIgnoreError(setRomFs(ctx, std::move(fs))); + std::ignore = setRomFs(ctx, std::move(fs)); #ifndef OX_BARE_METAL auto const&mods = modules(); for (auto &mod : mods) { diff --git a/src/olympic/studio/applib/src/main.cpp b/src/olympic/studio/applib/src/main.cpp index 8548220..be05412 100644 --- a/src/olympic/studio/applib/src/main.cpp +++ b/src/olympic/studio/applib/src/main.cpp @@ -56,7 +56,7 @@ static ox::Error runApp( return err; } -ox::Error run( +static ox::Error run( ox::CRStringView appName, ox::CRStringView projectDataDir, int, diff --git a/src/olympic/studio/applib/src/newmenu.hpp b/src/olympic/studio/applib/src/newmenu.hpp index 2852ddc..658e72e 100644 --- a/src/olympic/studio/applib/src/newmenu.hpp +++ b/src/olympic/studio/applib/src/newmenu.hpp @@ -28,7 +28,7 @@ class NewMenu: public studio::Popup { private: Stage m_stage = Stage::Closed; ox::String m_typeName; - ox::BString<255> m_itemName; + ox::IString<255> m_itemName; ox::Vector> m_types; int m_selectedType = 0; bool m_open = false; diff --git a/src/olympic/studio/applib/src/newproject.hpp b/src/olympic/studio/applib/src/newproject.hpp index 6aad38e..eae284d 100644 --- a/src/olympic/studio/applib/src/newproject.hpp +++ b/src/olympic/studio/applib/src/newproject.hpp @@ -28,7 +28,7 @@ class NewProject: public studio::Popup { Stage m_stage = Stage::Closed; ox::String const m_projectDataDir; ox::String m_projectPath; - ox::BString<255> m_projectName; + ox::IString<255> m_projectName; ox::Vector> m_types; bool m_open = false; diff --git a/src/olympic/studio/applib/src/studioapp.cpp b/src/olympic/studio/applib/src/studioapp.cpp index d4b8678..22daae1 100644 --- a/src/olympic/studio/applib/src/studioapp.cpp +++ b/src/olympic/studio/applib/src/studioapp.cpp @@ -417,10 +417,10 @@ ox::Error StudioUI::closeFile(ox::CRStringView path) noexcept { if (!m_openFiles.contains(path)) { return {}; } - oxIgnoreError(m_openFiles.erase(std::remove(m_openFiles.begin(), m_openFiles.end(), path))); + std::ignore = m_openFiles.erase(std::remove(m_openFiles.begin(), m_openFiles.end(), path)); // save to config studio::editConfig(keelCtx(m_ctx), [&](StudioConfig *config) { - oxIgnoreError(config->openFiles.erase(std::remove(config->openFiles.begin(), config->openFiles.end(), path))); + std::ignore = config->openFiles.erase(std::remove(config->openFiles.begin(), config->openFiles.end(), path)); }); return {}; } diff --git a/src/olympic/studio/modlib/include/studio/imguiutil.hpp b/src/olympic/studio/modlib/include/studio/imguiutil.hpp index aff6db8..8038660 100644 --- a/src/olympic/studio/modlib/include/studio/imguiutil.hpp +++ b/src/olympic/studio/modlib/include/studio/imguiutil.hpp @@ -8,6 +8,8 @@ #include +#include + #include #include @@ -15,6 +17,91 @@ namespace studio::ig { inline constexpr auto BtnSz = ImVec2{52, 22}; + +constexpr ImTextureID toImTextureID(ox::Unsigned_c auto id) noexcept + requires(sizeof(id) <= sizeof(ox::Uint)) { + return std::bit_cast(ox::Uint{id}); +} + +template +ox::Result getDragDropPayload(ox::CStringView name) noexcept { + auto const payload = ImGui::AcceptDragDropPayload(name.c_str()); + if (!payload) { + return OxError(1, "No drag/drop payload"); + } + return ox::readClaw( + reinterpret_cast(payload->Data), + static_cast(payload->DataSize)); +} + +ox::Error setDragDropPayload(ox::CStringView name, auto const &obj) noexcept { + oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal)); + ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size()); + return {}; +} + + +class DragDropSource { + private: + bool const m_active{}; + public: + inline DragDropSource() noexcept: + m_active(ImGui::BeginDragDropSource()) { + } + inline ~DragDropSource() noexcept { + if (m_active) { + ImGui::EndDragDropSource(); + } + } + constexpr operator bool() const noexcept { + return m_active; + } +}; + +inline auto dragDropSource(auto const&cb) noexcept { + if constexpr(ox::is_same_v) { + if (ig::DragDropSource const tgt; tgt) [[unlikely]] { + return cb(); + } + } else { + if (ig::DragDropSource const tgt; tgt) [[unlikely]] { + cb(); + } + } +} + + +class DragDropTarget { + private: + bool const m_active{}; + public: + inline DragDropTarget() noexcept: + m_active(ImGui::BeginDragDropTarget()) { + } + inline ~DragDropTarget() noexcept { + if (m_active) { + ImGui::EndDragDropTarget(); + } + } + constexpr operator bool() const noexcept { + return m_active; + } +}; + +inline auto dragDropTarget(auto const&cb) noexcept { + if constexpr(ox::is_same_v) { + if (ig::DragDropTarget const tgt; tgt) [[unlikely]] { + return cb(); + } + return ox::Error{}; + } else { + if (ig::DragDropTarget const tgt; tgt) [[unlikely]] { + cb(); + } + } +} + + class ChildStackItem { public: explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept; diff --git a/src/olympic/studio/modlib/src/filedialog_nfd.cpp b/src/olympic/studio/modlib/src/filedialog_nfd.cpp index dfdcd92..e010259 100644 --- a/src/olympic/studio/modlib/src/filedialog_nfd.cpp +++ b/src/olympic/studio/modlib/src/filedialog_nfd.cpp @@ -24,7 +24,7 @@ static ox::Result toResult(nfdresult_t r, NFD::UniquePathN const&pat ox::String out; for (auto i = 0u; path.get()[i]; ++i) { auto const c = static_cast(path.get()[i]); - oxIgnoreError(out.append(&c, 1)); + std::ignore = out.append(&c, 1); } return out; } diff --git a/src/olympic/studio/modlib/src/task.cpp b/src/olympic/studio/modlib/src/task.cpp index e25cacf..b966ee3 100644 --- a/src/olympic/studio/modlib/src/task.cpp +++ b/src/olympic/studio/modlib/src/task.cpp @@ -9,13 +9,13 @@ namespace studio { void TaskRunner::update(turbine::Context &ctx) noexcept { - oxIgnoreError(m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](ox::UPtr &t) { + std::ignore = m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](ox::UPtr &t) { auto const done = t->update(ctx) == TaskState::Done; if (done) { t->finished.emit(); } return done; - }))); + })); } void TaskRunner::add(Task &task) noexcept { diff --git a/src/olympic/studio/modlib/src/undostack.cpp b/src/olympic/studio/modlib/src/undostack.cpp index 7468774..ac5031b 100644 --- a/src/olympic/studio/modlib/src/undostack.cpp +++ b/src/olympic/studio/modlib/src/undostack.cpp @@ -12,7 +12,7 @@ bool UndoCommand::mergeWith(UndoCommand const*) noexcept { void UndoStack::push(ox::UPtr &&cmd) noexcept { for (auto const i = m_stackIdx; i < m_stack.size();) { - oxIgnoreError(m_stack.erase(i)); + std::ignore = m_stack.erase(i); } cmd->redo(); redoTriggered.emit(cmd.get()); diff --git a/src/olympic/turbine/src/glfw/gfx.cpp b/src/olympic/turbine/src/glfw/gfx.cpp index c6e531f..e3883f2 100644 --- a/src/olympic/turbine/src/glfw/gfx.cpp +++ b/src/olympic/turbine/src/glfw/gfx.cpp @@ -22,7 +22,7 @@ void addDrawer(Context &ctx, Drawer *cd) noexcept { void removeDrawer(Context &ctx, Drawer *cd) noexcept { for (auto i = 0u; i < ctx.drawers.size(); ++i) { if (ctx.drawers[i] == cd) { - oxIgnoreError(ctx.drawers.erase(i)); + std::ignore = ctx.drawers.erase(i); break; } }