parrotcode: C struct with unmanaged memory | |
Contents | PMCs |
src/pmc/unmanagedstruct.pmc - C struct with unmanaged memory
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.
static char *char_offset_int(PARROT_INTERP, PMC *pmc, INTVAL ix, int *type)
ix
,
and sets the element type in *type
.static INTVAL key_2_idx(PARROT_INTERP, PMC *pmc, PMC *key)
*key
.
Raises an exception if the key doesn't exist.static char *char_offset_key(PARROT_INTERP, PMC *pmc, PMC *key, int *type)
*key
,
and sets the element type in *type
.static INTVAL ret_int(PARROT_INTERP, const char *p, int type)
type
starting at *p
as an INTVAL
.char
or c<short> type size doesn't match,
this will fail we need some more configure support for type sizes.static FLOATVAL ret_float(PARROT_INTERP, const char *p, int type)
type
starting at *p
as a FLOATVAL
.static STRING *ret_string(PARROT_INTERP, char *p, int type)
type
starting at *p
as a Parrot string.static PMC *ret_pmc(PARROT_INTERP, PMC *pmc, char *p, int type, INTVAL idx)
type
starting at *p
as a PMC.static void set_int(PARROT_INTERP, char *p, int type, INTVAL value)
static void set_float(PARROT_INTERP, char *p, int type, FLOATVAL value)
type
starting at *p
to value
.static void set_string(PARROT_INTERP, char *p, int type, STRING *value)
type
starting at *p
to *value
.static int calc_align(PARROT_INTERP, PMC *pmc, PMC *type_pmc, int type, int offs)
struct
.long long
or double
is aligned on 4.static size_t calc_offsets(PARROT_INTERP, PMC *pmc, PMC *value, size_t toff)
struct
.
See init_pmc()
for a description of *value
.void init()
struct
with a default value of NULL
.void init_pmc(PMC *value)
*value
should be an array of triples of:void set_pmc(PMC *value)
*value
(see init_pmc()
and calculates the offsets.void mark()
struct
as live.INTVAL is_equal(PMC *value)
struct
s are equivalent.INTVAL defined()
struct
is defined.INTVAL get_integer()
struct
.void set_integer_native(INTVAL size)
struct
.INTVAL get_integer_keyed_int(INTVAL ix)
ix
.INTVAL get_integer_keyed(PMC *key)
*key
.FLOATVAL get_number_keyed_int(INTVAL key)
ix
.FLOATVAL get_number_keyed(PMC *key)
*key
.STRING *get_string_keyed_int(INTVAL key)
ix
.STRING *get_string_keyed(PMC *key)
*key
.PMC *get_pmc_keyed_int(INTVAL key)
ix
.PMC *get_pmc_keyed(PMC *key)
*key
.void *get_pointer()
struct
.void set_pointer(void *value)
struct
.void set_integer_keyed_int(INTVAL ix, INTVAL value)
ix
to value
.void set_integer_keyed(PMC *key, INTVAL value)
*key
to value
.void set_number_keyed_int(INTVAL key, FLOATVAL value)
ix
to value
.void set_number_keyed(PMC *key, FLOATVAL value)
*key
to value
.void set_string_keyed_int(INTVAL key, STRING *value)
key
to *value
.void set_string_keyed(PMC *key, STRING *value)
*key
to *value
.Initial revision by sean 2002/08/04
|