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

    'GI.Gio.Interfaces.FileDescriptorBased.FileDescriptorBased' is implemented by streams (implementations of
    'GI.Gio.Objects.InputStream.InputStream' or 'GI.Gio.Objects.OutputStream.OutputStream') that are based on file descriptors.

    Note that @\<gio\/gfiledescriptorbased.h>@ belongs to the UNIX-specific
    GIO interfaces, thus you have to use the @gio-unix-2.0.pc@ pkg-config
    file when using it.

    /Since: 2.24/
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Gio.Interfaces.FileDescriptorBased
        (

    -- * Exported types
        FileDescriptorBased(..)                 ,
        noFileDescriptorBased                   ,
        IsFileDescriptorBased                   ,
        toFileDescriptorBased                   ,

     -- * Methods
    -- ** getFd #method:getFd#

    #if ENABLE_OVERLOADING
        FileDescriptorBasedGetFdMethodInfo      ,
    #endif
        fileDescriptorBasedGetFd                ,

        ) 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.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.Text as T
    import qualified Data.ByteString.Char8 as B
    import qualified Data.Map as Map
    import qualified Foreign.Ptr as FP

    import qualified GI.GObject.Objects.Object as GObject.Object

    -- interface FileDescriptorBased
    -- | Memory-managed wrapper type.
    newtype FileDescriptorBased = FileDescriptorBased (ManagedPtr FileDescriptorBased)
    -- | A convenience alias for `Nothing` :: `Maybe` `FileDescriptorBased`.
    noFileDescriptorBased :: Maybe FileDescriptorBased
    noFileDescriptorBased = Nothing

    #if ENABLE_OVERLOADING
    type instance O.SignalList FileDescriptorBased = FileDescriptorBasedSignalList
    type FileDescriptorBasedSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

    #endif

    foreign import ccall "g_file_descriptor_based_get_type"
        c_g_file_descriptor_based_get_type :: IO GType

    instance GObject FileDescriptorBased where
        gobjectType _ = c_g_file_descriptor_based_get_type

    -- | Type class for types which can be safely cast to `FileDescriptorBased`, for instance with `toFileDescriptorBased`.
    class GObject o => IsFileDescriptorBased o
    #if MIN_VERSION_base(4,9,0)
    instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError FileDescriptorBased a) =>
        IsFileDescriptorBased a
    #endif
    instance IsFileDescriptorBased FileDescriptorBased
    instance GObject.Object.IsObject FileDescriptorBased

    -- | Cast to `FileDescriptorBased`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
    toFileDescriptorBased :: (MonadIO m, IsFileDescriptorBased o) => o -> m FileDescriptorBased
    toFileDescriptorBased = liftIO . unsafeCastTo FileDescriptorBased

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

    #if ENABLE_OVERLOADING
    #endif

    #if ENABLE_OVERLOADING
    type family ResolveFileDescriptorBasedMethod (t :: Symbol) (o :: *) :: * where
        ResolveFileDescriptorBasedMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
        ResolveFileDescriptorBasedMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
        ResolveFileDescriptorBasedMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
        ResolveFileDescriptorBasedMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
        ResolveFileDescriptorBasedMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
        ResolveFileDescriptorBasedMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
        ResolveFileDescriptorBasedMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
        ResolveFileDescriptorBasedMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
        ResolveFileDescriptorBasedMethod "ref" o = GObject.Object.ObjectRefMethodInfo
        ResolveFileDescriptorBasedMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
        ResolveFileDescriptorBasedMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
        ResolveFileDescriptorBasedMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
        ResolveFileDescriptorBasedMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
        ResolveFileDescriptorBasedMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
        ResolveFileDescriptorBasedMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
        ResolveFileDescriptorBasedMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
        ResolveFileDescriptorBasedMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
        ResolveFileDescriptorBasedMethod "getFd" o = FileDescriptorBasedGetFdMethodInfo
        ResolveFileDescriptorBasedMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
        ResolveFileDescriptorBasedMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
        ResolveFileDescriptorBasedMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
        ResolveFileDescriptorBasedMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
        ResolveFileDescriptorBasedMethod l o = O.MethodResolutionFailed l o

    instance (info ~ ResolveFileDescriptorBasedMethod t FileDescriptorBased, O.MethodInfo info FileDescriptorBased p) => O.IsLabelProxy t (FileDescriptorBased -> p) where
        fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveFileDescriptorBasedMethod t FileDescriptorBased, O.MethodInfo info FileDescriptorBased p) => O.IsLabel t (FileDescriptorBased -> 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

    #endif

    -- method FileDescriptorBased::get_fd
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "fd_based", argType = TInterface (Name {namespace = "Gio", name = "FileDescriptorBased"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileDescriptorBased.", 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_file_descriptor_based_get_fd" g_file_descriptor_based_get_fd ::
        Ptr FileDescriptorBased ->              -- fd_based : TInterface (Name {namespace = "Gio", name = "FileDescriptorBased"})
        IO Int32

    {- |
    Gets the underlying file descriptor.

    /Since: 2.24/
    -}
    fileDescriptorBasedGetFd ::
        (B.CallStack.HasCallStack, MonadIO m, IsFileDescriptorBased a) =>
        a
        {- ^ /@fdBased@/: a 'GI.Gio.Interfaces.FileDescriptorBased.FileDescriptorBased'. -}
        -> m Int32
        {- ^ __Returns:__ The file descriptor -}
    fileDescriptorBasedGetFd fdBased = liftIO $ do
        fdBased' <- unsafeManagedPtrCastPtr fdBased
        result <- g_file_descriptor_based_get_fd fdBased'
        touchManagedPtr fdBased
        return result

    #if ENABLE_OVERLOADING
    data FileDescriptorBasedGetFdMethodInfo
    instance (signature ~ (m Int32), MonadIO m, IsFileDescriptorBased a) => O.MethodInfo FileDescriptorBasedGetFdMethodInfo a signature where
        overloadedMethod _ = fileDescriptorBasedGetFd

    #endif