quickfix_ruby 1.14.3.1 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/ext/quickfix/Acceptor.h +2 -0
  3. data/ext/quickfix/AtomicCount.h +82 -12
  4. data/ext/quickfix/DOMDocument.h +9 -7
  5. data/ext/quickfix/DataDictionary.cpp +77 -14
  6. data/ext/quickfix/DataDictionary.h +90 -16
  7. data/ext/quickfix/Dictionary.cpp +1 -2
  8. data/ext/quickfix/Exceptions.h +3 -5
  9. data/ext/quickfix/Field.h +83 -32
  10. data/ext/quickfix/FieldConvertors.cpp +93 -0
  11. data/ext/quickfix/FieldConvertors.h +129 -275
  12. data/ext/quickfix/FieldMap.cpp +53 -13
  13. data/ext/quickfix/FieldMap.h +200 -62
  14. data/ext/quickfix/FieldTypes.cpp +10 -10
  15. data/ext/quickfix/FieldTypes.h +293 -44
  16. data/ext/quickfix/FileLog.cpp +6 -10
  17. data/ext/quickfix/FileLog.h +4 -10
  18. data/ext/quickfix/FileStore.cpp +19 -6
  19. data/ext/quickfix/FileStore.h +4 -0
  20. data/ext/quickfix/FixFieldNumbers.h +1462 -1461
  21. data/ext/quickfix/FixFields.h +1462 -1461
  22. data/ext/quickfix/FixValues.h +3230 -3227
  23. data/ext/quickfix/HttpConnection.cpp +1 -1
  24. data/ext/quickfix/Initiator.cpp +7 -1
  25. data/ext/quickfix/Initiator.h +2 -0
  26. data/ext/quickfix/Log.h +6 -12
  27. data/ext/quickfix/Message.cpp +186 -57
  28. data/ext/quickfix/Message.h +109 -47
  29. data/ext/quickfix/MySQLConnection.h +1 -1
  30. data/ext/quickfix/PostgreSQLConnection.h +1 -1
  31. data/ext/quickfix/QuickfixRuby.cpp +79141 -77959
  32. data/ext/quickfix/QuickfixRuby.h +1 -1
  33. data/ext/quickfix/SSLSocketAcceptor.cpp +410 -0
  34. data/ext/quickfix/SSLSocketAcceptor.h +185 -0
  35. data/ext/quickfix/SSLSocketConnection.cpp +427 -0
  36. data/ext/quickfix/SSLSocketConnection.h +206 -0
  37. data/ext/quickfix/SSLSocketInitiator.cpp +485 -0
  38. data/ext/quickfix/SSLSocketInitiator.h +196 -0
  39. data/ext/quickfix/Session.cpp +113 -20
  40. data/ext/quickfix/Session.h +18 -4
  41. data/ext/quickfix/SessionFactory.cpp +10 -3
  42. data/ext/quickfix/SessionSettings.cpp +5 -3
  43. data/ext/quickfix/SessionSettings.h +97 -5
  44. data/ext/quickfix/Settings.cpp +72 -2
  45. data/ext/quickfix/Settings.h +3 -0
  46. data/ext/quickfix/SharedArray.h +140 -6
  47. data/ext/quickfix/SocketConnection.cpp +2 -2
  48. data/ext/quickfix/SocketConnector.cpp +5 -2
  49. data/ext/quickfix/SocketConnector.h +3 -2
  50. data/ext/quickfix/SocketInitiator.cpp +28 -4
  51. data/ext/quickfix/SocketInitiator.h +1 -1
  52. data/ext/quickfix/SocketMonitor.cpp +5 -5
  53. data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +455 -0
  54. data/ext/quickfix/ThreadedSSLSocketAcceptor.h +217 -0
  55. data/ext/quickfix/ThreadedSSLSocketConnection.cpp +404 -0
  56. data/ext/quickfix/ThreadedSSLSocketConnection.h +189 -0
  57. data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +469 -0
  58. data/ext/quickfix/ThreadedSSLSocketInitiator.h +201 -0
  59. data/ext/quickfix/ThreadedSocketAcceptor.cpp +5 -1
  60. data/ext/quickfix/ThreadedSocketConnection.cpp +8 -2
  61. data/ext/quickfix/ThreadedSocketConnection.h +4 -1
  62. data/ext/quickfix/ThreadedSocketInitiator.cpp +24 -4
  63. data/ext/quickfix/ThreadedSocketInitiator.h +1 -1
  64. data/ext/quickfix/Utility.cpp +23 -1
  65. data/ext/quickfix/Utility.h +28 -2
  66. data/ext/quickfix/UtilitySSL.cpp +1733 -0
  67. data/ext/quickfix/UtilitySSL.h +277 -0
  68. data/ext/quickfix/config-all.h +10 -0
  69. data/ext/quickfix/dirent_windows.h +838 -0
  70. data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
  71. data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
  72. data/ext/quickfix/double-conversion/bignum.cc +766 -0
  73. data/ext/quickfix/double-conversion/bignum.h +144 -0
  74. data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
  75. data/ext/quickfix/double-conversion/cached-powers.h +64 -0
  76. data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
  77. data/ext/quickfix/double-conversion/diy-fp.h +118 -0
  78. data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
  79. data/ext/quickfix/double-conversion/double-conversion.h +543 -0
  80. data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
  81. data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
  82. data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
  83. data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
  84. data/ext/quickfix/double-conversion/ieee.h +402 -0
  85. data/ext/quickfix/double-conversion/strtod.cc +557 -0
  86. data/ext/quickfix/double-conversion/strtod.h +45 -0
  87. data/ext/quickfix/double-conversion/utils.h +372 -0
  88. data/ext/quickfix/stdint_msvc.h +254 -0
  89. data/lib/quickfix44.rb +3329 -10
  90. data/lib/quickfix50.rb +6649 -81
  91. data/lib/quickfix50sp1.rb +8054 -142
  92. data/lib/quickfix50sp2.rb +10900 -234
  93. data/lib/quickfix_fields.rb +7662 -7649
  94. data/spec/FIX40.xml +28 -28
  95. data/spec/FIX41.xml +29 -29
  96. data/spec/FIX42.xml +47 -47
  97. data/spec/FIX43.xml +148 -148
  98. data/spec/FIX44.xml +1078 -1081
  99. data/spec/FIX50.xml +1292 -1289
  100. data/spec/FIX50SP1.xml +1811 -1802
  101. data/spec/FIX50SP2.xml +1948 -1939
  102. data/spec/FIXT11.xml +5 -8
  103. data/test/test_FieldBaseTestCase.rb +1 -1
  104. data/test/test_MessageTestCase.rb +2 -2
  105. metadata +42 -6
