haskell-gi-base-0.26.9: Foundation for libraries generated by haskell-gi

Safe Haskell | None
Language | Haskell2010

Data.GI.Base.GHashTable

Description

Machinery for some basic support of `GHashTable`.

The GLib `GHashTable` implementation requires two things: we need to "pack" a datatype into a pointer (for datatypes that are represented by pointers this is the trivial operation, for integers it is not, and GLib has some helper macros).

We also need to be able to hash and check for equality different datatypes.

Synopsis

- type GHashFunc a = FunPtr (PtrWrapped a -> IO Word32)
- type GEqualFunc a = FunPtr (PtrWrapped a -> PtrWrapped a -> IO Int32)
- gDirectHash :: GHashFunc (Ptr a)
- gDirectEqual :: GEqualFunc (Ptr a)
- ptrPackPtr :: Ptr a -> PtrWrapped (Ptr a)
- ptrUnpackPtr :: PtrWrapped (Ptr a) -> Ptr a
- gStrHash :: GHashFunc CString
- gStrEqual :: GEqualFunc CString
- cstringPackPtr :: CString -> PtrWrapped CString
- cstringUnpackPtr :: PtrWrapped CString -> CString
- gvaluePackPtr :: Ptr GValue -> PtrWrapped (Ptr GValue)
- gvalueUnpackPtr :: PtrWrapped (Ptr GValue) -> Ptr GValue

# Documentation

type GHashFunc a = FunPtr (PtrWrapped a -> IO Word32) Source #

A pointer to a hashing function on the C side.

type GEqualFunc a = FunPtr (PtrWrapped a -> PtrWrapped a -> IO Int32) Source #

A pointer to an equality checking function on the C side.

gDirectHash :: GHashFunc (Ptr a) Source #

Compute the hash for a `Ptr`.

gDirectEqual :: GEqualFunc (Ptr a) Source #

Check whether two pointers are equal.

ptrPackPtr :: Ptr a -> PtrWrapped (Ptr a) Source #

Pack a `Ptr` into a `PtrWrapped` `Ptr`.

ptrUnpackPtr :: PtrWrapped (Ptr a) -> Ptr a Source #

Extract a `Ptr` from a `PtrWrapped` `Ptr`.

gStrHash :: GHashFunc CString Source #

Compute the hash for a `CString`.

gStrEqual :: GEqualFunc CString Source #

Check whether two `CString`s are equal.

cstringPackPtr :: CString -> PtrWrapped CString Source #

Pack a `CString` into a `Ptr` than can go into a `GHashTable`.

cstringUnpackPtr :: PtrWrapped CString -> CString Source #

Extract a `CString` wrapped into a `Ptr` coming from a `GHashTable`.

gvaluePackPtr :: Ptr GValue -> PtrWrapped (Ptr GValue) Source #

Pack a `Ptr` to `GValue` into a `Ptr` than can go into a `GHashTable`.

gvalueUnpackPtr :: PtrWrapped (Ptr GValue) -> Ptr GValue Source #

Extract a `Ptr` to `GValue` wrapped into a `Ptr` coming from a `GHashTable`.