NAME

src/pmc/callsignaturereturns.pmc - resizable array for typed pointers

DESCRIPTION

This class stores typed pointers used to fill results in CallSignature.

SYNOPSIS

  # VTABLEs are too tight to implement something more beautiful

  # Create signature
  rets = new CallSignatureReturns
  rets.set_pointer_keyed_int(0, &intval);
  rest.push_integer(PARROT_ARG_INTVAL);

  rets.set_pointer_keyed_int(1, &floatval);
  rest.push_integer(PARROT_ARG_FLOATVAL);

  rets.set_pointer_keyed_int(2, &string);
  rest.push_integer(PARROT_ARG_STRING);

  rets.set_pointer_keyed_int(3, &pmc);
  rest.push_integer(PARROT_ARG_PMC);

  # Fill
  rets.set_integer_keyed_int(intval, 0);
  rets.set_number_keyed_int(floatval, 1);
  rets.set_string_keyed_int(string, 2);
  rets.set_pmc_keyed_int(pmc, 3);

CallSignatureReturns will behave like CPointer with autocasting values.

Up to 8 returns use FixedSizeAllocator. Switch to malloc/free after.

Functions

void init()
Initialize the CallSignatureReturns PMC.
void destroy()
Destroy CallSignatureReturns.
void set_integer_native(INTVAL size)
Resizes the array to size elements.
INTVAL elements()
Returns the number of elements in the array.
void set_pointer_keyed_int(INTVAL key, void *value)
Sets the pointer at position key. The pointer should point to a storage location for a return value -- it must be a pointer to an INTVAL, FLOATVAL, PMC, or STRING storage location.
void push_integer(INTVAL value)
Set type of last pushed pointer.
void set_integer_keyed_int(INTVAL key, INTVAL value)
void set_number_keyed_int(INTVAL key, FLOATVAL value)
void set_string_keyed_int(INTVAL key, STRING *value)
void set_pmc_keyed_int(INTVAL key, PMC *value)
Sets the value of the element at index key to value, casting if necessary.
void *get_string_keyed_int(INTVAL key)
Gets raw pointer for result.
void *get_pointer_keyed_int(INTVAL key)
Gets raw pointer for result.

SEE ALSO

docs/pdds/pdd03_calling_conventions.pod.