2 Copyright (C) 2001-2010, Parrot Foundation.
7 src/pmc/packfilefixupentry.pmc - PackfileFixupEntry PMC
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.
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
26 pmclass PackfileFixupEntry auto_attrs {
36 Initialize PackfileFixupEntry.
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);
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);
71 Marks the object as live.
78 Parrot_PackfileFixupEntry_attributes * const attrs =
79 PARROT_PACKFILEFIXUPENTRY(SELF);
81 Parrot_gc_mark_STRING_alive(INTERP, attrs->name);
86 =item C<void set_pointer(void *pointer)>
88 Initialize from PackFile_FixupEntry pointer.
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;
107 =item C<void *get_pointer()>
109 Create PackFile_FixupEntry* from self.
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;
129 =item C<STRING *get_string()>
131 Fetch the label field of the fixup entry.
136 VTABLE STRING *get_string() {
137 return PARROT_PACKFILEFIXUPENTRY(SELF)->name;
142 =item C<void set_string_native(STRING *value)>
144 Set the label field of the fixup entry.
149 VTABLE void set_string_native(STRING *value) {
150 SETATTR_PackfileFixupEntry_name(INTERP, SELF, value);
156 =item C<INTVAL get_integer()>
158 Fetch the offset field of the fixup entry.
163 VTABLE INTVAL get_integer() {
164 return PARROT_PACKFILEFIXUPENTRY(SELF)->offset;
170 =item C<void set_integer_native(INTVAL offset)>
172 Set the offset field of the fixup entry.
177 VTABLE void set_integer_native(INTVAL offset) {
178 SETATTR_PackfileFixupEntry_offset(INTERP, SELF, offset);
184 =item C<INTVAL get_type()>
186 Fetch the type field of the fixup entry.
192 const INTVAL rv = PARROT_PACKFILEFIXUPENTRY(SELF)->type;
199 =item C<void set_type(INTVAL type)>
201 Set the type field of the fixup entry.
206 METHOD set_type(INTVAL type) {
207 SETATTR_PackfileFixupEntry_type(INTERP, SELF, type);
221 * c-file-style: "parrot"
223 * vim: expandtab shiftwidth=4: