PepperArray

extern class PepperArray

Nit class representing a Pepper C API PP_Var typed as an Array.

Inheritance

dep_class_pnacl-__PepperArrayObjectObjectPointerPointerPointer->ObjectPepperArrayPepperArrayPepperArray->Pointer

Parents

  • Pointer: Pointer classes are used to manipulate extern C structures.

Ancestors

  • Object: The root of the class hierarchy.

Constructors

Concerns

  • pnacl: Provides PNaCl support for Nit.
    • pnacl: Provides PNaCl support for Nit.

in pnacl::pnacl

redef type SELF

Type of this instance, automatically specialized in every class

A common use case of the virtual type SELF is to type an attribute and store another instance of the same type as self. It can also be used as as return type to a method producing a copy of self or returning an instance expected to be the exact same type as self.

This virtual type must be used with caution as it can hinder specialization. In fact, it imposes strict restrictions on all sub-classes and their usage. For example, using SELF as a return type of a method foo forces all subclasses to ensure that foo returns the correct and updated type. A dangerous usage take the form of a method typed by SELF which creates and returns a new instance. If not correctly specialized, this method would break when invoked on a sub-class.

A general rule for safe usage of SELF is to ensure that inputs typed SELF are stored in attributes typed SELF and returned by methods typed SELF, pretty much the same things as you would do with parameter types.

fun []=(index: Int, value: nullable Pepperable): Bool

Sets the value of an element in the array at indicated index.

If 'index' is larger than or equal to the array length, the length is updated to be 'index' + 1. Any position in the array that hasn't been set before is set to undefined, i.e., PepperVar of C type PP_VARTYPE_UNDEFINED. Returns a Boolean indicating whether the operation succeeds.

fun length=(length: Int): Bool

Sets the array length.

If 'length' is smaller than its current value, the array is truncated to the new length. Any elements that no longer fit are removed and the references to them will be released. If 'length' is larger than its current value, undefined PepperVars are appended to increase the array to the specified length.  Returns a Boolean indicating whether the operation succeeds.

fun native_set(index: Int, value: PepperVar): Bool

Takes a PepperVar for the 'value' param.

Sets the value of an element in the array at indicated index. If 'index' is larger than or equal to the array length, the length is updated to be 'index' + 1. Any position in the array that hasn't been set before is set to undefined, i.e., PepperVar of C type PP_VARTYPE_UNDEFINED. Returns a Boolean indicating whether the operation succeeds.