fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / src / pmc / imageiostrings.pmc
blobafe62f410c6b92c47c7c6ec309802e5119b8175a
1 /*
2 Copyright (C) 2010, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 src/pmc/imageiosize.pmc - ImageIOStrings PMC
9 =head1 DESCRIPTION
11 Get a list of strings in an object graph. Used in packfile creation.
13 =cut
17 /* HEADERIZER HFILE: none */
18 /* HEADERIZER BEGIN: static */
19 /* HEADERIZER END: static */
21 pmclass ImageIOStrings auto_attrs {
22     ATTR PMC *seen; /* seen hash */
23     ATTR PMC *todo; /* todo list */
24     ATTR PMC *list; /* list of strings seen */
28 =head1 VTABLES
30 =over 4
32 =cut
38 =item C<void init()>
40 Initializes the PMC.
42 =cut
45     VTABLE void init() {
46         PARROT_IMAGEIOSTRINGS(SELF)->todo = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
48         PARROT_IMAGEIOSTRINGS(SELF)->seen = Parrot_pmc_new(INTERP, enum_class_Hash);
49         VTABLE_set_pointer(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->seen,
50             parrot_new_intval_hash(INTERP));
52         PARROT_IMAGEIOSTRINGS(SELF)->list = Parrot_pmc_new(INTERP, enum_class_ResizableStringArray);
54         PObj_custom_mark_SET(SELF);
55     }
59 =item C<void mark()>
61 Marks the PMC as alive.
63 =cut
66     VTABLE void mark() {
67         Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->todo);
68         Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->seen);
69         Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->list);
70     }
74 =item C<VTABLE PMC *get_pmc()>
76 Gets the result PMC after a thaw.
78 =cut
82     VTABLE PMC *get_pmc() {
83         return PARROT_IMAGEIOSTRINGS(SELF)->list;
84     }
88 =item C<VTABLE PMC *get_iter()>
90 Get the C<todo> list for this freeze/thaw for iterating over.
92 =cut
96     VTABLE PMC *get_iter() {
97         return PARROT_IMAGEIOSTRINGS(SELF)->todo;
98     }
102 =item C<VTABLE INTVAL get_integer()>
104 Returns the flags describing the visit action
106 =cut
110     VTABLE INTVAL get_integer() {
111         return VISIT_FREEZE_NORMAL;
112     }
117 =item C<VTABLE void push_integer(INTVAL v)>
119 Do nothing.
121 =cut
125     VTABLE void push_integer(INTVAL v) { }
130 =item C<VTABLE void push_float(FLOATVAL v)>
132 Do nothing.
134 =cut
138     VTABLE void push_float(FLOATVAL v) { }
143 =item C<VTABLE void push_string(STRING *v)>
145 Adds the string to the list of strings.
147 =cut
151     VTABLE void push_string(STRING *v)
152     {
153         VTABLE_push_string(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->list, v);
154     }
158 =item C<VTABLE void push_pmc(PMC *v)>
160 Checks new pmcs for strings.
162 =cut
166     VTABLE void push_pmc(PMC *v) {
167         if (!PMC_IS_NULL(v)) {
168             Hash * const hash    = (Hash *)VTABLE_get_pointer(INTERP,
169                                                 PARROT_IMAGEIOSTRINGS(SELF)->seen);
170             HashBucket * const b = parrot_hash_get_bucket(INTERP, hash, v);
171             if (!b) {
172                 /* not yet seen */
173                 parrot_hash_put(INTERP, hash, v, v);
174                 VTABLE_push_pmc(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->todo, v);
175             }
176         }
177     }
179     VTABLE void set_pmc(PMC *p)
180     {
181         STATICSELF.push_pmc(p);
182         Parrot_visit_loop_visit(INTERP, SELF);
183     }
187 =back
189 =cut
196  * Local variables:
197  *   c-file-style: "parrot"
198  * End:
199  * vim: expandtab shiftwidth=4:
200  */