Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides various helpers used by generated code; developers are not expected to invoke them directly.
These helpers are used by the low-level api. Capnp.GenHelpers.Pure defines helpers used by high-level api.
Synopsis
- getWordField :: (ReadCtx m mut, IsWord a) => Struct mut -> Int -> Int -> Word64 -> m a
- setWordField :: (RWCtx m s, Bounded a, Integral a, IsWord a, Bits a) => Struct ('Mut s) -> a -> Int -> Int -> Word64 -> m ()
- embedCapPtr :: WriteCtx m s => Message ('Mut s) -> Client -> m (Maybe (Ptr ('Mut s)))
- getPtrConst :: FromPtr 'Const a => ByteString -> a
- getTag :: ReadCtx m mut => Struct mut -> Int -> m Word16
Documentation
getWordField :: (ReadCtx m mut, IsWord a) => Struct mut -> Int -> Int -> Word64 -> m a Source #
fetches a field from the
struct's data section. getWordField
struct index offset defindex
is the index of the 64-bit word in the data
section in which the field resides. offset
is the offset in bits from the
start of that word to the field. def
is the default value for this field.
setWordField :: (RWCtx m s, Bounded a, Integral a, IsWord a, Bits a) => Struct ('Mut s) -> a -> Int -> Int -> Word64 -> m () Source #
sets a field in the
struct's data section. The meaning of the parameters are as in
setWordField
struct value index offset defgetWordField
, with value
being the value to set. The width of the
value is inferred from its type.
getPtrConst :: FromPtr 'Const a => ByteString -> a Source #
Get a pointer from a ByteString, where the root object is a struct with
one pointer, which is the pointer we will retrieve. This is only safe for
trusted inputs; it reads the message with a traversal limit of maxBound
(and so is suseptable to denial of service attacks), and it calls error
if decoding is not successful.
The purpose of this is for defining constants of pointer type from a schema.