Safe Haskell | None |
---|---|
Language | Haskell2010 |
Capnp.Pointer
Description
This module provides support for parsing and serializing capnproto pointers. This is a low-level module; most users will not need to call it directly.
Synopsis
- data Ptr
- data ElementSize
- data EltSpec
- parsePtr :: Word64 -> Maybe Ptr
- parsePtr' :: Word64 -> Ptr
- serializePtr :: Maybe Ptr -> Word64
- serializePtr' :: Ptr -> Word64
- parseEltSpec :: Word64 -> EltSpec
- serializeEltSpec :: EltSpec -> Word64
Documentation
A Ptr
represents the information in a capnproto pointer.
Constructors
StructPtr !Int32 !Word16 !Word16 |
Note that the value |
ListPtr !Int32 !EltSpec |
|
FarPtr !Bool !Word32 !Word32 |
|
CapPtr !Word32 |
|
data ElementSize Source #
The element size field in a list pointer.
Instances
Enum ElementSize Source # | |
Defined in Capnp.Pointer Methods succ :: ElementSize -> ElementSize # pred :: ElementSize -> ElementSize # toEnum :: Int -> ElementSize # fromEnum :: ElementSize -> Int # enumFrom :: ElementSize -> [ElementSize] # enumFromThen :: ElementSize -> ElementSize -> [ElementSize] # enumFromTo :: ElementSize -> ElementSize -> [ElementSize] # enumFromThenTo :: ElementSize -> ElementSize -> ElementSize -> [ElementSize] # | |
Eq ElementSize Source # | |
Defined in Capnp.Pointer | |
Show ElementSize Source # | |
Defined in Capnp.Pointer Methods showsPrec :: Int -> ElementSize -> ShowS # show :: ElementSize -> String # showList :: [ElementSize] -> ShowS # |
A combination of the C and D fields in a list pointer, i.e. the element size, and either the number of elements in the list, or the total number of words in the list (if size is composite).
Constructors
EltNormal !ElementSize !Word32 |
|
EltComposite !Int32 |
|
parsePtr' :: Word64 -> Ptr Source #
parses parsePtr'
wordword
as a capnproto pointer. It ignores
nulls, returning them the same as (StructPtr 0 0 0)
.
serializePtr :: Maybe Ptr -> Word64 Source #
serializes the pointer as a serializePtr
ptrWord64
, translating
Nothing
to a null pointer.
This also changes the offset of zero-sized struct pointers to -1, to avoid them being interpreted as null.
serializePtr' :: Ptr -> Word64 Source #
serializes the pointer as a Word64.serializePtr'
ptr
Unlike serializePtr
, this results in a null pointer on the input
(StructPtr 0 0 0)
, rather than adjusting the offset.
parseEltSpec :: Word64 -> EltSpec Source #
reads the parseEltSpec
wordEltSpec
from word
, which must be the
encoding of a list pointer (this is not verified).
serializeEltSpec :: EltSpec -> Word64 Source #
serializes serializeEltSpec
eltSpeceltSpec
as a Word64
. all bits
which are not determined by the EltSpec
are zero.