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/test/ThriftTest.thrift b/test/ThriftTest.thrift
index 897d707..414dcea 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -56,6 +56,7 @@
byte testByte(byte thing = 1),
i32 testI32(i32 thing = 1),
i64 testI64(i64 thing = 1),
+ double testDouble(double thing = 1),
Xtruct testStruct(Xtruct thing = 1),
Xtruct2 testNest(Xtruct2 thing = 1),
map<i32,i32> testMap(map<i32,i32> thing = 1),
diff --git a/test/cpp/src/TestClient.cc b/test/cpp/src/TestClient.cc
index d340e26..e12b65b 100644
--- a/test/cpp/src/TestClient.cc
+++ b/test/cpp/src/TestClient.cc
@@ -99,6 +99,13 @@
printf("testI64(-34359738368)");
int64_t i64 = testClient.testI64(-34359738368LL);
printf(" = %ld\n", i64);
+
+ /**
+ * DOUBLE TEST
+ */
+ printf("testDouble(-5.2098523)");
+ double dub = testClient.testDouble(-5.2098523);
+ printf(" = %lf\n", dub);
/**
* STRUCT TEST
diff --git a/test/cpp/src/TestServer.cc b/test/cpp/src/TestServer.cc
index 63a7594..97d3440 100644
--- a/test/cpp/src/TestServer.cc
+++ b/test/cpp/src/TestServer.cc
@@ -47,6 +47,11 @@
return thing;
}
+ double testDouble(double thing) {
+ printf("testDouble(%lf)\n", thing);
+ return thing;
+ }
+
Xtruct testStruct(Xtruct thing) {
printf("testStruct({\"%s\", %d, %d, %ld})\n",
thing.string_thing.c_str(),
diff --git a/test/java/src/TestClient.java b/test/java/src/TestClient.java
index 686920c..74fbfef 100644
--- a/test/java/src/TestClient.java
+++ b/test/java/src/TestClient.java
@@ -94,6 +94,13 @@
System.out.print(" = " + i64 + "\n");
/**
+ * DOUBLE TEST
+ */
+ System.out.print("testDouble(5.325098235)");
+ double dub = testClient.testDouble(5.325098235);
+ System.out.print(" = " + dub + "\n");
+
+ /**
* STRUCT TEST
*/
System.out.print("testStruct({\"Zero\", 1, -3, -5})");
diff --git a/test/java/src/TestServer.java b/test/java/src/TestServer.java
index 7418cbb..8e3e4ed 100644
--- a/test/java/src/TestServer.java
+++ b/test/java/src/TestServer.java
@@ -45,6 +45,11 @@
System.out.print("testI64(" + thing + ")\n");
return thing;
}
+
+ public double testDouble(double thing) {
+ System.out.print("testDouble(" + thing + ")\n");
+ return thing;
+ }
public Xtruct testStruct(Xtruct thing) {
System.out.print("testStruct({" +
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index 6dd40d7..a92adcc 100644
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -85,6 +85,13 @@
print_r(" = $i64\n");
/**
+ * DOUBLE TEST
+ */
+print_r("testDouble(-852.234234234)");
+$dub = $testClient->testDouble(-852.234234234);
+print_r(" = $dub\n");
+
+/**
* STRUCT TEST
*/
print_r("testStruct({\"Zero\", 1, -3, -5})");
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index 21d1990..3edff1c 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -32,9 +32,15 @@
print "testI32(-1)"
print client.testI32(-1)
+print "testI32(0)"
+print client.testI32(0)
+
print "testI64(-34359738368)"
print client.testI64(-34359738368)
+print "testDouble(-5.235098235)"
+print client.testDouble(-5.235098235)
+
print "testStruct({Zero, 1, -3, -5})"
x = Xtruct()
x.string_thing = "Zero"
diff --git a/test/py/TestServer.py b/test/py/TestServer.py
index 4b571c7..525ffee 100755
--- a/test/py/TestServer.py
+++ b/test/py/TestServer.py
@@ -22,12 +22,33 @@
print 'testByte(%d)' % byte
return byte
+ def testI16(self, i16):
+ print 'testI16(%d)' % i16
+ return i16
+
+ def testI32(self, i32):
+ print 'testI32(%d)' % i32
+ return i32
+
+ def testI64(self, i64):
+ print 'testI64(%d)' % i64
+ return i64
+
+ def testDouble(self, dub):
+ print 'testDouble(%f)' % dub
+ return dub
+
+ def testStruct(self, thing):
+ print 'testStruct({%s, %d, %d, %d})' % (thing.string_thing, thing.byte_thing, thing.i32_thing, thing.i64_thing)
+ return thing
+
def testException(self, str):
print 'testException(%s)' % str
- x = Xception()
- x.errorCode = 1001
- x.message = str
- raise x
+ if str == 'Xception':
+ x = Xception()
+ x.errorCode = 1001
+ x.message = str
+ raise x
transport = TSocket.TServerSocket(9090)
protocol = TBinaryProtocol.TBinaryProtocol()