OLD | NEW |
1 // Copyright 2011 Baptiste Lepilleur | 1 // Copyright 2011 Baptiste Lepilleur |
2 // Distributed under MIT license, or public domain if desired and | 2 // Distributed under MIT license, or public domain if desired and |
3 // recognized in your jurisdiction. | 3 // recognized in your jurisdiction. |
4 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE | 4 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE |
5 | 5 |
6 #if !defined(JSON_IS_AMALGAMATION) | 6 #if !defined(JSON_IS_AMALGAMATION) |
7 # include <json/assertions.h> | 7 # include <json/assertions.h> |
8 # include <json/value.h> | 8 # include <json/value.h> |
9 # include <json/writer.h> | 9 # include <json/writer.h> |
10 # ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR | 10 # ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR |
11 # include "json_batchallocator.h" | 11 # include "json_batchallocator.h" |
12 # endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR | 12 # endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR |
13 #endif // if !defined(JSON_IS_AMALGAMATION) | 13 #endif // if !defined(JSON_IS_AMALGAMATION) |
14 #include <math.h> | 14 #include <math.h> |
15 #include <sstream> | 15 #include <sstream> |
16 #include <utility> | 16 #include <utility> |
17 #include <stdexcept> | 17 #include <stdexcept> |
18 #include <cstring> | 18 #include <cstring> |
19 #include <cassert> | 19 #include <cassert> |
20 #ifdef JSON_USE_CPPTL | 20 #ifdef JSON_USE_CPPTL |
21 # include <cpptl/conststring.h> | 21 # include <cpptl/conststring.h> |
22 #endif | 22 #endif |
23 #include <cstddef> // size_t | 23 #include <cstddef> // size_t |
24 | 24 |
25 #define JSON_ASSERT_UNREACHABLE assert( false ) | 25 #define JSON_ASSERT_UNREACHABLE assert( false ) |
26 | 26 |
27 namespace Json { | 27 namespace Json { |
28 | 28 |
29 // This is a walkaround to avoid the static initialization of Value::null. | 29 // This is a walkaround to avoid the static initialization of Value::null. |
30 // const Value Value::null; | 30 // kNull must be word-aligned to avoid crashing on ARM. We use an alignment of |
31 static const unsigned char kNull[sizeof(Value)] = { 0 }; | 31 // 8 (instead of 4) as a bit of future-proofing. |
| 32 #if defined(__ARMEL__) |
| 33 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) |
| 34 #else |
| 35 #define ALIGNAS(byte_alignment) |
| 36 #endif |
| 37 static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = {0}; |
32 const Value& Value::null = reinterpret_cast<const Value&>(kNull); | 38 const Value& Value::null = reinterpret_cast<const Value&>(kNull); |
33 | 39 |
34 const Int Value::minInt = Int( ~(UInt(-1)/2) ); | 40 const Int Value::minInt = Int( ~(UInt(-1)/2) ); |
35 const Int Value::maxInt = Int( UInt(-1)/2 ); | 41 const Int Value::maxInt = Int( UInt(-1)/2 ); |
36 const UInt Value::maxUInt = UInt(-1); | 42 const UInt Value::maxUInt = UInt(-1); |
37 # if defined(JSON_HAS_INT64) | 43 # if defined(JSON_HAS_INT64) |
38 const Int64 Value::minInt64 = Int64( ~(UInt64(-1)/2) ); | 44 const Int64 Value::minInt64 = Int64( ~(UInt64(-1)/2) ); |
39 const Int64 Value::maxInt64 = Int64( UInt64(-1)/2 ); | 45 const Int64 Value::maxInt64 = Int64( UInt64(-1)/2 ); |
40 const UInt64 Value::maxUInt64 = UInt64(-1); | 46 const UInt64 Value::maxUInt64 = UInt64(-1); |
41 // The constant is hard-coded because some compiler have trouble | 47 // The constant is hard-coded because some compiler have trouble |
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 // Error: node is not an object at position... | 1921 // Error: node is not an object at position... |
1916 } | 1922 } |
1917 node = &((*node)[arg.key_]); | 1923 node = &((*node)[arg.key_]); |
1918 } | 1924 } |
1919 } | 1925 } |
1920 return *node; | 1926 return *node; |
1921 } | 1927 } |
1922 | 1928 |
1923 | 1929 |
1924 } // namespace Json | 1930 } // namespace Json |
OLD | NEW |