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/java/src/protocol/TBinaryProtocol.java b/lib/java/src/protocol/TBinaryProtocol.java
index d90dece..4d6c345 100644
--- a/lib/java/src/protocol/TBinaryProtocol.java
+++ b/lib/java/src/protocol/TBinaryProtocol.java
@@ -95,6 +95,10 @@
out.write(i64out, 0, 8);
}
+ public void writeDouble(TTransport out, double dub) throws TException {
+ writeI64(out, Double.doubleToLongBits(dub));
+ }
+
public void writeString(TTransport out, String str) throws TException {
byte[] dat = str.getBytes();
writeI32(out, dat.length);
@@ -203,6 +207,10 @@
((long)(i64rd[7] & 0xff));
}
+ public double readDouble(TTransport in) throws TException {
+ return Double.longBitsToDouble(readI64(in));
+ }
+
public String readString(TTransport in) throws TException {
int size = readI32(in);
byte[] buf = new byte[size];
diff --git a/lib/java/src/protocol/TProtocol.java b/lib/java/src/protocol/TProtocol.java
index 69fe885..0831d12 100644
--- a/lib/java/src/protocol/TProtocol.java
+++ b/lib/java/src/protocol/TProtocol.java
@@ -61,6 +61,10 @@
public void writeI64 (TTransport out,
long i64) throws TException;
+ public void writeDouble (TTransport out,
+ double dub) throws TException;
+
+
public void writeString (TTransport out,
String str) throws TException;
@@ -102,6 +106,8 @@
public long readI64 (TTransport in) throws TException;
+ public double readDouble (TTransport in) throws TException;
+
public String readString (TTransport in) throws TException;
}
diff --git a/lib/java/src/protocol/TProtocolUtil.java b/lib/java/src/protocol/TProtocolUtil.java
index 5223639..1c88f8a 100644
--- a/lib/java/src/protocol/TProtocolUtil.java
+++ b/lib/java/src/protocol/TProtocolUtil.java
@@ -34,6 +34,10 @@
{
prot.readI64(in);
}
+ case TType.DOUBLE:
+ {
+ prot.readDouble(in);
+ }
case TType.STRING:
{
prot.readString(in);
diff --git a/lib/java/src/protocol/TType.java b/lib/java/src/protocol/TType.java
index 37b53bd..bed9a21 100644
--- a/lib/java/src/protocol/TType.java
+++ b/lib/java/src/protocol/TType.java
@@ -10,6 +10,7 @@
public static final byte VOID = 1;
public static final byte BOOL = 2;
public static final byte BYTE = 3;
+ public static final byte DOUBLE = 4;
public static final byte I16 = 6;
public static final byte I32 = 8;
public static final byte I64 = 10;