gi-girepository-1.0.18: GI/GIRepository/Structs/BaseInfo.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
GIBaseInfo is the common base struct of all other *Info structs
accessible through the 'GI.GIRepository.Objects.Repository.Repository' API.
All other structs can be casted to a 'GI.GIRepository.Structs.BaseInfo.BaseInfo', for instance:
\<example>
\<title>Casting a @/GIFunctionInfo/@ to 'GI.GIRepository.Structs.BaseInfo.BaseInfo'\<\/title>
\<programlisting>
GIFunctionInfo *function_info = ...;
GIBaseInfo *info = (GIBaseInfo*)function_info;
\<\/programlisting>
\<\/example>
Most 'GI.GIRepository.Objects.Repository.Repository' APIs returning a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' is actually creating a new struct, in other
words, @/g_base_info_unref()/@ has to be called when done accessing the data.
GIBaseInfos are normally accessed by calling either
'GI.GIRepository.Objects.Repository.repositoryFindByName', 'GI.GIRepository.Objects.Repository.repositoryFindByGtype' or 'GI.GIRepository.Objects.Repository.repositoryGetInfo'.
\<example>
\<title>Getting the Button of the Gtk typelib\<\/title>
\<programlisting>
GIBaseInfo *button_info = g_irepository_find_by_name(NULL, \"Gtk\", \"Button\");
... use button_info ...
g_base_info_unref(button_info);
\<\/programlisting>
\<\/example>
\<refsect1 id=\"gi-gibaseinfo.struct-hierarchy\" role=\"struct_hierarchy\">
\<title role=\"struct_hierarchy.title\">Struct hierarchy\<\/title>
\<synopsis>
GIBaseInfo
+----\<link linkend=\"gi-GIArgInfo\">GIArgInfo\<\/link>
+----\<link linkend=\"gi-GICallableInfo\">GICallableInfo\<\/link>
+----\<link linkend=\"gi-GIConstantInfo\">GIConstantInfo\<\/link>
+----\<link linkend=\"gi-GIFieldInfo\">GIFieldInfo\<\/link>
+----\<link linkend=\"gi-GIPropertyInfo\">GIPropertyInfo\<\/link>
+----\<link linkend=\"gi-GIRegisteredTypeInfo\">GIRegisteredTypeInfo\<\/link>
+----\<link linkend=\"gi-GITypeInfo\">GITypeInfo\<\/link>
\<\/synopsis>
\<\/refsect1>
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.GIRepository.Structs.BaseInfo
(
-- * Exported types
BaseInfo(..) ,
newZeroBaseInfo ,
noBaseInfo ,
-- * Methods
-- ** equal #method:equal#
#if ENABLE_OVERLOADING
BaseInfoEqualMethodInfo ,
#endif
baseInfoEqual ,
-- ** getAttribute #method:getAttribute#
#if ENABLE_OVERLOADING
BaseInfoGetAttributeMethodInfo ,
#endif
baseInfoGetAttribute ,
-- ** getContainer #method:getContainer#
#if ENABLE_OVERLOADING
BaseInfoGetContainerMethodInfo ,
#endif
baseInfoGetContainer ,
-- ** getName #method:getName#
#if ENABLE_OVERLOADING
BaseInfoGetNameMethodInfo ,
#endif
baseInfoGetName ,
-- ** getNamespace #method:getNamespace#
#if ENABLE_OVERLOADING
BaseInfoGetNamespaceMethodInfo ,
#endif
baseInfoGetNamespace ,
-- ** getType #method:getType#
#if ENABLE_OVERLOADING
BaseInfoGetTypeMethodInfo ,
#endif
baseInfoGetType ,
-- ** getTypelib #method:getTypelib#
#if ENABLE_OVERLOADING
BaseInfoGetTypelibMethodInfo ,
#endif
baseInfoGetTypelib ,
-- ** isDeprecated #method:isDeprecated#
#if ENABLE_OVERLOADING
BaseInfoIsDeprecatedMethodInfo ,
#endif
baseInfoIsDeprecated ,
-- ** iterateAttributes #method:iterateAttributes#
#if ENABLE_OVERLOADING
BaseInfoIterateAttributesMethodInfo ,
#endif
baseInfoIterateAttributes ,
) 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.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.GIRepository.Enums as GIRepository.Enums
import {-# SOURCE #-} qualified GI.GIRepository.Structs.AttributeIter as GIRepository.AttributeIter
import {-# SOURCE #-} qualified GI.GIRepository.Structs.Typelib as GIRepository.Typelib
-- | Memory-managed wrapper type.
newtype BaseInfo = BaseInfo (ManagedPtr BaseInfo)
foreign import ccall "g_base_info_gtype_get_type" c_g_base_info_gtype_get_type ::
IO GType
instance BoxedObject BaseInfo where
boxedType _ = c_g_base_info_gtype_get_type
-- | Construct a `BaseInfo` struct initialized to zero.
newZeroBaseInfo :: MonadIO m => m BaseInfo
newZeroBaseInfo = liftIO $ callocBoxedBytes 72 >>= wrapBoxed BaseInfo
instance tag ~ 'AttrSet => Constructible BaseInfo tag where
new _ attrs = do
o <- newZeroBaseInfo
GI.Attributes.set o attrs
return o
-- | A convenience alias for `Nothing` :: `Maybe` `BaseInfo`.
noBaseInfo :: Maybe BaseInfo
noBaseInfo = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList BaseInfo
type instance O.AttributeList BaseInfo = BaseInfoAttributeList
type BaseInfoAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method BaseInfo::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info1", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info2", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_equal" g_base_info_equal ::
Ptr BaseInfo -> -- info1 : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
Ptr BaseInfo -> -- info2 : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO CInt
{- |
Compare two 'GI.GIRepository.Structs.BaseInfo.BaseInfo'.
Using pointer comparison is not practical since many functions return
different instances of 'GI.GIRepository.Structs.BaseInfo.BaseInfo' that refers to the same part of the
TypeLib; use this function instead to do 'GI.GIRepository.Structs.BaseInfo.BaseInfo' comparisons.
-}
baseInfoEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info1@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> BaseInfo
{- ^ /@info2@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m Bool
{- ^ __Returns:__ 'True' if and only if /@info1@/ equals /@info2@/. -}
baseInfoEqual info1 info2 = liftIO $ do
info1' <- unsafeManagedPtrGetPtr info1
info2' <- unsafeManagedPtrGetPtr info2
result <- g_base_info_equal info1' info2'
let result' = (/= 0) result
touchManagedPtr info1
touchManagedPtr info2
return result'
#if ENABLE_OVERLOADING
data BaseInfoEqualMethodInfo
instance (signature ~ (BaseInfo -> m Bool), MonadIO m) => O.MethodInfo BaseInfoEqualMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoEqual
#endif
-- method BaseInfo::get_attribute
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a freeform string naming an attribute", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_get_attribute" g_base_info_get_attribute ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
CString -> -- name : TBasicType TUTF8
IO CString
{- |
Retrieve an arbitrary attribute associated with this node.
-}
baseInfoGetAttribute ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> T.Text
{- ^ /@name@/: a freeform string naming an attribute -}
-> m T.Text
{- ^ __Returns:__ The value of the attribute, or 'Nothing' if no such attribute exists -}
baseInfoGetAttribute info name = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
name' <- textToCString name
result <- g_base_info_get_attribute info' name'
checkUnexpectedReturnNULL "baseInfoGetAttribute" result
result' <- cstringToText result
touchManagedPtr info
freeMem name'
return result'
#if ENABLE_OVERLOADING
data BaseInfoGetAttributeMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m) => O.MethodInfo BaseInfoGetAttributeMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoGetAttribute
#endif
-- method BaseInfo::get_container
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_get_container" g_base_info_get_container ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO (Ptr BaseInfo)
{- |
Obtain the container of the /@info@/. The container is the parent
GIBaseInfo. For instance, the parent of a @/GIFunctionInfo/@ is an
@/GIObjectInfo/@ or @/GIInterfaceInfo/@.
-}
baseInfoGetContainer ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m BaseInfo
{- ^ __Returns:__ the container -}
baseInfoGetContainer info = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
result <- g_base_info_get_container info'
checkUnexpectedReturnNULL "baseInfoGetContainer" result
result' <- (newBoxed BaseInfo) result
touchManagedPtr info
return result'
#if ENABLE_OVERLOADING
data BaseInfoGetContainerMethodInfo
instance (signature ~ (m BaseInfo), MonadIO m) => O.MethodInfo BaseInfoGetContainerMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoGetContainer
#endif
-- method BaseInfo::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_get_name" g_base_info_get_name ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO CString
{- |
Obtain the name of the /@info@/. What the name represents depends on
the 'GI.GIRepository.Enums.InfoType' of the /@info@/. For instance for @/GIFunctionInfo/@ it is
the name of the function.
-}
baseInfoGetName ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m T.Text
{- ^ __Returns:__ the name of /@info@/ or 'Nothing' if it lacks a name. -}
baseInfoGetName info = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
result <- g_base_info_get_name info'
checkUnexpectedReturnNULL "baseInfoGetName" result
result' <- cstringToText result
touchManagedPtr info
return result'
#if ENABLE_OVERLOADING
data BaseInfoGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo BaseInfoGetNameMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoGetName
#endif
-- method BaseInfo::get_namespace
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_get_namespace" g_base_info_get_namespace ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO CString
{- |
Obtain the namespace of /@info@/.
-}
baseInfoGetNamespace ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m T.Text
{- ^ __Returns:__ the namespace -}
baseInfoGetNamespace info = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
result <- g_base_info_get_namespace info'
checkUnexpectedReturnNULL "baseInfoGetNamespace" result
result' <- cstringToText result
touchManagedPtr info
return result'
#if ENABLE_OVERLOADING
data BaseInfoGetNamespaceMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo BaseInfoGetNamespaceMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoGetNamespace
#endif
-- method BaseInfo::get_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GIRepository", name = "InfoType"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_get_type" g_base_info_get_type ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO CUInt
{- |
Obtain the info type of the GIBaseInfo.
-}
baseInfoGetType ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m GIRepository.Enums.InfoType
{- ^ __Returns:__ the info type of /@info@/ -}
baseInfoGetType info = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
result <- g_base_info_get_type info'
let result' = (toEnum . fromIntegral) result
touchManagedPtr info
return result'
#if ENABLE_OVERLOADING
data BaseInfoGetTypeMethodInfo
instance (signature ~ (m GIRepository.Enums.InfoType), MonadIO m) => O.MethodInfo BaseInfoGetTypeMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoGetType
#endif
-- method BaseInfo::get_typelib
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GIRepository", name = "Typelib"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_get_typelib" g_base_info_get_typelib ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO (Ptr GIRepository.Typelib.Typelib)
{- |
Obtain the typelib this /@info@/ belongs to
-}
baseInfoGetTypelib ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m GIRepository.Typelib.Typelib
{- ^ __Returns:__ the typelib. -}
baseInfoGetTypelib info = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
result <- g_base_info_get_typelib info'
checkUnexpectedReturnNULL "baseInfoGetTypelib" result
result' <- (newPtr GIRepository.Typelib.Typelib) result
touchManagedPtr info
return result'
#if ENABLE_OVERLOADING
data BaseInfoGetTypelibMethodInfo
instance (signature ~ (m GIRepository.Typelib.Typelib), MonadIO m) => O.MethodInfo BaseInfoGetTypelibMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoGetTypelib
#endif
-- method BaseInfo::is_deprecated
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_is_deprecated" g_base_info_is_deprecated ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
IO CInt
{- |
Obtain whether the /@info@/ is represents a metadata which is
deprecated or not.
-}
baseInfoIsDeprecated ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> m Bool
{- ^ __Returns:__ 'True' if deprecated -}
baseInfoIsDeprecated info = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
result <- g_base_info_is_deprecated info'
let result' = (/= 0) result
touchManagedPtr info
return result'
#if ENABLE_OVERLOADING
data BaseInfoIsDeprecatedMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo BaseInfoIsDeprecatedMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoIsDeprecated
#endif
-- method BaseInfo::iterate_attributes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GIRepository", name = "BaseInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIBaseInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iterator", argType = TInterface (Name {namespace = "GIRepository", name = "AttributeIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIAttributeIter structure, must be initialized; see below", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Returned name, must not be freed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Returned name, must not be freed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_base_info_iterate_attributes" g_base_info_iterate_attributes ::
Ptr BaseInfo -> -- info : TInterface (Name {namespace = "GIRepository", name = "BaseInfo"})
Ptr GIRepository.AttributeIter.AttributeIter -> -- iterator : TInterface (Name {namespace = "GIRepository", name = "AttributeIter"})
Ptr CString -> -- name : TBasicType TUTF8
Ptr CString -> -- value : TBasicType TUTF8
IO CInt
{- |
Iterate over all attributes associated with this node. The iterator
structure is typically stack allocated, and must have its first
member initialized to 'Nothing'. Attributes are arbitrary namespaced key–value
pairs which can be attached to almost any item. They are intended for use
by software higher in the toolchain than bindings, and are distinct from
normal GIR annotations.
Both the /@name@/ and /@value@/ should be treated as constants
and must not be freed.
\<example>
\<title>Iterating over attributes\<\/title>
\<programlisting>
void
print_attributes (GIBaseInfo *info)
{
GIAttributeIter iter = { 0, };
char *name;
char *value;
while (g_base_info_iterate_attributes (info, &iter, &name, &value))
{
g_print (\"attribute name: @/s/@ value: @/s/@\", name, value);
}
}
\<\/programlisting>
\<\/example>
-}
baseInfoIterateAttributes ::
(B.CallStack.HasCallStack, MonadIO m) =>
BaseInfo
{- ^ /@info@/: a 'GI.GIRepository.Structs.BaseInfo.BaseInfo' -}
-> GIRepository.AttributeIter.AttributeIter
{- ^ /@iterator@/: a 'GI.GIRepository.Structs.AttributeIter.AttributeIter' structure, must be initialized; see below -}
-> m ((Bool, T.Text, T.Text))
{- ^ __Returns:__ 'True' if there are more attributes -}
baseInfoIterateAttributes info iterator = liftIO $ do
info' <- unsafeManagedPtrGetPtr info
iterator' <- unsafeManagedPtrGetPtr iterator
name <- allocMem :: IO (Ptr CString)
value <- allocMem :: IO (Ptr CString)
result <- g_base_info_iterate_attributes info' iterator' name value
let result' = (/= 0) result
name' <- peek name
name'' <- cstringToText name'
value' <- peek value
value'' <- cstringToText value'
touchManagedPtr info
touchManagedPtr iterator
freeMem name
freeMem value
return (result', name'', value'')
#if ENABLE_OVERLOADING
data BaseInfoIterateAttributesMethodInfo
instance (signature ~ (GIRepository.AttributeIter.AttributeIter -> m ((Bool, T.Text, T.Text))), MonadIO m) => O.MethodInfo BaseInfoIterateAttributesMethodInfo BaseInfo signature where
overloadedMethod _ = baseInfoIterateAttributes
#endif
#if ENABLE_OVERLOADING
type family ResolveBaseInfoMethod (t :: Symbol) (o :: *) :: * where
ResolveBaseInfoMethod "equal" o = BaseInfoEqualMethodInfo
ResolveBaseInfoMethod "isDeprecated" o = BaseInfoIsDeprecatedMethodInfo
ResolveBaseInfoMethod "iterateAttributes" o = BaseInfoIterateAttributesMethodInfo
ResolveBaseInfoMethod "getAttribute" o = BaseInfoGetAttributeMethodInfo
ResolveBaseInfoMethod "getContainer" o = BaseInfoGetContainerMethodInfo
ResolveBaseInfoMethod "getName" o = BaseInfoGetNameMethodInfo
ResolveBaseInfoMethod "getNamespace" o = BaseInfoGetNamespaceMethodInfo
ResolveBaseInfoMethod "getType" o = BaseInfoGetTypeMethodInfo
ResolveBaseInfoMethod "getTypelib" o = BaseInfoGetTypelibMethodInfo
ResolveBaseInfoMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveBaseInfoMethod t BaseInfo, O.MethodInfo info BaseInfo p) => OL.IsLabel t (BaseInfo -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif