gi-gobject-0.2.46.13: GI/GObject/Structs/TypeInfo.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)
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(..) ,
newZeroTypeInfo ,
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)
-- | Construct a `TypeInfo` struct initialized to zero.
newZeroTypeInfo :: MonadIO m => m TypeInfo
newZeroTypeInfo = liftIO $ callocBytes 72 >>= wrapPtr 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'
type family ResolveTypeInfoMethod (t :: Symbol) (o :: *) :: * where
ResolveTypeInfoMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveTypeInfoMethod t TypeInfo, MethodInfo info TypeInfo p) => IsLabelProxy t (TypeInfo -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTypeInfoMethod t TypeInfo, MethodInfo info TypeInfo p) => IsLabel t (TypeInfo -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif