[svn:parrot] r40405 - in branches/auto_attrs: lib/Parrot lib/Parrot/Pmc2c src src/gc src/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Wed Aug 5 09:36:25 UTC 2009
Author: NotFound
Date: Wed Aug 5 09:36:23 2009
New Revision: 40405
URL: https://trac.parrot.org/parrot/changeset/40405
Log:
put the branch up to date with the changes already tested from TT #895
Modified:
branches/auto_attrs/lib/Parrot/Pmc2c/PMCEmitter.pm
branches/auto_attrs/lib/Parrot/Vtable.pm
branches/auto_attrs/src/gc/api.c
branches/auto_attrs/src/pmc.c
branches/auto_attrs/src/pmc/class.pmc
branches/auto_attrs/src/pmc/complex.pmc
branches/auto_attrs/src/pmc/continuation.pmc
branches/auto_attrs/src/pmc/cpointer.pmc
branches/auto_attrs/src/pmc/default.pmc
branches/auto_attrs/src/pmc/exception.pmc
branches/auto_attrs/src/pmc/exceptionhandler.pmc
branches/auto_attrs/src/pmc/fixedbooleanarray.pmc
branches/auto_attrs/src/pmc/fixedfloatarray.pmc
branches/auto_attrs/src/pmc/fixedintegerarray.pmc
branches/auto_attrs/src/pmc/fixedstringarray.pmc
branches/auto_attrs/src/pmc/multisub.pmc
branches/auto_attrs/src/pmc/parrotinterpreter.pmc
branches/auto_attrs/src/pmc/parrotlibrary.pmc
branches/auto_attrs/src/pmc/pmcproxy.pmc
branches/auto_attrs/src/pmc/resizablebooleanarray.pmc
branches/auto_attrs/src/pmc/resizablefloatarray.pmc
branches/auto_attrs/src/pmc/resizableintegerarray.pmc
branches/auto_attrs/src/pmc/resizablestringarray.pmc
branches/auto_attrs/src/pmc/retcontinuation.pmc
branches/auto_attrs/src/pmc/stringiterator.pmc
branches/auto_attrs/src/pmc/undef.pmc
Modified: branches/auto_attrs/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- branches/auto_attrs/lib/Parrot/Pmc2c/PMCEmitter.pm Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/lib/Parrot/Pmc2c/PMCEmitter.pm Wed Aug 5 09:36:23 2009 (r40405)
@@ -464,7 +464,8 @@
NULL, /* mro */
NULL, /* attribute_defs */
NULL, /* ro_variant_vtable */
- $methlist
+ $methlist,
+ 0 /* attr size */
};
ENDOFCODE
return $cout;
@@ -601,6 +602,12 @@
EOC
+ if ( @{$attributes} && $self->{flags}{auto_attrs} ) {
+ $cout .= <<"EOC";
+ vt->attr_size = sizeof(Parrot_${classname}_attributes);
+EOC
+ }
+
# init vtable slot
if ( $self->is_dynamic ) {
$cout .= <<"EOC";
@@ -640,6 +647,14 @@
vt_${k} = Parrot_${classname}_${k}_get_vtable(interp);
vt_${k}->base_type = $enum_name;
vt_${k}->flags = $k_flags;
+EOC
+ if ( @{$attributes} && $self->{flags}{auto_attrs} ) {
+ $cout .= <<"EOC";
+ vt_${k}->attr_size = sizeof(Parrot_${classname}_attributes);
+EOC
+ }
+ $cout .= <<"EOC";
+
vt_${k}->attribute_defs = attr_defs;
vt_${k}->base_type = entry;
Modified: branches/auto_attrs/lib/Parrot/Vtable.pm
==============================================================================
--- branches/auto_attrs/lib/Parrot/Vtable.pm Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/lib/Parrot/Vtable.pm Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/gc/api.c
==============================================================================
--- branches/auto_attrs/src/gc/api.c Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/gc/api.c Wed Aug 5 09:36:23 2009 (r40405)
@@ -373,6 +373,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: branches/auto_attrs/src/pmc.c
==============================================================================
--- branches/auto_attrs/src/pmc.c Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc.c Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/class.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/class.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/class.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/complex.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/complex.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/complex.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/continuation.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/continuation.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/continuation.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/cpointer.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/cpointer.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/cpointer.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/default.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/default.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/default.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/exception.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/exception.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/exception.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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,8 @@
*/
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. */
+ /* Set flags for custom GC mark. */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
SET_ATTR_severity(INTERP, SELF, EXCEPT_error);
SET_ATTR_handled(INTERP, SELF, 0);
@@ -116,9 +109,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 +122,8 @@
message_val = VTABLE_get_string(interp, values);
}
- PMC_data(SELF) = core_struct;
- /* 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 and default values for the exception object. */
@@ -175,25 +163,6 @@
/*
-=item C<void destroy()>
-
-Destroys the exception.
-
-=cut
-
-*/
-
- 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);
- }
- }
-
-/*
-
=item C<INTVAL get_bool()>
Return true.
Modified: branches/auto_attrs/src/pmc/exceptionhandler.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/exceptionhandler.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/exceptionhandler.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/fixedbooleanarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/fixedbooleanarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/fixedbooleanarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/fixedfloatarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/fixedfloatarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/fixedfloatarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/fixedintegerarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/fixedintegerarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/fixedintegerarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/fixedstringarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/fixedstringarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/fixedstringarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/multisub.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/multisub.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/multisub.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/parrotinterpreter.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/parrotinterpreter.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/parrotinterpreter.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -240,8 +240,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);
}
@@ -261,8 +262,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: branches/auto_attrs/src/pmc/parrotlibrary.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/parrotlibrary.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/parrotlibrary.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/pmcproxy.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/pmcproxy.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/pmcproxy.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/resizablebooleanarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/resizablebooleanarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/resizablebooleanarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/resizablefloatarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/resizablefloatarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/resizablefloatarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -20,7 +20,7 @@
*/
-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 */
@@ -35,9 +35,7 @@
*/
VTABLE void init() {
- Parrot_ResizableFloatArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_ResizableFloatArray_attributes);
- PMC_data(SELF) = attrs;
+ SUPER();
}
/*
Modified: branches/auto_attrs/src/pmc/resizableintegerarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/resizableintegerarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/resizableintegerarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -20,7 +20,7 @@
*/
-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 */
/*
@@ -33,10 +33,7 @@
*/
VTABLE void init() {
- Parrot_ResizableIntegerArray_attributes* attrs =
- mem_allocate_zeroed_typed(Parrot_ResizableIntegerArray_attributes);
- PMC_data(SELF) = attrs;
- PObj_active_destroy_SET(SELF);
+ SUPER();
}
/*
Modified: branches/auto_attrs/src/pmc/resizablestringarray.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/resizablestringarray.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/resizablestringarray.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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 */
/*
@@ -36,12 +36,7 @@
*/
VTABLE void init() {
- Parrot_ResizableStringArray_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_ResizableStringArray_attributes);
-
- PMC_data(SELF) = attrs;
-
- PObj_custom_mark_destroy_SETALL(SELF);
+ SUPER();
}
/*
Modified: branches/auto_attrs/src/pmc/retcontinuation.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/retcontinuation.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/retcontinuation.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/stringiterator.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/stringiterator.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/stringiterator.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -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: branches/auto_attrs/src/pmc/undef.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/undef.pmc Wed Aug 5 09:25:59 2009 (r40404)
+++ branches/auto_attrs/src/pmc/undef.pmc Wed Aug 5 09:36:23 2009 (r40405)
@@ -57,7 +57,6 @@
VTABLE_destroy(interp, clone);
PObj_is_object_SET(SELF);
- PObj_active_destroy_SET(SELF);
}
}
More information about the parrot-commits
mailing list