{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.MappedFile
(
MappedFile(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveMappedFileMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
MappedFileFreeMethodInfo ,
#endif
mappedFileFree ,
#if defined(ENABLE_OVERLOADING)
MappedFileGetBytesMethodInfo ,
#endif
mappedFileGetBytes ,
#if defined(ENABLE_OVERLOADING)
MappedFileGetContentsMethodInfo ,
#endif
mappedFileGetContents ,
#if defined(ENABLE_OVERLOADING)
MappedFileGetLengthMethodInfo ,
#endif
mappedFileGetLength ,
mappedFileNew ,
mappedFileNewFromFd ,
#if defined(ENABLE_OVERLOADING)
MappedFileRefMethodInfo ,
#endif
mappedFileRef ,
#if defined(ENABLE_OVERLOADING)
MappedFileUnrefMethodInfo ,
#endif
mappedFileUnref ,
) 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 {-# SOURCE #-} qualified GI.GLib.Structs.Bytes as GLib.Bytes
newtype MappedFile = MappedFile (SP.ManagedPtr MappedFile)
deriving (MappedFile -> MappedFile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MappedFile -> MappedFile -> Bool
$c/= :: MappedFile -> MappedFile -> Bool
== :: MappedFile -> MappedFile -> Bool
$c== :: MappedFile -> MappedFile -> Bool
Eq)
instance SP.ManagedPtrNewtype MappedFile where
toManagedPtr :: MappedFile -> ManagedPtr MappedFile
toManagedPtr (MappedFile ManagedPtr MappedFile
p) = ManagedPtr MappedFile
p
foreign import ccall "g_mapped_file_get_type" c_g_mapped_file_get_type ::
IO GType
type instance O.ParentTypes MappedFile = '[]
instance O.HasParentTypes MappedFile
instance B.Types.TypedObject MappedFile where
glibType :: IO GType
glibType = IO GType
c_g_mapped_file_get_type
instance B.Types.GBoxed MappedFile
instance B.GValue.IsGValue (Maybe MappedFile) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_mapped_file_get_type
gvalueSet_ :: Ptr GValue -> Maybe MappedFile -> IO ()
gvalueSet_ Ptr GValue
gv Maybe MappedFile
P.Nothing = forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (forall a. Ptr a
FP.nullPtr :: FP.Ptr MappedFile)
gvalueSet_ Ptr GValue
gv (P.Just MappedFile
obj) = forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr MappedFile
obj (forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe MappedFile)
gvalueGet_ Ptr GValue
gv = do
Ptr MappedFile
ptr <- forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr MappedFile)
if Ptr MappedFile
ptr forall a. Eq a => a -> a -> Bool
/= forall a. Ptr a
FP.nullPtr
then forall a. a -> Maybe a
P.Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr MappedFile -> MappedFile
MappedFile Ptr MappedFile
ptr
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList MappedFile
type instance O.AttributeList MappedFile = MappedFileAttributeList
type MappedFileAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_mapped_file_new" g_mapped_file_new ::
CString ->
CInt ->
Ptr (Ptr GError) ->
IO (Ptr MappedFile)
mappedFileNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
[Char]
-> Bool
-> m MappedFile
mappedFileNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[Char] -> Bool -> m MappedFile
mappedFileNew [Char]
filename Bool
writable = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
let writable' :: CInt
writable' = (forall a b. (Integral a, Num b) => a -> b
P.fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => a -> Int
P.fromEnum) Bool
writable
forall a b. IO a -> IO b -> IO a
onException (do
Ptr MappedFile
result <- forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError forall a b. (a -> b) -> a -> b
$ CString -> CInt -> Ptr (Ptr GError) -> IO (Ptr MappedFile)
g_mapped_file_new CString
filename' CInt
writable'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mappedFileNew" Ptr MappedFile
result
MappedFile
result' <- (forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MappedFile -> MappedFile
MappedFile) Ptr MappedFile
result
forall a. Ptr a -> IO ()
freeMem CString
filename'
forall (m :: * -> *) a. Monad m => a -> m a
return MappedFile
result'
) (do
forall a. Ptr a -> IO ()
freeMem CString
filename'
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_mapped_file_new_from_fd" g_mapped_file_new_from_fd ::
Int32 ->
CInt ->
Ptr (Ptr GError) ->
IO (Ptr MappedFile)
mappedFileNewFromFd ::
(B.CallStack.HasCallStack, MonadIO m) =>
Int32
-> Bool
-> m MappedFile
mappedFileNewFromFd :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Int32 -> Bool -> m MappedFile
mappedFileNewFromFd Int32
fd Bool
writable = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
let writable' :: CInt
writable' = (forall a b. (Integral a, Num b) => a -> b
P.fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => a -> Int
P.fromEnum) Bool
writable
forall a b. IO a -> IO b -> IO a
onException (do
Ptr MappedFile
result <- forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError forall a b. (a -> b) -> a -> b
$ Int32 -> CInt -> Ptr (Ptr GError) -> IO (Ptr MappedFile)
g_mapped_file_new_from_fd Int32
fd CInt
writable'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mappedFileNewFromFd" Ptr MappedFile
result
MappedFile
result' <- (forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MappedFile -> MappedFile
MappedFile) Ptr MappedFile
result
forall (m :: * -> *) a. Monad m => a -> m a
return MappedFile
result'
) (do
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_mapped_file_free" g_mapped_file_free ::
Ptr MappedFile ->
IO ()
{-# DEPRECATED mappedFileFree ["(Since version 2.22)","Use 'GI.GLib.Structs.MappedFile.mappedFileUnref' instead."] #-}
mappedFileFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
MappedFile
-> m ()
mappedFileFree :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MappedFile -> m ()
mappedFileFree MappedFile
file = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr MappedFile
file' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MappedFile
file
Ptr MappedFile -> IO ()
g_mapped_file_free Ptr MappedFile
file'
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MappedFile
file
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data MappedFileFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod MappedFileFreeMethodInfo MappedFile signature where
overloadedMethod = mappedFileFree
instance O.OverloadedMethodInfo MappedFileFreeMethodInfo MappedFile where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MappedFile.mappedFileFree",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.27/docs/GI-GLib-Structs-MappedFile.html#v:mappedFileFree"
})
#endif
foreign import ccall "g_mapped_file_get_bytes" g_mapped_file_get_bytes ::
Ptr MappedFile ->
IO (Ptr GLib.Bytes.Bytes)
mappedFileGetBytes ::
(B.CallStack.HasCallStack, MonadIO m) =>
MappedFile
-> m GLib.Bytes.Bytes
mappedFileGetBytes :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MappedFile -> m Bytes
mappedFileGetBytes MappedFile
file = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr MappedFile
file' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MappedFile
file
Ptr Bytes
result <- Ptr MappedFile -> IO (Ptr Bytes)
g_mapped_file_get_bytes Ptr MappedFile
file'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mappedFileGetBytes" Ptr Bytes
result
Bytes
result' <- (forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MappedFile
file
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'
#if defined(ENABLE_OVERLOADING)
data MappedFileGetBytesMethodInfo
instance (signature ~ (m GLib.Bytes.Bytes), MonadIO m) => O.OverloadedMethod MappedFileGetBytesMethodInfo MappedFile signature where
overloadedMethod = mappedFileGetBytes
instance O.OverloadedMethodInfo MappedFileGetBytesMethodInfo MappedFile where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MappedFile.mappedFileGetBytes",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.27/docs/GI-GLib-Structs-MappedFile.html#v:mappedFileGetBytes"
})
#endif
foreign import ccall "g_mapped_file_get_contents" g_mapped_file_get_contents ::
Ptr MappedFile ->
IO CString
mappedFileGetContents ::
(B.CallStack.HasCallStack, MonadIO m) =>
MappedFile
-> m T.Text
mappedFileGetContents :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MappedFile -> m Text
mappedFileGetContents MappedFile
file = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr MappedFile
file' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MappedFile
file
CString
result <- Ptr MappedFile -> IO CString
g_mapped_file_get_contents Ptr MappedFile
file'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mappedFileGetContents" CString
result
Text
result' <- HasCallStack => CString -> IO Text
cstringToText CString
result
forall a. Ptr a -> IO ()
freeMem CString
result
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MappedFile
file
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data MappedFileGetContentsMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.OverloadedMethod MappedFileGetContentsMethodInfo MappedFile signature where
overloadedMethod = mappedFileGetContents
instance O.OverloadedMethodInfo MappedFileGetContentsMethodInfo MappedFile where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MappedFile.mappedFileGetContents",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.27/docs/GI-GLib-Structs-MappedFile.html#v:mappedFileGetContents"
})
#endif
foreign import ccall "g_mapped_file_get_length" g_mapped_file_get_length ::
Ptr MappedFile ->
IO Word64
mappedFileGetLength ::
(B.CallStack.HasCallStack, MonadIO m) =>
MappedFile
-> m Word64
mappedFileGetLength :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MappedFile -> m Word64
mappedFileGetLength MappedFile
file = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr MappedFile
file' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MappedFile
file
Word64
result <- Ptr MappedFile -> IO Word64
g_mapped_file_get_length Ptr MappedFile
file'
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MappedFile
file
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result
#if defined(ENABLE_OVERLOADING)
data MappedFileGetLengthMethodInfo
instance (signature ~ (m Word64), MonadIO m) => O.OverloadedMethod MappedFileGetLengthMethodInfo MappedFile signature where
overloadedMethod = mappedFileGetLength
instance O.OverloadedMethodInfo MappedFileGetLengthMethodInfo MappedFile where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MappedFile.mappedFileGetLength",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.27/docs/GI-GLib-Structs-MappedFile.html#v:mappedFileGetLength"
})
#endif
foreign import ccall "g_mapped_file_ref" g_mapped_file_ref ::
Ptr MappedFile ->
IO (Ptr MappedFile)
mappedFileRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
MappedFile
-> m MappedFile
mappedFileRef :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MappedFile -> m MappedFile
mappedFileRef MappedFile
file = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr MappedFile
file' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MappedFile
file
Ptr MappedFile
result <- Ptr MappedFile -> IO (Ptr MappedFile)
g_mapped_file_ref Ptr MappedFile
file'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mappedFileRef" Ptr MappedFile
result
MappedFile
result' <- (forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MappedFile -> MappedFile
MappedFile) Ptr MappedFile
result
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MappedFile
file
forall (m :: * -> *) a. Monad m => a -> m a
return MappedFile
result'
#if defined(ENABLE_OVERLOADING)
data MappedFileRefMethodInfo
instance (signature ~ (m MappedFile), MonadIO m) => O.OverloadedMethod MappedFileRefMethodInfo MappedFile signature where
overloadedMethod = mappedFileRef
instance O.OverloadedMethodInfo MappedFileRefMethodInfo MappedFile where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MappedFile.mappedFileRef",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.27/docs/GI-GLib-Structs-MappedFile.html#v:mappedFileRef"
})
#endif
foreign import ccall "g_mapped_file_unref" g_mapped_file_unref ::
Ptr MappedFile ->
IO ()
mappedFileUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
MappedFile
-> m ()
mappedFileUnref :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MappedFile -> m ()
mappedFileUnref MappedFile
file = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr MappedFile
file' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MappedFile
file
Ptr MappedFile -> IO ()
g_mapped_file_unref Ptr MappedFile
file'
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MappedFile
file
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data MappedFileUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod MappedFileUnrefMethodInfo MappedFile signature where
overloadedMethod = mappedFileUnref
instance O.OverloadedMethodInfo MappedFileUnrefMethodInfo MappedFile where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MappedFile.mappedFileUnref",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.27/docs/GI-GLib-Structs-MappedFile.html#v:mappedFileUnref"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveMappedFileMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveMappedFileMethod "free" o = MappedFileFreeMethodInfo
ResolveMappedFileMethod "ref" o = MappedFileRefMethodInfo
ResolveMappedFileMethod "unref" o = MappedFileUnrefMethodInfo
ResolveMappedFileMethod "getBytes" o = MappedFileGetBytesMethodInfo
ResolveMappedFileMethod "getContents" o = MappedFileGetContentsMethodInfo
ResolveMappedFileMethod "getLength" o = MappedFileGetLengthMethodInfo
ResolveMappedFileMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveMappedFileMethod t MappedFile, O.OverloadedMethod info MappedFile p) => OL.IsLabel t (MappedFile -> 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 ~ ResolveMappedFileMethod t MappedFile, O.OverloadedMethod info MappedFile p, R.HasField t MappedFile p) => R.HasField t MappedFile p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveMappedFileMethod t MappedFile, O.OverloadedMethodInfo info MappedFile) => OL.IsLabel t (O.MethodProxy info MappedFile) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif