{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

TODO
-}

module GI.GIRepository.Structs.Typelib
    ( 

-- * Exported types
    Typelib(..)                             ,
    noTypelib                               ,


 -- * Methods
-- ** typelibFree
    typelibFree                             ,


-- ** typelibGetNamespace
    typelibGetNamespace                     ,


-- ** typelibSymbol
    typelibSymbol                           ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.GIRepository.Types
import GI.GIRepository.Callbacks

newtype Typelib = Typelib (ForeignPtr Typelib)
noTypelib :: Maybe Typelib
noTypelib = Nothing

-- method Typelib::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GIRepository" "Typelib", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GIRepository" "Typelib", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_typelib_free" g_typelib_free :: 
    Ptr Typelib ->                          -- _obj : TInterface "GIRepository" "Typelib"
    IO ()


typelibFree ::
    (MonadIO m) =>
    Typelib ->                              -- _obj
    m ()
typelibFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_typelib_free _obj'
    touchManagedPtr _obj
    return ()

-- method Typelib::get_namespace
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GIRepository" "Typelib", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GIRepository" "Typelib", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_typelib_get_namespace" g_typelib_get_namespace :: 
    Ptr Typelib ->                          -- _obj : TInterface "GIRepository" "Typelib"
    IO CString


typelibGetNamespace ::
    (MonadIO m) =>
    Typelib ->                              -- _obj
    m T.Text
typelibGetNamespace _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_typelib_get_namespace _obj'
    checkUnexpectedReturnNULL "g_typelib_get_namespace" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Typelib::symbol
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GIRepository" "Typelib", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "symbol_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "symbol", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GIRepository" "Typelib", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "symbol_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "symbol", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_typelib_symbol" g_typelib_symbol :: 
    Ptr Typelib ->                          -- _obj : TInterface "GIRepository" "Typelib"
    CString ->                              -- symbol_name : TBasicType TUTF8
    Ptr () ->                               -- symbol : TBasicType TVoid
    IO CInt


typelibSymbol ::
    (MonadIO m) =>
    Typelib ->                              -- _obj
    T.Text ->                               -- symbol_name
    Ptr () ->                               -- symbol
    m Bool
typelibSymbol _obj symbol_name symbol = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    symbol_name' <- textToCString symbol_name
    result <- g_typelib_symbol _obj' symbol_name' symbol
    let result' = (/= 0) result
    touchManagedPtr _obj
    freeMem symbol_name'
    return result'