gi-glib-0.2.46.13: GI/GLib/Structs/PollFD.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
Represents a file descriptor, which events to poll for, and which events
occurred.
-}
module GI.GLib.Structs.PollFD
(
-- * Exported types
PollFD(..) ,
newZeroPollFD ,
noPollFD ,
-- * Properties
-- ** Events
pollFDReadEvents ,
-- ** Fd
pollFDReadFd ,
-- ** Revents
pollFDReadRevents ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.GLib.Types
import GI.GLib.Callbacks
newtype PollFD = PollFD (ForeignPtr PollFD)
foreign import ccall "g_pollfd_get_type" c_g_pollfd_get_type ::
IO GType
instance BoxedObject PollFD where
boxedType _ = c_g_pollfd_get_type
-- | Construct a `PollFD` struct initialized to zero.
newZeroPollFD :: MonadIO m => m PollFD
newZeroPollFD = liftIO $ callocBoxedBytes 8 >>= wrapBoxed PollFD
noPollFD :: Maybe PollFD
noPollFD = Nothing
pollFDReadFd :: PollFD -> IO Int32
pollFDReadFd s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Int32
return val
pollFDReadEvents :: PollFD -> IO Word16
pollFDReadEvents s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Word16
return val
pollFDReadRevents :: PollFD -> IO Word16
pollFDReadRevents s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 6) :: IO Word16
return val
type family ResolvePollFDMethod (t :: Symbol) (o :: *) :: * where
ResolvePollFDMethod l o = MethodResolutionFailed l o
instance (info ~ ResolvePollFDMethod t PollFD, MethodInfo info PollFD p) => IsLabelProxy t (PollFD -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePollFDMethod t PollFD, MethodInfo info PollFD p) => IsLabel t (PollFD -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif