gi-gio-0.2.46.13: GI/Gio/Structs/OutputVector.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
Structure used for scatter/gather data output.
You generally pass in an array of #GOutputVectors
and the operation will use all the buffers as if they were
one buffer.
-}
module GI.Gio.Structs.OutputVector
(
-- * Exported types
OutputVector(..) ,
newZeroOutputVector ,
noOutputVector ,
-- * Properties
-- ** Buffer
outputVectorReadBuffer ,
-- ** Size
outputVectorReadSize ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gio.Types
import GI.Gio.Callbacks
newtype OutputVector = OutputVector (ForeignPtr OutputVector)
-- | Construct a `OutputVector` struct initialized to zero.
newZeroOutputVector :: MonadIO m => m OutputVector
newZeroOutputVector = liftIO $ callocBytes 16 >>= wrapPtr OutputVector
noOutputVector :: Maybe OutputVector
noOutputVector = Nothing
outputVectorReadBuffer :: OutputVector -> IO (Ptr ())
outputVectorReadBuffer s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
return val
outputVectorReadSize :: OutputVector -> IO Word64
outputVectorReadSize s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO Word64
return val
type family ResolveOutputVectorMethod (t :: Symbol) (o :: *) :: * where
ResolveOutputVectorMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveOutputVectorMethod t OutputVector, MethodInfo info OutputVector p) => IsLabelProxy t (OutputVector -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveOutputVectorMethod t OutputVector, MethodInfo info OutputVector p) => IsLabel t (OutputVector -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif