{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Objects.UnixFDList
(
UnixFDList(..) ,
IsUnixFDList ,
toUnixFDList ,
#if defined(ENABLE_OVERLOADING)
ResolveUnixFDListMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
UnixFDListAppendMethodInfo ,
#endif
unixFDListAppend ,
#if defined(ENABLE_OVERLOADING)
UnixFDListGetMethodInfo ,
#endif
unixFDListGet ,
#if defined(ENABLE_OVERLOADING)
UnixFDListGetLengthMethodInfo ,
#endif
unixFDListGetLength ,
unixFDListNew ,
unixFDListNewFromArray ,
#if defined(ENABLE_OVERLOADING)
UnixFDListPeekFdsMethodInfo ,
#endif
unixFDListPeekFds ,
#if defined(ENABLE_OVERLOADING)
UnixFDListStealFdsMethodInfo ,
#endif
unixFDListStealFds ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GObject.Objects.Object as GObject.Object
#else
import qualified GI.GObject.Objects.Object as GObject.Object
#endif
newtype UnixFDList = UnixFDList (SP.ManagedPtr UnixFDList)
deriving (UnixFDList -> UnixFDList -> Bool
(UnixFDList -> UnixFDList -> Bool)
-> (UnixFDList -> UnixFDList -> Bool) -> Eq UnixFDList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnixFDList -> UnixFDList -> Bool
== :: UnixFDList -> UnixFDList -> Bool
$c/= :: UnixFDList -> UnixFDList -> Bool
/= :: UnixFDList -> UnixFDList -> Bool
Eq)
instance SP.ManagedPtrNewtype UnixFDList where
toManagedPtr :: UnixFDList -> ManagedPtr UnixFDList
toManagedPtr (UnixFDList ManagedPtr UnixFDList
p) = ManagedPtr UnixFDList
p
foreign import ccall "g_unix_fd_list_get_type"
c_g_unix_fd_list_get_type :: IO B.Types.GType
instance B.Types.TypedObject UnixFDList where
glibType :: IO GType
glibType = IO GType
c_g_unix_fd_list_get_type
instance B.Types.GObject UnixFDList
class (SP.GObject o, O.IsDescendantOf UnixFDList o) => IsUnixFDList o
instance (SP.GObject o, O.IsDescendantOf UnixFDList o) => IsUnixFDList o
instance O.HasParentTypes UnixFDList
type instance O.ParentTypes UnixFDList = '[GObject.Object.Object]
toUnixFDList :: (MIO.MonadIO m, IsUnixFDList o) => o -> m UnixFDList
toUnixFDList :: forall (m :: * -> *) o.
(MonadIO m, IsUnixFDList o) =>
o -> m UnixFDList
toUnixFDList = IO UnixFDList -> m UnixFDList
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO UnixFDList -> m UnixFDList)
-> (o -> IO UnixFDList) -> o -> m UnixFDList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr UnixFDList -> UnixFDList) -> o -> IO UnixFDList
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr UnixFDList -> UnixFDList
UnixFDList
instance B.GValue.IsGValue (Maybe UnixFDList) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_unix_fd_list_get_type
gvalueSet_ :: Ptr GValue -> Maybe UnixFDList -> IO ()
gvalueSet_ Ptr GValue
gv Maybe UnixFDList
P.Nothing = Ptr GValue -> Ptr UnixFDList -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr UnixFDList
forall a. Ptr a
FP.nullPtr :: FP.Ptr UnixFDList)
gvalueSet_ Ptr GValue
gv (P.Just UnixFDList
obj) = UnixFDList -> (Ptr UnixFDList -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr UnixFDList
obj (Ptr GValue -> Ptr UnixFDList -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe UnixFDList)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr UnixFDList)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr UnixFDList)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject UnixFDList ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveUnixFDListMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveUnixFDListMethod "append" o = UnixFDListAppendMethodInfo
ResolveUnixFDListMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveUnixFDListMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveUnixFDListMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveUnixFDListMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveUnixFDListMethod "get" o = UnixFDListGetMethodInfo
ResolveUnixFDListMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveUnixFDListMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveUnixFDListMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveUnixFDListMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveUnixFDListMethod "peekFds" o = UnixFDListPeekFdsMethodInfo
ResolveUnixFDListMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveUnixFDListMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveUnixFDListMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveUnixFDListMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveUnixFDListMethod "stealFds" o = UnixFDListStealFdsMethodInfo
ResolveUnixFDListMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveUnixFDListMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveUnixFDListMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveUnixFDListMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveUnixFDListMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveUnixFDListMethod "getLength" o = UnixFDListGetLengthMethodInfo
ResolveUnixFDListMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveUnixFDListMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveUnixFDListMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveUnixFDListMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveUnixFDListMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveUnixFDListMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveUnixFDListMethod t UnixFDList, O.OverloadedMethod info UnixFDList p) => OL.IsLabel t (UnixFDList -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveUnixFDListMethod t UnixFDList, O.OverloadedMethod info UnixFDList p, R.HasField t UnixFDList p) => R.HasField t UnixFDList p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveUnixFDListMethod t UnixFDList, O.OverloadedMethodInfo info UnixFDList) => OL.IsLabel t (O.MethodProxy info UnixFDList) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList UnixFDList
type instance O.AttributeList UnixFDList = UnixFDListAttributeList
type UnixFDListAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList UnixFDList = UnixFDListSignalList
type UnixFDListSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_unix_fd_list_new" g_unix_fd_list_new ::
IO (Ptr UnixFDList)
unixFDListNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
m UnixFDList
unixFDListNew :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m UnixFDList
unixFDListNew = IO UnixFDList -> m UnixFDList
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnixFDList -> m UnixFDList) -> IO UnixFDList -> m UnixFDList
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr UnixFDList)
g_unix_fd_list_new
checkUnexpectedReturnNULL "unixFDListNew" result
result' <- (wrapObject UnixFDList) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_unix_fd_list_new_from_array" g_unix_fd_list_new_from_array ::
Ptr Int32 ->
Int32 ->
IO (Ptr UnixFDList)
unixFDListNewFromArray ::
(B.CallStack.HasCallStack, MonadIO m) =>
[Int32]
-> m UnixFDList
unixFDListNewFromArray :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[Int32] -> m UnixFDList
unixFDListNewFromArray [Int32]
fds = IO UnixFDList -> m UnixFDList
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnixFDList -> m UnixFDList) -> IO UnixFDList -> m UnixFDList
forall a b. (a -> b) -> a -> b
$ do
let nFds :: Int32
nFds = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> Int -> Int32
forall a b. (a -> b) -> a -> b
$ [Int32] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Int32]
fds
fds' <- [Int32] -> IO (Ptr Int32)
forall a. Storable a => [a] -> IO (Ptr a)
packStorableArray [Int32]
fds
result <- g_unix_fd_list_new_from_array fds' nFds
checkUnexpectedReturnNULL "unixFDListNewFromArray" result
result' <- (wrapObject UnixFDList) result
freeMem fds'
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_unix_fd_list_append" g_unix_fd_list_append ::
Ptr UnixFDList ->
Int32 ->
Ptr (Ptr GError) ->
IO Int32
unixFDListAppend ::
(B.CallStack.HasCallStack, MonadIO m, IsUnixFDList a) =>
a
-> Int32
-> m Int32
unixFDListAppend :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsUnixFDList a) =>
a -> Int32 -> m Int32
unixFDListAppend a
list Int32
fd = IO Int32 -> m Int32
forall a. IO a -> m a
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
list' <- a -> IO (Ptr UnixFDList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
onException (do
result <- propagateGError $ g_unix_fd_list_append list' fd
touchManagedPtr list
return result
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data UnixFDListAppendMethodInfo
instance (signature ~ (Int32 -> m Int32), MonadIO m, IsUnixFDList a) => O.OverloadedMethod UnixFDListAppendMethodInfo a signature where
overloadedMethod = unixFDListAppend
instance O.OverloadedMethodInfo UnixFDListAppendMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.UnixFDList.unixFDListAppend",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-UnixFDList.html#v:unixFDListAppend"
})
#endif
foreign import ccall "g_unix_fd_list_get" g_unix_fd_list_get ::
Ptr UnixFDList ->
Int32 ->
Ptr (Ptr GError) ->
IO Int32
unixFDListGet ::
(B.CallStack.HasCallStack, MonadIO m, IsUnixFDList a) =>
a
-> Int32
-> m Int32
unixFDListGet :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsUnixFDList a) =>
a -> Int32 -> m Int32
unixFDListGet a
list Int32
index_ = IO Int32 -> m Int32
forall a. IO a -> m a
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
list' <- a -> IO (Ptr UnixFDList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
onException (do
result <- propagateGError $ g_unix_fd_list_get list' index_
touchManagedPtr list
return result
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data UnixFDListGetMethodInfo
instance (signature ~ (Int32 -> m Int32), MonadIO m, IsUnixFDList a) => O.OverloadedMethod UnixFDListGetMethodInfo a signature where
overloadedMethod = unixFDListGet
instance O.OverloadedMethodInfo UnixFDListGetMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.UnixFDList.unixFDListGet",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-UnixFDList.html#v:unixFDListGet"
})
#endif
foreign import ccall "g_unix_fd_list_get_length" g_unix_fd_list_get_length ::
Ptr UnixFDList ->
IO Int32
unixFDListGetLength ::
(B.CallStack.HasCallStack, MonadIO m, IsUnixFDList a) =>
a
-> m Int32
unixFDListGetLength :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsUnixFDList a) =>
a -> m Int32
unixFDListGetLength a
list = IO Int32 -> m Int32
forall a. IO a -> m a
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
list' <- a -> IO (Ptr UnixFDList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
result <- g_unix_fd_list_get_length list'
touchManagedPtr list
return result
#if defined(ENABLE_OVERLOADING)
data UnixFDListGetLengthMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsUnixFDList a) => O.OverloadedMethod UnixFDListGetLengthMethodInfo a signature where
overloadedMethod = unixFDListGetLength
instance O.OverloadedMethodInfo UnixFDListGetLengthMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.UnixFDList.unixFDListGetLength",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-UnixFDList.html#v:unixFDListGetLength"
})
#endif
foreign import ccall "g_unix_fd_list_peek_fds" g_unix_fd_list_peek_fds ::
Ptr UnixFDList ->
Ptr Int32 ->
IO (Ptr Int32)
unixFDListPeekFds ::
(B.CallStack.HasCallStack, MonadIO m, IsUnixFDList a) =>
a
-> m [Int32]
unixFDListPeekFds :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsUnixFDList a) =>
a -> m [Int32]
unixFDListPeekFds a
list = IO [Int32] -> m [Int32]
forall a. IO a -> m a
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
list' <- a -> IO (Ptr UnixFDList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
length_ <- allocMem :: IO (Ptr Int32)
result <- g_unix_fd_list_peek_fds list' length_
length_' <- peek length_
checkUnexpectedReturnNULL "unixFDListPeekFds" result
result' <- (unpackStorableArrayWithLength length_') result
touchManagedPtr list
freeMem length_
return result'
#if defined(ENABLE_OVERLOADING)
data UnixFDListPeekFdsMethodInfo
instance (signature ~ (m [Int32]), MonadIO m, IsUnixFDList a) => O.OverloadedMethod UnixFDListPeekFdsMethodInfo a signature where
overloadedMethod = unixFDListPeekFds
instance O.OverloadedMethodInfo UnixFDListPeekFdsMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.UnixFDList.unixFDListPeekFds",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-UnixFDList.html#v:unixFDListPeekFds"
})
#endif
foreign import ccall "g_unix_fd_list_steal_fds" g_unix_fd_list_steal_fds ::
Ptr UnixFDList ->
Ptr Int32 ->
IO (Ptr Int32)
unixFDListStealFds ::
(B.CallStack.HasCallStack, MonadIO m, IsUnixFDList a) =>
a
-> m [Int32]
unixFDListStealFds :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsUnixFDList a) =>
a -> m [Int32]
unixFDListStealFds a
list = IO [Int32] -> m [Int32]
forall a. IO a -> m a
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
list' <- a -> IO (Ptr UnixFDList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
length_ <- allocMem :: IO (Ptr Int32)
result <- g_unix_fd_list_steal_fds list' length_
length_' <- peek length_
checkUnexpectedReturnNULL "unixFDListStealFds" result
result' <- (unpackStorableArrayWithLength length_') result
freeMem result
touchManagedPtr list
freeMem length_
return result'
#if defined(ENABLE_OVERLOADING)
data UnixFDListStealFdsMethodInfo
instance (signature ~ (m [Int32]), MonadIO m, IsUnixFDList a) => O.OverloadedMethod UnixFDListStealFdsMethodInfo a signature where
overloadedMethod = unixFDListStealFds
instance O.OverloadedMethodInfo UnixFDListStealFdsMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.UnixFDList.unixFDListStealFds",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-UnixFDList.html#v:unixFDListStealFds"
})
#endif