File: GType.hsc

package info (click to toggle)
haskell-haskell-gi 0.26.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: haskell: 8,617; ansic: 74; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Data.GI.CodeGen.GType
    ( GType     -- Reexport from Data.GI.Base.BasicTypes for convenience
    , gtypeIsA
    , gtypeIsBoxed
    ) where

#include <glib-object.h>

import Foreign.C
import System.IO.Unsafe (unsafePerformIO)
import Data.GI.Base.BasicTypes (CGType, GType(..))

foreign import ccall unsafe "g_type_is_a" g_type_is_a ::
    CGType -> CGType -> IO CInt

gtypeIsA :: GType -> GType -> Bool
gtypeIsA (GType gtype) (GType is_a) = (/= 0) $
    unsafePerformIO $ g_type_is_a gtype is_a

gtypeBoxed :: GType
gtypeBoxed = GType #const G_TYPE_BOXED

gtypeIsBoxed :: GType -> Bool
gtypeIsBoxed gtype = gtypeIsA gtype gtypeBoxed