#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.GLib.Structs.PollFD
(
PollFD(..) ,
newZeroPollFD ,
noPollFD ,
getPollFDEvents ,
#if ENABLE_OVERLOADING
pollFD_events ,
#endif
setPollFDEvents ,
getPollFDFd ,
#if ENABLE_OVERLOADING
pollFD_fd ,
#endif
setPollFDFd ,
getPollFDRevents ,
#if ENABLE_OVERLOADING
pollFD_revents ,
#endif
setPollFDRevents ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
newtype PollFD = PollFD (ManagedPtr 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
newZeroPollFD :: MonadIO m => m PollFD
newZeroPollFD = liftIO $ callocBoxedBytes 8 >>= wrapBoxed PollFD
instance tag ~ 'AttrSet => Constructible PollFD tag where
new _ attrs = do
o <- newZeroPollFD
GI.Attributes.set o attrs
return o
noPollFD :: Maybe PollFD
noPollFD = Nothing
getPollFDFd :: MonadIO m => PollFD -> m Int32
getPollFDFd s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Int32
return val
setPollFDFd :: MonadIO m => PollFD -> Int32 -> m ()
setPollFDFd s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: Int32)
#if ENABLE_OVERLOADING
data PollFDFdFieldInfo
instance AttrInfo PollFDFdFieldInfo where
type AttrAllowedOps PollFDFdFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PollFDFdFieldInfo = (~) Int32
type AttrBaseTypeConstraint PollFDFdFieldInfo = (~) PollFD
type AttrGetType PollFDFdFieldInfo = Int32
type AttrLabel PollFDFdFieldInfo = "fd"
type AttrOrigin PollFDFdFieldInfo = PollFD
attrGet _ = getPollFDFd
attrSet _ = setPollFDFd
attrConstruct = undefined
attrClear _ = undefined
pollFD_fd :: AttrLabelProxy "fd"
pollFD_fd = AttrLabelProxy
#endif
getPollFDEvents :: MonadIO m => PollFD -> m Word16
getPollFDEvents s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Word16
return val
setPollFDEvents :: MonadIO m => PollFD -> Word16 -> m ()
setPollFDEvents s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 4) (val :: Word16)
#if ENABLE_OVERLOADING
data PollFDEventsFieldInfo
instance AttrInfo PollFDEventsFieldInfo where
type AttrAllowedOps PollFDEventsFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PollFDEventsFieldInfo = (~) Word16
type AttrBaseTypeConstraint PollFDEventsFieldInfo = (~) PollFD
type AttrGetType PollFDEventsFieldInfo = Word16
type AttrLabel PollFDEventsFieldInfo = "events"
type AttrOrigin PollFDEventsFieldInfo = PollFD
attrGet _ = getPollFDEvents
attrSet _ = setPollFDEvents
attrConstruct = undefined
attrClear _ = undefined
pollFD_events :: AttrLabelProxy "events"
pollFD_events = AttrLabelProxy
#endif
getPollFDRevents :: MonadIO m => PollFD -> m Word16
getPollFDRevents s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 6) :: IO Word16
return val
setPollFDRevents :: MonadIO m => PollFD -> Word16 -> m ()
setPollFDRevents s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 6) (val :: Word16)
#if ENABLE_OVERLOADING
data PollFDReventsFieldInfo
instance AttrInfo PollFDReventsFieldInfo where
type AttrAllowedOps PollFDReventsFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PollFDReventsFieldInfo = (~) Word16
type AttrBaseTypeConstraint PollFDReventsFieldInfo = (~) PollFD
type AttrGetType PollFDReventsFieldInfo = Word16
type AttrLabel PollFDReventsFieldInfo = "revents"
type AttrOrigin PollFDReventsFieldInfo = PollFD
attrGet _ = getPollFDRevents
attrSet _ = setPollFDRevents
attrConstruct = undefined
attrClear _ = undefined
pollFD_revents :: AttrLabelProxy "revents"
pollFD_revents = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList PollFD
type instance O.AttributeList PollFD = PollFDAttributeList
type PollFDAttributeList = ('[ '("fd", PollFDFdFieldInfo), '("events", PollFDEventsFieldInfo), '("revents", PollFDReventsFieldInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
type family ResolvePollFDMethod (t :: Symbol) (o :: *) :: * where
ResolvePollFDMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePollFDMethod t PollFD, O.MethodInfo info PollFD p) => OL.IsLabel t (PollFD -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif