fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / src / pmc / packfilefixupentry.pmc
blobd4f1124cbffd946a7beeb6a4fc9ef6562f70d6b7
1 /*
2 Copyright (C) 2001-2010, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 src/pmc/packfilefixupentry.pmc - PackfileFixupEntry PMC
9 =head1 DESCRIPTION
11 This class implements a PackfileFixupEntry object.  It is an element in the
12 PackfileFixupTable segment of the .pbc file.  See PDD13 for a design spec.
14 =head2 Methods
16 =over 4
18 =cut
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
26 pmclass PackfileFixupEntry auto_attrs {
27     ATTR INTVAL     type;
28     ATTR STRING     *name;
29     ATTR INTVAL     offset;
34 =item C<void init()>
36 Initialize PackfileFixupEntry.
38 =cut
41     VTABLE void init() {
42         Parrot_PackfileFixupEntry_attributes * attrs =
43                 PMC_data_typed(SELF, Parrot_PackfileFixupEntry_attributes*);
45         attrs->name = CONST_STRING(INTERP, "");
47         PObj_custom_mark_SET(SELF);
48     }
50     VTABLE void init_pmc(PMC *init) {
51         Parrot_PackfileFixupEntry_attributes * attrs =
52                 PMC_data_typed(SELF, Parrot_PackfileFixupEntry_attributes*);
53         STRING *name    = CONST_STRING_GEN(INTERP, "name");
54         STRING *type    = CONST_STRING_GEN(INTERP, "type");
55         STRING *offset  = CONST_STRING_GEN(INTERP, "offset");
57         attrs->name = VTABLE_get_string(INTERP,
58                         VTABLE_get_pmc_keyed_str(INTERP, init, name));
59         attrs->type = VTABLE_get_integer(INTERP,
60                         VTABLE_get_pmc_keyed_str(INTERP, init, type));
61         attrs->offset = VTABLE_get_integer(INTERP,
62                         VTABLE_get_pmc_keyed_str(INTERP, init, offset));
64         PObj_custom_mark_SET(SELF);
65     }
69 =item C<void mark()>
71 Marks the object as live.
73 =cut
77     VTABLE void mark() {
78         Parrot_PackfileFixupEntry_attributes * const attrs =
79                 PARROT_PACKFILEFIXUPENTRY(SELF);
81         Parrot_gc_mark_STRING_alive(INTERP, attrs->name);
82     }
86 =item C<void set_pointer(void *pointer)>
88 Initialize from PackFile_FixupEntry pointer.
90 =cut
94     VTABLE void set_pointer(void * pointer) {
95         Parrot_PackfileFixupEntry_attributes * const attrs =
96                 PARROT_PACKFILEFIXUPENTRY(SELF);
97         PackFile_FixupEntry *entry = (PackFile_FixupEntry*)pointer;
99         attrs->type     = entry->type;
100         attrs->name     = Parrot_str_new_init(INTERP, entry->name,
101                 strlen(entry->name), Parrot_binary_encoding_ptr, 0);
102         attrs->offset   = entry->offset;
103     }
107 =item C<void *get_pointer()>
109 Create PackFile_FixupEntry* from self.
111 =cut
114     VTABLE void *get_pointer() {
115         Parrot_PackfileFixupEntry_attributes * const attrs =
116                 PARROT_PACKFILEFIXUPENTRY(SELF);
117         PackFile_FixupEntry                  * const entry =
118                 mem_gc_allocate_zeroed_typed(INTERP, PackFile_FixupEntry);
120         entry->type     = attrs->type;
121         entry->name     = strdup(Parrot_str_cstring(INTERP, attrs->name));
122         entry->offset   = attrs->offset;
123         return entry;
124     }
129 =item C<STRING *get_string()>
131 Fetch the label field of the fixup entry.
133 =cut
136     VTABLE STRING *get_string() {
137         return PARROT_PACKFILEFIXUPENTRY(SELF)->name;
138     }
142 =item C<void set_string_native(STRING *value)>
144 Set the label field of the fixup entry.
146 =cut
149     VTABLE void set_string_native(STRING *value) {
150         SETATTR_PackfileFixupEntry_name(INTERP, SELF, value);
151     }
156 =item C<INTVAL get_integer()>
158 Fetch the offset field of the fixup entry.
160 =cut
163     VTABLE INTVAL get_integer() {
164         return PARROT_PACKFILEFIXUPENTRY(SELF)->offset;
165     }
170 =item C<void set_integer_native(INTVAL offset)>
172 Set the offset field of the fixup entry.
174 =cut
177     VTABLE void set_integer_native(INTVAL offset) {
178         SETATTR_PackfileFixupEntry_offset(INTERP, SELF, offset);
179     }
184 =item C<INTVAL get_type()>
186 Fetch the type field of the fixup entry.
188 =cut
191     METHOD get_type() {
192         const INTVAL rv = PARROT_PACKFILEFIXUPENTRY(SELF)->type;
193         RETURN(INTVAL rv);
194     }
199 =item C<void set_type(INTVAL type)>
201 Set the type field of the fixup entry.
203 =cut
206     METHOD set_type(INTVAL type) {
207         SETATTR_PackfileFixupEntry_type(INTERP, SELF, type);
208     }
213 =back
215 =cut
220  * Local variables:
221  *   c-file-style: "parrot"
222  * End:
223  * vim: expandtab shiftwidth=4:
224  */