{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.IOChannel
(
IOChannel(..) ,
newZeroIOChannel ,
noIOChannel ,
#if defined(ENABLE_OVERLOADING)
ResolveIOChannelMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
IOChannelCloseMethodInfo ,
#endif
iOChannelClose ,
iOChannelErrorFromErrno ,
iOChannelErrorQuark ,
#if defined(ENABLE_OVERLOADING)
IOChannelFlushMethodInfo ,
#endif
iOChannelFlush ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetBufferConditionMethodInfo ,
#endif
iOChannelGetBufferCondition ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetBufferSizeMethodInfo ,
#endif
iOChannelGetBufferSize ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetBufferedMethodInfo ,
#endif
iOChannelGetBuffered ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetCloseOnUnrefMethodInfo ,
#endif
iOChannelGetCloseOnUnref ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetEncodingMethodInfo ,
#endif
iOChannelGetEncoding ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetFlagsMethodInfo ,
#endif
iOChannelGetFlags ,
#if defined(ENABLE_OVERLOADING)
IOChannelGetLineTermMethodInfo ,
#endif
iOChannelGetLineTerm ,
#if defined(ENABLE_OVERLOADING)
IOChannelInitMethodInfo ,
#endif
iOChannelInit ,
iOChannelNewFile ,
#if defined(ENABLE_OVERLOADING)
IOChannelReadMethodInfo ,
#endif
iOChannelRead ,
#if defined(ENABLE_OVERLOADING)
IOChannelReadCharsMethodInfo ,
#endif
iOChannelReadChars ,
#if defined(ENABLE_OVERLOADING)
IOChannelReadLineMethodInfo ,
#endif
iOChannelReadLine ,
#if defined(ENABLE_OVERLOADING)
IOChannelReadToEndMethodInfo ,
#endif
iOChannelReadToEnd ,
#if defined(ENABLE_OVERLOADING)
IOChannelReadUnicharMethodInfo ,
#endif
iOChannelReadUnichar ,
#if defined(ENABLE_OVERLOADING)
IOChannelRefMethodInfo ,
#endif
iOChannelRef ,
#if defined(ENABLE_OVERLOADING)
IOChannelSeekMethodInfo ,
#endif
iOChannelSeek ,
#if defined(ENABLE_OVERLOADING)
IOChannelSeekPositionMethodInfo ,
#endif
iOChannelSeekPosition ,
#if defined(ENABLE_OVERLOADING)
IOChannelSetBufferSizeMethodInfo ,
#endif
iOChannelSetBufferSize ,
#if defined(ENABLE_OVERLOADING)
IOChannelSetBufferedMethodInfo ,
#endif
iOChannelSetBuffered ,
#if defined(ENABLE_OVERLOADING)
IOChannelSetCloseOnUnrefMethodInfo ,
#endif
iOChannelSetCloseOnUnref ,
#if defined(ENABLE_OVERLOADING)
IOChannelSetEncodingMethodInfo ,
#endif
iOChannelSetEncoding ,
#if defined(ENABLE_OVERLOADING)
IOChannelSetFlagsMethodInfo ,
#endif
iOChannelSetFlags ,
#if defined(ENABLE_OVERLOADING)
IOChannelSetLineTermMethodInfo ,
#endif
iOChannelSetLineTerm ,
#if defined(ENABLE_OVERLOADING)
IOChannelShutdownMethodInfo ,
#endif
iOChannelShutdown ,
#if defined(ENABLE_OVERLOADING)
IOChannelUnixGetFdMethodInfo ,
#endif
iOChannelUnixGetFd ,
iOChannelUnixNew ,
#if defined(ENABLE_OVERLOADING)
IOChannelUnrefMethodInfo ,
#endif
iOChannelUnref ,
#if defined(ENABLE_OVERLOADING)
IOChannelWriteMethodInfo ,
#endif
iOChannelWrite ,
#if defined(ENABLE_OVERLOADING)
IOChannelWriteCharsMethodInfo ,
#endif
iOChannelWriteChars ,
#if defined(ENABLE_OVERLOADING)
IOChannelWriteUnicharMethodInfo ,
#endif
iOChannelWriteUnichar ,
) 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
import {-# SOURCE #-} qualified GI.GLib.Enums as GLib.Enums
import {-# SOURCE #-} qualified GI.GLib.Flags as GLib.Flags
newtype IOChannel = IOChannel (ManagedPtr IOChannel)
deriving (IOChannel -> IOChannel -> Bool
(IOChannel -> IOChannel -> Bool)
-> (IOChannel -> IOChannel -> Bool) -> Eq IOChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IOChannel -> IOChannel -> Bool
$c/= :: IOChannel -> IOChannel -> Bool
== :: IOChannel -> IOChannel -> Bool
$c== :: IOChannel -> IOChannel -> Bool
Eq)
foreign import ccall "g_io_channel_get_type" c_g_io_channel_get_type ::
IO GType
instance BoxedObject IOChannel where
boxedType :: IOChannel -> IO GType
boxedType _ = IO GType
c_g_io_channel_get_type
instance B.GValue.IsGValue IOChannel where
toGValue :: IOChannel -> IO GValue
toGValue o :: IOChannel
o = do
GType
gtype <- IO GType
c_g_io_channel_get_type
IOChannel -> (Ptr IOChannel -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr IOChannel
o (GType
-> (GValue -> Ptr IOChannel -> IO ()) -> Ptr IOChannel -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr IOChannel -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO IOChannel
fromGValue gv :: GValue
gv = do
Ptr IOChannel
ptr <- GValue -> IO (Ptr IOChannel)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr IOChannel)
(ManagedPtr IOChannel -> IOChannel)
-> Ptr IOChannel -> IO IOChannel
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr IOChannel -> IOChannel
IOChannel Ptr IOChannel
ptr
newZeroIOChannel :: MonadIO m => m IOChannel
newZeroIOChannel :: m IOChannel
newZeroIOChannel = IO IOChannel -> m IOChannel
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOChannel -> m IOChannel) -> IO IOChannel -> m IOChannel
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr IOChannel)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 136 IO (Ptr IOChannel)
-> (Ptr IOChannel -> IO IOChannel) -> IO IOChannel
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr IOChannel -> IOChannel)
-> Ptr IOChannel -> IO IOChannel
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IOChannel -> IOChannel
IOChannel
instance tag ~ 'AttrSet => Constructible IOChannel tag where
new :: (ManagedPtr IOChannel -> IOChannel)
-> [AttrOp IOChannel tag] -> m IOChannel
new _ attrs :: [AttrOp IOChannel tag]
attrs = do
IOChannel
o <- m IOChannel
forall (m :: * -> *). MonadIO m => m IOChannel
newZeroIOChannel
IOChannel -> [AttrOp IOChannel 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set IOChannel
o [AttrOp IOChannel tag]
[AttrOp IOChannel 'AttrSet]
attrs
IOChannel -> m IOChannel
forall (m :: * -> *) a. Monad m => a -> m a
return IOChannel
o
noIOChannel :: Maybe IOChannel
noIOChannel :: Maybe IOChannel
noIOChannel = Maybe IOChannel
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList IOChannel
type instance O.AttributeList IOChannel = IOChannelAttributeList
type IOChannelAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_io_channel_new_file" g_io_channel_new_file ::
CString ->
CString ->
Ptr (Ptr GError) ->
IO (Ptr IOChannel)
iOChannelNewFile ::
(B.CallStack.HasCallStack, MonadIO m) =>
[Char]
-> T.Text
-> m IOChannel
iOChannelNewFile :: [Char] -> Text -> m IOChannel
iOChannelNewFile filename :: [Char]
filename mode :: Text
mode = IO IOChannel -> m IOChannel
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOChannel -> m IOChannel) -> IO IOChannel -> m IOChannel
forall a b. (a -> b) -> a -> b
$ do
CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
CString
mode' <- Text -> IO CString
textToCString Text
mode
IO IOChannel -> IO () -> IO IOChannel
forall a b. IO a -> IO b -> IO a
onException (do
Ptr IOChannel
result <- (Ptr (Ptr GError) -> IO (Ptr IOChannel)) -> IO (Ptr IOChannel)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr IOChannel)) -> IO (Ptr IOChannel))
-> (Ptr (Ptr GError) -> IO (Ptr IOChannel)) -> IO (Ptr IOChannel)
forall a b. (a -> b) -> a -> b
$ CString -> CString -> Ptr (Ptr GError) -> IO (Ptr IOChannel)
g_io_channel_new_file CString
filename' CString
mode'
Text -> Ptr IOChannel -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "iOChannelNewFile" Ptr IOChannel
result
IOChannel
result' <- ((ManagedPtr IOChannel -> IOChannel)
-> Ptr IOChannel -> IO IOChannel
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IOChannel -> IOChannel
IOChannel) Ptr IOChannel
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
mode'
IOChannel -> IO IOChannel
forall (m :: * -> *) a. Monad m => a -> m a
return IOChannel
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
mode'
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_io_channel_unix_new" g_io_channel_unix_new ::
Int32 ->
IO (Ptr IOChannel)
iOChannelUnixNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Int32
-> m IOChannel
iOChannelUnixNew :: Int32 -> m IOChannel
iOChannelUnixNew fd :: Int32
fd = IO IOChannel -> m IOChannel
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOChannel -> m IOChannel) -> IO IOChannel -> m IOChannel
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
result <- Int32 -> IO (Ptr IOChannel)
g_io_channel_unix_new Int32
fd
Text -> Ptr IOChannel -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "iOChannelUnixNew" Ptr IOChannel
result
IOChannel
result' <- ((ManagedPtr IOChannel -> IOChannel)
-> Ptr IOChannel -> IO IOChannel
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IOChannel -> IOChannel
IOChannel) Ptr IOChannel
result
IOChannel -> IO IOChannel
forall (m :: * -> *) a. Monad m => a -> m a
return IOChannel
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_io_channel_close" g_io_channel_close ::
Ptr IOChannel ->
IO ()
{-# DEPRECATED iOChannelClose ["(Since version 2.2)","Use 'GI.GLib.Structs.IOChannel.iOChannelShutdown' instead."] #-}
iOChannelClose ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m ()
iOChannelClose :: IOChannel -> m ()
iOChannelClose channel :: IOChannel
channel = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr IOChannel -> IO ()
g_io_channel_close Ptr IOChannel
channel'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelCloseMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo IOChannelCloseMethodInfo IOChannel signature where
overloadedMethod = iOChannelClose
#endif
foreign import ccall "g_io_channel_flush" g_io_channel_flush ::
Ptr IOChannel ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelFlush ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m GLib.Enums.IOStatus
iOChannelFlush :: IOChannel -> m IOStatus
iOChannelFlush channel :: IOChannel
channel = IO IOStatus -> m IOStatus
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOStatus -> m IOStatus) -> IO IOStatus -> m IOStatus
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
IO IOStatus -> IO () -> IO IOStatus
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_flush Ptr IOChannel
channel'
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOStatus -> IO IOStatus
forall (m :: * -> *) a. Monad m => a -> m a
return IOStatus
result'
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data IOChannelFlushMethodInfo
instance (signature ~ (m GLib.Enums.IOStatus), MonadIO m) => O.MethodInfo IOChannelFlushMethodInfo IOChannel signature where
overloadedMethod = iOChannelFlush
#endif
foreign import ccall "g_io_channel_get_buffer_condition" g_io_channel_get_buffer_condition ::
Ptr IOChannel ->
IO CUInt
iOChannelGetBufferCondition ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m [GLib.Flags.IOCondition]
iOChannelGetBufferCondition :: IOChannel -> m [IOCondition]
iOChannelGetBufferCondition channel :: IOChannel
channel = IO [IOCondition] -> m [IOCondition]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [IOCondition] -> m [IOCondition])
-> IO [IOCondition] -> m [IOCondition]
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CUInt
result <- Ptr IOChannel -> IO CUInt
g_io_channel_get_buffer_condition Ptr IOChannel
channel'
let result' :: [IOCondition]
result' = CUInt -> [IOCondition]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
[IOCondition] -> IO [IOCondition]
forall (m :: * -> *) a. Monad m => a -> m a
return [IOCondition]
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelGetBufferConditionMethodInfo
instance (signature ~ (m [GLib.Flags.IOCondition]), MonadIO m) => O.MethodInfo IOChannelGetBufferConditionMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetBufferCondition
#endif
foreign import ccall "g_io_channel_get_buffer_size" g_io_channel_get_buffer_size ::
Ptr IOChannel ->
IO Word64
iOChannelGetBufferSize ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m Word64
iOChannelGetBufferSize :: IOChannel -> m Word64
iOChannelGetBufferSize channel :: IOChannel
channel = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Word64
result <- Ptr IOChannel -> IO Word64
g_io_channel_get_buffer_size Ptr IOChannel
channel'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result
#if defined(ENABLE_OVERLOADING)
data IOChannelGetBufferSizeMethodInfo
instance (signature ~ (m Word64), MonadIO m) => O.MethodInfo IOChannelGetBufferSizeMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetBufferSize
#endif
foreign import ccall "g_io_channel_get_buffered" g_io_channel_get_buffered ::
Ptr IOChannel ->
IO CInt
iOChannelGetBuffered ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m Bool
iOChannelGetBuffered :: IOChannel -> m Bool
iOChannelGetBuffered channel :: IOChannel
channel = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CInt
result <- Ptr IOChannel -> IO CInt
g_io_channel_get_buffered Ptr IOChannel
channel'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelGetBufferedMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo IOChannelGetBufferedMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetBuffered
#endif
foreign import ccall "g_io_channel_get_close_on_unref" g_io_channel_get_close_on_unref ::
Ptr IOChannel ->
IO CInt
iOChannelGetCloseOnUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m Bool
iOChannelGetCloseOnUnref :: IOChannel -> m Bool
iOChannelGetCloseOnUnref channel :: IOChannel
channel = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CInt
result <- Ptr IOChannel -> IO CInt
g_io_channel_get_close_on_unref Ptr IOChannel
channel'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelGetCloseOnUnrefMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo IOChannelGetCloseOnUnrefMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetCloseOnUnref
#endif
foreign import ccall "g_io_channel_get_encoding" g_io_channel_get_encoding ::
Ptr IOChannel ->
IO CString
iOChannelGetEncoding ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m T.Text
iOChannelGetEncoding :: IOChannel -> m Text
iOChannelGetEncoding channel :: IOChannel
channel = 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 IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CString
result <- Ptr IOChannel -> IO CString
g_io_channel_get_encoding Ptr IOChannel
channel'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "iOChannelGetEncoding" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelGetEncodingMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo IOChannelGetEncodingMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetEncoding
#endif
foreign import ccall "g_io_channel_get_flags" g_io_channel_get_flags ::
Ptr IOChannel ->
IO CUInt
iOChannelGetFlags ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m [GLib.Flags.IOFlags]
iOChannelGetFlags :: IOChannel -> m [IOFlags]
iOChannelGetFlags channel :: IOChannel
channel = IO [IOFlags] -> m [IOFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [IOFlags] -> m [IOFlags]) -> IO [IOFlags] -> m [IOFlags]
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CUInt
result <- Ptr IOChannel -> IO CUInt
g_io_channel_get_flags Ptr IOChannel
channel'
let result' :: [IOFlags]
result' = CUInt -> [IOFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
[IOFlags] -> IO [IOFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [IOFlags]
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelGetFlagsMethodInfo
instance (signature ~ (m [GLib.Flags.IOFlags]), MonadIO m) => O.MethodInfo IOChannelGetFlagsMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetFlags
#endif
foreign import ccall "g_io_channel_get_line_term" g_io_channel_get_line_term ::
Ptr IOChannel ->
Int32 ->
IO CString
iOChannelGetLineTerm ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Int32
-> m T.Text
iOChannelGetLineTerm :: IOChannel -> Int32 -> m Text
iOChannelGetLineTerm channel :: IOChannel
channel length_ :: Int32
length_ = 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 IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CString
result <- Ptr IOChannel -> Int32 -> IO CString
g_io_channel_get_line_term Ptr IOChannel
channel' Int32
length_
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "iOChannelGetLineTerm" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelGetLineTermMethodInfo
instance (signature ~ (Int32 -> m T.Text), MonadIO m) => O.MethodInfo IOChannelGetLineTermMethodInfo IOChannel signature where
overloadedMethod = iOChannelGetLineTerm
#endif
foreign import ccall "g_io_channel_init" g_io_channel_init ::
Ptr IOChannel ->
IO ()
iOChannelInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m ()
iOChannelInit :: IOChannel -> m ()
iOChannelInit channel :: IOChannel
channel = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr IOChannel -> IO ()
g_io_channel_init Ptr IOChannel
channel'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo IOChannelInitMethodInfo IOChannel signature where
overloadedMethod = iOChannelInit
#endif
foreign import ccall "g_io_channel_read" g_io_channel_read ::
Ptr IOChannel ->
CString ->
Word64 ->
Word64 ->
IO CUInt
{-# DEPRECATED iOChannelRead ["(Since version 2.2)","Use 'GI.GLib.Structs.IOChannel.iOChannelReadChars' instead."] #-}
iOChannelRead ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> T.Text
-> Word64
-> Word64
-> m GLib.Enums.IOError
iOChannelRead :: IOChannel -> Text -> Word64 -> Word64 -> m IOError
iOChannelRead channel :: IOChannel
channel buf :: Text
buf count :: Word64
count bytesRead :: Word64
bytesRead = IO IOError -> m IOError
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOError -> m IOError) -> IO IOError -> m IOError
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CString
buf' <- Text -> IO CString
textToCString Text
buf
CUInt
result <- Ptr IOChannel -> CString -> Word64 -> Word64 -> IO CUInt
g_io_channel_read Ptr IOChannel
channel' CString
buf' Word64
count Word64
bytesRead
let result' :: IOError
result' = (Int -> IOError
forall a. Enum a => Int -> a
toEnum (Int -> IOError) -> (CUInt -> Int) -> CUInt -> IOError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
buf'
IOError -> IO IOError
forall (m :: * -> *) a. Monad m => a -> m a
return IOError
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelReadMethodInfo
instance (signature ~ (T.Text -> Word64 -> Word64 -> m GLib.Enums.IOError), MonadIO m) => O.MethodInfo IOChannelReadMethodInfo IOChannel signature where
overloadedMethod = iOChannelRead
#endif
foreign import ccall "g_io_channel_read_chars" g_io_channel_read_chars ::
Ptr IOChannel ->
Ptr Word8 ->
Word64 ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelReadChars ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> ByteString
-> m ((GLib.Enums.IOStatus, ByteString, Word64))
iOChannelReadChars :: IOChannel -> ByteString -> m (IOStatus, ByteString, Word64)
iOChannelReadChars channel :: IOChannel
channel buf :: ByteString
buf = IO (IOStatus, ByteString, Word64)
-> m (IOStatus, ByteString, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IOStatus, ByteString, Word64)
-> m (IOStatus, ByteString, Word64))
-> IO (IOStatus, ByteString, Word64)
-> m (IOStatus, ByteString, Word64)
forall a b. (a -> b) -> a -> b
$ do
let count :: Word64
count = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buf
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr Word8
buf' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buf
Ptr Word64
bytesRead <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO (IOStatus, ByteString, Word64)
-> IO () -> IO (IOStatus, ByteString, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel
-> Ptr Word8
-> Word64
-> Ptr Word64
-> Ptr (Ptr GError)
-> IO CUInt
g_io_channel_read_chars Ptr IOChannel
channel' Ptr Word8
buf' Word64
count Ptr Word64
bytesRead
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
ByteString
buf'' <- (Word64 -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength Word64
count) Ptr Word8
buf'
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buf'
Word64
bytesRead' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesRead
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesRead
(IOStatus, ByteString, Word64) -> IO (IOStatus, ByteString, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (IOStatus
result', ByteString
buf'', Word64
bytesRead')
) (do
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buf'
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesRead
)
#if defined(ENABLE_OVERLOADING)
data IOChannelReadCharsMethodInfo
instance (signature ~ (ByteString -> m ((GLib.Enums.IOStatus, ByteString, Word64))), MonadIO m) => O.MethodInfo IOChannelReadCharsMethodInfo IOChannel signature where
overloadedMethod = iOChannelReadChars
#endif
foreign import ccall "g_io_channel_read_line" g_io_channel_read_line ::
Ptr IOChannel ->
Ptr CString ->
Ptr Word64 ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelReadLine ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m ((GLib.Enums.IOStatus, T.Text, Word64, Word64))
iOChannelReadLine :: IOChannel -> m (IOStatus, Text, Word64, Word64)
iOChannelReadLine channel :: IOChannel
channel = IO (IOStatus, Text, Word64, Word64)
-> m (IOStatus, Text, Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IOStatus, Text, Word64, Word64)
-> m (IOStatus, Text, Word64, Word64))
-> IO (IOStatus, Text, Word64, Word64)
-> m (IOStatus, Text, Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr CString
strReturn <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
Ptr Word64
length_ <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
Ptr Word64
terminatorPos <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO (IOStatus, Text, Word64, Word64)
-> IO () -> IO (IOStatus, Text, Word64, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel
-> Ptr CString
-> Ptr Word64
-> Ptr Word64
-> Ptr (Ptr GError)
-> IO CUInt
g_io_channel_read_line Ptr IOChannel
channel' Ptr CString
strReturn Ptr Word64
length_ Ptr Word64
terminatorPos
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
CString
strReturn' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
strReturn
Text
strReturn'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
strReturn'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strReturn'
Word64
length_' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
length_
Word64
terminatorPos' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
terminatorPos
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
strReturn
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
length_
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
terminatorPos
(IOStatus, Text, Word64, Word64)
-> IO (IOStatus, Text, Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (IOStatus
result', Text
strReturn'', Word64
length_', Word64
terminatorPos')
) (do
Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
strReturn
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
length_
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
terminatorPos
)
#if defined(ENABLE_OVERLOADING)
data IOChannelReadLineMethodInfo
instance (signature ~ (m ((GLib.Enums.IOStatus, T.Text, Word64, Word64))), MonadIO m) => O.MethodInfo IOChannelReadLineMethodInfo IOChannel signature where
overloadedMethod = iOChannelReadLine
#endif
foreign import ccall "g_io_channel_read_to_end" g_io_channel_read_to_end ::
Ptr IOChannel ->
Ptr (Ptr Word8) ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelReadToEnd ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m ((GLib.Enums.IOStatus, ByteString))
iOChannelReadToEnd :: IOChannel -> m (IOStatus, ByteString)
iOChannelReadToEnd channel :: IOChannel
channel = IO (IOStatus, ByteString) -> m (IOStatus, ByteString)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IOStatus, ByteString) -> m (IOStatus, ByteString))
-> IO (IOStatus, ByteString) -> m (IOStatus, ByteString)
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr (Ptr Word8)
strReturn <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
Ptr Word64
length_ <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO (IOStatus, ByteString) -> IO () -> IO (IOStatus, ByteString)
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel
-> Ptr (Ptr Word8) -> Ptr Word64 -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_read_to_end Ptr IOChannel
channel' Ptr (Ptr Word8)
strReturn Ptr Word64
length_
Word64
length_' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
length_
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
Ptr Word8
strReturn' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
strReturn
ByteString
strReturn'' <- (Word64 -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength Word64
length_') Ptr Word8
strReturn'
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
strReturn'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
strReturn
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
length_
(IOStatus, ByteString) -> IO (IOStatus, ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return (IOStatus
result', ByteString
strReturn'')
) (do
Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
strReturn
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
length_
)
#if defined(ENABLE_OVERLOADING)
data IOChannelReadToEndMethodInfo
instance (signature ~ (m ((GLib.Enums.IOStatus, ByteString))), MonadIO m) => O.MethodInfo IOChannelReadToEndMethodInfo IOChannel signature where
overloadedMethod = iOChannelReadToEnd
#endif
foreign import ccall "g_io_channel_read_unichar" g_io_channel_read_unichar ::
Ptr IOChannel ->
Ptr CInt ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelReadUnichar ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m ((GLib.Enums.IOStatus, Char))
iOChannelReadUnichar :: IOChannel -> m (IOStatus, Char)
iOChannelReadUnichar channel :: IOChannel
channel = IO (IOStatus, Char) -> m (IOStatus, Char)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IOStatus, Char) -> m (IOStatus, Char))
-> IO (IOStatus, Char) -> m (IOStatus, Char)
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr CInt
thechar <- IO (Ptr CInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CInt)
IO (IOStatus, Char) -> IO () -> IO (IOStatus, Char)
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> Ptr CInt -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_read_unichar Ptr IOChannel
channel' Ptr CInt
thechar
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
CInt
thechar' <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
thechar
let thechar'' :: Char
thechar'' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
thechar'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
thechar
(IOStatus, Char) -> IO (IOStatus, Char)
forall (m :: * -> *) a. Monad m => a -> m a
return (IOStatus
result', Char
thechar'')
) (do
Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
thechar
)
#if defined(ENABLE_OVERLOADING)
data IOChannelReadUnicharMethodInfo
instance (signature ~ (m ((GLib.Enums.IOStatus, Char))), MonadIO m) => O.MethodInfo IOChannelReadUnicharMethodInfo IOChannel signature where
overloadedMethod = iOChannelReadUnichar
#endif
foreign import ccall "g_io_channel_ref" g_io_channel_ref ::
Ptr IOChannel ->
IO (Ptr IOChannel)
iOChannelRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m IOChannel
iOChannelRef :: IOChannel -> m IOChannel
iOChannelRef channel :: IOChannel
channel = IO IOChannel -> m IOChannel
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOChannel -> m IOChannel) -> IO IOChannel -> m IOChannel
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr IOChannel
result <- Ptr IOChannel -> IO (Ptr IOChannel)
g_io_channel_ref Ptr IOChannel
channel'
Text -> Ptr IOChannel -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "iOChannelRef" Ptr IOChannel
result
IOChannel
result' <- ((ManagedPtr IOChannel -> IOChannel)
-> Ptr IOChannel -> IO IOChannel
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IOChannel -> IOChannel
IOChannel) Ptr IOChannel
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOChannel -> IO IOChannel
forall (m :: * -> *) a. Monad m => a -> m a
return IOChannel
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelRefMethodInfo
instance (signature ~ (m IOChannel), MonadIO m) => O.MethodInfo IOChannelRefMethodInfo IOChannel signature where
overloadedMethod = iOChannelRef
#endif
foreign import ccall "g_io_channel_seek" g_io_channel_seek ::
Ptr IOChannel ->
Int64 ->
CUInt ->
IO CUInt
{-# DEPRECATED iOChannelSeek ["(Since version 2.2)","Use 'GI.GLib.Structs.IOChannel.iOChannelSeekPosition' instead."] #-}
iOChannelSeek ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Int64
-> GLib.Enums.SeekType
-> m GLib.Enums.IOError
iOChannelSeek :: IOChannel -> Int64 -> SeekType -> m IOError
iOChannelSeek channel :: IOChannel
channel offset :: Int64
offset type_ :: SeekType
type_ = IO IOError -> m IOError
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOError -> m IOError) -> IO IOError -> m IOError
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SeekType -> Int) -> SeekType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SeekType -> Int
forall a. Enum a => a -> Int
fromEnum) SeekType
type_
CUInt
result <- Ptr IOChannel -> Int64 -> CUInt -> IO CUInt
g_io_channel_seek Ptr IOChannel
channel' Int64
offset CUInt
type_'
let result' :: IOError
result' = (Int -> IOError
forall a. Enum a => Int -> a
toEnum (Int -> IOError) -> (CUInt -> Int) -> CUInt -> IOError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOError -> IO IOError
forall (m :: * -> *) a. Monad m => a -> m a
return IOError
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelSeekMethodInfo
instance (signature ~ (Int64 -> GLib.Enums.SeekType -> m GLib.Enums.IOError), MonadIO m) => O.MethodInfo IOChannelSeekMethodInfo IOChannel signature where
overloadedMethod = iOChannelSeek
#endif
foreign import ccall "g_io_channel_seek_position" g_io_channel_seek_position ::
Ptr IOChannel ->
Int64 ->
CUInt ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelSeekPosition ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Int64
-> GLib.Enums.SeekType
-> m GLib.Enums.IOStatus
iOChannelSeekPosition :: IOChannel -> Int64 -> SeekType -> m IOStatus
iOChannelSeekPosition channel :: IOChannel
channel offset :: Int64
offset type_ :: SeekType
type_ = IO IOStatus -> m IOStatus
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOStatus -> m IOStatus) -> IO IOStatus -> m IOStatus
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SeekType -> Int) -> SeekType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SeekType -> Int
forall a. Enum a => a -> Int
fromEnum) SeekType
type_
IO IOStatus -> IO () -> IO IOStatus
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> Int64 -> CUInt -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_seek_position Ptr IOChannel
channel' Int64
offset CUInt
type_'
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOStatus -> IO IOStatus
forall (m :: * -> *) a. Monad m => a -> m a
return IOStatus
result'
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data IOChannelSeekPositionMethodInfo
instance (signature ~ (Int64 -> GLib.Enums.SeekType -> m GLib.Enums.IOStatus), MonadIO m) => O.MethodInfo IOChannelSeekPositionMethodInfo IOChannel signature where
overloadedMethod = iOChannelSeekPosition
#endif
foreign import ccall "g_io_channel_set_buffer_size" g_io_channel_set_buffer_size ::
Ptr IOChannel ->
Word64 ->
IO ()
iOChannelSetBufferSize ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Word64
-> m ()
iOChannelSetBufferSize :: IOChannel -> Word64 -> m ()
iOChannelSetBufferSize channel :: IOChannel
channel size :: Word64
size = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr IOChannel -> Word64 -> IO ()
g_io_channel_set_buffer_size Ptr IOChannel
channel' Word64
size
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelSetBufferSizeMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m) => O.MethodInfo IOChannelSetBufferSizeMethodInfo IOChannel signature where
overloadedMethod = iOChannelSetBufferSize
#endif
foreign import ccall "g_io_channel_set_buffered" g_io_channel_set_buffered ::
Ptr IOChannel ->
CInt ->
IO ()
iOChannelSetBuffered ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Bool
-> m ()
iOChannelSetBuffered :: IOChannel -> Bool -> m ()
iOChannelSetBuffered channel :: IOChannel
channel buffered :: Bool
buffered = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let buffered' :: CInt
buffered' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
buffered
Ptr IOChannel -> CInt -> IO ()
g_io_channel_set_buffered Ptr IOChannel
channel' CInt
buffered'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelSetBufferedMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo IOChannelSetBufferedMethodInfo IOChannel signature where
overloadedMethod = iOChannelSetBuffered
#endif
foreign import ccall "g_io_channel_set_close_on_unref" g_io_channel_set_close_on_unref ::
Ptr IOChannel ->
CInt ->
IO ()
iOChannelSetCloseOnUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Bool
-> m ()
iOChannelSetCloseOnUnref :: IOChannel -> Bool -> m ()
iOChannelSetCloseOnUnref channel :: IOChannel
channel doClose :: Bool
doClose = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let doClose' :: CInt
doClose' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
doClose
Ptr IOChannel -> CInt -> IO ()
g_io_channel_set_close_on_unref Ptr IOChannel
channel' CInt
doClose'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelSetCloseOnUnrefMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo IOChannelSetCloseOnUnrefMethodInfo IOChannel signature where
overloadedMethod = iOChannelSetCloseOnUnref
#endif
foreign import ccall "g_io_channel_set_encoding" g_io_channel_set_encoding ::
Ptr IOChannel ->
CString ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelSetEncoding ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Maybe (T.Text)
-> m GLib.Enums.IOStatus
iOChannelSetEncoding :: IOChannel -> Maybe Text -> m IOStatus
iOChannelSetEncoding channel :: IOChannel
channel encoding :: Maybe Text
encoding = IO IOStatus -> m IOStatus
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOStatus -> m IOStatus) -> IO IOStatus -> m IOStatus
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CString
maybeEncoding <- case Maybe Text
encoding of
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
Just jEncoding :: Text
jEncoding -> do
CString
jEncoding' <- Text -> IO CString
textToCString Text
jEncoding
CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jEncoding'
IO IOStatus -> IO () -> IO IOStatus
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> CString -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_set_encoding Ptr IOChannel
channel' CString
maybeEncoding
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeEncoding
IOStatus -> IO IOStatus
forall (m :: * -> *) a. Monad m => a -> m a
return IOStatus
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeEncoding
)
#if defined(ENABLE_OVERLOADING)
data IOChannelSetEncodingMethodInfo
instance (signature ~ (Maybe (T.Text) -> m GLib.Enums.IOStatus), MonadIO m) => O.MethodInfo IOChannelSetEncodingMethodInfo IOChannel signature where
overloadedMethod = iOChannelSetEncoding
#endif
foreign import ccall "g_io_channel_set_flags" g_io_channel_set_flags ::
Ptr IOChannel ->
CUInt ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelSetFlags ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> [GLib.Flags.IOFlags]
-> m GLib.Enums.IOStatus
iOChannelSetFlags :: IOChannel -> [IOFlags] -> m IOStatus
iOChannelSetFlags channel :: IOChannel
channel flags :: [IOFlags]
flags = IO IOStatus -> m IOStatus
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOStatus -> m IOStatus) -> IO IOStatus -> m IOStatus
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let flags' :: CUInt
flags' = [IOFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [IOFlags]
flags
IO IOStatus -> IO () -> IO IOStatus
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> CUInt -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_set_flags Ptr IOChannel
channel' CUInt
flags'
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOStatus -> IO IOStatus
forall (m :: * -> *) a. Monad m => a -> m a
return IOStatus
result'
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data IOChannelSetFlagsMethodInfo
instance (signature ~ ([GLib.Flags.IOFlags] -> m GLib.Enums.IOStatus), MonadIO m) => O.MethodInfo IOChannelSetFlagsMethodInfo IOChannel signature where
overloadedMethod = iOChannelSetFlags
#endif
foreign import ccall "g_io_channel_set_line_term" g_io_channel_set_line_term ::
Ptr IOChannel ->
CString ->
Int32 ->
IO ()
iOChannelSetLineTerm ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Maybe (T.Text)
-> Int32
-> m ()
iOChannelSetLineTerm :: IOChannel -> Maybe Text -> Int32 -> m ()
iOChannelSetLineTerm channel :: IOChannel
channel lineTerm :: Maybe Text
lineTerm length_ :: Int32
length_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CString
maybeLineTerm <- case Maybe Text
lineTerm of
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
Just jLineTerm :: Text
jLineTerm -> do
CString
jLineTerm' <- Text -> IO CString
textToCString Text
jLineTerm
CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jLineTerm'
Ptr IOChannel -> CString -> Int32 -> IO ()
g_io_channel_set_line_term Ptr IOChannel
channel' CString
maybeLineTerm Int32
length_
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeLineTerm
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelSetLineTermMethodInfo
instance (signature ~ (Maybe (T.Text) -> Int32 -> m ()), MonadIO m) => O.MethodInfo IOChannelSetLineTermMethodInfo IOChannel signature where
overloadedMethod = iOChannelSetLineTerm
#endif
foreign import ccall "g_io_channel_shutdown" g_io_channel_shutdown ::
Ptr IOChannel ->
CInt ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelShutdown ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Bool
-> m GLib.Enums.IOStatus
iOChannelShutdown :: IOChannel -> Bool -> m IOStatus
iOChannelShutdown channel :: IOChannel
channel flush :: Bool
flush = IO IOStatus -> m IOStatus
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOStatus -> m IOStatus) -> IO IOStatus -> m IOStatus
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let flush' :: CInt
flush' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
flush
IO IOStatus -> IO () -> IO IOStatus
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> CInt -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_shutdown Ptr IOChannel
channel' CInt
flush'
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOStatus -> IO IOStatus
forall (m :: * -> *) a. Monad m => a -> m a
return IOStatus
result'
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data IOChannelShutdownMethodInfo
instance (signature ~ (Bool -> m GLib.Enums.IOStatus), MonadIO m) => O.MethodInfo IOChannelShutdownMethodInfo IOChannel signature where
overloadedMethod = iOChannelShutdown
#endif
foreign import ccall "g_io_channel_unix_get_fd" g_io_channel_unix_get_fd ::
Ptr IOChannel ->
IO Int32
iOChannelUnixGetFd ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m Int32
iOChannelUnixGetFd :: IOChannel -> m Int32
iOChannelUnixGetFd channel :: IOChannel
channel = 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 IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Int32
result <- Ptr IOChannel -> IO Int32
g_io_channel_unix_get_fd Ptr IOChannel
channel'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result
#if defined(ENABLE_OVERLOADING)
data IOChannelUnixGetFdMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo IOChannelUnixGetFdMethodInfo IOChannel signature where
overloadedMethod = iOChannelUnixGetFd
#endif
foreign import ccall "g_io_channel_unref" g_io_channel_unref ::
Ptr IOChannel ->
IO ()
iOChannelUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> m ()
iOChannelUnref :: IOChannel -> m ()
iOChannelUnref channel :: IOChannel
channel = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr IOChannel -> IO ()
g_io_channel_unref Ptr IOChannel
channel'
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data IOChannelUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo IOChannelUnrefMethodInfo IOChannel signature where
overloadedMethod = iOChannelUnref
#endif
foreign import ccall "g_io_channel_write" g_io_channel_write ::
Ptr IOChannel ->
CString ->
Word64 ->
Word64 ->
IO CUInt
{-# DEPRECATED iOChannelWrite ["(Since version 2.2)","Use 'GI.GLib.Structs.IOChannel.iOChannelWriteChars' instead."] #-}
iOChannelWrite ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> T.Text
-> Word64
-> Word64
-> m GLib.Enums.IOError
iOChannelWrite :: IOChannel -> Text -> Word64 -> Word64 -> m IOError
iOChannelWrite channel :: IOChannel
channel buf :: Text
buf count :: Word64
count bytesWritten :: Word64
bytesWritten = IO IOError -> m IOError
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOError -> m IOError) -> IO IOError -> m IOError
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
CString
buf' <- Text -> IO CString
textToCString Text
buf
CUInt
result <- Ptr IOChannel -> CString -> Word64 -> Word64 -> IO CUInt
g_io_channel_write Ptr IOChannel
channel' CString
buf' Word64
count Word64
bytesWritten
let result' :: IOError
result' = (Int -> IOError
forall a. Enum a => Int -> a
toEnum (Int -> IOError) -> (CUInt -> Int) -> CUInt -> IOError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
buf'
IOError -> IO IOError
forall (m :: * -> *) a. Monad m => a -> m a
return IOError
result'
#if defined(ENABLE_OVERLOADING)
data IOChannelWriteMethodInfo
instance (signature ~ (T.Text -> Word64 -> Word64 -> m GLib.Enums.IOError), MonadIO m) => O.MethodInfo IOChannelWriteMethodInfo IOChannel signature where
overloadedMethod = iOChannelWrite
#endif
foreign import ccall "g_io_channel_write_chars" g_io_channel_write_chars ::
Ptr IOChannel ->
Ptr Word8 ->
Int64 ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelWriteChars ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Ptr Word8
-> Int64
-> m ((GLib.Enums.IOStatus, Word64))
iOChannelWriteChars :: IOChannel -> Ptr Word8 -> Int64 -> m (IOStatus, Word64)
iOChannelWriteChars channel :: IOChannel
channel buf :: Ptr Word8
buf count :: Int64
count = IO (IOStatus, Word64) -> m (IOStatus, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IOStatus, Word64) -> m (IOStatus, Word64))
-> IO (IOStatus, Word64) -> m (IOStatus, Word64)
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO (IOStatus, Word64) -> IO () -> IO (IOStatus, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel
-> Ptr Word8 -> Int64 -> Ptr Word64 -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_write_chars Ptr IOChannel
channel' Ptr Word8
buf Int64
count Ptr Word64
bytesWritten
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
(IOStatus, Word64) -> IO (IOStatus, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (IOStatus
result', Word64
bytesWritten')
) (do
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data IOChannelWriteCharsMethodInfo
instance (signature ~ (Ptr Word8 -> Int64 -> m ((GLib.Enums.IOStatus, Word64))), MonadIO m) => O.MethodInfo IOChannelWriteCharsMethodInfo IOChannel signature where
overloadedMethod = iOChannelWriteChars
#endif
foreign import ccall "g_io_channel_write_unichar" g_io_channel_write_unichar ::
Ptr IOChannel ->
CInt ->
Ptr (Ptr GError) ->
IO CUInt
iOChannelWriteUnichar ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOChannel
-> Char
-> m GLib.Enums.IOStatus
iOChannelWriteUnichar :: IOChannel -> Char -> m IOStatus
iOChannelWriteUnichar channel :: IOChannel
channel thechar :: Char
thechar = IO IOStatus -> m IOStatus
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOStatus -> m IOStatus) -> IO IOStatus -> m IOStatus
forall a b. (a -> b) -> a -> b
$ do
Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
let thechar' :: CInt
thechar' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
thechar
IO IOStatus -> IO () -> IO IOStatus
forall a b. IO a -> IO b -> IO a
onException (do
CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr IOChannel -> CInt -> Ptr (Ptr GError) -> IO CUInt
g_io_channel_write_unichar Ptr IOChannel
channel' CInt
thechar'
let result' :: IOStatus
result' = (Int -> IOStatus
forall a. Enum a => Int -> a
toEnum (Int -> IOStatus) -> (CUInt -> Int) -> CUInt -> IOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
IOStatus -> IO IOStatus
forall (m :: * -> *) a. Monad m => a -> m a
return IOStatus
result'
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data IOChannelWriteUnicharMethodInfo
instance (signature ~ (Char -> m GLib.Enums.IOStatus), MonadIO m) => O.MethodInfo IOChannelWriteUnicharMethodInfo IOChannel signature where
overloadedMethod = iOChannelWriteUnichar
#endif
foreign import ccall "g_io_channel_error_from_errno" g_io_channel_error_from_errno ::
Int32 ->
IO CUInt
iOChannelErrorFromErrno ::
(B.CallStack.HasCallStack, MonadIO m) =>
Int32
-> m GLib.Enums.IOChannelError
iOChannelErrorFromErrno :: Int32 -> m IOChannelError
iOChannelErrorFromErrno en :: Int32
en = IO IOChannelError -> m IOChannelError
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO IOChannelError -> m IOChannelError)
-> IO IOChannelError -> m IOChannelError
forall a b. (a -> b) -> a -> b
$ do
CUInt
result <- Int32 -> IO CUInt
g_io_channel_error_from_errno Int32
en
let result' :: IOChannelError
result' = (Int -> IOChannelError
forall a. Enum a => Int -> a
toEnum (Int -> IOChannelError)
-> (CUInt -> Int) -> CUInt -> IOChannelError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
IOChannelError -> IO IOChannelError
forall (m :: * -> *) a. Monad m => a -> m a
return IOChannelError
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_io_channel_error_quark" g_io_channel_error_quark ::
IO Word32
iOChannelErrorQuark ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Word32
iOChannelErrorQuark :: m Word32
iOChannelErrorQuark = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
Word32
result <- IO Word32
g_io_channel_error_quark
Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveIOChannelMethod (t :: Symbol) (o :: *) :: * where
ResolveIOChannelMethod "close" o = IOChannelCloseMethodInfo
ResolveIOChannelMethod "flush" o = IOChannelFlushMethodInfo
ResolveIOChannelMethod "init" o = IOChannelInitMethodInfo
ResolveIOChannelMethod "read" o = IOChannelReadMethodInfo
ResolveIOChannelMethod "readChars" o = IOChannelReadCharsMethodInfo
ResolveIOChannelMethod "readLine" o = IOChannelReadLineMethodInfo
ResolveIOChannelMethod "readToEnd" o = IOChannelReadToEndMethodInfo
ResolveIOChannelMethod "readUnichar" o = IOChannelReadUnicharMethodInfo
ResolveIOChannelMethod "ref" o = IOChannelRefMethodInfo
ResolveIOChannelMethod "seek" o = IOChannelSeekMethodInfo
ResolveIOChannelMethod "seekPosition" o = IOChannelSeekPositionMethodInfo
ResolveIOChannelMethod "shutdown" o = IOChannelShutdownMethodInfo
ResolveIOChannelMethod "unixGetFd" o = IOChannelUnixGetFdMethodInfo
ResolveIOChannelMethod "unref" o = IOChannelUnrefMethodInfo
ResolveIOChannelMethod "write" o = IOChannelWriteMethodInfo
ResolveIOChannelMethod "writeChars" o = IOChannelWriteCharsMethodInfo
ResolveIOChannelMethod "writeUnichar" o = IOChannelWriteUnicharMethodInfo
ResolveIOChannelMethod "getBufferCondition" o = IOChannelGetBufferConditionMethodInfo
ResolveIOChannelMethod "getBufferSize" o = IOChannelGetBufferSizeMethodInfo
ResolveIOChannelMethod "getBuffered" o = IOChannelGetBufferedMethodInfo
ResolveIOChannelMethod "getCloseOnUnref" o = IOChannelGetCloseOnUnrefMethodInfo
ResolveIOChannelMethod "getEncoding" o = IOChannelGetEncodingMethodInfo
ResolveIOChannelMethod "getFlags" o = IOChannelGetFlagsMethodInfo
ResolveIOChannelMethod "getLineTerm" o = IOChannelGetLineTermMethodInfo
ResolveIOChannelMethod "setBufferSize" o = IOChannelSetBufferSizeMethodInfo
ResolveIOChannelMethod "setBuffered" o = IOChannelSetBufferedMethodInfo
ResolveIOChannelMethod "setCloseOnUnref" o = IOChannelSetCloseOnUnrefMethodInfo
ResolveIOChannelMethod "setEncoding" o = IOChannelSetEncodingMethodInfo
ResolveIOChannelMethod "setFlags" o = IOChannelSetFlagsMethodInfo
ResolveIOChannelMethod "setLineTerm" o = IOChannelSetLineTermMethodInfo
ResolveIOChannelMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveIOChannelMethod t IOChannel, O.MethodInfo info IOChannel p) => OL.IsLabel t (IOChannel -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif