From db878c54c598abc90bc543fd9bb9f3b7641f6875 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 20 Jan 2024 10:08:15 +0000 Subject: [PATCH] Fix C++ standard syntax compatibility for repair() --- include/etl/circular_buffer.h | 14 +++++--------- include/etl/deque.h | 8 +++----- include/etl/platform.h | 9 +++++++++ include/etl/string.h | 10 ++++++---- include/etl/u16string.h | 10 ++++++---- include/etl/u32string.h | 10 ++++++---- include/etl/u8string.h | 10 ++++++---- include/etl/vector.h | 21 +++++++++++---------- include/etl/wstring.h | 10 ++++++---- 9 files changed, 58 insertions(+), 44 deletions(-) diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index a099ca4a..f57d863d 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -1208,11 +1208,9 @@ namespace etl /// Fix the internal pointers after a low level memory copy. //************************************************************************* #ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE - virtual -#endif + virtual void repair() ETL_OVERRIDE +#else void repair() -#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE - ETL_OVERRIDE #endif { ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::circular_buffer_incompatible_type)); @@ -1395,11 +1393,9 @@ namespace etl /// Fix the internal pointers after a low level memory copy. //************************************************************************* #ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE - virtual -#endif - void repair() -#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { } diff --git a/include/etl/deque.h b/include/etl/deque.h index 8a11063e..5586360a 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -2483,11 +2483,9 @@ namespace etl /// Fix the internal pointers after a low level memory copy. //************************************************************************* #ifdef ETL_IDEQUE_REPAIR_ENABLE - virtual -#endif - void repair() -#ifdef ETL_IDEQUE_REPAIR_ENABLE - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED diff --git a/include/etl/platform.h b/include/etl/platform.h index 360f9027..17c7961d 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -202,6 +202,14 @@ SOFTWARE. #define ETL_HAS_IDEQUE_REPAIR 0 #endif +//************************************* +// Option to enable repair-after-memcpy for icircular_buffer. +#if defined(ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE) +#define ETL_HAS_ICIRCULAR_BUFFER_REPAIR 1 +#else +#define ETL_HAS_ICIRCULAR_BUFFER_REPAIR 0 +#endif + //************************************* // Indicate if C++ exceptions are enabled. #if defined(ETL_THROW_EXCEPTIONS) @@ -477,6 +485,7 @@ namespace etl static ETL_CONSTANT bool has_string_clear_after_use = (ETL_HAS_STRING_CLEAR_AFTER_USE == 1); static ETL_CONSTANT bool has_istring_repair = (ETL_HAS_ISTRING_REPAIR == 1); static ETL_CONSTANT bool has_ivector_repair = (ETL_HAS_IVECTOR_REPAIR == 1); + static ETL_CONSTANT bool has_icircular_buffer_repair = (ETL_HAS_ICIRCULAR_BUFFER_REPAIR == 1); static ETL_CONSTANT bool has_mutable_array_view = (ETL_HAS_MUTABLE_ARRAY_VIEW == 1); static ETL_CONSTANT bool has_ideque_repair = (ETL_HAS_IDEQUE_REPAIR == 1); static ETL_CONSTANT bool has_virtual_messages = (ETL_HAS_VIRTUAL_MESSAGES == 1); diff --git a/include/etl/string.h b/include/etl/string.h index 5f925337..1fbc19d2 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -246,9 +246,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { etl::istring::repair_buffer(buffer); @@ -434,9 +435,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { } diff --git a/include/etl/u16string.h b/include/etl/u16string.h index 2c100c8b..c0fea3a2 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -230,9 +230,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { etl::iu16string::repair_buffer(buffer); @@ -414,9 +415,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { } diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 88d0ed44..766a0cbc 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -230,9 +230,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { etl::iu32string::repair_buffer(buffer); @@ -414,9 +415,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { } diff --git a/include/etl/u8string.h b/include/etl/u8string.h index 9d8b9458..015ef3c1 100644 --- a/include/etl/u8string.h +++ b/include/etl/u8string.h @@ -247,9 +247,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { etl::iu8string::repair_buffer(buffer); @@ -435,9 +436,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { } diff --git a/include/etl/vector.h b/include/etl/vector.h index af236dc7..4150c443 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -1346,11 +1346,9 @@ namespace etl /// Fix the internal pointers after a low level memory copy. //************************************************************************* #ifdef ETL_IVECTOR_REPAIR_ENABLE - virtual -#endif + virtual void repair() ETL_OVERRIDE +#else void repair() -#ifdef ETL_IVECTOR_REPAIR_ENABLE - ETL_OVERRIDE #endif { ETL_ASSERT_OR_RETURN(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); @@ -1527,9 +1525,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #ifdef ETL_IVECTOR_REPAIR_ENABLE - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { } @@ -1649,9 +1648,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #ifdef ETL_IVECTOR_REPAIR_ENABLE - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { etl::ivector::repair_buffer(buffer); @@ -1806,9 +1806,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #ifdef ETL_IVECTOR_REPAIR_ENABLE - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { etl::ivector::repair_buffer(this->p_buffer); diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 20ce4ac4..683359de 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -231,9 +231,10 @@ namespace etl /// Fix the internal pointers after a low level memory copy. //************************************************************************* #if ETL_HAS_ISTRING_REPAIR - virtual -#endif + virtual void repair() ETL_OVERRIDE +#else void repair() +#endif { etl::iwstring::repair_buffer(buffer); } @@ -414,9 +415,10 @@ namespace etl //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* - void repair() #if ETL_HAS_ISTRING_REPAIR - ETL_OVERRIDE + virtual void repair() ETL_OVERRIDE +#else + void repair() #endif { }