Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

203 lines (130 sloc) 3.635 kb
/*
Copyright (C) 2010-2014, Parrot Foundation.
=head1 NAME
src/pmc/imageiostrings.pmc - ImageIOStrings PMC
=head1 DESCRIPTION
Get a list of strings in an object graph. Used in packfile creation.
=cut
*/
/* HEADERIZER HFILE: none */
/* HEADERIZER BEGIN: static */
/* HEADERIZER END: static */
pmclass ImageIOStrings auto_attrs {
ATTR PMC *seen; /* seen hash */
ATTR PMC *todo; /* todo list */
ATTR PMC *list; /* list of strings seen */
/*
=head1 VTABLES
=over 4
=cut
*/
/*
=item C<void init()>
Initializes the PMC.
=cut
*/
VTABLE void init() {
PARROT_IMAGEIOSTRINGS(SELF)->todo = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
PARROT_IMAGEIOSTRINGS(SELF)->seen = Parrot_pmc_new(INTERP, enum_class_Hash);
VTABLE_set_pointer(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->seen,
Parrot_hash_new_intval_hash(INTERP));
PARROT_IMAGEIOSTRINGS(SELF)->list = Parrot_pmc_new(INTERP, enum_class_ResizableStringArray);
PObj_custom_mark_SET(SELF);
}
/*
=item C<void mark()>
Marks the PMC as alive.
=cut
*/
VTABLE void mark() :no_wb {
Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->todo);
Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->seen);
Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->list);
}
/*
=item C<VTABLE PMC *get_pmc()>
Gets the result PMC after a thaw.
=cut
*/
VTABLE PMC *get_pmc() :no_wb {
UNUSED(INTERP)
return PARROT_IMAGEIOSTRINGS(SELF)->list;
}
/*
=item C<VTABLE INTVAL get_integer()>
Returns the flags describing the visit action
=cut
*/
VTABLE INTVAL get_integer() :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
return VISIT_FREEZE_NORMAL;
}
/*
=item C<VTABLE void push_integer(INTVAL v)>
Do nothing.
=cut
*/
VTABLE void push_integer(INTVAL v) :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
UNUSED(v)
}
/*
=item C<VTABLE void push_float(FLOATVAL v)>
Do nothing.
=cut
*/
VTABLE void push_float(FLOATVAL v) :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
UNUSED(v)
}
/*
=item C<VTABLE void push_string(STRING *v)>
Adds the string to the list of strings.
=cut
*/
VTABLE void push_string(STRING *v) :manual_wb {
VTABLE_push_string(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->list, v);
}
/*
=item C<VTABLE void push_pmc(PMC *v)>
Checks new pmcs for strings.
=cut
*/
VTABLE void push_pmc(PMC *v) :manual_wb {
if (!PMC_IS_NULL(v)) {
Hash * const hash = (Hash *)VTABLE_get_pointer(INTERP,
PARROT_IMAGEIOSTRINGS(SELF)->seen);
HashBucket * const b = Parrot_hash_get_bucket(INTERP, hash, v);
if (!b) {
/* not yet seen */
Parrot_hash_put(INTERP, hash, v, v);
VTABLE_push_pmc(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->todo, v);
}
else
PARROT_GC_WRITE_BARRIER(INTERP, SELF);
}
}
VTABLE void set_pmc(PMC *p) :manual_wb {
PMC * const todo = PARROT_IMAGEIOSTRINGS(SELF)->todo;
STATICSELF.push_pmc(p);
while (VTABLE_elements(INTERP, todo)) {
PMC * const current = VTABLE_shift_pmc(INTERP, todo);
VTABLE_freeze(INTERP, current, SELF);
VTABLE_visit(INTERP, current, SELF);
SELF.push_pmc(PMC_metadata(current));
}
}
/*
=back
=cut
*/
}
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/
Jump to Line
Something went wrong with that request. Please try again.