NAME
src/pmc/ptr.pmc - Ptr PMC
DESCRIPTION
Ptr is a bare bones PMC for representing the base type for pointers.
It is intended that additional functionality be added via subclassing.
Any functionality added to this PMC not critical to its operation as a pointer representation is deprecated in advance and subject to removal without notice.
Fat versus Thin
Ptr can be implemented with two separate representations - fat,
which makes use of the conventional PMC attributes structure and thin which is more efficient and stores the pointer directly,
avoiding memory allocation and pointer dereference costs at the expense of extensibility.
The distinction is managed via a set of macros - PTR_FAT_TEST,
PTR_FAT_SET,
and PTR_FAT_CLEAR.
Internally,
these use the private1 flag,
and this flag is therefore unavailable for subclass use.
Vtable Functions
void init()
If init_int(INTVAL i)init_pmc(PMC *p)void *get_pointer()void set_pointer(void *ptr)
Get and set the pointer value.
INTVAL get_bool()
Boolean value of the pointer.
Non-void destroy()
Manage attribute deallocation for INTVAL get_integer()
Implement
fat and attributes have not yet been otherwise allocated,
will allocate room for the representation.Unless otherwise initialized,
Parrot will have zeroed this and the pointer value will be NULL.
init with a value from an INTVAL.
init with a value from an existing pointer-ish PMC.
NULL is true,
following in the C tradition.
fat representation.
PtrBuf interface.
Specifies length of the buffer.In this case,
always returns 0,
indicating undetermined length.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.