{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Structs.IOExtension.IOExtension' is an opaque data structure and can only be accessed
-- using the following functions.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gio.Structs.IOExtension
    ( 

-- * Exported types
    IOExtension(..)                         ,
    noIOExtension                           ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveIOExtensionMethod                ,
#endif


-- ** getName #method:getName#

#if defined(ENABLE_OVERLOADING)
    IOExtensionGetNameMethodInfo            ,
#endif
    iOExtensionGetName                      ,


-- ** getPriority #method:getPriority#

#if defined(ENABLE_OVERLOADING)
    IOExtensionGetPriorityMethodInfo        ,
#endif
    iOExtensionGetPriority                  ,


-- ** getType #method:getType#

#if defined(ENABLE_OVERLOADING)
    IOExtensionGetTypeMethodInfo            ,
#endif
    iOExtensionGetType                      ,




    ) 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


-- | Memory-managed wrapper type.
newtype IOExtension = IOExtension (ManagedPtr IOExtension)
    deriving (IOExtension -> IOExtension -> Bool
(IOExtension -> IOExtension -> Bool)
-> (IOExtension -> IOExtension -> Bool) -> Eq IOExtension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IOExtension -> IOExtension -> Bool
$c/= :: IOExtension -> IOExtension -> Bool
== :: IOExtension -> IOExtension -> Bool
$c== :: IOExtension -> IOExtension -> Bool
Eq)
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr IOExtension where
    wrappedPtrCalloc :: IO (Ptr IOExtension)
wrappedPtrCalloc = Ptr IOExtension -> IO (Ptr IOExtension)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr IOExtension
forall a. Ptr a
nullPtr
    wrappedPtrCopy :: IOExtension -> IO IOExtension
wrappedPtrCopy = IOExtension -> IO IOExtension
forall (m :: * -> *) a. Monad m => a -> m a
return
    wrappedPtrFree :: Maybe (GDestroyNotify IOExtension)
wrappedPtrFree = Maybe (GDestroyNotify IOExtension)
forall a. Maybe a
Nothing

-- | A convenience alias for `Nothing` :: `Maybe` `IOExtension`.
noIOExtension :: Maybe IOExtension
noIOExtension :: Maybe IOExtension
noIOExtension = Maybe IOExtension
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList IOExtension
type instance O.AttributeList IOExtension = IOExtensionAttributeList
type IOExtensionAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method IOExtension::get_name
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "IOExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GIOExtension" , 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_io_extension_get_name" g_io_extension_get_name :: 
    Ptr IOExtension ->                      -- extension : TInterface (Name {namespace = "Gio", name = "IOExtension"})
    IO CString

-- | Gets the name under which /@extension@/ was registered.
-- 
-- Note that the same type may be registered as extension
-- for multiple extension points, under different names.
iOExtensionGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IOExtension
    -- ^ /@extension@/: a t'GI.Gio.Structs.IOExtension.IOExtension'
    -> m T.Text
    -- ^ __Returns:__ the name of /@extension@/.
iOExtensionGetName :: IOExtension -> m Text
iOExtensionGetName extension :: IOExtension
extension = 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 IOExtension
extension' <- IOExtension -> IO (Ptr IOExtension)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOExtension
extension
    CString
result <- Ptr IOExtension -> IO CString
g_io_extension_get_name Ptr IOExtension
extension'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "iOExtensionGetName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    IOExtension -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOExtension
extension
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data IOExtensionGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo IOExtensionGetNameMethodInfo IOExtension signature where
    overloadedMethod = iOExtensionGetName

#endif

-- method IOExtension::get_priority
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "IOExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GIOExtension" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_io_extension_get_priority" g_io_extension_get_priority :: 
    Ptr IOExtension ->                      -- extension : TInterface (Name {namespace = "Gio", name = "IOExtension"})
    IO Int32

-- | Gets the priority with which /@extension@/ was registered.
iOExtensionGetPriority ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IOExtension
    -- ^ /@extension@/: a t'GI.Gio.Structs.IOExtension.IOExtension'
    -> m Int32
    -- ^ __Returns:__ the priority of /@extension@/
iOExtensionGetPriority :: IOExtension -> m Int32
iOExtensionGetPriority extension :: IOExtension
extension = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr IOExtension
extension' <- IOExtension -> IO (Ptr IOExtension)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOExtension
extension
    Int32
result <- Ptr IOExtension -> IO Int32
g_io_extension_get_priority Ptr IOExtension
extension'
    IOExtension -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOExtension
extension
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data IOExtensionGetPriorityMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo IOExtensionGetPriorityMethodInfo IOExtension signature where
    overloadedMethod = iOExtensionGetPriority

#endif

-- method IOExtension::get_type
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "IOExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GIOExtension" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "g_io_extension_get_type" g_io_extension_get_type :: 
    Ptr IOExtension ->                      -- extension : TInterface (Name {namespace = "Gio", name = "IOExtension"})
    IO CGType

-- | Gets the type associated with /@extension@/.
iOExtensionGetType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IOExtension
    -- ^ /@extension@/: a t'GI.Gio.Structs.IOExtension.IOExtension'
    -> m GType
    -- ^ __Returns:__ the type of /@extension@/
iOExtensionGetType :: IOExtension -> m GType
iOExtensionGetType extension :: IOExtension
extension = IO GType -> m GType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GType -> m GType) -> IO GType -> m GType
forall a b. (a -> b) -> a -> b
$ do
    Ptr IOExtension
extension' <- IOExtension -> IO (Ptr IOExtension)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOExtension
extension
    CGType
result <- Ptr IOExtension -> IO CGType
g_io_extension_get_type Ptr IOExtension
extension'
    let result' :: GType
result' = CGType -> GType
GType CGType
result
    IOExtension -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOExtension
extension
    GType -> IO GType
forall (m :: * -> *) a. Monad m => a -> m a
return GType
result'

#if defined(ENABLE_OVERLOADING)
data IOExtensionGetTypeMethodInfo
instance (signature ~ (m GType), MonadIO m) => O.MethodInfo IOExtensionGetTypeMethodInfo IOExtension signature where
    overloadedMethod = iOExtensionGetType

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveIOExtensionMethod (t :: Symbol) (o :: *) :: * where
    ResolveIOExtensionMethod "getName" o = IOExtensionGetNameMethodInfo
    ResolveIOExtensionMethod "getPriority" o = IOExtensionGetPriorityMethodInfo
    ResolveIOExtensionMethod "getType" o = IOExtensionGetTypeMethodInfo
    ResolveIOExtensionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveIOExtensionMethod t IOExtension, O.MethodInfo info IOExtension p) => OL.IsLabel t (IOExtension -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif