{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Wp.Structs.IteratorMethods
    ( 

-- * Exported types
    IteratorMethods(..)                     ,
    newZeroIteratorMethods                  ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveIteratorMethodsMethod            ,
#endif



 -- * Properties


-- ** finalize #attr:finalize#
-- | /No description available in the introspection data./

    clearIteratorMethodsFinalize            ,
    getIteratorMethodsFinalize              ,
#if defined(ENABLE_OVERLOADING)
    iteratorMethods_finalize                ,
#endif
    setIteratorMethodsFinalize              ,


-- ** next #attr:next#
-- | /No description available in the introspection data./

    clearIteratorMethodsNext                ,
    getIteratorMethodsNext                  ,
#if defined(ENABLE_OVERLOADING)
    iteratorMethods_next                    ,
#endif
    setIteratorMethodsNext                  ,


-- ** reset #attr:reset#
-- | /No description available in the introspection data./

    clearIteratorMethodsReset               ,
    getIteratorMethodsReset                 ,
#if defined(ENABLE_OVERLOADING)
    iteratorMethods_reset                   ,
#endif
    setIteratorMethodsReset                 ,


-- ** version #attr:version#
-- | /No description available in the introspection data./

    getIteratorMethodsVersion               ,
#if defined(ENABLE_OVERLOADING)
    iteratorMethods_version                 ,
#endif
    setIteratorMethodsVersion               ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.Wp.Callbacks as Wp.Callbacks

#else
import qualified GI.Wp.Callbacks as Wp.Callbacks

#endif

-- | Memory-managed wrapper type.
newtype IteratorMethods = IteratorMethods (SP.ManagedPtr IteratorMethods)
    deriving (Eq)

instance SP.ManagedPtrNewtype IteratorMethods where
    toManagedPtr (IteratorMethods p) = p

instance BoxedPtr IteratorMethods where
    boxedPtrCopy = \p -> B.ManagedPtr.withManagedPtr p (copyBytes 48 >=> B.ManagedPtr.wrapPtr IteratorMethods)
    boxedPtrFree = \x -> SP.withManagedPtr x SP.freeMem
instance CallocPtr IteratorMethods where
    boxedPtrCalloc = callocBytes 48


-- | Construct a t'IteratorMethods' struct initialized to zero.
newZeroIteratorMethods :: MonadIO m => m IteratorMethods
newZeroIteratorMethods = liftIO $ boxedPtrCalloc >>= wrapPtr IteratorMethods

instance tag ~ 'AttrSet => Constructible IteratorMethods tag where
    new _ attrs = do
        o <- newZeroIteratorMethods
        GI.Attributes.set o attrs
        return o


-- | Get the value of the “@version@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' iteratorMethods #version
-- @
getIteratorMethodsVersion :: MonadIO m => IteratorMethods -> m Word32
getIteratorMethodsVersion s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Word32
    return val

-- | Set the value of the “@version@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' iteratorMethods [ #version 'Data.GI.Base.Attributes.:=' value ]
-- @
setIteratorMethodsVersion :: MonadIO m => IteratorMethods -> Word32 -> m ()
setIteratorMethodsVersion s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Word32)

#if defined(ENABLE_OVERLOADING)
data IteratorMethodsVersionFieldInfo
instance AttrInfo IteratorMethodsVersionFieldInfo where
    type AttrBaseTypeConstraint IteratorMethodsVersionFieldInfo = (~) IteratorMethods
    type AttrAllowedOps IteratorMethodsVersionFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint IteratorMethodsVersionFieldInfo = (~) Word32
    type AttrTransferTypeConstraint IteratorMethodsVersionFieldInfo = (~)Word32
    type AttrTransferType IteratorMethodsVersionFieldInfo = Word32
    type AttrGetType IteratorMethodsVersionFieldInfo = Word32
    type AttrLabel IteratorMethodsVersionFieldInfo = "version"
    type AttrOrigin IteratorMethodsVersionFieldInfo = IteratorMethods
    attrGet = getIteratorMethodsVersion
    attrSet = setIteratorMethodsVersion
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.IteratorMethods.version"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-IteratorMethods.html#g:attr:version"
        })

iteratorMethods_version :: AttrLabelProxy "version"
iteratorMethods_version = AttrLabelProxy

#endif


-- | Get the value of the “@reset@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' iteratorMethods #reset
-- @
getIteratorMethodsReset :: MonadIO m => IteratorMethods -> m (Maybe Wp.Callbacks.IteratorMethodsResetFieldCallback)
getIteratorMethodsReset s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO (FunPtr Wp.Callbacks.C_IteratorMethodsResetFieldCallback)
    result <- SP.convertFunPtrIfNonNull val $ \val' -> do
        let val'' = Wp.Callbacks.dynamic_IteratorMethodsResetFieldCallback val'
        return val''
    return result

