File tree Expand file tree Collapse file tree 5 files changed +10
-40
lines changed Expand file tree Collapse file tree 5 files changed +10
-40
lines changed Original file line number Diff line number Diff line change 5
5
#include < ArduinoJson.h>
6
6
#include < catch.hpp>
7
7
8
+ TEST_CASE (" VariantData" ) {
9
+ REQUIRE (std::is_standard_layout<ArduinoJson::detail::VariantData>::value ==
10
+ true );
11
+ }
12
+
8
13
TEST_CASE (" JsonVariant from JsonArray" ) {
9
14
SECTION (" JsonArray is null" ) {
10
15
JsonArray arr;
Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ using namespace ArduinoJson::detail;
10
10
11
11
TEST_CASE (" Test unsigned integer overflow" ) {
12
12
VariantData first, second;
13
- first.init ();
14
- second.init ();
15
13
16
14
// Avoids MSVC warning C4127 (conditional expression is constant)
17
15
size_t integerSize = sizeof (JsonInteger);
@@ -30,8 +28,6 @@ TEST_CASE("Test unsigned integer overflow") {
30
28
31
29
TEST_CASE (" Test signed integer overflow" ) {
32
30
VariantData first, second;
33
- first.init ();
34
- second.init ();
35
31
36
32
// Avoids MSVC warning C4127 (conditional expression is constant)
37
33
size_t integerSize = sizeof (JsonInteger);
@@ -50,7 +46,6 @@ TEST_CASE("Test signed integer overflow") {
50
46
51
47
TEST_CASE (" Invalid value" ) {
52
48
VariantData result;
53
- result.init ();
54
49
55
50
parseNumber (" 6a3" , result);
56
51
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
41
41
// https://arduinojson.org/v6/api/jsondocument/clear/
42
42
void clear () {
43
43
_pool.clear ();
44
- _data.init ();
44
+ _data.setNull ();
45
45
}
46
46
47
47
// Returns true if the root is of the specified type.
@@ -277,17 +277,11 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
277
277
}
278
278
279
279
protected:
280
- JsonDocument () : _pool(0 , 0 ) {
281
- _data.init ();
282
- }
280
+ JsonDocument () : _pool(0 , 0 ) {}
283
281
284
- JsonDocument (detail::MemoryPool pool) : _pool(pool) {
285
- _data.init ();
286
- }
282
+ JsonDocument (detail::MemoryPool pool) : _pool(pool) {}
287
283
288
- JsonDocument (char * buf, size_t capa) : _pool(buf, capa) {
289
- _data.init ();
290
- }
284
+ JsonDocument (char * buf, size_t capa) : _pool(buf, capa) {}
291
285
292
286
~JsonDocument () {}
293
287
Original file line number Diff line number Diff line change @@ -146,7 +146,6 @@ inline bool parseNumber(const char* s, VariantData& result) {
146
146
template <typename T>
147
147
inline T parseNumber (const char * s) {
148
148
VariantData value;
149
- value.init (); // VariantData is a POD, so it has no constructor
150
149
parseNumber (s, value);
151
150
return Converter<T>::fromJson (JsonVariantConst (&value));
152
151
}
Original file line number Diff line number Diff line change 11
11
#include < ArduinoJson/Strings/StringAdapters.hpp>
12
12
#include < ArduinoJson/Variant/VariantContent.hpp>
13
13
14
- // VariantData can't have a constructor (to be a POD), so we have no way to fix
15
- // this warning
16
- #if defined(__GNUC__)
17
- # if __GNUC__ >= 7
18
- # pragma GCC diagnostic push
19
- # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
20
- # pragma GCC diagnostic ignored "-Wuninitialized"
21
- # endif
22
- #endif
23
-
24
14
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
25
15
26
16
class VariantData {
27
17
VariantContent _content; // must be first to allow cast from array to variant
28
18
uint8_t _flags;
29
19
30
20
public:
31
- // Must be a POD!
32
- // - no constructor
33
- // - no destructor
34
- // - no virtual
35
- // - no inheritance
36
- void init () {
37
- _flags = VALUE_IS_NULL;
38
- }
21
+ VariantData () : _flags(VALUE_IS_NULL) {}
39
22
40
23
void operator =(const VariantData& src) {
41
24
_content = src._content ;
@@ -337,9 +320,3 @@ class VariantData {
337
320
};
338
321
339
322
ARDUINOJSON_END_PRIVATE_NAMESPACE
340
-
341
- #if defined(__GNUC__)
342
- # if __GNUC__ >= 8
343
- # pragma GCC diagnostic pop
344
- # endif
345
- #endif
You can’t perform that action at this time.
0 commit comments