THRIFT-2704 - compiler: T_ONEWAY type used for oneway methods instead of T_CALL
Patch: Konrad Grochowski
This closes #216
diff --git a/lib/hs/src/Thrift/Protocol/Compact.hs b/lib/hs/src/Thrift/Protocol/Compact.hs
index c3bd22d..a329f4e 100644
--- a/lib/hs/src/Thrift/Protocol/Compact.hs
+++ b/lib/hs/src/Thrift/Protocol/Compact.hs
@@ -60,6 +60,7 @@
version = 0x01
versionMask = 0x1f -- 0001 1111
typeMask = 0xe0 -- 1110 0000
+typeBits = 0x07 -- 0000 0111
typeShiftAmount :: Int
typeShiftAmount = 5
@@ -81,7 +82,7 @@
w <- fromIntegral <$> P.anyWord8
let ver = w .&. versionMask
when (ver /= version) $ error "Bad Protocol version"
- let typ = (w `shiftR` typeShiftAmount) .&. 0x03
+ let typ = (w `shiftR` typeShiftAmount) .&. typeBits
seqId <- parseVarint zigZagToI32
TString name <- parseCompactValue T_STRING
return (decodeUtf8 name, toEnum $ fromIntegral $ typ, seqId)
diff --git a/lib/hs/src/Thrift/Types.hs b/lib/hs/src/Thrift/Types.hs
index b014ac6..b90c42c 100644
--- a/lib/hs/src/Thrift/Types.hs
+++ b/lib/hs/src/Thrift/Types.hs
@@ -113,17 +113,20 @@
= M_CALL
| M_REPLY
| M_EXCEPTION
+ | M_ONEWAY
deriving ( Eq, Show )
instance Enum MessageType where
fromEnum M_CALL = 1
fromEnum M_REPLY = 2
fromEnum M_EXCEPTION = 3
+ fromEnum M_ONEWAY = 4
toEnum 1 = M_CALL
toEnum 2 = M_REPLY
toEnum 3 = M_EXCEPTION
+ toEnum 4 = M_ONEWAY
toEnum t = error $ "Invalid MessageType " ++ show t
instance Arbitrary MessageType where
- arbitrary = elements [M_CALL, M_REPLY, M_EXCEPTION]
+ arbitrary = elements [M_CALL, M_REPLY, M_EXCEPTION, M_ONEWAY]