Author: petdance
Date: Tue May 29 23:35:36 2007
New Revision: 18680
Modified:
trunk/include/parrot/hash.h
trunk/src/hash.c
trunk/src/objects.c
trunk/src/pmc/hash.pmc
Log:
parrot_hash_get_bucket and parrot_hash_get_idx now take consted hashes. This
will allow a lot of upward cascades of const
Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h (original)
+++ trunk/include/parrot/hash.h Tue May 29 23:35:36 2007
@@ -86,7 +86,7 @@
PARROT_API INTVAL parrot_hash_size(Interp *interp, Hash *hash);
PARROT_API void parrot_hash_set_size(Interp *interp, Hash *hash, UINTVAL size);
PARROT_API void parrot_hash_destroy(Interp *interp, Hash *hash);
-PARROT_API HashBucket *parrot_hash_get_bucket(Interp *interp, Hash *hash, void
*key);
+PARROT_API HashBucket *parrot_hash_get_bucket(Interp *interp, const Hash
*hash, void *key);
PARROT_API void *parrot_hash_get(Interp *interp, Hash *hash, void *key);
PARROT_API INTVAL parrot_hash_exists(Interp *interp, Hash *hash, void *key);
PARROT_API HashBucket *parrot_hash_put(Interp *interp, Hash *hash, void *key,
void *value);
@@ -94,7 +94,7 @@
PARROT_API void parrot_mark_hash(Interp *interp, Hash *hash);
PARROT_API void parrot_hash_visit(Interp *interp, Hash *hash, void*);
PARROT_API void parrot_dump_hash(Interp *interp, Hash *hash);
-PARROT_API void* parrot_hash_get_idx(Interp *interp, Hash *hash, PMC *key);
+PARROT_API void* parrot_hash_get_idx(Interp *interp, const Hash *hash, PMC
*key);
#endif /* PARROT_HASH_H_GUARD */
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c (original)
+++ trunk/src/hash.c Tue May 29 23:35:36 2007
@@ -720,7 +720,7 @@
/*
=item C<void *
-parrot_hash_get_idx(Interp *interp, Hash *hash, PMC * key)>
+parrot_hash_get_idx(Interp *interp, const Hash *hash, PMC * key)>
Called by iterator.
@@ -729,10 +729,10 @@
*/
void *
-parrot_hash_get_idx(Interp *interp, Hash *hash, PMC * key)
+parrot_hash_get_idx(Interp *interp, const Hash *hash, PMC * key)
{
INTVAL i = PMC_int_val(key);
- BucketIndex bi = (BucketIndex)PMC_data(key);
+ const BucketIndex bi = (BucketIndex)PMC_data(key);
HashBucket *b;
void *res;
INTVAL size;
@@ -772,7 +772,7 @@
/*
=item C<HashBucket *
-parrot_hash_get_bucket(Interp *interp, Hash *hash, void *key)>
+parrot_hash_get_bucket(Interp *interp, const Hash *hash, void *key)>
Returns the bucket for C<key>.
@@ -781,7 +781,7 @@
*/
HashBucket *
-parrot_hash_get_bucket(Interp *interp, Hash *hash, void *key)
+parrot_hash_get_bucket(Interp *interp, const Hash *hash, void *key)
{
const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed);
HashBucket *bucket = hash->bi[hashval & hash->mask];
Modified: trunk/src/objects.c
==============================================================================
--- trunk/src/objects.c (original)
+++ trunk/src/objects.c Tue May 29 23:35:36 2007
@@ -2007,9 +2007,7 @@
/* Check if it's in the exclude list. */
if (got_exclude) {
- int exclude_count;
-
- exclude_count = VTABLE_elements(interp, exclude);
+ const int exclude_count = VTABLE_elements(interp, exclude);
for (i = 0; i < exclude_count; i++) {
const STRING * const check =
VTABLE_get_string_keyed_int(interp, exclude, i);
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc (original)
+++ trunk/src/pmc/hash.pmc Tue May 29 23:35:36 2007
@@ -263,7 +263,7 @@
STRING *keystr;
HashBucket *b;
PMC *nextkey;
- Hash * const hash = (Hash *)PMC_struct_val(SELF);
+ const Hash * const hash = (Hash *)PMC_struct_val(SELF);
switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
case KEY_hash_iterator_FLAGS:
@@ -274,7 +274,7 @@
return (INTVAL)parrot_hash_get_idx(INTERP, hash, key);
}
else {
- STRING *s = (STRING*)parrot_hash_get_idx(INTERP, hash,
key);
+ const STRING * const s =
(STRING*)parrot_hash_get_idx(INTERP, hash, key);
return string_to_int(INTERP, s);
}
default: