9 Commits

Author SHA1 Message Date
e4d99ad455 lil continue 2022-08-02 14:42:31 +02:00
82faf448f4 working on some hacky randering 2022-08-02 14:42:31 +02:00
76161df6cd mult frames in flight 2022-08-02 14:42:31 +02:00
a0024b34e9 main loop and sync 2022-08-02 14:42:31 +02:00
525db7fe6b refactor, move vulkan to proper location 2022-08-02 14:42:31 +02:00
cab146ac45 hack in framebuffers 2022-08-02 14:42:31 +02:00
695e2e5486 views 2022-08-02 14:42:31 +02:00
808822e70b start refactoring 2022-08-02 14:42:31 +02:00
e55808b32f next try, this time with vk headers and hpp 2022-08-02 14:42:31 +02:00
177 changed files with 1704 additions and 2982 deletions

View File

@ -9,8 +9,6 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug
EM_VERSION: 3.1.32
EM_CACHE_FOLDER: 'emsdk-cache'
jobs:
linux:
@ -22,12 +20,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
submodules: recursive
# TODO: cache
- name: Install Dependencies
run: sudo apt update && sudo apt -y install libsdl2-dev xserver-xorg-video-dummy
run: sudo apt update && sudo apt -y install libsdl2-dev
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
@ -35,20 +35,11 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
#- name: Test
#working-directory: ${{github.workspace}}/build
## Execute tests defined by the CMake configuration.
## See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
#run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
# TODO: look into xinit
env:
DISPLAY: :0
run: |
sudo Xorg :0 -config ${{github.workspace}}/.github/workflows/x/dummy-1920x1080.conf -noautoBindGPU &
sleep 20s
ctest --output-on-failure --timeout 20
sudo pkill -15 Xorg
linux_gles:
timeout-minutes: 10
@ -56,10 +47,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
submodules: recursive
# TODO: cache
- name: Install Dependencies
run: sudo apt update && sudo apt -y install libsdl2-dev
@ -69,64 +62,18 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
linux_tracy:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Dependencies
run: sudo apt update && sudo apt -y install libsdl2-dev
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DTRACY_ENABLE=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
emscripten:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
with:
# Make sure to set a version number!
version: ${{env.EM_VERSION}}
# This is the name of the cache folder.
# The cache folder will be placed in the build directory,
# so make sure it doesn't conflict with anything!
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Verify
run: emcc --check
- name: Configure CMake
run: emcmake cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DMM_OPENGL_3_GLES=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
macos:
timeout-minutes: 10
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
submodules: recursive
# TODO: cache
- name: Install Dependencies
run: brew install sdl2
@ -136,28 +83,30 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
windows:
timeout-minutes: 15 # TODO: caching
# TODO: for some reason vcpkg find sdl does not work, despite the find_package REQUIRE not failing
#windows:
#timeout-minutes: 10
runs-on: windows-latest
#runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
#steps:
#- uses: actions/checkout@v2
#with:
#submodules: recursive
# TODO: cache
- name: Install Dependencies
run: vcpkg install sdl2[core,vulkan]:x64-windows
## TODO: cache
# setup vs env
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
#- name: Install Dependencies
#run: vcpkg install sdl2:x64-windows
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
## setup vs env
#- uses: ilammy/msvc-dev-cmd@v1
#with:
#arch: amd64
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
#- name: Configure CMake
#run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
#- name: Build
#run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4

View File

@ -1,21 +0,0 @@
# https://wiki.archlinux.org/title/Xorg
Section "Monitor"
Identifier "dummy_monitor"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
EndSection
Section "Device"
Identifier "dummy_card"
VideoRam 256000
Driver "dummy"
EndSection
Section "Screen"
Identifier "dummy_screen"
Device "dummy_card"
Monitor "dummy_monitor"
SubSection "Display"
EndSubSection
EndSection

4
.gitmodules vendored
View File

@ -37,3 +37,7 @@
path = external/physfs/physfs
url = https://github.com/icculus/physfs.git
branch = main
[submodule "external/Vulkan-Headers"]
path = external/Vulkan-Headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
shallow = true

View File

@ -1,28 +0,0 @@
{
"configurations": {
"run_ctest_native": {
"default": true,
"adapter": "CodeLLDB",
"configuration": {
"request": "launch",
"stopOnEntry": true,
"console": "integratedTerminal",
"program": "ctest",
"cwd": "${workspaceRoot}/build"
}
},
"run_native": {
"adapter": "CodeLLDB",
"variables": {
"Executable": "s6zer_test"
},
"configuration": {
"request": "launch",
"stopOnEntry": true,
"console": "integratedTerminal",
"program": "${workspaceRoot}/build/bin/${Executable}",
"cwd": "${workspaceRoot}/build"
}
}
}
}

View File

@ -20,16 +20,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# add this to your projects cmake to enable ipo
#if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
#include(CheckIPOSupported)
#check_ipo_supported(RESULT HAVE_LTO)
#if(HAVE_LTO)
#check_ipo_supported()
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
#message(STATUS "Enabled LTO")
#else()
#message(STATUS "LTO not supported")
#endif()
#endif()
# enable test
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

View File

@ -26,7 +26,6 @@ add_subdirectory("physfs")
if(NOT MM_HEADLESS)
if(NOT EMSCRIPTEN)
# TODO: move into imgui and soload, since they are the one requireing this
if(VCPKG_TARGET_TRIPLET)
find_package(SDL2 CONFIG REQUIRED)
else() # HACK: fix sdl find module
@ -39,6 +38,9 @@ if(NOT MM_HEADLESS)
add_subdirectory("glad-debug")
endif()
add_subdirectory("Vulkan-Headers")
target_compile_definitions(Vulkan-Headers INTERFACE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1)
# stb utilies
add_subdirectory("stb")

1
external/Vulkan-Headers vendored Submodule

Submodule external/Vulkan-Headers added at 245d25ce8c

2
external/entt vendored

1
external/glm.cmake vendored
View File

@ -2,5 +2,4 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE "${CMAKE_CURRENT_LIST_DIR}/glm")
target_compile_definitions(glm INTERFACE GLM_ENABLE_EXPERIMENTAL)

View File

