NAME ^

src/pmc/metaclass.pmc - Metaclass - defines a class

DESCRIPTION ^

This class implements the basic Parrot metaclass, used for describing a class.

Functions ^

void init()

Initializes the class.

void init_pmc(PMC *name)

The actual class creation code, called from newclass opcode. The init argument should stringify to the classname. The class will be attatched to the current namespace.

void destroy()

Free the memory associated with the underlying struct.

void mark()

Mark any referenced strings and PMCs.

void attributes()

Return a hash where the keys are attribute names and the values are instances of MetaAttribute, describing the attribute.

void add_attribute()

Add an attribute to the class. Requires a name and, optionally, a type.

void name()

Sets the name of the class.

void namespace()

With a parameter, sets the namespace for the class. Expects a fully qualified namespace to be specified as a key. If you already have linked another namespace with this class, this link will be broken and the new namespace specified will be linked to this class.

void new()

Creates an instance of the object.

void parents()

Return the parents array PMC.

void add_parent(PMC *parent)

Return the parents array PMC.

void add_method(STRING *name, PMC *sub)

Adds the given sub PMC as a method with the given name.

void roles()

Return the roles array PMC.

void _get_attrib_index()

This finds the index of an attribute in an object's attribute store and returns it. Returns -1 if the attribute does not exist. This method exists solely for the use of the Object PMC or any PMCs derived from it; the index will be useless anyway, since only the Object knows what to do with it.

void _get_method_pmc(STRING *name)

This walks the method resolution order and tries to locate a method of the give name. Returns the first one it finds, or NULL if no method is found. This method is intended to be used by the Object PMC.

SEE ALSO ^

docs/pdds/pdd15_objects.pod.


parrot