{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Structs.InputVector
(
InputVector(..) ,
newZeroInputVector ,
noInputVector ,
#if defined(ENABLE_OVERLOADING)
ResolveInputVectorMethod ,
#endif
clearInputVectorBuffer ,
getInputVectorBuffer ,
#if defined(ENABLE_OVERLOADING)
inputVector_buffer ,
#endif
setInputVectorBuffer ,
getInputVectorSize ,
#if defined(ENABLE_OVERLOADING)
inputVector_size ,
#endif
setInputVectorSize ,
) 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
newtype InputVector = InputVector (ManagedPtr InputVector)
deriving (Eq)
instance WrappedPtr InputVector where
wrappedPtrCalloc = callocBytes 8
wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 8 >=> wrapPtr InputVector)
wrappedPtrFree = Just ptr_to_g_free
newZeroInputVector :: MonadIO m => m InputVector
newZeroInputVector = liftIO $ wrappedPtrCalloc >>= wrapPtr InputVector
instance tag ~ 'AttrSet => Constructible InputVector tag where
new _ attrs = do
o <- newZeroInputVector
GI.Attributes.set o attrs
return o
noInputVector :: Maybe InputVector
noInputVector = Nothing
getInputVectorBuffer :: MonadIO m => InputVector -> m (Ptr ())
getInputVectorBuffer s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
return val
setInputVectorBuffer :: MonadIO m => InputVector -> Ptr () -> m ()
setInputVectorBuffer s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: Ptr ())
clearInputVectorBuffer :: MonadIO m => InputVector -> m ()
clearInputVectorBuffer s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (FP.nullPtr :: Ptr ())
#if defined(ENABLE_OVERLOADING)
data InputVectorBufferFieldInfo
instance AttrInfo InputVectorBufferFieldInfo where
type AttrBaseTypeConstraint InputVectorBufferFieldInfo = (~) InputVector
type AttrAllowedOps InputVectorBufferFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint InputVectorBufferFieldInfo = (~) (Ptr ())
type AttrTransferTypeConstraint InputVectorBufferFieldInfo = (~)(Ptr ())
type AttrTransferType InputVectorBufferFieldInfo = (Ptr ())
type AttrGetType InputVectorBufferFieldInfo = Ptr ()
type AttrLabel InputVectorBufferFieldInfo = "buffer"
type AttrOrigin InputVectorBufferFieldInfo = InputVector
attrGet = getInputVectorBuffer
attrSet = setInputVectorBuffer
attrConstruct = undefined
attrClear = clearInputVectorBuffer
attrTransfer _ v = do
return v
inputVector_buffer :: AttrLabelProxy "buffer"
inputVector_buffer = AttrLabelProxy
#endif
getInputVectorSize :: MonadIO m => InputVector -> m Word32
getInputVectorSize s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Word32
return val
setInputVectorSize :: MonadIO m => InputVector -> Word32 -> m ()
setInputVectorSize s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 4) (val :: Word32)
#if defined(ENABLE_OVERLOADING)
data InputVectorSizeFieldInfo
instance AttrInfo InputVectorSizeFieldInfo where
type AttrBaseTypeConstraint InputVectorSizeFieldInfo = (~) InputVector
type AttrAllowedOps InputVectorSizeFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint InputVectorSizeFieldInfo = (~) Word32
type AttrTransferTypeConstraint InputVectorSizeFieldInfo = (~)Word32
type AttrTransferType InputVectorSizeFieldInfo = Word32
type AttrGetType InputVectorSizeFieldInfo = Word32
type AttrLabel InputVectorSizeFieldInfo = "size"
type AttrOrigin InputVectorSizeFieldInfo = InputVector
attrGet = getInputVectorSize
attrSet = setInputVectorSize
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
inputVector_size :: AttrLabelProxy "size"
inputVector_size = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList InputVector
type instance O.AttributeList InputVector = InputVectorAttributeList
type InputVectorAttributeList = ('[ '("buffer", InputVectorBufferFieldInfo), '("size", InputVectorSizeFieldInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveInputVectorMethod (t :: Symbol) (o :: *) :: * where
ResolveInputVectorMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveInputVectorMethod t InputVector, O.MethodInfo info InputVector p) => OL.IsLabel t (InputVector -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif