{-# LANGUAGE TypeApplications #-}


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

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

module GI.GObject.Structs.EnumClass
    ( 

-- * Exported types
    EnumClass(..)                           ,
    newZeroEnumClass                        ,
    noEnumClass                             ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveEnumClassMethod                  ,
#endif




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

#if defined(ENABLE_OVERLOADING)
    enumClass_gTypeClass                    ,
#endif
    getEnumClassGTypeClass                  ,


-- ** maximum #attr:maximum#
-- | the largest possible value.

#if defined(ENABLE_OVERLOADING)
    enumClass_maximum                       ,
#endif
    getEnumClassMaximum                     ,
    setEnumClassMaximum                     ,


-- ** minimum #attr:minimum#
-- | the smallest possible value.

#if defined(ENABLE_OVERLOADING)
    enumClass_minimum                       ,
#endif
    getEnumClassMinimum                     ,
    setEnumClassMinimum                     ,


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

#if defined(ENABLE_OVERLOADING)
    enumClass_nValues                       ,
#endif
    getEnumClassNValues                     ,
    setEnumClassNValues                     ,


-- ** values #attr:values#
-- | an array of t'GI.GObject.Structs.EnumValue.EnumValue' structs describing the
--  individual values.

    clearEnumClassValues                    ,
#if defined(ENABLE_OVERLOADING)
    enumClass_values                        ,
#endif
    getEnumClassValues                      ,
    setEnumClassValues                      ,




    ) 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.GI.Base.Signals as B.Signals
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

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

-- | Memory-managed wrapper type.
newtype EnumClass = EnumClass (ManagedPtr EnumClass)
    deriving (EnumClass -> EnumClass -> Bool
(EnumClass -> EnumClass -> Bool)
-> (EnumClass -> EnumClass -> Bool) -> Eq EnumClass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumClass -> EnumClass -> Bool
$c/= :: EnumClass -> EnumClass -> Bool
== :: EnumClass -> EnumClass -> Bool
$c== :: EnumClass -> EnumClass -> Bool
Eq)
instance WrappedPtr EnumClass where
    wrappedPtrCalloc :: IO (Ptr EnumClass)
wrappedPtrCalloc = Int -> IO (Ptr EnumClass)
forall a. Int -> IO (Ptr a)
callocBytes 32
    wrappedPtrCopy :: EnumClass -> IO EnumClass
wrappedPtrCopy = \p :: EnumClass
p -> EnumClass -> (Ptr EnumClass -> IO EnumClass) -> IO EnumClass
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumClass
p (Int -> Ptr EnumClass -> IO (Ptr EnumClass)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 32 (Ptr EnumClass -> IO (Ptr EnumClass))
-> (Ptr EnumClass -> IO EnumClass) -> Ptr EnumClass -> IO EnumClass
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr EnumClass -> EnumClass)
-> Ptr EnumClass -> IO EnumClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr EnumClass -> EnumClass
EnumClass)
    wrappedPtrFree :: Maybe (GDestroyNotify EnumClass)
wrappedPtrFree = GDestroyNotify EnumClass -> Maybe (GDestroyNotify EnumClass)
forall a. a -> Maybe a
Just GDestroyNotify EnumClass
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | Construct a `EnumClass` struct initialized to zero.
newZeroEnumClass :: MonadIO m => m EnumClass
newZeroEnumClass :: m EnumClass
newZeroEnumClass = IO EnumClass -> m EnumClass
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO EnumClass -> m EnumClass) -> IO EnumClass -> m EnumClass
forall a b. (a -> b) -> a -> b
$ IO (Ptr EnumClass)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr EnumClass)
-> (Ptr EnumClass -> IO EnumClass) -> IO EnumClass
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr EnumClass -> EnumClass)
-> Ptr EnumClass -> IO EnumClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr EnumClass -> EnumClass
EnumClass

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


-- | A convenience alias for `Nothing` :: `Maybe` `EnumClass`.
noEnumClass :: Maybe EnumClass
noEnumClass :: Maybe EnumClass
noEnumClass = Maybe EnumClass
forall a. Maybe a
Nothing

-- | 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' enumClass #gTypeClass
-- @
getEnumClassGTypeClass :: MonadIO m => EnumClass -> m GObject.TypeClass.TypeClass
getEnumClassGTypeClass :: EnumClass -> m TypeClass
getEnumClassGTypeClass s :: EnumClass
s = IO TypeClass -> m TypeClass
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
$ EnumClass -> (Ptr EnumClass -> IO TypeClass) -> IO TypeClass
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumClass
s ((Ptr EnumClass -> IO TypeClass) -> IO TypeClass)
-> (Ptr EnumClass -> IO TypeClass) -> IO TypeClass
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumClass
ptr -> do
    let val :: Ptr TypeClass
val = Ptr EnumClass
ptr Ptr EnumClass -> Int -> Ptr TypeClass
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: (Ptr GObject.TypeClass.TypeClass)
    TypeClass
val' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeClass -> TypeClass
GObject.TypeClass.TypeClass) Ptr TypeClass
val
    TypeClass -> IO TypeClass
