From edb0be3079a7ae71b55ef442d4c99acd9de7810f Mon Sep 17 00:00:00 2001 From: Markus Mertama Date: Sun, 8 Sep 2024 02:54:24 +0300 Subject: [PATCH] Really careless update to C++20 --- README.md | 2 +- affiliates/test_rpc/CMakeLists.txt | 2 +- examples/audio/CMakeLists.txt | 2 +- examples/dialogs/CMakeLists.txt | 2 +- examples/drawcanvas/CMakeLists.txt | 2 +- examples/eval/CMakeLists.txt | 2 +- examples/fire/CMakeLists.txt | 2 +- examples/flakes/CMakeLists.txt | 2 +- examples/hello/CMakeLists.txt | 2 +- examples/hello2/CMakeLists.txt | 2 +- examples/helloworld/CMakeLists.txt | 2 +- examples/imageblit/CMakeLists.txt | 2 +- examples/minihello/CMakeLists.txt | 2 +- examples/snowflakes/CMakeLists.txt | 2 +- examples/tick/CMakeLists.txt | 6 +++--- gempyrelib/CMakeLists.txt | 4 ++-- gempyrelib/include/gempyre_bitmap.h | 15 +++++++++++++++ scripts/gencmake.py | 2 +- test/apitests/CMakeLists.txt | 2 +- test/install_test/CMakeLists.txt | 2 +- test/mock_browser/CMakeLists.txt | 2 +- test/unittests/CMakeLists.txt | 2 +- 22 files changed, 39 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 852ebf2a..a4da8d6a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ For the application, Gempyre let engine to be implemented using C++ (or Python), Gempyre is intended for applications that has a solid C++ core (or C), and allows rapid UI development without extra hassle with platform specific UI development. -Gempyre is multiplatform, its core is written using C++17 (tested on OSX (CLang), Ubuntu (gcc), Raspberry OS (gcc) and Windows 10 (MSVC and MinGW) ). The Gempyre framework can be downloaded at Github under MIT license. +Gempyre is multiplatform, its core is built using C++20 (tested on OSX (CLang), Ubuntu (gcc), Raspberry OS (gcc) and Windows 10 (MSVC and MinGW) ). The Gempyre framework can be downloaded at Github under MIT license. Gempyre itself does not contain an application window. The UI is drawn using external application. Some OSes defaults to system browser, some Python webview. However that is fully configurable per application. diff --git a/affiliates/test_rpc/CMakeLists.txt b/affiliates/test_rpc/CMakeLists.txt index ea879d19..81065d58 100644 --- a/affiliates/test_rpc/CMakeLists.txt +++ b/affiliates/test_rpc/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME affiliates_test_rpc) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/audio/CMakeLists.txt b/examples/audio/CMakeLists.txt index bc5cba8c..3431f46d 100644 --- a/examples/audio/CMakeLists.txt +++ b/examples/audio/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME audio) project (${NAME}test) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/dialogs/CMakeLists.txt b/examples/dialogs/CMakeLists.txt index d07951f2..e9713e94 100644 --- a/examples/dialogs/CMakeLists.txt +++ b/examples/dialogs/CMakeLists.txt @@ -1,7 +1,7 @@ set(NAME dialogs_test) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/drawcanvas/CMakeLists.txt b/examples/drawcanvas/CMakeLists.txt index e73f8437..00fa2abe 100644 --- a/examples/drawcanvas/CMakeLists.txt +++ b/examples/drawcanvas/CMakeLists.txt @@ -5,7 +5,7 @@ project (${NAME}test) include(../../scripts/gempyre.cmake) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include) diff --git a/examples/eval/CMakeLists.txt b/examples/eval/CMakeLists.txt index bb6d00c9..b0dc3629 100644 --- a/examples/eval/CMakeLists.txt +++ b/examples/eval/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME eval) project (${NAME}test) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/fire/CMakeLists.txt b/examples/fire/CMakeLists.txt index c3c6c628..04670272 100644 --- a/examples/fire/CMakeLists.txt +++ b/examples/fire/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME fire) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/flakes/CMakeLists.txt b/examples/flakes/CMakeLists.txt index 4209213c..b26385b8 100644 --- a/examples/flakes/CMakeLists.txt +++ b/examples/flakes/CMakeLists.txt @@ -5,7 +5,7 @@ project (${NAME}test) include(../../scripts/gempyre.cmake) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/hello/CMakeLists.txt b/examples/hello/CMakeLists.txt index 6f3399a7..753c2af3 100644 --- a/examples/hello/CMakeLists.txt +++ b/examples/hello/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME hello) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/hello2/CMakeLists.txt b/examples/hello2/CMakeLists.txt index 5e356233..0b227f89 100644 --- a/examples/hello2/CMakeLists.txt +++ b/examples/hello2/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME hello2) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/helloworld/CMakeLists.txt b/examples/helloworld/CMakeLists.txt index 873ac416..3bffc51c 100644 --- a/examples/helloworld/CMakeLists.txt +++ b/examples/helloworld/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.18) project (helloworld) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/imageblit/CMakeLists.txt b/examples/imageblit/CMakeLists.txt index c8601920..772f243a 100644 --- a/examples/imageblit/CMakeLists.txt +++ b/examples/imageblit/CMakeLists.txt @@ -5,7 +5,7 @@ project (${NAME}test) include(../../scripts/gempyre.cmake) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/minihello/CMakeLists.txt b/examples/minihello/CMakeLists.txt index e579b78a..ce823edc 100644 --- a/examples/minihello/CMakeLists.txt +++ b/examples/minihello/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) set(NAME minihello) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/snowflakes/CMakeLists.txt b/examples/snowflakes/CMakeLists.txt index f41a9556..79da9286 100644 --- a/examples/snowflakes/CMakeLists.txt +++ b/examples/snowflakes/CMakeLists.txt @@ -5,7 +5,7 @@ project (${NAME}test) include(../../scripts/gempyre.cmake) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include diff --git a/examples/tick/CMakeLists.txt b/examples/tick/CMakeLists.txt index f5c8236c..e1985425 100644 --- a/examples/tick/CMakeLists.txt +++ b/examples/tick/CMakeLists.txt @@ -3,14 +3,14 @@ cmake_minimum_required (VERSION 3.18) set(NAME tick) project (${NAME}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) if(MSVC) if (MSVC_VERSION GREATER_EQUAL "1900") include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("/std:c++17" _cpp_latest_flag_supported) + CHECK_CXX_COMPILER_FLAG("/std:c++20" _cpp_latest_flag_supported) if (_cpp_latest_flag_supported) - add_compile_options("/std:c++17") + add_compile_options("/std:c++20") endif() endif() endif() diff --git a/gempyrelib/CMakeLists.txt b/gempyrelib/CMakeLists.txt index e2be15a4..1b1111ac 100644 --- a/gempyrelib/CMakeLists.txt +++ b/gempyrelib/CMakeLists.txt @@ -1,7 +1,7 @@ #cmake_minimum_required (VERSION 3.18) -project (gempyre VERSION 1.4.2 LANGUAGES CXX C) +project (gempyre VERSION 1.5.0 LANGUAGES CXX C) # Must use GNUInstallDirs to install libraries into correct # locations on all platforms. include(GNUInstallDirs) @@ -210,7 +210,7 @@ else() endif() endif() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_definitions(_GLIBCXX_DEBUG) diff --git a/gempyrelib/include/gempyre_bitmap.h b/gempyrelib/include/gempyre_bitmap.h index 6a77c7ed..d63ed05f 100644 --- a/gempyrelib/include/gempyre_bitmap.h +++ b/gempyrelib/include/gempyre_bitmap.h @@ -248,9 +248,24 @@ namespace Gempyre { /// underlaying data const uint8_t* const_data() const; + + /// @brief Copy pixels into bitmap + /// @param bytes (TODO will change to std::span when moving to C++20) + /// @param offset + /// @return false on overflow, otherwise true + template, int> = 0> + bool set_data(const T& bytes, size_t offset = 0) { + if(bytes.size() + offset > size()) + return false; + std::memcpy(inner_data() + offset, bytes.data(), sizeof(Color::type) * bytes.size()); + return true; + } + protected: /// @cond INTERNAL void copy_from(const Bitmap& other); + Color::type* inner_data(); + std::size_t size() const; /// @endcond private: friend class Gempyre::CanvasElement; diff --git a/scripts/gencmake.py b/scripts/gencmake.py index 48991a33..885d41f6 100644 --- a/scripts/gencmake.py +++ b/scripts/gencmake.py @@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.14) set(NAME !NAME) project (${NAME} VERSION 0.1) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( diff --git a/test/apitests/CMakeLists.txt b/test/apitests/CMakeLists.txt index 1f9f4d5a..3fe32a8b 100644 --- a/test/apitests/CMakeLists.txt +++ b/test/apitests/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) include(GoogleTest) project (apitests) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include include diff --git a/test/install_test/CMakeLists.txt b/test/install_test/CMakeLists.txt index 09d078c3..d2350b92 100644 --- a/test/install_test/CMakeLists.txt +++ b/test/install_test/CMakeLists.txt @@ -8,7 +8,7 @@ if(gempyre_FOUND) include(gempyre) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 20) include_directories( include diff --git a/test/mock_browser/CMakeLists.txt b/test/mock_browser/CMakeLists.txt index bb5ecf10..9ea4822f 100644 --- a/test/mock_browser/CMakeLists.txt +++ b/test/mock_browser/CMakeLists.txt @@ -1,6 +1,6 @@ project(mock_browser) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) if(NOT USE_LIBWEBSOCKETS) include(${CMAKE_SOURCE_DIR}/gempyrelib/cmake/libwebsockets.cmake) diff --git a/test/unittests/CMakeLists.txt b/test/unittests/CMakeLists.txt index d91aaa63..015bac57 100644 --- a/test/unittests/CMakeLists.txt +++ b/test/unittests/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.18) include(GoogleTest) project (unittests) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include_directories( ../../gempyrelib/include ../../gempyrelib/src