{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GIRepository.Structs.Typelib
(
Typelib(..) ,
noTypelib ,
#if defined(ENABLE_OVERLOADING)
ResolveTypelibMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
TypelibFreeMethodInfo ,
#endif
typelibFree ,
#if defined(ENABLE_OVERLOADING)
TypelibGetNamespaceMethodInfo ,
#endif
typelibGetNamespace ,
#if defined(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.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
newtype Typelib = Typelib (ManagedPtr Typelib)
deriving (Typelib -> Typelib -> Bool
(Typelib -> Typelib -> Bool)
-> (Typelib -> Typelib -> Bool) -> Eq Typelib
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Typelib -> Typelib -> Bool
$c/= :: Typelib -> Typelib -> Bool
== :: Typelib -> Typelib -> Bool
$c== :: Typelib -> Typelib -> Bool
Eq)
instance WrappedPtr Typelib where
wrappedPtrCalloc :: IO (Ptr Typelib)
wrappedPtrCalloc = Ptr Typelib -> IO (Ptr Typelib)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Typelib
forall a. Ptr a
nullPtr
wrappedPtrCopy :: Typelib -> IO Typelib
wrappedPtrCopy = Typelib -> IO Typelib
forall (m :: * -> *) a. Monad m => a -> m a
return
wrappedPtrFree :: Maybe (GDestroyNotify Typelib)
wrappedPtrFree = Maybe (GDestroyNotify Typelib)
forall a. Maybe a
Nothing
noTypelib :: Maybe Typelib
noTypelib :: Maybe Typelib
noTypelib = Maybe Typelib
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Typelib
type instance O.AttributeList Typelib = TypelibAttributeList
type TypelibAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_typelib_free" g_typelib_free ::
Ptr Typelib ->
IO ()
typelibFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Typelib
-> m ()
typelibFree :: Typelib -> m ()
typelibFree typelib :: Typelib
typelib = 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 Typelib
typelib' <- Typelib -> IO (Ptr Typelib)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Typelib
typelib
Ptr Typelib -> IO ()
g_typelib_free Ptr Typelib
typelib'
Typelib -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Typelib
typelib
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TypelibFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TypelibFreeMethodInfo Typelib signature where
overloadedMethod = typelibFree
#endif
foreign import ccall "g_typelib_get_namespace" g_typelib_get_namespace ::
Ptr Typelib ->
IO CString
typelibGetNamespace ::
(B.CallStack.HasCallStack, MonadIO m) =>
Typelib
-> m T.Text
typelibGetNamespace :: Typelib -> m Text
typelibGetNamespace typelib :: Typelib
typelib = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr Typelib
typelib' <- Typelib -> IO (Ptr Typelib)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Typelib
typelib
CString
result <- Ptr Typelib -> IO CString
g_typelib_get_namespace Ptr Typelib
typelib'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "typelibGetNamespace" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
Typelib -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Typelib
typelib
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data TypelibGetNamespaceMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo TypelibGetNamespaceMethodInfo Typelib signature where
overloadedMethod = typelibGetNamespace
#endif
foreign import ccall "g_typelib_symbol" g_typelib_symbol ::
Ptr Typelib ->
CString ->
Ptr () ->
IO CInt
typelibSymbol ::
(B.CallStack.HasCallStack, MonadIO m) =>
Typelib
-> T.Text
-> Ptr ()
-> m Bool
typelibSymbol :: Typelib -> Text -> Ptr () -> m Bool
typelibSymbol typelib :: Typelib
typelib symbolName :: Text
symbolName symbol :: Ptr ()
symbol = 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 Typelib
typelib' <- Typelib -> IO (Ptr Typelib)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Typelib
typelib
CString
symbolName' <- Text -> IO CString
textToCString Text
symbolName
CInt
result <- Ptr Typelib -> CString -> Ptr () -> IO CInt
g_typelib_symbol Ptr Typelib
typelib' CString
symbolName' Ptr ()
symbol
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
Typelib -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Typelib
typelib
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
symbolName'
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data TypelibSymbolMethodInfo
instance (signature ~ (T.Text -> Ptr () -> m Bool), MonadIO m) => O.MethodInfo TypelibSymbolMethodInfo Typelib signature where
overloadedMethod = typelibSymbol
#endif
#if defined(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 @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif