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

cotto at svn.parrot.org cotto at svn.parrot.org
Wed Dec 9 06:35:11 UTC 2009


Author: cotto
Date: Wed Dec  9 06:35:10 2009
New Revision: 42954
URL: https://trac.parrot.org/parrot/changeset/42954

Log:
[pmc] switch AddrRegistry to use GET_ATTR macros, courtesy of JimmyZ++

Modified:
   trunk/src/pmc/addrregistry.pmc

Modified: trunk/src/pmc/addrregistry.pmc
==============================================================================
--- trunk/src/pmc/addrregistry.pmc	Wed Dec  9 06:30:42 2009	(r42953)
+++ trunk/src/pmc/addrregistry.pmc	Wed Dec  9 06:35:10 2009	(r42954)
@@ -70,8 +70,11 @@
 */
 
     VTABLE INTVAL get_integer_keyed(PMC *key) {
-        Hash   *hash  = (Hash *)SELF.get_pointer();
-        void   *value = parrot_hash_get(INTERP, hash, key);
+        Hash       *hash;
+        const void *value;
+	
+        GET_ATTR_hash(interp, SELF, hash);
+        value = parrot_hash_get(INTERP, hash, key);
 
         if (value)
             return (INTVAL)value;
@@ -80,11 +83,19 @@
     }
 
     VTABLE INTVAL elements() {
-        return parrot_hash_size(INTERP, (Hash *)SELF.get_pointer());
+        const Hash *hash;
+
+        GET_ATTR_hash(interp, SELF, hash);
+
+        return parrot_hash_size(INTERP, hash);
     }
 
     VTABLE INTVAL get_bool() {
-        return parrot_hash_size(INTERP, (Hash *)SELF.get_pointer()) != 0;
+        const Hash *hash;
+
+        GET_ATTR_hash(interp, SELF, hash);
+
+        return parrot_hash_size(INTERP, hash) != 0;
     }
 /*
 
@@ -108,11 +119,15 @@
 */
 
     VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
-        Hash       * const hash = (Hash *)SELF.get_pointer();
-        void       *oldval      = parrot_hash_get(INTERP, hash, key);
-        long        newval      = 1;
+        const void *oldval;
+        long        newval = 1;
+        Hash       *hash;
         UNUSED(value);
 
+        GET_ATTR_hash(interp, SELF, hash);
+
+        oldval = parrot_hash_get(INTERP, hash, key);
+
         if (oldval)
             newval += (long)oldval;
 
@@ -120,13 +135,17 @@
     }
 
     VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
-        Hash *hash = (Hash *)SELF.get_pointer();
+        Hash *hash;
+        GET_ATTR_hash(interp, SELF, hash);
         parrot_hash_put(INTERP, hash, key, (void *)value);
     }
 
     VTABLE void delete_keyed(PMC *key) {
-        Hash       * const hash  = (Hash *)SELF.get_pointer();
-        void              *value = parrot_hash_get(INTERP, hash, key);
+        Hash       *hash;
+        void       *value;
+
+        GET_ATTR_hash(interp, SELF, hash);
+        value = parrot_hash_get(INTERP, hash, key);
 
         /* these casts look bad, but they avoid type punning warnings with -O */
         if (value) {


More information about the parrot-commits mailing list