From cfc0193d466df7b18a0995b300a8586a462b92a1 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Fri, 1 Sep 2006 22:18:16 +0000 Subject: [PATCH] Thrift library updates, remove unsigned types git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664772 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/Thrift.h | 2 +- lib/cpp/src/protocol/TBinaryProtocol.cc | 118 +++++-------- lib/cpp/src/protocol/TBinaryProtocol.h | 26 +-- lib/cpp/src/protocol/TProtocol.h | 44 +---- lib/php/src/Thrift.php | 6 +- lib/php/src/protocol/TBinaryProtocol.php | 202 ++++++----------------- lib/php/src/protocol/TProtocol.php | 68 +++++--- lib/php/src/protocol/TType.php | 19 ++- 8 files changed, 163 insertions(+), 322 deletions(-) diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h index 1f98d82c..9254b562 100644 --- a/lib/cpp/src/Thrift.h +++ b/lib/cpp/src/Thrift.h @@ -9,7 +9,7 @@ #include #include -namespace facebook {namespace thrift { +namespace facebook { namespace thrift { class Exception : public std::exception { private: diff --git a/lib/cpp/src/protocol/TBinaryProtocol.cc b/lib/cpp/src/protocol/TBinaryProtocol.cc index f2fbe873..51c93068 100644 --- a/lib/cpp/src/protocol/TBinaryProtocol.cc +++ b/lib/cpp/src/protocol/TBinaryProtocol.cc @@ -7,11 +7,11 @@ namespace facebook { namespace thrift { namespace protocol { uint32_t TBinaryProtocol::writeMessageBegin(shared_ptr out, const std::string name, const TMessageType messageType, - const uint32_t seqid) const { + const int32_t seqid) const { return writeString(out, name) + - writeByte(out, (uint8_t)messageType) + - writeU32(out, seqid); + writeByte(out, (int8_t)messageType) + + writeI32(out, seqid); } uint32_t TBinaryProtocol::writeMessageEnd(shared_ptr out) const { @@ -32,7 +32,7 @@ uint32_t TBinaryProtocol::writeFieldBegin(shared_ptr out, const TType fieldType, const int16_t fieldId) const { return - writeByte(out, (uint8_t)fieldType) + + writeByte(out, (int8_t)fieldType) + writeI16(out, fieldId); } @@ -42,7 +42,7 @@ uint32_t TBinaryProtocol::writeFieldEnd(shared_ptr out) const { uint32_t TBinaryProtocol::writeFieldStop(shared_ptr out) const { return - writeByte(out, (uint8_t)T_STOP); + writeByte(out, (int8_t)T_STOP); } uint32_t TBinaryProtocol::writeMapBegin(shared_ptr out, @@ -50,9 +50,9 @@ uint32_t TBinaryProtocol::writeMapBegin(shared_ptr out, const TType valType, const uint32_t size) const { return - writeByte(out, (uint8_t)keyType) + - writeByte(out, (uint8_t)valType) + - writeU32(out, (uint32_t)size); + writeByte(out, (int8_t)keyType) + + writeByte(out, (int8_t)valType) + + writeI32(out, (int32_t)size); } uint32_t TBinaryProtocol::writeMapEnd(shared_ptr out) const { @@ -63,8 +63,8 @@ uint32_t TBinaryProtocol::writeListBegin(shared_ptr out, const TType elemType, const uint32_t size) const { return - writeByte(out, (uint8_t) elemType) + - writeU32(out, (int32_t)size); + writeByte(out, (int8_t) elemType) + + writeI32(out, (int32_t)size); } uint32_t TBinaryProtocol::writeListEnd(shared_ptr out) const { @@ -75,8 +75,8 @@ uint32_t TBinaryProtocol::writeSetBegin(shared_ptr out, const TType elemType, const uint32_t size) const { return - writeByte(out, (uint8_t)elemType) + - writeU32(out, (int32_t)size); + writeByte(out, (int8_t)elemType) + + writeI32(out, (int32_t)size); } uint32_t TBinaryProtocol::writeSetEnd(shared_ptr out) const { @@ -91,18 +91,11 @@ uint32_t TBinaryProtocol::writeBool(shared_ptr out, } uint32_t TBinaryProtocol::writeByte(shared_ptr out, - const uint8_t byte) const { - out->write(&byte, 1); + const int8_t byte) const { + out->write((uint8_t*)&byte, 1); return 1; } -uint32_t TBinaryProtocol::writeU16(shared_ptr out, - const uint16_t u16) const { - uint16_t net = (uint16_t)htons(u16); - out->write((uint8_t*)&net, 2); - return 2; -} - uint32_t TBinaryProtocol::writeI16(shared_ptr out, const int16_t i16) const { int16_t net = (int16_t)htons(i16); @@ -110,13 +103,6 @@ uint32_t TBinaryProtocol::writeI16(shared_ptr out, return 2; } -uint32_t TBinaryProtocol::writeU32(shared_ptr out, - const uint32_t u32) const { - uint32_t net = (uint32_t)htonl(u32); - out->write((uint8_t*)&net, 4); - return 4; -} - uint32_t TBinaryProtocol::writeI32(shared_ptr out, const int32_t i32) const { int32_t net = (int32_t)htonl(i32); @@ -124,13 +110,6 @@ uint32_t TBinaryProtocol::writeI32(shared_ptr out, return 4; } -uint32_t TBinaryProtocol::writeU64(shared_ptr out, - const uint64_t u64) const { - uint64_t net = (uint64_t)htonll(u64); - out->write((uint8_t*)&net, 8); - return 8; -} - uint32_t TBinaryProtocol::writeI64(shared_ptr out, const int64_t i64) const { int64_t net = (int64_t)htonll(i64); @@ -152,14 +131,14 @@ uint32_t TBinaryProtocol::writeString(shared_ptr out, uint32_t TBinaryProtocol::readMessageBegin(shared_ptr in, std::string& name, TMessageType& messageType, - uint32_t& seqid) const { + int32_t& seqid) const { uint32_t result = 0; - uint8_t type; + int8_t type; result+= readString(in, name); result+= readByte(in, type); messageType = (TMessageType)type; - result+= readU32(in, seqid); + result+= readI32(in, seqid); return result; } @@ -182,7 +161,7 @@ uint32_t TBinaryProtocol::readFieldBegin(shared_ptr in, TType& fieldType, int16_t& fieldId) const { uint32_t result = 0; - uint8_t type; + int8_t type; result += readByte(in, type); fieldType = (TType)type; if (fieldType == T_STOP) { @@ -201,13 +180,16 @@ uint32_t TBinaryProtocol::readMapBegin(shared_ptr in, TType& keyType, TType& valType, uint32_t& size) const { - uint8_t k, v; + int8_t k, v; uint32_t result = 0; + int32_t sizei; result += readByte(in, k); keyType = (TType)k; result += readByte(in, v); valType = (TType)v; - result += readU32(in, size); + result += readI32(in, sizei); + // TODO(mcslee): check for negative size + size = (uint32_t)sizei; return result; } @@ -218,11 +200,14 @@ uint32_t TBinaryProtocol::readMapEnd(shared_ptr in) const { uint32_t TBinaryProtocol::readListBegin(shared_ptr in, TType& elemType, uint32_t& size) const { - uint8_t e; + int8_t e; uint32_t result = 0; + int32_t sizei; result += readByte(in, e); elemType = (TType)e; - result += readU32(in, size); + result += readI32(in, sizei); + // TODO(mcslee): check for negative size + size = (uint32_t)sizei; return result; } @@ -233,11 +218,14 @@ uint32_t TBinaryProtocol::readListEnd(shared_ptr in) const { uint32_t TBinaryProtocol::readSetBegin(shared_ptr in, TType& elemType, uint32_t& size) const { - uint8_t e; + int8_t e; uint32_t result = 0; + int32_t sizei; result += readByte(in, e); elemType = (TType)e; - result += readU32(in, size); + result += readI32(in, sizei); + // TODO(mcslee): check for negative size + size = (uint32_t)sizei; return result; } @@ -249,27 +237,18 @@ uint32_t TBinaryProtocol::readBool(shared_ptr in, bool& value) const { uint8_t b[1]; in->readAll(b, 1); - value = *(uint8_t*)b != 0; + value = *(int8_t*)b != 0; return 1; } uint32_t TBinaryProtocol::readByte(shared_ptr in, - uint8_t& byte) const { + int8_t& byte) const { uint8_t b[1]; in->readAll(b, 1); - byte = *(uint8_t*)b; + byte = *(int8_t*)b; return 1; } -uint32_t TBinaryProtocol::readU16(shared_ptr in, - uint16_t& u16) const { - uint8_t b[2]; - in->readAll(b, 2); - u16 = *(uint16_t*)b; - u16 = (uint16_t)ntohs(u16); - return 2; -} - uint32_t TBinaryProtocol::readI16(shared_ptr in, int16_t& i16) const { uint8_t b[2]; @@ -279,15 +258,6 @@ uint32_t TBinaryProtocol::readI16(shared_ptr in, return 2; } -uint32_t TBinaryProtocol::readU32(shared_ptr in, - uint32_t& u32) const { - uint8_t b[4]; - in->readAll(b, 4); - u32 = *(uint32_t*)b; - u32 = (uint32_t)ntohl(u32); - return 4; -} - uint32_t TBinaryProtocol::readI32(shared_ptr in, int32_t& i32) const { uint8_t b[4]; @@ -297,15 +267,6 @@ uint32_t TBinaryProtocol::readI32(shared_ptr in, return 4; } -uint32_t TBinaryProtocol::readU64(shared_ptr in, - uint64_t& u64) const { - uint8_t b[8]; - in->readAll(b, 8); - u64 = *(uint64_t*)b; - u64 = (uint64_t)ntohll(u64); - return 8; -} - uint32_t TBinaryProtocol::readI64(shared_ptr in, int64_t& i64) const { uint8_t b[8]; @@ -318,8 +279,10 @@ uint32_t TBinaryProtocol::readI64(shared_ptr in, uint32_t TBinaryProtocol::readString(shared_ptr in, string& str) const { uint32_t result; - uint32_t size; - result = readU32(in, size); + int32_t size; + result = readI32(in, size); + + // TODO(mcslee): check for negative size // Use the heap here to prevent stack overflow for v. large strings uint8_t *b = new uint8_t[size]; @@ -329,4 +292,5 @@ uint32_t TBinaryProtocol::readString(shared_ptr in, return result + (uint32_t)size; } + }}} // facebook::thrift::protocol diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h index 7780f168..d66fa2fe 100644 --- a/lib/cpp/src/protocol/TBinaryProtocol.h +++ b/lib/cpp/src/protocol/TBinaryProtocol.h @@ -27,7 +27,7 @@ using namespace boost; virtual uint32_t writeMessageBegin(shared_ptr out, const std::string name, const TMessageType messageType, - const uint32_t seqid) const; + const int32_t seqid) const; virtual uint32_t writeMessageEnd(shared_ptr out) const; @@ -69,23 +69,14 @@ using namespace boost; const bool value) const; uint32_t writeByte(shared_ptr out, - const uint8_t byte) const; - - uint32_t writeU16(shared_ptr out, - const uint16_t u16) const; + const int8_t byte) const; uint32_t writeI16(shared_ptr out, const int16_t i16) const; - uint32_t writeU32(shared_ptr out, - const uint32_t u32) const; - uint32_t writeI32(shared_ptr out, const int32_t i32) const; - uint32_t writeU64(shared_ptr out, - const uint64_t u64) const; - uint32_t writeI64(shared_ptr out, const int64_t i64) const; @@ -100,7 +91,7 @@ using namespace boost; uint32_t readMessageBegin(shared_ptr in, std::string& name, TMessageType& messageType, - uint32_t& seqid) const; + int32_t& seqid) const; uint32_t readMessageEnd(shared_ptr in) const; @@ -139,23 +130,14 @@ using namespace boost; bool& value) const; uint32_t readByte(shared_ptr in, - uint8_t& byte) const; - - uint32_t readU16(shared_ptr in, - uint16_t& u16) const; + int8_t& byte) const; uint32_t readI16(shared_ptr in, int16_t& i16) const; - uint32_t readU32(shared_ptr in, - uint32_t& u32) const; - uint32_t readI32(shared_ptr in, int32_t& i32) const; - uint32_t readU64(shared_ptr in, - uint64_t& u64) const; - uint32_t readI64(shared_ptr in, int64_t& i64) const; diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h index 092dd8d5..2b3666fa 100644 --- a/lib/cpp/src/protocol/TProtocol.h +++ b/lib/cpp/src/protocol/TProtocol.h @@ -33,11 +33,8 @@ enum TType { T_VOID = 1, T_BOOL = 2, T_BYTE = 3, - T_U08 = 3, - T_I08 = 4, - T_U16 = 5, + T_I08 = 3, T_I16 = 6, - T_U32 = 7, T_I32 = 8, T_U64 = 9, T_I64 = 10, @@ -82,7 +79,7 @@ class TProtocol { virtual uint32_t writeMessageBegin(shared_ptr out, const std::string name, const TMessageType messageType, - const uint32_t seqid) const = 0; + const int32_t seqid) const = 0; virtual uint32_t writeMessageEnd(shared_ptr out) const = 0; @@ -124,23 +121,14 @@ class TProtocol { const bool value) const = 0; virtual uint32_t writeByte(shared_ptr out, - const uint8_t byte) const = 0; + const int8_t byte) const = 0; virtual uint32_t writeI16(shared_ptr out, const int16_t i16) const = 0; - virtual uint32_t writeU16(shared_ptr out, - const uint16_t u16) const = 0; - - virtual uint32_t writeU32(shared_ptr out, - const uint32_t u32) const = 0; - virtual uint32_t writeI32(shared_ptr out, const int32_t i32) const = 0; - virtual uint32_t writeU64(shared_ptr out, - const uint64_t u64) const = 0; - virtual uint32_t writeI64(shared_ptr out, const int64_t i64) const = 0; @@ -154,7 +142,7 @@ class TProtocol { virtual uint32_t readMessageBegin(shared_ptr in, std::string& name, TMessageType& messageType, - uint32_t& seqid) const = 0; + int32_t& seqid) const = 0; virtual uint32_t readMessageEnd(shared_ptr in) const = 0; @@ -193,23 +181,14 @@ class TProtocol { bool& value) const = 0; virtual uint32_t readByte(shared_ptr in, - uint8_t& byte) const = 0; - - virtual uint32_t readU16(shared_ptr in, - uint16_t& u16) const = 0; + int8_t& byte) const = 0; virtual uint32_t readI16(shared_ptr in, int16_t& i16) const = 0; - virtual uint32_t readU32(shared_ptr in, - uint32_t& u32) const = 0; - virtual uint32_t readI32(shared_ptr in, int32_t& i32) const = 0; - virtual uint32_t readU64(shared_ptr in, - uint64_t& u64) const = 0; - virtual uint32_t readI64(shared_ptr in, int64_t& i64) const = 0; @@ -223,24 +202,19 @@ class TProtocol { switch (type) { case T_BYTE: { - uint8_t byte; + int8_t byte; return readByte(in, byte); } - case T_U32: + case T_I16: { - uint32_t u32; - return readU32(in, u32); + int16_t i16; + return readI16(in, i16); } case T_I32: { int32_t i32; return readI32(in, i32); } - case T_U64: - { - uint64_t u64; - return readU64(in, u64); - } case T_I64: { int64_t i64; diff --git a/lib/php/src/Thrift.php b/lib/php/src/Thrift.php index 1e8f3fb6..ee480920 100644 --- a/lib/php/src/Thrift.php +++ b/lib/php/src/Thrift.php @@ -1,5 +1,9 @@ diff --git a/lib/php/src/protocol/TBinaryProtocol.php b/lib/php/src/protocol/TBinaryProtocol.php index 0d2349e7..4bb02977 100644 --- a/lib/php/src/protocol/TBinaryProtocol.php +++ b/lib/php/src/protocol/TBinaryProtocol.php @@ -1,7 +1,7 @@ writeString($out, $name) + - $this->writeByte($out, $type) + - $this->writeU32($out, $seqid); + return + $this->writeString($out, $name) + + $this->writeByte($out, $type) + + $this->writeI32($out, $seqid); } public function writeMessageEnd($out) { @@ -88,12 +88,6 @@ class TBinaryProtocol extends TProtocol { return 1; } - public function writeI08($out, $value) { - $data = pack('c', $value); - $out->write($data, 1); - return 1; - } - public function writeI16($out, $value) { $data = pack('n', $value); $out->write($data, 2); @@ -107,25 +101,23 @@ class TBinaryProtocol extends TProtocol { } public function writeI64($out, $value) { - - /* If we are on a 32bit architecture we have to explicitly deal with 64-bit twos-complement arithmetic - since PHP wants to treat all ints as signed and any int over 2^31 - 1 as a float */ - - if(PHP_INT_SIZE == 4) { - + // If we are on a 32bit architecture we have to explicitly deal with + // 64-bit twos-complement arithmetic since PHP wants to treat all ints + // as signed and any int over 2^31 - 1 as a float + if (PHP_INT_SIZE == 4) { $neg = $value < 0; - - if($neg) { - $value*= -1; + + if ($neg) { + $value *= -1; } - + $hi = (int)($value / 4294967296); $lo = (int)$value; - if($neg) { + if ($neg) { $hi = ~$hi; $lo = ~$lo; - if(($lo & (int)0xffffffff) == (int)0xffffffff) { + if (($lo & (int)0xffffffff) == (int)0xffffffff) { $lo = 0; $hi++; } else { @@ -144,56 +136,18 @@ class TBinaryProtocol extends TProtocol { return 8; } - public function writeU08($out, $value) { - $data = pack('c', $value); - $out->write($data, 1); - return 1; - } - - public function writeU16($out, $value) { - $data = pack('n', $value); - $out->write($data, 2); - return 2; - } - - public function writeU32($out, $value) { - $data = pack('N', $value); - $out->write($data, 4); - return 4; - } - - public function writeU64($out, $value) { - - /* If we are on a 32bit architecture we have to explicitly deal with 64-bit twos-complement arithmetic - since PHP wants to treat all ints as signed and any int over 2^31 - 1 as a float */ - - if(PHP_INT_SIZE == 4) { - - $hi = (int)($value / 4294967296); - $lo = (int)$value; - $data = pack('N2', $hi, $lo); - - } else { - $hi = $value >> 32; - $lo = $value & 0xFFFFFFFF; - $data = pack('N2', $hi, $lo); - } - - $out->write($data, 8); - return 8; - } - public function writeString($out, $value) { $len = strlen($value); - $result = $this->writeU32($out, $len); + $result = $this->writeI32($out, $len); $out->write($value, $len); return $result + $len; } public function readMessageBegin($in, &$name, &$type, &$seqid) { - $result = $this->readString($in, $name); - $result+= $this->readByte($in, $type); - $result+= $this->readU32($in, $seqid); + return + $this->readString($in, $name) + + $this->readByte($in, $type) + + $this->readI32($in, $seqid); } public function readMessageEnd($out) { @@ -224,10 +178,10 @@ class TBinaryProtocol extends TProtocol { } public function readMapBegin($in, &$keyType, &$valType, &$size) { - $result = $this->readByte($in, $keyType); - $result += $this->readByte($in, $valType); - $result += $this->readI32($in, $size); - return $result; + return + $this->readByte($in, $keyType) + + $this->readByte($in, $valType) + + $this->readI32($in, $size); } public function readMapEnd($in) { @@ -235,9 +189,9 @@ class TBinaryProtocol extends TProtocol { } public function readListBegin($in, &$elemType, &$size) { - $result = $this->readByte($in, $elemType); - $result += $this->readI32($in, $size); - return $result; + return + $this->readByte($in, $elemType) + + $this->readI32($in, $size); } public function readListEnd($in) { @@ -245,9 +199,9 @@ class TBinaryProtocol extends TProtocol { } public function readSetBegin($in, &$elemType, &$size) { - $result = $this->readByte($in, $elemType); - $result += $this->readI32($in, $size); - return $result; + return + $this->readByte($in, $elemType) + + $this->readI32($in, $size); } public function readSetEnd($in) { @@ -268,19 +222,12 @@ class TBinaryProtocol extends TProtocol { return 1; } - public function readI08($in, &$value) { - $data = $in->readAll(1); - $arr = unpack('c', $data); - $value = $arr[1]; - return 1; - } - public function readI16($in, &$value) { $data = $in->readAll(2); $arr = unpack('n', $data); $value = $arr[1]; - if($value > 0x7fff) { - $value = 0 - (($value - 1) ^ 0xffff); + if ($value > 0x7fff) { + $value = 0 - (($value - 1) ^ 0xffff); } return 2; } @@ -289,33 +236,32 @@ class TBinaryProtocol extends TProtocol { $data = $in->readAll(4); $arr = unpack('N', $data); $value = $arr[1]; - if($value > 0x7fffffff) { + if ($value > 0x7fffffff) { $value = 0 - (($value - 1) ^ 0xffffffff); } return 4; } public function readI64($in, &$value) { - $data = $in->readAll(8); $arr = unpack('N2', $data); - /* If we are on a 32bit architecture we have to explicitly deal with 64-bit twos-complement arithmetic - since PHP wants to treat all ints as signed and any int over 2^31 - 1 as a float */ - - if(PHP_INT_SIZE == 4) { + // If we are on a 32bit architecture we have to explicitly deal with + // 64-bit twos-complement arithmetic since PHP wants to treat all ints + // as signed and any int over 2^31 - 1 as a float + if (PHP_INT_SIZE == 4) { $hi = $arr[1]; $lo = $arr[2]; $isNeg = $hi < 0; // Check for a negative - if($isNeg) { + if ($isNeg) { $hi = ~$hi & (int)0xffffffff; $lo = ~$lo & (int)0xffffffff; - if($lo == (int)0xffffffff) { + if ($lo == (int)0xffffffff) { $hi++; $lo = 0; } else { @@ -323,22 +269,22 @@ class TBinaryProtocol extends TProtocol { } } - /* Force 32bit words in excess of 2G to pe positive - we deal wigh sign - explicitly below */ + // Force 32bit words in excess of 2G to pe positive - we deal wigh sign + // explicitly below - if($hi & (int)0x80000000) { - $hi&= (int)0x7fffffff; + if ($hi & (int)0x80000000) { + $hi &= (int)0x7fffffff; $hi += 0x80000000; } - if($lo & (int)0x80000000) { - $lo&= (int)0x7fffffff; + if ($lo & (int)0x80000000) { + $lo &= (int)0x7fffffff; $lo += 0x80000000; } $value = $hi * 4294967296 + $lo; - if($isNeg) { + if ($isNeg) { $value = 0 - $value; } } else { @@ -356,62 +302,8 @@ class TBinaryProtocol extends TProtocol { return 8; } - public function readU08($in, &$value) { - $data = $in->readAll(1); - $arr = unpack('c', $data); - $value = $arr[1]; - return 1; - } - - public function readU16($in, &$value) { - $data = $in->readAll(2); - $arr = unpack('n', $data); - $value = $arr[1]; - return 2; - } - - public function readU32($in, &$value) { - $data = $in->readAll(4); - $arr = unpack('N', $data); - $value = $arr[1]; - return 4; - } - - public function readU64($in, &$value) { - $data = $in->readAll(8); - $arr = unpack('N2', $data); - - /* If we are on a 32bit architecture we have to explicitly deal with 64-bit twos-complement arithmetic - since PHP wants to treat all ints as signed and any int over 2^31 - 1 as a float */ - - if(PHP_INT_SIZE == 4) { - - $hi = $arr[1]; - $lo = $arr[2]; - - /* Prevent implicit integer sign extension */ - - if($hi & (int)0x80000000) { - $hi&= (int)0x7fffffff; - $hi += 0x80000000; - } - - if($lo & (int)0x80000000) { - $lo&= (int)0x7fffffff; - $lo += 0x80000000; - } - - $value = $hi * 4294967296 + $lo; - - } else { - - $value = $arr[1]*4294967296 + $arr[2]; - } - return 8; - } - public function readString($in, &$value) { - $result = $this->readU32($in, $len); + $result = $this->readI32($in, $len); $value = $in->readAll($len); return $result + $len; } diff --git a/lib/php/src/protocol/TProtocol.php b/lib/php/src/protocol/TProtocol.php index a3596ab8..15938dfb 100644 --- a/lib/php/src/protocol/TProtocol.php +++ b/lib/php/src/protocol/TProtocol.php @@ -1,7 +1,10 @@ readByte($in, $byte); + case TType::I16; + return $this->readI16($in, $i16); case TType::I32: return $this->readI32($in, $i32); case TType::I64: diff --git a/lib/php/src/protocol/TType.php b/lib/php/src/protocol/TType.php index e9576f97..22c1c3d1 100644 --- a/lib/php/src/protocol/TType.php +++ b/lib/php/src/protocol/TType.php @@ -6,30 +6,35 @@ * @package thrift.protocol * @author Mark Slee */ + +/** + * Data types that can be sent via Thrift + */ class TType { const STOP = 0; const VOID = 1; const BOOL = 2; const BYTE = 3; - const U08 = 3; const I08 = 4; - const U16 = 5; const I16 = 6; - const U32 = 7; const I32 = 8; - const U64 = 9; const I64 = 10; const STRING = 11; const UTF7 = 11; const STRUCT = 12; const MAP = 13; const SET = 14; - const LST = 15; // cannot use LIST keyword in PHP! + const LST = 15; // N.B. cannot use LIST keyword in PHP! const UTF8 = 16; const UTF16 = 17; } +/** + * Message types for RPC + */ class TMessageType { - const CALL = 1; - const REPLY = 2; + const CALL = 1; + const REPLY = 2; } + +?> -- 2.17.1