From 0daa97a5f0148a38166a99e6958a1879bcdbf1ea Mon Sep 17 00:00:00 2001 From: Matthew Paletta Date: Mon, 15 Jun 2020 16:52:47 -0700 Subject: [PATCH 01/13] Added templated move support for antlrcpp::Any --- contributors.txt | 1 + runtime/Cpp/runtime/src/support/Any.h | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/contributors.txt b/contributors.txt index e24449596..c20f1ab12 100644 --- a/contributors.txt +++ b/contributors.txt @@ -244,3 +244,4 @@ YYYY/MM/DD, github id, Full name, email 2020/04/07, deniskyashif, Denis Kyashif, denis.kyashif@gmail.com 2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com 2020/05/31, d-markey, David Markey, dmarkey@free.fr +2020/06/15, mattpaletta, Matthew Paletta, mattpaletta@gmail.com diff --git a/runtime/Cpp/runtime/src/support/Any.h b/runtime/Cpp/runtime/src/support/Any.h index 5db59f6e6..938f04362 100644 --- a/runtime/Cpp/runtime/src/support/Any.h +++ b/runtime/Cpp/runtime/src/support/Any.h @@ -65,16 +65,26 @@ struct ANTLR4CPP_PUBLIC Any return derived->value; } - template + template::value || std::is_copy_assignable::value>::value> operator U() { return as>(); } - template + template::value && !std::is_copy_assignable::value) && (std::is_move_constructible::value || std::is_move_assignable::value)>::value> + operator U() { + return std::move(as>()); + } + + template::value || std::is_copy_assignable::value>::value> operator const U() const { return as>(); } + template::value && !std::is_copy_assignable::value) && (std::is_move_constructible::value || std::is_move_assignable::value)>::value> + operator const U() const { + return std::move(as>()); + } + Any& operator = (const Any& a) { if (_ptr == a._ptr) return *this; @@ -99,7 +109,7 @@ struct ANTLR4CPP_PUBLIC Any virtual ~Any(); - virtual bool equals(Any other) const { + virtual bool equals(const Any& other) const { return _ptr == other._ptr; } -- 2.34.1 From 680a42e023c6c915577de52182dbb732081b2c04 Mon Sep 17 00:00:00 2001 From: Alexander Bigerl Date: Tue, 19 Jan 2021 09:06:21 +0100 Subject: [PATCH 02/13] No building tests/samples for external utfcpp --- runtime/Cpp/runtime/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt index a8503bb61..7979e2a4e 100644 --- a/runtime/Cpp/runtime/CMakeLists.txt +++ b/runtime/Cpp/runtime/CMakeLists.txt @@ -9,8 +9,7 @@ ExternalProject_Add( GIT_TAG "v3.1.1" SOURCE_DIR ${UTFCPP_DIR} UPDATE_DISCONNECTED 1 - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -Dgtest_force_shared_crt=ON - TEST_AFTER_INSTALL 1 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -DUTF8_TESTS=off -DUTF8_SAMPLES=off STEP_TARGETS build) -- 2.34.1 From d2bc3a5cde6221524979990fb7319623e52c8013 Mon Sep 17 00:00:00 2001 From: Alexander Bigerl Date: Tue, 19 Jan 2021 09:08:26 +0100 Subject: [PATCH 03/13] Update contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index d4f853975..35d67ea57 100644 --- a/contributors.txt +++ b/contributors.txt @@ -284,3 +284,4 @@ YYYY/MM/DD, github id, Full name, email 2020/11/26, mr-c, Michael R. Crusoe, 1330696+mr-c@users.noreply.github.com 2020/12/01, maxence-lefebvre, Maxence Lefebvre, maxence-lefebvre@users.noreply.github.com 2020/12/03, electrum, David Phillips, david@acz.org +2020/12/03, bigerl, Alexander Bigerl, bigerl@mail.upb.de -- 2.34.1 From ac10e7bb79a4b6628f6f1bf9c449145e751f9144 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 10 Feb 2021 08:53:04 +0100 Subject: [PATCH 04/13] contributors.txt: sign it --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index 8b185f40d..e8c6f6d16 100644 --- a/contributors.txt +++ b/contributors.txt @@ -286,4 +286,5 @@ YYYY/MM/DD, github id, Full name, email 2020/12/03, electrum, David Phillips, david@acz.org 2021/01/25, l215884529, Qiheng Liu, 13607681+l215884529@users.noreply.github.com 2021/02/02, tsotnikov, Taras Sotnikov, taras.sotnikov@gmail.com +2021/02/10, jirislaby, Jiri Slaby, jirislaby@gmail.com 2021/02/21, namasikanam, Xingyu Xie, namasikanam@gmail.com -- 2.34.1 From 5a808b470e1314b63b0a921178040ccabb357945 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 10 Feb 2021 08:44:32 +0100 Subject: [PATCH 05/13] Cpp/runtime: use utf8cpp from system if possible Try to find system's utf8cpp first, instead of downloading it from github. utf8cpp 3 defines a cmake package, so we can use find_package. Older utf8cpps don't, so we try also find_path. If all that fails, we still fall back to github download. This is needed as distributions cannot download stuff from their build systems. And people want to use libraries/headers from the distribution anyway. I had to reorder the file a bit, so that the libraries are defined through the utf8cpp detection --- runtime/Cpp/runtime/CMakeLists.txt | 79 ++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt index a8503bb61..89515a0b4 100644 --- a/runtime/Cpp/runtime/CMakeLists.txt +++ b/runtime/Cpp/runtime/CMakeLists.txt @@ -1,19 +1,3 @@ - -include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) - -set(THIRDPARTY_DIR ${CMAKE_BINARY_DIR}/runtime/thirdparty) -set(UTFCPP_DIR ${THIRDPARTY_DIR}/utfcpp) -ExternalProject_Add( - utfcpp - GIT_REPOSITORY "git://github.com/nemtrif/utfcpp" - GIT_TAG "v3.1.1" - SOURCE_DIR ${UTFCPP_DIR} - UPDATE_DISCONNECTED 1 - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -Dgtest_force_shared_crt=ON - TEST_AFTER_INSTALL 1 - STEP_TARGETS build) - - include_directories( ${PROJECT_SOURCE_DIR}/runtime/src ${PROJECT_SOURCE_DIR}/runtime/src/atn @@ -23,8 +7,6 @@ include_directories( ${PROJECT_SOURCE_DIR}/runtime/src/tree ${PROJECT_SOURCE_DIR}/runtime/src/tree/pattern ${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath - ${UTFCPP_DIR}/install/include/utf8cpp - ${UTFCPP_DIR}/install/include/utf8cpp/utf8 ) @@ -50,8 +32,49 @@ add_custom_target(make_lib_output_dir ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_OUTPUT_DIR} ) -add_dependencies(antlr4_shared make_lib_output_dir utfcpp) -add_dependencies(antlr4_static make_lib_output_dir utfcpp) +add_dependencies(antlr4_shared make_lib_output_dir) +add_dependencies(antlr4_static make_lib_output_dir) + +find_package(utf8cpp QUIET) + +set(INSTALL_utf8cpp FALSE) + +if (utf8cpp_FOUND) + target_link_libraries(antlr4_shared utf8cpp) + target_link_libraries(antlr4_static utf8cpp) +else() + + # older utf8cpp doesn't define the package above + find_path(utf8cpp_HEADER utf8.h + PATH_SUFFIXES utf8cpp + ) + + if (utf8cpp_HEADER) + include_directories(${utf8cpp_HEADER}) + else() + include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) + set(THIRDPARTY_DIR ${CMAKE_BINARY_DIR}/runtime/thirdparty) + set(UTFCPP_DIR ${THIRDPARTY_DIR}/utfcpp) + ExternalProject_Add( + utf8cpp + GIT_REPOSITORY "git://github.com/nemtrif/utfcpp" + GIT_TAG "v3.1.1" + SOURCE_DIR ${UTFCPP_DIR} + UPDATE_DISCONNECTED 1 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -Dgtest_force_shared_crt=ON + TEST_AFTER_INSTALL 1 + STEP_TARGETS build) + + include_directories( + ${UTFCPP_DIR}/install/include/utf8cpp + ${UTFCPP_DIR}/install/include/utf8cpp/utf8 + ) + + add_dependencies(antlr4_shared utf8cpp) + add_dependencies(antlr4_static utf8cpp) + set(INSTALL_utf8cpp TRUE) + endif() +endif() if(CMAKE_SYSTEM_NAME MATCHES "Linux") target_link_libraries(antlr4_shared ${UUID_LIBRARIES}) @@ -131,13 +154,15 @@ install(DIRECTORY "${PROJECT_SOURCE_DIR}/runtime/src/" FILES_MATCHING PATTERN "*.h" ) -install(FILES "${UTFCPP_DIR}/source/utf8.h" - DESTINATION "include/antlr4-runtime") -install(DIRECTORY "${UTFCPP_DIR}/source/utf8" - DESTINATION "include/antlr4-runtime" - COMPONENT dev - FILES_MATCHING PATTERN "*.h" - ) +if (INSTALL_utf8cpp) + install(FILES "${UTFCPP_DIR}/source/utf8.h" + DESTINATION "include/antlr4-runtime") + install(DIRECTORY "${UTFCPP_DIR}/source/utf8" + DESTINATION "include/antlr4-runtime" + COMPONENT dev + FILES_MATCHING PATTERN "*.h" + ) +endif() -- 2.34.1 From e7bdb71a2863f5e9555d4539a32c03408669269b Mon Sep 17 00:00:00 2001 From: Andrei DAMIAN Date: Sat, 3 Apr 2021 18:22:17 +0300 Subject: [PATCH 06/13] c++ finally don't use std::function --- runtime/Cpp/runtime/src/antlr4-common.h | 1 - runtime/Cpp/runtime/src/support/CPPUtils.cpp | 6 ------ runtime/Cpp/runtime/src/support/CPPUtils.h | 10 +++++++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/runtime/Cpp/runtime/src/antlr4-common.h b/runtime/Cpp/runtime/src/antlr4-common.h index 47312978a..020c6a560 100644 --- a/runtime/Cpp/runtime/src/antlr4-common.h +++ b/runtime/Cpp/runtime/src/antlr4-common.h @@ -34,7 +34,6 @@ #include #include #include -#include #ifndef USE_UTF8_INSTEAD_OF_CODECVT #include diff --git a/runtime/Cpp/runtime/src/support/CPPUtils.cpp b/runtime/Cpp/runtime/src/support/CPPUtils.cpp index 86a3751a2..496f6c932 100755 --- a/runtime/Cpp/runtime/src/support/CPPUtils.cpp +++ b/runtime/Cpp/runtime/src/support/CPPUtils.cpp @@ -202,12 +202,6 @@ namespace antlrcpp { return result; } - //----------------- FinallyAction ------------------------------------------------------------------------------------ - - FinalAction finally(std::function f) { - return FinalAction(f); - } - //----------------- SingleWriteMultipleRead -------------------------------------------------------------------------- void SingleWriteMultipleReadLock::readLock() { diff --git a/runtime/Cpp/runtime/src/support/CPPUtils.h b/runtime/Cpp/runtime/src/support/CPPUtils.h index fc83503cf..5f2ad609f 100644 --- a/runtime/Cpp/runtime/src/support/CPPUtils.h +++ b/runtime/Cpp/runtime/src/support/CPPUtils.h @@ -19,8 +19,9 @@ namespace antlrcpp { std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true); // Using RAII + a lambda to implement a "finally" replacement. + template struct FinalAction { - FinalAction(std::function f) : _cleanUp { f } {} + FinalAction(OnEnd f) : _cleanUp { std::move(f) } {} FinalAction(FinalAction &&other) : _cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) { other._enabled = false; // Don't trigger the lambda after ownership has moved. @@ -29,11 +30,14 @@ namespace antlrcpp { void disable() { _enabled = false; } private: - std::function _cleanUp; + OnEnd _cleanUp; bool _enabled {true}; }; - ANTLR4CPP_PUBLIC FinalAction finally(std::function f); + template + FinalAction finally(OnEnd f) { + return FinalAction(std::move(f)); + } // Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places. template -- 2.34.1 From 0172e8661f97544627c74a65ae9f8cf8994e6afb Mon Sep 17 00:00:00 2001 From: b1f6c1c4 Date: Wed, 7 Apr 2021 17:42:27 -0400 Subject: [PATCH 07/13] Update ExternalAntlr4Cpp.cmake --- runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake b/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake index 4d037cf50..18adff3bb 100644 --- a/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake +++ b/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake @@ -112,7 +112,7 @@ else() EXCLUDE_FROM_ALL 1) endif() -# Seperate build step as rarely people want both +# Separate build step as rarely people want both set(ANTLR4_BUILD_DIR ${ANTLR4_ROOT}) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0") # CMake 3.14 builds in above's SOURCE_SUBDIR when BUILD_IN_SOURCE is true -- 2.34.1 From e6023b7555186594221e1c83c7cd2303f9ce0ba3 Mon Sep 17 00:00:00 2001 From: b1f6c1c4 Date: Wed, 7 Apr 2021 17:45:03 -0400 Subject: [PATCH 08/13] sign contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index 39af403dc..bbc29d10c 100644 --- a/contributors.txt +++ b/contributors.txt @@ -290,3 +290,4 @@ YYYY/MM/DD, github id, Full name, email 2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com 2021/03/02, hackeris 2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com +2021/04/07, b1f6c1c4, Jinzheng Tu, b1f6c1c4@gmail.com -- 2.34.1 From 6a46c1dcb0533effd22d9e1723149fbdf9b97142 Mon Sep 17 00:00:00 2001 From: Alexander Bigerl Date: Thu, 8 Apr 2021 16:24:49 +0200 Subject: [PATCH 09/13] Update contributors.txt --- contributors.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index a95be394b..cfb17f41d 100644 --- a/contributors.txt +++ b/contributors.txt @@ -290,4 +290,4 @@ YYYY/MM/DD, github id, Full name, email 2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com 2021/03/02, hackeris 2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com -2020/04/08, bigerl, Alexander Bigerl, bigerl@mail.upb.de +2021/04/08, bigerl, Alexander Bigerl, bigerl@mail.upb.de -- 2.34.1 From 4b4ca4058a6b5bb46b3388ffefce1d621687b06c Mon Sep 17 00:00:00 2001 From: Mike Lischke Date: Fri, 9 Apr 2021 14:18:25 +0200 Subject: [PATCH 10/13] Revert "Cpp target: No building tests/samples for external utfcpp" --- contributors.txt | 3 +-- runtime/Cpp/runtime/CMakeLists.txt | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/contributors.txt b/contributors.txt index fdc21aa6f..d475526d3 100644 --- a/contributors.txt +++ b/contributors.txt @@ -291,5 +291,4 @@ YYYY/MM/DD, github id, Full name, email 2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com 2021/03/02, hackeris 2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com -2021/04/08, bigerl, Alexander Bigerl, bigerl@mail.upb.de -2021/04/07, b1f6c1c4, Jinzheng Tu, b1f6c1c4@gmail.com \ No newline at end of file +2021/04/07, b1f6c1c4, Jinzheng Tu, b1f6c1c4@gmail.com diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt index 78fbf7d25..89515a0b4 100644 --- a/runtime/Cpp/runtime/CMakeLists.txt +++ b/runtime/Cpp/runtime/CMakeLists.txt @@ -1,16 +1,3 @@ -include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) - -set(THIRDPARTY_DIR ${CMAKE_BINARY_DIR}/runtime/thirdparty) -set(UTFCPP_DIR ${THIRDPARTY_DIR}/utfcpp) -ExternalProject_Add( - utfcpp - GIT_REPOSITORY "git://github.com/nemtrif/utfcpp" - GIT_TAG "v3.1.1" - SOURCE_DIR ${UTFCPP_DIR} - UPDATE_DISCONNECTED 1 - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -DUTF8_TESTS=off -DUTF8_SAMPLES=off - STEP_TARGETS build) - include_directories( ${PROJECT_SOURCE_DIR}/runtime/src ${PROJECT_SOURCE_DIR}/runtime/src/atn -- 2.34.1 From 49cf9d4fe2e5b462bd45b9ec162191cf761b6f94 Mon Sep 17 00:00:00 2001 From: Alexander Bigerl Date: Sat, 24 Apr 2021 18:55:46 +0200 Subject: [PATCH 11/13] C++ runtime: disable build of dep utf8cpp tests and samples --- runtime/Cpp/runtime/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt index 89515a0b4..c10a4bf31 100644 --- a/runtime/Cpp/runtime/CMakeLists.txt +++ b/runtime/Cpp/runtime/CMakeLists.txt @@ -61,8 +61,7 @@ else() GIT_TAG "v3.1.1" SOURCE_DIR ${UTFCPP_DIR} UPDATE_DISCONNECTED 1 - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -Dgtest_force_shared_crt=ON - TEST_AFTER_INSTALL 1 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -DUTF8_TESTS=off -DUTF8_SAMPLES=off STEP_TARGETS build) include_directories( -- 2.34.1 From d5e8ada699d7382c17c2b08e75a7695339db54d3 Mon Sep 17 00:00:00 2001 From: Alexander Bigerl Date: Sat, 24 Apr 2021 18:55:54 +0200 Subject: [PATCH 12/13] add bigerl to contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index d5ebacd47..368c00d28 100644 --- a/contributors.txt +++ b/contributors.txt @@ -293,3 +293,4 @@ YYYY/MM/DD, github id, Full name, email 2021/03/02, hackeris 2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com 2021/04/07, b1f6c1c4, Jinzheng Tu, b1f6c1c4@gmail.com +2021/04/24, bigerl, Alexander Bigerl, alexander [äät] bigerl [pkt] eu -- 2.34.1 From 90f99604c6d0a18ebf2b27483568f1f775d1c271 Mon Sep 17 00:00:00 2001 From: forgetest1 Date: Mon, 18 Oct 2021 11:41:53 +0800 Subject: [PATCH 13/13] ADD file via upload --- 修正 (1).txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 修正 (1).txt diff --git a/修正 (1).txt b/修正 (1).txt new file mode 100644 index 000000000..4733641dd --- /dev/null +++ b/修正 (1).txt @@ -0,0 +1 @@ +234234 \ No newline at end of file -- 2.34.1