@@ -0,0 +1,45 @@
1
+ // Copyright 2010 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef DOUBLE_CONVERSION_STRTOD_H_
29
+ #define DOUBLE_CONVERSION_STRTOD_H_
30
+
31
+ #include "double-conversion/utils.h"
32
+
33
+ namespace double_conversion {
34
+
35
+ // The buffer must only contain digits in the range [0-9]. It must not
36
+ // contain a dot or a sign. It must not start with '0', and must not be empty.
37
+ double Strtod(Vector<const char> buffer, int exponent);
38
+
39
+ // The buffer must only contain digits in the range [0-9]. It must not
40
+ // contain a dot or a sign. It must not start with '0', and must not be empty.
41
+ float Strtof(Vector<const char> buffer, int exponent);
42
+
43
+ } // namespace double_conversion
44
+
45
+ #endif // DOUBLE_CONVERSION_STRTOD_H_
@@ -0,0 +1,372 @@
1
+ // Copyright 2010 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef DOUBLE_CONVERSION_UTILS_H_
29
+ #define DOUBLE_CONVERSION_UTILS_H_
30
+
31
+ #include <stdlib.h>
32
+ #include <string.h>
33
+
34
+ #include <assert.h>
35
+
36
+ #if defined(__SUNPRO_CC)
37
+ #ifndef ASSERT
38
+ #define ASSERT(condition)
39
+ #endif
40
+ #endif
41
+
42
+ #ifndef ASSERT
43
+ #define ASSERT(condition) \
44
+ assert(condition);
45
+ #endif
46
+ #ifndef UNIMPLEMENTED
47
+ #define UNIMPLEMENTED() (abort())
48
+ #endif
49
+ #ifndef UNREACHABLE
50
+ #define UNREACHABLE() (abort())
51
+ #endif
52
+
53
+ // Double operations detection based on target architecture.
54
+ // Linux uses a 80bit wide floating point stack on x86. This induces double
55
+ // rounding, which in turn leads to wrong results.
56
+ // An easy way to test if the floating-point operations are correct is to
57
+ // evaluate: 89255.0/1e22. If the floating-point stack is 64 bits wide then
58
+ // the result is equal to 89255e-22.
59
+ // The best way to test this, is to create a division-function and to compare
60
+ // the output of the division with the expected result. (Inlining must be
61
+ // disabled.)
62
+ // On Linux,x86 89255e-22 != Div_double(89255.0/1e22)
63
+ #if defined(_M_X64) || defined(__x86_64__) || \
64
+ defined(__ARMEL__) || defined(__avr32__) || \
65
+ defined(__hppa__) || defined(__ia64__) || \
66
+ defined(__mips__) || \
67
+ defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \
68
+ defined(_POWER) || defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \
69
+ defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
70
+ defined(__SH4__) || defined(__alpha__) || \
71
+ defined(_MIPS_ARCH_MIPS32R2) || \
72
+ defined(__AARCH64EL__) || defined(__aarch64__)
73
+ #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
74
+ #elif defined(__mc68000__)
75
+ #undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
76
+ #elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
77
+ #if defined(_WIN32)
78
+ // Windows uses a 64bit wide floating point stack.
79
+ #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
80
+ #else
81
+ #undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
82
+ #endif // _WIN32
83
+ #else
84
+ #error Target architecture was not detected as supported by Double-Conversion.
85
+ #endif
86
+
87
+ #if defined(__GNUC__)
88
+ #define DOUBLE_CONVERSION_UNUSED __attribute__((unused))
89
+ #else
90
+ #define DOUBLE_CONVERSION_UNUSED
91
+ #endif
92
+
93
+ #if defined(_WIN32) && !defined(__MINGW32__)
94
+
95
+ typedef signed char int8_t;
96
+ typedef unsigned char uint8_t;
97
+ typedef short int16_t; // NOLINT
98
+ typedef unsigned short uint16_t; // NOLINT
99
+ typedef int int32_t;
100
+ typedef unsigned int uint32_t;
101
+ typedef __int64 int64_t;
102
+ typedef unsigned __int64 uint64_t;
103
+ // intptr_t and friends are defined in crtdefs.h through stdio.h.
104
+
105
+ #else
106
+
107
+ #include <stdint.h>
108
+
109
+ #endif
110
+
111
+ typedef uint16_t uc16;
112
+
113
+ // The following macro works on both 32 and 64-bit platforms.
114
+ // Usage: instead of writing 0x1234567890123456
115
+ // write UINT64_2PART_C(0x12345678,90123456);
116
+ #define UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
117
+
118
+
119
+ // The expression ARRAY_SIZE(a) is a compile-time constant of type
120
+ // size_t which represents the number of elements of the given
121
+ // array. You should only use ARRAY_SIZE on statically allocated
122
+ // arrays.
123
+ #ifndef ARRAY_SIZE
124
+ #define ARRAY_SIZE(a) \
125
+ ((sizeof(a) / sizeof(*(a))) / \
126
+ static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
127
+ #endif
128
+
129
+ // A macro to disallow the evil copy constructor and operator= functions
130
+ // This should be used in the private: declarations for a class
131
+ #ifndef DISALLOW_COPY_AND_ASSIGN
132
+ #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
133
+ TypeName(const TypeName&); \
134
+ void operator=(const TypeName&)
135
+ #endif
136
+
137
+ // A macro to disallow all the implicit constructors, namely the
138
+ // default constructor, copy constructor and operator= functions.
139
+ //
140
+ // This should be used in the private: declarations for a class
141
+ // that wants to prevent anyone from instantiating it. This is
142
+ // especially useful for classes containing only static methods.
143
+ #ifndef DISALLOW_IMPLICIT_CONSTRUCTORS
144
+ #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
145
+ TypeName(); \
146
+ DISALLOW_COPY_AND_ASSIGN(TypeName)
147
+ #endif
148
+
149
+ namespace double_conversion {
150
+
151
+ static const int kCharSize = sizeof(char);
152
+
153
+ // Returns the maximum of the two parameters.
154
+ template <typename T>
155
+ static T Max(T a, T b) {
156
+ return a < b ? b : a;
157
+ }
158
+
159
+
160
+ // Returns the minimum of the two parameters.
161
+ template <typename T>
162
+ static T Min(T a, T b) {
163
+ return a < b ? a : b;
164
+ }
165
+
166
+
167
+ inline int StrLength(const char* string) {
168
+ size_t length = strlen(string);
169
+ ASSERT(length == static_cast<size_t>(static_cast<int>(length)));
170
+ return static_cast<int>(length);
171
+ }
172
+
173
+ // This is a simplified version of V8's Vector class.
174
+ template <typename T>
175
+ class Vector {
176
+ public:
177
+ Vector() : start_(NULL), length_(0) {}
178
+ Vector(T* data, int len) : start_(data), length_(len) {
179
+ ASSERT(len == 0 || (len > 0 && data != NULL));
180
+ }
181
+
182
+ // Returns a vector using the same backing storage as this one,
183
+ // spanning from and including 'from', to but not including 'to'.
184
+ Vector<T> SubVector(int from, int to) {
185
+ ASSERT(to <= length_);
186
+ ASSERT(from < to);
187
+ ASSERT(0 <= from);
188
+ return Vector<T>(start() + from, to - from);
189
+ }
190
+
191
+ // Returns the length of the vector.
192
+ int length() const { return length_; }
193
+
194
+ // Returns whether or not the vector is empty.
195
+ bool is_empty() const { return length_ == 0; }
196
+
197
+ // Returns the pointer to the start of the data in the vector.
198
+ T* start() const { return start_; }
199
+
200
+ // Access individual vector elements - checks bounds in debug mode.
201
+ T& operator[](int index) const {
202
+ ASSERT(0 <= index && index < length_);
203
+ return start_[index];
204
+ }
205
+
206
+ T& first() { return start_[0]; }
207
+
208
+ T& last() { return start_[length_ - 1]; }
209
+
210
+ private:
211
+ T* start_;
212
+ int length_;
213
+ };
214
+
215
+
216
+ // Helper class for building result strings in a character buffer. The
217
+ // purpose of the class is to use safe operations that checks the
218
+ // buffer bounds on all operations in debug mode.
219
+ class StringBuilder {
220
+ public:
221
+ StringBuilder(char* buffer, int buffer_size)
222
+ : buffer_(buffer, buffer_size), position_(0) { }
223
+
224
+ ~StringBuilder() { if (!is_finalized()) Finalize(); }
225
+
226
+ int size() const { return buffer_.length(); }
227
+
228
+ // Get the current position in the builder.
229
+ int position() const {
230
+ ASSERT(!is_finalized());
231
+ return position_;
232
+ }
233
+
234
+ // Reset the position.
235
+ void Reset() { position_ = 0; }
236
+
237
+ // Add a single character to the builder. It is not allowed to add
238
+ // 0-characters; use the Finalize() method to terminate the string
239
+ // instead.
240
+ void AddCharacter(char c) {
241
+ ASSERT(c != '\0');
242
+ ASSERT(!is_finalized() && position_ < buffer_.length());
243
+ buffer_[position_++] = c;
244
+ }
245
+
246
+ // Add an entire string to the builder. Uses strlen() internally to
247
+ // compute the length of the input string.
248
+ void AddString(const char* s) {
249
+ AddSubstring(s, StrLength(s));
250
+ }
251
+
252
+ // Add the first 'n' characters of the given string 's' to the
253
+ // builder. The input string must have enough characters.
254
+ void AddSubstring(const char* s, int n) {
255
+ ASSERT(!is_finalized() && position_ + n < buffer_.length());
256
+ ASSERT(static_cast<size_t>(n) <= strlen(s));
257
+ memmove(&buffer_[position_], s, n * kCharSize);
258
+ position_ += n;
259
+ }
260
+
261
+
262
+ // Add character padding to the builder. If count is non-positive,
263
+ // nothing is added to the builder.
264
+ void AddPadding(char c, int count) {
265
+ for (int i = 0; i < count; i++) {
266
+ AddCharacter(c);
267
+ }
268
+ }
269
+
270
+ // Finalize the string by 0-terminating it and returning the buffer.
271
+ char* Finalize() {
272
+ ASSERT(!is_finalized() && position_ < buffer_.length());
273
+ buffer_[position_] = '\0';
274
+ // Make sure nobody managed to add a 0-character to the
275
+ // buffer while building the string.
276
+ ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_));
277
+ position_ = -1;
278
+ ASSERT(is_finalized());
279
+ return buffer_.start();
280
+ }
281
+
282
+ // Truncate trailing zeros
283
+ // truncate 1.23000 to 1.23
284
+ // truncate 1.23000e15 to 1.23e15
285
+ // don't truncate 1.23e10 to 1.23e1
286
+ void TrimTrailingZeros()
287
+ {
288
+ ASSERT(!is_finalized() && position_ < buffer_.length());
289
+
290
+ for (int dot_pos = 0; dot_pos < position_; ++dot_pos)
291
+ {
292
+ if (buffer_[dot_pos] == '.')
293
+ {
294
+ int pow_size = 0;
295
+ int pow_pos = position_;
296
+ while ( --pow_pos > dot_pos )
297
+ {
298
+ if (buffer_[pow_pos] == 'e' ||
299
+ buffer_[pow_pos] == 'E')
300
+ {
301
+ pow_size = position_ - pow_pos;
302
+ position_ = pow_pos;
303
+ break;
304
+ }
305
+ }
306
+
307
+ while (position_ > 0 && buffer_[position_ - 1] == '0')
308
+ --position_;
309
+
310
+ if (position_ > 0 && buffer_[position_ - 1] == '.')
311
+ --position_;
312
+
313
+ if (pow_size > 0)
314
+ AddSubstring( &buffer_[pow_pos], pow_size);
315
+ }
316
+ }
317
+
318
+ }
319
+
320
+ private:
321
+ Vector<char> buffer_;
322
+ int position_;
323
+
324
+ bool is_finalized() const { return position_ < 0; }
325
+
326
+ DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
327
+ };
328
+
329
+ // The type-based aliasing rule allows the compiler to assume that pointers of
330
+ // different types (for some definition of different) never alias each other.
331
+ // Thus the following code does not work:
332
+ //
333
+ // float f = foo();
334
+ // int fbits = *(int*)(&f);
335
+ //
336
+ // The compiler 'knows' that the int pointer can't refer to f since the types
337
+ // don't match, so the compiler may cache f in a register, leaving random data
338
+ // in fbits. Using C++ style casts makes no difference, however a pointer to
339
+ // char data is assumed to alias any other pointer. This is the 'memcpy
340
+ // exception'.
341
+ //
342
+ // Bit_cast uses the memcpy exception to move the bits from a variable of one
343
+ // type of a variable of another type. Of course the end result is likely to
344
+ // be implementation dependent. Most compilers (gcc-4.2 and MSVC 2005)
345
+ // will completely optimize BitCast away.
346
+ //
347
+ // There is an additional use for BitCast.
348
+ // Recent gccs will warn when they see casts that may result in breakage due to
349
+ // the type-based aliasing rule. If you have checked that there is no breakage
350
+ // you can use BitCast to cast one pointer type to another. This confuses gcc
351
+ // enough that it can no longer see that you have cast one pointer type to
352
+ // another thus avoiding the warning.
353
+ template <class Dest, class Source>
354
+ inline Dest BitCast(const Source& source) {
355
+ // Compile time assertion: sizeof(Dest) == sizeof(Source)
356
+ // A compile error here means your Dest and Source have different sizes.
357
+ DOUBLE_CONVERSION_UNUSED
358
+ typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
359
+
360
+ Dest dest;
361
+ memmove(&dest, &source, sizeof(dest));
362
+ return dest;
363
+ }
364
+
365
+ template <class Dest, class Source>
366
+ inline Dest BitCast(Source* source) {
367
+ return BitCast<Dest>(reinterpret_cast<uintptr_t>(source));
368
+ }
369
+
370
+ } // namespace double_conversion
371
+
372
+ #endif // DOUBLE_CONVERSION_UTILS_H_
@@ -0,0 +1,254 @@
1
+ // ISO C9x compliant stdint.h for Microsoft Visual Studio
2
+ // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3
+ //
4
+ // Copyright (c) 2006-2013 Alexander Chemeris
5
+ //
6
+ // Redistribution and use in source and binary forms, with or without
7
+ // modification, are permitted provided that the following conditions are met:
8
+ //
9
+ // 1. Redistributions of source code must retain the above copyright notice,
10
+ // this list of conditions and the following disclaimer.
11
+ //
12
+ // 2. Redistributions in binary form must reproduce the above copyright
13
+ // notice, this list of conditions and the following disclaimer in the
14
+ // documentation and/or other materials provided with the distribution.
15
+ //
16
+ // 3. Neither the name of the product nor the names of its contributors may
17
+ // be used to endorse or promote products derived from this software
18
+ // without specific prior written permission.
19
+ //
20
+ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
21
+ // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
23
+ // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26
+ // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
+ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28
+ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
+ // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ //
31
+ ///////////////////////////////////////////////////////////////////////////////
32
+
33
+ #ifndef _MSC_VER // [
34
+ #error "Use this header only with Microsoft Visual C++ compilers!"
35
+ #endif // _MSC_VER ]
36
+
37
+ #ifndef _MSC_STDINT_H_ // [
38
+ #define _MSC_STDINT_H_
39
+
40
+ #if _MSC_VER > 1000
41
+ #pragma once
42
+ #endif
43
+
44
+ #include <limits.h>
45
+
46
+ // For Visual Studio 6 in C++ mode and for many Visual Studio versions when
47
+ // compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
48
+ // or compiler give many errors like this:
49
+ // error C2733: second C linkage of overloaded function 'wmemchr' not allowed
50
+ #ifdef __cplusplus
51
+ extern "C" {
52
+ #endif
53
+ # include <wchar.h>
54
+ #ifdef __cplusplus
55
+ }
56
+ #endif
57
+
58
+ // Define _W64 macros to mark types changing their size, like intptr_t.
59
+ #ifndef _W64
60
+ # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
61
+ # define _W64 __w64
62
+ # else
63
+ # define _W64
64
+ # endif
65
+ #endif
66
+
67
+
68
+ // 7.18.1 Integer types
69
+
70
+ // 7.18.1.1 Exact-width integer types
71
+
72
+ // Visual Studio 6 and Embedded Visual C++ 4 doesn't
73
+ // realize that, e.g. char has the same size as __int8
74
+ // so we give up on __intX for them.
75
+ #if (_MSC_VER < 1300)
76
+ typedef signed char int8_t;
77
+ typedef signed short int16_t;
78
+ typedef signed int int32_t;
79
+ typedef unsigned char uint8_t;
80
+ typedef unsigned short uint16_t;
81
+ typedef unsigned int uint32_t;
82
+ #else
83
+ typedef signed __int8 int8_t;
84
+ typedef signed __int16 int16_t;
85
+ typedef signed __int32 int32_t;
86
+ typedef unsigned __int8 uint8_t;
87
+ typedef unsigned __int16 uint16_t;
88
+ typedef unsigned __int32 uint32_t;
89
+ #endif
90
+ typedef signed __int64 int64_t;
91
+ typedef unsigned __int64 uint64_t;
92
+
93
+
94
+ // 7.18.1.2 Minimum-width integer types
95
+ typedef int8_t int_least8_t;
96
+ typedef int16_t int_least16_t;
97
+ typedef int32_t int_least32_t;
98
+ typedef int64_t int_least64_t;
99
+ typedef uint8_t uint_least8_t;
100
+ typedef uint16_t uint_least16_t;
101
+ typedef uint32_t uint_least32_t;
102
+ typedef uint64_t uint_least64_t;
103
+
104
+ // 7.18.1.3 Fastest minimum-width integer types
105
+ typedef int8_t int_fast8_t;
106
+ typedef int16_t int_fast16_t;
107
+ typedef int32_t int_fast32_t;
108
+ typedef int64_t int_fast64_t;
109
+ typedef uint8_t uint_fast8_t;
110
+ typedef uint16_t uint_fast16_t;
111
+ typedef uint32_t uint_fast32_t;
112
+ typedef uint64_t uint_fast64_t;
113
+
114
+ // 7.18.1.4 Integer types capable of holding object pointers
115
+ #ifdef _WIN64 // [
116
+ typedef signed __int64 intptr_t;
117
+ typedef unsigned __int64 uintptr_t;
118
+ #else // _WIN64 ][
119
+ typedef _W64 signed int intptr_t;
120
+ typedef _W64 unsigned int uintptr_t;
121
+ #endif // _WIN64 ]
122
+
123
+ // 7.18.1.5 Greatest-width integer types
124
+ typedef int64_t intmax_t;
125
+ typedef uint64_t uintmax_t;
126
+
127
+
128
+ // 7.18.2 Limits of specified-width integer types
129
+
130
+ #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
131
+
132
+ // 7.18.2.1 Limits of exact-width integer types
133
+ #define INT8_MIN ((int8_t)_I8_MIN)
134
+ #define INT8_MAX _I8_MAX
135
+ #define INT16_MIN ((int16_t)_I16_MIN)
136
+ #define INT16_MAX _I16_MAX
137
+ #define INT32_MIN ((int32_t)_I32_MIN)
138
+ #define INT32_MAX _I32_MAX
139
+ #define INT64_MIN ((int64_t)_I64_MIN)
140
+ #define INT64_MAX _I64_MAX
141
+ #define UINT8_MAX _UI8_MAX
142
+ #define UINT16_MAX _UI16_MAX
143
+ #define UINT32_MAX _UI32_MAX
144
+ #define UINT64_MAX _UI64_MAX
145
+
146
+ // 7.18.2.2 Limits of minimum-width integer types
147
+ #define INT_LEAST8_MIN INT8_MIN
148
+ #define INT_LEAST8_MAX INT8_MAX
149
+ #define INT_LEAST16_MIN INT16_MIN
150
+ #define INT_LEAST16_MAX INT16_MAX
151
+ #define INT_LEAST32_MIN INT32_MIN
152
+ #define INT_LEAST32_MAX INT32_MAX
153
+ #define INT_LEAST64_MIN INT64_MIN
154
+ #define INT_LEAST64_MAX INT64_MAX
155
+ #define UINT_LEAST8_MAX UINT8_MAX
156
+ #define UINT_LEAST16_MAX UINT16_MAX
157
+ #define UINT_LEAST32_MAX UINT32_MAX
158
+ #define UINT_LEAST64_MAX UINT64_MAX
159
+
160
+ // 7.18.2.3 Limits of fastest minimum-width integer types
161
+ #define INT_FAST8_MIN INT8_MIN
162
+ #define INT_FAST8_MAX INT8_MAX
163
+ #define INT_FAST16_MIN INT16_MIN
164
+ #define INT_FAST16_MAX INT16_MAX
165
+ #define INT_FAST32_MIN INT32_MIN
166
+ #define INT_FAST32_MAX INT32_MAX
167
+ #define INT_FAST64_MIN INT64_MIN
168
+ #define INT_FAST64_MAX INT64_MAX
169
+ #define UINT_FAST8_MAX UINT8_MAX
170
+ #define UINT_FAST16_MAX UINT16_MAX
171
+ #define UINT_FAST32_MAX UINT32_MAX
172
+ #define UINT_FAST64_MAX UINT64_MAX
173
+
174
+ // 7.18.2.4 Limits of integer types capable of holding object pointers
175
+ #ifdef _WIN64 // [
176
+ # define INTPTR_MIN INT64_MIN
177
+ # define INTPTR_MAX INT64_MAX
178
+ # define UINTPTR_MAX UINT64_MAX
179
+ #else // _WIN64 ][
180
+ # define INTPTR_MIN INT32_MIN
181
+ # define INTPTR_MAX INT32_MAX
182
+ # define UINTPTR_MAX UINT32_MAX
183
+ #endif // _WIN64 ]
184
+
185
+ // 7.18.2.5 Limits of greatest-width integer types
186
+ #define INTMAX_MIN INT64_MIN
187
+ #define INTMAX_MAX INT64_MAX
188
+ #define UINTMAX_MAX UINT64_MAX
189
+
190
+ // 7.18.3 Limits of other integer types
191
+
192
+ #ifdef _WIN64 // [
193
+ # define PTRDIFF_MIN _I64_MIN
194
+ # define PTRDIFF_MAX _I64_MAX
195
+ #else // _WIN64 ][
196
+ # define PTRDIFF_MIN _I32_MIN
197
+ # define PTRDIFF_MAX _I32_MAX
198
+ #endif // _WIN64 ]
199
+
200
+ #define SIG_ATOMIC_MIN INT_MIN
201
+ #define SIG_ATOMIC_MAX INT_MAX
202
+
203
+ #ifndef SIZE_MAX // [
204
+ # ifdef _WIN64 // [
205
+ # define SIZE_MAX _UI64_MAX
206
+ # else // _WIN64 ][
207
+ # define SIZE_MAX _UI32_MAX
208
+ # endif // _WIN64 ]
209
+ #endif // SIZE_MAX ]
210
+
211
+ // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
212
+ #ifndef WCHAR_MIN // [
213
+ # define WCHAR_MIN 0
214
+ #endif // WCHAR_MIN ]
215
+ #ifndef WCHAR_MAX // [
216
+ # define WCHAR_MAX _UI16_MAX
217
+ #endif // WCHAR_MAX ]
218
+
219
+ #define WINT_MIN 0
220
+ #define WINT_MAX _UI16_MAX
221
+
222
+ #endif // __STDC_LIMIT_MACROS ]
223
+
224
+
225
+ // 7.18.4 Limits of other integer types
226
+
227
+ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
228
+
229
+ // 7.18.4.1 Macros for minimum-width integer constants
230
+
231
+ #define INT8_C(val) val##i8
232
+ #define INT16_C(val) val##i16
233
+ #define INT32_C(val) val##i32
234
+ #define INT64_C(val) val##i64
235
+
236
+ #define UINT8_C(val) val##ui8
237
+ #define UINT16_C(val) val##ui16
238
+ #define UINT32_C(val) val##ui32
239
+ #define UINT64_C(val) val##ui64
240
+
241
+ // 7.18.4.2 Macros for greatest-width integer constants
242
+ // These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.
243
+ // Check out Issue 9 for the details.
244
+ #ifndef INTMAX_C // [
245
+ #define INTMAX_C INT64_C
246
+ #endif // INTMAX_C ]
247
+ #ifndef UINTMAX_C // [
248
+ #define UINTMAX_C UINT64_C
249
+ #endif // UINTMAX_C ]
250
+
251
+ #endif // __STDC_CONSTANT_MACROS ]
252
+
253
+
254
+ #endif // _MSC_STDINT_H_ ]