NAME
src/packfile/pf_items.c - Fetch/store packfile data
DESCRIPTION
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.
BE
and be
are short for "Big-endian",
while LE
and le
are short for "little endian".
Functions
static void cvt_num12_num8
Converts i386 LE 12-byte long double to IEEE 754 8-byte double.
static void cvt_num16_num12
Converts IEEE 754 LE 16-byte long double to i386 LE 12-byte long double .Not yet implemented (throws internal_exception).
See http://babbage.cs.qc.cuny.edu/IEEE-754/References.xhtml
static void cvt_num12_num16
Converts i386 LE 12-byte long double to IEEE 754 LE 16-byte long double.TODO: Inaccurate implementation 12->8->16.
Need to follow cvt_num12_num8 See http://babbage.cs.qc.cuny.edu/IEEE-754/References.xhtml
static void cvt_num16_num8
Converts IEEE 754 16-byte long double to IEEE 754 8 byte double.Untested.
static void cvt_num8_num16
Converts IEEE 754 8-byte double to IEEE 754 16 byte long double.Untested.
static void cvt_num8_num12
Converts i386 8-byte double to i386 12 byte long double.Untested.
static void cvt_num8_num12_be
Converts a big-endian IEEE 754 8-byte double to i386 LE 12-byte long double.Untested.
static void cvt_num8_num16_le
Converts a little-endian IEEE 754 8-byte double to big-endian 16-byte long double.Untested.
static void cvt_num12_num16_le
Converts a little-endian 12-byte double to big-endian 16-byte long double.Untested.
static void cvt_num12_num8_le
Converts a little-endian 12-byte i386 long double into a IEEE 754 8-byte double.Untested.
static void cvt_num16_num8_le
Converts a little-endian IEEE 754 intel 16-byte long double into a big-endian IEEE 754 8-byte double.Untested.
static void cvt_num16_num8_be
Converts a big-endian IEEE 754 16-byte long double into a IEEE 754 8-byte double.Untested.
static void cvt_num16_num12_be
Converts a big-endian IEEE 754 16-byte long double into a 12-byte i386 long double.Untested.
static void cvt_num8_num16_be
Converts a big-endian IEEE 754 8-byte double to little-endian IEEE 754 16 byte long double.Untested.
static opcode_t fetch_op_test
Fetches an static opcode_t fetch_op_mixed_le
opcode fetch helper functionThis is mostly wrong or at least untestedFetch an opcode and convert to LE
static opcode_t fetch_op_mixed_be
Fetch an opcode and convert to BE.
Determines size of opcode from static opcode_t fetch_op_be_4
Fetches a 4-byte big-endian opcode.
static opcode_t fetch_op_be_8
Fetches an 8-byte big-endian opcode.
static opcode_t fetch_op_le_4
Fetches a 4-byte little-endian opcode
static opcode_t fetch_op_le_8
Fetches an 8-byte little-endian opcode
opcode_t PF_fetch_opcode
Fetches an opcode_t *PF_store_opcode
Stores an size_t PF_size_opcode
Returns the size of an item in INTVAL PF_fetch_integer
Fetches an opcode_t *PF_store_integer
Stores an size_t PF_size_integer
Returns stored size of FLOATVAL PF_fetch_number
Fetches a opcode_t *PF_store_number
Writes a size_t PF_size_number
Returns stored size of FLOATVAL in STRING *PF_fetch_string
Fetches a opcode_t *PF_store_string
Writes a size_t PF_size_string
Reports stored size of char *PF_fetch_cstring
Fetches a cstring from bytecode and returns an allocated copy
opcode_t *PF_store_cstring
Writes a size_t PF_size_cstring
Returns store size of a C-string in void PackFile_assign_transforms
Assigns transform functions to the vtable.
opcode_t
operation in little-endian format.
OPCODE_T_SIZE
macro,
and proceeds accordingly.
opcode_t
from the stream,
converting byteorder if needed.
opcode_t
to stream as-is.
opcode_t
units.
The size of opcode_t
is 1 per definition.
INTVAL
from the stream,
converting byteorder if needed.XXX assumes sizeof (INTVAL) == sizeof (opcode_t)
- we don't have INTVAL
size in the PackFile header.
INTVAL
to stream as is.
INTVAL
in opcode_t
units.
FLOATVAL
from the stream,
converting byteorder if needed.
Then advances the stream pointer by the packfile float size.
FLOATVAL
to the opcode stream as-is.
opcode_t
units.
STRING
from bytecode and return a new STRING
.Opcode format is:
opcode_t flags opcode_t encoding opcode_t type opcode_t size * data
STRING
to the opcode stream.
STRING
in opcode_t
units.
NULL
-terminated string to the stream.
opcode_t
units.
HISTORY
Initial review by leo 2003.11.21
Most routines moved from src/packfile.c.
Renamed PackFile_* to PF_*
Added 16 byte types.
TODO
<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.