    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- The class of a flags type holds information about its
    -- possible values.

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.GObject.Structs.FlagsClass
        (

    -- * Exported types
        FlagsClass(..)                          ,
        newZeroFlagsClass                       ,

     -- * Methods

    #if defined(ENABLE_OVERLOADING)
        ResolveFlagsClassMethod                 ,
    #endif

     -- * Properties

    -- ** gTypeClass #attr:gTypeClass#
    -- | the parent class

    #if defined(ENABLE_OVERLOADING)
        flagsClass_gTypeClass                   ,
    #endif
        getFlagsClassGTypeClass                 ,

    -- ** mask #attr:mask#
    -- | a mask covering all possible values.

    #if defined(ENABLE_OVERLOADING)
        flagsClass_mask                         ,
    #endif
        getFlagsClassMask                       ,
        setFlagsClassMask                       ,

    -- ** nValues #attr:nValues#
    -- | the number of possible values.

    #if defined(ENABLE_OVERLOADING)
        flagsClass_nValues                      ,
    #endif
        getFlagsClassNValues                    ,
        setFlagsClassNValues                    ,

        ) 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 {-# SOURCE #-} qualified GI.GObject.Structs.TypeClass as GObject.TypeClass

    #else
    import {-# SOURCE #-} qualified GI.GObject.Structs.TypeClass as GObject.TypeClass

    #endif

    -- | Memory-managed wrapper type.
    newtype FlagsClass = FlagsClass (SP.ManagedPtr FlagsClass)
        deriving (FlagsClass -> FlagsClass -> Bool
    (FlagsClass -> FlagsClass -> Bool)
    -> (FlagsClass -> FlagsClass -> Bool) -> Eq FlagsClass
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FlagsClass -> FlagsClass -> Bool
    == :: FlagsClass -> FlagsClass -> Bool
    $c/= :: FlagsClass -> FlagsClass -> Bool
    /= :: FlagsClass -> FlagsClass -> Bool
    Eq)

    instance SP.ManagedPtrNewtype FlagsClass where
        toManagedPtr :: FlagsClass -> ManagedPtr FlagsClass
    toManagedPtr (FlagsClass ManagedPtr FlagsClass
    p) = ManagedPtr FlagsClass
    p

    instance BoxedPtr FlagsClass where
        boxedPtrCopy :: FlagsClass -> IO FlagsClass
    boxedPtrCopy = \FlagsClass
    p -> FlagsClass -> (Ptr FlagsClass -> IO FlagsClass) -> IO FlagsClass
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    B.ManagedPtr.withManagedPtr FlagsClass
    p (Int -> Ptr FlagsClass -> IO (Ptr FlagsClass)
    forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
    copyBytes Int
    24 (Ptr FlagsClass -> IO (Ptr FlagsClass))
    -> (Ptr FlagsClass -> IO FlagsClass)
    -> Ptr FlagsClass
    -> IO FlagsClass
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> (ManagedPtr FlagsClass -> FlagsClass)
    -> Ptr FlagsClass -> IO FlagsClass
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    B.ManagedPtr.wrapPtr ManagedPtr FlagsClass -> FlagsClass
    FlagsClass)
        boxedPtrFree :: FlagsClass -> IO ()
    boxedPtrFree = \FlagsClass
    x -> FlagsClass -> (Ptr FlagsClass -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    SP.withManagedPtr FlagsClass
    x Ptr FlagsClass -> IO ()
    forall a. Ptr a -> IO ()
    SP.freeMem
    instance CallocPtr FlagsClass where
        boxedPtrCalloc :: IO (Ptr FlagsClass)
    boxedPtrCalloc = Int -> IO (Ptr FlagsClass)
    forall a. Int -> IO (Ptr a)
    callocBytes Int
    24

    -- | Construct a t'FlagsClass' struct initialized to zero.
    newZeroFlagsClass :: MonadIO m => m FlagsClass
    newZeroFlagsClass :: forall (m :: * -> *). MonadIO m => m FlagsClass
    newZeroFlagsClass = IO FlagsClass -> m FlagsClass
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO FlagsClass -> m FlagsClass) -> IO FlagsClass -> m FlagsClass
    forall a b. (a -> b) -> a -> b
    $ IO (Ptr FlagsClass)
    forall a. CallocPtr a => IO (Ptr a)
    boxedPtrCalloc IO (Ptr FlagsClass)
    -> (Ptr FlagsClass -> IO FlagsClass) -> IO FlagsClass
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (ManagedPtr FlagsClass -> FlagsClass)
    -> Ptr FlagsClass -> IO FlagsClass
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapPtr ManagedPtr FlagsClass -> FlagsClass
    FlagsClass

    instance tag ~ 'AttrSet => Constructible FlagsClass tag where
        new :: forall (m :: * -> *).
    MonadIO m =>
    (ManagedPtr FlagsClass -> FlagsClass)
    -> [AttrOp FlagsClass tag] -> m FlagsClass
    new ManagedPtr FlagsClass -> FlagsClass
    _ [AttrOp FlagsClass tag]
    attrs = do
            o <- m FlagsClass
    forall (m :: * -> *). MonadIO m => m FlagsClass
    newZeroFlagsClass
            GI.Attributes.set o attrs
            return o

    -- | Get the value of the “@g_type_class@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.get' flagsClass #gTypeClass
    -- @
    getFlagsClassGTypeClass :: MonadIO m => FlagsClass -> m GObject.TypeClass.TypeClass
    getFlagsClassGTypeClass :: forall (m :: * -> *). MonadIO m => FlagsClass -> m TypeClass
    getFlagsClassGTypeClass FlagsClass
    s = IO TypeClass -> m TypeClass
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO TypeClass -> m TypeClass) -> IO TypeClass -> m TypeClass
    forall a b. (a -> b) -> a -> b
    $ FlagsClass -> (Ptr FlagsClass -> IO TypeClass) -> IO TypeClass
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FlagsClass
    s ((Ptr FlagsClass -> IO TypeClass) -> IO TypeClass)
    -> (Ptr FlagsClass -> IO TypeClass) -> IO TypeClass
    forall a b. (a -> b) -> a -> b
    $ \Ptr FlagsClass
    ptr -> do
        let val :: Ptr TypeClass
    val = Ptr FlagsClass
    ptr Ptr FlagsClass -> Int -> Ptr TypeClass
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    0 :: (Ptr GObject.TypeClass.TypeClass)
        val' <- ((ManagedPtr TypeClass -> TypeClass)
    -> Ptr TypeClass -> IO TypeClass
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    newPtr ManagedPtr TypeClass -> TypeClass
    GObject.TypeClass.TypeClass) Ptr TypeClass
    val
        return val'

    #if defined(ENABLE_OVERLOADING)
    data FlagsClassGTypeClassFieldInfo
    instance AttrInfo FlagsClassGTypeClassFieldInfo where
        type AttrBaseTypeConstraint FlagsClassGTypeClassFieldInfo = (~) FlagsClass
        type AttrAllowedOps FlagsClassGTypeClassFieldInfo = '[ 'AttrGet]
        type AttrSetTypeConstraint FlagsClassGTypeClassFieldInfo = (~) (Ptr GObject.TypeClass.TypeClass)
        type AttrTransferTypeConstraint FlagsClassGTypeClassFieldInfo = (~)(Ptr GObject.TypeClass.TypeClass)
        type AttrTransferType FlagsClassGTypeClassFieldInfo = (Ptr GObject.TypeClass.TypeClass)
        type AttrGetType FlagsClassGTypeClassFieldInfo = GObject.TypeClass.TypeClass
        type AttrLabel FlagsClassGTypeClassFieldInfo = "g_type_class"
        type AttrOrigin FlagsClassGTypeClassFieldInfo = FlagsClass
        attrGet = getFlagsClassGTypeClass
        attrSet = undefined
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer = undefined
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GObject.Structs.FlagsClass.gTypeClass"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gobject-2.0.31/docs/GI-GObject-Structs-FlagsClass.html#g:attr:gTypeClass"
            })

    flagsClass_gTypeClass :: AttrLabelProxy "gTypeClass"
    flagsClass_gTypeClass = AttrLabelProxy

    #endif

    -- | Get the value of the “@mask@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.get' flagsClass #mask
    -- @
    getFlagsClassMask :: MonadIO m => FlagsClass -> m Word32
    getFlagsClassMask :: forall (m :: * -> *). MonadIO m => FlagsClass -> m Word32
    getFlagsClassMask FlagsClass
    s = IO Word32 -> m Word32
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
    forall a b. (a -> b) -> a -> b
    $ FlagsClass -> (Ptr FlagsClass -> IO Word32) -> IO Word32
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FlagsClass
    s ((Ptr FlagsClass -> IO Word32) -> IO Word32)
    -> (Ptr FlagsClass -> IO Word32) -> IO Word32
    forall a b. (a -> b) -> a -> b
    $ \Ptr FlagsClass
    ptr -> do
        val <- Ptr Word32 -> IO Word32
    forall a. Storable a => Ptr a -> IO a
    peek (Ptr FlagsClass
    ptr Ptr FlagsClass -> Int -> Ptr Word32
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    8) :: IO Word32
        return val

    -- | Set the value of the “@mask@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.set' flagsClass [ #mask 'Data.GI.Base.Attributes.:=' value ]
    -- @
    setFlagsClassMask :: MonadIO m => FlagsClass -> Word32 -> m ()
    setFlagsClassMask :: forall (m :: * -> *). MonadIO m => FlagsClass -> Word32 -> m ()
    setFlagsClassMask FlagsClass
    s Word32
    val = IO () -> m ()
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ FlagsClass -> (Ptr FlagsClass -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FlagsClass
    s ((Ptr FlagsClass -> IO ()) -> IO ())
    -> (Ptr FlagsClass -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FlagsClass
    ptr -> do
        Ptr Word32 -> Word32 -> IO ()
    forall a. Storable a => Ptr a -> a -> IO ()
    poke (Ptr FlagsClass
    ptr Ptr FlagsClass -> Int -> Ptr Word32
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    8) (Word32
    val :: Word32)

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

    flagsClass_mask :: AttrLabelProxy "mask"
    flagsClass_mask = AttrLabelProxy

    #endif

    -- | Get the value of the “@n_values@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.get' flagsClass #nValues
    -- @
    getFlagsClassNValues :: MonadIO m => FlagsClass -> m Word32
    getFlagsClassNValues :: forall (m :: * -> *). MonadIO m => FlagsClass -> m Word32
    getFlagsClassNValues FlagsClass
    s = IO Word32 -> m Word32
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
    forall a b. (a -> b) -> a -> b
    $ FlagsClass -> (Ptr FlagsClass -> IO Word32) -> IO Word32
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FlagsClass
    s ((Ptr FlagsClass -> IO Word32) -> IO Word32)
    -> (Ptr FlagsClass -> IO Word32) -> IO Word32
    forall a b. (a -> b) -> a -> b
    $ \Ptr FlagsClass
    ptr -> do
        val <- Ptr Word32 -> IO Word32
    forall a. Storable a => Ptr a -> IO a
    peek (Ptr FlagsClass
    ptr Ptr FlagsClass -> Int -> Ptr Word32
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    12) :: IO Word32
        return val

    -- | Set the value of the “@n_values@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.set' flagsClass [ #nValues 'Data.GI.Base.Attributes.:=' value ]
    -- @
    setFlagsClassNValues :: MonadIO m => FlagsClass -> Word32 -> m ()
    setFlagsClassNValues :: forall (m :: * -> *). MonadIO m => FlagsClass -> Word32 -> m ()
    setFlagsClassNValues FlagsClass
    s Word32
    val = IO () -> m ()
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ FlagsClass -> (Ptr FlagsClass -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FlagsClass
    s ((Ptr FlagsClass -> IO ()) -> IO ())
    -> (Ptr FlagsClass -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FlagsClass
    ptr -> do
        Ptr Word32 -> Word32 -> IO ()
    forall a. Storable a => Ptr a -> a -> IO ()
    poke (Ptr FlagsClass
    ptr Ptr FlagsClass -> Int -> Ptr Word32
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    12) (Word32
    val :: Word32)

    #if defined(ENABLE_OVERLOADING)
    data FlagsClassNValuesFieldInfo
    instance AttrInfo FlagsClassNValuesFieldInfo where
        type AttrBaseTypeConstraint FlagsClassNValuesFieldInfo = (~) FlagsClass
        type AttrAllowedOps FlagsClassNValuesFieldInfo = '[ 'AttrSet, 'AttrGet]
        type AttrSetTypeConstraint FlagsClassNValuesFieldInfo = (~) Word32
        type AttrTransferTypeConstraint FlagsClassNValuesFieldInfo = (~)Word32
        type AttrTransferType FlagsClassNValuesFieldInfo = Word32
        type AttrGetType FlagsClassNValuesFieldInfo = Word32
        type AttrLabel FlagsClassNValuesFieldInfo = "n_values"
        type AttrOrigin FlagsClassNValuesFieldInfo = FlagsClass
        attrGet = getFlagsClassNValues
        attrSet = setFlagsClassNValues
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer _ v = do
            return v
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GObject.Structs.FlagsClass.nValues"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gobject-2.0.31/docs/GI-GObject-Structs-FlagsClass.html#g:attr:nValues"
            })

    flagsClass_nValues :: AttrLabelProxy "nValues"
    flagsClass_nValues = AttrLabelProxy

    #endif

    -- XXX Skipped attribute for "FlagsClass:values"
    -- Not implemented: Don't know how to unpack C array of type TCArray False (-1) 2 (TInterface (Name {namespace = "GObject", name = "FlagsValue"}))

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList FlagsClass
    type instance O.AttributeList FlagsClass = FlagsClassAttributeList
    type FlagsClassAttributeList = ('[ '("gTypeClass", FlagsClassGTypeClassFieldInfo), '("mask", FlagsClassMaskFieldInfo), '("nValues", FlagsClassNValuesFieldInfo)] :: [(Symbol, DK.Type)])
    #endif

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

    instance (info ~ ResolveFlagsClassMethod t FlagsClass, O.OverloadedMethod info FlagsClass p) => OL.IsLabel t (FlagsClass -> 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 ~ ResolveFlagsClassMethod t FlagsClass, O.OverloadedMethod info FlagsClass p, R.HasField t FlagsClass p) => R.HasField t FlagsClass p where
        getField = O.overloadedMethod @info

    #endif

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

    #endif