NAME
src/pmc/unmanagedstruct.pmc - C struct with unmanaged memory
DESCRIPTION
PMC class to hold C struct
s that Parrot's not responsible for disposing of.
Buffer can be accessed using keyed assignments to PMC. Out of bounds access will very likely segfault.
Functions
static char *char_offset_int(PARROT_INTERP, PMC *pmc, INTVAL ix, int *type)
Returns the pointer for the element at index static INTVAL key_2_idx(PARROT_INTERP, PMC *pmc, PMC *key)
Returns the index for the element associated with key static char *char_offset_key(PARROT_INTERP, PMC *pmc, PMC *key, int *type)
Returns the pointer for the element associated with key static INTVAL ret_int(PARROT_INTERP, const char *p, int type)
Returns the element of type static FLOATVAL ret_float(PARROT_INTERP, const char *p, int type)
Returns the element of type static STRING *ret_string(PARROT_INTERP, char *p, int type)
Returns the element of type static PMC *ret_pmc(PARROT_INTERP, PMC *pmc, char *p, int type, INTVAL idx)
Returns the element of type static void set_int(PARROT_INTERP, char *p, int type, INTVAL value)
static void set_float(PARROT_INTERP, char *p, int type, FLOATVAL value)
Sets the value of the element of type static void set_string(PARROT_INTERP, char *p, int type, STRING *value)
Sets the value of the element of type static int calc_align(PARROT_INTERP, PMC *pmc, PMC *type_pmc, int type, size_t offs)
Alignment of contained structures is the alignment of the biggest item in that static size_t calc_offsets(PARROT_INTERP, PMC *pmc, PMC *value, size_t toff)
Calculates the offsets for the
ix
,
and sets the element type in *type
.
*key
.
Raises an exception if the key doesn't exist.
*key
,
and sets the element type in *type
.
type
starting at *p
as an INTVAL
.If,
for example,
char
or c<short> type size doesn't match,
this will fail we need some more configure support for type sizes.
type
starting at *p
as a FLOATVAL
.
type
starting at *p
as a Parrot string.
type
starting at *p
as a PMC.
type
starting at *p
to value
.
type
starting at *p
to *value
.
struct
.i386: long long
or double
is aligned on 4.This is recursive as structure definitions.
struct
.
See init_pmc()
for a description of *value
.Methods
void init()
Initializes the void init_pmc(PMC *value)
Initialize the struct with some data.void set_pmc(PMC *value)
Sets void mark()
Marks the INTVAL is_equal(PMC *value)
Returns whether the two INTVAL defined()
Returns whether the INTVAL get_integer()
Returns the size of the void set_integer_native(INTVAL size)
Sets the size of the INTVAL get_integer_keyed_int(INTVAL ix)
Returns the integer value at index INTVAL get_integer_keyed(PMC *key)
Returns the integer value associated with FLOATVAL get_number_keyed_int(INTVAL key)
Returns the floating-point value at index FLOATVAL get_number_keyed(PMC *key)
Returns the floating-point value associated with STRING *get_string_keyed_int(INTVAL key)
Returns the Parrot string value at index STRING *get_string_keyed(PMC *key)
Returns the Parrot string value associated with PMC *get_pmc_keyed_int(INTVAL key)
Returns the PMC value at index PMC *get_pmc_keyed(PMC *key)
Returns the PMC value associated with void *get_pointer()
Returns the pointer to the actual C void set_pointer(void *value)
Set the pointer to the actual C void set_integer_keyed_int(INTVAL ix, INTVAL value)
Sets the value of the element at index void set_integer_keyed(PMC *key, INTVAL value)
Sets the value of the element associated with key void set_number_keyed_int(INTVAL key, FLOATVAL value)
Sets the value of the element at index void set_number_keyed(PMC *key, FLOATVAL value)
Sets the value of the element associated with key void set_string_keyed_int(INTVAL key, STRING *value)
Sets the value of the element at index void set_string_keyed(PMC *key, STRING *value)
Sets the value of the element associated with key
struct
with a default value of NULL
.
*value
should be an array of triples of:
*value
(see init_pmc()
and calculates the offsets.
struct
as live.
struct
s are equivalent.
struct
is defined.
struct
.
struct
.
ix
.
*key
.
ix
.
*key
.
ix
.
*key
.
ix
.
*key
.
struct
.
struct
.
ix
to value
.
*key
to value
.May cause segfaults if value is out of bounds.
ix
to value
.
*key
to value
.
key
to *value
.
*key
to *value
.HISTORY
Initial revision by sean 2002/08/04