NAME

src/pmc/ptr.pmc - Pointer base type

DESCRIPTION

Ptr is a bare bones PMC for representing 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.

VTABLEs

void init()
If 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_int(INTVAL i)
init with a value from an INTVAL.
init_pmc(PMC *p)
init with a value from an existing pointer-ish PMC.
void *get_pointer()
void set_pointer(void *ptr)
Get and set the pointer value.
INTVAL get_bool()
Boolean value of the pointer. Non-NULL is true, following in the C tradition.
void destroy()
Manage attribute deallocation for fat representation.
INTVAL get_integer()
Implement PtrBuf interface. Specifies length of the buffer.In this case, always returns 0, indicating undetermined length.