{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

This structure is used to provide the type system with the information
required to initialize and destruct (finalize) a type's class and
its instances.

The initialized structure is passed to the g_type_register_static() function
(or is copied into the provided #GTypeInfo structure in the
g_type_plugin_complete_type_info()). The type system will perform a deep
copy of this structure, so its memory does not need to be persistent
across invocation of g_type_register_static().
-}

module GI.GObject.Structs.TypeInfo
    ( 

-- * Exported types
    TypeInfo(..)                            ,
    noTypeInfo                              ,


 -- * Properties
-- ** ClassData
    typeInfoReadClassData                   ,


-- ** ClassSize
    typeInfoReadClassSize                   ,


-- ** InstanceSize
    typeInfoReadInstanceSize                ,


-- ** NPreallocs
    typeInfoReadNPreallocs                  ,


-- ** ValueTable
    typeInfoReadValueTable                  ,




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

newtype TypeInfo = TypeInfo (ForeignPtr TypeInfo)
noTypeInfo :: Maybe TypeInfo
noTypeInfo = Nothing

typeInfoReadClassSize :: TypeInfo -> IO Word16
typeInfoReadClassSize s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Word16
    return val

-- XXX Skipped getter for "TypeInfo:base_init" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

-- XXX Skipped getter for "TypeInfo:base_finalize" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

-- XXX Skipped getter for "TypeInfo:class_init" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

-- XXX Skipped getter for "TypeInfo:class_finalize" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

typeInfoReadClassData :: TypeInfo -> IO (Ptr ())
typeInfoReadClassData s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO (Ptr ())
    return val

typeInfoReadInstanceSize :: TypeInfo -> IO Word16
typeInfoReadInstanceSize s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 48) :: IO Word16
    return val

typeInfoReadNPreallocs :: TypeInfo -> IO Word16
typeInfoReadNPreallocs s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 50) :: IO Word16
    return val

-- XXX Skipped getter for "TypeInfo:instance_init" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

typeInfoReadValueTable :: TypeInfo -> IO TypeValueTable
typeInfoReadValueTable s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 64) :: IO (Ptr TypeValueTable)
    val' <- (newPtr 64 TypeValueTable) val
    return val'