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/php/src/protocol/TBinaryProtocol.php b/lib/php/src/protocol/TBinaryProtocol.php
index 4bb0297..2b1384f 100644
--- a/lib/php/src/protocol/TBinaryProtocol.php
+++ b/lib/php/src/protocol/TBinaryProtocol.php
@@ -136,6 +136,12 @@
return 8;
}
+ public function writeDouble($out, $value) {
+ $data = pack('d', $value);
+ $out->write(strrev($data), 8);
+ return 8;
+ }
+
public function writeString($out, $value) {
$len = strlen($value);
$result = $this->writeI32($out, $len);
@@ -302,6 +308,13 @@
return 8;
}
+ public function readDouble($in, &$value) {
+ $data = strrev($in->readAll(8));
+ $arr = unpack('d', $data);
+ $value = $arr[1];
+ return 8;
+ }
+
public function readString($in, &$value) {
$result = $this->readI32($in, $len);
$value = $in->readAll($len);