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/TBinaryProtocol.cc b/lib/cpp/src/protocol/TBinaryProtocol.cc
index 51c9306..9fb2ec3 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.cc
+++ b/lib/cpp/src/protocol/TBinaryProtocol.cc
@@ -116,7 +116,24 @@
   out->write((uint8_t*)&net, 8);
   return 8;
 }
+  
+uint32_t TBinaryProtocol::writeDouble(shared_ptr<TTransport> out,
+                                      const double dub) const {
+  uint8_t b[8];
+  uint8_t* d = (uint8_t*)&dub;
+  b[0] = d[7];
+  b[1] = d[6];
+  b[2] = d[5];
+  b[3] = d[4];
+  b[4] = d[3];
+  b[5] = d[2];
+  b[6] = d[1];
+  b[7] = d[0];
+  out->write((uint8_t*)b, 8);
+  return 8;
+}
 
+  
 uint32_t TBinaryProtocol::writeString(shared_ptr<TTransport> out,
                                       const string& str) const {
   uint32_t result = writeI32(out, str.size());
@@ -276,6 +293,23 @@
   return 8;
 }
 
+uint32_t TBinaryProtocol::readDouble(shared_ptr<TTransport> in,
+                                     double& dub) const {
+  uint8_t b[8];
+  uint8_t d[8];
+  in->readAll(b, 8);
+  d[0] = b[7];
+  d[1] = b[6];
+  d[2] = b[5];
+  d[3] = b[4];
+  d[4] = b[3];
+  d[5] = b[2];
+  d[6] = b[1];
+  d[7] = b[0];
+  dub = *(double*)d;
+  return 8;
+}
+
 uint32_t TBinaryProtocol::readString(shared_ptr<TTransport> in,
                                      string& str) const {
   uint32_t result;
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h
index 5bca6dd..7f36a57 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/protocol/TBinaryProtocol.h
@@ -80,6 +80,10 @@
   uint32_t writeI64(shared_ptr<TTransport> out,
 		     const int64_t i64) const;
 
+  uint32_t writeDouble(shared_ptr<TTransport> out,
+                       const double dub) const;
+
+
   uint32_t writeString(shared_ptr<TTransport> out,
 			const std::string& str) const;
 
@@ -141,6 +145,9 @@
   uint32_t readI64(shared_ptr<TTransport> in,
 		    int64_t& i64) const;
 
+  uint32_t readDouble(shared_ptr<TTransport> in,
+                      double& dub) const;
+
   uint32_t readString(shared_ptr<TTransport> in,
 		       std::string& str) const;
 };
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;