mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Allow using PROGMEM outside of Arduino (fixes #1903)
This commit is contained in:
		| @@ -5,6 +5,7 @@ HEAD | |||||||
| ---- | ---- | ||||||
|  |  | ||||||
| * Fix compatibility with the Zephyr Project (issue #1905) | * Fix compatibility with the Zephyr Project (issue #1905) | ||||||
|  | * Allow using PROGMEM outside of Arduino (issue #1903) | ||||||
|  |  | ||||||
| v6.21.1 (2023-03-27) | v6.21.1 (2023-03-27) | ||||||
| ------- | ------- | ||||||
|   | |||||||
| @@ -7,5 +7,7 @@ | |||||||
| #include "api/Print.h" | #include "api/Print.h" | ||||||
| #include "api/Stream.h" | #include "api/Stream.h" | ||||||
| #include "api/String.h" | #include "api/String.h" | ||||||
|  | #include "avr/pgmspace.h" | ||||||
|  |  | ||||||
|  | #define ARDUINO | ||||||
| #define ARDUINO_H_INCLUDED 1 | #define ARDUINO_H_INCLUDED 1 | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ | |||||||
| // Copyright © 2014-2023, Benoit BLANCHON
 | // Copyright © 2014-2023, Benoit BLANCHON
 | ||||||
| // MIT License
 | // MIT License
 | ||||||
| 
 | 
 | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
| #include <stdint.h>  // uint8_t | #include <stdint.h>  // uint8_t | ||||||
| 
 | 
 | ||||||
| #define PROGMEM | #define PROGMEM | ||||||
| @@ -2,17 +2,16 @@ | |||||||
| // Copyright © 2014-2023, Benoit BLANCHON | // Copyright © 2014-2023, Benoit BLANCHON | ||||||
| // MIT License | // MIT License | ||||||
|  |  | ||||||
| #define ARDUINOJSON_ENABLE_PROGMEM 1 | #include <Arduino.h> | ||||||
|  |  | ||||||
| #include "custom_string.hpp" |  | ||||||
| #include "progmem_emulation.hpp" |  | ||||||
| #include "weird_strcmp.hpp" |  | ||||||
|  |  | ||||||
| #include <ArduinoJson/Strings/IsString.hpp> | #include <ArduinoJson/Strings/IsString.hpp> | ||||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||||
|  |  | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
|  | #include "custom_string.hpp" | ||||||
|  | #include "weird_strcmp.hpp" | ||||||
|  |  | ||||||
| using namespace ArduinoJson::detail; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("ZeroTerminatedRamString") { | TEST_CASE("ZeroTerminatedRamString") { | ||||||
|   | |||||||
| @@ -2,10 +2,13 @@ | |||||||
| // Copyright © 2014-2023, Benoit BLANCHON | // Copyright © 2014-2023, Benoit BLANCHON | ||||||
| // MIT License | // MIT License | ||||||
|  |  | ||||||
| #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 | #include <Arduino.h> | ||||||
|  |  | ||||||
| #define ARDUINOJSON_STRING_BUFFER_SIZE 5 | #define ARDUINOJSON_STRING_BUFFER_SIZE 5 | ||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
|  |  | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| #include "custom_string.hpp" | #include "custom_string.hpp" | ||||||
|  |  | ||||||
| using namespace ArduinoJson::detail; | using namespace ArduinoJson::detail; | ||||||
|   | |||||||
| @@ -2,8 +2,6 @@ | |||||||
| // Copyright © 2014-2023, Benoit BLANCHON | // Copyright © 2014-2023, Benoit BLANCHON | ||||||
| // MIT License | // MIT License | ||||||
|  |  | ||||||
| #include "progmem_emulation.hpp" |  | ||||||
|  |  | ||||||
| #define ARDUINOJSON_ENABLE_PROGMEM 1 | #define ARDUINOJSON_ENABLE_PROGMEM 1 | ||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,8 +2,6 @@ | |||||||
| // Copyright © 2014-2023, Benoit BLANCHON | // Copyright © 2014-2023, Benoit BLANCHON | ||||||
| // MIT License | // MIT License | ||||||
|  |  | ||||||
| #include "progmem_emulation.hpp" |  | ||||||
|  |  | ||||||
| #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 | #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 | ||||||
| #define ARDUINOJSON_ENABLE_PROGMEM 1 | #define ARDUINOJSON_ENABLE_PROGMEM 1 | ||||||
| #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 0 | #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 0 | ||||||
|   | |||||||
| @@ -2,8 +2,6 @@ | |||||||
| // Copyright © 2014-2023, Benoit BLANCHON | // Copyright © 2014-2023, Benoit BLANCHON | ||||||
| // MIT License | // MIT License | ||||||
|  |  | ||||||
| #include "progmem_emulation.hpp" |  | ||||||
|  |  | ||||||
| #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 | #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 | ||||||
| #define ARDUINOJSON_ENABLE_PROGMEM 1 | #define ARDUINOJSON_ENABLE_PROGMEM 1 | ||||||
| #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 | #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 | ||||||
|   | |||||||
| @@ -5,8 +5,6 @@ | |||||||
| #define ARDUINO | #define ARDUINO | ||||||
| #define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) | #define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) | ||||||
|  |  | ||||||
| #include "progmem_emulation.hpp" |  | ||||||
|  |  | ||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
|  |  | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|   | |||||||
| @@ -13,7 +13,8 @@ | |||||||
| // Include Arduino.h before stdlib.h to avoid conflict with atexit() | // Include Arduino.h before stdlib.h to avoid conflict with atexit() | ||||||
| // https://github.com/bblanchon/ArduinoJson/pull/1693#issuecomment-1001060240 | // https://github.com/bblanchon/ArduinoJson/pull/1693#issuecomment-1001060240 | ||||||
| #if ARDUINOJSON_ENABLE_ARDUINO_STRING || ARDUINOJSON_ENABLE_ARDUINO_STREAM || \ | #if ARDUINOJSON_ENABLE_ARDUINO_STRING || ARDUINOJSON_ENABLE_ARDUINO_STREAM || \ | ||||||
|     ARDUINOJSON_ENABLE_ARDUINO_PRINT || ARDUINOJSON_ENABLE_PROGMEM |     ARDUINOJSON_ENABLE_ARDUINO_PRINT ||                                       \ | ||||||
|  |     (ARDUINOJSON_ENABLE_PROGMEM && defined(ARDUINO)) | ||||||
| #  include <Arduino.h> | #  include <Arduino.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| #include <Arduino.h> | #include <ArduinoJson/Polyfills/pgmspace.hpp> | ||||||
|  |  | ||||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,7 +4,13 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| #include <Arduino.h> | #ifdef ARDUINO | ||||||
|  | #  include <Arduino.h> | ||||||
|  | #else | ||||||
|  | // Allow using PROGMEM outside of Arduino (issue #1903) | ||||||
|  | class __FlashStringHelper; | ||||||
|  | #  include <avr/pgmspace.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #include <ArduinoJson/Configuration.hpp> | #include <ArduinoJson/Configuration.hpp> | ||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
|   | |||||||
| @@ -4,8 +4,6 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| #include <Arduino.h> |  | ||||||
|  |  | ||||||
| #include <ArduinoJson/Polyfills/pgmspace.hpp> | #include <ArduinoJson/Polyfills/pgmspace.hpp> | ||||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user