-- | Set the value of the “@reset@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' iteratorMethods [ #reset 'Data.GI.Base.Attributes.:=' value ]
-- @
setIteratorMethodsReset :: MonadIO m => IteratorMethods -> FunPtr Wp.Callbacks.C_IteratorMethodsResetFieldCallback -> m ()
setIteratorMethodsReset s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: FunPtr Wp.Callbacks.C_IteratorMethodsResetFieldCallback)

-- | Set the value of the “@reset@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #reset
-- @
clearIteratorMethodsReset :: MonadIO m => IteratorMethods -> m ()
clearIteratorMethodsReset s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (FP.nullFunPtr :: FunPtr Wp.Callbacks.C_IteratorMethodsResetFieldCallback)

#if defined(ENABLE_OVERLOADING)
data IteratorMethodsResetFieldInfo
instance AttrInfo IteratorMethodsResetFieldInfo where
    type AttrBaseTypeConstraint IteratorMethodsResetFieldInfo = (~) IteratorMethods
    type AttrAllowedOps IteratorMethodsResetFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint IteratorMethodsResetFieldInfo = (~) (FunPtr Wp.Callbacks.C_IteratorMethodsResetFieldCallback)
    type AttrTransferTypeConstraint IteratorMethodsResetFieldInfo = (~)Wp.Callbacks.IteratorMethodsResetFieldCallback
    type AttrTransferType IteratorMethodsResetFieldInfo = (FunPtr Wp.Callbacks.C_IteratorMethodsResetFieldCallback)
    type AttrGetType IteratorMethodsResetFieldInfo = Maybe Wp.Callbacks.IteratorMethodsResetFieldCallback
    type AttrLabel IteratorMethodsResetFieldInfo = "reset"
    type AttrOrigin IteratorMethodsResetFieldInfo = IteratorMethods
    attrGet = getIteratorMethodsReset
    attrSet = setIteratorMethodsReset
    attrConstruct = undefined
    attrClear = clearIteratorMethodsReset
    attrTransfer _ v = do
        Wp.Callbacks.mk_IteratorMethodsResetFieldCallback (Wp.Callbacks.wrap_IteratorMethodsResetFieldCallback Nothing v)
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.IteratorMethods.reset"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-IteratorMethods.html#g:attr:reset"
        })

iteratorMethods_reset :: AttrLabelProxy "reset"
iteratorMethods_reset = AttrLabelProxy

#endif


-- | Get the value of the “@next@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' iteratorMethods #next
-- @
getIteratorMethodsNext :: MonadIO m => IteratorMethods -> m (Maybe Wp.Callbacks.IteratorMethodsNextFieldCallback)
getIteratorMethodsNext s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (FunPtr Wp.Callbacks.C_IteratorMethodsNextFieldCallback)
    result <- SP.convertFunPtrIfNonNull val $ \val' -> do
        let val'' = Wp.Callbacks.dynamic_IteratorMethodsNextFieldCallback val'
        return val''
    return result

-- | Set the value of the “@next@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' iteratorMethods [ #next 'Data.GI.Base.Attributes.:=' value ]
-- @
setIteratorMethodsNext :: MonadIO m => IteratorMethods -> FunPtr Wp.Callbacks.C_IteratorMethodsNextFieldCallback -> m ()
setIteratorMethodsNext s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: FunPtr Wp.Callbacks.C_IteratorMethodsNextFieldCallback)

-- | Set the value of the “@next@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #next
-- @
clearIteratorMethodsNext :: MonadIO m => IteratorMethods -> m ()
clearIteratorMethodsNext s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (FP.nullFunPtr :: FunPtr Wp.Callbacks.C_IteratorMethodsNextFieldCallback)

#if defined(ENABLE_OVERLOADING)
data IteratorMethodsNextFieldInfo
instance AttrInfo IteratorMethodsNextFieldInfo where
    type AttrBaseTypeConstraint IteratorMethodsNextFieldInfo = (~) IteratorMethods
    type AttrAllowedOps IteratorMethodsNextFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint IteratorMethodsNextFieldInfo = (~) (FunPtr Wp.Callbacks.C_IteratorMethodsNextFieldCallback)
    type AttrTransferTypeConstraint IteratorMethodsNextFieldInfo = (~)Wp.Callbacks.IteratorMethodsNextFieldCallback
    type AttrTransferType IteratorMethodsNextFieldInfo = (FunPtr Wp.Callbacks.C_IteratorMethodsNextFieldCallback)
    type AttrGetType IteratorMethodsNextFieldInfo = Maybe Wp.Callbacks.IteratorMethodsNextFieldCallback
    type AttrLabel IteratorMethodsNextFieldInfo = "next"
    type AttrOrigin IteratorMethodsNextFieldInfo = IteratorMethods
    attrGet = getIteratorMethodsNext
    attrSet = setIteratorMethodsNext
    attrConstruct = undefined
    attrClear = clearIteratorMethodsNext
    attrTransfer _ v = do
        Wp.Callbacks.mk_IteratorMethodsNextFieldCallback (Wp.Callbacks.wrap_IteratorMethodsNextFieldCallback Nothing v)
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.IteratorMethods.next"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-IteratorMethods.html#g:attr:next"
        })

