Skip to content

Commit

Permalink
consting
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Feb 27, 2011
1 parent 1d16751 commit 8325884
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/pmc/filehandle.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Free structures.
*/
VTABLE void destroy() {
if (PARROT_FILEHANDLE(SELF)) {
Parrot_FileHandle_attributes *attrs = PARROT_FILEHANDLE(SELF);
Parrot_FileHandle_attributes * const attrs = PARROT_FILEHANDLE(SELF);

if (!Parrot_io_is_closed_filehandle(INTERP, SELF)) {
if (attrs->flags & PIO_F_SHARED)
Expand Down Expand Up @@ -388,7 +388,7 @@ Read a line from the filehandle and return it in a string.

#ifdef PARROT_HAS_READLINE
/* 4-column indent to get c_indent.t to DTRT */
char *prompt_cstring =
char * const prompt_cstring =
(got_prompt ? Parrot_str_to_cstring(INTERP, prompt) : NULL);
char * const r = readline(prompt_cstring);
Parrot_str_free_cstring(prompt_cstring);
Expand All @@ -409,7 +409,7 @@ Read a line from the filehandle and return it in a string.
}
#else
if (got_prompt) {
char *prompt_cstring = Parrot_str_to_cstring(INTERP, prompt);
char * const prompt_cstring = Parrot_str_to_cstring(INTERP, prompt);
fprintf(stderr, "%s", prompt_cstring);
Parrot_str_free_cstring(prompt_cstring);
}
Expand Down Expand Up @@ -769,7 +769,7 @@ Returns the next byte from the stream, but does not remove it.
*/

METHOD peek() {
STRING *s = Parrot_io_peek(INTERP, SELF);
STRING * const s = Parrot_io_peek(INTERP, SELF);
RETURN(STRING* s);
}

Expand Down
8 changes: 4 additions & 4 deletions src/pmc/hash.pmc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2010, Parrot Foundation.
Copyright (C) 2001-2011, Parrot Foundation.

=head1 NAME

Expand Down Expand Up @@ -299,7 +299,7 @@ NB: this method will destroy all old data!
=cut
*/
METHOD set_value_type(INTVAL type) {
Hash *old_hash = (Hash *)SELF.get_pointer();
Hash * const old_hash = (Hash *)SELF.get_pointer();
Hash *new_hash;

/*
Expand Down Expand Up @@ -330,7 +330,7 @@ NB: this method will destroy all old data!
}

METHOD get_value_type() {
INTVAL ret = ((Hash *)SELF.get_pointer())->entry_type;
const INTVAL ret = ((Hash *)SELF.get_pointer())->entry_type;
RETURN(INTVAL ret);
}

Expand Down Expand Up @@ -388,7 +388,7 @@ Return a representation of the hash contents.

VTABLE STRING *get_repr() {
PMC * const iter = VTABLE_get_iter(INTERP, SELF);
PMC *sb = Parrot_pmc_new(INTERP, enum_class_StringBuilder);
PMC * const sb = Parrot_pmc_new(INTERP, enum_class_StringBuilder);
const INTVAL n = VTABLE_elements(INTERP, SELF);
INTVAL j;

Expand Down
4 changes: 2 additions & 2 deletions src/pmc/hashiterator.pmc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2010, Parrot Foundation.
Copyright (C) 2001-2011, Parrot Foundation.

=head1 NAME

Expand Down Expand Up @@ -101,7 +101,7 @@ advance_to_next(PARROT_INTERP, ARGMOD(PMC *self))
}
else {
/* linear scan */
int n_buckets = N_BUCKETS(attrs->total_buckets);
const int n_buckets = N_BUCKETS(attrs->total_buckets);

if (!attrs->bucket)
attrs->bucket = attrs->parrot_hash->buckets;
Expand Down
11 changes: 6 additions & 5 deletions src/pmc/hashiteratorkey.pmc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2009, Parrot Foundation.
Copyright (C) 2001-2011, Parrot Foundation.

=head1 NAME

Expand Down Expand Up @@ -47,14 +47,15 @@ Get "key".
}

METHOD key() {
PMC *ret = SELF.get_pmc();
PMC * const ret = SELF.get_pmc();
RETURN(PMC* ret);
}

METHOD value() {
Parrot_HashIteratorKey_attributes *attrs =
const Parrot_HashIteratorKey_attributes * const attrs =
PARROT_HASHITERATORKEY(SELF);
PMC *ret = Parrot_hash_value_to_pmc(INTERP, attrs->parrot_hash, attrs->bucket->value);
PMC * const ret =
Parrot_hash_value_to_pmc(INTERP, attrs->parrot_hash, attrs->bucket->value);
RETURN(PMC* ret);
}

Expand All @@ -64,7 +65,7 @@ Get "key".
}

VTABLE STRING* get_string() {
Parrot_HashIteratorKey_attributes *attrs =
const Parrot_HashIteratorKey_attributes * const attrs =
PARROT_HASHITERATORKEY(SELF);

/* TT #1080 & TT #1081 Wallpapering problem with NULL attributes */
Expand Down
14 changes: 7 additions & 7 deletions src/pmc/lexpad.pmc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2007-2010, Parrot Foundation.
Copyright (C) 2007-2011, Parrot Foundation.

=head1 NAME

Expand Down Expand Up @@ -97,9 +97,9 @@ Return the LexInfo PMC, if any or a Null PMC.

VTABLE INTVAL exists_keyed_str(STRING *name) {
PMC *info;
Hash *hash;
const Hash *hash;
GET_ATTR_lexinfo(INTERP, SELF, info);
hash = (Hash *)VTABLE_get_pointer(INTERP, info);
hash = (const Hash *)VTABLE_get_pointer(INTERP, info);

return hash->entries
? (Parrot_hash_get_bucket(INTERP, hash, name) != 0)
Expand All @@ -113,12 +113,12 @@ Return the LexInfo PMC, if any or a Null PMC.

VTABLE PMC *get_pmc_keyed_str(STRING *name) {
PMC *info;
Hash *hash;
const Hash *hash;
PMC *ctx;
HashBucket *b;

GET_ATTR_lexinfo(INTERP, SELF, info);
hash = (Hash *)VTABLE_get_pointer(INTERP, info);
hash = (const Hash *)VTABLE_get_pointer(INTERP, info);

if (!hash->entries)
return PMCNULL;
Expand All @@ -139,12 +139,12 @@ Return the LexInfo PMC, if any or a Null PMC.

VTABLE void set_pmc_keyed_str(STRING *name, PMC *value) {
PMC * info;
Hash * hash;
const Hash * hash;
PMC * ctx;
HashBucket * b;

GET_ATTR_lexinfo(INTERP, SELF, info);
hash = (Hash *)VTABLE_get_pointer(INTERP, info);
hash = (const Hash *)VTABLE_get_pointer(INTERP, info);
b = Parrot_hash_get_bucket(INTERP, hash, name);

if (!b)
Expand Down

0 comments on commit 8325884

Please sign in to comment.