NAME
src/pmc/unmanagedstruct.pmc - UnManagedStruct PMC
DESCRIPTION
PMC class to hold C structs that Parrot's not responsible for disposing of,
C struct for unmanaged memory in NCI.
They are typically used to access structures returned by NCI calls.
Members of this struct are not subject to garbage collection during run-time.
But if you can, rather use PtrBuf objects instead.
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)Set int value based on int type
- 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 *type_pmc, int type, size_t offs)Alignment of contained structures is the alignment of the biggest item in that
- static void 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.Vtable Functions
- void init_pmc(PMC *value)Initialize the struct with some data.
- PMC *clone()Return a clone of this PMC.
- void set_pmc(PMC *value)Sets
- void mark()Marks the
- INTVAL is_equal(PMC *value)Returns whether the two
- INTVAL get_bool()
- 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
*value should be an array of triples of:
*value (see init_pmc() and calculates the offsets.
struct as live.
structs 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.Methods
- as_string(string encodingname)Create a string from the buffer,
assumed to be a C string,
with the encoding specified.
If the encoding is omitted or null,
use platform encoding.
SEE ALSO
docs/pmc/struct.pod