iteratorMethods_next :: AttrLabelProxy "next"
iteratorMethods_next = AttrLabelProxy

#endif


-- | Get the value of the “@finalize@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' iteratorMethods #finalize
-- @
getIteratorMethodsFinalize :: MonadIO m => IteratorMethods -> m (Maybe Wp.Callbacks.IteratorMethodsFinalizeFieldCallback)
getIteratorMethodsFinalize s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO (FunPtr Wp.Callbacks.C_IteratorMethodsFinalizeFieldCallback)
    result <- SP.convertFunPtrIfNonNull val $ \val' -> do
        let val'' = Wp.Callbacks.dynamic_IteratorMethodsFinalizeFieldCallback val'
        return val''
    return result

-- | Set the value of the “@finalize@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' iteratorMethods [ #finalize 'Data.GI.Base.Attributes.:=' value ]
-- @
setIteratorMethodsFinalize :: MonadIO m => IteratorMethods -> FunPtr Wp.Callbacks.C_IteratorMethodsFinalizeFieldCallback -> m ()
setIteratorMethodsFinalize s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 40) (val :: FunPtr Wp.Callbacks.C_IteratorMethodsFinalizeFieldCallback)

-- | Set the value of the “@finalize@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #finalize
-- @
clearIteratorMethodsFinalize :: MonadIO m => IteratorMethods -> m ()
clearIteratorMethodsFinalize s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 40) (FP.nullFunPtr :: FunPtr Wp.Callbacks.C_IteratorMethodsFinalizeFieldCallback)

#if defined(ENABLE_OVERLOADING)
data IteratorMethodsFinalizeFieldInfo
instance AttrInfo IteratorMethodsFinalizeFieldInfo where
    type AttrBaseTypeConstraint IteratorMethodsFinalizeFieldInfo = (~) IteratorMethods
    type AttrAllowedOps IteratorMethodsFinalizeFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint IteratorMethodsFinalizeFieldInfo = (~) (FunPtr Wp.Callbacks.C_IteratorMethodsFinalizeFieldCallback)
    type AttrTransferTypeConstraint IteratorMethodsFinalizeFieldInfo = (~)Wp.Callbacks.IteratorMethodsFinalizeFieldCallback
    type AttrTransferType IteratorMethodsFinalizeFieldInfo = (FunPtr Wp.Callbacks.C_IteratorMethodsFinalizeFieldCallback)
    type AttrGetType IteratorMethodsFinalizeFieldInfo = Maybe Wp.Callbacks.IteratorMethodsFinalizeFieldCallback
    type AttrLabel IteratorMethodsFinalizeFieldInfo = "finalize"
    type AttrOrigin IteratorMethodsFinalizeFieldInfo = IteratorMethods
    attrGet = getIteratorMethodsFinalize
    attrSet = setIteratorMethodsFinalize
    attrConstruct = undefined
    attrClear = clearIteratorMethodsFinalize
    attrTransfer _ v = do
        Wp.Callbacks.mk_IteratorMethodsFinalizeFieldCallback (Wp.Callbacks.wrap_IteratorMethodsFinalizeFieldCallback Nothing v)
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.IteratorMethods.finalize"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-IteratorMethods.html#g:attr:finalize"
        })

iteratorMethods_finalize :: AttrLabelProxy "finalize"
iteratorMethods_finalize = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList IteratorMethods
type instance O.AttributeList IteratorMethods = IteratorMethodsAttributeList
type IteratorMethodsAttributeList = ('[ '("version", IteratorMethodsVersionFieldInfo), '("reset", IteratorMethodsResetFieldInfo), '("next", IteratorMethodsNextFieldInfo), '("finalize", IteratorMethodsFinalizeFieldInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveIteratorMethodsMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveIteratorMethodsMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveIteratorMethodsMethod t IteratorMethods, O.OverloadedMethod info IteratorMethods p) => OL.IsLabel t (IteratorMethods -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveIteratorMethodsMethod t IteratorMethods, O.OverloadedMethod info IteratorMethods p, R.HasField t IteratorMethods p) => R.HasField t IteratorMethods p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveIteratorMethodsMethod t IteratorMethods, O.OverloadedMethodInfo info IteratorMethods) => OL.IsLabel t (O.MethodProxy info IteratorMethods) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif


