{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Pango.Structs.AttrIterator
(
AttrIterator(..) ,
noAttrIterator ,
#if defined(ENABLE_OVERLOADING)
ResolveAttrIteratorMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
AttrIteratorDestroyMethodInfo ,
#endif
attrIteratorDestroy ,
#if defined(ENABLE_OVERLOADING)
AttrIteratorGetAttrsMethodInfo ,
#endif
attrIteratorGetAttrs ,
#if defined(ENABLE_OVERLOADING)
AttrIteratorGetFontMethodInfo ,
#endif
attrIteratorGetFont ,
#if defined(ENABLE_OVERLOADING)
AttrIteratorNextMethodInfo ,
#endif
attrIteratorNext ,
#if defined(ENABLE_OVERLOADING)
AttrIteratorRangeMethodInfo ,
#endif
attrIteratorRange ,
) 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.Pango.Structs.Attribute as Pango.Attribute
import {-# SOURCE #-} qualified GI.Pango.Structs.FontDescription as Pango.FontDescription
import {-# SOURCE #-} qualified GI.Pango.Structs.Language as Pango.Language
newtype AttrIterator = AttrIterator (ManagedPtr AttrIterator)
deriving (AttrIterator -> AttrIterator -> Bool
(AttrIterator -> AttrIterator -> Bool)
-> (AttrIterator -> AttrIterator -> Bool) -> Eq AttrIterator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttrIterator -> AttrIterator -> Bool
$c/= :: AttrIterator -> AttrIterator -> Bool
== :: AttrIterator -> AttrIterator -> Bool
$c== :: AttrIterator -> AttrIterator -> Bool
Eq)
instance WrappedPtr AttrIterator where
wrappedPtrCalloc :: IO (Ptr AttrIterator)
wrappedPtrCalloc = Ptr AttrIterator -> IO (Ptr AttrIterator)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr AttrIterator
forall a. Ptr a
nullPtr
wrappedPtrCopy :: AttrIterator -> IO AttrIterator
wrappedPtrCopy = AttrIterator -> IO AttrIterator
forall (m :: * -> *) a. Monad m => a -> m a
return
wrappedPtrFree :: Maybe (GDestroyNotify AttrIterator)
wrappedPtrFree = Maybe (GDestroyNotify AttrIterator)
forall a. Maybe a
Nothing
noAttrIterator :: Maybe AttrIterator
noAttrIterator :: Maybe AttrIterator
noAttrIterator = Maybe AttrIterator
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AttrIterator
type instance O.AttributeList AttrIterator = AttrIteratorAttributeList
type AttrIteratorAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "pango_attr_iterator_destroy" pango_attr_iterator_destroy ::
Ptr AttrIterator ->
IO ()
attrIteratorDestroy ::
(B.CallStack.HasCallStack, MonadIO m) =>
AttrIterator
-> m ()
attrIteratorDestroy :: AttrIterator -> m ()
attrIteratorDestroy iterator :: AttrIterator
iterator = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr AttrIterator
iterator' <- AttrIterator -> IO (Ptr AttrIterator)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AttrIterator
iterator
Ptr AttrIterator -> IO ()
pango_attr_iterator_destroy Ptr AttrIterator
iterator'
AttrIterator -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr AttrIterator
iterator
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data AttrIteratorDestroyMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AttrIteratorDestroyMethodInfo AttrIterator signature where
overloadedMethod = attrIteratorDestroy
#endif
foreign import ccall "pango_attr_iterator_get_attrs" pango_attr_iterator_get_attrs ::
Ptr AttrIterator ->
IO (Ptr (GSList (Ptr Pango.Attribute.Attribute)))
attrIteratorGetAttrs ::
(B.CallStack.HasCallStack, MonadIO m) =>
AttrIterator
-> m [Pango.Attribute.Attribute]
attrIteratorGetAttrs :: AttrIterator -> m [Attribute]
attrIteratorGetAttrs iterator :: AttrIterator
iterator = IO [Attribute] -> m [Attribute]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Attribute] -> m [Attribute])
-> IO [Attribute] -> m [Attribute]
forall a b. (a -> b) -> a -> b
$ do
Ptr AttrIterator
iterator' <- AttrIterator -> IO (Ptr AttrIterator)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AttrIterator
iterator
Ptr (GSList (Ptr Attribute))
result <- Ptr AttrIterator -> IO (Ptr (GSList (Ptr Attribute)))
pango_attr_iterator_get_attrs Ptr AttrIterator
iterator'
[Ptr Attribute]
result' <- Ptr (GSList (Ptr Attribute)) -> IO [Ptr Attribute]
forall a. Ptr (GSList (Ptr a)) -> IO [Ptr a]
unpackGSList Ptr (GSList (Ptr Attribute))
result
[Attribute]
result'' <- (Ptr Attribute -> IO Attribute)
-> [Ptr Attribute] -> IO [Attribute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr Attribute -> Attribute
Pango.Attribute.Attribute) [Ptr Attribute]
result'
Ptr (GSList (Ptr Attribute)) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList (Ptr Attribute))
result
AttrIterator -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr AttrIterator
iterator
[Attribute] -> IO [Attribute]
forall (m :: * -> *) a. Monad m => a -> m a
return [Attribute]
result''
#if defined(ENABLE_OVERLOADING)
data AttrIteratorGetAttrsMethodInfo
instance (signature ~ (m [Pango.Attribute.Attribute]), MonadIO m) => O.MethodInfo AttrIteratorGetAttrsMethodInfo AttrIterator signature where
overloadedMethod = attrIteratorGetAttrs
#endif
foreign import ccall "pango_attr_iterator_get_font" pango_attr_iterator_get_font ::
Ptr AttrIterator ->
Ptr Pango.FontDescription.FontDescription ->
Ptr Pango.Language.Language ->
Ptr (GSList (Ptr Pango.Attribute.Attribute)) ->
IO ()
attrIteratorGetFont ::
(B.CallStack.HasCallStack, MonadIO m) =>
AttrIterator
-> Pango.FontDescription.FontDescription
-> Maybe (Pango.Language.Language)
-> [Pango.Attribute.Attribute]
-> m ()
attrIteratorGetFont :: AttrIterator
-> FontDescription -> Maybe Language -> [Attribute] -> m ()
attrIteratorGetFont iterator :: AttrIterator
iterator desc :: FontDescription
desc language :: Maybe Language
language extraAttrs :: [Attribute]
extraAttrs = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr AttrIterator
iterator' <- AttrIterator -> IO (Ptr AttrIterator)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AttrIterator
iterator
Ptr FontDescription
desc' <- FontDescription -> IO (Ptr FontDescription)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr FontDescription
desc
Ptr Language
maybeLanguage <- case Maybe Language
language of
Nothing -> Ptr Language -> IO (Ptr Language)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Language
forall a. Ptr a
nullPtr
Just jLanguage :: Language
jLanguage -> do
Ptr Language
jLanguage' <- Language -> IO (Ptr Language)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Language
jLanguage
Ptr Language -> IO (Ptr Language)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Language
jLanguage'
[Ptr Attribute]
extraAttrs' <- (Attribute -> IO (Ptr Attribute))
-> [Attribute] -> IO [Ptr Attribute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Attribute -> IO (Ptr Attribute)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [Attribute]
extraAttrs
Ptr (GSList (Ptr Attribute))
extraAttrs'' <- [Ptr Attribute] -> IO (Ptr (GSList (Ptr Attribute)))
forall a. [Ptr a] -> IO (Ptr (GSList (Ptr a)))
packGSList [Ptr Attribute]
extraAttrs'
Ptr AttrIterator
-> Ptr FontDescription
-> Ptr Language
-> Ptr (GSList (Ptr Attribute))
-> IO ()
pango_attr_iterator_get_font Ptr AttrIterator
iterator' Ptr FontDescription
desc' Ptr Language
maybeLanguage Ptr (GSList (Ptr Attribute))
extraAttrs''
AttrIterator -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr AttrIterator
iterator
FontDescription -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr FontDescription
desc
Maybe Language -> (Language -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Language
language Language -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
(Attribute -> IO ()) -> [Attribute] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Attribute -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [Attribute]
extraAttrs
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data AttrIteratorGetFontMethodInfo
instance (signature ~ (Pango.FontDescription.FontDescription -> Maybe (Pango.Language.Language) -> [Pango.Attribute.Attribute] -> m ()), MonadIO m) => O.MethodInfo AttrIteratorGetFontMethodInfo AttrIterator signature where
overloadedMethod = attrIteratorGetFont
#endif
foreign import ccall "pango_attr_iterator_next" pango_attr_iterator_next ::
Ptr AttrIterator ->
IO CInt
attrIteratorNext ::
(B.CallStack.HasCallStack, MonadIO m) =>
AttrIterator
-> m Bool
attrIteratorNext :: AttrIterator -> m Bool
attrIteratorNext iterator :: AttrIterator
iterator = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr AttrIterator
iterator' <- AttrIterator -> IO (Ptr AttrIterator)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AttrIterator
iterator
CInt
result <- Ptr AttrIterator -> IO CInt
pango_attr_iterator_next Ptr AttrIterator
iterator'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
AttrIterator -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr AttrIterator
iterator
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data AttrIteratorNextMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo AttrIteratorNextMethodInfo AttrIterator signature where
overloadedMethod = attrIteratorNext
#endif
foreign import ccall "pango_attr_iterator_range" pango_attr_iterator_range ::
Ptr AttrIterator ->
Ptr Int32 ->
Ptr Int32 ->
IO ()
attrIteratorRange ::
(B.CallStack.HasCallStack, MonadIO m) =>
AttrIterator
-> m ((Int32, Int32))
attrIteratorRange :: AttrIterator -> m (Int32, Int32)
attrIteratorRange iterator :: AttrIterator
iterator = IO (Int32, Int32) -> m (Int32, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, Int32) -> m (Int32, Int32))
-> IO (Int32, Int32) -> m (Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
Ptr AttrIterator
iterator' <- AttrIterator -> IO (Ptr AttrIterator)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AttrIterator
iterator
Ptr Int32
start <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
Ptr Int32
end <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
Ptr AttrIterator -> Ptr Int32 -> Ptr Int32 -> IO ()
pango_attr_iterator_range Ptr AttrIterator
iterator' Ptr Int32
start Ptr Int32
end
Int32
start' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
start
Int32
end' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
end
AttrIterator -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr AttrIterator
iterator
Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
start
Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
end
(Int32, Int32) -> IO (Int32, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int32
start', Int32
end')
#if defined(ENABLE_OVERLOADING)
data AttrIteratorRangeMethodInfo
instance (signature ~ (m ((Int32, Int32))), MonadIO m) => O.MethodInfo AttrIteratorRangeMethodInfo AttrIterator signature where
overloadedMethod = attrIteratorRange
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveAttrIteratorMethod (t :: Symbol) (o :: *) :: * where
ResolveAttrIteratorMethod "destroy" o = AttrIteratorDestroyMethodInfo
ResolveAttrIteratorMethod "next" o = AttrIteratorNextMethodInfo
ResolveAttrIteratorMethod "range" o = AttrIteratorRangeMethodInfo
ResolveAttrIteratorMethod "getAttrs" o = AttrIteratorGetAttrsMethodInfo
ResolveAttrIteratorMethod "getFont" o = AttrIteratorGetFontMethodInfo
ResolveAttrIteratorMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAttrIteratorMethod t AttrIterator, O.MethodInfo info AttrIterator p) => OL.IsLabel t (AttrIterator -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif