Safe Haskell | None |
---|---|
Language | Haskell98 |
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.
- 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
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
.
gStrEqual :: GEqualFunc CString Source
Check whether two CString
s are equal.