gi-gobject-0.2.46.13: GI/GObject/Structs/TypeQuery.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)
A structure holding information for a specific type.
It is filled in by the g_type_query() function.
-}
module GI.GObject.Structs.TypeQuery
(
-- * Exported types
TypeQuery(..) ,
newZeroTypeQuery ,
noTypeQuery ,
-- * Properties
-- ** ClassSize
typeQueryReadClassSize ,
-- ** InstanceSize
typeQueryReadInstanceSize ,
-- ** Type
typeQueryReadType ,
-- ** TypeName
typeQueryReadTypeName ,
) 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 TypeQuery = TypeQuery (ForeignPtr TypeQuery)
-- | Construct a `TypeQuery` struct initialized to zero.
newZeroTypeQuery :: MonadIO m => m TypeQuery
newZeroTypeQuery = liftIO $ callocBytes 24 >>= wrapPtr TypeQuery
noTypeQuery :: Maybe TypeQuery
noTypeQuery = Nothing
typeQueryReadType :: TypeQuery -> IO GType
typeQueryReadType s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CGType
let val' = GType val
return val'
typeQueryReadTypeName :: TypeQuery -> IO T.Text
typeQueryReadTypeName s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CString
val' <- cstringToText val
return val'
typeQueryReadClassSize :: TypeQuery -> IO Word32
typeQueryReadClassSize s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO Word32
return val
typeQueryReadInstanceSize :: TypeQuery -> IO Word32
typeQueryReadInstanceSize s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 20) :: IO Word32
return val
type family ResolveTypeQueryMethod (t :: Symbol) (o :: *) :: * where
ResolveTypeQueryMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveTypeQueryMethod t TypeQuery, MethodInfo info TypeQuery p) => IsLabelProxy t (TypeQuery -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTypeQueryMethod t TypeQuery, MethodInfo info TypeQuery p) => IsLabel t (TypeQuery -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif