[svn:parrot] r41228 - trunk/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Sat Sep 12 12:55:12 UTC 2009
Author: bacek
Date: Sat Sep 12 12:55:08 2009
New Revision: 41228
URL: https://trac.parrot.org/parrot/changeset/41228
Log:
[core] Migrate Packfile* PMCs to auto_attrs
Modified:
trunk/src/pmc/packfile.pmc
trunk/src/pmc/packfileannotation.pmc
trunk/src/pmc/packfileannotations.pmc
trunk/src/pmc/packfileconstanttable.pmc
trunk/src/pmc/packfiledirectory.pmc
trunk/src/pmc/packfilefixupentry.pmc
trunk/src/pmc/packfilefixuptable.pmc
trunk/src/pmc/packfilerawsegment.pmc
trunk/src/pmc/packfilesegment.pmc
Modified: trunk/src/pmc/packfile.pmc
==============================================================================
--- trunk/src/pmc/packfile.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfile.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -43,7 +43,7 @@
}
-pmclass Packfile {
+pmclass Packfile auto_attrs {
ATTR INTVAL wordsize;
ATTR INTVAL byteorder;
ATTR INTVAL fptype;
@@ -67,41 +67,23 @@
*/
VTABLE void init() {
Parrot_Packfile_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_Packfile_attributes);
+ PMC_data_typed(SELF, Parrot_Packfile_attributes*);
PackFile *pf;
attrs->uuid = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
attrs->directory = pmc_new(INTERP, enum_class_PackfileDirectory);
- PMC_data(SELF) = attrs;
/* Create dummy PackFile and copy default attributes to self */
pf = PackFile_new(interp, 0);
copy_packfile_header(interp, SELF, pf);
PackFile_destroy(interp, pf);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
}
/*
-=item C<void destroy()>
-
-Destroys the PackFile object.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- if (PARROT_PACKFILE(SELF)) {
- mem_sys_free(PARROT_PACKFILE(SELF));
- PMC_data(SELF) = NULL;
- }
- }
-
-/*
-
=item C<void mark()>
Marks the Packfile as alive.
@@ -115,7 +97,7 @@
if (attrs->uuid)
Parrot_gc_mark_PObj_alive(INTERP, (PObj *)attrs->uuid);
- if (attrs->directory)
+ if (!PMC_IS_NULL(attrs->directory))
Parrot_gc_mark_PObj_alive(INTERP, (PObj *)attrs->directory);
}
/*
Modified: trunk/src/pmc/packfileannotation.pmc
==============================================================================
--- trunk/src/pmc/packfileannotation.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfileannotation.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -19,7 +19,7 @@
*/
-pmclass PackfileAnnotation {
+pmclass PackfileAnnotation auto_attrs {
ATTR STRING *name;
ATTR INTVAL offset;
ATTR INTVAL value_type;
@@ -40,32 +40,33 @@
VTABLE void init() {
Parrot_PackfileAnnotation_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileAnnotation_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileAnnotation_attributes*);
- PObj_custom_destroy_SET(SELF);
+ PObj_custom_mark_SET(SELF);
PMC_data(SELF) = attrs;
}
/*
-=item C<void destroy()>
+=item C<void mark()>
-Destroys the PMC and frees all allocated memory.
+Marks the object as live.
=cut
*/
- VTABLE void destroy() {
+ VTABLE void mark() {
Parrot_PackfileAnnotation_attributes * attrs =
PARROT_PACKFILEANNOTATION(SELF);
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
+ if (attrs->name)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->name);
+ if ((attrs->value_type == PF_ANNOTATION_KEY_TYPE_STR) && attrs->str_value)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->str_value);
}
+
/*
=item C<INTVAL get_offset()>
Modified: trunk/src/pmc/packfileannotations.pmc
==============================================================================
--- trunk/src/pmc/packfileannotations.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfileannotations.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -29,7 +29,7 @@
#include "pmc_packfileannotation.h"
-pmclass PackfileAnnotations extends PackfileSegment {
+pmclass PackfileAnnotations auto_attrs extends PackfileSegment {
/* ConstantTable used for names lookup */
ATTR PMC *const_table;
@@ -47,12 +47,15 @@
*/
VTABLE void init() {
Parrot_PackfileAnnotations_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileAnnotations_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileAnnotations_attributes*);
attrs->annotations = pmc_new(interp, enum_class_ResizablePMCArray);
+ /*
+ Don't initialize C<const_table>. It will be set to NULL bu auto_attrs
+ handling. And should be set to proper PMC in set_directory.
+ */
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -69,35 +72,15 @@
Parrot_PackfileAnnotations_attributes * attrs =
PARROT_PACKFILEANNOTATIONS(SELF);
- if (attrs->const_table)
+ if (!PMC_IS_NULL(attrs->const_table))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->const_table);
- if (attrs->annotations)
+ if (!PMC_IS_NULL(attrs->annotations))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->annotations);
SUPER();
}
-/*
-
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileAnnotations_attributes * attrs =
- PARROT_PACKFILEANNOTATIONS(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
/*
Modified: trunk/src/pmc/packfileconstanttable.pmc
==============================================================================
--- trunk/src/pmc/packfileconstanttable.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfileconstanttable.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -24,7 +24,7 @@
*/
-pmclass PackfileConstantTable extends PackfileSegment {
+pmclass PackfileConstantTable auto_attrs extends PackfileSegment {
/* ResizablePMCArray for storing constants */
ATTR PMC *constants;
@@ -43,12 +43,12 @@
VTABLE void init() {
Parrot_PackfileConstantTable_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileConstantTable_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileConstantTable_attributes*);
attrs->constants = pmc_new(interp, enum_class_ResizablePMCArray);
attrs->types = pmc_new(interp, enum_class_ResizableIntegerArray);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
PMC_data(SELF) = attrs;
}
@@ -66,35 +66,14 @@
Parrot_PackfileConstantTable_attributes * attrs =
PARROT_PACKFILECONSTANTTABLE(SELF);
- if (attrs->constants)
+ if (!PMC_IS_NULL(attrs->constants))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->constants);
- if (attrs->types)
+ if (!PMC_IS_NULL(attrs->types))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->types);
SUPER();
}
-/*
-
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileConstantTable_attributes * attrs =
- PARROT_PACKFILECONSTANTTABLE(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
/*
Modified: trunk/src/pmc/packfiledirectory.pmc
==============================================================================
--- trunk/src/pmc/packfiledirectory.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfiledirectory.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -25,7 +25,7 @@
*/
-pmclass PackfileDirectory extends PackfileSegment {
+pmclass PackfileDirectory auto_attrs extends PackfileSegment {
/* Directory is a hash of Segments */
ATTR PMC *hash;
@@ -40,12 +40,11 @@
*/
VTABLE void init() {
Parrot_PackfileDirectory_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileDirectory_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileDirectory_attributes*);
attrs->hash = pmc_new(interp, enum_class_Hash);
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -62,7 +61,7 @@
Parrot_PackfileDirectory_attributes * attrs =
PARROT_PACKFILEDIRECTORY(SELF);
- if (attrs->hash)
+ if (!PMC_IS_NULL(attrs->hash))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->hash);
SUPER();
Modified: trunk/src/pmc/packfilefixupentry.pmc
==============================================================================
--- trunk/src/pmc/packfilefixupentry.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfilefixupentry.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -19,7 +19,7 @@
*/
-pmclass PackfileFixupEntry {
+pmclass PackfileFixupEntry auto_attrs {
ATTR INTVAL type;
ATTR STRING *name;
ATTR INTVAL offset;
@@ -36,12 +36,11 @@
*/
VTABLE void init() {
Parrot_PackfileFixupEntry_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileFixupEntry_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileFixupEntry_attributes*);
attrs->name = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -64,27 +63,6 @@
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileFixupEntry_attributes * attrs =
- PARROT_PACKFILEFIXUPENTRY(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
-/*
-
=item C<void set_pointer(void *pointer)>
Initialize from PackFile_FixupEntry pointer.
Modified: trunk/src/pmc/packfilefixuptable.pmc
==============================================================================
--- trunk/src/pmc/packfilefixuptable.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfilefixuptable.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -24,7 +24,7 @@
*/
-pmclass PackfileFixupTable extends PackfileSegment {
+pmclass PackfileFixupTable auto_attrs extends PackfileSegment {
/* RPA of entries */
ATTR PMC *entries;
@@ -40,12 +40,11 @@
VTABLE void init() {
Parrot_PackfileFixupTable_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileFixupTable_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileFixupTable_attributes*);
attrs->entries = pmc_new(interp, enum_class_ResizablePMCArray);
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -62,7 +61,7 @@
Parrot_PackfileFixupTable_attributes * attrs =
PARROT_PACKFILEFIXUPTABLE(SELF);
- if (attrs->entries)
+ if (!PMC_IS_NULL(attrs->entries))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->entries);
SUPER();
@@ -70,28 +69,6 @@
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileFixupTable_attributes * attrs =
- PARROT_PACKFILEFIXUPTABLE(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
-
-/*
-
=item C<void set_pointer(void *pointer)>
Initialize from PackFile_FixupTable pointer.
Modified: trunk/src/pmc/packfilerawsegment.pmc
==============================================================================
--- trunk/src/pmc/packfilerawsegment.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfilerawsegment.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -24,7 +24,7 @@
*/
-pmclass PackfileRawSegment extends PackfileSegment {
+pmclass PackfileRawSegment auto_attrs extends PackfileSegment {
/* Type of segment */
ATTR INTVAL type;
/* ResizableIntegerArray of opcodes */
@@ -42,13 +42,12 @@
VTABLE void init() {
Parrot_PackfileRawSegment_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileRawSegment_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileRawSegment_attributes*);
attrs->opcodes = pmc_new(interp, enum_class_ResizableIntegerArray);
attrs->type = PF_BYTEC_SEG;
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -65,33 +64,12 @@
Parrot_PackfileRawSegment_attributes * attrs =
PARROT_PACKFILERAWSEGMENT(SELF);
- if (attrs->opcodes)
+ if (!PMC_IS_NULL(attrs->opcodes))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->opcodes);
SUPER();
}
-/*
-
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileRawSegment_attributes * attrs =
- PARROT_PACKFILERAWSEGMENT(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
/*
Modified: trunk/src/pmc/packfilesegment.pmc
==============================================================================
--- trunk/src/pmc/packfilesegment.pmc Sat Sep 12 11:57:57 2009 (r41227)
+++ trunk/src/pmc/packfilesegment.pmc Sat Sep 12 12:55:08 2009 (r41228)
@@ -23,7 +23,7 @@
*/
-pmclass PackfileSegment {
+pmclass PackfileSegment auto_attrs {
/*
Directory which owns this segment. Required for correct pack/unpack
Annotations.
@@ -42,12 +42,11 @@
*/
VTABLE void init() {
Parrot_PackfileSegment_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileSegment_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileSegment_attributes*);
- attrs->directory = NULL;
+ attrs->directory = PMCNULL;
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -64,32 +63,12 @@
Parrot_PackfileSegment_attributes * attrs =
PARROT_PACKFILESEGMENT(SELF);
- if (attrs->directory)
+ if (!PMC_IS_NULL(attrs->directory))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->directory);
}
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileSegment_attributes * attrs =
- PARROT_PACKFILESEGMENT(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-/*
-
=item C<void set_pointer(void *ptr)>
Initialize PMC internals.
More information about the parrot-commits
mailing list