[svn:parrot] r40628 - in trunk: lib/Parrot lib/Parrot/Pmc2c src src/dynpmc src/gc src/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Tue Aug 18 17:24:29 UTC 2009
Author: NotFound
Date: Tue Aug 18 17:24:24 2009
New Revision: 40628
URL: https://trac.parrot.org/parrot/changeset/40628
Log:
merge auto_attrs branch into trunk
Modified:
trunk/lib/Parrot/Pmc2c/PMCEmitter.pm
trunk/lib/Parrot/Vtable.pm
trunk/src/dynpmc/dynlexpad.pmc
trunk/src/dynpmc/foo.pmc
trunk/src/dynpmc/foo2.pmc
trunk/src/dynpmc/rotest.pmc
trunk/src/gc/api.c
trunk/src/pmc.c
trunk/src/pmc/arrayiterator.pmc
trunk/src/pmc/boolean.pmc
trunk/src/pmc/callsignature.pmc
trunk/src/pmc/capture.pmc
trunk/src/pmc/class.pmc
trunk/src/pmc/codestring.pmc
trunk/src/pmc/complex.pmc
trunk/src/pmc/continuation.pmc
trunk/src/pmc/cpointer.pmc
trunk/src/pmc/default.pmc
trunk/src/pmc/exception.pmc
trunk/src/pmc/exceptionhandler.pmc
trunk/src/pmc/exporter.pmc
trunk/src/pmc/filehandle.pmc
trunk/src/pmc/fixedbooleanarray.pmc
trunk/src/pmc/fixedfloatarray.pmc
trunk/src/pmc/fixedintegerarray.pmc
trunk/src/pmc/fixedpmcarray.pmc
trunk/src/pmc/fixedstringarray.pmc
trunk/src/pmc/float.pmc
trunk/src/pmc/hashiterator.pmc
trunk/src/pmc/hashiteratorkey.pmc
trunk/src/pmc/integer.pmc
trunk/src/pmc/key.pmc
trunk/src/pmc/lexpad.pmc
trunk/src/pmc/managedstruct.pmc
trunk/src/pmc/multisub.pmc
trunk/src/pmc/nci.pmc
trunk/src/pmc/orderedhashiterator.pmc
trunk/src/pmc/parrotinterpreter.pmc
trunk/src/pmc/parrotlibrary.pmc
trunk/src/pmc/pmcproxy.pmc
trunk/src/pmc/pointer.pmc
trunk/src/pmc/resizablebooleanarray.pmc
trunk/src/pmc/resizablefloatarray.pmc
trunk/src/pmc/resizableintegerarray.pmc
trunk/src/pmc/resizablepmcarray.pmc
trunk/src/pmc/resizablestringarray.pmc
trunk/src/pmc/retcontinuation.pmc
trunk/src/pmc/role.pmc
trunk/src/pmc/scheduler.pmc
trunk/src/pmc/schedulermessage.pmc
trunk/src/pmc/sockaddr.pmc
trunk/src/pmc/socket.pmc
trunk/src/pmc/string.pmc
trunk/src/pmc/stringhandle.pmc
trunk/src/pmc/stringiterator.pmc
trunk/src/pmc/task.pmc
trunk/src/pmc/timer.pmc
trunk/src/pmc/undef.pmc
trunk/src/pmc/unmanagedstruct.pmc
Modified: trunk/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/PMCEmitter.pm Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/lib/Parrot/Pmc2c/PMCEmitter.pm Tue Aug 18 17:24:24 2009 (r40628)
@@ -464,7 +464,8 @@
NULL, /* mro */
NULL, /* attribute_defs */
NULL, /* ro_variant_vtable */
- $methlist
+ $methlist,
+ 0 /* attr size */
};
ENDOFCODE
return $cout;
@@ -640,6 +641,7 @@
vt_${k} = Parrot_${classname}_${k}_get_vtable(interp);
vt_${k}->base_type = $enum_name;
vt_${k}->flags = $k_flags;
+
vt_${k}->attribute_defs = attr_defs;
vt_${k}->base_type = entry;
@@ -761,6 +763,22 @@
my $classname = $self->name;
my $export = $self->is_dynamic ? 'PARROT_DYNEXT_EXPORT ' : 'PARROT_EXPORT';
+ # Sets the attr_size field:
+ # If the auto_attrs flag is set, use the current data,
+ # else check if this PMC has init or init_pmc vtable functions,
+ # setting it to 0 in that case, and keeping the value from the
+ # parent otherwise.
+ my $set_attr_size = '';
+ if ( @{$self->attributes} && $self->{flags}{auto_attrs} ) {
+ $set_attr_size .= "sizeof(Parrot_${classname}_attributes)";
+ }
+ else {
+ $set_attr_size .= "0" if exists($self->{has_method}{init}) ||
+ exists($self->{has_method}{init_pmc});
+ }
+ $set_attr_size = " vt->attr_size = " . $set_attr_size . ";\n"
+ if $set_attr_size ne '';
+
my $vtable_updates = '';
for my $name ( @{ $self->vtable->names } ) {
if (exists $self->{has_method}{$name}) {
@@ -768,6 +786,8 @@
}
}
+ $vtable_updates .= $set_attr_size;
+
$cout .= <<"EOC";
$export
@@ -793,6 +813,8 @@
}
}
+ $vtable_updates .= $set_attr_size;
+
$cout .= <<"EOC";
$export
Modified: trunk/lib/Parrot/Vtable.pm
==============================================================================
--- trunk/lib/Parrot/Vtable.pm Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/lib/Parrot/Vtable.pm Tue Aug 18 17:24:24 2009 (r40628)
@@ -186,6 +186,10 @@
$struct .= " $entry->[1]_method_t $entry->[1];\n";
}
+ $struct .= <<'EOF';
+ UINTVAL attr_size; /* Size of the attributes struct */
+EOF
+
$struct .= "} _vtable;\n";
return $struct;
Modified: trunk/src/dynpmc/dynlexpad.pmc
==============================================================================
--- trunk/src/dynpmc/dynlexpad.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/dynpmc/dynlexpad.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -19,7 +19,7 @@
*/
-pmclass DynLexPad dynpmc provides lexpad need_ext {
+pmclass DynLexPad dynpmc provides lexpad need_ext auto_attrs {
ATTR Hash *hash;
ATTR PMC *init; /* the PMC used to initialize this DynLexPad */
@@ -42,8 +42,7 @@
Hash *hash;
Parrot_DynLexPad_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_DynLexPad_attributes);
- PMC_data(SELF) = attrs;
+ (Parrot_DynLexPad_attributes *) PMC_data(SELF);
if (VTABLE_elements(interp, lexinfo)) {
attrs->init = pmc_new_init(interp, enum_class_LexPad, lexinfo);
@@ -188,8 +187,6 @@
parrot_hash_destroy(interp, PARROT_DYNLEXPAD(SELF)->hash);
PARROT_DYNLEXPAD(SELF)->hash = NULL;
}
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/dynpmc/foo.pmc
==============================================================================
--- trunk/src/dynpmc/foo.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/dynpmc/foo.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -8,7 +8,7 @@
* proper inheritance - for testing only
*/
-pmclass Foo dynpmc group foo_group provides scalar extends Integer {
+pmclass Foo dynpmc group foo_group provides scalar extends Integer auto_attrs {
VTABLE INTVAL get_integer() {
return 42;
Modified: trunk/src/dynpmc/foo2.pmc
==============================================================================
--- trunk/src/dynpmc/foo2.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/dynpmc/foo2.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -8,7 +8,7 @@
* proper inheritance - for testing only
*/
-pmclass Foo2 dynpmc group foo_group provides scalar extends Foo {
+pmclass Foo2 dynpmc group foo_group provides scalar extends Foo auto_attrs {
VTABLE INTVAL get_integer() {
INTVAL i = SUPER();
Modified: trunk/src/dynpmc/rotest.pmc
==============================================================================
--- trunk/src/dynpmc/rotest.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/dynpmc/rotest.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -8,7 +8,7 @@
* generation. For testing only.
*/
-pmclass ROTest dynpmc provides scalar extends Integer {
+pmclass ROTest dynpmc provides scalar extends Integer auto_attrs {
VTABLE void set_integer_native(INTVAL value) :read {
}
VTABLE INTVAL get_integer() :write {
Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/gc/api.c Tue Aug 18 17:24:24 2009 (r40628)
@@ -374,6 +374,16 @@
if (PObj_active_destroy_TEST(pmc))
VTABLE_destroy(interp, pmc);
+ if (PMC_data(pmc) && pmc->vtable->attr_size) {
+#if 0
+ mem_sys_free(PMC_data(pmc));
+ PMC_data(pmc) = NULL;
+#else
+ Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#endif
+ }
+ PARROT_ASSERT(NULL == PMC_data(pmc));
+
if (PObj_is_PMC_EXT_TEST(pmc))
Parrot_gc_free_pmc_ext(interp, pmc);
Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc.c Tue Aug 18 17:24:24 2009 (r40628)
@@ -241,6 +241,24 @@
/* Set the right vtable */
pmc->vtable = new_vtable;
+ if (PMC_data(pmc) && pmc->vtable->attr_size) {
+#if 0
+ mem_sys_free(PMC_data(pmc));
+#else
+ Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#endif
+ }
+
+ if (new_vtable->attr_size) {
+#if 0
+ PMC_data(pmc) = mem_sys_allocate_zeroed(new_vtable->attr_size);
+#else
+ Parrot_gc_allocate_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#endif
+}
+ else
+ PMC_data(pmc) = NULL;
+
return pmc;
}
@@ -361,6 +379,14 @@
/* Do we have an extension area? */
INTVAL const has_ext = (PObj_is_PMC_EXT_TEST(pmc) && pmc->pmc_ext);
+ if (PMC_data(pmc) && pmc->vtable->attr_size) {
+#if 0
+ mem_sys_free(PMC_data(pmc));
+#else
+ Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#endif
+ }
+
/* Do we need one? */
if (flags & VTABLE_PMC_NEEDS_EXT) {
/* If we need an ext area, go allocate one */
@@ -465,6 +491,14 @@
pmc = Parrot_gc_new_pmc_header(interp, flags);
pmc->vtable = vtable;
+ if (vtable->attr_size) {
+#if 0
+ PMC_data(pmc) = mem_sys_allocate_zeroed(vtable->attr_size);
+#else
+ Parrot_gc_allocate_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#endif
+ }
+
#if GC_VERBOSE
if (Interp_flags_TEST(interp, PARROT_TRACE_FLAG)) {
/* XXX make a more verbose trace flag */
Modified: trunk/src/pmc/arrayiterator.pmc
==============================================================================
--- trunk/src/pmc/arrayiterator.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/arrayiterator.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -51,7 +51,7 @@
*/
-pmclass ArrayIterator extends Iterator no_ro {
+pmclass ArrayIterator extends Iterator no_ro auto_attrs {
ATTR PMC *array; /* the array which this Iterator iterates */
ATTR INTVAL pos; /* Current position of iterator for forward iterator */
/* Previous position of iterator for reverse iterator */
@@ -86,12 +86,11 @@
VTABLE void init_pmc(PMC *array) {
Parrot_ArrayIterator_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_ArrayIterator_attributes);
+ (Parrot_ArrayIterator_attributes *) PMC_data(SELF);
attrs->array = array;
- PMC_data(SELF) = attrs;
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
/* by default, iterate from start */
SELF.set_integer_native(ITERATE_FROM_START);
@@ -99,21 +98,6 @@
/*
-=item C<void destroy()>
-
-destroys this PMC
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<void mark()>
Marks the current idx/key and the aggregate as live.
Modified: trunk/src/pmc/boolean.pmc
==============================================================================
--- trunk/src/pmc/boolean.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/boolean.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -21,7 +21,7 @@
*/
-pmclass Boolean extends Integer provides boolean provides scalar {
+pmclass Boolean extends Integer provides boolean provides scalar auto_attrs {
/*
Modified: trunk/src/pmc/callsignature.pmc
==============================================================================
--- trunk/src/pmc/callsignature.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/callsignature.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -27,7 +27,7 @@
if (!PARROT_CAPTURE(obj)->hash) \
PARROT_CAPTURE(obj)->hash = pmc_new((i), enum_class_Hash);
-pmclass CallSignature extends Capture need_ext provides array provides hash {
+pmclass CallSignature extends Capture need_ext auto_attrs provides array provides hash {
ATTR PMC *returns; /* Result PMCs, if they were passed with the call */
ATTR PMC *type_tuple; /* Cached argument types for multiple dispatch */
ATTR STRING *short_sig; /* Simple string signature args & returns */
@@ -44,16 +44,10 @@
VTABLE void init() {
Parrot_CallSignature_attributes * const sig_struct =
- mem_allocate_typed(Parrot_CallSignature_attributes);
- PMC_data(SELF) = sig_struct;
- sig_struct->short_sig = NULL;
+ (Parrot_CallSignature_attributes *) PMC_data(SELF);
+ SUPER();
sig_struct->type_tuple = PMCNULL;
sig_struct->returns = PMCNULL;
- sig_struct->array = NULL;
- sig_struct->hash = NULL;
- sig_struct->data_size = CAPTURE_DATA_SIZE;
- PObj_active_destroy_SET(SELF);
- PObj_custom_mark_SET(SELF);
}
/*
@@ -182,15 +176,9 @@
*/
VTABLE void mark() {
- PMC ** const data = PMC_data_typed(SELF, PMC **);
Parrot_CallSignature_attributes * const attrs = PARROT_CALLSIGNATURE(SELF);
if (attrs) {
-
- if (attrs->array)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->array);
- if (attrs->hash)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->hash);
if (attrs->returns)
Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->returns);
if (attrs->type_tuple)
@@ -198,13 +186,7 @@
if (attrs->short_sig)
Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->short_sig);
}
-
- if (data) {
- INTVAL i;
- for (i = attrs->data_size - 1; i >= 0; --i)
- if (data[i])
- Parrot_gc_mark_PObj_alive(interp, (PObj *)data[i]);
- }
+ SUPER();
}
Modified: trunk/src/pmc/capture.pmc
==============================================================================
--- trunk/src/pmc/capture.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/capture.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2008, Parrot Foundation.
+Copyright (C) 2001-2009, Parrot Foundation.
$Id$
=head1 NAME
@@ -26,7 +26,7 @@
if (!PARROT_CAPTURE(obj)->hash) \
PARROT_CAPTURE(obj)->hash = pmc_new((i), enum_class_Hash);
-pmclass Capture need_ext {
+pmclass Capture need_ext auto_attrs {
ATTR PMC *array;
ATTR PMC *hash;
ATTR INTVAL data_size;
@@ -37,31 +37,17 @@
Initializes the Capture instance.
-=item C<void destroy()>
-
-Free structures.
-
=cut
*/
VTABLE void init() {
- Parrot_Capture_attributes *capture = mem_allocate_typed(Parrot_Capture_attributes);
- PMC_data(SELF) = capture;
- capture->array = NULL;
- capture->hash = NULL;
+ Parrot_Capture_attributes *capture =
+ (Parrot_Capture_attributes *) PMC_data(SELF);
capture->data_size = CAPTURE_DATA_SIZE;
- PObj_active_destroy_SET(SELF);
PObj_custom_mark_SET(SELF);
}
- VTABLE void destroy() {
- if (PARROT_CAPTURE(SELF)) {
- mem_sys_free(PARROT_CAPTURE(SELF));
- PMC_data(SELF) = NULL;
- }
- }
-
/*
=item C<PMC *clone()>
Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/class.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -443,7 +443,7 @@
*/
pmclass Class
- need_ext {
+ need_ext auto_attrs {
ATTR INTVAL id; /* The type number of the PMC. [deprecated: See RT #48024] */
ATTR STRING *name; /* The name of the class. */
@@ -479,14 +479,13 @@
*/
VTABLE void init() {
- Parrot_Class_attributes * const _class = mem_allocate_zeroed_typed(Parrot_Class_attributes);
+ Parrot_Class_attributes * const _class =
+ (Parrot_Class_attributes *) PMC_data(SELF);
- /* Set flags for custom GC mark and destroy. */
+ /* Set flag for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
/* Set up the object. */
- PMC_data(SELF) = _class;
_class->name = CONST_STRING(interp, "");
_class->_namespace = PMCNULL;
_class->parents = pmc_new(interp, enum_class_ResizablePMCArray);
@@ -559,21 +558,6 @@
/*
-=item C<void destroy()>
-
-Frees the memory associated with the class's underlying struct.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<STRING *get_string()>
Returns the name of the class (without the HLL namespace).
Modified: trunk/src/pmc/codestring.pmc
==============================================================================
--- trunk/src/pmc/codestring.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/codestring.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -34,18 +34,10 @@
# include <unicode/uchar.h>
#endif
-pmclass CodeString extends String provides string {
+pmclass CodeString extends String provides string auto_attrs {
ATTR INTVAL last_line_number; /* most recent line number seen */
ATTR INTVAL last_pos; /* most recent byte position seen */
- VTABLE void init() {
- Parrot_CodeString_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_CodeString_attributes);
- attrs->str_val = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
- PMC_data(SELF) = attrs;
- PObj_custom_mark_destroy_SETALL(SELF);
- }
-
/*
=item C<emit(string fmt [, pmc args ] [, pmc hash ])>
Modified: trunk/src/pmc/complex.pmc
==============================================================================
--- trunk/src/pmc/complex.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/complex.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -217,7 +217,7 @@
}
-pmclass Complex need_ext {
+pmclass Complex need_ext auto_attrs {
ATTR FLOATVAL re; /* real part */
ATTR FLOATVAL im; /* imaginary part */
@@ -327,10 +327,6 @@
Initializes the complex number with the specified initializer.
The initializer can be a string PMC or a numeric array with (real, imag)
-=item C<void destroy()>
-
-Cleans up.
-
=item C<PMC *clone()>
Creates an identical copy of the complex number.
@@ -340,12 +336,8 @@
*/
VTABLE void init() {
- /* XXX should check if mem_sys_allocate failed */
- PMC_data(SELF) = mem_allocate_typed(Parrot_Complex_attributes);
SET_ATTR_re(INTERP, SELF, 0.0);
SET_ATTR_im(INTERP, SELF, 0.0);
-
- PObj_active_destroy_SET(SELF);
}
VTABLE void init_pmc(PMC *initializer) {
@@ -380,11 +372,6 @@
}
}
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
VTABLE PMC *clone() {
PMC * const dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
FLOATVAL re, im;
Modified: trunk/src/pmc/continuation.pmc
==============================================================================
--- trunk/src/pmc/continuation.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/continuation.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -45,7 +45,7 @@
* need the next_for_GC pointer in the pmc_ext area.
*/
-pmclass Continuation need_ext {
+pmclass Continuation need_ext auto_attrs {
ATTR struct Parrot_cont *cont; /* the continuation struct */
/*
@@ -60,8 +60,7 @@
VTABLE void init() {
Parrot_Continuation_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_Continuation_attributes);
- PMC_data(SELF) = attrs;
+ (Parrot_Continuation_attributes *) PMC_data(SELF);
PMC_cont(SELF) = new_continuation(INTERP, NULL);
PObj_custom_mark_destroy_SETALL(SELF);
@@ -120,8 +119,6 @@
mem_sys_free(cc);
}
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/cpointer.pmc
==============================================================================
--- trunk/src/pmc/cpointer.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/cpointer.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -46,7 +46,7 @@
*/
-pmclass CPointer need_ext {
+pmclass CPointer need_ext auto_attrs {
ATTR void *pointer; /* The stored pointer. */
ATTR STRING *sig; /* A string signature for the pointer. */
@@ -61,12 +61,8 @@
*/
VTABLE void init() {
- Parrot_CPointer_attributes * const pdata_struct =
- mem_allocate_typed(Parrot_CPointer_attributes);
-
- PMC_data(SELF) = pdata_struct;
- pdata_struct->pointer = NULL;
- pdata_struct->sig = NULL;
+ SET_ATTR_pointer(INTERP, SELF, NULL);
+ SET_ATTR_sig(INTERP, SELF, NULL);
PObj_custom_mark_destroy_SETALL(SELF);
}
@@ -83,19 +79,21 @@
*/
VTABLE void mark() {
- Parrot_CPointer_attributes * const data = PARROT_CPOINTER(SELF);
-
- if (data->sig) {
- Parrot_gc_mark_PObj_alive(interp, (PObj *)data->sig);
-
- if (data->pointer) {
- if (Parrot_str_equal(interp, data->sig, CONST_STRING(interp, "P"))) {
- PMC ** const pmc_pointer = (PMC **) data->pointer;
+ STRING *sig;
+ GET_ATTR_sig(INTERP, SELF, sig);
+ if (sig) {
+ void *pointer;
+ GET_ATTR_pointer(INTERP, SELF, pointer);
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)sig);
+
+ if (pointer) {
+ if (Parrot_str_equal(interp, sig, CONST_STRING(interp, "P"))) {
+ PMC ** const pmc_pointer = (PMC **) pointer;
PARROT_ASSERT(*pmc_pointer);
Parrot_gc_mark_PObj_alive(interp, (PObj *) *pmc_pointer);
}
- else if (Parrot_str_equal(interp, data->sig, CONST_STRING(interp, "S"))) {
- STRING ** const str_pointer = (STRING **) data->pointer;
+ else if (Parrot_str_equal(interp, sig, CONST_STRING(interp, "S"))) {
+ STRING ** const str_pointer = (STRING **) pointer;
PARROT_ASSERT(*str_pointer);
Parrot_gc_mark_PObj_alive(interp, (PObj *) *str_pointer);
}
@@ -114,12 +112,6 @@
*/
VTABLE void destroy() {
- Parrot_CPointer_attributes * const data = PARROT_CPOINTER(SELF);
-
- if (data) {
- mem_sys_free(data);
- PMC_data(SELF) = NULL;
- }
}
/*
Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/default.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -327,6 +327,19 @@
/*
+=item C<void destroy()>
+
+Does nothing.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ }
+
+/*
+
=item C<PMC *instantiate(PMC *init)>
Default fallback. Creates a new PMC of the type of the class SELF and
Modified: trunk/src/pmc/exception.pmc
==============================================================================
--- trunk/src/pmc/exception.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/exception.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -52,7 +52,7 @@
#include "parrot/exceptions.h"
#include "pmc_sub.h"
-pmclass Exception {
+pmclass Exception auto_attrs {
ATTR INTVAL id; /* The task ID in the scheduler. */
ATTR FLOATVAL birthtime; /* The creation time stamp of the exception. */
@@ -83,15 +83,9 @@
*/
VTABLE void init() {
- Parrot_Exception_attributes * const core_struct =
- mem_allocate_zeroed_typed(Parrot_Exception_attributes);
-
- /* Set up the core struct and default values for the exception object. */
- PMC_data(SELF) = core_struct;
-
/* Set flags for custom GC mark and destroy. */
- PObj_custom_mark_SET(SELF);
PObj_active_destroy_SET(SELF);
+ PObj_custom_mark_SET(SELF);
SET_ATTR_severity(INTERP, SELF, EXCEPT_error);
SET_ATTR_handled(INTERP, SELF, 0);
@@ -116,9 +110,6 @@
INTVAL severity_val;
STRING *message_val;
- Parrot_Exception_attributes * const core_struct =
- mem_allocate_zeroed_typed(Parrot_Exception_attributes);
-
INTVAL ishash = VTABLE_isa(interp, values, CONST_STRING(interp, 'Hash'));
if (ishash) {
@@ -132,10 +123,9 @@
message_val = VTABLE_get_string(interp, values);
}
- PMC_data(SELF) = core_struct;
- /* Set flags for custom GC mark and destroy. */
- PObj_custom_mark_SET(SELF);
+ /* Set flags for custom GC mark. */
PObj_active_destroy_SET(SELF);
+ PObj_custom_mark_SET(SELF);
/* Set up the core struct and default values for the exception object. */
@@ -185,11 +175,8 @@
VTABLE void destroy() {
Parrot_Exception_attributes * const core_struct = PARROT_EXCEPTION(SELF);
- if (core_struct) {
- if (core_struct->thrower)
- Parrot_free_context(interp, core_struct->thrower, 1);
- mem_sys_free(core_struct);
- }
+ if (core_struct && core_struct->thrower)
+ Parrot_free_context(interp, core_struct->thrower, 1);
}
/*
Modified: trunk/src/pmc/exceptionhandler.pmc
==============================================================================
--- trunk/src/pmc/exceptionhandler.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/exceptionhandler.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -22,7 +22,7 @@
#include "parrot/oplib/ops.h"
-pmclass ExceptionHandler extends Continuation need_ext {
+pmclass ExceptionHandler extends Continuation need_ext auto_attrs {
ATTR PMC *handled_types;
ATTR PMC *handled_types_except;
@@ -41,11 +41,10 @@
VTABLE void init() {
Parrot_ExceptionHandler_attributes * const core_struct =
- mem_allocate_zeroed_typed(Parrot_ExceptionHandler_attributes);
+ (Parrot_ExceptionHandler_attributes *)PMC_data(SELF);
Parrot_cont * const cc = new_continuation(INTERP, NULL);
cc->invoked = 0;
- PMC_data(SELF) = core_struct;
PMC_cont(SELF) = cc;
core_struct->min_severity = 0;
core_struct->max_severity = 0;
Modified: trunk/src/pmc/exporter.pmc
==============================================================================
--- trunk/src/pmc/exporter.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/exporter.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -90,7 +90,7 @@
*/
-pmclass Exporter need_ext {
+pmclass Exporter need_ext auto_attrs {
ATTR PMC *ns_src;
ATTR PMC *ns_dest;
@@ -107,10 +107,6 @@
*/
VTABLE void init() {
- Parrot_Exporter_attributes * const exp =
- mem_allocate_zeroed_typed(Parrot_Exporter_attributes);
- PMC_data(SELF) = exp;
-
/* Set up the object. */
SET_ATTR_ns_src(INTERP, SELF, PMCNULL);
SET_ATTR_ns_dest(INTERP, SELF, CONTEXT(interp)->current_namespace);
@@ -118,26 +114,8 @@
/* Set flags for custom GC mark and destroy. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
}
-
-/*
-
-=item C<void destroy()>
-
-Free the memory associated with the object's underlying struct.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-
/*
=item C<void mark()>
Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/filehandle.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -31,7 +31,7 @@
#endif
#endif
-pmclass FileHandle extends Handle {
+pmclass FileHandle extends Handle auto_attrs {
ATTR INTVAL flags; /* Filehandle flags */
ATTR STRING *filename; /* The opened path and filename */
ATTR STRING *mode; /* The mode string used in open */
@@ -64,9 +64,8 @@
VTABLE void init() {
Parrot_FileHandle_attributes * const data_struct =
- mem_allocate_typed(Parrot_FileHandle_attributes);
+ (Parrot_FileHandle_attributes *) PMC_data(SELF);
- PMC_data(SELF) = data_struct;
data_struct->flags = 0;
data_struct->filename = NULL;
data_struct->mode = NULL;
@@ -150,9 +149,6 @@
if (data_struct->buffer_start)
mem_sys_free(data_struct->buffer_start);
-
- mem_sys_free(PARROT_FILEHANDLE(SELF));
- PMC_data(SELF) = NULL;
}
}
Modified: trunk/src/pmc/fixedbooleanarray.pmc
==============================================================================
--- trunk/src/pmc/fixedbooleanarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/fixedbooleanarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -23,7 +23,7 @@
#define BITS_PER_CHAR 8
-pmclass FixedBooleanArray need_ext provides array {
+pmclass FixedBooleanArray need_ext auto_attrs provides array {
ATTR UINTVAL size; /* # of bits this fba holds */
ATTR UINTVAL resize_threshold; /* max capacity before resizing */
ATTR unsigned char * bit_array; /* where the bits go */
@@ -45,10 +45,6 @@
*/
VTABLE void init() {
- Parrot_FixedBooleanArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_FixedBooleanArray_attributes);
-
- PMC_data(SELF) = attrs;
PObj_active_destroy_SET(SELF);
}
@@ -67,8 +63,6 @@
GET_ATTR_bit_array(INTERP, SELF, bit_array);
if (bit_array)
mem_sys_free(bit_array);
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/fixedfloatarray.pmc
==============================================================================
--- trunk/src/pmc/fixedfloatarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/fixedfloatarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -19,7 +19,7 @@
*/
-pmclass FixedFloatArray need_ext provides array {
+pmclass FixedFloatArray need_ext auto_attrs provides array {
ATTR INTVAL size;
ATTR FLOATVAL *float_array;
@@ -40,9 +40,6 @@
*/
VTABLE void init() {
- Parrot_FixedFloatArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_FixedFloatArray_attributes);
- PMC_data(SELF) = attrs;
}
/*
@@ -60,9 +57,6 @@
GET_ATTR_float_array(INTERP, SELF, float_array);
if (float_array)
mem_sys_free(float_array);
-
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/fixedintegerarray.pmc
==============================================================================
--- trunk/src/pmc/fixedintegerarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/fixedintegerarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -19,7 +19,7 @@
*/
-pmclass FixedIntegerArray need_ext provides array {
+pmclass FixedIntegerArray need_ext auto_attrs provides array {
ATTR INTVAL size; /* number of INTVALs stored in this array */
ATTR INTVAL * int_array; /* INTVALs are stored here */
@@ -40,9 +40,6 @@
*/
VTABLE void init() {
- Parrot_FixedIntegerArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_FixedIntegerArray_attributes);
- PMC_data(SELF) = attrs;
PObj_active_destroy_SET(SELF);
}
@@ -154,8 +151,6 @@
GET_ATTR_int_array(INTERP, SELF, int_array);
if (int_array)
mem_sys_free(int_array);
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/fixedpmcarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -27,7 +27,7 @@
#define PMC_size(x) ((Parrot_FixedPMCArray_attributes *)PMC_data(x))->size
#define PMC_array(x) ((Parrot_FixedPMCArray_attributes *)PMC_data(x))->pmc_array
-pmclass FixedPMCArray need_ext provides array {
+pmclass FixedPMCArray need_ext auto_attrs provides array {
ATTR INTVAL size; /* number of elements in the array */
ATTR PMC **pmc_array; /* pointer to PMC array */
@@ -66,9 +66,7 @@
VTABLE void init() {
Parrot_FixedPMCArray_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_FixedPMCArray_attributes);
-
- PMC_data(SELF) = attrs;
+ (Parrot_FixedPMCArray_attributes *) PMC_data(SELF);
PObj_custom_mark_destroy_SETALL(SELF);
}
@@ -86,8 +84,6 @@
if (PMC_array(SELF)) {
mem_sys_free(PMC_array(SELF));
}
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/fixedstringarray.pmc
==============================================================================
--- trunk/src/pmc/fixedstringarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/fixedstringarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -19,7 +19,7 @@
*/
-pmclass FixedStringArray need_ext provides array {
+pmclass FixedStringArray need_ext auto_attrs provides array {
ATTR STRING **str_array; /* where the STRINGs are stored */
ATTR UINTVAL size; /* element count */
@@ -40,12 +40,6 @@
*/
VTABLE void init() {
-
- Parrot_FixedStringArray_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_FixedStringArray_attributes);
-
- PMC_data(SELF) = attrs;
-
PObj_custom_mark_destroy_SETALL(SELF);
}
@@ -67,9 +61,6 @@
if (str_array)
mem_sys_free(str_array);
-
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/float.pmc
==============================================================================
--- trunk/src/pmc/float.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/float.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -18,7 +18,7 @@
*/
-pmclass Float extends scalar provides float provides scalar {
+pmclass Float extends scalar provides float provides scalar auto_attrs {
ATTR FLOATVAL fv;
/*
@@ -32,27 +32,9 @@
*/
VTABLE void init() {
- Parrot_Float_attributes * const fattr = mem_allocate_zeroed_typed(Parrot_Float_attributes);
-
- PMC_data(SELF) = fattr;
SET_ATTR_fv(INTERP, SELF, 0.0);
-
- PObj_active_destroy_SET(SELF);
}
-/*
-
-=item C<void destroy()>
-
-Destroy this PMC.
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
/*
=item C<PMC *clone()>
Modified: trunk/src/pmc/hashiterator.pmc
==============================================================================
--- trunk/src/pmc/hashiterator.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/hashiterator.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -75,7 +75,7 @@
return bucket;
}
-pmclass HashIterator extends Iterator no_ro {
+pmclass HashIterator extends Iterator no_ro auto_attrs {
ATTR PMC *pmc_hash; /* the Hash which this Iterator iterates */
ATTR Hash *parrot_hash; /* Underlying implementation of hash */
ATTR HashBucket *bucket; /* Current bucket */
@@ -96,7 +96,7 @@
VTABLE void init_pmc(PMC *hash) {
Parrot_HashIterator_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_HashIterator_attributes);
+ (Parrot_HashIterator_attributes *) PMC_data(SELF);
attrs->pmc_hash = hash;
attrs->parrot_hash = (Hash*)VTABLE_get_pointer(INTERP, hash);
@@ -106,9 +106,8 @@
/* Will be decreased on initial advance_to_next */
/* XXX Do we really need to support this use-case ? */
attrs->elements = attrs->parrot_hash->entries + 1;
- PMC_data(SELF) = attrs;
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
/* Initial state of iterator is "before start" */
/* So, advance to first element */
@@ -117,21 +116,6 @@
/*
-=item C<void destroy()>
-
-destroys this PMC
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<void mark()>
Marks the hash as live.
Modified: trunk/src/pmc/hashiteratorkey.pmc
==============================================================================
--- trunk/src/pmc/hashiteratorkey.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/hashiteratorkey.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -19,48 +19,12 @@
*/
-pmclass HashIteratorKey no_ro {
+pmclass HashIteratorKey no_ro auto_attrs {
ATTR Hash *parrot_hash; /* Underlying parrot's hash */
ATTR HashBucket *bucket; /* Current bucket from HashItertor */
/*
-=item C<void init()>
-
-Initializes the PMC.
-
-Not really part of public API.
-
-=cut
-
-*/
-
- VTABLE void init() {
- Parrot_HashIteratorKey_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_HashIteratorKey_attributes);
-
- PMC_data(SELF) = attrs;
-
- PObj_active_destroy_SET(SELF);
- }
-
-/*
-
-=item C<void destroy()>
-
-Destroys this PMC
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<get_pmc()>
Get "key".
Modified: trunk/src/pmc/integer.pmc
==============================================================================
--- trunk/src/pmc/integer.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/integer.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -43,7 +43,7 @@
return self;
}
-pmclass Integer extends scalar provides integer provides scalar {
+pmclass Integer extends scalar provides integer provides scalar auto_attrs {
ATTR INTVAL iv; /* the value of this Integer */
/*
@@ -91,16 +91,13 @@
VTABLE void init() {
Parrot_Integer_attributes * const attrs =
- mem_allocate_typed(Parrot_Integer_attributes);
+ (Parrot_Integer_attributes *)PMC_data(SELF);
attrs->iv = 0;
- PMC_data(SELF) = attrs;
PObj_active_destroy_SET(SELF);
}
VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/key.pmc
==============================================================================
--- trunk/src/pmc/key.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/key.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -18,7 +18,7 @@
*/
-pmclass Key need_ext {
+pmclass Key need_ext auto_attrs {
ATTR PMC *next_key; /* Sometimes it's the next key, sometimes it's
not. The Key code is like that. */
ATTR INTVAL int_key; /* int value of this key, or something magical if
@@ -40,26 +40,7 @@
*/
VTABLE void init() {
-
- Parrot_Key_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_Key_attributes);
-
- PMC_data(SELF) = attrs;
- PObj_custom_mark_destroy_SETALL(SELF);
- }
-
-/*
-
-=item C<void destroy()>
-
-Destroy this Key, but not in the way anyone reading its code would want.
-
-=cut
-
-*/
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -77,8 +58,6 @@
PMC *dkey = dest;
PMC *key = SELF;
- PObj_custom_mark_destroy_SETALL(dest);
-
for (; key ;) {
switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
case KEY_integer_FLAG:
Modified: trunk/src/pmc/lexpad.pmc
==============================================================================
--- trunk/src/pmc/lexpad.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/lexpad.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -26,7 +26,7 @@
* pmc_val ... LexInfo
*/
-pmclass LexPad provides hash no_ro {
+pmclass LexPad provides hash no_ro auto_attrs {
ATTR PMC *lexinfo;
ATTR struct Parrot_Context *ctx;
@@ -78,18 +78,7 @@
*/
VTABLE void init_pmc(PMC *lexinfo) {
- Parrot_LexPad_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_LexPad_attributes);
-
- PObj_active_destroy_SET(SELF);
-
- attrs->lexinfo = lexinfo;
- PMC_data(SELF) = attrs;
- }
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
+ SET_ATTR_lexinfo(INTERP, SELF, lexinfo);
}
VTABLE void set_pointer(void *ctx) {
Modified: trunk/src/pmc/managedstruct.pmc
==============================================================================
--- trunk/src/pmc/managedstruct.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/managedstruct.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -22,7 +22,7 @@
typedef void (*custom_free_func_t)(PARROT_INTERP, void *ptr, void *priv);
typedef PMC * (*custom_clone_func_t)(PARROT_INTERP, PMC *ptr, void *priv);
-pmclass ManagedStruct extends UnManagedStruct need_ext {
+pmclass ManagedStruct extends UnManagedStruct need_ext auto_attrs {
/* if custom_free_func and ptr (inherited from UnManagedStruct) are both set,
* custom_free_func is called before the normal destroy() function does any
* work.
@@ -46,11 +46,7 @@
*/
VTABLE void init() {
- Parrot_ManagedStruct_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_ManagedStruct_attributes);
PObj_active_destroy_SET(SELF);
- PMC_data(SELF) = attrs;
-
}
/*
@@ -91,8 +87,6 @@
} else
mem_sys_free(ptr);
}
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/multisub.pmc
==============================================================================
--- trunk/src/pmc/multisub.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/multisub.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -19,7 +19,7 @@
*/
-pmclass MultiSub extends ResizablePMCArray need_ext provides array {
+pmclass MultiSub extends ResizablePMCArray need_ext auto_attrs provides array {
VTABLE void push_pmc(PMC *value) {
STRING * const _sub = CONST_STRING(interp, "Sub");
Modified: trunk/src/pmc/nci.pmc
==============================================================================
--- trunk/src/pmc/nci.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/nci.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -101,7 +101,7 @@
}
-pmclass NCI need_ext {
+pmclass NCI need_ext auto_attrs {
ATTR STRING *signature; /* The signature. */
ATTR void *func; /* Function pointer to call. */
ATTR void *orig_func; /* Function pointer
@@ -155,12 +155,9 @@
*/
VTABLE void init() {
- PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
-
/* Mark that we're not a raw NCI. */
PObj_flag_CLEAR(private2, SELF);
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
}
/*
@@ -232,25 +229,6 @@
/*
-=item C<void destroy()>
-
-Destroys the NCI, freeing any allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- if (PMC_data(SELF)) {
- Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
-
- mem_sys_free(nci_info);
- PMC_data(SELF) = NULL;
- }
- }
-
-/*
-
=item C<PMC *clone()>
Creates and returns a clone of the NCI.
Modified: trunk/src/pmc/orderedhashiterator.pmc
==============================================================================
--- trunk/src/pmc/orderedhashiterator.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/orderedhashiterator.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -21,7 +21,7 @@
#include "pmc_hash.h"
#include "pmc_hashiteratorkey.h"
-pmclass OrderedHashIterator extends Iterator no_ro {
+pmclass OrderedHashIterator extends Iterator no_ro auto_attrs {
ATTR PMC *pmc_hash; /* the Hash which this Iterator iterates */
ATTR Hash *parrot_hash; /* Underlying implementation of hash */
ATTR INTVAL pos; /* */
@@ -41,7 +41,7 @@
VTABLE void init_pmc(PMC *hash) {
Parrot_OrderedHashIterator_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_OrderedHashIterator_attributes);
+ (Parrot_OrderedHashIterator_attributes *) PMC_data(SELF);
attrs->pmc_hash = hash;
attrs->parrot_hash = (Hash*)VTABLE_get_pointer(INTERP, hash);
@@ -49,24 +49,8 @@
/* Will be decreased on initial advance_to_next */
/* XXX Do we really need to support this use-case ? */
attrs->elements = attrs->parrot_hash->entries;
- PMC_data(SELF) = attrs;
- PObj_custom_mark_destroy_SETALL(SELF);
- }
-
-/*
-
-=item C<void destroy()>
-
-destroys this PMC
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
+ PObj_custom_mark_SET(SELF);
}
/*
Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/parrotinterpreter.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -238,8 +238,9 @@
Parrot_ParrotInterpreter_attributes *attrs =
mem_allocate_zeroed_typed(Parrot_ParrotInterpreter_attributes);
PMC_data(SELF) = attrs;
+ }
+ if (!PMC_interp(SELF)) {
create_interp(SELF, INTERP);
- PARROT_ASSERT(attrs->interp);
}
PObj_active_destroy_SET(SELF);
}
@@ -259,8 +260,15 @@
VTABLE void init_pmc(PMC *parent) {
Parrot_Interp p = PMC_interp(parent);
- if (!PMC_interp(SELF))
+ if (!PMC_data(SELF)) {
+ Parrot_ParrotInterpreter_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_ParrotInterpreter_attributes);
+ PMC_data(SELF) = attrs;
+ }
+ if (!PMC_interp(SELF)) {
create_interp(SELF, p);
+ }
+ PObj_active_destroy_SET(SELF);
}
Modified: trunk/src/pmc/parrotlibrary.pmc
==============================================================================
--- trunk/src/pmc/parrotlibrary.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/parrotlibrary.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -31,7 +31,7 @@
#define PMC_dlhandle(x) ((Parrot_ParrotLibrary_attributes*)PMC_data(x))->dl_handle
#define PMC_oplib_init(x) ((Parrot_ParrotLibrary_attributes*)PMC_data(x))->oplib_init
-pmclass ParrotLibrary need_ext provides library {
+pmclass ParrotLibrary need_ext auto_attrs provides library {
ATTR void * dl_handle; /* DLL handle */
ATTR void * oplib_init; /* oplib init function */
@@ -46,9 +46,6 @@
*/
VTABLE void init() {
- Parrot_ParrotLibrary_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_ParrotLibrary_attributes);
- PMC_data(SELF) = attrs;
PObj_active_destroy_SET(SELF);
}
@@ -66,8 +63,6 @@
void *dl_handle = PMC_dlhandle(SELF);
if (dl_handle)
Parrot_dlclose(dl_handle);
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
Modified: trunk/src/pmc/pmcproxy.pmc
==============================================================================
--- trunk/src/pmc/pmcproxy.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/pmcproxy.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -64,7 +64,7 @@
*/
-pmclass PMCProxy extends Class need_ext {
+pmclass PMCProxy extends Class need_ext auto_attrs {
/*
@@ -77,14 +77,13 @@
*/
VTABLE void init() {
- Parrot_Class_attributes * const _pmc = mem_allocate_zeroed_typed(Parrot_Class_attributes);
+ Parrot_Class_attributes * const _pmc =
+ (Parrot_Class_attributes *) PMC_data(SELF);
PMC * const new_attribute = pmc_new(interp, enum_class_Hash);
STRING * const name = CONST_STRING(interp, "proxy");
- PMC_data(SELF) = _pmc;
- /* Set flags for custom GC mark and destroy. */
+ /* Set flag for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
/* Set up the object. */
_pmc->id = 0;
Modified: trunk/src/pmc/pointer.pmc
==============================================================================
--- trunk/src/pmc/pointer.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/pointer.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,7 +20,7 @@
*/
-pmclass Pointer need_ext {
+pmclass Pointer need_ext auto_attrs {
ATTR void * mark_function;
ATTR void * pointer;
@@ -35,28 +35,11 @@
*/
VTABLE void init() {
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_Pointer_attributes);
+ PObj_custom_mark_SET(SELF);
}
/*
-=item C<void destroy()>
-
-Destroy the Pointer and free associated memory
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PARROT_POINTER(SELF));
- PMC_data(SELF) = NULL;
- }
-
-
-/*
-
=item C<void mark()>
Marks the pointer as live.
Modified: trunk/src/pmc/resizablebooleanarray.pmc
==============================================================================
--- trunk/src/pmc/resizablebooleanarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/resizablebooleanarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -30,7 +30,7 @@
/* Convert a size in bits to a size in bytes */
#define BITS_TO_BYTES(size) ((size) / BITS_PER_CHAR)
-pmclass ResizableBooleanArray extends FixedBooleanArray need_ext provides array {
+pmclass ResizableBooleanArray extends FixedBooleanArray need_ext auto_attrs provides array {
/* RBA uses the same attributes as FBA, but in RBA they're used as follows:
size: position of the last element (a.k.a tail_pos)
resize_threshold: position of the first element (a.k.a. head_pos) */
Modified: trunk/src/pmc/resizablefloatarray.pmc
==============================================================================
--- trunk/src/pmc/resizablefloatarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/resizablefloatarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,26 +20,9 @@
*/
-pmclass ResizableFloatArray extends FixedFloatArray need_ext provides array {
+pmclass ResizableFloatArray extends FixedFloatArray need_ext auto_attrs provides array {
ATTR INTVAL resize_threshold; /* max size before array needs resizing */
-
-
-/*
-
-=item C<void init()>
-
-Initializes this array.
-
-=cut
-
-*/
- VTABLE void init() {
- Parrot_ResizableFloatArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_ResizableFloatArray_attributes);
- PMC_data(SELF) = attrs;
- }
-
/*
=item C<FLOATVAL get_number_keyed_int(INTVAL key)>
Modified: trunk/src/pmc/resizableintegerarray.pmc
==============================================================================
--- trunk/src/pmc/resizableintegerarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/resizableintegerarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,27 +20,11 @@
*/
-pmclass ResizableIntegerArray extends FixedIntegerArray need_ext provides array {
+pmclass ResizableIntegerArray extends FixedIntegerArray need_ext auto_attrs provides array {
ATTR INTVAL resize_threshold; /* max size before array needs to be resized */
/*
-=item C<void init()>
-
-Initializes the array.
-
-=cut
-
-*/
- VTABLE void init() {
- Parrot_ResizableIntegerArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_ResizableIntegerArray_attributes);
- PMC_data(SELF) = attrs;
- PObj_active_destroy_SET(SELF);
- }
-
-/*
-
=item C<INTVAL get_integer_keyed_int(INTVAL key)>
Returns the integer value of the element at index C<key>.
Modified: trunk/src/pmc/resizablepmcarray.pmc
==============================================================================
--- trunk/src/pmc/resizablepmcarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/resizablepmcarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -23,7 +23,7 @@
#define PMC_array(x) ((Parrot_ResizablePMCArray_attributes *)PMC_data(x))->pmc_array
#define PMC_threshold(x) ((Parrot_ResizablePMCArray_attributes *)PMC_data(x))->resize_threshold
-pmclass ResizablePMCArray extends FixedPMCArray need_ext provides array {
+pmclass ResizablePMCArray extends FixedPMCArray need_ext auto_attrs provides array {
ATTR INTVAL resize_threshold; /* max size before array needs resizing */
@@ -37,10 +37,6 @@
*/
VTABLE void init() {
- Parrot_ResizablePMCArray_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_ResizablePMCArray_attributes);
-
- PMC_data(SELF) = attrs;
PObj_custom_mark_destroy_SETALL(SELF);
}
Modified: trunk/src/pmc/resizablestringarray.pmc
==============================================================================
--- trunk/src/pmc/resizablestringarray.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/resizablestringarray.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -18,7 +18,7 @@
*/
-pmclass ResizableStringArray extends FixedStringArray need_ext provides array {
+pmclass ResizableStringArray extends FixedStringArray need_ext auto_attrs provides array {
ATTR UINTVAL resize_threshold; /*max capacity before resizing */
/*
@@ -27,25 +27,6 @@
=over 4
-=item C<void init()>
-
-Initializes the array.
-
-=cut
-
-*/
-
- VTABLE void init() {
- Parrot_ResizableStringArray_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_ResizableStringArray_attributes);
-
- PMC_data(SELF) = attrs;
-
- PObj_custom_mark_destroy_SETALL(SELF);
- }
-
-/*
-
=item C<STRING *get_string_keyed_int(INTVAL key)>
Returns the Parrot string value of the element at index C<key>.
Modified: trunk/src/pmc/retcontinuation.pmc
==============================================================================
--- trunk/src/pmc/retcontinuation.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/retcontinuation.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -23,7 +23,7 @@
#include "parrot/oplib/ops.h"
-pmclass RetContinuation extends Continuation need_ext {
+pmclass RetContinuation extends Continuation need_ext auto_attrs {
/*
@@ -37,9 +37,7 @@
VTABLE void init() {
Parrot_RetContinuation_attributes * const attrs =
- mem_allocate_typed(Parrot_RetContinuation_attributes);
-
- PMC_data(SELF) = attrs;
+ (Parrot_RetContinuation_attributes *) PMC_data(SELF);
PMC_cont(SELF) = new_ret_continuation(INTERP);
PObj_custom_mark_destroy_SETALL(SELF);
@@ -55,9 +53,6 @@
if (cc)
mem_sys_free(cc);
-
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/role.pmc
==============================================================================
--- trunk/src/pmc/role.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/role.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -198,7 +198,7 @@
*/
-pmclass Role need_ext {
+pmclass Role need_ext auto_attrs {
ATTR STRING *name; /* The name of the role. */
ATTR PMC *_namespace; /* The namespace it's linked to, if any. */
ATTR PMC *roles; /* Roles from which this role is composed. */
@@ -221,12 +221,11 @@
*/
VTABLE void init() {
- Parrot_Role_attributes * const role = mem_allocate_zeroed_typed(Parrot_Role_attributes);
- PMC_data(SELF) = role;
+ Parrot_Role_attributes * const role =
+ (Parrot_Role_attributes *) PMC_data(SELF);
- /* Set flags for custom GC mark and destroy. */
+ /* Set flags for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
/* Set up the object. */
role->name = CONST_STRING(interp, "");
@@ -246,21 +245,6 @@
/*
-=item C<void destroy()>
-
-Free the memory associated with the object's underlying struct.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<void mark()>
Mark referenced strings and PMCs in the structure as live.
Modified: trunk/src/pmc/scheduler.pmc
==============================================================================
--- trunk/src/pmc/scheduler.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/scheduler.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,7 +20,7 @@
#include "parrot/scheduler_private.h"
-pmclass Scheduler need_ext {
+pmclass Scheduler need_ext auto_attrs {
ATTR INTVAL id; /* The scheduler's ID. */
ATTR INTVAL max_tid; /* The highest assigned task ID. */
@@ -48,14 +48,13 @@
VTABLE void init() {
Parrot_Scheduler_attributes * const core_struct =
- mem_allocate_zeroed_typed(Parrot_Scheduler_attributes);
+ (Parrot_Scheduler_attributes *) PMC_data(SELF);
/* Set flags for custom GC mark and destroy. */
PObj_custom_mark_SET(SELF);
PObj_active_destroy_SET(SELF);
/* Set up the core struct. */
- PMC_data(SELF) = core_struct;
core_struct->id = 0;
core_struct->max_tid = 0;
core_struct->task_list = pmc_new(interp, enum_class_Hash);
@@ -248,8 +247,6 @@
VTABLE void destroy() {
Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
MUTEX_DESTROY(core_struct->msg_lock);
- mem_sys_free(core_struct);
- PMC_data(SELF) = NULL;
}
Modified: trunk/src/pmc/schedulermessage.pmc
==============================================================================
--- trunk/src/pmc/schedulermessage.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/schedulermessage.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2008, Parrot Foundation.
+Copyright (C) 2001-2009, Parrot Foundation.
$Id$
=head1 NAME
@@ -20,7 +20,7 @@
#include "parrot/scheduler_private.h"
-pmclass SchedulerMessage need_ext {
+pmclass SchedulerMessage need_ext auto_attrs {
ATTR INTVAL id; /* The message's ID. */
ATTR STRING *type; /* The message's type. */
ATTR PMC *data; /* Additional data for the message. */
@@ -37,14 +37,12 @@
VTABLE void init() {
Parrot_SchedulerMessage_attributes * const core_struct
- = mem_allocate_zeroed_typed(Parrot_SchedulerMessage_attributes);
+ = (Parrot_SchedulerMessage_attributes *) PMC_data(SELF);
- /* Set flags for custom GC mark and destroy. */
+ /* Set flags for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
/* Set up the core struct. */
- PMC_data(SELF) = core_struct;
core_struct->id = 0;
core_struct->type = CONST_STRING(INTERP, "");
core_struct->data = PMCNULL;
@@ -189,20 +187,6 @@
/*
-=item C<void destroy()>
-
-Free the scheduler's underlying struct.
-
-=cut
-
-*/
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<void mark()>
Mark any referenced strings and PMCs.
Modified: trunk/src/pmc/sockaddr.pmc
==============================================================================
--- trunk/src/pmc/sockaddr.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/sockaddr.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -29,7 +29,7 @@
}
#endif
-pmclass Sockaddr need_ext {
+pmclass Sockaddr need_ext auto_attrs {
ATTR void *pointer; /* The stored pointer. */
/*
@@ -44,10 +44,10 @@
VTABLE void init() {
Parrot_Sockaddr_attributes * const pdata_struct =
- mem_allocate_typed(Parrot_Sockaddr_attributes);
+ (Parrot_Sockaddr_attributes *) PMC_data(SELF);
- PMC_data(SELF) = pdata_struct;
pdata_struct->pointer = mem_allocate_zeroed_typed(struct sockaddr_in);
+ PObj_active_destroy_SET(SELF);
}
/*
@@ -65,8 +65,7 @@
if (data) {
mem_sys_free(data->pointer);
- mem_sys_free(data);
- PMC_data(SELF) = NULL;
+ data->pointer = NULL;
}
}
Modified: trunk/src/pmc/socket.pmc
==============================================================================
--- trunk/src/pmc/socket.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/socket.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,7 +20,7 @@
#include "../src/io/io_private.h"
-pmclass Socket extends Handle {
+pmclass Socket extends Handle auto_attrs {
ATTR PMC *local; /* Local addr */
ATTR PMC *remote; /* Remote addr */
@@ -36,9 +36,8 @@
VTABLE void init() {
Parrot_Socket_attributes *data_struct =
- mem_allocate_zeroed_typed(Parrot_Socket_attributes);
+ (Parrot_Socket_attributes *) PMC_data(SELF);
- PMC_data(SELF) = data_struct;
data_struct->local = PMCNULL;
data_struct->remote = PMCNULL;
@@ -119,7 +118,6 @@
Parrot_io_close_piohandle(interp, data_struct->os_handle);
data_struct->os_handle = PIO_INVALID_HANDLE;
}
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/string.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,7 +20,7 @@
*/
-pmclass String extends scalar provides string provides scalar {
+pmclass String extends scalar provides string provides scalar auto_attrs {
ATTR STRING * str_val;
/*
@@ -34,33 +34,14 @@
*/
VTABLE void init() {
- Parrot_String_attributes *attrs =
- mem_allocate_typed(Parrot_String_attributes);
STRING *str_val = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
- PMC_data(SELF) = attrs;
SET_ATTR_str_val(INTERP, SELF, str_val);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
}
/*
-=item C<void destroy()>
-
-Destroys this String PMC.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-
-/*
-
=item C<PMC instantiate_str(STRING *rep)>
Class method to construct a String from the string representation C<rep>.
@@ -111,7 +92,6 @@
VTABLE PMC *clone() {
PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type);
- PObj_custom_mark_destroy_SETALL(dest);
VTABLE_set_string_native(INTERP, dest, Parrot_str_copy(INTERP, SELF.get_string()));
return dest;
}
Modified: trunk/src/pmc/stringhandle.pmc
==============================================================================
--- trunk/src/pmc/stringhandle.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/stringhandle.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -46,7 +46,7 @@
return Parrot_str_equal(interp, s, CONST_STRING(interp, "utf8"));
}
-pmclass StringHandle extends Handle need_ext {
+pmclass StringHandle extends Handle need_ext auto_attrs {
ATTR INTVAL flags; /* Filehandle flags */
ATTR STRING *stringhandle; /* The string data */
ATTR STRING *mode; /* The mode string used in open */
@@ -70,9 +70,8 @@
VTABLE void init() {
Parrot_StringHandle_attributes *data_struct =
- mem_allocate_typed(Parrot_StringHandle_attributes);
+ (Parrot_StringHandle_attributes *) PMC_data(SELF);
- PMC_data(SELF) = data_struct;
data_struct->flags = 0;
data_struct->stringhandle = NULL;
data_struct->mode = NULL;
@@ -81,7 +80,6 @@
data_struct->read_offset = 0;
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
}
/*
@@ -134,22 +132,6 @@
/*
-=item C<void destroy()>
-
-Free structures.
-
-=cut
-
-*/
- VTABLE void destroy() {
- if (PARROT_STRINGHANDLE(SELF)) {
- mem_sys_free(PARROT_STRINGHANDLE(SELF));
- PMC_data(SELF) = NULL;
- }
- }
-
-/*
-
=item C<INTVAL get_bool()>
Returns whether the StringHandle has reached the end of the file.
Modified: trunk/src/pmc/stringiterator.pmc
==============================================================================
--- trunk/src/pmc/stringiterator.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/stringiterator.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -22,7 +22,7 @@
*/
-pmclass StringIterator extends Iterator {
+pmclass StringIterator auto_attrs extends Iterator {
ATTR PMC *string; /* String to iterate over */
ATTR INTVAL pos; /* Current position of iterator for forward iterator */
/* Previous position of iterator for reverse iterator */
@@ -39,31 +39,11 @@
*/
VTABLE void init_pmc(PMC *string) {
- Parrot_StringIterator_attributes * const attrs =
- mem_allocate_zeroed_typed(Parrot_StringIterator_attributes);
-
- attrs->string = string;
- PMC_data(SELF) = attrs;
-
- PObj_custom_mark_destroy_SETALL(SELF);
+ SET_ATTR_string(INTERP, SELF, string);
/* by default, iterate from start */
SELF.set_integer_native(ITERATE_FROM_START);
- }
-
-/*
-
-=item C<void destroy()>
-
-destroys this PMC
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
+ PObj_custom_mark_SET(SELF);
}
/*
Modified: trunk/src/pmc/task.pmc
==============================================================================
--- trunk/src/pmc/task.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/task.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -20,7 +20,7 @@
#include "parrot/scheduler_private.h"
-pmclass Task need_ext {
+pmclass Task need_ext auto_attrs {
ATTR INTVAL id; /* The task ID. */
ATTR INTVAL priority; /* The priority of the task. */
ATTR FLOATVAL birthtime; /* The creation time stamp of the task. */
@@ -44,14 +44,12 @@
VTABLE void init() {
Parrot_Task_attributes * const core_struct =
- mem_allocate_zeroed_typed(Parrot_Task_attributes);
+ (Parrot_Task_attributes *) PMC_data(SELF);
- /* Set flags for custom GC mark and destroy. */
+ /* Set flags for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
/* Set up the core struct. */
- PMC_data(SELF) = core_struct;
core_struct->id = 0;
core_struct->type = CONST_STRING(interp, "");
core_struct->subtype = CONST_STRING(interp, "");
@@ -123,14 +121,12 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
"Task initializer must be a Hash");
- core_struct = mem_allocate_zeroed_typed(Parrot_Task_attributes);
+ core_struct = (Parrot_Task_attributes *) PMC_data(SELF);
- /* Set flags for custom GC mark and destroy. */
+ /* Set flags for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
/* Set up the core struct. */
- PMC_data(SELF) = core_struct;
elem = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "id"));
if (! PMC_IS_NULL(elem))
@@ -369,20 +365,6 @@
/*
-=item C<void destroy()>
-
-Free the task's underlying struct.
-
-=cut
-
-*/
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<void mark()>
Mark any referenced strings and PMCs.
Modified: trunk/src/pmc/timer.pmc
==============================================================================
--- trunk/src/pmc/timer.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/timer.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -57,7 +57,7 @@
#include "parrot/scheduler_private.h"
-pmclass Timer extends Task provides event need_ext {
+pmclass Timer extends Task provides event need_ext auto_attrs {
ATTR FLOATVAL duration; /* The duration of the timer pause */
ATTR FLOATVAL interval; /* How often to repeat */
ATTR INTVAL repeat; /* Whether to repeat:
@@ -75,14 +75,13 @@
VTABLE void init() {
Parrot_Timer_attributes * const core_struct =
- mem_allocate_zeroed_typed(Parrot_Timer_attributes);
+ (Parrot_Timer_attributes *) PMC_data(SELF);
/* Set flags for custom GC mark and destroy. */
PObj_custom_mark_SET(SELF);
PObj_active_destroy_SET(SELF);
/* Set up the core struct. */
- PMC_data(SELF) = core_struct;
core_struct->id = 0;
core_struct->type = CONST_STRING(interp, "timer");
core_struct->subtype = CONST_STRING(interp, "");
@@ -179,8 +178,6 @@
VTABLE void destroy() {
Parrot_cx_delete_task(INTERP, SELF);
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
Modified: trunk/src/pmc/undef.pmc
==============================================================================
--- trunk/src/pmc/undef.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/undef.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -57,7 +57,6 @@
VTABLE_destroy(interp, clone);
PObj_is_object_SET(SELF);
- PObj_active_destroy_SET(SELF);
}
}
Modified: trunk/src/pmc/unmanagedstruct.pmc
==============================================================================
--- trunk/src/pmc/unmanagedstruct.pmc Tue Aug 18 16:52:00 2009 (r40627)
+++ trunk/src/pmc/unmanagedstruct.pmc Tue Aug 18 17:24:24 2009 (r40628)
@@ -651,7 +651,7 @@
return toff;
}
-pmclass UnManagedStruct need_ext no_ro {
+pmclass UnManagedStruct need_ext auto_attrs no_ro {
ATTR void *ptr; /* the struct that this UnManagedStruct isn't managing */
ATTR PMC *init; /* the initializer used with this UnManagedStruct */
ATTR INTVAL size; /* the size of the struct */
@@ -664,39 +664,6 @@
=over 4
-=item C<void init()>
-
-Initializes the C<struct> with a default value of C<NULL>.
-
-=cut
-
-*/
-
- VTABLE void init() {
- Parrot_UnManagedStruct_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_UnManagedStruct_attributes);
- PMC_data(SELF) = attrs;
- PObj_active_destroy_SET(SELF);
- }
-
-/*
-
-=item C<void destroy()>
-
-Destroys the subroutine.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-
-/*
-
=item C<void init_pmc(PMC *value)>
Initialize the struct with some data.
@@ -724,9 +691,6 @@
*/
VTABLE void init_pmc(PMC *value) {
- Parrot_UnManagedStruct_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_UnManagedStruct_attributes);
- PMC_data(SELF) = attrs;
SELF.set_pmc(value);
}
More information about the parrot-commits
mailing list