parrotcode: Class and object | |
Contents | C |
objects.c - Class and object
Handles class and object manipulation.
PARROT_API INTVAL Parrot_get_vtable_index(PARROT_INTERP, NOTNULL(const STRING *name))
name
is a valid vtable slot name.PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static PMC *find_vtable_meth_ns(PARROT_INTERP, NOTNULL(PMC *ns), INTVAL vtable_index)
PARROT_API PARROT_CAN_RETURN_NULL PMC *Parrot_find_vtable_meth(PARROT_INTERP, NOTNULL(PMC *pmc), NOTNULL(STRING *meth))
PARROT_API PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL STRING *readable_name(PARROT_INTERP, NOTNULL(PMC *name))
static void fail_if_exist(PARROT_INTERP, NOTNULL(PMC *name))
static void rebuild_attrib_stuff(PARROT_INTERP, NOTNULL(PMC *_class))
static void create_deleg_pmc_vtable(PARROT_INTERP, NOTNULL(PMC *_class), int full)
PARROT_API PARROT_PURE_FUNCTION PARROT_CAN_RETURN_NULL const char *Parrot_MMD_method_name(SHIM_INTERP, INTVAL idx)
PARROT_API PARROT_PURE_FUNCTION INTVAL Parrot_MMD_method_idx(SHIM_INTERP, NOTNULL(const char *name))
PARROT_API PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *Parrot_single_subclass(PARROT_INTERP, NOTNULL(PMC *base_class), NULLOK(PMC *name))
child_class
is NULL
,
this is an anonymous subclass we're creating,
function.PARROT_API void Parrot_new_class(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(PMC *name))
class_name
.PARROT_API PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT PMC *Parrot_class_lookup(PARROT_INTERP, NOTNULL(STRING *class_name))
class_name
and returns it if it exists.
Otherwise it returns PMCNULL
.PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT PMC *Parrot_class_lookup_p(PARROT_INTERP, NOTNULL(PMC *class_name))
class_name
and returns it if it exists.
Otherwise it returns PMCNULL
.PARROT_WARN_UNUSED_RESULT static INTVAL register_type(PARROT_INTERP, NOTNULL(PMC *name))
static void parrot_class_register(PARROT_INTERP, NOTNULL(PMC *name), NOTNULL(PMC *new_class), NULLOK(PMC *parent), NOTNULL(PMC *mro))
init
method initializes objects of the class rather than the class itself,
and adding it to the interpreter's base type table so you can create a new foo
in PASM like this: new Px, foo
.PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static PMC *get_init_meth(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(STRING *prop_str), NOTNULL(STRING **meth_str))
static void do_initcall(PARROT_INTERP, NULLOK(PMC *_class), NULLOK(PMC *object), NULLOK(PMC *init))
PARROT_API void Parrot_instantiate_object_init(PARROT_INTERP, NOTNULL(PMC *object), NOTNULL(PMC *init))
PARROT_API void Parrot_instantiate_object(PARROT_INTERP, NOTNULL(PMC *object))
static void instantiate_object(PARROT_INTERP, NOTNULL(PMC *object), NULLOK(PMC *init))
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static PMC *not_empty(PARROT_INTERP, NOTNULL(PMC *seqs))
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static PMC *class_mro_merge(PARROT_INTERP, NOTNULL(PMC *seqs))
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static PMC *create_class_mro(PARROT_INTERP, NOTNULL(PMC *_class))
PARROT_API PARROT_IGNORABLE_RESULT PARROT_CAN_RETURN_NULL PMC *Parrot_remove_parent(PARROT_INTERP, NOTNULL(PMC *removed_class), NOTNULL(PMC *existing_class))
PMCNULL
.PARROT_API PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL PMC *Parrot_multi_subclass(PARROT_INTERP, NOTNULL(PMC *base_class_array), NOTNULL(STRING *child_class_name))
PMCNULL
.PARROT_API PARROT_WARN_UNUSED_RESULT INTVAL Parrot_object_isa(PARROT_INTERP, NOTNULL(PMC *pmc), NOTNULL(PMC *_class))
pmc
is an instance of class _class
.PARROT_API PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL PMC *Parrot_new_method_cache(PARROT_INTERP)
PMCNULL
.void mark_object_cache(PARROT_INTERP)
void init_object_cache(PARROT_INTERP)
void destroy_object_cache(PARROT_INTERP)
static void invalidate_type_caches(PARROT_INTERP, UINTVAL type)
static void invalidate_all_caches(PARROT_INTERP)
PARROT_API void Parrot_invalidate_method_cache(PARROT_INTERP, NULLOK(STRING *_class), NOTNULL(STRING *meth))
PARROT_API PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT PMC *Parrot_find_method_direct(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(STRING *method_name))
PARROT_API PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT PMC *Parrot_find_method_with_cache(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(STRING *method_name))
static void debug_trace_find_meth(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(STRING *name), NULLOK(PMC *sub))
PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static PMC *find_method_direct_1(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(STRING *method_name))
PARROT_API void Parrot_note_method_offset(PARROT_INTERP, UINTVAL offset, NOTNULL(PMC *method))
PARROT_API INTVAL Parrot_add_attribute(PARROT_INTERP, NOTNULL(PMC *_class), NOTNULL(STRING *attr))
attr
to the class. Life is ever so much easier if a class keeps its attributes at the
end of the attribute array, since we don't have to insert and
reorder attributes. Inserting's no big deal, especially since we're
going to break horribly if you insert into a class that's been
subclassed, but it'll do for now.
PARROT_API PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT PMC *Parrot_get_attrib_by_num(PARROT_INTERP, NOTNULL(PMC *object), INTVAL attrib)
attrib
from object
. Presumably the code is asking for the correct attribute number.static INTVAL attr_str_2_num(PARROT_INTERP, NOTNULL(PMC *object), NOTNULL(STRING *attr))
PARROT_API PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT PMC *Parrot_get_attrib_by_str(PARROT_INTERP, NOTNULL(PMC *object), NOTNULL(STRING *attr))
attr
from object
.PARROT_API void Parrot_set_attrib_by_num(PARROT_INTERP, NOTNULL(PMC *object), INTVAL attrib, NOTNULL(PMC *value))
attrib
from object
to value
. Presumably the code is asking for the correct attribute number.PARROT_API void Parrot_set_attrib_by_str(PARROT_INTERP, NOTNULL(PMC *object), NOTNULL(STRING *attr), NOTNULL(PMC *value))
attr
from object
to value
.PARROT_API INTVAL Parrot_class_offset(PARROT_INTERP, NOTNULL(PMC *object), NOTNULL(STRING *_class))
PARROT_API PARROT_CAN_RETURN_NULL PMC *Parrot_find_class_constructor(PARROT_INTERP, NOTNULL(STRING *_class), INTVAL classtoken)
PARROT_API PARROT_CAN_RETURN_NULL PMC *Parrot_find_class_destructor(PARROT_INTERP, NOTNULL(STRING *_class), INTVAL classtoken)
PARROT_API PARROT_CAN_RETURN_NULL PMC *Parrot_find_class_fallback(PARROT_INTERP, NOTNULL(STRING *_class), INTVAL classtoken)
PARROT_API void Parrot_set_class_constructor(PARROT_INTERP, NOTNULL(STRING *_class), INTVAL classtoken, NOTNULL(STRING *method))
PARROT_API void Parrot_set_class_destructor(PARROT_INTERP, NOTNULL(STRING *_class), INTVAL classtoken, NOTNULL(STRING *method))
PARROT_API void Parrot_set_class_fallback(PARROT_INTERP, NOTNULL(STRING *_class), INTVAL classtoken, NOTNULL(STRING *method))
PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static PMC *C3_merge(PARROT_INTERP, NOTNULL(PMC *merge_list))
PARROT_API PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL PMC *Parrot_ComputeMRO_C3(PARROT_INTERP, NOTNULL(PMC *_class))
PARROT_API void Parrot_ComposeRole(PARROT_INTERP, NOTNULL(PMC *role), NOTNULL(PMC *exclude), int got_exclude, NOTNULL(PMC *alias), int got_alias, NOTNULL(PMC *methods_hash), NOTNULL(PMC *roles_list))
role
parameter is the role that we are composing into the class or role. methods_hash
is the hash of method names to invokable PMCs that contains the methods the class or role has. roles_list
is the list of roles the the class or method does.role
parameter is only dealt with by its external interface. Whether this routine is usable by any other object system implemented in Parrot very much depends on how closely the role composition semantics they want are to the default implementation.include/parrot/objects.h, docs/pdds/pdd15_objects.pod.
|