From 4e261068a1ab916c58f2a4c31805451a276799f1 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Wed, 16 Jun 2021 21:08:01 +0200 Subject: [PATCH] clang-format: set IndentPPDirectives to AfterHash --- .clang-format | 1 + extras/tests/FailingBuilds/read_long_long.cpp | 4 +- .../tests/FailingBuilds/write_long_long.cpp | 4 +- extras/tests/Misc/unsigned_char.cpp | 2 +- src/ArduinoJson.hpp | 10 +- src/ArduinoJson/Array/ElementProxy.hpp | 6 +- src/ArduinoJson/Configuration.hpp | 247 +++++++++--------- .../Deserialization/DeserializationError.hpp | 2 +- src/ArduinoJson/Deserialization/Reader.hpp | 8 +- src/ArduinoJson/Json/Utf16.hpp | 14 +- src/ArduinoJson/Namespace.hpp | 24 +- src/ArduinoJson/Numbers/Integer.hpp | 12 +- src/ArduinoJson/Numbers/convertNumber.hpp | 20 +- src/ArduinoJson/Object/MemberProxy.hpp | 6 +- src/ArduinoJson/Polyfills/assert.hpp | 6 +- src/ArduinoJson/Polyfills/attributes.hpp | 54 ++-- src/ArduinoJson/Polyfills/limits.hpp | 6 +- src/ArduinoJson/Polyfills/static_array.hpp | 32 +-- .../Polyfills/type_traits/is_convertible.hpp | 6 +- src/ArduinoJson/Serialization/Writer.hpp | 8 +- src/ArduinoJson/Strings/IsWriteableString.hpp | 4 +- src/ArduinoJson/Strings/StringAdapters.hpp | 8 +- src/ArduinoJson/Variant/VariantData.hpp | 16 +- 23 files changed, 251 insertions(+), 249 deletions(-) diff --git a/.clang-format b/.clang-format index 63de3819..25f529f5 100644 --- a/.clang-format +++ b/.clang-format @@ -4,6 +4,7 @@ BasedOnStyle: Google Standard: Cpp03 AllowShortFunctionsOnASingleLine: Empty IncludeBlocks: Preserve +IndentPPDirectives: AfterHash # Always break after if to get accurate coverage AllowShortIfStatementsOnASingleLine: false diff --git a/extras/tests/FailingBuilds/read_long_long.cpp b/extras/tests/FailingBuilds/read_long_long.cpp index 71e71200..242231f2 100644 --- a/extras/tests/FailingBuilds/read_long_long.cpp +++ b/extras/tests/FailingBuilds/read_long_long.cpp @@ -6,11 +6,11 @@ #include #if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8 -#error This test requires sizeof(long) < 8 +# error This test requires sizeof(long) < 8 #endif #if !ARDUINOJSON_HAS_LONG_LONG -#error This test requires C++11 +# error This test requires C++11 #endif ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(long long) diff --git a/extras/tests/FailingBuilds/write_long_long.cpp b/extras/tests/FailingBuilds/write_long_long.cpp index 35c1343f..130fabb5 100644 --- a/extras/tests/FailingBuilds/write_long_long.cpp +++ b/extras/tests/FailingBuilds/write_long_long.cpp @@ -6,11 +6,11 @@ #include #if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8 -#error This test requires sizeof(long) < 8 +# error This test requires sizeof(long) < 8 #endif #if !ARDUINOJSON_HAS_LONG_LONG -#error This test requires C++11 +# error This test requires C++11 #endif int main() { diff --git a/extras/tests/Misc/unsigned_char.cpp b/extras/tests/Misc/unsigned_char.cpp index d63f4727..acdbe93c 100644 --- a/extras/tests/Misc/unsigned_char.cpp +++ b/extras/tests/Misc/unsigned_char.cpp @@ -6,7 +6,7 @@ #include #if defined(__clang__) -#define CONFLICTS_WITH_BUILTIN_OPERATOR +# define CONFLICTS_WITH_BUILTIN_OPERATOR #endif TEST_CASE("unsigned char[]") { diff --git a/src/ArduinoJson.hpp b/src/ArduinoJson.hpp index 28d42eef..d16ca08c 100644 --- a/src/ArduinoJson.hpp +++ b/src/ArduinoJson.hpp @@ -7,11 +7,11 @@ #include "ArduinoJson/Configuration.hpp" #if !ARDUINOJSON_DEBUG -#ifdef __clang__ -#pragma clang system_header -#elif defined __GNUC__ -#pragma GCC system_header -#endif +# ifdef __clang__ +# pragma clang system_header +# elif defined __GNUC__ +# pragma GCC system_header +# endif #endif #include "ArduinoJson/Array/ArrayRef.hpp" diff --git a/src/ArduinoJson/Array/ElementProxy.hpp b/src/ArduinoJson/Array/ElementProxy.hpp index c6062e49..7ee7f03b 100644 --- a/src/ArduinoJson/Array/ElementProxy.hpp +++ b/src/ArduinoJson/Array/ElementProxy.hpp @@ -10,8 +10,8 @@ #include #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4522) +# pragma warning(push) +# pragma warning(disable : 4522) #endif namespace ARDUINOJSON_NAMESPACE { @@ -189,5 +189,5 @@ class ElementProxy : public VariantOperators >, } // namespace ARDUINOJSON_NAMESPACE #ifdef _MSC_VER -#pragma warning(pop) +# pragma warning(pop) #endif diff --git a/src/ArduinoJson/Configuration.hpp b/src/ArduinoJson/Configuration.hpp index 0c0d4c48..dbc8ff1d 100644 --- a/src/ArduinoJson/Configuration.hpp +++ b/src/ArduinoJson/Configuration.hpp @@ -5,251 +5,252 @@ #pragma once #if __cplusplus >= 201103L -#define ARDUINOJSON_HAS_LONG_LONG 1 -#define ARDUINOJSON_HAS_NULLPTR 1 -#define ARDUINOJSON_HAS_RVALUE_REFERENCES 1 +# define ARDUINOJSON_HAS_LONG_LONG 1 +# define ARDUINOJSON_HAS_NULLPTR 1 +# define ARDUINOJSON_HAS_RVALUE_REFERENCES 1 #else -#define ARDUINOJSON_HAS_LONG_LONG 0 -#define ARDUINOJSON_HAS_NULLPTR 0 -#define ARDUINOJSON_HAS_RVALUE_REFERENCES 0 +# define ARDUINOJSON_HAS_LONG_LONG 0 +# define ARDUINOJSON_HAS_NULLPTR 0 +# define ARDUINOJSON_HAS_RVALUE_REFERENCES 0 #endif #if defined(_MSC_VER) && !ARDUINOJSON_HAS_LONG_LONG -#define ARDUINOJSON_HAS_INT64 1 +# define ARDUINOJSON_HAS_INT64 1 #else -#define ARDUINOJSON_HAS_INT64 0 +# define ARDUINOJSON_HAS_INT64 0 #endif // Small or big machine? #ifndef ARDUINOJSON_EMBEDDED_MODE -#if defined(ARDUINO) /* Arduino*/ \ - || defined(__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench */ \ - || defined(__XC) /* MPLAB XC compiler */ \ - || defined(__ARMCC_VERSION) /* Keil ARM Compiler */ \ - || defined(__AVR) /* Atmel AVR8/GNU C Compiler */ -#define ARDUINOJSON_EMBEDDED_MODE 1 -#else -#define ARDUINOJSON_EMBEDDED_MODE 0 -#endif +# if defined(ARDUINO) /* Arduino*/ \ + || defined(__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench */ \ + || defined(__XC) /* MPLAB XC compiler */ \ + || defined(__ARMCC_VERSION) /* Keil ARM Compiler */ \ + || defined(__AVR) /* Atmel AVR8/GNU C Compiler */ +# define ARDUINOJSON_EMBEDDED_MODE 1 +# else +# define ARDUINOJSON_EMBEDDED_MODE 0 +# endif #endif // Auto enable std::stream if the right headers are here and no conflicting // macro is defined #if !defined(ARDUINOJSON_ENABLE_STD_STREAM) && defined(__has_include) -#if __has_include() && \ +# if __has_include() && \ __has_include() && \ !defined(min) && \ !defined(max) -#define ARDUINOJSON_ENABLE_STD_STREAM 1 -#else -#define ARDUINOJSON_ENABLE_STD_STREAM 0 -#endif +# define ARDUINOJSON_ENABLE_STD_STREAM 1 +# else +# define ARDUINOJSON_ENABLE_STD_STREAM 0 +# endif #endif // Auto enable std::string if the right header is here and no conflicting // macro is defined #if !defined(ARDUINOJSON_ENABLE_STD_STRING) && defined(__has_include) -#if __has_include() && !defined(min) && !defined(max) -#define ARDUINOJSON_ENABLE_STD_STRING 1 -#else -#define ARDUINOJSON_ENABLE_STD_STRING 0 -#endif +# if __has_include() && !defined(min) && !defined(max) +# define ARDUINOJSON_ENABLE_STD_STRING 1 +# else +# define ARDUINOJSON_ENABLE_STD_STRING 0 +# endif #endif #if ARDUINOJSON_EMBEDDED_MODE // Store floats by default to reduce the memory usage (issue #134) -#ifndef ARDUINOJSON_USE_DOUBLE -#define ARDUINOJSON_USE_DOUBLE 0 -#endif +# ifndef ARDUINOJSON_USE_DOUBLE +# define ARDUINOJSON_USE_DOUBLE 0 +# endif // Store longs by default, because they usually match the size of a float. -#ifndef ARDUINOJSON_USE_LONG_LONG -#define ARDUINOJSON_USE_LONG_LONG 0 -#endif +# ifndef ARDUINOJSON_USE_LONG_LONG +# define ARDUINOJSON_USE_LONG_LONG 0 +# endif // Embedded systems usually don't have std::string -#ifndef ARDUINOJSON_ENABLE_STD_STRING -#define ARDUINOJSON_ENABLE_STD_STRING 0 -#endif +# ifndef ARDUINOJSON_ENABLE_STD_STRING +# define ARDUINOJSON_ENABLE_STD_STRING 0 +# endif // Embedded systems usually don't have std::stream -#ifndef ARDUINOJSON_ENABLE_STD_STREAM -#define ARDUINOJSON_ENABLE_STD_STREAM 0 -#endif +# ifndef ARDUINOJSON_ENABLE_STD_STREAM +# define ARDUINOJSON_ENABLE_STD_STREAM 0 +# endif // Limit nesting as the stack is likely to be small -#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT -#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 -#endif +# ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT +# define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 +# endif // Number of bits to store the pointer to next node // (saves RAM but limits the number of values in a document) -#ifndef ARDUINOJSON_SLOT_OFFSET_SIZE -#if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 2 +# ifndef ARDUINOJSON_SLOT_OFFSET_SIZE +# if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 2 // Address space == 16-bit => max 127 values -#define ARDUINOJSON_SLOT_OFFSET_SIZE 1 -#else +# define ARDUINOJSON_SLOT_OFFSET_SIZE 1 +# else // Address space > 16-bit => max 32767 values -#define ARDUINOJSON_SLOT_OFFSET_SIZE 2 -#endif -#endif +# define ARDUINOJSON_SLOT_OFFSET_SIZE 2 +# endif +# endif #else // ARDUINOJSON_EMBEDDED_MODE // On a computer we have plenty of memory so we can use doubles -#ifndef ARDUINOJSON_USE_DOUBLE -#define ARDUINOJSON_USE_DOUBLE 1 -#endif +# ifndef ARDUINOJSON_USE_DOUBLE +# define ARDUINOJSON_USE_DOUBLE 1 +# endif // Use long long when available -#ifndef ARDUINOJSON_USE_LONG_LONG -#if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64 -#define ARDUINOJSON_USE_LONG_LONG 1 -#else -#define ARDUINOJSON_USE_LONG_LONG 0 -#endif -#endif +# ifndef ARDUINOJSON_USE_LONG_LONG +# if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64 +# define ARDUINOJSON_USE_LONG_LONG 1 +# else +# define ARDUINOJSON_USE_LONG_LONG 0 +# endif +# endif // On a computer, we can use std::string -#ifndef ARDUINOJSON_ENABLE_STD_STRING -#define ARDUINOJSON_ENABLE_STD_STRING 1 -#endif +# ifndef ARDUINOJSON_ENABLE_STD_STRING +# define ARDUINOJSON_ENABLE_STD_STRING 1 +# endif // On a computer, we can assume std::stream -#ifndef ARDUINOJSON_ENABLE_STD_STREAM -#define ARDUINOJSON_ENABLE_STD_STREAM 1 -#endif +# ifndef ARDUINOJSON_ENABLE_STD_STREAM +# define ARDUINOJSON_ENABLE_STD_STREAM 1 +# endif // On a computer, the stack is large so we can increase nesting limit -#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT -#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 -#endif +# ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT +# define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 +# endif // Number of bits to store the pointer to next node -#ifndef ARDUINOJSON_SLOT_OFFSET_SIZE -#define ARDUINOJSON_SLOT_OFFSET_SIZE 4 -#endif +# ifndef ARDUINOJSON_SLOT_OFFSET_SIZE +# define ARDUINOJSON_SLOT_OFFSET_SIZE 4 +# endif #endif // ARDUINOJSON_EMBEDDED_MODE #ifdef ARDUINO -#include +# include // Enable support for Arduino's String class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING -#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 -#endif +# ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING +# define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 +# endif // Enable support for Arduino's Stream class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM -#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 -#endif +# ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM +# define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 +# endif // Enable support for Arduino's Print class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT -#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 -#endif +# ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT +# define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 +# endif #else // ARDUINO // Disable support for Arduino's String class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING -#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 -#endif +# ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING +# define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 +# endif // Disable support for Arduino's Stream class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM -#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 -#endif +# ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM +# define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 +# endif // Disable support for Arduino's Print class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT -#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 -#endif +# ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT +# define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 +# endif #endif // ARDUINO #ifndef ARDUINOJSON_ENABLE_PROGMEM -#if defined(PROGMEM) && defined(pgm_read_byte) && defined(pgm_read_dword) && \ - defined(pgm_read_ptr) && defined(pgm_read_float) -#define ARDUINOJSON_ENABLE_PROGMEM 1 -#else -#define ARDUINOJSON_ENABLE_PROGMEM 0 -#endif +# if defined(PROGMEM) && defined(pgm_read_byte) && defined(pgm_read_dword) && \ + defined(pgm_read_ptr) && defined(pgm_read_float) +# define ARDUINOJSON_ENABLE_PROGMEM 1 +# else +# define ARDUINOJSON_ENABLE_PROGMEM 0 +# endif #endif // Convert unicode escape sequence (\u0123) to UTF-8 #ifndef ARDUINOJSON_DECODE_UNICODE -#define ARDUINOJSON_DECODE_UNICODE 1 +# define ARDUINOJSON_DECODE_UNICODE 1 #endif // Ignore comments in input #ifndef ARDUINOJSON_ENABLE_COMMENTS -#define ARDUINOJSON_ENABLE_COMMENTS 0 +# define ARDUINOJSON_ENABLE_COMMENTS 0 #endif // Support NaN in JSON #ifndef ARDUINOJSON_ENABLE_NAN -#define ARDUINOJSON_ENABLE_NAN 0 +# define ARDUINOJSON_ENABLE_NAN 0 #endif // Support Infinity in JSON #ifndef ARDUINOJSON_ENABLE_INFINITY -#define ARDUINOJSON_ENABLE_INFINITY 0 +# define ARDUINOJSON_ENABLE_INFINITY 0 #endif // Control the exponentiation threshold for big numbers // CAUTION: cannot be more that 1e9 !!!! #ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD -#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 +# define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 #endif // Control the exponentiation threshold for small numbers #ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD -#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 +# define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 #endif #ifndef ARDUINOJSON_LITTLE_ENDIAN -#if defined(_MSC_VER) || \ - (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ - defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64) -#define ARDUINOJSON_LITTLE_ENDIAN 1 -#else -#define ARDUINOJSON_LITTLE_ENDIAN 0 -#endif +# if defined(_MSC_VER) || \ + (defined(__BYTE_ORDER__) && \ + __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ + defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64) +# define ARDUINOJSON_LITTLE_ENDIAN 1 +# else +# define ARDUINOJSON_LITTLE_ENDIAN 0 +# endif #endif #ifndef ARDUINOJSON_ENABLE_ALIGNMENT -#if defined(__AVR) -#define ARDUINOJSON_ENABLE_ALIGNMENT 0 -#else -#define ARDUINOJSON_ENABLE_ALIGNMENT 1 -#endif +# if defined(__AVR) +# define ARDUINOJSON_ENABLE_ALIGNMENT 0 +# else +# define ARDUINOJSON_ENABLE_ALIGNMENT 1 +# endif #endif #ifndef ARDUINOJSON_TAB -#define ARDUINOJSON_TAB " " +# define ARDUINOJSON_TAB " " #endif #ifndef ARDUINOJSON_ENABLE_STRING_DEDUPLICATION -#define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 +# define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 #endif #ifndef ARDUINOJSON_STRING_BUFFER_SIZE -#define ARDUINOJSON_STRING_BUFFER_SIZE 32 +# define ARDUINOJSON_STRING_BUFFER_SIZE 32 #endif #ifndef ARDUINOJSON_DEBUG -#ifdef __PLATFORMIO_BUILD_DEBUG__ -#define ARDUINOJSON_DEBUG 1 -#else -#define ARDUINOJSON_DEBUG 0 -#endif +# ifdef __PLATFORMIO_BUILD_DEBUG__ +# define ARDUINOJSON_DEBUG 1 +# else +# define ARDUINOJSON_DEBUG 0 +# endif #endif #if ARDUINOJSON_HAS_NULLPTR && defined(nullptr) -#error nullptr is defined as a macro. Remove the faulty #define or #undef nullptr +# error nullptr is defined as a macro. Remove the faulty #define or #undef nullptr // See https://github.com/bblanchon/ArduinoJson/issues/1355 #endif diff --git a/src/ArduinoJson/Deserialization/DeserializationError.hpp b/src/ArduinoJson/Deserialization/DeserializationError.hpp index 7b617111..11ec7df6 100644 --- a/src/ArduinoJson/Deserialization/DeserializationError.hpp +++ b/src/ArduinoJson/Deserialization/DeserializationError.hpp @@ -9,7 +9,7 @@ #include #if ARDUINOJSON_ENABLE_STD_STREAM -#include +# include #endif namespace ARDUINOJSON_NAMESPACE { diff --git a/src/ArduinoJson/Deserialization/Reader.hpp b/src/ArduinoJson/Deserialization/Reader.hpp index e965c825..9ae2d598 100644 --- a/src/ArduinoJson/Deserialization/Reader.hpp +++ b/src/ArduinoJson/Deserialization/Reader.hpp @@ -40,17 +40,17 @@ struct BoundedReader { #include #if ARDUINOJSON_ENABLE_ARDUINO_STREAM -#include +# include #endif #if ARDUINOJSON_ENABLE_ARDUINO_STRING -#include +# include #endif #if ARDUINOJSON_ENABLE_PROGMEM -#include +# include #endif #if ARDUINOJSON_ENABLE_STD_STREAM -#include +# include #endif diff --git a/src/ArduinoJson/Json/Utf16.hpp b/src/ArduinoJson/Json/Utf16.hpp index 00397caf..e2b90105 100644 --- a/src/ArduinoJson/Json/Utf16.hpp +++ b/src/ArduinoJson/Json/Utf16.hpp @@ -12,10 +12,10 @@ // we choose to ignore the problem to reduce the size of the code // Garbage in => Garbage out #if defined(__GNUC__) -#if __GNUC__ >= 7 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif +# if __GNUC__ >= 7 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +# endif #endif namespace ARDUINOJSON_NAMESPACE { @@ -61,7 +61,7 @@ class Codepoint { } // namespace ARDUINOJSON_NAMESPACE #if defined(__GNUC__) -#if __GNUC__ >= 8 -#pragma GCC diagnostic pop -#endif +# if __GNUC__ >= 8 +# pragma GCC diagnostic pop +# endif #endif diff --git a/src/ArduinoJson/Namespace.hpp b/src/ArduinoJson/Namespace.hpp index 2d85440a..26def8ab 100644 --- a/src/ArduinoJson/Namespace.hpp +++ b/src/ArduinoJson/Namespace.hpp @@ -10,17 +10,17 @@ #ifndef ARDUINOJSON_NAMESPACE -#define ARDUINOJSON_NAMESPACE \ - ARDUINOJSON_CONCAT4( \ - ARDUINOJSON_CONCAT4(ArduinoJson, ARDUINOJSON_VERSION_MAJOR, \ - ARDUINOJSON_VERSION_MINOR, \ - ARDUINOJSON_VERSION_REVISION), \ - _, \ - ARDUINOJSON_HEX_DIGIT(ARDUINOJSON_ENABLE_PROGMEM, \ - ARDUINOJSON_USE_LONG_LONG, ARDUINOJSON_USE_DOUBLE, \ - ARDUINOJSON_ENABLE_STRING_DEDUPLICATION), \ - ARDUINOJSON_HEX_DIGIT( \ - ARDUINOJSON_ENABLE_NAN, ARDUINOJSON_ENABLE_INFINITY, \ - ARDUINOJSON_ENABLE_COMMENTS, ARDUINOJSON_DECODE_UNICODE)) +# define ARDUINOJSON_NAMESPACE \ + ARDUINOJSON_CONCAT4( \ + ARDUINOJSON_CONCAT4(ArduinoJson, ARDUINOJSON_VERSION_MAJOR, \ + ARDUINOJSON_VERSION_MINOR, \ + ARDUINOJSON_VERSION_REVISION), \ + _, \ + ARDUINOJSON_HEX_DIGIT( \ + ARDUINOJSON_ENABLE_PROGMEM, ARDUINOJSON_USE_LONG_LONG, \ + ARDUINOJSON_USE_DOUBLE, ARDUINOJSON_ENABLE_STRING_DEDUPLICATION), \ + ARDUINOJSON_HEX_DIGIT( \ + ARDUINOJSON_ENABLE_NAN, ARDUINOJSON_ENABLE_INFINITY, \ + ARDUINOJSON_ENABLE_COMMENTS, ARDUINOJSON_DECODE_UNICODE)) #endif diff --git a/src/ArduinoJson/Numbers/Integer.hpp b/src/ArduinoJson/Numbers/Integer.hpp index fb656a7d..e0ed519a 100644 --- a/src/ArduinoJson/Numbers/Integer.hpp +++ b/src/ArduinoJson/Numbers/Integer.hpp @@ -22,11 +22,11 @@ typedef unsigned long UInt; } // namespace ARDUINOJSON_NAMESPACE #if ARDUINOJSON_HAS_LONG_LONG && !ARDUINOJSON_USE_LONG_LONG -#define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \ - static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::Integer), \ - "To use 64-bit integers with ArduinoJson, you must set " \ - "ARDUINOJSON_USE_LONG_LONG to 1. See " \ - "https://arduinojson.org/v6/api/config/use_long_long/"); +# define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \ + static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::Integer), \ + "To use 64-bit integers with ArduinoJson, you must set " \ + "ARDUINOJSON_USE_LONG_LONG to 1. See " \ + "https://arduinojson.org/v6/api/config/use_long_long/"); #else -#define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) +# define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) #endif diff --git a/src/ArduinoJson/Numbers/convertNumber.hpp b/src/ArduinoJson/Numbers/convertNumber.hpp index 02bbefa5..8f2cd592 100644 --- a/src/ArduinoJson/Numbers/convertNumber.hpp +++ b/src/ArduinoJson/Numbers/convertNumber.hpp @@ -5,13 +5,13 @@ #pragma once #if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wconversion" #elif defined(__GNUC__) -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -#pragma GCC diagnostic push -#endif -#pragma GCC diagnostic ignored "-Wconversion" +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wconversion" #endif #include @@ -99,9 +99,9 @@ TOut convertNumber(TIn value) { } // namespace ARDUINOJSON_NAMESPACE #if defined(__clang__) -#pragma clang diagnostic pop +# pragma clang diagnostic pop #elif defined(__GNUC__) -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -#pragma GCC diagnostic pop -#endif +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +# pragma GCC diagnostic pop +# endif #endif diff --git a/src/ArduinoJson/Object/MemberProxy.hpp b/src/ArduinoJson/Object/MemberProxy.hpp index 0bee84bf..882b1fd2 100644 --- a/src/ArduinoJson/Object/MemberProxy.hpp +++ b/src/ArduinoJson/Object/MemberProxy.hpp @@ -12,8 +12,8 @@ #include #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4522) +# pragma warning(push) +# pragma warning(disable : 4522) #endif namespace ARDUINOJSON_NAMESPACE { @@ -198,5 +198,5 @@ class MemberProxy : public VariantOperators >, } // namespace ARDUINOJSON_NAMESPACE #ifdef _MSC_VER -#pragma warning(pop) +# pragma warning(pop) #endif diff --git a/src/ArduinoJson/Polyfills/assert.hpp b/src/ArduinoJson/Polyfills/assert.hpp index 1030ec60..f5fa9467 100644 --- a/src/ArduinoJson/Polyfills/assert.hpp +++ b/src/ArduinoJson/Polyfills/assert.hpp @@ -7,8 +7,8 @@ #include #if ARDUINOJSON_DEBUG -#include -#define ARDUINOJSON_ASSERT(X) assert(X) +# include +# define ARDUINOJSON_ASSERT(X) assert(X) #else -#define ARDUINOJSON_ASSERT(X) ((void)0) +# define ARDUINOJSON_ASSERT(X) ((void)0) #endif diff --git a/src/ArduinoJson/Polyfills/attributes.hpp b/src/ArduinoJson/Polyfills/attributes.hpp index f04c9acc..8ef33afe 100644 --- a/src/ArduinoJson/Polyfills/attributes.hpp +++ b/src/ArduinoJson/Polyfills/attributes.hpp @@ -6,49 +6,49 @@ #ifdef _MSC_VER // Visual Studio -#define FORCE_INLINE // __forceinline causes C4714 when returning std::string -#define NO_INLINE __declspec(noinline) +# define FORCE_INLINE // __forceinline causes C4714 when returning std::string +# define NO_INLINE __declspec(noinline) -#ifndef ARDUINOJSON_DEPRECATED -#define ARDUINOJSON_DEPRECATED(msg) __declspec(deprecated(msg)) -#endif +# ifndef ARDUINOJSON_DEPRECATED +# define ARDUINOJSON_DEPRECATED(msg) __declspec(deprecated(msg)) +# endif #elif defined(__GNUC__) // GCC or Clang -#define FORCE_INLINE __attribute__((always_inline)) -#define NO_INLINE __attribute__((noinline)) +# define FORCE_INLINE __attribute__((always_inline)) +# define NO_INLINE __attribute__((noinline)) -#ifndef ARDUINOJSON_DEPRECATED -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated(msg))) -#else -#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated)) -#endif -#endif +# ifndef ARDUINOJSON_DEPRECATED +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated(msg))) +# else +# define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated)) +# endif +# endif #else // Other compilers -#define FORCE_INLINE -#define NO_INLINE +# define FORCE_INLINE +# define NO_INLINE -#ifndef ARDUINOJSON_DEPRECATED -#define ARDUINOJSON_DEPRECATED(msg) -#endif +# ifndef ARDUINOJSON_DEPRECATED +# define ARDUINOJSON_DEPRECATED(msg) +# endif #endif #if __cplusplus >= 201103L -#define NOEXCEPT noexcept +# define NOEXCEPT noexcept #else -#define NOEXCEPT throw() +# define NOEXCEPT throw() #endif #if defined(__has_attribute) -#if __has_attribute(no_sanitize) -#define ARDUINOJSON_NO_SANITIZE(check) __attribute__((no_sanitize(check))) +# if __has_attribute(no_sanitize) +# define ARDUINOJSON_NO_SANITIZE(check) __attribute__((no_sanitize(check))) +# else +# define ARDUINOJSON_NO_SANITIZE(check) +# endif #else -#define ARDUINOJSON_NO_SANITIZE(check) -#endif -#else -#define ARDUINOJSON_NO_SANITIZE(check) +# define ARDUINOJSON_NO_SANITIZE(check) #endif diff --git a/src/ArduinoJson/Polyfills/limits.hpp b/src/ArduinoJson/Polyfills/limits.hpp index 80048284..68a2bf8a 100644 --- a/src/ArduinoJson/Polyfills/limits.hpp +++ b/src/ArduinoJson/Polyfills/limits.hpp @@ -7,8 +7,8 @@ #include "type_traits.hpp" #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4310) +# pragma warning(push) +# pragma warning(disable : 4310) #endif namespace ARDUINOJSON_NAMESPACE { @@ -41,5 +41,5 @@ struct numeric_limits< } // namespace ARDUINOJSON_NAMESPACE #ifdef _MSC_VER -#pragma warning(pop) +# pragma warning(pop) #endif diff --git a/src/ArduinoJson/Polyfills/static_array.hpp b/src/ArduinoJson/Polyfills/static_array.hpp index a877b4ca..b070628c 100644 --- a/src/ArduinoJson/Polyfills/static_array.hpp +++ b/src/ArduinoJson/Polyfills/static_array.hpp @@ -8,27 +8,27 @@ #if ARDUINOJSON_ENABLE_PROGMEM -#include +# include -#ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY -#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ - static type const name[] PROGMEM = value; -#endif +# ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY +# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ + static type const name[] PROGMEM = value; +# endif -#ifndef ARDUINOJSON_READ_STATIC_ARRAY -#define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ - pgm_read(name + index) -#endif +# ifndef ARDUINOJSON_READ_STATIC_ARRAY +# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ + pgm_read(name + index) +# endif #else // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0 -#ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY -#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ - static type const name[] = value; -#endif +# ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY +# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ + static type const name[] = value; +# endif -#ifndef ARDUINOJSON_READ_STATIC_ARRAY -#define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] -#endif +# ifndef ARDUINOJSON_READ_STATIC_ARRAY +# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] +# endif #endif diff --git a/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp b/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp index 847525a9..b3a073b8 100644 --- a/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp +++ b/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp @@ -7,9 +7,9 @@ #include "declval.hpp" #ifdef _MSC_VER -#pragma warning(push) +# pragma warning(push) // conversion from 'T' to 'To', possible loss of data -#pragma warning(disable : 4244) +# pragma warning(disable : 4244) #endif // clang-format off @@ -37,7 +37,7 @@ struct is_convertible { } // namespace ARDUINOJSON_NAMESPACE #ifdef _MSC_VER -#pragma warning(pop) +# pragma warning(pop) #endif // clang-format off diff --git a/src/ArduinoJson/Serialization/Writer.hpp b/src/ArduinoJson/Serialization/Writer.hpp index 52bd1175..f9a97985 100644 --- a/src/ArduinoJson/Serialization/Writer.hpp +++ b/src/ArduinoJson/Serialization/Writer.hpp @@ -31,17 +31,17 @@ class Writer { #include #if ARDUINOJSON_ENABLE_STD_STRING -#include +# include #endif #if ARDUINOJSON_ENABLE_ARDUINO_STRING -#include +# include #endif #if ARDUINOJSON_ENABLE_STD_STREAM -#include +# include #endif #if ARDUINOJSON_ENABLE_ARDUINO_PRINT -#include +# include #endif diff --git a/src/ArduinoJson/Strings/IsWriteableString.hpp b/src/ArduinoJson/Strings/IsWriteableString.hpp index 32039e3d..556c4765 100644 --- a/src/ArduinoJson/Strings/IsWriteableString.hpp +++ b/src/ArduinoJson/Strings/IsWriteableString.hpp @@ -8,11 +8,11 @@ #include #if ARDUINOJSON_ENABLE_ARDUINO_STRING -#include +# include #endif #if ARDUINOJSON_ENABLE_STD_STRING -#include +# include #endif namespace ARDUINOJSON_NAMESPACE { diff --git a/src/ArduinoJson/Strings/StringAdapters.hpp b/src/ArduinoJson/Strings/StringAdapters.hpp index 3d294d29..b587a387 100644 --- a/src/ArduinoJson/Strings/StringAdapters.hpp +++ b/src/ArduinoJson/Strings/StringAdapters.hpp @@ -9,14 +9,14 @@ #include #if ARDUINOJSON_ENABLE_STD_STRING -#include +# include #endif #if ARDUINOJSON_ENABLE_ARDUINO_STRING -#include +# include #endif #if ARDUINOJSON_ENABLE_PROGMEM -#include -#include +# include +# include #endif diff --git a/src/ArduinoJson/Variant/VariantData.hpp b/src/ArduinoJson/Variant/VariantData.hpp index 5631147f..fd54a94c 100644 --- a/src/ArduinoJson/Variant/VariantData.hpp +++ b/src/ArduinoJson/Variant/VariantData.hpp @@ -13,11 +13,11 @@ // VariantData can't have a constructor (to be a POD), so we have no way to fix // this warning #if defined(__GNUC__) -#if __GNUC__ >= 7 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#pragma GCC diagnostic ignored "-Wuninitialized" -#endif +# if __GNUC__ >= 7 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +# pragma GCC diagnostic ignored "-Wuninitialized" +# endif #endif namespace ARDUINOJSON_NAMESPACE { @@ -362,7 +362,7 @@ class VariantData { } // namespace ARDUINOJSON_NAMESPACE #if defined(__GNUC__) -#if __GNUC__ >= 8 -#pragma GCC diagnostic pop -#endif +# if __GNUC__ >= 8 +# pragma GCC diagnostic pop +# endif #endif