diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 040c19935..0896d9abc 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -20,6 +20,8 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' + - 'irr/**.[ch]' + - 'irr/**.cpp' - '**/CMakeLists.txt' - 'cmake/Modules/**' - 'android/**' @@ -27,13 +29,13 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Install deps run: | sudo apt-get update - sudo apt-get install -y --no-install-recommends gettext openjdk-11-jdk-headless + sudo apt-get install -y --no-install-recommends gettext openjdk-17-jdk-headless - name: Build AAB with Gradle # We build an AAB as well for uploading to the the Play Store. run: cd android; ./gradlew bundlerelease diff --git a/.github/workflows/cpp_lint.yml b/.github/workflows/cpp_lint.yml index 79b8ffc4e..0ec8ebf1d 100644 --- a/.github/workflows/cpp_lint.yml +++ b/.github/workflows/cpp_lint.yml @@ -20,6 +20,8 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' + - 'irr/**.[ch]' + - 'irr/**.cpp' - '**/CMakeLists.txt' - 'cmake/Modules/**' - 'util/ci/**' diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml index 421d2edf4..1a2805e22 100644 --- a/.github/workflows/docker_image.yml +++ b/.github/workflows/docker_image.yml @@ -17,6 +17,8 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' + - 'irr/**.[ch]' + - 'irr/**.cpp' - '**/CMakeLists.txt' - 'cmake/Modules/**' - 'util/ci/**' diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index eb2b032da..2d0c72907 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -22,6 +22,8 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' + - 'irr/**.[ch]' + - 'irr/**.cpp' - '**/CMakeLists.txt' - 'cmake/Modules/**' - 'util/ci/**' @@ -55,21 +57,21 @@ jobs: ./bin/minetest --run-unittests # Current gcc version - gcc_12: - runs-on: ubuntu-22.04 + gcc_14: + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Install deps run: | source ./util/ci/common.sh - install_linux_deps g++-12 libluajit-5.1-dev + install_linux_deps g++-14 libluajit-5.1-dev - name: Build run: | ./util/ci/build.sh env: - CC: gcc-12 - CXX: g++-12 + CC: gcc-14 + CXX: g++-14 - name: Test run: | @@ -101,21 +103,21 @@ jobs: ./bin/minetest --run-unittests # Current clang version - clang_14: - runs-on: ubuntu-22.04 + clang_18: + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Install deps run: | source ./util/ci/common.sh - install_linux_deps clang-14 lldb + install_linux_deps clang-18 lldb - name: Build run: | ./util/ci/build.sh env: - CC: clang-14 - CXX: clang++-14 + CC: clang-18 + CXX: clang++-18 - name: Test run: | @@ -126,27 +128,26 @@ jobs: ./util/test_multiplayer.sh # Build with prometheus-cpp (server-only) - clang_9_prometheus: - name: "clang_9 (PROMETHEUS=1)" - runs-on: ubuntu-20.04 + clang_11_prometheus: + name: "clang_11 (PROMETHEUS=1)" + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Install deps run: | source ./util/ci/common.sh - install_linux_deps clang-9 + install_linux_deps clang-11 - name: Build prometheus-cpp - run: | - ./util/ci/build_prometheus_cpp.sh + run: ./util/ci/build_prometheus_cpp.sh - name: Build run: | ./util/ci/build.sh env: - CC: clang-9 - CXX: clang++-9 - CMAKE_FLAGS: "-DENABLE_PROMETHEUS=1 -DBUILD_CLIENT=0" + CC: clang-11 + CXX: clang++-11 + CMAKE_FLAGS: "-DENABLE_PROMETHEUS=1 -DBUILD_CLIENT=0 -DENABLE_CURSES=0" - name: Test run: | diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml index 6f803d133..0073eca2e 100644 --- a/.github/workflows/lua.yml +++ b/.github/workflows/lua.yml @@ -17,7 +17,7 @@ jobs: # Note that the integration tests are also run in build.yml, but only when C++ code is changed. integration_tests: name: "Compile and run multiplayer tests" - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Install deps @@ -39,7 +39,7 @@ jobs: luacheck: name: "Builtin Luacheck and Unit Tests" - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: @@ -50,11 +50,7 @@ jobs: - uses: leafo/gh-actions-luarocks@v4.3.0 - name: Install LuaJIT - run: | - cd $HOME - git clone https://github.com/LuaJIT/LuaJIT/ - cd LuaJIT - make -j$(nproc) + run: ./util/ci/build_luajit.sh - name: Install luarocks tools run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index a7c670ed7..ad9982f66 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -19,6 +19,9 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' + - 'irr/**.[ch]' + - 'irr/**.cpp' + - 'irr/**.mm' # Objective-C(++) - '**/CMakeLists.txt' - 'cmake/Modules/**' - '.github/workflows/macos.yml' diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9a036a24f..367933148 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -21,6 +21,8 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' + - 'irr/**.[ch]' + - 'irr/**.cpp' - '**/CMakeLists.txt' - 'cmake/Modules/**' - 'util/buildbot/**' @@ -67,8 +69,8 @@ jobs: name: VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} runs-on: windows-2019 env: - VCPKG_VERSION: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50 - # 2023.10.19 + VCPKG_VERSION: 01f602195983451bc83e72f4214af2cbc495aa94 + # 2024.05.24 vcpkg_packages: zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp sdl2 strategy: fail-fast: false @@ -92,12 +94,6 @@ jobs: steps: - uses: actions/checkout@v4 - # Workaround for regression, see https://github.com/minetest/minetest/pull/14536 - - name: Pin CMake to 3.28 - uses: lukka/get-cmake@latest - with: - cmakeVersion: "~3.28.0" - - name: Restore from cache and run vcpkg uses: lukka/run-vcpkg@v7 with: diff --git a/.gitignore b/.gitignore index d37564977..fed437b47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ ## Editors and development environments *~ +.cmake +CMakeUserPresets.json +Testing/* *.swp *.bak* *.orig @@ -26,7 +29,8 @@ gtags.files # Codelite *.project # Visual Studio Code & plugins -.vscode/ +.vscode/* +!.vscode/extensions.json build/.cmake/ # Fleet .fleet @@ -107,7 +111,10 @@ src/cmake_config_githash.h *.iml test_config.h cmake-build-debug/ +cmake-build-minsizerel/ cmake-build-release/ +cmake-build-relwithdebinfo/ +cmake-build-default/ cmake_config.h cmake_config_githash.h CMakeDoxy* diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..fd9b2c09b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c6c60ba9..2cd2e7336 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,6 +277,7 @@ find_package(Lua REQUIRED) if(NOT USE_LUAJIT) add_subdirectory(lib/bitop) endif() +add_subdirectory(lib/sha256) if(BUILD_UNITTESTS OR BUILD_BENCHMARKS) add_subdirectory(lib/catch2) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..d1e6a4037 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,41 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 12 + }, + "configurePresets": [ + { + "name": "Debug", + "displayName": "Debug", + "description": "Debug preset with debug symbols and no optimizations", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "Release", + "displayName": "Release", + "description": "Release preset with optimizations and no debug symbols", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "RelWithDebInfo", + "displayName": "RelWithDebInfo", + "description": "Release with debug symbols", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "MinSizeRel", + "displayName": "MinSizeRel", + "description": "Release with minimal code size", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "MinSizeRel" + } + } + ] +} diff --git a/android/app/src/main/java/net/minetest/minetest/GameActivity.java b/android/app/src/main/java/net/minetest/minetest/GameActivity.java index 2646721d1..b0e301c53 100644 --- a/android/app/src/main/java/net/minetest/minetest/GameActivity.java +++ b/android/app/src/main/java/net/minetest/minetest/GameActivity.java @@ -23,6 +23,7 @@ import org.libsdl.app.SDLActivity; import android.content.Intent; +import android.content.ActivityNotFoundException; import android.net.Uri; import android.os.Bundle; import android.text.InputType; @@ -33,6 +34,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.LinearLayout; +import android.widget.Toast; import android.content.res.Configuration; import androidx.annotation.Keep; @@ -201,7 +203,11 @@ public int getDisplayWidth() { public void openURI(String uri) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); - startActivity(browserIntent); + try { + startActivity(browserIntent); + } catch (ActivityNotFoundException e) { + runOnUiThread(() -> Toast.makeText(this, R.string.no_web_browser, Toast.LENGTH_SHORT).show()); + } } public String getUserDataPath() { diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 9eb1d3ca1..5885a7b7a 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -7,4 +7,5 @@ Loading Minetest Less than 1 minute… Done + No web browser found diff --git a/builtin/fstk/dialog.lua b/builtin/fstk/dialog.lua index c50d23855..991ec20ab 100644 --- a/builtin/fstk/dialog.lua +++ b/builtin/fstk/dialog.lua @@ -78,15 +78,12 @@ function dialog_create(name,get_formspec,buttonhandler,eventhandler) return self end +-- "message" must already be formspec-escaped, e.g. via fgettext or +-- core.formspec_escape. function messagebox(name, message) return dialog_create(name, function() - return ([[ - formspec_version[3] - size[8,3] - textarea[0.375,0.375;7.25,1.2;;;%s] - button[3,1.825;2,0.8;ok;%s] - ]]):format(message, fgettext("OK")) + return ui.get_message_formspec("", message, "ok") end, function(this, fields) if fields.ok then diff --git a/builtin/fstk/ui.lua b/builtin/fstk/ui.lua index a63cb2cd0..a3a8fed77 100644 --- a/builtin/fstk/ui.lua +++ b/builtin/fstk/ui.lua @@ -50,6 +50,20 @@ function ui.find_by_name(name) return ui.childlist[name] end +-------------------------------------------------------------------------------- +-- "title" and "message" must already be formspec-escaped, e.g. via fgettext or +-- core.formspec_escape. +function ui.get_message_formspec(title, message, btn_id) + return table.concat({ + "size[14,8]", + "real_coordinates[true]", + "set_focus[", btn_id, ";true]", + "box[0.5,1.2;13,5;#000]", + ("textarea[0.5,1.2;13,5;;%s;%s]"):format(title, message), + "button[5,6.6;4,1;", btn_id, ";" .. fgettext("OK") .. "]", + }) +end + -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Internal functions not to be called from user @@ -76,6 +90,9 @@ function ui.update() } ui.overridden = true elseif gamedata ~= nil and gamedata.errormessage ~= nil then + -- Note to API users: + -- "gamedata.errormessage" must not be formspec-escaped yet. + -- For translations, fgettext_ne should be used. local error_message = core.formspec_escape(gamedata.errormessage) local error_title @@ -84,15 +101,7 @@ function ui.update() else error_title = fgettext("An error occurred:") end - formspec = { - "size[14,8]", - "real_coordinates[true]", - "set_focus[btn_error_confirm;true]", - "box[0.5,1.2;13,5;#000]", - ("textarea[0.5,1.2;13,5;;%s;%s]"):format( - error_title, error_message), - "button[5,6.6;4,1;btn_error_confirm;" .. fgettext("OK") .. "]" - } + formspec = {ui.get_message_formspec(error_title, error_message, "btn_error_confirm")} ui.overridden = true else local active_toplevel_ui_elements = 0 diff --git a/builtin/mainmenu/content/dlg_contentdb.lua b/builtin/mainmenu/content/dlg_contentdb.lua index 4dafafc45..a975e1326 100644 --- a/builtin/mainmenu/content/dlg_contentdb.lua +++ b/builtin/mainmenu/content/dlg_contentdb.lua @@ -117,7 +117,7 @@ local function resolve_auto_install_spec() end if not resolved then - gamedata.errormessage = fgettext("The package $1 was not found.", auto_install_spec) + gamedata.errormessage = fgettext_ne("The package $1 was not found.", auto_install_spec) ui.update() auto_install_spec = nil diff --git a/builtin/mainmenu/content/dlg_install.lua b/builtin/mainmenu/content/dlg_install.lua index 8c2a43b09..11cb0674b 100644 --- a/builtin/mainmenu/content/dlg_install.lua +++ b/builtin/mainmenu/content/dlg_install.lua @@ -66,35 +66,45 @@ local function get_formspec(data) message_bg = mt_color_orange end + local ENABLE_TOUCH = core.settings:get_bool("enable_touch") + + local w = ENABLE_TOUCH and 14 or 7 + local padded_w = w - 2*0.375 + local dropdown_w = ENABLE_TOUCH and 10.2 or 4.25 + local button_w = (padded_w - 0.25) / 3 + local button_pad = button_w / 2 + local formspec = { "formspec_version[3]", - "size[7,7.85]", + "size[", w, ",9.05]", + ENABLE_TOUCH and "padding[0.01,0.01]" or "position[0.5,0.55]", "style[title;border=false]", - "box[0,0;7,0.5;#3333]", - "button[0,0;7,0.5;title;", fgettext("Install $1", package.title) , "]", + "box[0,0;", w, ",0.8;#3333]", + "button[0,0;", w, ",0.8;title;", fgettext("Install $1", package.title) , "]", - "container[0.375,0.70]", + "container[0.375,1]", - "label[0,0.25;", fgettext("Base Game:"), "]", - "dropdown[2,0;4.25,0.5;selected_game;", table.concat(game_list, ","), ";", selected_game_idx, "]", + "label[0,0.4;", fgettext("Base Game:"), "]", + "dropdown[", padded_w - dropdown_w, ",0;", dropdown_w, ",0.8;selected_game;", + table.concat(game_list, ","), ";", selected_game_idx, "]", - "label[0,0.8;", fgettext("Dependencies:"), "]", + "label[0,1.1;", fgettext("Dependencies:"), "]", "tablecolumns[color;text;color;text]", - "table[0,1.1;6.25,3;packages;", table.concat(formatted_deps, ","), "]", + "table[0,1.4;", padded_w, ",3;packages;", table.concat(formatted_deps, ","), "]", "container_end[]", - "checkbox[0.375,5.1;will_install_deps;", + "checkbox[0.375,5.7;will_install_deps;", fgettext("Install missing dependencies"), ";", will_install_deps and "true" or "false", "]", - "box[0,5.4;7,1.2;", message_bg, "]", - "textarea[0.375,5.5;6.25,1;;;", message, "]", + "box[0,6;", w, ",1.8;", message_bg, "]", + "textarea[0.375,6.1;", padded_w, ",1.6;;;", message, "]", - "container[1.375,6.85]", - "button[0,0;2,0.8;install_all;", fgettext("Install"), "]", - "button[2.25,0;2,0.8;cancel;", fgettext("Cancel"), "]", + "container[", 0.375 + button_pad, ",8.05]", + "button[0,0;", button_w, ",0.8;install_all;", fgettext("Install"), "]", + "button[", 0.25 + button_w, ",0;", button_w, ",0.8;cancel;", fgettext("Cancel"), "]", "container_end[]", } diff --git a/builtin/mainmenu/settings/dlg_settings.lua b/builtin/mainmenu/settings/dlg_settings.lua index d6bbf2570..fe1e1924f 100644 --- a/builtin/mainmenu/settings/dlg_settings.lua +++ b/builtin/mainmenu/settings/dlg_settings.lua @@ -723,6 +723,11 @@ local function eventhandler(event) mm_game_theme.set_engine(true) return true end + if event == "FullscreenChange" then + -- Refresh the formspec to keep the fullscreen checkbox up to date. + ui.update() + return true + end return false end diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua index 98ba17299..1ed08d825 100644 --- a/builtin/mainmenu/tab_local.lua +++ b/builtin/mainmenu/tab_local.lua @@ -156,10 +156,18 @@ local function get_formspec(tabview, name, tabdata) -- Point the player to ContentDB when no games are found if #pkgmgr.games == 0 then + local W = tabview.width + local H = tabview.height + + local hypertext = "" .. + fgettext_ne("Minetest is a game-creation platform that allows you to play many different games.") .. "\n" .. + fgettext_ne("Minetest doesn't come with a game by default.") .. " " .. + fgettext_ne("You need to install a game before you can create a world.") + + local button_y = H * 2/3 - 0.6 return table.concat({ - "style[label_button;border=false]", - "button[2.75,1.5;10,1;label_button;", fgettext("You have no games installed."), "]", - "button[5.25,3.5;5,1.2;game_open_cdb;", fgettext("Install a game"), "]"}) + "hypertext[0.375,0;", W - 2*0.375, ",", button_y, ";ht;", core.formspec_escape(hypertext), "]", + "button[5.25,", button_y, ";5,1.2;game_open_cdb;", fgettext("Install a game"), "]"}) end local retval = "" diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 8dc37c3e7..aca960590 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2399,6 +2399,9 @@ keymap_minimap (Minimap key) key KEY_KEY_V # Key for taking screenshots. keymap_screenshot (Screenshot) key KEY_F12 +# Key for toggling fullscreen mode. +keymap_fullscreen (Fullscreen key) key KEY_F11 + # Key for dropping the currently selected item. keymap_drop (Drop item key) key KEY_KEY_Q @@ -2522,6 +2525,9 @@ keymap_toggle_debug (Debug info toggle key) key KEY_F5 # Key for toggling the display of the profiler. Used for development. keymap_toggle_profiler (Profiler toggle key) key KEY_F6 +# Key for toggling the display of mapblock boundaries. +keymap_toggle_block_bounds (Block bounds toggle key) key + # Key for switching between first- and third-person camera. keymap_camera_mode (Toggle camera mode key) key KEY_KEY_C diff --git a/doc/compiling/README.md b/doc/compiling/README.md index 3652c2d74..a1ab1ebbd 100644 --- a/doc/compiling/README.md +++ b/doc/compiling/README.md @@ -20,6 +20,8 @@ General options and their default values: SemiDebug - Partially optimized debug build RelWithDebInfo - Release build with debug information MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible + PRECOMPILE_HEADERS=FALSE - Precompile some headers (experimental; requires CMake 3.16 or later) + PRECOMPILED_HEADERS_PATH= - Path to a file listing all headers to precompile (default points to src/precompiled_headers.txt) ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal) ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations diff --git a/doc/ides/images/jetbrains_cmake_profiles.png b/doc/ides/images/jetbrains_cmake_profiles.png new file mode 100644 index 000000000..f0e969a6b Binary files /dev/null and b/doc/ides/images/jetbrains_cmake_profiles.png differ diff --git a/doc/ides/images/jetbrains_ide.png b/doc/ides/images/jetbrains_ide.png new file mode 100644 index 000000000..8b9b11c0f Binary files /dev/null and b/doc/ides/images/jetbrains_ide.png differ diff --git a/doc/ides/images/jetbrains_notification_profiles.png b/doc/ides/images/jetbrains_notification_profiles.png new file mode 100644 index 000000000..8aeb13073 Binary files /dev/null and b/doc/ides/images/jetbrains_notification_profiles.png differ diff --git a/doc/ides/images/jetbrains_open_project_wizard_profiles.png b/doc/ides/images/jetbrains_open_project_wizard_profiles.png new file mode 100644 index 000000000..dafc2c0c4 Binary files /dev/null and b/doc/ides/images/jetbrains_open_project_wizard_profiles.png differ diff --git a/doc/ides/images/jetbrains_open_project_wizard_windows_cmake.png b/doc/ides/images/jetbrains_open_project_wizard_windows_cmake.png new file mode 100644 index 000000000..2366908ec Binary files /dev/null and b/doc/ides/images/jetbrains_open_project_wizard_windows_cmake.png differ diff --git a/doc/ides/images/jetbrains_open_project_wizard_windows_compiler.png b/doc/ides/images/jetbrains_open_project_wizard_windows_compiler.png new file mode 100644 index 000000000..928e0788f Binary files /dev/null and b/doc/ides/images/jetbrains_open_project_wizard_windows_compiler.png differ diff --git a/doc/ides/images/jetbrains_vcpkg.png b/doc/ides/images/jetbrains_vcpkg.png new file mode 100644 index 000000000..31ab265ce Binary files /dev/null and b/doc/ides/images/jetbrains_vcpkg.png differ diff --git a/doc/ides/images/vscode_cmake_preset_selection.png b/doc/ides/images/vscode_cmake_preset_selection.png new file mode 100644 index 000000000..f73ede5be Binary files /dev/null and b/doc/ides/images/vscode_cmake_preset_selection.png differ diff --git a/doc/ides/images/vscode_toolbar.png b/doc/ides/images/vscode_toolbar.png new file mode 100644 index 000000000..13bfcbbde Binary files /dev/null and b/doc/ides/images/vscode_toolbar.png differ diff --git a/doc/ides/jetbrains.md b/doc/ides/jetbrains.md new file mode 100644 index 000000000..09a95b92f --- /dev/null +++ b/doc/ides/jetbrains.md @@ -0,0 +1,81 @@ +# [Jetbrains IntellIJ CLion](https://www.jetbrains.com/clion) + +## Linux + +When opening the folder for the first time, select `Open as CMake project` if the IDE ask you between Make and CMake. + +The IDE will open the folder and display the open project wizard: + +![Open Project Wizard](images/jetbrains_open_project_wizard_profiles.png) + +CLion try to determine a base configuration, but Minetest define it's own presets for easier setup. So you need to +delete the `Debug` profile with the `-` sign and close the dialog. + +You should notice a notification telling you 4 presets have been loaded in the bottom right corner. + +![Notification Popup](images/jetbrains_notification_profiles.png) + +Clicking on the `View` link or going to `Settings > Build, Execution, Deployment > CMake` you should get a window +similar to the Open Project Wizard, but with the readonly presets listed. + +![CMake Profiles](images/jetbrains_cmake_profiles.png) + +By default, none of the presets are enabled. You can select them and enable the ones you want. Keep in mind that +triggering the CMake project reload (VCS updates, config changes, etc) will reload all the enabled profiles, so unless +you need the other ones you can enable just `Debug` and `Release`. + +If none of the availlable profiles fit your needs, you can create a `CMakeUserPresets.json` file, edit it by hand and +CLion will load the presets in this window. But the easiest solution is to create an editable copy of one of the availlable +presets with the `Copy` button icon. + +After these steps you should get an IDE like this. + +On the main toolbar at the top right, you have a dropdown for selecting the CMake profile to use for the build. You have another dropdown next to it to select the build target; by default the `minetest` executable will be selected, but you may also have to use `IrrlichtMt` for building just the library . + +![Jetbrains IDE](images/jetbrains_ide.png) + +You can rightclick the topbar to change the project icon and color, for fancier looking IDE. + +## Windows + +Under Windows, the recommended compiler is the [Visual Studio](https://visualstudio.microsoft.com) compiler. + +From the Visual Studio installer, you need to install the `Desktop development with C++` Workload. CMake is already +bundled in CLion. + +By default, CLion have a MinGW compiler bundled, so if you want to use Visual Studio, you need to configure it as the default compiler. + +CLion may ask you in the open project wisard for your compilers, with MinGW and Visual Studio if you have installed it predefined. You can use the arrows to make `Visual Studio` the default. + +If not you can go to `Settings > Build, Execution, Deployment > Toolchains` to change it. + +![Jetbrains Open Project Wizard](images/jetbrains_open_project_wizard_windows_compiler.png) + + + + +Then, the process is roughly similar to Linux, you just need to pick `Visual Studio` as toolchain. + +![Jetbrains Open Project Wizard](images/jetbrains_open_project_wizard_windows_cmake.png) + + + + +[Vcpkg](https://vcpkg.io) is the recommended way of installing Minetest dependencies. + +You need to let CLion know about a `vcpkg` installation to let the bundled CMake use the dependencies seamlessly and get +IDE integration. (Require CLion 2023 or later) + +Go to `View > Tool Windows > Vcpkg` and click the add button. I will open a popup allowing you to add a Vcpkg +installation. By default it will download a new one that you can use to install your dependencies, but if you already +have one installed or you do not plan on using CLion only then install Vcpkg by hand and select your installation +directory. Don't forget to check `Add vcpkg installation to existing CMake profiles`. If you haven't already installed +Minetest dependencies in your vcpkg installation, you can do it right from CLion's Vcpkg tool window. + +![Jetbrains Vcpkg](images/jetbrains_vcpkg.png) + +Reloading the CMake project (should happen automatically, or display a notification for outdated CMake project) will now +load the dependencies. + +[More infos on Vcpkg integration in CLion](https://blog.jetbrains.com/clion/2023/01/support-for-vcpkg-in-clion) + diff --git a/doc/ides/visual_studio.md b/doc/ides/visual_studio.md new file mode 100644 index 000000000..a08a58ea2 --- /dev/null +++ b/doc/ides/visual_studio.md @@ -0,0 +1,7 @@ +# [Visual Studio](https://visualstudio.microsoft.com) + +From the Visual Studio installer, you need to install the `Desktop development with C++` Workload. You need to make sure the `C++ CMake tools for Windows` component is included in the installation details panel. + +You need to install [Vcpkg](https://vcpkg.io) and install Minetest dependencies as stated in the compilation documentation. + +For the packages to be discoverable and used by Visual Studio, you need to run `vcpkg integrate install`. diff --git a/doc/ides/vscode.md b/doc/ides/vscode.md new file mode 100644 index 000000000..6814a7a88 --- /dev/null +++ b/doc/ides/vscode.md @@ -0,0 +1,51 @@ +# [Visual Studio Code](https://code.visualstudio.com) + +VSCode suppport for C/C++ and CMake is provided by +the [Microsoft C/C++ extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack). +You can install it from the VSCode extensions tab. + +If you use a unofficial VSCode distribution like [VSCodium](https://vscodium.com), you will need to install the +extension pack manually by downloading the VSIX files and going to `Extensions > ... > Install from VSIX`. + +CMake support for VSCode uses CMake presets provided by the project by default. + +When you open the Minetest folder with VSCode, you should get a quick pick asking you for the default preset. + +![VSCode CMake Preset Selection](images/vscode_cmake_preset_selection.png) + +You can use the bottom bar to change the CMake profile, change the build target, build, run and debug (running/debugging doesn't build first). + +![VSCode Toolbar](images/vscode_toolbar.png) + +Like most of the VSCode experience, it may be faster to use commands directly (most of the VSCode UI just trigger commands). + +| Command Name | Usecase | +|----------------------------------|----------------------------------| +| `CMake: Select Configure Preset` | Change the current CMake profile | +| `CMake: Set Build Target` | Change the current build target | +| `CMake: Build` | Build current target | +| `CMake: Clean` | Clean build files | +| `CMake: Run Without Debugging` | Run selected run target | +| `CMake: Debug` | Debug selected run target | + +## Windows + +Under Windows, the recommended compiler is the [Visual Studio](https://visualstudio.microsoft.com) compiler. + +From the Visual Studio installer, you need to install the `Desktop development with C++` Workload. + +[Vcpkg](https://vcpkg.io) is the recommended way of installing Minetest dependencies. + +Follow the official documentation to install it and install Minetest dependencies as explained in [Windows compilation process](../compiling/windows.md). + +You need to let CMake know about the `vcpkg` installation in VSCode. + +Modify your `.vscode/settings.json`: + +```json +{ + "cmake.configureSettings": { + "CMAKE_TOOLCHAIN_FILE": "C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake" + } +} +``` diff --git a/doc/lua_api.md b/doc/lua_api.md index 4eea2f7f3..b1412ca85 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -63,6 +63,8 @@ The game directory can contain the following files: * `name`: (Deprecated) same as title. * `description`: Short description to be shown in the content tab. See [Translating content meta](#translating-content-meta). + * `first_mod`: Use this to specify the mod that must be loaded before any other mod. + * `last_mod`: Use this to specify the mod that must be loaded after all other mods * `allowed_mapgens = ` e.g. `allowed_mapgens = v5,v6,flat` Mapgens not in this list are removed from the list of mapgens for the @@ -5794,6 +5796,7 @@ Call these functions only at load time! * `last_login`: The timestamp of the previous login, or nil if player is new * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))` * Called when a player leaves the game + * Does not get executed for connected players on shutdown. * `timed_out`: True for timeout, false for other reasons. * `minetest.register_on_authplayer(function(name, ip, is_success))` * Called when a client attempts to log into an account. @@ -8230,7 +8233,11 @@ child will follow movement and rotation of that bone. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky. (default: `"regular"`) * `textures`: A table containing up to six textures in the following - order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south). + order: Y+ (top), Y- (bottom), X+ (east), X- (west), Z- (south), Z+ (north). + The top and bottom textures are oriented in-line with the east (X+) face (the top edge of the + bottom texture and the bottom edge of the top texture touch the east face). + Some top and bottom textures expect to be aligned with the north face and will need to be rotated + by -90 and 90 degrees, respectively, to fit the eastward orientation. * `clouds`: Boolean for whether clouds appear. (default: `true`) * `sky_color`: A table used in `"regular"` type only, containing the following values (alpha is ignored): diff --git a/doc/menu_lua_api.md b/doc/menu_lua_api.md index cb1f07a90..19540a607 100644 --- a/doc/menu_lua_api.md +++ b/doc/menu_lua_api.md @@ -14,7 +14,8 @@ Callbacks * `core.button_handler(fields)`: called when a button is pressed. * `fields` = `{name1 = value1, name2 = value2, ...}` * `core.event_handler(event)` - * `event`: `"MenuQuit"`, `"KeyEnter"`, `"ExitButton"` or `"EditBoxEnter"` + * `event`: `"MenuQuit"`, `"KeyEnter"`, `"ExitButton"`, `"EditBoxEnter"` or + `"FullscreenChange"` Gamedata diff --git a/games/devtest/game.conf b/games/devtest/game.conf index 0f5656c99..8184881a2 100644 --- a/games/devtest/game.conf +++ b/games/devtest/game.conf @@ -1,2 +1,4 @@ title = Development Test description = Testing environment to help with testing the engine features of Minetest. It can also be helpful in mod development. +first_mod = first_mod +last_mod = last_mod diff --git a/games/devtest/mods/first_mod/init.lua b/games/devtest/mods/first_mod/init.lua new file mode 100644 index 000000000..3909a39cc --- /dev/null +++ b/games/devtest/mods/first_mod/init.lua @@ -0,0 +1 @@ +-- Nothing to do here, loading order is tested in C++ unittests. diff --git a/games/devtest/mods/first_mod/mod.conf b/games/devtest/mods/first_mod/mod.conf new file mode 100644 index 000000000..d35fa8d28 --- /dev/null +++ b/games/devtest/mods/first_mod/mod.conf @@ -0,0 +1,2 @@ +name = first_mod +description = Mod which should be loaded before every other mod. diff --git a/games/devtest/mods/last_mod/init.lua b/games/devtest/mods/last_mod/init.lua new file mode 100644 index 000000000..3909a39cc --- /dev/null +++ b/games/devtest/mods/last_mod/init.lua @@ -0,0 +1 @@ +-- Nothing to do here, loading order is tested in C++ unittests. diff --git a/games/devtest/mods/last_mod/mod.conf b/games/devtest/mods/last_mod/mod.conf new file mode 100644 index 000000000..734bf4c0c --- /dev/null +++ b/games/devtest/mods/last_mod/mod.conf @@ -0,0 +1,5 @@ +name = last_mod +description = Mod which should be loaded as last mod. +# Test dependencies +optional_depends = unittests +depends = first_mod diff --git a/games/devtest/mods/testnodes/textures.lua b/games/devtest/mods/testnodes/textures.lua index 0caaaed9d..86bc3e343 100644 --- a/games/devtest/mods/testnodes/textures.lua +++ b/games/devtest/mods/testnodes/textures.lua @@ -181,14 +181,6 @@ fractal = nil frac_emb = nil checker = nil -do - -- we used to write the textures to our mod folder. in order to avoid - -- duplication errors delete them if they still exist. - local path = core.get_modpath(core.get_current_modname()) .. "/textures/" - os.remove(path .. "testnodes_generated_mb.png") - os.remove(path .. "testnodes_generated_ck.png") -end - local textures_path = core.get_worldpath() .. "/" core.safe_file_write( textures_path .. "testnodes1.png", diff --git a/games/devtest/mods/unittests/mod.conf b/games/devtest/mods/unittests/mod.conf index fa94e01a6..ccff73701 100644 --- a/games/devtest/mods/unittests/mod.conf +++ b/games/devtest/mods/unittests/mod.conf @@ -1,3 +1,4 @@ name = unittests description = Adds automated unit tests for the engine -depends = basenodes +# Also test that it is possible to depend on first_mod +depends = first_mod, basenodes diff --git a/irr/include/IEventReceiver.h b/irr/include/IEventReceiver.h index e0660a6f1..cf7dee3ab 100644 --- a/irr/include/IEventReceiver.h +++ b/irr/include/IEventReceiver.h @@ -331,7 +331,6 @@ struct SEvent //! A bitmap of button states. You can use isButtonPressed() to determine //! if a button is pressed or not. - //! Currently only valid if the event was EMIE_MOUSE_MOVED u32 ButtonStates; //! Is the left button pressed down? diff --git a/irr/include/IMeshBuffer.h b/irr/include/IMeshBuffer.h index 3e2e3d74e..c69a12d1d 100644 --- a/irr/include/IMeshBuffer.h +++ b/irr/include/IMeshBuffer.h @@ -176,6 +176,32 @@ class IMeshBuffer : public virtual IReferenceCounted } return 0; } + + //! Calculate size of vertices and indices in memory + virtual size_t getSize() const + { + size_t ret = 0; + switch (getVertexType()) { + case video::EVT_STANDARD: + ret += sizeof(video::S3DVertex) * getVertexCount(); + break; + case video::EVT_2TCOORDS: + ret += sizeof(video::S3DVertex2TCoords) * getVertexCount(); + break; + case video::EVT_TANGENTS: + ret += sizeof(video::S3DVertexTangents) * getVertexCount(); + break; + } + switch (getIndexType()) { + case video::EIT_16BIT: + ret += sizeof(u16) * getIndexCount(); + break; + case video::EIT_32BIT: + ret += sizeof(u32) * getIndexCount(); + break; + } + return ret; + } }; } // end namespace scene diff --git a/irr/include/IrrlichtDevice.h b/irr/include/IrrlichtDevice.h index 38ba8c63d..11619010c 100644 --- a/irr/include/IrrlichtDevice.h +++ b/irr/include/IrrlichtDevice.h @@ -179,6 +179,11 @@ class IrrlichtDevice : public virtual IReferenceCounted /** \return True if window is fullscreen. */ virtual bool isFullscreen() const = 0; + //! Enables or disables fullscreen mode. + /** Only works on SDL. + \return True on success. */ + virtual bool setFullscreen(bool fullscreen) { return false; } + //! Checks if the window could possibly be visible. /** If this returns false, you should not do any rendering. */ virtual bool isWindowVisible() const { return true; }; diff --git a/irr/src/CIrrDeviceOSX.mm b/irr/src/CIrrDeviceOSX.mm index 8e4843441..67c0ce05c 100644 --- a/irr/src/CIrrDeviceOSX.mm +++ b/irr/src/CIrrDeviceOSX.mm @@ -852,6 +852,7 @@ - (BOOL)isQuit ievent.MouseInput.Wheel *= 10.0f; else ievent.MouseInput.Wheel *= 5.0f; + ievent.MouseInput.ButtonStates = MouseButtonStates; postMouseEvent(event, ievent); break; @@ -1048,6 +1049,7 @@ - (BOOL)isQuit ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; ievent.MouseInput.X = x; ievent.MouseInput.Y = y; + ievent.MouseInput.ButtonStates = MouseButtonStates; postEventFromUser(ievent); } } diff --git a/irr/src/CIrrDeviceSDL.cpp b/irr/src/CIrrDeviceSDL.cpp index b50fd4b4a..81ff37511 100644 --- a/irr/src/CIrrDeviceSDL.cpp +++ b/irr/src/CIrrDeviceSDL.cpp @@ -272,6 +272,19 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters ¶m) : SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0"); #endif + // Minetest has its own signal handler + SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); + + // Disabling the compositor is not a good idea in windowed mode. + // See https://github.com/minetest/minetest/issues/14596 + SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + // These are not interesting for our use + SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); + SDL_SetHint(SDL_HINT_TV_REMOTE_AS_JOYSTICK, "0"); +#endif + // Minetest has its own code to synthesize mouse events from touch events, // so we prevent SDL from doing it. SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); @@ -463,13 +476,7 @@ bool CIrrDeviceSDL::createWindowWithContext() { u32 SDL_Flags = 0; - if (CreationParams.Fullscreen) { -#ifdef _IRR_EMSCRIPTEN_PLATFORM_ - SDL_Flags |= SDL_WINDOW_FULLSCREEN; -#else - SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; -#endif - } + SDL_Flags |= getFullscreenFlag(CreationParams.Fullscreen); if (Resizable) SDL_Flags |= SDL_WINDOW_RESIZABLE; if (CreationParams.WindowMaximized) @@ -673,6 +680,7 @@ bool CIrrDeviceSDL::run() #else irrevent.MouseInput.Wheel = SDL_event.wheel.y; #endif + irrevent.MouseInput.ButtonStates = MouseButtonStates; irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0; irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0; irrevent.MouseInput.X = MouseX; @@ -889,6 +897,14 @@ bool CIrrDeviceSDL::run() IsInBackground = false; break; + case SDL_RENDER_TARGETS_RESET: + os::Printer::log("Received SDL_RENDER_TARGETS_RESET. Rendering is probably broken.", ELL_ERROR); + break; + + case SDL_RENDER_DEVICE_RESET: + os::Printer::log("Received SDL_RENDER_DEVICE_RESET. Rendering is probably broken.", ELL_ERROR); + break; + default: break; } // end switch @@ -1157,14 +1173,37 @@ bool CIrrDeviceSDL::isWindowMaximized() const bool CIrrDeviceSDL::isFullscreen() const { + if (!Window) + return false; + u32 flags = SDL_GetWindowFlags(Window); + return (flags & SDL_WINDOW_FULLSCREEN) != 0 || + (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; +} + +u32 CIrrDeviceSDL::getFullscreenFlag(bool fullscreen) +{ + if (!fullscreen) + return 0; #ifdef _IRR_EMSCRIPTEN_PLATFORM_ - return SDL_GetWindowFlags(0) == SDL_WINDOW_FULLSCREEN; + return SDL_WINDOW_FULLSCREEN; #else - - return CIrrDeviceStub::isFullscreen(); + return SDL_WINDOW_FULLSCREEN_DESKTOP; #endif } +bool CIrrDeviceSDL::setFullscreen(bool fullscreen) +{ + if (!Window) + return false; + // The SDL wiki says that this may trigger SDL_RENDER_TARGETS_RESET, but + // looking at the SDL source, this only happens with D3D, so it's not + // relevant to us. + bool success = SDL_SetWindowFullscreen(Window, getFullscreenFlag(fullscreen)) == 0; + if (!success) + os::Printer::log("SDL_SetWindowFullscreen failed", SDL_GetError(), ELL_ERROR); + return success; +} + bool CIrrDeviceSDL::isWindowVisible() const { return !IsInBackground; diff --git a/irr/src/CIrrDeviceSDL.h b/irr/src/CIrrDeviceSDL.h index a83e8cf5e..c536a8149 100644 --- a/irr/src/CIrrDeviceSDL.h +++ b/irr/src/CIrrDeviceSDL.h @@ -86,6 +86,10 @@ class CIrrDeviceSDL : public CIrrDeviceStub /** \return True if window is fullscreen. */ bool isFullscreen() const override; + //! Enables or disables fullscreen mode. + /** \return True on success. */ + bool setFullscreen(bool fullscreen) override; + //! Checks if the window could possibly be visible. bool isWindowVisible() const override; @@ -299,6 +303,8 @@ class CIrrDeviceSDL : public CIrrDeviceStub bool Resizable; + static u32 getFullscreenFlag(bool fullscreen); + core::rect lastElemPos; struct SKeyMap diff --git a/lib/catch2/CMakeLists.txt b/lib/catch2/CMakeLists.txt index 077272571..252dc11e3 100644 --- a/lib/catch2/CMakeLists.txt +++ b/lib/catch2/CMakeLists.txt @@ -1,8 +1,8 @@ -# catch2 is distributed as a standalone header. +# catch2 is distributed as a standalone header / source amalgamation. # # Downloaded from: # -# https://github.com/catchorg/Catch2/releases/download/v2.13.9/catch.hpp +# https://github.com/catchorg/Catch2/releases/tag/v3.6.0 # # The following changes were made to always print in microseconds, fixed format: # @@ -12,6 +12,7 @@ # - return os << duration.value() << ' ' << duration.unitsAsString(); # + return os << std::fixed << duration.value() << ' ' << duration.unitsAsString(); -add_library(catch2 INTERFACE) +add_library(catch2 STATIC catch_amalgamated.cpp) +target_compile_definitions(catch2 PRIVATE CATCH_CONFIG_NOSTDOUT CATCH_AMALGAMATED_CUSTOM_MAIN) add_library(Catch2::Catch2 ALIAS catch2) target_include_directories(catch2 INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/lib/catch2/catch.hpp b/lib/catch2/catch.hpp deleted file mode 100644 index 9b309bddc..000000000 --- a/lib/catch2/catch.hpp +++ /dev/null @@ -1,17976 +0,0 @@ -/* - * Catch v2.13.10 - * Generated: 2022-10-16 11:01:23.452308 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 10 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -// See e.g.: -// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html -#ifdef __APPLE__ -# include -# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ - (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) -# define CATCH_PLATFORM_MAC -# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -// Only GCC compiler should be used in this block, so other compilers trying to -// mask themselves as GCC should be ignored. -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) - -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -# if !defined(__ibmxl__) && !defined(__CUDACC__) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -# endif - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -# if !defined(__clang__) // Handle Clang masquerading for msvc - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL - -// Only do this if we're not using clang on Windows, which uses `diagnostic push` & `diagnostic pop` -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) -# endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # include - # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template