packages feed

gi-glib-0.2.46.13: GI/GLib/Structs/PtrArray.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)

Contains the public fields of a pointer array.
-}

module GI.GLib.Structs.PtrArray
    ( 

-- * Exported types
    PtrArray(..)                            ,
    newZeroPtrArray                         ,
    noPtrArray                              ,


 -- * Properties
-- ** Len
    ptrArrayReadLen                         ,


-- ** Pdata
    ptrArrayReadPdata                       ,




    ) 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.GLib.Types
import GI.GLib.Callbacks

newtype PtrArray = PtrArray (ForeignPtr 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

-- | Construct a `PtrArray` struct initialized to zero.
newZeroPtrArray :: MonadIO m => m PtrArray
newZeroPtrArray = liftIO $ callocBoxedBytes 16 >>= wrapBoxed PtrArray

noPtrArray :: Maybe PtrArray
noPtrArray = Nothing

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

ptrArrayReadLen :: PtrArray -> IO Word32
ptrArrayReadLen s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

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

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

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