Skip to content
Snippets Groups Projects
Commit fe921bc6 authored by Jens Nolte's avatar Jens Nolte
Browse files

Add showArgument

parent eeab2bb1
No related branches found
No related tags found
No related merge requests found
...@@ -92,56 +92,67 @@ class (Eq (Argument a), Show (Argument a)) => WireFormat a where ...@@ -92,56 +92,67 @@ class (Eq (Argument a), Show (Argument a)) => WireFormat a where
type Argument a type Argument a
putArgument :: Argument a -> PutM () putArgument :: Argument a -> PutM ()
getArgument :: Get (Argument a) getArgument :: Get (Argument a)
showArgument :: Argument a -> String
instance WireFormat 'IntArgument where instance WireFormat 'IntArgument where
type Argument 'IntArgument = Int32 type Argument 'IntArgument = Int32
putArgument = putInt32host putArgument = putInt32host
getArgument = getInt32host getArgument = getInt32host
showArgument = show
instance WireFormat 'UIntArgument where instance WireFormat 'UIntArgument where
type Argument 'UIntArgument = Word32 type Argument 'UIntArgument = Word32
putArgument = putWord32host putArgument = putWord32host
getArgument = getWord32host getArgument = getWord32host
showArgument = show
instance WireFormat 'FixedArgument where instance WireFormat 'FixedArgument where
type Argument 'FixedArgument = Fixed type Argument 'FixedArgument = Fixed
putArgument (Fixed repr) = putWord32host repr putArgument (Fixed repr) = putWord32host repr
getArgument = Fixed <$> getWord32host getArgument = Fixed <$> getWord32host
showArgument = show
instance WireFormat 'StringArgument where instance WireFormat 'StringArgument where
type Argument 'StringArgument = BS.ByteString type Argument 'StringArgument = BS.ByteString
putArgument = putWaylandBlob putArgument = putWaylandBlob
getArgument = getWaylandBlob getArgument = getWaylandBlob
showArgument = show
instance WireFormat 'ArrayArgument where instance WireFormat 'ArrayArgument where
type Argument 'ArrayArgument = BS.ByteString type Argument 'ArrayArgument = BS.ByteString
putArgument = putWaylandBlob putArgument = putWaylandBlob
getArgument = getWaylandBlob getArgument = getWaylandBlob
showArgument array = "[array " <> show (BS.length array) <> "B]"
instance WireFormat 'ObjectArgument where instance WireFormat 'ObjectArgument where
type Argument 'ObjectArgument = ObjectId type Argument 'ObjectArgument = ObjectId
putArgument = putWord32host putArgument = putWord32host
getArgument = getWord32host getArgument = getWord32host
showArgument oId = "@" <> show oId
instance WireFormat 'UnknownObjectArgument where instance WireFormat 'UnknownObjectArgument where
type Argument 'UnknownObjectArgument = ObjectId type Argument 'UnknownObjectArgument = ObjectId
putArgument = putWord32host putArgument = putWord32host
getArgument = getWord32host getArgument = getWord32host
showArgument oId = "@" <> show oId
instance WireFormat 'NewIdArgument where instance WireFormat 'NewIdArgument where
type Argument 'NewIdArgument = NewId type Argument 'NewIdArgument = NewId
putArgument (NewId newId) = putWord32host newId putArgument (NewId newId) = putWord32host newId
getArgument = NewId <$> getWord32host getArgument = NewId <$> getWord32host
showArgument newId = "new @" <> show newId
instance WireFormat 'UnknownNewIdArgument where instance WireFormat 'UnknownNewIdArgument where
type Argument 'UnknownNewIdArgument = NewId type Argument 'UnknownNewIdArgument = NewId
putArgument (NewId newId) = putWord32host newId putArgument (NewId newId) = putWord32host newId
getArgument = NewId <$> getWord32host getArgument = NewId <$> getWord32host
showArgument newId = "new @" <> show newId
instance WireFormat 'FdArgument where instance WireFormat 'FdArgument where
type Argument 'FdArgument = Void type Argument 'FdArgument = Void
putArgument = undefined putArgument = undefined
getArgument = undefined getArgument = undefined
showArgument = undefined
-- | A wayland interface -- | A wayland interface
...@@ -269,7 +280,6 @@ putDynamicArgument (DynamicNewIdArgument x) = putWord32host x ...@@ -269,7 +280,6 @@ putDynamicArgument (DynamicNewIdArgument x) = putWord32host x
putDynamicArgument _ = undefined putDynamicArgument _ = undefined
type ClientProtocolState m = ProtocolState 'Client m type ClientProtocolState m = ProtocolState 'Client m
type ServerProtocolState m = ProtocolState 'Server m type ServerProtocolState m = ProtocolState 'Server m
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment