Thrift: Added support for double type across all languages
Summary: Just for completeness cause I'm crazy. Let's never use these!
Notes: Also made thrift grammar support # style comments, so you can do this at the top of your files
#!/usr/local/bin/thrift --cpp
/**
* This is a thrift def file youc an invoke directly and gen code!
*/
blah
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664789 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h
index 65d6f3c..89c7f48 100644
--- a/lib/cpp/src/protocol/TProtocol.h
+++ b/lib/cpp/src/protocol/TProtocol.h
@@ -16,7 +16,7 @@
using namespace facebook::thrift::transport;
-#define ntohll(x) (((uint64_t)(ntohl((int)((x << 32) >> 32))) << 32) | (uint32_t)ntohl(((int)(x >> 32))))
+#define ntohll(x) (((uint64_t)(ntohl((int)((x & 0x00000000FFFFFFFF)))) << 32) | (uint32_t)ntohl(((int)(x >> 32 & 0x00000000FFFFFFFF))))
#define htonll(x) ntohll(x)
@@ -38,6 +38,7 @@
T_I32 = 8,
T_U64 = 9,
T_I64 = 10,
+ T_DOUBLE = 4,
T_STRING = 11,
T_UTF7 = 11,
T_STRUCT = 12,
@@ -133,6 +134,9 @@
virtual uint32_t writeI64(shared_ptr<TTransport> out,
const int64_t i64) const = 0;
+ virtual uint32_t writeDouble(shared_ptr<TTransport> out,
+ const double dub) const = 0;
+
virtual uint32_t writeString(shared_ptr<TTransport> out,
const std::string& str) const = 0;
@@ -193,6 +197,9 @@
virtual uint32_t readI64(shared_ptr<TTransport> in,
int64_t& i64) const = 0;
+ virtual uint32_t readDouble(shared_ptr<TTransport> in,
+ double& dub) const = 0;
+
virtual uint32_t readString(shared_ptr<TTransport> in,
std::string& str) const = 0;
@@ -226,6 +233,11 @@
int64_t i64;
return readI64(in, i64);
}
+ case T_DOUBLE:
+ {
+ double dub;
+ return readDouble(in, dub);
+ }
case T_STRING:
{
std::string str;