[svn:parrot] r35669 - trunk/src/pmc

[email protected]
Newsgroups perl.cvs.parrot
Message-ID <[email protected]>
Author: cotto
Date: Sat Jan 17 01:55:00 2009
New Revision: 35669

Modified:
   trunk/src/pmc/lexpad.pmc

Log:
[pmc] convert some LexPad code to use attrs


Modified: trunk/src/pmc/lexpad.pmc
==============================================================================
--- trunk/src/pmc/lexpad.pmc	(original)
+++ trunk/src/pmc/lexpad.pmc	Sat Jan 17 01:55:00 2009
@@ -29,6 +29,7 @@
  */
 
 pmclass LexPad provides hash no_ro {
+    ATTR PMC * lexinfo;
 
     VTABLE void init() {
         Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
@@ -78,7 +79,14 @@
 
 */
     VTABLE void init_pmc(PMC *lexinfo) {
-        PMC_pmc_val(SELF) = lexinfo;
+        Parrot_LexPad_attributes *attrs = 
+            mem_allocate_zeroed_typed(Parrot_LexPad_attributes);
+        attrs->lexinfo = lexinfo;
+        PMC_data(SELF) = attrs;
+    }
+
+    VTABLE void destroy() {
+        mem_sys_free(PMC_data(SELF));
     }
 
     VTABLE void set_pointer(void *ctx) {
@@ -86,12 +94,14 @@
     }
 
     VTABLE INTVAL elements() {
-        PMC *info = PMC_pmc_val(SELF);
+        PMC *info;
+        GET_ATTR_lexinfo(INTERP, SELF, info);
         return parrot_hash_size(INTERP, (Hash *)PMC_struct_val(info));
     }
 
     VTABLE INTVAL exists_keyed_str(STRING *name) {
-        PMC * const info = PMC_pmc_val(SELF);
+        PMC *info;
+        GET_ATTR_lexinfo(INTERP, SELF, info);
         return parrot_hash_get_bucket(INTERP,
             (Hash *)PMC_struct_val(info), name) != 0;
     }
@@ -102,12 +112,17 @@
     }
 
     VTABLE PMC *get_pmc_keyed_str(STRING *name) {
-        PMC              * const info = PMC_pmc_val(SELF);
-        Hash             * const hash = (Hash *)PMC_struct_val(info);
-        Parrot_Context   * const ctx  = (Parrot_Context *)PMC_struct_val(SELF);
-        HashBucket       * const b    = parrot_hash_get_bucket(INTERP, hash, name);
+        PMC              * info;
+        Hash             * hash;
+        Parrot_Context   * ctx;
+        HashBucket       * b;
         INTVAL            regno;
 
+        GET_ATTR_lexinfo(INTERP, SELF, info);
+        hash = (Hash *)PMC_struct_val(info);
+        ctx  = (Parrot_Context *)PMC_struct_val(SELF);
+        b    = parrot_hash_get_bucket(INTERP, hash, name);
+
         if (!b)
             return NULL;
 
@@ -122,11 +137,16 @@
     }
 
     VTABLE void set_pmc_keyed_str(STRING *name, PMC *value) {
-        PMC              * const info  = PMC_pmc_val(SELF);
-        Hash             * const hash  = (Hash *)PMC_struct_val(info);
-        Parrot_Context   * const ctx   = (Parrot_Context *)PMC_struct_val(SELF);
-        HashBucket       * const b     = parrot_hash_get_bucket(INTERP, hash, name);
-        INTVAL            regno;
+        PMC              * info;
+        Hash             * hash;
+        Parrot_Context   * ctx;
+        HashBucket       * b;
+        INTVAL             regno;
+
+        GET_ATTR_lexinfo(INTERP, SELF, info);
+        hash = (Hash *)PMC_struct_val(info);
+        ctx  = (Parrot_Context *)PMC_struct_val(SELF);
+        b    = parrot_hash_get_bucket(INTERP, hash, name);
 
         if (!b)
             Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LEX_NOT_FOUND,
@@ -142,7 +162,8 @@
     }
 
     METHOD get_lexinfo() {
-        PMC *lexinfo = PMC_pmc_val(SELF);
+        PMC *lexinfo;
+        GET_ATTR_lexinfo(INTERP, SELF, lexinfo);
         RETURN(PMC *lexinfo);
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.