NAME
src/pmc/namespace.pmc - NameSpace PMC
DESCRIPTION
These are the vtable functions for the namespace PMC.
Functions
static void add_to_class(PARROT_INTERP, Parrot_NameSpace_attributes *nsinfo, PMC *classobj, STRING *key, PMC *value)
Add the method Sub static int ns_insert_sub_keyed_str(PARROT_INTERP, PMC *self, STRING *key, PMC *value)
Add the Sub PMC static int maybe_add_sub_to_namespace(PARROT_INTERP, PMC *SELF, STRING *key, PMC *value)
If the item static void add_native_to_namespace(PARROT_INTERP, PMC *SELF, STRING *key, PMC *value)
Add an NCI or NativePCCMethod PMC to the namespace.
The PMC static void add_multi_to_namespace(PARROT_INTERP, PMC *SELF, STRING *key, PMC *value)
If PMC void init()
Initialize a void mark()
Marks the namespace as live.
PMC *get_class()
Returns the class or role PMC that is associated with this namespace.
void set_pmc_keyed_str(STRING *key, PMC *value)
Sets void set_pmc_keyed(PMC *key, PMC *value)
If PMC *get_pmc_keyed(PMC *key)
Return the given namespace or PMCNULL.
PMC *get_pmc_keyed_str(STRING *key)
Return the given namespace item or PMCNULL.
If the named item is either a NameSpace or a var,
the NameSpace is returned.
PMC *get_pmc_keyed_int(INTVAL key)
Return a Sub representing an overridden vtable entry or PMCNULL.
This is not really a public API.
void *get_pointer_keyed_str(STRING *key)
Return the given namepace item or PMCNULL,
keyed by name.
void *get_pointer_keyed(PMC *key)
Return the given namespace item or PMCNULL.
If the named item is either a NameSpace or a var,
the var is returned.TT #1472 TOTAL KLUDGE.
ON THE CHOPPING BLOCK.
STRING *get_string()
Return the name of this namespace part.
PMC *inspect_str(STRING *what)
Provides introspection of a specific piece of information about the namespace.
The available information is:
- class The class object associated with the namespace, if any.
- methods A temporary cache of methods (destroyed when class object is created). Hash keyed on method name, value is an invokable PMC. Includes methods composed in from roles.
- vtable_overrides A temporary cache of vtable overrides (destroyed when class object is created). Hash keyed on vtable name, value is an invokable PMC. Includes vtable overrides composed in from roles.
value
with name key
to the classobj
.
value
to the namespace.
If it's a vtable,
add it as a vtable to the corresponding Class (or store it locally for the Class to fetch later).
If it's a method,
do the same.
value
is a non-null Sub PMC (but not a subclass),
add it to the namespace and any associated Class PMC (if it's a method or vtable).
value
must be non-null.
If it's flagged as a method (usually for NativePCCMethod PMCs) add it to the Class as well.
value
is a MultiSub,
add it to the namespace and possibly the associated class.
NameSpace
PMC.
*value
as the namespace item for *key
.
This is part of the raw interface.
If the PMC value
is exactly a NameSpace,
SELF
will be set as the parent of that namespace and the name key
of value
is stored too.
key
is a simple key,
it works like above.
If key
is an array of strings or a chained key,
add all components to the namespace.
key
is either an array of strings,
or a possibly nested key.
Methods
METHOD make_namespace(PMC* key)
Create and retrieve the namespace given by METHOD add_namespace(STRING *name, PMC *namespace)
Stores the given namespace under this namespace,
with the given name.
Throws an invalid type exception if METHOD add_sub(STRING *name, PMC *sub)
Stores the given sub under this namespace,
with the given name.
Throws an invalid type exception if METHOD add_var(STRING *name, PMC *var)
Stores the given variable under this namespace,
with the given name.
METHOD get_name()
Returns the name of the namespace as an array of strings.
METHOD find_namespace(STRING *name)
Return the namespace with the given name.
METHOD find_sub(STRING *name)
Return the Sub PMC with the given name.
METHOD find_var(STRING *name)
Return the PMC with the given name.
METHOD del_namespace(STRING *name)
Deletes the contained NameSpace PMC with the given name. Throws an invalid type exception if the item to delete is not a NameSpace PMC or subclass, and does not delete the PMC.
METHOD del_sub(STRING *name)
Deletes the contained Sub PMC with the given name. Throws an invalid type exception if the item to delete is not a Sub PMC or subclass, and does not delete the PMC.
METHOD del_var(STRING *name)
Deletes the contained variable-like PMC with the given name.
METHOD get_sym(STRING *name)
Return the symbol (var or sub) with the given name. This can be used to retrieve symbols, if a NameSpace with the same name exists.
METHOD export_to(PMC *dest, PMC *what)
Export items from this NameSpace into the METHOD get_parent()
Return the parent NameSpace or PMCNULL, if none.
METHOD get_class()
Returns the class or role PMC that is associated with this namespace.
METHOD set_class(PMC *class_or_role)
Sets the class or role PMC that is associated with this namespace.
METHOD get_associated_methods()
Gets the Hash of methods associated with this namespace and removes it from the namespace.
METHOD get_associated_vtable_methods()
Gets the Hash of vtables associated with this namespace and removes it from the namespace.
key
.
If the namespace already exists,
only retrieve it.
namespace
is not a NameSpace PMC or subclass.
sub
is not a Sub PMC or subclass.
$P2 = $P3.'get_name'() $S0 = join '::', $P2 # '::Foo::Bar'
dest
NameSpace. The items to export are named in what
, which may be an array of strings, a hash, or null. If what
is an array of strings, interpretation of items in an array follows the conventions of the source (exporting) namespace. If what
is a hash, the keys correspond to the names in the source namespace, and the values correspond to the names in the destination namespace. if a hash value is null or an empty string, the name in the hash key is used. A null what
requests the 'default' set of items. Any other type passed in what
throws an exception.NOTE: exporting 'default' set of items is not yet implemented.
SEE ALSO
docs/pdds/pdd21_namespaces.pod