@ -1,40 +1,50 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(imgui C CXX)
add_library(imgui
"imgui/imgui.h"
set(CPP_FILES
"imgui/imgui.cpp"
"imgui/imgui_draw.cpp"
"imgui/imgui_widgets.cpp"
"imgui/imgui_tables.cpp"
"imgui/imgui_demo.cpp"
"imgui/misc/cpp/imgui_stdlib.cpp"
"imgui_plot_var.cpp"
#"imgui_impl_sdl_gl3.cpp" # very old
#"imgui_impl_sdl.cpp" # old
#"imgui_impl_opengl3.cpp" # old
"imgui/backends/imgui_impl_sdl.cpp"
"imgui/backends/imgui_impl_opengl3.cpp"
)
set(HPP_FILES
"imgui/imgui.h"
"imgui/imstb_rectpack.h"
"imgui/imstb_textedit.h"
"imgui/imstb_truetype.h"
"imgui/misc/cpp/imgui_stdlib.h"
"imgui/misc/cpp/imgui_stdlib.cpp"
"imgui_plot_var.hpp"
"imgui_plot_var.cpp"
# TODO: seperate backends into libs
"imgui/backends/imgui_impl_sdl2.h"
"imgui/backends/imgui_impl_sdl2.cpp"
#"imgui_impl_sdl_gl3.h" # very old
#"imgui_impl_sdl.h" # old
#"imgui_impl_opengl3.h" # old
"imgui/backends/imgui_impl_sdl.h"
"imgui/backends/imgui_impl_opengl3.h"
"imgui/backends/imgui_impl_opengl3.cpp"
)
target_compile_features(imgui PUBLIC cxx_std_11)
add_library(imgui ${CPP_FILES} ${HPP_FILES})
if(MM_OPENGL_3_GLES)
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_ES3)
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_CUSTOM) # bug?
else()
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLAD)
target_link_libraries(imgui PUBLIC glad)
target_link_libraries(imgui glad)
endif()
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
@ -44,21 +54,15 @@ target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui") # i
target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
if(EMSCRIPTEN)
target_compile_options(imgui PUBLIC -sUSE_SDL=2)
target_link_libraries(imgui PUBLIC -sUSE_SDL=2 -sUSE_WEBGL2=1 -sFULL_ES3=1)
set_target_properties(imgui PROPERTIES COMPILE_FLAGS "-s USE_SDL=2 -s USE_WEBGL2=1 -s FULL_ES2=1 -s FULL_ES3=1")
set_target_properties(imgui PROPERTIES LINK_FLAGS "-s USE_SDL=2 -s USE_WEBGL2=1 -s FULL_ES2=1 -s FULL_ES3=1")
elseif(ANDROID)
target_link_libraries(imgui PUBLIC SDL)
target_link_libraries(imgui SDL)
elseif(VCPKG_TARGET_TRIPLET)
target_link_libraries(imgui
PUBLIC
SDL2::SDL2
#PRIVATE
#SDL2::SDL2main
#SDL2::SDL2-static
)
target_link_libraries(imgui SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static)
else()
target_include_directories(imgui PUBLIC "${SDL2_INCLUDE_DIR}")
target_link_libraries(imgui PUBLIC ${SDL2_LIBRARY})
target_link_libraries(imgui ${SDL2_LIBRARY})
endif()
target_compile_definitions(imgui PUBLIC ImTextureID=unsigned\ long)

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -12,7 +12,7 @@
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 1
#warning "Already included a different version of the library!"
#endif
#endif
@ -20,7 +20,7 @@
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_PATCH 1 // NOLINT(modernize-macro-to-enum)
#ifndef JSON_DIAGNOSTICS
#define JSON_DIAGNOSTICS 0
@ -42,59 +42,38 @@
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
#endif
#define NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch) \
json_v ## major ## _ ## minor ## _ ## patch
#define NLOHMANN_JSON_ABI_PREFIX(major, minor, patch) \
NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch)
// Construct the namespace ABI tags component
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c
#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) \
NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c)
#define NLOHMANN_JSON_ABI_TAGS \
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
#define NLOHMANN_JSON_ABI_STRING \
NLOHMANN_JSON_ABI_CONCAT( \
NLOHMANN_JSON_ABI_PREFIX( \
NLOHMANN_JSON_VERSION_MAJOR, \
NLOHMANN_JSON_VERSION_MINOR, \
NLOHMANN_JSON_VERSION_PATCH), \
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
// Construct the namespace version component
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
_v ## major ## _ ## minor ## _ ## patch
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
#define NLOHMANN_JSON_NAMESPACE_VERSION
#else
#define NLOHMANN_JSON_NAMESPACE_VERSION \
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
NLOHMANN_JSON_VERSION_MINOR, \
NLOHMANN_JSON_VERSION_PATCH)
#endif
// Combine namespace components
#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
#ifndef NLOHMANN_JSON_NAMESPACE
#define NLOHMANN_JSON_NAMESPACE \
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
NLOHMANN_JSON_ABI_TAGS, \
NLOHMANN_JSON_NAMESPACE_VERSION)
#define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
namespace nlohmann \
{ \
inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
NLOHMANN_JSON_ABI_TAGS, \
NLOHMANN_JSON_NAMESPACE_VERSION) \
inline namespace NLOHMANN_JSON_ABI_STRING \
{
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_END
#define NLOHMANN_JSON_NAMESPACE_END \
} /* namespace (inline namespace) NOLINT(readability/namespace) */ \
} // namespace nlohmann
} /* namespace (abi_string) */ \
} /* namespace nlohmann */
#endif

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2009 Florian Loitsch <https://florian.loitsch.com/>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -267,15 +267,9 @@ inline void to_json(BasicJsonType& j, T b) noexcept
external_constructor<value_t::boolean>::construct(j, b);
}
template < typename BasicJsonType, typename BoolRef,
enable_if_t <
((std::is_same<std::vector<bool>::reference, BoolRef>::value
&& !std::is_same <std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value)
|| (std::is_same<std::vector<bool>::const_reference, BoolRef>::value
&& !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
typename BasicJsonType::boolean_t >::value))
&& std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value, int > = 0 >
inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept
template<typename BasicJsonType,
enable_if_t<std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value, int> = 0>
inline void to_json(BasicJsonType& j, const std::vector<bool>::reference& b) noexcept
{
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
}

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -20,6 +20,7 @@
#include <string> // char_traits, string
#include <utility> // make_pair, move
#include <vector> // vector
#include <map> // map
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/input/input_adapters.hpp>
@ -1952,7 +1953,7 @@ class binary_reader
return false;
}
if (size_and_type.first != npos)
if (size_and_type.first != string_t::npos)
{
if (size_and_type.second != 0)
{
@ -2185,7 +2186,7 @@ class binary_reader
for (auto i : dim)
{
result *= i;
if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type()
if (result == 0 || result == string_t::npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be string_t::npos as it is used to initialize size in get_ubjson_size_type()
{
return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr));
}
@ -2231,7 +2232,7 @@ class binary_reader
*/
bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result, bool inside_ndarray = false)
{
result.first = npos; // size
result.first = string_t::npos; // size
result.second = 0; // type
bool is_ndarray = false;
@ -2239,9 +2240,10 @@ class binary_reader
if (current == '$')
{
std::vector<char_int_type> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
result.second = get(); // must not ignore 'N', because 'N' maybe the type
if (input_format == input_format_t::bjdata
&& JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
if (JSON_HEDLEY_UNLIKELY( input_format == input_format_t::bjdata && std::find(bjdx.begin(), bjdx.end(), result.second) != bjdx.end() ))
{
auto last_token = get_token_string();
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
@ -2490,23 +2492,23 @@ class binary_reader
// if bit-8 of size_and_type.second is set to 1, encode bjdata ndarray as an object in JData annotated array format (https://github.com/NeuroJSON/jdata):
// {"_ArrayType_" : "typeid", "_ArraySize_" : [n1, n2, ...], "_ArrayData_" : [v1, v2, ...]}
if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
{
std::map<char_int_type, string_t> bjdtype = {{'U', "uint8"}, {'i', "int8"}, {'u', "uint16"}, {'I', "int16"},
{'m', "uint32"}, {'l', "int32"}, {'M', "uint64"}, {'L', "int64"}, {'d', "single"}, {'D', "double"}, {'C', "char"}
};
size_and_type.second &= ~(static_cast<char_int_type>(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker
auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type & p, char_int_type t)
{
return p.first < t;
});
string_t key = "_ArrayType_";
if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second))
if (JSON_HEDLEY_UNLIKELY(bjdtype.count(size_and_type.second) == 0))
{
auto last_token = get_token_string();
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr));
}
string_t type = it->second; // sax->string() takes a reference
if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(type)))
if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(bjdtype[size_and_type.second]) ))
{
return false;
}
@ -2533,7 +2535,7 @@ class binary_reader
return (sax->end_array() && sax->end_object());
}
if (size_and_type.first != npos)
if (size_and_type.first != string_t::npos)
{
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first)))
{
@ -2596,7 +2598,7 @@ class binary_reader
}
// do not accept ND-array size in objects in BJData
if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
{
auto last_token = get_token_string();
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
@ -2604,7 +2606,7 @@ class binary_reader
}
string_t key;
if (size_and_type.first != npos)
if (size_and_type.first != string_t::npos)
{
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first)))
{
@ -2948,8 +2950,6 @@ class binary_reader
}
private:
static JSON_INLINE_VARIABLE constexpr std::size_t npos = static_cast<std::size_t>(-1);
/// input adapter
InputAdapterType ia;
@ -2967,44 +2967,7 @@ class binary_reader
/// the SAX parser
json_sax_t* sax = nullptr;
// excluded markers in bjdata optimized type
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
make_array<bjd_type>( \
bjd_type{'C', "char"}, \
bjd_type{'D', "double"}, \
bjd_type{'I', "int16"}, \
bjd_type{'L', "int64"}, \
bjd_type{'M', "uint64"}, \
bjd_type{'U', "uint8"}, \
bjd_type{'d', "single"}, \
bjd_type{'i', "int8"}, \
bjd_type{'l', "int32"}, \
bjd_type{'m', "uint32"}, \
bjd_type{'u', "uint16"})
JSON_PRIVATE_UNLESS_TESTED:
// lookup tables
// NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers =
JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_;
using bjd_type = std::pair<char_int_type, string_t>;
// NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map =
JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_;
#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
};
#ifndef JSON_HAS_CPP_17
template<typename BasicJsonType, typename InputAdapterType, typename SAX>
constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
#endif
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -846,143 +846,55 @@ class json_pointer
return result;
}
public:
#if JSON_HAS_THREE_WAY_COMPARISON
/// @brief compares two JSON pointers for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
template<typename RefStringTypeRhs>
bool operator==(const json_pointer<RefStringTypeRhs>& rhs) const noexcept
{
return reference_tokens == rhs.reference_tokens;
}
/*!
@brief compares two JSON pointers for equality
/// @brief compares JSON pointer and string for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer))
bool operator==(const string_t& rhs) const
{
return *this == json_pointer(rhs);
}
@param[in] lhs JSON pointer to compare
@param[in] rhs JSON pointer to compare
@return whether @a lhs is equal to @a rhs
/// @brief 3-way compares two JSON pointers
template<typename RefStringTypeRhs>
std::strong_ordering operator<=>(const json_pointer<RefStringTypeRhs>& rhs) const noexcept // *NOPAD*
{
return reference_tokens <=> rhs.reference_tokens; // *NOPAD*
}
#else
/// @brief compares two JSON pointers for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
*/
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept;
friend bool operator==(json_pointer<RefStringTypeLhs> const& lhs,
json_pointer<RefStringTypeRhs> const& rhs) noexcept;
/// @brief compares JSON pointer and string for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
template<typename RefStringTypeLhs, typename StringType>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs);
/*!
@brief compares two JSON pointers for inequality
/// @brief compares string and JSON pointer for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
template<typename RefStringTypeRhs, typename StringType>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator==(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs);
@param[in] lhs JSON pointer to compare
@param[in] rhs JSON pointer to compare
@return whether @a lhs is not equal @a rhs
/// @brief compares two JSON pointers for inequality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
*/
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept;
friend bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
json_pointer<RefStringTypeRhs> const& rhs) noexcept;
/// @brief compares JSON pointer and string for inequality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/
template<typename RefStringTypeLhs, typename StringType>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs);
/// @brief compares string and JSON pointer for inequality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/
template<typename RefStringTypeRhs, typename StringType>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator!=(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs);
/// @brief compares two JSON pointer for less-than
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
// NOLINTNEXTLINE(readability-redundant-declaration)
friend bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept;
#endif
private:
/// the reference tokens
std::vector<string_t> reference_tokens;
};
#if !JSON_HAS_THREE_WAY_COMPARISON
// functions cannot be defined inside class due to ODR violations
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept
inline bool operator==(json_pointer<RefStringTypeLhs> const& lhs,
json_pointer<RefStringTypeRhs> const& rhs) noexcept
{
return lhs.reference_tokens == rhs.reference_tokens;
}
template<typename RefStringTypeLhs,
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs)
{
return lhs == json_pointer<RefStringTypeLhs>(rhs);
}
template<typename RefStringTypeRhs,
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs)
{
return json_pointer<RefStringTypeRhs>(lhs) == rhs;
}
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept
inline bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
json_pointer<RefStringTypeRhs> const& rhs) noexcept
{
return !(lhs == rhs);
}
template<typename RefStringTypeLhs,
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs)
{
return !(lhs == rhs);
}
template<typename RefStringTypeRhs,
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
inline bool operator!=(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs)
{
return !(lhs == rhs);
}
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
inline bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept
{
return lhs.reference_tokens < rhs.reference_tokens;
}
#endif
NLOHMANN_JSON_NAMESPACE_END

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -9,7 +9,6 @@
#pragma once
#include <array> // array
#include <cstddef> // size_t
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
#include <utility> // index_sequence, make_index_sequence, index_sequence_for
@ -153,19 +152,15 @@ template<> struct priority_tag<0> {};
template<typename T>
struct static_const
{
static JSON_INLINE_VARIABLE constexpr T value{};
static constexpr T value{};
};
#ifndef JSON_HAS_CPP_17
template<typename T>
constexpr T static_const<T>::value;
#endif
template<typename T, typename... Args>
inline constexpr std::array<T, sizeof...(Args)> make_array(Args&& ... args)
{
return std::array<T, sizeof...(Args)> {{static_cast<T>(std::forward<Args>(args))...}};
}
template<typename T>
constexpr T static_const<T>::value; // NOLINT(readability-redundant-declaration)
#endif
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -684,57 +684,5 @@ inline constexpr bool value_in_range_of(T val)
return value_in_range_of_impl1<OfType, T>::test(val);
}
template<bool Value>
using bool_constant = std::integral_constant<bool, Value>;
///////////////////////////////////////////////////////////////////////////////
// is_c_string
///////////////////////////////////////////////////////////////////////////////
namespace impl
{
template<typename T>
inline constexpr bool is_c_string()
{
using TUnExt = typename std::remove_extent<T>::type;
using TUnCVExt = typename std::remove_cv<TUnExt>::type;
using TUnPtr = typename std::remove_pointer<T>::type;
using TUnCVPtr = typename std::remove_cv<TUnPtr>::type;
return
(std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
|| (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
}
} // namespace impl
// checks whether T is a [cv] char */[cv] char[] C string
template<typename T>
struct is_c_string : bool_constant<impl::is_c_string<T>()> {};
template<typename T>
using is_c_string_uncvref = is_c_string<uncvref_t<T>>;
///////////////////////////////////////////////////////////////////////////////
// is_transparent
///////////////////////////////////////////////////////////////////////////////
namespace impl
{
template<typename T>
inline constexpr bool is_transparent()
{
return is_detected<detect_is_transparent, T>::value;
}
} // namespace impl
// checks whether T has a member named is_transparent
template<typename T>
struct is_transparent : bool_constant<impl::is_transparent<T>()> {};
///////////////////////////////////////////////////////////////////////////////
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2008-2009 Björn Hoehrmann <bjoern@hoehrmann.de>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -514,7 +514,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
object = nullptr; // silence warning, see #821
if (JSON_HEDLEY_UNLIKELY(t == value_t::null))
{
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.11.2", nullptr)); // LCOV_EXCL_LINE
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.11.1", nullptr)); // LCOV_EXCL_LINE
}
break;
}
@ -2194,24 +2194,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a string argument with ", type_name()), this));
}
private:
template<typename KeyType>
using is_comparable_with_object_key = detail::is_comparable <
object_comparator_t, const typename object_t::key_type&, KeyType >;
template<typename ValueType>
using value_return_type = std::conditional <
detail::is_c_string_uncvref<ValueType>::value,
string_t, typename std::decay<ValueType>::type >;
public:
/// @brief access specified object element with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
template < class ValueType, detail::enable_if_t <
!detail::is_transparent<object_comparator_t>::value
// this is the value(const typename object_t::key_type&) overload
template < class KeyType, class ValueType, detail::enable_if_t <
std::is_same<KeyType, typename object_t::key_type>::value
&& detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
&& !std::is_same<value_t, ValueType>::value, int > = 0 >
typename std::decay<ValueType>::type value(const KeyType& key, ValueType && default_value) const
{
// value only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
@ -2220,32 +2210,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
const auto it = find(key);
if (it != end())
{
return it->template get<ValueType>();
}
return default_value;
}
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
}
/// @brief access specified object element with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
detail::enable_if_t <
!detail::is_transparent<object_comparator_t>::value
&& detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
ReturnType value(const typename object_t::key_type& key, ValueType && default_value) const
{
// value only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
{
// if key is found, return value and given default value otherwise
const auto it = find(key);
if (it != end())
{
return it->template get<ReturnType>();
return it->template get<typename std::decay<ValueType>::type>();
}
return std::forward<ValueType>(default_value);
@ -2256,62 +2221,67 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief access specified object element with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
template < class ValueType, class KeyType, detail::enable_if_t <
detail::is_transparent<object_comparator_t>::value
&& !detail::is_json_pointer<KeyType>::value
&& is_comparable_with_object_key<KeyType>::value
&& detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
ValueType value(KeyType && key, const ValueType& default_value) const
/// overload for a default value of type const char*
string_t value(const typename object_t::key_type& key, const char* default_value) const
{
// value only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
{
// if key is found, return value and given default value otherwise
const auto it = find(std::forward<KeyType>(key));
if (it != end())
{
return it->template get<ValueType>();
return value(key, string_t(default_value));
}
return default_value;
}
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
}
/// @brief access specified object element via JSON Pointer with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
detail::enable_if_t <
detail::is_transparent<object_comparator_t>::value
&& !detail::is_json_pointer<KeyType>::value
&& is_comparable_with_object_key<KeyType>::value
&& detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
ReturnType value(KeyType && key, ValueType && default_value) const
{
// value only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
{
// if key is found, return value and given default value otherwise
const auto it = find(std::forward<KeyType>(key));
if (it != end())
{
return it->template get<ReturnType>();
}
return std::forward<ValueType>(default_value);
}
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
}
/// @brief access specified object element via JSON Pointer with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
// these two functions, in conjunction with value(const KeyType &, ValueType &&),
// resolve an ambiguity that would otherwise occur between the json_pointer and
// typename object_t::key_type & overloads
template < class ValueType, detail::enable_if_t <
detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
&& !std::is_same<value_t, ValueType>::value, int > = 0 >
typename std::decay<ValueType>::type value(const char* key, ValueType && default_value) const
{
return value(typename object_t::key_type(key), std::forward<ValueType>(default_value));
}
string_t value(const char* key, const char* default_value) const
{
return value(typename object_t::key_type(key), string_t(default_value));
}
/// @brief access specified object element with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
/// using std::is_convertible in a std::enable_if will fail when using explicit conversions
template < class KeyType, class ValueType, detail::enable_if_t <
detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, ValueType>::value
&& detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int > = 0 >
typename std::decay<ValueType>::type value(KeyType && key, ValueType && default_value) const
{
// value only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
{
// if key is found, return value and given default value otherwise
const auto it = find(std::forward<KeyType>(key));
if (it != end())
{
return it->template get<typename std::decay<ValueType>::type>();
}
return std::forward<ValueType>(default_value);
}
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
}
/// @brief access specified object element with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
/// overload for a default value of type const char*
template < class KeyType, detail::enable_if_t <
!detail::is_json_pointer<KeyType>::value, int > = 0 >
string_t value(KeyType && key, const char* default_value) const
{
return value(std::forward<KeyType>(key), string_t(default_value));
}
/// @brief access specified object element via JSON Pointer with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
template < class ValueType, detail::enable_if_t <
detail::is_getable<basic_json_t, ValueType>::value, int> = 0 >
ValueType value(const json_pointer& ptr, const ValueType& default_value) const
{
// value only works for objects
@ -2331,50 +2301,29 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
}
/// @brief access specified object element via JSON Pointer with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
detail::enable_if_t <
detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
ReturnType value(const json_pointer& ptr, ValueType && default_value) const
{
// value only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
{
// if pointer resolves a value, return it or use default value
JSON_TRY
{
return ptr.get_checked(this).template get<ReturnType>();
}
JSON_INTERNAL_CATCH (out_of_range&)
{
return std::forward<ValueType>(default_value);
}
}
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
}
template < class ValueType, class BasicJsonType, detail::enable_if_t <
detail::is_basic_json<BasicJsonType>::value
&& detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
detail::is_getable<basic_json_t, ValueType>::value, int> = 0 >
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
ValueType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, const ValueType& default_value) const
{
return value(ptr.convert(), default_value);
}
template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
detail::enable_if_t <
detail::is_basic_json<BasicJsonType>::value
&& detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
ReturnType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, ValueType && default_value) const
/// @brief access specified object element via JSON Pointer with default value
/// @sa https://json.nlohmann.me/api/basic_json/value/
/// overload for a default value of type const char*
JSON_HEDLEY_NON_NULL(3)
string_t value(const json_pointer& ptr, const char* default_value) const
{
return value(ptr.convert(), std::forward<ValueType>(default_value));
return value(ptr, string_t(default_value));
}
template<typename BasicJsonType>
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
JSON_HEDLEY_NON_NULL(3)
string_t value(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr, const char* default_value) const
{
return value(ptr.convert(), default_value);
}
/// @brief access the first element
@ -2736,9 +2685,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return ptr.contains(this);
}
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
template<typename BasicJsonType>
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType> ptr) const
{
return ptr.contains(this);
}
@ -4617,7 +4566,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return ptr.get_checked(this);
}
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
template<typename BasicJsonType>
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
{
@ -4631,7 +4580,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return ptr.get_checked(this);
}
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
template<typename BasicJsonType>
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
{

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
@ -51,7 +51,7 @@ class basic_json;
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
/// @sa https://json.nlohmann.me/api/json_pointer/
template<typename RefStringType>
template<typename BasicJsonType>
class json_pointer;
/*!

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -2,7 +2,7 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// | | |__ | | | | | | version 3.11.1
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>

View File

@ -1,6 +1,6 @@
project('nlohmann_json',
'cpp',
version : '3.11.2',
version : '3.11.1',
license : 'MIT',
)
@ -14,7 +14,6 @@ nlohmann_json_multiple_headers = declare_dependency(
if not meson.is_subproject()
install_headers('single_include/nlohmann/json.hpp', subdir: 'nlohmann')
install_headers('single_include/nlohmann/json_fwd.hpp', subdir: 'nlohmann')
pkgc = import('pkgconfig')
pkgc.generate(name: 'nlohmann_json',

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,6 @@ set(CPP_FILES
soloud/src/backend/alsa/soloud_alsa.cpp
soloud/src/backend/coreaudio/soloud_coreaudio.cpp
soloud/src/backend/null/soloud_null.cpp
soloud/src/backend/nosound/soloud_nosound.cpp
#soloud/src/backend/openal/soloud_openal.cpp
#soloud/src/backend/openal/soloud_openal_dll.c
soloud/src/backend/opensles/soloud_opensles.cpp
@ -157,38 +156,32 @@ set(HPP_FILES
add_library(soloud ${CPP_FILES} ${HPP_FILES})
target_compile_definitions(soloud PRIVATE WITH_NULL)
target_compile_definitions(soloud PRIVATE WITH_NOSOUND)
#target_compile_definitions(soloud PRIVATE WITH_SDL2)
target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC)
target_include_directories(soloud SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/soloud/include")
if(EMSCRIPTEN)
target_compile_options(soloud PUBLIC -sUSE_SDL=2)
target_link_libraries(soloud PUBLIC -sUSE_SDL=2)
elseif(VCPKG_TARGET_TRIPLET)
target_link_libraries(soloud
PUBLIC
SDL2::SDL2
#PRIVATE
#SDL2::SDL2main
#SDL2::SDL2-static
)
#if not android or emscripten
if(VCPKG_TARGET_TRIPLET)
target_link_libraries(soloud SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static)
else()
target_include_directories(soloud PUBLIC "${SDL2_INCLUDE_DIR}")
target_link_libraries(soloud PUBLIC ${SDL2_LIBRARY})
target_link_libraries(soloud ${SDL2_LIBRARY})
endif()
#if not android or emscripten
#if android
#target_link_libraries(soloud SDL)
#endif
if(EMSCRIPTEN)
set_target_properties(soloud PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
set_target_properties(soloud PROPERTIES LINK_FLAGS "-s USE_SDL=2")
endif()
# TODO: remove
if(UNIX)
target_link_libraries(soloud PUBLIC
target_link_libraries(soloud
-ldl
)
endif()

View File

@ -11,8 +11,9 @@ target_link_libraries(stb_image stb)
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
target_link_libraries(stb_image_write stb)
add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
target_link_libraries(stb_perlin stb)
# lel TODO: add back in when patent expires
#add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
#target_link_libraries(stb_perlin stb)
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
target_link_libraries(stb_rect_pack stb)

View File

@ -2,16 +2,14 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
if(NOT EMSCRIPTEN)
add_library(tracy_client
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/Tracy.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/TracyLua.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/TracyVulkan.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/tracy/TracyOpenGL.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/Tracy.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyLua.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyVulkan.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyOpenGL.hpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/TracyClient.cpp"
"${CMAKE_CURRENT_LIST_DIR}/tracy/TracyClient.cpp"
)
option(TRACY_ENABLE "Enable tracy profiling" OFF)
if(TRACY_ENABLE)
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
@ -20,7 +18,7 @@ if(NOT EMSCRIPTEN)
target_compile_features(tracy_client PUBLIC cxx_std_17)
target_include_directories(tracy_client PUBLIC "${CMAKE_CURRENT_LIST_DIR}/tracy/public")
target_include_directories(tracy_client PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
if(UNIX)
target_link_libraries(tracy_client dl)
@ -34,7 +32,7 @@ else() # EMSCRIPTEN
target_compile_features(tracy_client INTERFACE cxx_std_17)
target_include_directories(tracy_client INTERFACE "${CMAKE_CURRENT_LIST_DIR}/tracy/public")
target_include_directories(tracy_client INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
endif()

View File

@ -5,7 +5,6 @@ project(framework)
add_subdirectory(engine)
add_subdirectory(logger)
add_subdirectory(resource_manager)
add_subdirectory(s6zer)
add_subdirectory(common_components)
add_subdirectory(std_utils)
add_subdirectory(random)
@ -18,6 +17,7 @@ if(NOT MM_HEADLESS)
add_subdirectory(simple_sdl_renderer)
add_subdirectory(opengl_primitives)
add_subdirectory(opengl_renderer)
add_subdirectory(vulkan_renderer)
add_subdirectory(imgui)
add_subdirectory(input)
add_subdirectory(sound)

View File

@ -4,8 +4,6 @@ project(common_components CXX)
add_library(common_components INTERFACE)
add_library(MM::common_components ALIAS common_components)
target_include_directories(common_components INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(common_components INTERFACE
@ -15,23 +13,8 @@ target_link_libraries(common_components INTERFACE
##########################
add_library(common_components_serialize_s6zer INTERFACE)
add_library(MM::common_components_serialize_s6zer ALIAS common_components_serialize_s6zer)
target_include_directories(common_components_serialize_s6zer INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(common_components_serialize_s6zer INTERFACE
common_components
s6zer
)
##########################
add_library(common_components_serialize_json INTERFACE)
add_library(MM::common_components_serialize_json ALIAS common_components_serialize_json)
target_include_directories(common_components_serialize_json INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(common_components_serialize_json INTERFACE

View File

@ -4,7 +4,7 @@
namespace MM::Components {
struct Name {
static const size_t max_str_len {64u};
static const size_t max_str_len = 64;
std::string str;
};
}

View File

@ -4,7 +4,7 @@ namespace MM::Components {
// used to lift 2D into 3D space. like a z-index in css/svg
struct Position2D_ZOffset {
float z_offset {500.f}; // default camera allows values to be between 0 and 1000
float z_offset = 500.f; // default camera allows values to be between 0 and 1000
};
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Color, color)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Color, color)
} // MM::Components

View File

@ -9,9 +9,9 @@
namespace glm {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(vec2, x, y)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(vec3, x, y, z)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(vec4, x, y, z, w)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec2, x, y)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3, x, y, z)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4, x, y, z, w)
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(mat4x4, [0], y, z, w)
inline void to_json(nlohmann::json& nlohmann_json_j, const mat4x4& nlohmann_json_t) {

View File

@ -5,7 +5,6 @@
#include <mm/components/name.hpp>
namespace MM::Components {
// TODO: manual with str len limit
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Name, str)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Position2D, pos)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D, pos)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Position2D_ZOffset, z_offset)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D_ZOffset, z_offset)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Position3D, pos)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position3D, pos)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Rotation2D, rot)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Rotation2D, rot)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Scale2D, scale)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Scale2D, scale)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Transform4x4, trans)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform4x4, trans)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Velocity2DPosition, pos_vel)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPosition, pos_vel)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Velocity2DPositionIntent, intent)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPositionIntent, intent)
} // MM::Components

View File

@ -7,6 +7,6 @@
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Velocity2DRotation, rot_vel)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DRotation, rot_vel)
} // MM::Components

View File

@ -5,6 +5,6 @@
#include <mm/components/view_dir2d.hpp>
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ViewDir2D, dir)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ViewDir2D, dir)
} // MM::Components

View File

@ -5,6 +5,6 @@
#include <mm/components/view_dir3d.hpp>
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ViewDir3D, yaw, pitch, roll)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ViewDir3D, yaw, pitch, roll)
} // MM::Components

View File

@ -1,17 +0,0 @@
#pragma once
#include <mm/s6zer/serialize.hpp>
#include <mm/components/color.hpp>
namespace MM::Components {
MM_DEFINE_SERIALIZE(Color,
MM_S6ZER_BAIL(stream.serializeFloat(data.color.r))
MM_S6ZER_BAIL(stream.serializeFloat(data.color.g))
MM_S6ZER_BAIL(stream.serializeFloat(data.color.b))
MM_S6ZER_BAIL(stream.serializeFloat(data.color.a))
)
} // MM::Components

View File

@ -3,7 +3,7 @@
namespace MM::Components {
struct ViewDir2D {
float dir {0.f}; // rad
float dir = 0.f; // rad
};
} // MM::Components

View File

@ -3,9 +3,9 @@
namespace MM::Components {
struct ViewDir3D {
float yaw {0.f}; // rad
float pitch {0.f}; // rad
float roll {0.f}; // rad
float yaw = 0.f; // rad
float pitch = 0.f; // rad
float roll = 0.f; // rad
};
} // MM::Components

View File

@ -7,25 +7,10 @@ target_include_directories(common_component_json_serialization_test PRIVATE ".")
target_link_libraries(common_component_json_serialization_test
common_components_serialize_json
engine
gtest_main
)
add_test(NAME common_component_json_serialization_test COMMAND common_component_json_serialization_test)
########################################
add_executable(common_component_s6zer_serialization_test
component_s6zer_serialization_test.cpp
)
target_include_directories(common_component_s6zer_serialization_test PRIVATE ".")
target_link_libraries(common_component_s6zer_serialization_test
common_components_serialize_s6zer
gtest_main
)
add_test(NAME common_component_s6zer_serialization_test COMMAND common_component_s6zer_serialization_test)

View File

@ -1,3 +1,4 @@
#include "mm/components/position2d.hpp"
#include <gtest/gtest.h>
#include <mm/components/serialize/json_name.hpp>

View File

@ -1,289 +0,0 @@
#include <gtest/gtest.h>
#include <array>
#include <mm/s6zer/serialize.hpp>
//#include <mm/components/serialize/json_name.hpp>
#include <mm/components/serialize/s6zer_color.hpp>
//#include <mm/components/serialize/json_position2d.hpp>
//#include <mm/components/serialize/json_position2d_zoffset.hpp>
//#include <mm/components/serialize/json_position3d.hpp>
//#include <mm/components/serialize/json_rotation2d.hpp>
//#include <mm/components/serialize/json_scale2d.hpp>
//#include <mm/components/serialize/json_transform4x4.hpp>
//#include <mm/components/serialize/json_velocity2d_position.hpp>
//#include <mm/components/serialize/json_velocity2d_position_intent.hpp>
//#include <mm/components/serialize/json_velocity2d_rotation.hpp>
//#include <mm/components/serialize/json_view_dir2d.hpp>
//#include <mm/components/serialize/json_view_dir3d.hpp>
#define TEST_JSON_SERL_EXPAND(x) x
#define TEST_JSON_SERL_IN_OUT(TYPE, JSON_STR, TEST_CORPUS) \
TEST(common_components_json_serialization, in_out_##TYPE) { \
MM::Components::TYPE comp; \
{ /* in */ \
auto j = nlohmann::json::parse(JSON_STR); \
comp = j; \
TEST_CORPUS \
} \
{ /* out */ \
nlohmann::json j; \
j = comp; \
ASSERT_EQ(JSON_STR, j.dump()); \
} \
}
//TEST(common_components_json_serialization, in_out_name) {
//MM::Components::Name comp;
//const char* json_test_file = "{\"str\":\"test_name\"}";
//{ // in
//auto j = nlohmann::json::parse(json_test_file);
//EXPECT_NO_THROW({
//comp = j;
//});
//ASSERT_EQ(comp.str, "test_name");
//}
//{ // out
//nlohmann::json j;
//EXPECT_NO_THROW({
//j = comp;
//});
//ASSERT_EQ(json_test_file, j.dump());
//}
//}
//TEST(common_components_json_serialization, in_out_name_fail) {
//MM::Components::Name name_comp;
//// intentional malformed json string
//const char* json_test_file = "{\"strasdf\":\"test_name\"}";
//{ // in
//auto j = nlohmann::json::parse(json_test_file);
//ASSERT_ANY_THROW({
//name_comp = j;
//});
//}
//}
// ##############################################################
//TEST_S6ZER_SERL_IN_OUT(
//Color,
//R"({"color":{"w":1337.0,"x":0.0,"y":1.0,"z":3.0}})",
//TEST_JSON_SERL_EXPAND({
//glm::vec4 comp_val(0.f, 1.f, 3.f, 1337.f);
//ASSERT_EQ(comp.color.x, comp_val.x);
//ASSERT_EQ(comp.color.y, comp_val.y);
//ASSERT_EQ(comp.color.z, comp_val.z);
//ASSERT_EQ(comp.color.w, comp_val.w);
//})
//)
TEST(common_components_s6zer_serialization, out_in_color) {
const MM::Components::Color comp_out{
{1337.f, 0.f, 1.f, 3.f}
};
std::array<uint32_t, 128> buffer;
size_t buffer_size = buffer.size()*sizeof(uint32_t);
{ // to bits
MM::s6zer::StreamWriter writer{buffer.data(), buffer_size};
ASSERT_TRUE(MM::Components::mm_serialize(writer, comp_out));
ASSERT_TRUE(writer.flush());
buffer_size = writer.bytesWritten();
}
MM::Components::Color comp_in;
{ // from bits
MM::s6zer::StreamReader reader{buffer.data(), buffer_size};
ASSERT_TRUE(MM::Components::mm_serialize(reader, comp_in));
ASSERT_EQ(reader.bytesRead(), buffer_size);
}
ASSERT_EQ(comp_out.color.x, comp_in.color.x);
ASSERT_EQ(comp_out.color.y, comp_in.color.y);
ASSERT_EQ(comp_out.color.z, comp_in.color.z);
ASSERT_EQ(comp_out.color.w, comp_in.color.w);
}
#if 0
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Position2D,
R"({"pos":{"x":42.0,"y":6.0}})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.pos.x, 42.f);
ASSERT_EQ(comp.pos.y, 6.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Position2D_ZOffset,
R"({"z_offset":3.0})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.z_offset, 3.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Position3D,
R"({"pos":{"x":42.0,"y":6.0,"z":44.0}})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.pos.x, 42.f);
ASSERT_EQ(comp.pos.y, 6.f);
ASSERT_EQ(comp.pos.z, 44.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Rotation2D,
R"({"rot":42.0})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.rot, 42.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Scale2D,
R"({"scale":{"x":42.0,"y":6.0}})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.scale.x, 42.f);
ASSERT_EQ(comp.scale.y, 6.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Transform4x4,
R"({"trans":[{"w":0.0,"x":1.0,"y":0.0,"z":0.0},{"w":0.0,"x":0.0,"y":1.0,"z":0.0},{"w":0.0,"x":0.0,"y":0.0,"z":1.0},{"w":1.0,"x":0.0,"y":0.0,"z":0.0}]})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.trans, glm::mat4x4{1.f});
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Velocity2DPosition,
R"({"pos_vel":{"x":42.0,"y":6.0}})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.pos_vel.x, 42.f);
ASSERT_EQ(comp.pos_vel.y, 6.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Velocity2DPositionIntent,
R"({"intent":{"x":42.0,"y":6.0}})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.intent.x, 42.f);
ASSERT_EQ(comp.intent.y, 6.f);
)
)
// ##############################################################
TEST_JSON_SERL_IN_OUT(
Velocity2DRotation,
R"({"rot_vel":42.0})",
TEST_JSON_SERL_EXPAND(
ASSERT_EQ(comp.rot_vel, 42.f);
)
)
// ##############################################################
TEST(common_components_json_serialization, in_out_view_dir2d) {
MM::Components::ViewDir2D comp;
const char* json_test_file = R"({"dir":6.0})";
{ // in
auto j = nlohmann::json::parse(json_test_file);
EXPECT_NO_THROW({
comp = j;
});
ASSERT_EQ(comp.dir, 6.f);
}
{ // out
nlohmann::json j;
EXPECT_NO_THROW({
j = comp;
});
ASSERT_EQ(json_test_file, j.dump());
}
}
// ##############################################################
TEST(common_components_json_serialization, in_out_view_dir3d) {
MM::Components::ViewDir3D comp;
const char* json_test_file = R"({"pitch":6.0,"roll":99.0,"yaw":42.0})";
{ // in
auto j = nlohmann::json::parse(json_test_file);
EXPECT_NO_THROW({
comp = j;
});
ASSERT_EQ(comp.yaw, 42.f);
ASSERT_EQ(comp.pitch, 6.f);
ASSERT_EQ(comp.roll, 99.f);
}
{ // out
nlohmann::json j;
EXPECT_NO_THROW({
j = comp;
});
ASSERT_EQ(json_test_file, j.dump());
}
}
#endif
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -24,8 +24,6 @@ add_library(engine
target_include_directories(engine PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_compile_features(engine PUBLIC cxx_std_17)
target_link_libraries(engine
tracy_client
logger

View File

@ -69,11 +69,11 @@ void Engine::cleanup(void) {
}
void Engine::update(void) {
FrameMarkStart("update");
FrameMarkStart("update")
_update_strategy->doUpdate(*this);
FrameMarkEnd("update");
FrameMarkEnd("update")
}
#ifdef __EMSCRIPTEN__

View File

@ -1,43 +0,0 @@
#pragma once
#include <mm/engine.hpp>
namespace MM::Services {
// counts X times and stops engine
// useful for automatic testing
class CountDown : public Service {
public:
CountDown(int64_t start) : _counter(start) {}
const char* name(void) override { return "CountDown"; }
bool enable(Engine&, std::vector<UpdateStrategies::TaskInfo>& task_array) override {
// add task
task_array.push_back(
UpdateStrategies::TaskInfo{"CountDown::tick"}
.phase(UpdateStrategies::update_phase_t::POST)
.fn([this](Engine& e) { this->tick(e); })
);
return true;
}
void disable(Engine&) override {}
private:
void tick(Engine& engine) {
_counter--;
if (_counter == 0) {
engine.stop();
}
}
private:
int64_t _counter = 0;
};
} // MM::Services

View File

@ -50,11 +50,11 @@ namespace MM::Services {
public: // send/recv
// sends a packet of max getMaxPacketSize() bytes
virtual bool sendPacket(peer_id peer, channel_id channel, const uint8_t* data, size_t data_size) = 0;
virtual bool sendPacket(peer_id peer, channel_id channel, uint8_t* data, size_t data_size) = 0;
// sends a packet, automatically split if too big
// !! only on lossless channels
virtual bool sendPacketLarge(peer_id peer, channel_id channel, const uint8_t* data, size_t data_size) = 0;
virtual bool sendPacketLarge(peer_id peer, channel_id channel, uint8_t* data, size_t data_size) = 0;
// TODO: broadcast?
// has any?

View File

@ -72,7 +72,7 @@ bool Sequential::disableService(const entt::id_type service_id) {
}
void Sequential::doUpdate(MM::Engine& engine) {
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate");
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate")
// TODO: caching
std::set<update_key_t> pre_tasks;
std::set<update_key_t> main_tasks;
@ -93,22 +93,22 @@ void Sequential::doUpdate(MM::Engine& engine) {
}
{ // pre
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::pre");
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::pre")
doGraphSequential(engine, pre_tasks);
}
{ // main
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::main");
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::main")
doGraphSequential(engine, main_tasks);
}
{ // post
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::post");
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::post")
doGraphSequential(engine, post_tasks);
}
{ // simulate async
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::async");
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::async")
for (size_t i = 0; !_async_queue.empty() && i < _max_async_per_tick; i++) {
_async_queue.back()(engine);
_async_queue.pop_back();
@ -116,7 +116,7 @@ void Sequential::doUpdate(MM::Engine& engine) {
}
{
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::deferred");
ZoneScopedN("MM::UpdateStrategies::Sequential::doUpdate::deferred")
if (!_deferred_queue.empty()) {
for (auto&& fn : _deferred_queue) {
fn(engine);

View File

@ -14,7 +14,7 @@ add_library(filesystem_service
target_include_directories(filesystem_service PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(filesystem_service PUBLIC
target_link_libraries(filesystem_service
engine
logger
entt
@ -30,22 +30,14 @@ if(NOT MM_HEADLESS)
#endif
if(EMSCRIPTEN)
target_compile_options(filesystem_service PUBLIC -sUSE_SDL=2)
target_link_libraries(filesystem_service PUBLIC -sUSE_SDL=2)
set_target_properties(filesystem_service PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
set_target_properties(filesystem_service PROPERTIES LINK_FLAGS "-s USE_SDL=2")
elseif(VCPKG_TARGET_TRIPLET)
find_package(SDL2 CONFIG REQUIRED)
target_link_libraries(filesystem_service
PUBLIC
SDL2::SDL2
SDL2::SDL2main
#SDL2::SDL2-static
)
target_link_libraries(filesystem_service SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static)
else()
#if not android or emscripten
find_package(SDL2 REQUIRED)
target_include_directories(filesystem_service PUBLIC "${SDL2_INCLUDE_DIR}")
target_link_libraries(filesystem_service PUBLIC ${SDL2_LIBRARY})
target_link_libraries(filesystem_service ${SDL2_LIBRARY})
#endif
endif()
endif()

View File

@ -33,7 +33,6 @@ bool FilesystemService::enable(Engine&, std::vector<UpdateStrategies::TaskInfo>&
return false;
}
// TODO: why exclude EMSCRIPTEN here? also wrong macro
#if !defined(MM_HEADLESS) && !defined(EMSCRIPTEN)
char* pref_path = SDL_GetPrefPath("made_of_jelly", _app_name);
#else
@ -198,7 +197,7 @@ FilesystemService::fs_file_t FilesystemService::open(const char* filepath, Files
phys_file = PHYSFS_openAppend(filepath);
break;
default:
LOG_ERROR("invalid fopen mode {} for '{}'", static_cast<int>(t), filepath);
LOG_ERROR("invalid fopen mode {} for '{}'", t, filepath);
return nullptr;
}
@ -316,31 +315,6 @@ nlohmann::json FilesystemService::readJson(const char* filepath) const {
return r;
}
nlohmann::ordered_json FilesystemService::readJsonOrdered(fs_file_t file) const {
if (!file)
return {};
seek(file, 0);
std::string buffer;
readString(file, buffer);
// disable exeptions
// TODO: use callback instead of readString()
return nlohmann::ordered_json::parse(buffer, nullptr, false);
}
nlohmann::ordered_json FilesystemService::readJsonOrdered(const char* filepath) const {
if (!isFile(filepath)) {
return {};
}
auto h = open(filepath, READ);
auto r = readJsonOrdered(h);
close(h);
return r;
}
bool FilesystemService::writeJson(fs_file_t file, nlohmann::json& j, const int indent, const char indent_char) const {
if (!file) {
LOG_ERROR("writing json to invalid file");

View File

@ -78,9 +78,6 @@ class FilesystemService : public Service {
nlohmann::json readJson(fs_file_t file) const;
nlohmann::json readJson(const char* filepath) const;
nlohmann::ordered_json readJsonOrdered(fs_file_t file) const;
nlohmann::ordered_json readJsonOrdered(const char* filepath) const;
bool writeJson(fs_file_t file, nlohmann::json& j, const int indent = -1, const char indent_char = ' ') const;
bool writeJson(const char* filepath, nlohmann::json& j, const int indent = -1, const char indent_char = ' ') const;

View File

@ -4,8 +4,6 @@
//#include <physfs.h>
#include <nlohmann/json.hpp>
#include <SDL.h> // SDL_main
#include <mm/fs_const_archiver.hpp>
#include <mm/logger.hpp>

View File

@ -85,8 +85,8 @@ private:
bool entityHasComponent(Registry& registry, EntityType& entity, ComponentTypeID type_id)
{
const auto* storage_ptr = registry.storage(type_id);
return storage_ptr != nullptr && storage_ptr->contains(entity);
const auto storage_it = registry.storage(type_id);
return storage_it != registry.storage().end() && storage_it->second.contains(entity);
}
public:
@ -243,11 +243,11 @@ public:
}
});
} else {
entt::runtime_view view{};
entt::basic_runtime_view<entt::basic_sparse_set<EntityType>> view{};
for (const auto type : comp_list) {
auto* storage_ptr = registry.storage(type);
if (storage_ptr != nullptr) {
view.iterate(*storage_ptr);
auto storage_it = registry.storage(type);
if (storage_it != registry.storage().end()) {
view.iterate(registry.storage(type)->second);
}
}

Some files were not shown because too many files have changed in this diff Show More