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/py/src/protocol/TBinaryProtocol.py b/lib/py/src/protocol/TBinaryProtocol.py
index 860f461..25f3218 100644
--- a/lib/py/src/protocol/TBinaryProtocol.py
+++ b/lib/py/src/protocol/TBinaryProtocol.py
@@ -73,6 +73,10 @@
buff = pack("!q", i64)
otrans.write(buff)
+ def writeDouble(self, otrans, dub):
+ buff = pack("!d", dub)
+ otrans.write(buff)
+
def writeString(self, otrans, str):
self.writeI32(otrans, len(str))
otrans.write(str)
@@ -153,6 +157,11 @@
val, = unpack('!q', buff)
return val
+ def readDouble(self, itrans):
+ buff = itrans.readAll(8)
+ val, = unpack('!d', buff)
+ return val
+
def readString(self, itrans):
len = self.readI32(itrans)
str = itrans.readAll(len)
diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py
index 3105e25..0b480d3 100644
--- a/lib/py/src/protocol/TProtocol.py
+++ b/lib/py/src/protocol/TProtocol.py
@@ -3,7 +3,8 @@
VOID = 1
BOOL = 2
BYTE = 3
- I08 = 4
+ I08 = 3
+ DOUBLE = 4
I16 = 6
I32 = 8
I64 = 10
@@ -78,6 +79,9 @@
def writeI64(self, otrans, i64):
pass
+ def writeDouble(self, otrans, dub):
+ pass
+
def writeString(self, otrans, str):
pass
@@ -132,6 +136,9 @@
def readI64(self, itrans):
pass
+ def readDouble(self, itrans):
+ pass
+
def readString(self, itrans):
pass
@@ -148,6 +155,8 @@
self.readI32(itrans)
elif type == TType.I64:
self.readI64(itrans)
+ elif type == TType.DOUBLE:
+ self.readDouble(itrans)
elif type == TType.STRING:
self.readString(itrans)
elif type == TType.STRUCT:
diff --git a/lib/py/src/server/TServer.py b/lib/py/src/server/TServer.py
index 69be260..a5d5621 100644
--- a/lib/py/src/server/TServer.py
+++ b/lib/py/src/server/TServer.py
@@ -1,3 +1,6 @@
+import sys
+import traceback
+
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
@@ -27,6 +30,6 @@
while True:
self.processor.process(client, client)
except Exception, x:
- print x
+ print '%s, %s, %s' % (type(x), x, traceback.format_exc())
print 'Client died.'
client.close()
diff --git a/lib/py/src/transport/TSocket.py b/lib/py/src/transport/TSocket.py
index 4ef35d9..61f1cff 100644
--- a/lib/py/src/transport/TSocket.py
+++ b/lib/py/src/transport/TSocket.py
@@ -36,7 +36,7 @@
def read(self, sz):
buff = self.handle.recv(sz)
if len(buff) == 0:
- raise Exception('TScket read 0 bytes')
+ raise Exception('TSocket read 0 bytes')
return buff
def write(self, buff):