NAME ^

src/pmc/fixedpmcarray.pmc - fixed size array for PMCs only

DESCRIPTION ^

This class, FixedPMCArray, implements an array of fixed size which stores PMCs. It puts things into Integer, Float, or String PMCs as appropriate

Note ^

The flag PObj_private0_FLAG is used in the NameSpace PMC and should never be set for user arrays.

Functions ^

METHOD sort(PMC *cmp_func)

Sort this array, optionally using the provided cmp_func

Methods ^

void init()

Initializes the array.

void destroy()

Destroys the array.

PMC *clone()

Creates and returns a copy of the array.

INTVAL get_bool()

Returns whether the array has any elements (meaning been initialized, for a fixed sized array).

INTVAL elements()

INTVAL get_integer()

Returns the number of elements in the array.

FLOATVAL get_number()

Returns the number of elements in the array.

STRING *get_string()

Returns the number of elements in the array as a Parrot string. (??? -leo)

STRING *get_repr()

Returns a string representation of the array contents. RT #46673 implement freeze/thaw and use that instead.

INTVAL get_integer_keyed_int(INTVAL key)

Returns the integer value of the element at index key.

INTVAL get_integer_keyed(PMC *key)

Returns the integer value of the element at index *key.

FLOATVAL get_number_keyed_int(INTVAL key)

Returns the floating-point value of the element at index key.

FLOATVAL get_number_keyed(PMC *key)

Returns the floating-point value of the element at index *key.

STRING *get_string_keyed_int(INTVAL key)

Returns the Parrot string value of the element at index key.

STRING *get_string_keyed(PMC *key)

Returns the Parrot string value of the element at index *key.

PMC *get_pmc_keyed_int(INTVAL key)

Returns the PMC value of the element at index key.

PMC *get_pmc_keyed(PMC *key)

Returns the PMC value of the element at index *key.

void set_integer_native(INTVAL size)

Sizes the array to size elements. Can't be used to resize an array.

void set_integer_keyed_int(INTVAL key, INTVAL value)

Sets the integer value of the element at index key to value.

void set_integer_keyed(PMC *key, INTVAL value)

Sets the integer value of the element at index key to value.

void set_number_keyed_int(INTVAL key, FLOATVAL value)

Sets the floating-point value of the element at index key to value.

void set_number_keyed(PMC *key, FLOATVAL value)

Sets the floating-point value of the element at index key to value.

void set_string_keyed_int(INTVAL key, STRING *value)

Sets the Parrot string value of the element at index key to value.

void set_string_keyed(PMC *key, STRING *value)

Sets the string value of the element at index key to value.

void set_pmc_keyed_int(INTVAL key, PMC *src)

Sets the PMC value of the element at index key to *src.

void set_pmc_keyed(PMC *key, PMC *value)

Sets the PMC at index key to value.

INTVAL is_equal(PMC *value)

The == operation. Compares two array to hold equal elements.

PMC *slice(PMC *key, INTVAL f)

Return a new iterator for the slice PMC key if f == 0.

Return a new pythonic array slice if f == 1.

PMC *get_iter()

Return a new iterator for SELF.

INTVAL exists_keyed_int(INTVAL key)

INTVAL exists_keyed_int(PMC *key)

Returns TRUE is the element at key exists; otherwise returns false.

void splice(PMC *value, INTVAL offset, INTVAL count)

Replaces count elements starting at offset with the elements in value.

If count is 0 then the elements in value will be inserted after offset.

This throws an exception if any of the spliced in values are out of the range of this array.

*/

    void splice(PMC *value, INTVAL offset, INTVAL count) {
        if (count + offset > PMC_int_val(SELF))
            Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
                _("FixedPMCArray: index out of bounds!"));

        for (count--; count >= 0; --count) {
            VTABLE_set_pmc_keyed_int(INTERP, SELF, offset + count, value);
        }
    }
/*

void visit(visit_info *info)

This is used by freeze/thaw to visit the contents of the array.

*info is the visit info, (see include/parrot/pmc_freeze.h).

void freeze(visit_info *info)

Used to archive the array.

void thaw(visit_info *info)

Used to unarchive the array.

INTVAL defined_keyed_int(INTVAL key)

Returns TRUE is the element at key is defined; otherwise returns false.

SEE ALSO ^

docs/pdds/pdd17_basic_types.pod.


parrot