forall (m :: * -> *) a. Monad m => a -> m a
return TypeClass
val'

#if defined(ENABLE_OVERLOADING)
data EnumClassGTypeClassFieldInfo
instance AttrInfo EnumClassGTypeClassFieldInfo where
    type AttrBaseTypeConstraint EnumClassGTypeClassFieldInfo = (~) EnumClass
    type AttrAllowedOps EnumClassGTypeClassFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint EnumClassGTypeClassFieldInfo = (~) (Ptr GObject.TypeClass.TypeClass)
    type AttrTransferTypeConstraint EnumClassGTypeClassFieldInfo = (~)(Ptr GObject.TypeClass.TypeClass)
    type AttrTransferType EnumClassGTypeClassFieldInfo = (Ptr GObject.TypeClass.TypeClass)
    type AttrGetType EnumClassGTypeClassFieldInfo = GObject.TypeClass.TypeClass
    type AttrLabel EnumClassGTypeClassFieldInfo = "g_type_class"
    type AttrOrigin EnumClassGTypeClassFieldInfo = EnumClass
    attrGet = getEnumClassGTypeClass
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined

enumClass_gTypeClass :: AttrLabelProxy "gTypeClass"
enumClass_gTypeClass = AttrLabelProxy

#endif


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

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

#if defined(ENABLE_OVERLOADING)
data EnumClassMinimumFieldInfo
instance AttrInfo EnumClassMinimumFieldInfo where
    type AttrBaseTypeConstraint EnumClassMinimumFieldInfo = (~) EnumClass
    type AttrAllowedOps EnumClassMinimumFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EnumClassMinimumFieldInfo = (~) Int32
    type AttrTransferTypeConstraint EnumClassMinimumFieldInfo = (~)Int32
    type AttrTransferType EnumClassMinimumFieldInfo = Int32
    type AttrGetType EnumClassMinimumFieldInfo = Int32
    type AttrLabel EnumClassMinimumFieldInfo = "minimum"
    type AttrOrigin EnumClassMinimumFieldInfo = EnumClass
    attrGet = getEnumClassMinimum
    attrSet = setEnumClassMinimum
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

enumClass_minimum :: AttrLabelProxy "minimum"
enumClass_minimum = AttrLabelProxy

#endif


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

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

#if defined(ENABLE_OVERLOADING)
data EnumClassMaximumFieldInfo
instance AttrInfo EnumClassMaximumFieldInfo where
    type AttrBaseTypeConstraint EnumClassMaximumFieldInfo = (~) EnumClass
    type AttrAllowedOps EnumClassMaximumFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EnumClassMaximumFieldInfo = (~) Int32
    type AttrTransferTypeConstraint EnumClassMaximumFieldInfo = (~)Int32
    type AttrTransferType EnumClassMaximumFieldInfo = Int32
    type AttrGetType EnumClassMaximumFieldInfo = Int32
    type AttrLabel EnumClassMaximumFieldInfo = "maximum"
    type AttrOrigin EnumClassMaximumFieldInfo = EnumClass
    attrGet = getEnumClassMaximum
    attrSet = setEnumClassMaximum
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

enumClass_maximum :: AttrLabelProxy "maximum"
enumClass_maximum = 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' enumClass #nValues
-- @
getEnumClassNValues :: MonadIO m => EnumClass -> m Word32
getEnumClassNValues :: EnumClass -> m Word32
getEnumClassNValues s :: EnumClass
s = IO Word32 -> m Word32
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
$ EnumClass -> (Ptr EnumClass -> IO Word32) -> IO Word32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumClass
s ((Ptr EnumClass -> IO Word32) -> IO Word32)
-> (Ptr EnumClass -> IO Word32) -> IO Word32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumClass
ptr -> do
    Word32
