Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > cd14cddf3b3ceaf1193157472227757a > files > 268

parrot-doc-1.6.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Parrot  - defines a class</title>
        <link rel="stylesheet" type="text/css"
            href="../../../resources/parrot.css"
            media="all">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    </head>
    <body>
        <div id="wrapper">
            <div id="header">

                <a href="http://www.parrot.org">
                <img border=0 src="../../../resources/parrot_logo.png" id="logo" alt="parrot">
                </a>
            </div> <!-- "header" -->
            <div id="divider"></div>
            <div id="mainbody">
                <div id="breadcrumb">
                    <a href="../../../html/index.html">Home</a> &raquo; <a href="../../../html/pmc.html">PMCs</a> &raquo; defines a class
                </div>

<h1><a name="NAME"
>NAME</a></h1>

<p>src/pmc/class.pmc &#45; defines a class</p>

<h1><a name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>This class implements the Class PMC,
as outlined in <em><a href="../../docs/pdds/pdd15_objects.pod.html">docs/pdds/pdd15_objects.pod</a></em>.</p>

<p>Class is not derived from any other PMC.</p>

<h2><a name="Structure"
>Structure</a></h2>

<p>The Class PMC structure (<code>Parrot_Class</code>) consists of twelve items:</p>

<dl>
<dt><a name="id"
><b><code>id</b></code></a></dt>
The type number of the PMC.
[deprecated: See RT #48024]
<dt><a name="name"
><b><code>name</b></code></a></dt>
The name of the class &#45;&#45; a STRING.
An empty STRING is allocated during initialization.
<dt><a name="namespace"
><b><code>namespace</b></code></a></dt>
The namespace the class is associated with,
if any.
A Null PMC is allocated during initialization.
<dt><a name="instantiated"
><b><code>instantiated</b></code></a></dt>
A flag denoting whether this class has been instantiated since last modification.
A native integer with value zero is allocated during initialization.
<dt><a name="parents"
><b><code>parents</b></code></a></dt>
An array of immediate parent classes.
An empty ResizablePMCArray PMC is allocated during initialization.
<dt><a name="all_parents"
><b><code>all_parents</b></code></a></dt>
A cached array of ourself and all parent classes,
in method resolution order (MRO).
A ResizablePMCArray PMC is allocated during initialization,
and is populated with the current class.
<dt><a name="roles"
><b><code>roles</b></code></a></dt>
An array of the roles this class has been composed from.
An empty ResizablePMCArray PMC is allocated during initialization.
<dt><a name="methods"
><b><code>methods</b></code></a></dt>
A directory of method names and method bodies this class provides.
An empty Hash PMC is allocated during initialization.
<dt><a name="vtable_overrides"
><b><code>vtable_overrides</b></code></a></dt>
A directory of vtable method names and method bodies this class overrides.
An empty Hash PMC is allocated during initialization.
<dt><a name="attrib_metadata"
><b><code>attrib_metadata</b></code></a></dt>
A directory of attribute names and attribute metadata this class contains.
An empty Hash PMC is allocated during initialization.
<dt><a name="attrib_index"
><b><code>attrib_index</b></code></a></dt>
A lookup table for attributes in this class and parents.
A Null PMC is allocated during initialization.
<dt><a name="attrib_cache"
><b><code>attrib_cache</b></code></a></dt>
A cache of visible attribute names to attribute indexes.
A Null PMC is allocated during initialization.
<dt><a name="resolve_method"
><b><code>resolve_method</b></code></a></dt>
A list of method names the class provides used for name conflict resolution.
An empty ResizablePMCArray PMC is allocated during initialization.</dl>

<h2><a name="Functions"
>Functions</a></h2>

<dl>
<dt><a name="void_init()"
><b><code>void init()</b></code></a></dt>
Initializes a Class PMC.
<dt><a name="void_init_pmc(PMC_*init_data)"
><b><code>void init_pmc(PMC *init_data)</b></code></a></dt>
The actual class creation code,
called from <code>newclass</code> opcode.
The <code>init_data</code> argument may be either the name of the class or a hash of initialization arguments.
The class is attached to the current HLL namespace.
<dt><a name="STRING_*get_string()"
><b><code>STRING *get_string()</b></code></a></dt>
Returns the name of the class (without the HLL namespace).
<dt><a name="void_mark()"
><b><code>void mark()</b></code></a></dt>
Marks any referenced strings and PMCs in the structure as live.
<dt><a name="void_add_attribute(STRING_*name,_PMC_*type)"
><b><code>void add_attribute(STRING *name, PMC *type)</b></code></a></dt>
Adds the given attribute (<code>name</code>) with an optional <code>type</code>.
Throws an exception if the current class has been instantiated.
Enters the attribute in the <code>attrib_metadata</code> table.
Returns an error if an attribute of <code>name</code> already exists.
<dt><a name="void_remove_attribute(STRING_*name)"
><b><code>void remove_attribute(STRING *name)</b></code></a></dt>
Removes the given attribute (<code>name</code>) from the class.
Throws an exception if the current class has been instantiated,
or if the class has no attribute <code>name</code>.
<dt><a name="void_add_method(STRING_*name,_PMC_*sub)"
><b><code>void add_method(STRING *name, PMC *sub)</b></code></a></dt>
Adds the given sub PMC as a method with the given name.
<dt><a name="void_remove_method(STRING_*name)"
><b><code>void remove_method(STRING *name)</b></code></a></dt>
Removes the method with the given name.
<dt><a name="void_add_vtable_override(STRING_*name,_PMC_*sub)"
><b><code>void add_vtable_override(STRING *name, PMC *sub)</b></code></a></dt>
Adds the given sub PMC as a vtable override with the given name.
<dt><a name="void_add_parent(PMC_*parent)"
><b><code>void add_parent(PMC *parent)</b></code></a></dt>
Adds the supplied PMC to the list of parents for the class.
<dt><a name="void_remove_parent(PMC_*parent)"
><b><code>void remove_parent(PMC *parent)</b></code></a></dt>
Remove the supplied class object from the list of parents for the class.
Throws an exception if parent is null,
is not a class,
or is not a parent,
or if the class has been instantiated.
<dt><a name="void_add_role(PMC_*role)"
><b><code>void add_role(PMC *role)</b></code></a></dt>
Adds the supplied PMC to the list of roles for the class,
provided there are no conflicts.
<dt><a name="PMC_*inspect_str(STRING_*what)"
><b><code>PMC *inspect_str(STRING *what)</b></code></a></dt>
Provides introspection of a specific piece of information about the class.
The available information is:
<dl>
<dt><a name="name"
>name</a></dt>
String PMC containing the name of the class
<dt><a name="namespace"
>namespace</a></dt>
NameSpace PMC of the the namespace attached to the class.
<dt><a name="attributes"
>attributes</a></dt>
Hash keyed on attribute name,
where the value is a hash describing it.
<dt><a name="methods"
>methods</a></dt>
Hash keyed on method name,
value is an invokable PMC.
Includes methods composed in from roles.
<dt><a name="roles"
>roles</a></dt>
Array of Role PMCs.
Includes roles done by the roles that were composed into this class.
<dt><a name="parents"
>parents</a></dt>
Array of Class PMCs representing the direct parents of this class.</dl>

<dt><a name="PMC_*inspect()"
><b><code>PMC *inspect()</b></code></a></dt>
Returns a Hash describing the class,
with key/value pairs as described in inspect_str.
<dt><a name="PMC_*clone()"
><b><code>PMC *clone()</b></code></a></dt>
Returns an anonymous copy of the class (with no name and no link to a namespace).
Unsets the instantiated flag,
allowing modifications.
<dt><a name="PMC_*clone_pmc(PMC_*args)"
><b><code>PMC *clone_pmc(PMC *args)</b></code></a></dt>
Makes a copy of the class,
then modifies or adds to it based upon the contents of the supplied initialization data.
If a new name or namespace is not supplied in <code>args</code> then the cloned class will be anonymous.
The instantiated flag is unset to allow further modifications.
<dt><a name="PMC_*instantiate(PMC_*init)"
><b><code>PMC *instantiate(PMC *init)</b></code></a></dt>
Creates a new PMC object of the type of the class and calls init().
<dt><a name="INTVAL_isa_pmc(PMC_*class)"
><b><code>INTVAL isa_pmc(PMC *class)</b></code></a></dt>
Returns whether the class is or inherits from <code>*class</code>.
<dt><a name="INTVAL_isa(STRING_*classname)"
><b><code>INTVAL isa(STRING *classname)</b></code></a></dt>
Returns whether the class is or inherits from <code>*classname</code>.
<dt><a name="INTVAL_does(STRING_*role_name)"
><b><code>INTVAL does(STRING *role_name)</b></code></a></dt>
Returns whether the class does the role with the given <code>*role_name</code>.
<dt><a name="INTVAL_does_pmc(PMC_*role)"
><b><code>INTVAL does_pmc(PMC *role)</b></code></a></dt>
Returns whether the class does the given <code>*role</code>.
<dt><a name="INTVAL_type()"
><b><code>INTVAL type()</b></code></a></dt>
Returns the integer type of the class.
<dt><a name="void_visit(visit_info_*info)"
><b><code>void visit(visit_info *info)</b></code></a></dt>
This is used by freeze/thaw to visit the contents of the class.<code>*info</code> is the visit info,
(see <em>include/parrot/pmc_freeze.h</em>).
<dt><a name="void_freeze(visit_info_*info)"
><b><code>void freeze(visit_info *info)</b></code></a></dt>
Used to archive the class.
<dt><a name="void_thaw(visit_info_*info)"
><b><code>void thaw(visit_info *info)</b></code></a></dt>
Used to unarchive the class.
<dt><a name="INTVAL_get_integer()"
><b><code>INTVAL get_integer()</b></code></a></dt>
This is just a temporary hack.
Type ID numbers shouldn&#39;t be externally visible to the average PIR user.
However,
we need this for now to interface with functions like pmc_new and pmc_reuse,
which take type ID numbers still.
<dt><a name="void_thawfinish(visit_info_*info)"
><b><code>void thawfinish(visit_info *info)</b></code></a></dt>
Called after the class has been thawed.
<dt><a name="void_name(STRING_*name_:optional,_int_has_name_:opt_flag)"
><b><code>void name(STRING *name :optional, int has_name :opt_flag)</b></code></a></dt>
Sets the name of the class,
and updates the namespace accordingly.
<dt><a name="void_get_namespace()"
><b><code>void get_namespace()</b></code></a></dt>
Gets the namespace that this class is attached to.
<dt><a name="void_resolve_method()"
><b><code>void resolve_method()</b></code></a></dt>
Sets the list of method names that the class provides to resolve conflicts in methods from roles.
When called with no parameter,
returns the list.
<dt><a name="void_new(PMC_*args_:slurpy_:named)"
><b><code>void new(PMC *args :slurpy :named)</b></code></a></dt>
Creates an instance of the object.
Initializes any attributes specified in the parameter list.
<dt><a name="void_attributes()"
><b><code>void attributes()</b></code></a></dt>
Return a hash where the keys are attribute names and the values are hashes providing a set of key/value pairs describing the attribute.
<dt><a name="void_add_attribute()"
><b><code>void add_attribute()</b></code></a></dt>
Add an attribute to the class.
Requires a name and,
optionally,
a type.
<dt><a name="void_methods()"
><b><code>void methods()</b></code></a></dt>
Return a hash where the keys are method names and the values are methods.
<dt><a name="void_add_method(STRING_*name,_PMC_*sub)"
><b><code>void add_method(STRING *name, PMC *sub)</b></code></a></dt>
Adds the given sub PMC as a method with the given name.
Delegates to the <code>add_method</code> vtable method.
<dt><a name="void_add_vtable_override(STRING_*name,_PMC_*sub)"
><b><code>void add_vtable_override(STRING *name, PMC *sub)</b></code></a></dt>
Adds the given sub PMC as a vtable override with the given name.
Delegates to the <code>add_vtable_override</code> vtable method.
<dt><a name="void_remove_method(STRING_*name)"
><b><code>void remove_method(STRING *name)</b></code></a></dt>
Removes the method with the given name.
<dt><a name="PMC_*find_method(STRING_*name)"
><b><code>PMC *find_method(STRING *name)</b></code></a></dt>
Walks the MRO of the class and finds the method with the given name.
<dt><a name="void_parents()"
><b><code>void parents()</b></code></a></dt>
Returns the parents array PMC.
<dt><a name="void_add_parent(PMC_*parent)"
><b><code>void add_parent(PMC *parent)</b></code></a></dt>
Adds the supplied PMC to the list of parents for the class.
<dt><a name="void_roles()"
><b><code>void roles()</b></code></a></dt>
Returns the roles array PMC.
<dt><a name="void_add_role(PMC_*role,_PMC_*exclude_:optional_:named(&#34;exclude&#34;),_PMC_*alias_:optional_:named(&#34;alias&#34;))"
><b><code>void add_role(PMC *role, PMC *exclude :optional :named(&#34;exclude&#34;), PMC *alias :optional :named(&#34;alias&#34;))</b></code></a></dt>
Composes a role into a class with the given exclusions and aliases.
<dt><a name="void_inspect(STRING_*what_:optional)"
><b><code>void inspect(STRING *what :optional)</b></code></a></dt>
Gets all introspection data for the class or,
if the optional string parameter is supplied,
a particular item of introspection data.
<dt><a name="void_isa(STRING_*class_name)"
><b><code>void isa(STRING *class_name)</b></code></a></dt>
Returns true if this object is or derives from the class named in <code>class_name</code>,
false otherwise.
<dt><a name="void_does(STRING_*role_name)"
><b><code>void does(STRING *role_name)</b></code></a></dt>
Returns true if this object or one of its parents performs the named role,
false otherwise.</dl>

<h1><a name="SEE_ALSO"
>SEE ALSO</a></h1>

<p><em><a href="../../docs/pdds/pdd15_objects.pod.html">docs/pdds/pdd15_objects.pod</a></em>.</p>
            </div> <!-- "mainbody" -->
            <div id="divider"></div>
            <div id="footer">
	        Copyright &copy; 2002-2009, Parrot Foundation.
            </div>
        </div> <!-- "wrapper" -->
    </body>
</html>