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

module GI.GObject.Objects.TypeModule
    ( 

-- * Exported types
    TypeModule(..)                          ,
    TypeModuleK                             ,
    toTypeModule                            ,
    noTypeModule                            ,


 -- * Methods
-- ** typeModuleAddInterface
    typeModuleAddInterface                  ,


-- ** typeModuleRegisterEnum
    typeModuleRegisterEnum                  ,


-- ** typeModuleRegisterFlags
    typeModuleRegisterFlags                 ,


-- ** typeModuleRegisterType
    typeModuleRegisterType                  ,


-- ** typeModuleSetName
    typeModuleSetName                       ,


-- ** typeModuleUnuse
    typeModuleUnuse                         ,


-- ** typeModuleUse
    typeModuleUse                           ,




    ) 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.GObject.Types
import GI.GObject.Callbacks

newtype TypeModule = TypeModule (ForeignPtr TypeModule)
foreign import ccall "g_type_module_get_type"
    c_g_type_module_get_type :: IO GType

type instance ParentTypes TypeModule = TypeModuleParentTypes
type TypeModuleParentTypes = '[Object, TypePlugin]

instance GObject TypeModule where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_type_module_get_type
    

class GObject o => TypeModuleK o
instance (GObject o, IsDescendantOf TypeModule o) => TypeModuleK o

toTypeModule :: TypeModuleK o => o -> IO TypeModule
toTypeModule = unsafeCastTo TypeModule

noTypeModule :: Maybe TypeModule
noTypeModule = Nothing

type instance AttributeList TypeModule = TypeModuleAttributeList
type TypeModuleAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList TypeModule = TypeModuleSignalList
type TypeModuleSignalList = ('[ '("notify", ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method TypeModule::add_interface
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "instance_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interface_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interface_info", argType = TInterface "GObject" "InterfaceInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "instance_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interface_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interface_info", argType = TInterface "GObject" "InterfaceInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_type_module_add_interface" g_type_module_add_interface :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    CGType ->                               -- instance_type : TBasicType TGType
    CGType ->                               -- interface_type : TBasicType TGType
    Ptr InterfaceInfo ->                    -- interface_info : TInterface "GObject" "InterfaceInfo"
    IO ()


typeModuleAddInterface ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    GType ->                                -- instance_type
    GType ->                                -- interface_type
    InterfaceInfo ->                        -- interface_info
    m ()
typeModuleAddInterface _obj instance_type interface_type interface_info = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let instance_type' = gtypeToCGType instance_type
    let interface_type' = gtypeToCGType interface_type
    let interface_info' = unsafeManagedPtrGetPtr interface_info
    g_type_module_add_interface _obj' instance_type' interface_type' interface_info'
    touchManagedPtr _obj
    touchManagedPtr interface_info
    return ()

-- method TypeModule::register_enum
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "const_static_values", argType = TInterface "GObject" "EnumValue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "const_static_values", argType = TInterface "GObject" "EnumValue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TGType
-- throws : False
-- Skip return : False

foreign import ccall "g_type_module_register_enum" g_type_module_register_enum :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    CString ->                              -- name : TBasicType TUTF8
    Ptr EnumValue ->                        -- const_static_values : TInterface "GObject" "EnumValue"
    IO CGType


typeModuleRegisterEnum ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- name
    EnumValue ->                            -- const_static_values
    m GType
typeModuleRegisterEnum _obj name const_static_values = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    name' <- textToCString name
    let const_static_values' = unsafeManagedPtrGetPtr const_static_values
    result <- g_type_module_register_enum _obj' name' const_static_values'
    let result' = GType result
    touchManagedPtr _obj
    touchManagedPtr const_static_values
    freeMem name'
    return result'

-- method TypeModule::register_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "const_static_values", argType = TInterface "GObject" "FlagsValue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "const_static_values", argType = TInterface "GObject" "FlagsValue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TGType
-- throws : False
-- Skip return : False

foreign import ccall "g_type_module_register_flags" g_type_module_register_flags :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    CString ->                              -- name : TBasicType TUTF8
    Ptr FlagsValue ->                       -- const_static_values : TInterface "GObject" "FlagsValue"
    IO CGType


typeModuleRegisterFlags ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- name
    FlagsValue ->                           -- const_static_values
    m GType
typeModuleRegisterFlags _obj name const_static_values = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    name' <- textToCString name
    let const_static_values' = unsafeManagedPtrGetPtr const_static_values
    result <- g_type_module_register_flags _obj' name' const_static_values'
    let result' = GType result
    touchManagedPtr _obj
    touchManagedPtr const_static_values
    freeMem name'
    return result'

-- method TypeModule::register_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parent_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type_info", argType = TInterface "GObject" "TypeInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "GObject" "TypeFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "TypeModule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parent_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type_info", argType = TInterface "GObject" "TypeInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "GObject" "TypeFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TGType
-- throws : False
-- Skip return : False

foreign import ccall "g_type_module_register_type" g_type_module_register_type :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    CGType ->                               -- parent_type : TBasicType TGType
    CString ->                              -- type_name : TBasicType TUTF8
    Ptr TypeInfo ->                         -- type_info : TInterface "GObject" "TypeInfo"
    CUInt ->                                -- flags : TInterface "GObject" "TypeFlags"
    IO CGType


typeModuleRegisterType ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    GType ->                                -- parent_type
    T.Text ->                               -- type_name
    TypeInfo ->                             -- type_info
    [TypeFlags] ->                          -- flags
    m GType
typeModuleRegisterType _obj parent_type type_name type_info flags = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let parent_type' = gtypeToCGType parent_type
    type_name' <- textToCString type_name
    let type_info' = unsafeManagedPtrGetPtr type_info
    let flags' = gflagsToWord flags
    result <- g_type_module_register_type _obj' parent_type' type_name' type_info' flags'
    let result' = GType result
    touchManagedPtr _obj
    touchManagedPtr type_info
    freeMem type_name'
    return result'

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

foreign import ccall "g_type_module_set_name" g_type_module_set_name :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    CString ->                              -- name : TBasicType TUTF8
    IO ()


typeModuleSetName ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- name
    m ()
typeModuleSetName _obj name = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    name' <- textToCString name
    g_type_module_set_name _obj' name'
    touchManagedPtr _obj
    freeMem name'
    return ()

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

foreign import ccall "g_type_module_unuse" g_type_module_unuse :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    IO ()


typeModuleUnuse ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    m ()
typeModuleUnuse _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_type_module_unuse _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "g_type_module_use" g_type_module_use :: 
    Ptr TypeModule ->                       -- _obj : TInterface "GObject" "TypeModule"
    IO CInt


typeModuleUse ::
    (MonadIO m, TypeModuleK a) =>
    a ->                                    -- _obj
    m Bool
typeModuleUse _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_type_module_use _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'