THRIFT-2704 - compiler: T_ONEWAY type used for oneway methods instead of T_CALL

Patch: Konrad Grochowski

This closes #216
diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.cpp b/lib/cpp/src/thrift/processor/PeekProcessor.cpp
index bfc4ac7..9303a13 100644
--- a/lib/cpp/src/thrift/processor/PeekProcessor.cpp
+++ b/lib/cpp/src/thrift/processor/PeekProcessor.cpp
@@ -66,7 +66,7 @@
   int32_t seqid;
   in->readMessageBegin(fname, mtype, seqid);
 
-  if (mtype != T_CALL) {
+  if (mtype != T_CALL && mtype != T_ONEWAY) {
     throw TException("Unexpected message type");
   }
 
diff --git a/lib/cpp/src/thrift/processor/StatsProcessor.h b/lib/cpp/src/thrift/processor/StatsProcessor.h
index 58cd1dc..0fc123e 100644
--- a/lib/cpp/src/thrift/processor/StatsProcessor.h
+++ b/lib/cpp/src/thrift/processor/StatsProcessor.h
@@ -50,7 +50,7 @@
     int32_t seqid;
 
     piprot_->readMessageBegin(fname, mtype, seqid);
-    if (mtype != apache::thrift::protocol::T_CALL) {
+    if (mtype != apache::thrift::protocol::T_CALL && mtype != apache::thrift::protocol::T_ONEWAY) {
       if (print_) {
         printf("Unknown message type\n");
       }
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
index d6da745..ce60b45 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
@@ -39,6 +39,7 @@
   static const int8_t  VERSION_N = 1;
   static const int8_t  VERSION_MASK = 0x1f; // 0001 1111
   static const int8_t  TYPE_MASK = (int8_t)0xE0u; // 1110 0000
+  static const int8_t  TYPE_BITS = 0x07; // 0000 0111
   static const int32_t TYPE_SHIFT_AMOUNT = 5;
 
   Transport_* trans_;
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
index a0955fc..85dde6c 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
@@ -433,7 +433,7 @@
     throw TProtocolException(TProtocolException::BAD_VERSION, "Bad protocol version");
   }
 
-  messageType = (TMessageType)((versionAndType >> TYPE_SHIFT_AMOUNT) & 0x03);
+  messageType = (TMessageType)((versionAndType >> TYPE_SHIFT_AMOUNT) & TYPE_BITS);
   rsize += readVarint32(seqid);
   rsize += readString(name);
 
diff --git a/lib/cpp/test/AllProtocolTests.tcc b/lib/cpp/test/AllProtocolTests.tcc
index 7ccaef5..3c98943 100644
--- a/lib/cpp/test/AllProtocolTests.tcc
+++ b/lib/cpp/test/AllProtocolTests.tcc
@@ -97,14 +97,16 @@
     const char* name;
     TMessageType type;
     int32_t seqid;
-  } messages[4] = {
+  } messages[] = {
     {"short message name", T_CALL, 0},
     {"1", T_REPLY, 12345},
     {"loooooooooooooooooooooooooooooooooong", T_EXCEPTION, 1 << 16},
+    {"one way push", T_ONEWAY, 12},
     {"Janky", T_CALL, 0}
   };
+  const int messages_count = sizeof(messages) / sizeof(TMessage);
 
-  for (int i = 0; i < 4; i++) {
+  for (int i = 0; i < messages_count; i++) {
     shared_ptr<TTransport> transport(new TMemoryBuffer());
     shared_ptr<TProtocol> protocol(new TProto(transport));