{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.OSTree.Objects.ContentWriter
(
ContentWriter(..) ,
IsContentWriter ,
toContentWriter ,
#if defined(ENABLE_OVERLOADING)
ResolveContentWriterMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
ContentWriterFinishMethodInfo ,
#endif
contentWriterFinish ,
) 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.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 GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.OutputStream as Gio.OutputStream
newtype ContentWriter = ContentWriter (SP.ManagedPtr ContentWriter)
deriving (ContentWriter -> ContentWriter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContentWriter -> ContentWriter -> Bool
$c/= :: ContentWriter -> ContentWriter -> Bool
== :: ContentWriter -> ContentWriter -> Bool
$c== :: ContentWriter -> ContentWriter -> Bool
Eq)
instance SP.ManagedPtrNewtype ContentWriter where
toManagedPtr :: ContentWriter -> ManagedPtr ContentWriter
toManagedPtr (ContentWriter ManagedPtr ContentWriter
p) = ManagedPtr ContentWriter
p
foreign import ccall "ostree_content_writer_get_type"
c_ostree_content_writer_get_type :: IO B.Types.GType
instance B.Types.TypedObject ContentWriter where
glibType :: IO GType
glibType = IO GType
c_ostree_content_writer_get_type
instance B.Types.GObject ContentWriter
class (SP.GObject o, O.IsDescendantOf ContentWriter o) => IsContentWriter o
instance (SP.GObject o, O.IsDescendantOf ContentWriter o) => IsContentWriter o
instance O.HasParentTypes ContentWriter
type instance O.ParentTypes ContentWriter = '[Gio.OutputStream.OutputStream, GObject.Object.Object]
toContentWriter :: (MIO.MonadIO m, IsContentWriter o) => o -> m ContentWriter
toContentWriter :: forall (m :: * -> *) o.
(MonadIO m, IsContentWriter o) =>
o -> m ContentWriter
toContentWriter = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr ContentWriter -> ContentWriter
ContentWriter
instance B.GValue.IsGValue (Maybe ContentWriter) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_ostree_content_writer_get_type
gvalueSet_ :: Ptr GValue -> Maybe ContentWriter -> IO ()
gvalueSet_ Ptr GValue
gv Maybe ContentWriter
P.Nothing = forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (forall a. Ptr a
FP.nullPtr :: FP.Ptr ContentWriter)
gvalueSet_ Ptr GValue
gv (P.Just ContentWriter
obj) = forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ContentWriter
obj (forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe ContentWriter)
gvalueGet_ Ptr GValue
gv = do
Ptr ContentWriter
ptr <- forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr ContentWriter)
if Ptr ContentWriter
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 b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr ContentWriter -> ContentWriter
ContentWriter Ptr ContentWriter
ptr
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveContentWriterMethod (t :: Symbol) (o :: *) :: * where
ResolveContentWriterMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveContentWriterMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveContentWriterMethod "clearPending" o = Gio.OutputStream.OutputStreamClearPendingMethodInfo
ResolveContentWriterMethod "close" o = Gio.OutputStream.OutputStreamCloseMethodInfo
ResolveContentWriterMethod "closeAsync" o = Gio.OutputStream.OutputStreamCloseAsyncMethodInfo
ResolveContentWriterMethod "closeFinish" o = Gio.OutputStream.OutputStreamCloseFinishMethodInfo
ResolveContentWriterMethod "finish" o = ContentWriterFinishMethodInfo
ResolveContentWriterMethod "flush" o = Gio.OutputStream.OutputStreamFlushMethodInfo
ResolveContentWriterMethod "flushAsync" o = Gio.OutputStream.OutputStreamFlushAsyncMethodInfo
ResolveContentWriterMethod "flushFinish" o = Gio.OutputStream.OutputStreamFlushFinishMethodInfo
ResolveContentWriterMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveContentWriterMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveContentWriterMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveContentWriterMethod "hasPending" o = Gio.OutputStream.OutputStreamHasPendingMethodInfo
ResolveContentWriterMethod "isClosed" o = Gio.OutputStream.OutputStreamIsClosedMethodInfo
ResolveContentWriterMethod "isClosing" o = Gio.OutputStream.OutputStreamIsClosingMethodInfo
ResolveContentWriterMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveContentWriterMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveContentWriterMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveContentWriterMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveContentWriterMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveContentWriterMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveContentWriterMethod "splice" o = Gio.OutputStream.OutputStreamSpliceMethodInfo
ResolveContentWriterMethod "spliceAsync" o = Gio.OutputStream.OutputStreamSpliceAsyncMethodInfo
ResolveContentWriterMethod "spliceFinish" o = Gio.OutputStream.OutputStreamSpliceFinishMethodInfo
ResolveContentWriterMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveContentWriterMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveContentWriterMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveContentWriterMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveContentWriterMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveContentWriterMethod "write" o = Gio.OutputStream.OutputStreamWriteMethodInfo
ResolveContentWriterMethod "writeAll" o = Gio.OutputStream.OutputStreamWriteAllMethodInfo
ResolveContentWriterMethod "writeAllAsync" o = Gio.OutputStream.OutputStreamWriteAllAsyncMethodInfo
ResolveContentWriterMethod "writeAllFinish" o = Gio.OutputStream.OutputStreamWriteAllFinishMethodInfo
ResolveContentWriterMethod "writeAsync" o = Gio.OutputStream.OutputStreamWriteAsyncMethodInfo
ResolveContentWriterMethod "writeBytes" o = Gio.OutputStream.OutputStreamWriteBytesMethodInfo
ResolveContentWriterMethod "writeBytesAsync" o = Gio.OutputStream.OutputStreamWriteBytesAsyncMethodInfo
ResolveContentWriterMethod "writeBytesFinish" o = Gio.OutputStream.OutputStreamWriteBytesFinishMethodInfo
ResolveContentWriterMethod "writeFinish" o = Gio.OutputStream.OutputStreamWriteFinishMethodInfo
ResolveContentWriterMethod "writev" o = Gio.OutputStream.OutputStreamWritevMethodInfo
ResolveContentWriterMethod "writevAll" o = Gio.OutputStream.OutputStreamWritevAllMethodInfo
ResolveContentWriterMethod "writevAllAsync" o = Gio.OutputStream.OutputStreamWritevAllAsyncMethodInfo
ResolveContentWriterMethod "writevAllFinish" o = Gio.OutputStream.OutputStreamWritevAllFinishMethodInfo
ResolveContentWriterMethod "writevAsync" o = Gio.OutputStream.OutputStreamWritevAsyncMethodInfo
ResolveContentWriterMethod "writevFinish" o = Gio.OutputStream.OutputStreamWritevFinishMethodInfo
ResolveContentWriterMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveContentWriterMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveContentWriterMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveContentWriterMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveContentWriterMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveContentWriterMethod "setPending" o = Gio.OutputStream.OutputStreamSetPendingMethodInfo
ResolveContentWriterMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveContentWriterMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveContentWriterMethod t ContentWriter, O.OverloadedMethod info ContentWriter p) => OL.IsLabel t (ContentWriter -> 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 ~ ResolveContentWriterMethod t ContentWriter, O.OverloadedMethod info ContentWriter p, R.HasField t ContentWriter p) => R.HasField t ContentWriter p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveContentWriterMethod t ContentWriter, O.OverloadedMethodInfo info ContentWriter) => OL.IsLabel t (O.MethodProxy info ContentWriter) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ContentWriter
type instance O.AttributeList ContentWriter = ContentWriterAttributeList
type ContentWriterAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList ContentWriter = ContentWriterSignalList
type ContentWriterSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "ostree_content_writer_finish" ostree_content_writer_finish ::
Ptr ContentWriter ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CString
contentWriterFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsContentWriter a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m T.Text
contentWriterFinish :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsContentWriter a, IsCancellable b) =>
a -> Maybe b -> m Text
contentWriterFinish a
self Maybe b
cancellable = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr ContentWriter
self' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Maybe b
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Ptr a
nullPtr
Just b
jCancellable -> do
Ptr Cancellable
jCancellable' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
forall a b. IO a -> IO b -> IO a
onException (do
CString
result <- forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError forall a b. (a -> b) -> a -> b
$ Ptr ContentWriter
-> Ptr Cancellable -> Ptr (Ptr GError) -> IO CString
ostree_content_writer_finish Ptr ContentWriter
self' Ptr Cancellable
maybeCancellable
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contentWriterFinish" 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 a
self
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
) (do
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data ContentWriterFinishMethodInfo
instance (signature ~ (Maybe (b) -> m T.Text), MonadIO m, IsContentWriter a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod ContentWriterFinishMethodInfo a signature where
overloadedMethod = contentWriterFinish
instance O.OverloadedMethodInfo ContentWriterFinishMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.OSTree.Objects.ContentWriter.contentWriterFinish",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-ostree-1.0.16/docs/GI-OSTree-Objects-ContentWriter.html#v:contentWriterFinish"
})
#endif