classes/parrotclass.pmc - Parrot Class
The structure of a parrot class is reasonably straightforward.
The PMC's cached integer value is the number of attribute slots that an object of this type requires.
The data pointer holds a pointer to an array of PMCs.
That array has:
- 0,
PCD_PARENTS
- An array of immediate parents.
- 1,
PCD_CLASS_NAME
- The class name PMC.
- 2,
PCD_ALL_PARENTS
- A pruned array of all parents,
in search order.
- 3,
PCD_ATTRIB_OFFS
- A hash,
keys are the class names,
values are the offsets to their attributes.
- 4,
PCD_ATTRIBUTES
- A hash,
the keys are the classname/attrib name pair (separated by a
NULL
),
while the value is the offset to the attribute.
- 5,
PCD_CLASS_ATTRIBUTES
- Array of attribute of this class.
- 6,
PCD_OBJECT_VTABLE
- Vtable PMC that holds the vtable for objects of this class.
void init()
- Initializes the class.
INTVAL isa(STRING *classname)
- Returns whether the class is or inherits from
*classname
.
PMC *find_method(STRING *name)
- Figure out which method PMC we need.
By default we just defer to the system method lookup code.
INTVAL can(STRING *method)
- Returns whether the class can perform
*method
.
PMC *get_class()
- Return SELF.
STRING *namespace_name()
- Return the name of the namespace,
which is the classname of ParrotClass classes.
void visit(visit_info *info)
- This is used by freeze/thaw to visit the contents of the class.
*info
is the visit info,
(see include/parrot/pmc_freeze.h).
void freeze(visit_info *info)
- Used to archive the class.
void thaw(visit_info *info)
- Used to unarchive the class.
void thawfinish(visit_info *info)
- Create the class from the thawed parents and attributes array.