#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.GLib.Structs.PtrArray
(
PtrArray(..) ,
newZeroPtrArray ,
noPtrArray ,
getPtrArrayLen ,
#if ENABLE_OVERLOADING
ptrArray_len ,
#endif
setPtrArrayLen ,
clearPtrArrayPdata ,
getPtrArrayPdata ,
#if ENABLE_OVERLOADING
ptrArray_pdata ,
#endif
setPtrArrayPdata ,
) 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.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 PtrArray = PtrArray (ManagedPtr PtrArray)
foreign import ccall "g_ptr_array_get_type" c_g_ptr_array_get_type ::
IO GType
instance BoxedObject PtrArray where
boxedType _ = c_g_ptr_array_get_type
newZeroPtrArray :: MonadIO m => m PtrArray
newZeroPtrArray = liftIO $ callocBoxedBytes 16 >>= wrapBoxed PtrArray
instance tag ~ 'AttrSet => Constructible PtrArray tag where
new _ attrs = do
o <- newZeroPtrArray
GI.Attributes.set o attrs
return o
noPtrArray :: Maybe PtrArray
noPtrArray = Nothing
getPtrArrayPdata :: MonadIO m => PtrArray -> m (Ptr ())
getPtrArrayPdata s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
return val
setPtrArrayPdata :: MonadIO m => PtrArray -> Ptr () -> m ()
setPtrArrayPdata s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: Ptr ())
clearPtrArrayPdata :: MonadIO m => PtrArray -> m ()
clearPtrArrayPdata s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (FP.nullPtr :: Ptr ())
#if ENABLE_OVERLOADING
data PtrArrayPdataFieldInfo
instance AttrInfo PtrArrayPdataFieldInfo where
type AttrAllowedOps PtrArrayPdataFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint PtrArrayPdataFieldInfo = (~) (Ptr ())
type AttrBaseTypeConstraint PtrArrayPdataFieldInfo = (~) PtrArray
type AttrGetType PtrArrayPdataFieldInfo = Ptr ()
type AttrLabel PtrArrayPdataFieldInfo = "pdata"
type AttrOrigin PtrArrayPdataFieldInfo = PtrArray
attrGet _ = getPtrArrayPdata
attrSet _ = setPtrArrayPdata
attrConstruct = undefined
attrClear _ = clearPtrArrayPdata
ptrArray_pdata :: AttrLabelProxy "pdata"
ptrArray_pdata = AttrLabelProxy
#endif
getPtrArrayLen :: MonadIO m => PtrArray -> m Word32
getPtrArrayLen s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO Word32
return val
setPtrArrayLen :: MonadIO m => PtrArray -> Word32 -> m ()
setPtrArrayLen s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 8) (val :: Word32)
#if ENABLE_OVERLOADING
data PtrArrayLenFieldInfo
instance AttrInfo PtrArrayLenFieldInfo where
type AttrAllowedOps PtrArrayLenFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PtrArrayLenFieldInfo = (~) Word32
type AttrBaseTypeConstraint PtrArrayLenFieldInfo = (~) PtrArray
type AttrGetType PtrArrayLenFieldInfo = Word32
type AttrLabel PtrArrayLenFieldInfo = "len"
type AttrOrigin PtrArrayLenFieldInfo = PtrArray
attrGet _ = getPtrArrayLen
attrSet _ = setPtrArrayLen
attrConstruct = undefined
attrClear _ = undefined
ptrArray_len :: AttrLabelProxy "len"
ptrArray_len = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList PtrArray
type instance O.AttributeList PtrArray = PtrArrayAttributeList
type PtrArrayAttributeList = ('[ '("pdata", PtrArrayPdataFieldInfo), '("len", PtrArrayLenFieldInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
type family ResolvePtrArrayMethod (t :: Symbol) (o :: *) :: * where
ResolvePtrArrayMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePtrArrayMethod t PtrArray, O.MethodInfo info PtrArray p) => OL.IsLabel t (PtrArray -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif