8000 Allow mixed configuration in compilation units (issue #809) · java64/ArduinoJson@527dc19 · GitHub
[go: up one dir, main page]

Skip to content

Commit 527dc19

Browse files
committed
Allow mixed configuration in compilation units (issue bblanchon#809)
1 parent 29e71cb commit 527dc19

File tree

122 files changed

+579
-690
lines changed
  • test
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    122 files changed

    +579
    -690
    lines changed

    CHANGELOG.md

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -5,6 +5,7 @@ HEAD
    55
    ----
    66

    77
    * Added implicit conversion from `JsonArray` and `JsonObject` to `JsonVariant`
    8+
    * Allow mixed configuration in compilation units (issue #809)
    89

    910
    v6.4.0-beta (2018-09-11)
    1011
    -----------

    src/ArduinoJson.hpp

    Lines changed: 14 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -4,7 +4,7 @@
    44

    55
    #pragma once
    66

    7-
    #include "ArduinoJson/version.hpp"
    7+
    #include "ArduinoJson/Namespace.hpp"
    88

    99
    #include "ArduinoJson/DynamicJsonDocument.hpp"
    1010
    #include "ArduinoJson/StaticJsonDocument.hpp"
    @@ -24,3 +24,16 @@
    2424
    #include "ArduinoJson/Json/PrettyJsonSerializer.hpp"
    2525
    #include "ArduinoJson/MsgPack/MsgPackDeserializer.hpp"
    2626
    #include "ArduinoJson/MsgPack/MsgPackSerializer.hpp"
    27+
    28+
    namespace ArduinoJson {
    29+
    using ARDUINOJSON_NAMESPACE::DeserializationError;
    30+
    using ARDUINOJSON_NAMESPACE::DynamicJsonDocument;
    31+
    using ARDUINOJSON_NAMESPACE::JsonArray;
    32+
    using ARDUINOJSON_NAMESPACE::JsonFloat;
    33+
    using ARDUINOJSON_NAMESPACE::JsonInteger;
    34+
    using ARDUINOJSON_NAMESPACE::JsonObject;
    35+
    using ARDUINOJSON_NAMESPACE::JsonUInt;
    36+
    using ARDUINOJSON_NAMESPACE::JsonVariant;
    37+
    using ARDUINOJSON_NAMESPACE::serialized;
    38+
    using ARDUINOJSON_NAMESPACE::StaticJsonDocument;
    39+
    } // namespace ArduinoJson

    src/ArduinoJson/Configuration.hpp

    Lines changed: 13 additions & 17 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,6 +4,18 @@
    44

    55
    #pragma once
    66

    7+
    #if defined(_MSC_VER)
    8+
    #define ARDUINOJSON_HAS_INT64 1
    9+
    #else
    10+
    #define ARDUINOJSON_HAS_INT64 0
    11+
    #endif
    12+
    13+
    #if __cplusplus >= 201103L
    14+
    #define ARDUINOJSON_HAS_LONG_LONG 1
    15+
    #else
    16+
    #define ARDUINOJSON_HAS_LONG_LONG 0
    17+
    #endif
    18+
    719
    // Small or big machine?
    820
    #ifndef ARDUINOJSON_EMBEDDED_MODE
    921
    #if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) || defined(__XC) || \
    @@ -25,9 +37,6 @@
    2537
    #ifndef ARDUINOJSON_USE_LONG_LONG
    2638
    #define ARDUINOJSON_USE_LONG_LONG 0
    2739
    #endif
    28-
    #ifndef ARDUINOJSON_USE_INT64
    29-
    #define ARDUINOJSON_USE_INT64 0
    30-
    #endif
    3140

    3241
    // Embedded systems usually don't have std::string
    3342
    #ifndef ARDUINOJSON_ENABLE_STD_STRING
    @@ -53,22 +62,13 @@
    5362

    5463
    // Use long long when available
    5564
    #ifndef ARDUINOJSON_USE_LONG_LONG
    56-
    #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
    65+
    #if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64
    5766
    #define ARDUINOJSON_USE_LONG_LONG 1
    5867
    #else
    5968
    #define ARDUINOJSON_USE_LONG_LONG 0
    6069
    #endif
    6170
    #endif
    6271

    63-
    // Use _int64 on old versions of Visual Studio
    64-
    #ifndef ARDUINOJSON_USE_INT64
    65-
    #if defined(_MSC_VER) && _MSC_VER <= 1700
    66-
    #define ARDUINOJSON_USE_INT64 1
    67-
    #else
    68-
    #define ARDUINOJSON_USE_INT64 0
    69-
    #endif
    70-
    #endif
    71-
    7272
    // On a computer, we can use std::string
    7373
    #ifndef ARDUINOJSON_ENABLE_STD_STRING
    7474
    #define ARDUINOJSON_ENABLE_STD_STRING 1
    @@ -141,10 +141,6 @@
    141141
    #define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5
    142142
    #endif
    143143

    144-
    #if ARDUINOJSON_USE_LONG_LONG && ARDUINOJSON_USE_INT64
    145-
    #error ARDUINOJSON_USE_LONG_LONG and ARDUINOJSON_USE_INT64 cannot be set together
    146-
    #endif
    147-
    148144
    #ifndef ARDUINOJSON_LITTLE_ENDIAN
    149145
    #if defined(_MSC_VER) || \
    150146
    (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \

    src/ArduinoJson/Data/IsVariant.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,12 +6,10 @@
    66

    77
    #include "../Polyfills/type_traits.hpp"
    88

    9-
    namespace ArduinoJson {
    10-
    namespace Internals {
    9+
    namespace ARDUINOJSON_NAMESPACE {
    1110

    1211
    class JsonVariantTag {};
    1312

    1413
    template <typename T>
    1514
    struct IsVariant : is_base_of<JsonVariantTag, T> {};
    16-
    } // namespace Internals
    17-
    } // namespace ArduinoJson
    15+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonFloat.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,13 +6,11 @@
    66

    77
    #include "../Configuration.hpp"
    88

    9-
    namespace ArduinoJson {
    10-
    namespace Internals {
    9+
    namespace ARDUINOJSON_NAMESPACE {
    1110

    1211
    #if ARDUINOJSON_USE_DOUBLE
    1312
    typedef double JsonFloat;
    1413
    #else
    1514
    typedef float JsonFloat;
    1615
    #endif
    17-
    }
    18-
    }
    16+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonInteger.hpp

    Lines changed: 4 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,18 +6,13 @@
    66

    77
    #include "../Configuration.hpp"
    88

    9-
    namespace ArduinoJson {
    10-
    namespace Internals {
    9+
    namespace ARDUINOJSON_NAMESPACE {
    1110

    1211
    #if ARDUINOJSON_USE_LONG_LONG
    13-
    typedef long long JsonInteger;
    14-
    typedef unsigned long long JsonUInt;
    15-
    #elif ARDUINOJSON_USE_INT64
    16-
    typedef __int64 JsonInteger;
    17-
    typedef unsigned _int64 JsonUInt;
    12+
    typedef int64_t JsonInteger;
    13+
    typedef uint64_t JsonUInt;
    1814
    #else
    1915
    typedef long JsonInteger;
    2016
    typedef unsigned long JsonUInt;
    2117
    #endif
    22-
    }
    23-
    }
    18+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonVariantAs.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,8 +4,7 @@
    44

    55
    #pragma once
    66

    7-
    namespace ArduinoJson {
    8-
    namespace Internals {
    7+
    namespace ARDUINOJSON_NAMESPACE {
    98

    109
    // A metafunction that returns the type of the value returned by
    1110
    // JsonVariant::as<T>()
    @@ -19,5 +18,4 @@ struct JsonVariantAs<char*> {
    1918
    typedef const char* type;
    2019
    };
    2120

    22-
    } // namespace Internals
    23-
    } // namespace ArduinoJson
    21+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonVariantContent.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -9,8 +9,7 @@
    99
    #include "JsonFloat.hpp"
    1010
    #include "JsonInteger.hpp"
    1111

    12-
    namespace ArduinoJson {
    13-
    namespace Internals {
    12+
    namespace ARDUINOJSON_NAMESPACE {
    1413
    struct JsonObjectData {
    1514
    struct Slot* head;
    1615
    struct Slot* tail;
    @@ -40,5 +39,4 @@ union JsonVariantContent {
    4039
    } asRaw;
    4140
    };
    4241

    43-
    } // namespace Internals
    44-
    } // namespace ArduinoJson
    42+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonVariantData.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,8 +7,7 @@
    77
    #include "JsonVariantContent.hpp"
    88
    #include "JsonVariantType.hpp"
    99

    10-
    namespace ArduinoJson {
    11-
    namespace Internals {
    10+
    namespace ARDUINOJSON_NAMESPACE {
    1211

    1312
    // this struct must be a POD type to prevent error calling offsetof on clang
    1413
    struct JsonVariantData {
    @@ -31,5 +30,4 @@ inline JsonVariantData *getVariantData(JsonObjectData *obj) {
    3130
    return reinterpret_cast<JsonVariantData *>(reinterpret_cast<char *>(obj) -
    3231
    offset);
    3332
    }
    34-
    } // namespace Internals
    35-
    } // namespace ArduinoJson
    33+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonVariantTo.hpp

    Lines changed: 2 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,13 +4,11 @@
    44

    55
    #pragma once
    66

    7-
    namespace ArduinoJson {
    7+
    namespace ARDUINOJSON_NAMESPACE {
    88
    class JsonArray;
    99
    class JsonObject;
    1010
    class JsonVariant;
    1111

    12-
    namespace Internals {
    13-
    1412
    // A metafunction that returns the type of the value returned by
    1513
    // JsonVariant::to<T>()
    1614
    template <typename T>
    @@ -29,5 +27,4 @@ struct JsonVariantTo<JsonVariant> {
    2927
    typedef JsonVariant type;
    3028
    };
    3129

    32-
    } // namespace Internals
    33-
    } // namespace ArduinoJson
    30+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/JsonVariantType.hpp

    Lines changed: 2 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,10 +4,7 @@
    44

    55
    #pragma once
    66

    7-
    namespace ArduinoJson {
    8-
    9-
    namespace Internals {
    10-
    7+
    namespace ARDUINOJSON_NAMESPACE {
    118
    // Enumerated type to know the current type of a JsonVariant.
    129
    // The value determines which member of JsonVariantContent is used.
    1310
    enum JsonVariantType {
    @@ -23,5 +20,4 @@ enum JsonVariantType {
    2320
    JSON_OBJECT,
    2421
    JSON_FLOAT
    2522
    };
    26-
    } // namespace Internals
    27-
    } // namespace ArduinoJson
    23+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Data/Slot.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,8 +7,7 @@
    77
    #include "../Memory/AllocableInMemoryPool.hpp"
    88
    #include "JsonVariantData.hpp"
    99

    10-
    namespace ArduinoJson {
    11-
    namespace Internals {
    10+
    namespace ARDUINOJSON_NAMESPACE {
    1211

    1312
    struct Slot : AllocableInMemoryPool {
    1413
    JsonVariantData value;
    @@ -17,5 +16,4 @@ struct Slot : AllocableInMemoryPool {
    1716
    const char* key;
    1817
    };
    1918

    20-
    } // namespace Internals
    21-
    } // namespace ArduinoJson
    19+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Deserialization/ArduinoStreamReader.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,8 +8,7 @@
    88

    99
    #include <Stream.h>
    1010

    11-
    namespace ArduinoJson {
    12-
    namespace Internals {
    11+
    namespace ARDUINOJSON_NAMESPACE {
    1312

    1413
    struct ArduinoStreamReader {
    1514
    Stream& _stream;
    @@ -35,7 +34,6 @@ struct ArduinoStreamReader {
    3534
    inline ArduinoStreamReader makeReader(Stream& input) {
    3635
    return ArduinoStreamReader(input);
    3736
    }
    38-
    } // namespace Internals
    39-
    } // namespace ArduinoJson
    37+
    } // namespace ARDUINOJSON_NAMESPACE
    4038

    4139
    #endif

    src/ArduinoJson/Deserialization/CharPointerReader.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,8 +4,7 @@
    44

    55
    #pragma once
    66

    7-
    namespace ArduinoJson {
    8-
    namespace Internals {
    7+
    namespace ARDUINOJSON_NAMESPACE {
    98

    109
    template <typename TChar>
    1110
    class UnsafeCharPointerReader {
    @@ -60,5 +59,4 @@ inline SafeCharPointerReader<char> makeReader(const String& input) {
    6059
    }
    6160
    #endif
    6261

    63-
    } // namespace Internals
    64-
    } // namespace ArduinoJson
    62+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Deserialization/DeserializationError.hpp

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    #include <ostream>
    99
    #endif
    1010

    11-
    namespace ArduinoJson {
    11+
    namespace ARDUINOJSON_NAMESPACE {
    1212

    1313
    class DeserializationError {
    1414
    public:
    @@ -80,4 +80,4 @@ inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) {
    8080
    }
    8181
    #endif
    8282

    83-
    } // namespace ArduinoJson
    83+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Deserialization/FlashStringReader.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,8 +6,7 @@
    66

    77
    #if ARDUINOJSON_ENABLE_PROGMEM
    88

    9-
    namespace ArduinoJson {
    10-
    namespace Internals {
    9+
    namespace ARDUINOJSON_NAMESPACE {
    1110
    class UnsafeFlashStringReader {
    1211
    const char* _ptr;
    1312

    @@ -50,7 +49,6 @@ inline SafeFlashStringReader makeReader(const __FlashStringHelper* input,
    5049
    size_t size) {
    5150
    return SafeFlashStringReader(input, size);
    5251
    }
    53-
    } // namespace Internals
    54-
    } // namespace ArduinoJson
    52+
    } // namespace ARDUINOJSON_NAMESPACE
    5553

    5654
    #endif

    src/ArduinoJson/Deserialization/IteratorReader.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,8 +4,7 @@
    44

    55
    #pragma once
    66

    7-
    namespace ArduinoJson {
    8-
    namespace Internals {
    7+
    namespace ARDUINOJSON_NAMESPACE {
    98

    109
    template <typename TIterator>
    1110
    class IteratorReader {
    @@ -30,5 +29,4 @@ inline IteratorReader<typename TInput::const_iterator> makeReader(
    3029
    return IteratorReader<typename TInput::const_iterator>(input.begin(),
    3130
    input.end());
    3231
    }
    33-
    } // namespace Internals
    34-
    } // namespace ArduinoJson
    32+
    } // namespace ARDUINOJSON_NAMESPACE

    src/ArduinoJson/Deserialization/StdStreamReader.hpp

    Lines changed: 2 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,8 +8,7 @@
    88

    99
    #include <istream>
    1010

    11-
    namespace ArduinoJson {
    12-
    namespace Internals {
    11+
    namespace ARDUINOJSON_NAMESPACE {
    1312

    1413
    class StdStreamReader {
    1514
    std::istream& _stream;
    @@ -34,7 +33,6 @@ class StdStreamReader {
    3433
    inline StdStreamReader makeReader(std::istream& input) {
    3534
    return StdStreamReader(input);
    3635
    }
    37-
    } // namespace Internals
    38-
    } // namespace ArduinoJson
    36+
    } // 3B8C namespace ARDUINOJSON_NAMESPACE
    3937

    4038
    #endif

    0 commit comments

    Comments
     (0)
    0