{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Objects.SocketAddress
(
SocketAddress(..) ,
IsSocketAddress ,
toSocketAddress ,
#if defined(ENABLE_OVERLOADING)
ResolveSocketAddressMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
SocketAddressGetFamilyMethodInfo ,
#endif
socketAddressGetFamily ,
#if defined(ENABLE_OVERLOADING)
SocketAddressGetNativeSizeMethodInfo ,
#endif
socketAddressGetNativeSize ,
socketAddressNewFromNative ,
#if defined(ENABLE_OVERLOADING)
SocketAddressToNativeMethodInfo ,
#endif
socketAddressToNative ,
#if defined(ENABLE_OVERLOADING)
SocketAddressFamilyPropertyInfo ,
#endif
getSocketAddressFamily ,
#if defined(ENABLE_OVERLOADING)
socketAddressFamily ,
#endif
) 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.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Callbacks as GObject.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketAddressEnumerator as Gio.SocketAddressEnumerator
#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
#endif
newtype SocketAddress = SocketAddress (SP.ManagedPtr SocketAddress)
deriving (SocketAddress -> SocketAddress -> Bool
(SocketAddress -> SocketAddress -> Bool)
-> (SocketAddress -> SocketAddress -> Bool) -> Eq SocketAddress
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SocketAddress -> SocketAddress -> Bool
== :: SocketAddress -> SocketAddress -> Bool
$c/= :: SocketAddress -> SocketAddress -> Bool
/= :: SocketAddress -> SocketAddress -> Bool
Eq)
instance SP.ManagedPtrNewtype SocketAddress where
toManagedPtr :: SocketAddress -> ManagedPtr SocketAddress
toManagedPtr (SocketAddress ManagedPtr SocketAddress
p) = ManagedPtr SocketAddress
p
foreign import ccall "g_socket_address_get_type"
c_g_socket_address_get_type :: IO B.Types.GType
instance B.Types.TypedObject SocketAddress where
glibType :: IO GType
glibType = IO GType
c_g_socket_address_get_type
instance B.Types.GObject SocketAddress
class (SP.GObject o, O.IsDescendantOf SocketAddress o) => IsSocketAddress o
instance (SP.GObject o, O.IsDescendantOf SocketAddress o) => IsSocketAddress o
instance O.HasParentTypes SocketAddress
type instance O.ParentTypes SocketAddress = '[GObject.Object.Object, Gio.SocketConnectable.SocketConnectable]
toSocketAddress :: (MIO.MonadIO m, IsSocketAddress o) => o -> m SocketAddress
toSocketAddress :: forall (m :: * -> *) o.
(MonadIO m, IsSocketAddress o) =>
o -> m SocketAddress
toSocketAddress = IO SocketAddress -> m SocketAddress
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO SocketAddress -> m SocketAddress)
-> (o -> IO SocketAddress) -> o -> m SocketAddress
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr SocketAddress -> SocketAddress)
-> o -> IO SocketAddress
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr SocketAddress -> SocketAddress
SocketAddress
instance B.GValue.IsGValue (Maybe SocketAddress) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_socket_address_get_type
gvalueSet_ :: Ptr GValue -> Maybe SocketAddress -> IO ()
gvalueSet_ Ptr GValue
gv Maybe SocketAddress
P.Nothing = Ptr GValue -> Ptr SocketAddress -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr SocketAddress
forall a. Ptr a
FP.nullPtr :: FP.Ptr SocketAddress)
gvalueSet_ Ptr GValue
gv (P.Just SocketAddress
obj) = SocketAddress -> (Ptr SocketAddress -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr SocketAddress
obj (Ptr GValue -> Ptr SocketAddress -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe SocketAddress)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr SocketAddress)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr SocketAddress)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject SocketAddress ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveSocketAddressMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveSocketAddressMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveSocketAddressMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveSocketAddressMethod "enumerate" o = Gio.SocketConnectable.SocketConnectableEnumerateMethodInfo
ResolveSocketAddressMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveSocketAddressMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveSocketAddressMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveSocketAddressMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveSocketAddressMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveSocketAddressMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveSocketAddressMethod "proxyEnumerate" o = Gio.SocketConnectable.SocketConnectableProxyEnumerateMethodInfo
ResolveSocketAddressMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveSocketAddressMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveSocketAddressMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveSocketAddressMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveSocketAddressMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveSocketAddressMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveSocketAddressMethod "toNative" o = SocketAddressToNativeMethodInfo
ResolveSocketAddressMethod "toString" o = Gio.SocketConnectable.SocketConnectableToStringMethodInfo
ResolveSocketAddressMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveSocketAddressMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveSocketAddressMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveSocketAddressMethod "getFamily" o = SocketAddressGetFamilyMethodInfo
ResolveSocketAddressMethod "getNativeSize" o = SocketAddressGetNativeSizeMethodInfo
ResolveSocketAddressMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveSocketAddressMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveSocketAddressMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveSocketAddressMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveSocketAddressMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveSocketAddressMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveSocketAddressMethod t SocketAddress, O.OverloadedMethod info SocketAddress p) => OL.IsLabel t (SocketAddress -> 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 ~ ResolveSocketAddressMethod t SocketAddress, O.OverloadedMethod info SocketAddress p, R.HasField t SocketAddress p) => R.HasField t SocketAddress p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveSocketAddressMethod t SocketAddress, O.OverloadedMethodInfo info SocketAddress) => OL.IsLabel t (O.MethodProxy info SocketAddress) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
getSocketAddressFamily :: (MonadIO m, IsSocketAddress o) => o -> m Gio.Enums.SocketFamily
getSocketAddressFamily :: forall (m :: * -> *) o.
(MonadIO m, IsSocketAddress o) =>
o -> m SocketFamily
getSocketAddressFamily o
obj = IO SocketFamily -> m SocketFamily
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO SocketFamily -> m SocketFamily)
-> IO SocketFamily -> m SocketFamily
forall a b. (a -> b) -> a -> b
$ o -> String -> IO SocketFamily
forall a b. (GObject a, Enum b, BoxedEnum b) => a -> String -> IO b
B.Properties.getObjectPropertyEnum o
obj String
"family"
#if defined(ENABLE_OVERLOADING)
data SocketAddressFamilyPropertyInfo
instance AttrInfo SocketAddressFamilyPropertyInfo where
type AttrAllowedOps SocketAddressFamilyPropertyInfo = '[ 'AttrGet]
type AttrBaseTypeConstraint SocketAddressFamilyPropertyInfo = IsSocketAddress
type AttrSetTypeConstraint SocketAddressFamilyPropertyInfo = (~) ()
type AttrTransferTypeConstraint SocketAddressFamilyPropertyInfo = (~) ()
type AttrTransferType SocketAddressFamilyPropertyInfo = ()
type AttrGetType SocketAddressFamilyPropertyInfo = Gio.Enums.SocketFamily
type AttrLabel SocketAddressFamilyPropertyInfo = "family"
type AttrOrigin SocketAddressFamilyPropertyInfo = SocketAddress
attrGet = getSocketAddressFamily
attrSet = undefined
attrTransfer _ = undefined
attrConstruct = undefined
attrClear = undefined
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.SocketAddress.family"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-SocketAddress.html#g:attr:family"
})
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList SocketAddress
type instance O.AttributeList SocketAddress = SocketAddressAttributeList
type SocketAddressAttributeList = ('[ '("family", SocketAddressFamilyPropertyInfo)] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
socketAddressFamily :: AttrLabelProxy "family"
socketAddressFamily = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList SocketAddress = SocketAddressSignalList
type SocketAddressSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_socket_address_new_from_native" g_socket_address_new_from_native ::
Ptr () ->
FCT.CSize ->
IO (Ptr SocketAddress)
socketAddressNewFromNative ::
(B.CallStack.HasCallStack, MonadIO m) =>
Ptr ()
-> FCT.CSize
-> m SocketAddress
socketAddressNewFromNative :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> CSize -> m SocketAddress
socketAddressNewFromNative Ptr ()
native CSize
len = IO SocketAddress -> m SocketAddress
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SocketAddress -> m SocketAddress)
-> IO SocketAddress -> m SocketAddress
forall a b. (a -> b) -> a -> b
$ do
result <- Ptr () -> CSize -> IO (Ptr SocketAddress)
g_socket_address_new_from_native Ptr ()
native CSize
len
checkUnexpectedReturnNULL "socketAddressNewFromNative" result
result' <- (wrapObject SocketAddress) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_socket_address_get_family" g_socket_address_get_family ::
Ptr SocketAddress ->
IO CUInt
socketAddressGetFamily ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketAddress a) =>
a
-> m Gio.Enums.SocketFamily
socketAddressGetFamily :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocketAddress a) =>
a -> m SocketFamily
socketAddressGetFamily a
address = IO SocketFamily -> m SocketFamily
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SocketFamily -> m SocketFamily)
-> IO SocketFamily -> m SocketFamily
forall a b. (a -> b) -> a -> b
$ do
address' <- a -> IO (Ptr SocketAddress)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
address
result <- g_socket_address_get_family address'
let result' = (Int -> SocketFamily
forall a. Enum a => Int -> a
toEnum (Int -> SocketFamily) -> (CUInt -> Int) -> CUInt -> SocketFamily
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
touchManagedPtr address
return result'
#if defined(ENABLE_OVERLOADING)
data SocketAddressGetFamilyMethodInfo
instance (signature ~ (m Gio.Enums.SocketFamily), MonadIO m, IsSocketAddress a) => O.OverloadedMethod SocketAddressGetFamilyMethodInfo a signature where
overloadedMethod = socketAddressGetFamily
instance O.OverloadedMethodInfo SocketAddressGetFamilyMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.SocketAddress.socketAddressGetFamily",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-SocketAddress.html#v:socketAddressGetFamily"
})
#endif
foreign import ccall "g_socket_address_get_native_size" g_socket_address_get_native_size ::
Ptr SocketAddress ->
IO DI.Int64
socketAddressGetNativeSize ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketAddress a) =>
a
-> m DI.Int64
socketAddressGetNativeSize :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocketAddress a) =>
a -> m Int64
socketAddressGetNativeSize a
address = IO Int64 -> m Int64
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
address' <- a -> IO (Ptr SocketAddress)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
address
result <- g_socket_address_get_native_size address'
touchManagedPtr address
return result
#if defined(ENABLE_OVERLOADING)
data SocketAddressGetNativeSizeMethodInfo
instance (signature ~ (m DI.Int64), MonadIO m, IsSocketAddress a) => O.OverloadedMethod SocketAddressGetNativeSizeMethodInfo a signature where
overloadedMethod = socketAddressGetNativeSize
instance O.OverloadedMethodInfo SocketAddressGetNativeSizeMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.SocketAddress.socketAddressGetNativeSize",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-SocketAddress.html#v:socketAddressGetNativeSize"
})
#endif
foreign import ccall "g_socket_address_to_native" g_socket_address_to_native ::
Ptr SocketAddress ->
Ptr () ->
FCT.CSize ->
Ptr (Ptr GError) ->
IO CInt
socketAddressToNative ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketAddress a) =>
a
-> Ptr ()
-> FCT.CSize
-> m ()
socketAddressToNative :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocketAddress a) =>
a -> Ptr () -> CSize -> m ()
socketAddressToNative a
address Ptr ()
dest CSize
destlen = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
address' <- a -> IO (Ptr SocketAddress)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
address
onException (do
_ <- propagateGError $ g_socket_address_to_native address' dest destlen
touchManagedPtr address
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data SocketAddressToNativeMethodInfo
instance (signature ~ (Ptr () -> FCT.CSize -> m ()), MonadIO m, IsSocketAddress a) => O.OverloadedMethod SocketAddressToNativeMethodInfo a signature where
overloadedMethod = socketAddressToNative
instance O.OverloadedMethodInfo SocketAddressToNativeMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.SocketAddress.socketAddressToNative",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-SocketAddress.html#v:socketAddressToNative"
})
#endif