capnp-0.5.0.0: Cap'n Proto for Haskell

Safe HaskellNone
LanguageHaskell2010

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

Documentation

data Ptr Source #

A Ptr represents the information in a capnproto pointer.

Constructors

StructPtr !Int32 !Word16 !Word16

StructPtr off dataSz ptrSz is a pointer to a struct at offset off in words from the end of the pointer, with a data section of size dataSz words, and a pointer section of size ptrSz words.

Note that the value StructPtr 0 0 0 is illegal, since its encoding is reserved for the "null" pointer.

ListPtr !Int32 !EltSpec

ListPtr off eltSpec is a pointer to a list starting at offset off in words from the end of the pointer. eltSpec encodes the C and D fields in the encoding spec; see EltSpec for details

FarPtr !Bool !Word32 !Word32

FarPtr twoWords off segment is a far pointer, whose landing pad is:

  • two words iff twoWords,
  • off words from the start of the target segment, and
  • in segment id segment.
CapPtr !Word32

CapPtr id is a pointer to the capability with the id id.

Instances
Eq Ptr Source # 
Instance details

Defined in Capnp.Pointer

Methods

(==) :: Ptr -> Ptr -> Bool #

(/=) :: Ptr -> Ptr -> Bool #

Show Ptr Source # 
Instance details

Defined in Capnp.Pointer

Methods

showsPrec :: Int -> Ptr -> ShowS #

show :: Ptr -> String #

showList :: [Ptr] -> ShowS #

data EltSpec Source #

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

EltNormal size len is a normal (non-composite) element type (C /= 7). size is the size of the elements, and len is the number of elements in the list.

EltComposite !Int32

EltComposite len is a composite element (C == 7). len is the length of the list in words.

Instances
Eq EltSpec Source # 
Instance details

Defined in Capnp.Pointer

Methods

(==) :: EltSpec -> EltSpec -> Bool #

(/=) :: EltSpec -> EltSpec -> Bool #

Show EltSpec Source # 
Instance details

Defined in Capnp.Pointer

parsePtr :: Word64 -> Maybe Ptr Source #

parsePtr word parses word as a capnproto pointer. A null pointer is parsed as Nothing.

parsePtr' :: Word64 -> Ptr Source #

parsePtr' word parses word as a capnproto pointer. It ignores nulls, returning them the same as (StructPtr 0 0 0).

serializePtr :: Maybe Ptr -> Word64 Source #

serializePtr ptr serializes the pointer as a Word64, translating Nothing to a null pointer.

serializePtr' :: Ptr -> Word64 Source #

serializePtr' ptr serializes the pointer as a Word64.

Unlike serializePtr, this results in a null pointer on the input (StructPtr 0 0 0), rather than adjusting the offset.

parseEltSpec :: Word64 -> EltSpec Source #

parseEltSpec word reads the EltSpec from word, which must be the encoding of a list pointer (this is not verified).

serializeEltSpec :: EltSpec -> Word64 Source #

serializeEltSpec eltSpec serializes eltSpec as a Word64. all bits which are not determined by the EltSpec are zero.