[svn:parrot] r37644 - in trunk: . include/parrot src src/pmc

cotto at svn.parrot.org cotto at svn.parrot.org
Mon Mar 23 08:44:45 UTC 2009


Author: cotto
Date: Mon Mar 23 08:44:44 2009
New Revision: 37644
URL: https://trac.parrot.org/parrot/changeset/37644

Log:
[hash] change Parrot_new_INTVAL_hash to parrot_new_intval_hash, make it return a Hash*
also, unrelated trailing space fix

Modified:
   trunk/DEPRECATED.pod
   trunk/include/parrot/hash.h
   trunk/src/hash.c
   trunk/src/hll.c
   trunk/src/pmc/hash.pmc
   trunk/src/pmc/object.pmc
   trunk/src/pmc_freeze.c

Modified: trunk/DEPRECATED.pod
==============================================================================
--- trunk/DEPRECATED.pod	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/DEPRECATED.pod	Mon Mar 23 08:44:44 2009	(r37644)
@@ -207,14 +207,6 @@
 
 L<https://trac.parrot.org/parrot/ticket/443>
 
-=item src/hash.c API cleanup [eligible in 1.1]
-
-C<Parrot_new_INTVAL_hash> will also be rewritten to return a Hash* and will be
-renamed to C<parrot_new_intval_hash> for consistency with other similar
-functions.
-
-L<https://trac.parrot.org/parrot/ticket/456>
-
 =item Parrot_add_library_path [eligible in 1.1]
 
 Will be renamed to C<Parrot_lib_add_path_from_cstring>.

Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/include/parrot/hash.h	Mon Mar 23 08:44:44 2009	(r37644)
@@ -192,7 +192,7 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-PMC* Parrot_new_INTVAL_hash(PARROT_INTERP, UINTVAL flags)
+Hash* parrot_new_intval_hash(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 PARROT_EXPORT
@@ -288,7 +288,7 @@
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_parrot_new_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_new_INTVAL_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_parrot_new_intval_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_parrot_new_pmc_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \

Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/src/hash.c	Mon Mar 23 08:44:44 2009	(r37644)
@@ -1052,7 +1052,7 @@
 
 /*
 
-=item C<PMC* Parrot_new_INTVAL_hash>
+=item C<Hash* parrot_new_intval_hash>
 
 Creates and returns new Hash PMC with INTVAL keys and values. C<flags> can be
 C<PObj_constant_FLAG> or 0.
@@ -1064,21 +1064,12 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-PMC*
-Parrot_new_INTVAL_hash(PARROT_INTERP, UINTVAL flags)
+Hash*
+parrot_new_intval_hash(PARROT_INTERP)
 {
-    ASSERT_ARGS(Parrot_new_INTVAL_hash)
-    Hash *hash;
-    PMC * const h = (flags & PObj_constant_FLAG)
-                  ? constant_pmc_new_noinit(interp, enum_class_Hash)
-                  : pmc_new_noinit(interp, enum_class_Hash);
-
-    hash = parrot_create_hash(interp,
-            enum_type_INTVAL, Hash_key_type_int, int_compare, key_hash_int);
-    PMC_struct_val(h) = hash;
-    hash->container   = h;
-    PObj_active_destroy_SET(h);
-    return h;
+    ASSERT_ARGS(parrot_new_intval_hash)
+    return parrot_create_hash(interp, enum_type_INTVAL, Hash_key_type_int,
+            int_compare, key_hash_int);
 }
 
 

Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/src/hll.c	Mon Mar 23 08:44:44 2009	(r37644)
@@ -197,7 +197,8 @@
     VTABLE_set_pmc_keyed_int(interp, interp->HLL_namespace, idx, ns_hash);
 
     /* create HLL typemap hash */
-    type_hash = Parrot_new_INTVAL_hash(interp, PObj_constant_FLAG);
+    type_hash = constant_pmc_new(interp, enum_class_Hash);
+    VTABLE_set_pointer(interp, type_hash, parrot_new_intval_hash(interp));
     VTABLE_set_pmc_keyed_int(interp, entry, e_HLL_typemap, type_hash);
 
     /* UNLOCK */

Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/src/pmc/hash.pmc	Mon Mar 23 08:44:44 2009	(r37644)
@@ -175,15 +175,16 @@
 =cut
 
 */
-    
+
     VTABLE void set_pointer(void *ptr) {
         Hash *old_hash = (Hash *)PMC_struct_val(SELF);
         Hash *new_hash = (Hash *)ptr;
-        
+
         PMC_struct_val(SELF) = new_hash;
+        new_hash->container  = SELF;
         parrot_hash_destroy(INTERP, old_hash);
     }
-        
+
 /*
 
 =item C<void *get_pointer()>
@@ -1098,10 +1099,10 @@
             const INTVAL v_type = VTABLE_shift_integer(INTERP, io);
             Hash        *hash;
 
-            /* RT #46651 make a better interface for hash creation
-             * RT #46653 create hash with needed size in the first place */
+            /* RT #46653 create hash with needed size in the first place */
             if (k_type == Hash_key_type_int && v_type == enum_hash_int) {
-                PMC * const dummy     = Parrot_new_INTVAL_hash(INTERP, 0);
+                PMC * const dummy  = pmc_new(interp, enum_class_Hash);
+                VTABLE_set_pointer(INTERP, dummy, parrot_new_intval_hash(INTERP));
 
                 /* don't leak the hash if we're going to overwrite it anyway */
                 if (PMC_struct_val(SELF))

Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/src/pmc/object.pmc	Mon Mar 23 08:44:44 2009	(r37644)
@@ -361,7 +361,7 @@
                 }
             }
             else {
-                Parrot_ex_throw_from_c_args(INTERP, NULL, -1, 
+                Parrot_ex_throw_from_c_args(INTERP, NULL, -1,
                         "Class %Ss inherits from alien parents.", class_info->name);
             }
         }

Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c	Sun Mar 22 12:57:11 2009	(r37643)
+++ trunk/src/pmc_freeze.c	Mon Mar 23 08:44:44 2009	(r37644)
@@ -1132,7 +1132,8 @@
     info->visit_pmc_later = add_pmc_todo_list;
     /* we must use PMCs here, so that they get marked properly */
     info->todo = pmc_new(interp, enum_class_Array);
-    info->seen = Parrot_new_INTVAL_hash(interp, 0);
+    info->seen = pmc_new(interp, enum_class_Hash);
+    VTABLE_set_pointer(interp, info->seen, parrot_new_intval_hash(interp));
 
     ft_init(interp, info);
 }


More information about the parrot-commits mailing list