{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An opaque structure used to iterate over attributes
-- in a t'GI.GIRepository.Structs.BaseInfo.BaseInfo' struct.

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

module GI.GIRepository.Structs.AttributeIter
    ( 

-- * Exported types
    AttributeIter(..)                       ,
    newZeroAttributeIter                    ,
    noAttributeIter                         ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveAttributeIterMethod              ,
#endif




    ) 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


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

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

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


-- | A convenience alias for `Nothing` :: `Maybe` `AttributeIter`.
noAttributeIter :: Maybe AttributeIter
noAttributeIter :: Maybe AttributeIter
noAttributeIter = Maybe AttributeIter
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AttributeIter
type instance O.AttributeList AttributeIter = AttributeIterAttributeList
type AttributeIterAttributeList = ('[ ] :: [(Symbol, *)])
#endif

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

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

#endif