packages feed

gi-gio-0.2.46.13: GI/Gio/Structs/InputVector.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 input.
You generally pass in an array of #GInputVectors
and the operation will store the read data starting in the
first buffer, switching to the next as needed.
-}

module GI.Gio.Structs.InputVector
    ( 

-- * Exported types
    InputVector(..)                         ,
    newZeroInputVector                      ,
    noInputVector                           ,


 -- * Properties
-- ** Buffer
    inputVectorReadBuffer                   ,


-- ** Size
    inputVectorReadSize                     ,




    ) 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 InputVector = InputVector (ForeignPtr InputVector)
-- | Construct a `InputVector` struct initialized to zero.
newZeroInputVector :: MonadIO m => m InputVector
newZeroInputVector = liftIO $ callocBytes 16 >>= wrapPtr InputVector

noInputVector :: Maybe InputVector
noInputVector = Nothing

inputVectorReadBuffer :: InputVector -> IO (Ptr ())
inputVectorReadBuffer s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
    return val

inputVectorReadSize :: InputVector -> IO Word64
inputVectorReadSize s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word64
    return val

type family ResolveInputVectorMethod (t :: Symbol) (o :: *) :: * where
    ResolveInputVectorMethod l o = MethodResolutionFailed l o

instance (info ~ ResolveInputVectorMethod t InputVector, MethodInfo info InputVector p) => IsLabelProxy t (InputVector -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveInputVectorMethod t InputVector, MethodInfo info InputVector p) => IsLabel t (InputVector -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif