-------------------------------------------------------------------------------- -- | -- Module : Sound.ALSA.Sequencer.Marshal -- Copyright : (c) Henning Thielemann, 2010 -- (c) Iavor S. Diatchki, 2007 -- License : BSD3 -- -- Maintainer: Henning Thielemann -- Stability : provisional -- -- PRIVATE MODULE. -- -- Here we have the various types used by the library, -- and how they are imported\/exported to C. -- -- NOTE: In the translations bellow we make the following assumptions -- about the sizes of C types. -- CChar = 8 bits -- CShort = 16 bit -- CInt = 32 bits -------------------------------------------------------------------------------- module Sound.ALSA.Sequencer.Marshal.Client where #include import qualified Sound.ALSA.Sequencer.Utility as U import Foreign.C.Types (CInt, ) import Foreign.Storable (Storable, ) import Data.Word (Word8, ) -- | The type of client identifiers. newtype T = Cons Word8 deriving (Eq, Ord, Storable) instance Show T where showsPrec prec (Cons x) = U.showsRecord prec "Client" [U.showsField x] #{enum T, Cons , system = SND_SEQ_CLIENT_SYSTEM , subscribers = SND_SEQ_ADDRESS_SUBSCRIBERS , broadcast = SND_SEQ_ADDRESS_BROADCAST , unknown = SND_SEQ_ADDRESS_UNKNOWN } exp :: T -> CInt exp (Cons c) = fromIntegral c imp :: CInt -> T imp p = Cons (fromIntegral p) -- | The different types of clients. data Type = User | Kernel impType :: CInt -> Type impType x = if x == #{const SND_SEQ_USER_CLIENT} then User else Kernel