{-# 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                    ,


 -- * 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.BasicTypes as B.Types
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 Control.Monad.IO.Class as MIO
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 (SP.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 SP.ManagedPtrNewtype AttributeIter where
    toManagedPtr :: AttributeIter -> ManagedPtr AttributeIter
toManagedPtr (AttributeIter ManagedPtr AttributeIter
p) = ManagedPtr AttributeIter
p

instance BoxedPtr AttributeIter where
    boxedPtrCopy :: AttributeIter -> IO AttributeIter
boxedPtrCopy = \AttributeIter
p -> AttributeIter
-> (Ptr AttributeIter -> IO AttributeIter) -> IO AttributeIter
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr AttributeIter
p (Int -> Ptr AttributeIter -> IO (Ptr AttributeIter)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
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, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr AttributeIter -> AttributeIter
AttributeIter)
    boxedPtrFree :: AttributeIter -> IO ()
boxedPtrFree = \AttributeIter
x -> AttributeIter -> (Ptr AttributeIter -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr AttributeIter
x Ptr AttributeIter -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr AttributeIter where
    boxedPtrCalloc :: IO (Ptr AttributeIter)
boxedPtrCalloc = Int -> IO (Ptr AttributeIter)
forall a. Int -> IO (Ptr a)
callocBytes Int
32


-- | 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. CallocPtr a => IO (Ptr a)
boxedPtrCalloc 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, BoxedPtr 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 ManagedPtr AttributeIter -> AttributeIter
_ [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



#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