val <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek (Ptr EnumClass
ptr Ptr EnumClass -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO Word32
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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' enumClass [ #nValues 'Data.GI.Base.Attributes.:=' value ]
-- @
setEnumClassNValues :: MonadIO m => EnumClass -> Word32 -> m ()
setEnumClassNValues :: EnumClass -> Word32 -> m ()
setEnumClassNValues s :: EnumClass
s val :: Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumClass -> (Ptr EnumClass -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumClass
s ((Ptr EnumClass -> IO ()) -> IO ())
-> (Ptr EnumClass -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumClass
ptr -> do
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumClass
ptr Ptr EnumClass -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (Word32
val :: Word32)

#if defined(ENABLE_OVERLOADING)
data EnumClassNValuesFieldInfo
instance AttrInfo EnumClassNValuesFieldInfo where
    type AttrBaseTypeConstraint EnumClassNValuesFieldInfo = (~) EnumClass
    type AttrAllowedOps EnumClassNValuesFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EnumClassNValuesFieldInfo = (~) Word32
    type AttrTransferTypeConstraint EnumClassNValuesFieldInfo = (~)Word32
    type AttrTransferType EnumClassNValuesFieldInfo = Word32
    type AttrGetType EnumClassNValuesFieldInfo = Word32
    type AttrLabel EnumClassNValuesFieldInfo = "n_values"
    type AttrOrigin EnumClassNValuesFieldInfo = EnumClass
    attrGet = getEnumClassNValues
    attrSet = setEnumClassNValues
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

enumClass_nValues :: AttrLabelProxy "nValues"
enumClass_nValues = AttrLabelProxy

#endif


-- | Get the value of the “@values@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' enumClass #values
-- @
getEnumClassValues :: MonadIO m => EnumClass -> m (Maybe GObject.EnumValue.EnumValue)
getEnumClassValues :: EnumClass -> m (Maybe EnumValue)
getEnumClassValues s :: EnumClass
s = IO (Maybe EnumValue) -> m (Maybe EnumValue)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe EnumValue) -> m (Maybe EnumValue))
-> IO (Maybe EnumValue) -> m (Maybe EnumValue)
forall a b. (a -> b) -> a -> b
$ EnumClass
-> (Ptr EnumClass -> IO (Maybe EnumValue)) -> IO (Maybe EnumValue)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumClass
s ((Ptr EnumClass -> IO (Maybe EnumValue)) -> IO (Maybe EnumValue))
-> (Ptr EnumClass -> IO (Maybe EnumValue)) -> IO (Maybe EnumValue)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumClass
ptr -> do
    Ptr EnumValue
val <- Ptr (Ptr EnumValue) -> IO (Ptr EnumValue)
forall a. Storable a => Ptr a -> IO a
peek (Ptr EnumClass
ptr Ptr EnumClass -> Int -> Ptr (Ptr EnumValue)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) :: IO (Ptr GObject.EnumValue.EnumValue)
    Maybe EnumValue
result <- Ptr EnumValue
-> (Ptr EnumValue -> IO EnumValue) -> IO (Maybe EnumValue)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull Ptr EnumValue
val ((Ptr EnumValue -> IO EnumValue) -> IO (Maybe EnumValue))
-> (Ptr EnumValue -> IO EnumValue) -> IO (Maybe EnumValue)
forall a b. (a -> b) -> a -> b
$ \val' :: Ptr EnumValue
val' -> do
        EnumValue
val'' <- ((ManagedPtr EnumValue -> EnumValue)
-> Ptr EnumValue -> IO EnumValue
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr EnumValue -> EnumValue
GObject.EnumValue.EnumValue) Ptr EnumValue
val'
        EnumValue -> IO EnumValue
forall (m :: * -> *) a. Monad m => a -> m a
return EnumValue
val''
    Maybe EnumValue -> IO (Maybe EnumValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe EnumValue
result

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

-- | Set the value of the “@values@” 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' #values
-- @
clearEnumClassValues :: MonadIO m => EnumClass -> m ()
clearEnumClassValues :: EnumClass -> m ()
clearEnumClassValues s :: EnumClass
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumClass -> (Ptr EnumClass -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumClass
s ((Ptr EnumClass -> IO ()) -> IO ())
-> (Ptr EnumClass -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumClass
ptr -> do
    Ptr (Ptr EnumValue) -> Ptr EnumValue -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumClass
ptr Ptr EnumClass -> Int -> Ptr (Ptr EnumValue)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) (Ptr EnumValue
forall a. Ptr a
FP.nullPtr :: Ptr GObject.EnumValue.EnumValue)

#if defined(ENABLE_OVERLOADING)
data EnumClassValuesFieldInfo
instance AttrInfo EnumClassValuesFieldInfo where
    type AttrBaseTypeConstraint EnumClassValuesFieldInfo = (~) EnumClass
    type AttrAllowedOps EnumClassValuesFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EnumClassValuesFieldInfo = (~) (Ptr GObject.EnumValue.EnumValue)
    type AttrTransferTypeConstraint EnumClassValuesFieldInfo = (~)(Ptr GObject.EnumValue.EnumValue)
    type AttrTransferType EnumClassValuesFieldInfo = (Ptr GObject.EnumValue.EnumValue)
    type AttrGetType EnumClassValuesFieldInfo = Maybe GObject.EnumValue.EnumValue
    type AttrLabel EnumClassValuesFieldInfo = "values"
    type AttrOrigin EnumClassValuesFieldInfo = EnumClass
    attrGet = getEnumClassValues
    attrSet = setEnumClassValues
    attrConstruct = undefined
    attrClear = clearEnumClassValues
    attrTransfer _ v = do
        return v

enumClass_values :: AttrLabelProxy "values"
enumClass_values = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList EnumClass
type instance O.AttributeList EnumClass = EnumClassAttributeList
type EnumClassAttributeList = ('[ '("gTypeClass", EnumClassGTypeClassFieldInfo), '("minimum", EnumClassMinimumFieldInfo), '("maximum", EnumClassMaximumFieldInfo), '("nValues", EnumClassNValuesFieldInfo), '("values", EnumClassValuesFieldInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveEnumClassMethod (t :: Symbol) (o :: *) :: * where
    ResolveEnumClassMethod l o = O.MethodResolutionFailed l o

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

#endif