mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Fixed naming conflict with "CAPACITY" (issue #839)
This commit is contained in:
		| @@ -7,6 +7,7 @@ HEAD | ||||
| * Fixed warning "unused variable" with GCC 4.4 (issue #912) | ||||
| * Fixed warning "cast  increases required alignment" (issue #914) | ||||
| * Fixed warning "conversion may alter value" (issue #914) | ||||
| * Fixed naming conflict with "CAPACITY" (issue #839) | ||||
| * Muted warning "will change in GCC 7.1" (issue #914) | ||||
| * Added a clear error message for `StaticJsonBuffer` and `DynamicJsonBuffer` | ||||
| * Marked ArduinoJson.h  as a "system header" | ||||
|   | ||||
| @@ -8,28 +8,28 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| template <size_t CAPACITY> | ||||
| template <size_t desiredCapacity> | ||||
| class StaticJsonDocument : public JsonDocument { | ||||
|   static const size_t ACTUAL_CAPACITY = | ||||
|       AddPadding<Max<1, CAPACITY>::value>::value; | ||||
|   static const size_t _capacity = | ||||
|       AddPadding<Max<1, desiredCapacity>::value>::value; | ||||
|  | ||||
|  public: | ||||
|   StaticJsonDocument() : JsonDocument(_buffer, ACTUAL_CAPACITY) {} | ||||
|   StaticJsonDocument() : JsonDocument(_buffer, _capacity) {} | ||||
|  | ||||
|   StaticJsonDocument(const StaticJsonDocument& src) | ||||
|       : JsonDocument(_buffer, ACTUAL_CAPACITY) { | ||||
|       : JsonDocument(_buffer, _capacity) { | ||||
|     set(src); | ||||
|   } | ||||
|  | ||||
|   template <typename T> | ||||
|   StaticJsonDocument(const T& src, | ||||
|                      typename enable_if<IsVisitable<T>::value>::type* = 0) | ||||
|       : JsonDocument(_buffer, ACTUAL_CAPACITY) { | ||||
|       : JsonDocument(_buffer, _capacity) { | ||||
|     set(src); | ||||
|   } | ||||
|  | ||||
|   // disambiguate | ||||
|   StaticJsonDocument(VariantRef src) : JsonDocument(_buffer, ACTUAL_CAPACITY) { | ||||
|   StaticJsonDocument(VariantRef src) : JsonDocument(_buffer, _capacity) { | ||||
|     set(src); | ||||
|   } | ||||
|  | ||||
| @@ -45,7 +45,7 @@ class StaticJsonDocument : public JsonDocument { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   char _buffer[ACTUAL_CAPACITY]; | ||||
|   char _buffer[_capacity]; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| # MIT License | ||||
|  | ||||
| add_executable(MiscTests | ||||
|     empty.cpp | ||||
| 	conflicts.cpp | ||||
| 	FloatParts.cpp | ||||
| 	StringWriter.cpp | ||||
| 	TypeTraits.cpp | ||||
|   | ||||
							
								
								
									
										42
									
								
								test/Misc/conflicts.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								test/Misc/conflicts.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| // ArduinoJson - arduinojson.org | ||||
| // Copyright Benoit Blanchon 2014-2019 | ||||
| // MIT License | ||||
|  | ||||
| // All cores | ||||
| #define bit() | ||||
| #define constrain() | ||||
| #define DEFAULT | ||||
| #define DISABLED | ||||
| #define HIGH | ||||
| #define INPUT | ||||
| #define LOW | ||||
| #define max() | ||||
| #define min() | ||||
| #define OUTPUT | ||||
| #define round() | ||||
| #define sq() | ||||
| #define word() | ||||
| #define bitRead() | ||||
| #define bitSet() | ||||
| #define bitClear() | ||||
| #define bitWrite() | ||||
| #define interrupts() | ||||
| #define lowByte() | ||||
| #define highByte() | ||||
| #define DEC | ||||
| #define HEX | ||||
| #define OCT | ||||
| #define BIN | ||||
| #define cbi() | ||||
| #define sbi() | ||||
|  | ||||
| // ESP8266 | ||||
| #define _max() | ||||
| #define _min() | ||||
|  | ||||
| // issue #839 | ||||
| #define BLOCKSIZE | ||||
| #define CAPACITY | ||||
|  | ||||
| // catch.hpp mutes several warnings, this file also allows to detect them | ||||
| #include "ArduinoJson.h" | ||||
| @@ -1,7 +0,0 @@ | ||||
| // ArduinoJson - arduinojson.org | ||||
| // Copyright Benoit Blanchon 2014-2019 | ||||
| // MIT License | ||||
|  | ||||
| // catch.hpp mutes several warnings, this file allows to detect them | ||||
|  | ||||
| #include "ArduinoJson.h" | ||||
		Reference in New Issue
	
	Block a user