parrotcode: Fetch/store packfile data | |
Contents | C |
src/packfile/pf_items.c - Fetch/store packfile data
Low level packfile functions to fetch and store Parrot data,
i.e.
INTVAL
,
FLOATVAL
,
STRING
...
PF_fetch_<item>()
functions retrieve the datatype item from the opcode stream and convert byteordering or binary format on the fly,
depending on the packfile header.
PF_store_<item>()
functions write the datatype item to the stream as is.
These functions don't check the available size.
PF_size_<item>()
functions return the store size of item in opcode_t
units.
static void cvt_num12_num8(NOTNULL(unsigned char *dest), ARGIN(const unsigned char *src))
static void cvt_num12_num8_be(NOTNULL(unsigned char *dest), ARGIN(const unsigned char *src))
static void cvt_num12_num8_le(NOTNULL(unsigned char *dest), NOTNULL(unsigned char *src))
static opcode_t fetch_op_test(NOTNULL(unsigned char *b))
static opcode_t fetch_op_mixed_le(NOTNULL(unsigned char *b))
static opcode_t fetch_op_mixed_be(NOTNULL(unsigned char *b))
static opcode_t fetch_op_be_4(NOTNULL(unsigned char *b))
static opcode_t fetch_op_be_8(NOTNULL(unsigned char *b))
static opcode_t fetch_op_le_4(NOTNULL(unsigned char *b))
static opcode_t fetch_op_le_8(NOTNULL(unsigned char *b))
PARROT_WARN_UNUSED_RESULT opcode_t PF_fetch_opcode(NULLOK(PackFile *pf), NOTNULL(opcode_t **stream))
opcode_t
from the stream,
converting byteorder if needed.PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL opcode_t *PF_store_opcode(NOTNULL(opcode_t *cursor), opcode_t val)
opcode_t
to stream as is.PARROT_CONST_FUNCTION size_t PF_size_opcode(void)
opcode_t
units,
which is 1 per definitionem.PARROT_WARN_UNUSED_RESULT INTVAL PF_fetch_integer(NULLOK(PackFile *pf), NOTNULL(opcode_t **stream))
INTVAL
from the stream,
converting byteorder if needed.sizeof (INTVAL) == sizeof (opcode_t)
- we don't have INTVAL
size in the PackFile header.PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL opcode_t *PF_store_integer(NOTNULL(opcode_t *cursor), INTVAL val)
INTVAL
to stream as is.PARROT_CONST_FUNCTION size_t PF_size_integer(void)
INTVAL
in opcode_t
units.PARROT_WARN_UNUSED_RESULT FLOATVAL PF_fetch_number(NULLOK(PackFile *pf), NOTNULL(opcode_t **stream))
FLOATVAL
from the stream,
converting byteorder if needed.
Then advance stream pointer by amount of packfile float size.PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL opcode_t *PF_store_number(NOTNULL(opcode_t *cursor), ARGIN(const FLOATVAL *val))
FLOATVAL
to the opcode stream as is.PARROT_CONST_FUNCTION size_t PF_size_number(void)
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL STRING *PF_fetch_string(PARROT_INTERP, NULLOK(PackFile *pf), NOTNULL(opcode_t **cursor))
STRING
from bytecode and return a new STRING
. opcode_t flags
opcode_t encoding
opcode_t type
opcode_t size
* data
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL opcode_t *PF_store_string(NOTNULL(opcode_t *cursor), NOTNULL(STRING *s))
PARROT_PURE_FUNCTION size_t PF_size_string(ARGIN(const STRING *s))
STRING
in opcode_t
units.PARROT_MALLOC PARROT_CANNOT_RETURN_NULL char *PF_fetch_cstring(NOTNULL(PackFile *pf), NOTNULL(opcode_t **cursor))
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL opcode_t *PF_store_cstring(NOTNULL(opcode_t *cursor), ARGIN(const char *s))
PARROT_PURE_FUNCTION size_t PF_size_cstring(ARGIN(const char *s))
opcode_t
units.void PackFile_assign_transforms(NOTNULL(PackFile *pf))
Initial review by leo 2003.11.21
Most routines moved from src/packfile.c.
Renamed PackFile_* to PF_*
<PF_store_<type
()>> - write an opcode_t stream to cursor in natural byte-ordering.
<PF_fetch_<type
()>> - read items and possibly convert the foreign format.
<PF_size_<type
()>> - return the needed size in opcode_t
units.
|