[svn:parrot] r40488 - branches/auto_attrs/src/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Tue Aug 11 11:13:03 UTC 2009


Author: NotFound
Date: Tue Aug 11 11:13:00 2009
New Revision: 40488
URL: https://trac.parrot.org/parrot/changeset/40488

Log:
set auto_attrs on FileHandle and StringHandle PMCs

Modified:
   branches/auto_attrs/src/pmc/filehandle.pmc
   branches/auto_attrs/src/pmc/stringhandle.pmc

Modified: branches/auto_attrs/src/pmc/filehandle.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/filehandle.pmc	Tue Aug 11 08:02:51 2009	(r40487)
+++ branches/auto_attrs/src/pmc/filehandle.pmc	Tue Aug 11 11:13:00 2009	(r40488)
@@ -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: branches/auto_attrs/src/pmc/stringhandle.pmc
==============================================================================
--- branches/auto_attrs/src/pmc/stringhandle.pmc	Tue Aug 11 08:02:51 2009	(r40487)
+++ branches/auto_attrs/src/pmc/stringhandle.pmc	Tue Aug 11 11:13:00 2009	(r40488)
@@ -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.


More information about the parrot-commits mailing list