{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) TODO -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GIRepository.Structs.Typelib ( -- * Exported types Typelib(..) , noTypelib , -- * Methods -- ** free #method:free# #if ENABLE_OVERLOADING TypelibFreeMethodInfo , #endif typelibFree , -- ** getNamespace #method:getNamespace# #if ENABLE_OVERLOADING TypelibGetNamespaceMethodInfo , #endif typelibGetNamespace , -- ** symbol #method:symbol# #if ENABLE_OVERLOADING TypelibSymbolMethodInfo , #endif typelibSymbol , ) 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 -- | Memory-managed wrapper type. newtype Typelib = Typelib (ManagedPtr Typelib) -- XXX Wrapping a foreign struct/union with no known destructor or size, leak? instance WrappedPtr Typelib where wrappedPtrCalloc = return nullPtr wrappedPtrCopy = return wrappedPtrFree = Nothing -- | A convenience alias for `Nothing` :: `Maybe` `Typelib`. noTypelib :: Maybe Typelib noTypelib = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList Typelib type instance O.AttributeList Typelib = TypelibAttributeList type TypelibAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method Typelib::free -- method type : OrdinaryMethod -- Args : [Arg {argCName = "typelib", argType = TInterface (Name {namespace = "GIRepository", name = "Typelib"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_typelib_free" g_typelib_free :: Ptr Typelib -> -- typelib : TInterface (Name {namespace = "GIRepository", name = "Typelib"}) IO () {- | /No description available in the introspection data./ -} typelibFree :: (B.CallStack.HasCallStack, MonadIO m) => Typelib -> m () typelibFree typelib = liftIO $ do typelib' <- unsafeManagedPtrGetPtr typelib g_typelib_free typelib' touchManagedPtr typelib return () #if ENABLE_OVERLOADING data TypelibFreeMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TypelibFreeMethodInfo Typelib signature where overloadedMethod _ = typelibFree #endif -- method Typelib::get_namespace -- method type : OrdinaryMethod -- Args : [Arg {argCName = "typelib", argType = TInterface (Name {namespace = "GIRepository", name = "Typelib"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, 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_typelib_get_namespace" g_typelib_get_namespace :: Ptr Typelib -> -- typelib : TInterface (Name {namespace = "GIRepository", name = "Typelib"}) IO CString {- | /No description available in the introspection data./ -} typelibGetNamespace :: (B.CallStack.HasCallStack, MonadIO m) => Typelib -> m T.Text typelibGetNamespace typelib = liftIO $ do typelib' <- unsafeManagedPtrGetPtr typelib result <- g_typelib_get_namespace typelib' checkUnexpectedReturnNULL "typelibGetNamespace" result result' <- cstringToText result touchManagedPtr typelib return result' #if ENABLE_OVERLOADING data TypelibGetNamespaceMethodInfo instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo TypelibGetNamespaceMethodInfo Typelib signature where overloadedMethod _ = typelibGetNamespace #endif -- method Typelib::symbol -- method type : OrdinaryMethod -- Args : [Arg {argCName = "typelib", argType = TInterface (Name {namespace = "GIRepository", name = "Typelib"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "symbol_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "symbol", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, 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_typelib_symbol" g_typelib_symbol :: Ptr Typelib -> -- typelib : TInterface (Name {namespace = "GIRepository", name = "Typelib"}) CString -> -- symbol_name : TBasicType TUTF8 Ptr () -> -- symbol : TBasicType TPtr IO CInt {- | /No description available in the introspection data./ -} typelibSymbol :: (B.CallStack.HasCallStack, MonadIO m) => Typelib -> T.Text -> Ptr () -> m Bool typelibSymbol typelib symbolName symbol = liftIO $ do typelib' <- unsafeManagedPtrGetPtr typelib symbolName' <- textToCString symbolName result <- g_typelib_symbol typelib' symbolName' symbol let result' = (/= 0) result touchManagedPtr typelib freeMem symbolName' return result' #if ENABLE_OVERLOADING data TypelibSymbolMethodInfo instance (signature ~ (T.Text -> Ptr () -> m Bool), MonadIO m) => O.MethodInfo TypelibSymbolMethodInfo Typelib signature where overloadedMethod _ = typelibSymbol #endif #if ENABLE_OVERLOADING type family ResolveTypelibMethod (t :: Symbol) (o :: *) :: * where ResolveTypelibMethod "free" o = TypelibFreeMethodInfo ResolveTypelibMethod "symbol" o = TypelibSymbolMethodInfo ResolveTypelibMethod "getNamespace" o = TypelibGetNamespaceMethodInfo ResolveTypelibMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveTypelibMethod t Typelib, O.MethodInfo info Typelib p) => OL.IsLabel t (Typelib -> 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