Skip to content

Commit

Permalink
Add const to ContainerConfigurer and code_pair_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuomingliang committed Sep 23, 2013
1 parent 4d6176e commit 319a40b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/6model/6model.h
Expand Up @@ -213,7 +213,7 @@ struct MVMSTable {
/* If this is a container, then this contains information needed in
* order to fetch the value in it. If not, it'll be null, which can
* be taken as a "not a container" indication. */
MVMContainerSpec *container_spec;
const MVMContainerSpec *container_spec;

/* Data that the container spec may need to function. */
/* Any data specific to this type that the REPR wants to keep. */
Expand Down
8 changes: 4 additions & 4 deletions src/6model/containers.c
Expand Up @@ -70,7 +70,7 @@ static void code_pair_deserialize(MVMThreadContext *tc, MVMSTable *st, MVMSerial
MVM_ASSIGN_REF(tc, st, data->store_code, reader->read_ref(tc, reader));
}

static MVMContainerSpec code_pair_spec = {
static const MVMContainerSpec code_pair_spec = {
"code_pair",
code_pair_fetch,
code_pair_store,
Expand Down Expand Up @@ -111,7 +111,7 @@ static void code_pair_configure_container_spec(MVMThreadContext *tc, MVMSTable *
});
}

static MVMContainerConfigurer ContainerConfigurer = {
static const MVMContainerConfigurer ContainerConfigurer = {
code_pair_set_container_spec,
code_pair_configure_container_spec
};
Expand All @@ -122,7 +122,7 @@ static MVMContainerConfigurer ContainerConfigurer = {

/* Adds a container configurer to the registry. */
void MVM_6model_add_container_config(MVMThreadContext *tc, MVMString *name,
MVMContainerConfigurer *configurer) {
const MVMContainerConfigurer *configurer) {
void *kdata;
MVMContainerRegistry *entry;
size_t klen;
Expand All @@ -146,7 +146,7 @@ void MVM_6model_add_container_config(MVMThreadContext *tc, MVMString *name,
}

/* Gets a container configurer from the registry. */
MVMContainerConfigurer * MVM_6model_get_container_config(MVMThreadContext *tc, MVMString *name) {
const MVMContainerConfigurer * MVM_6model_get_container_config(MVMThreadContext *tc, MVMString *name) {
void *kdata;
MVMContainerRegistry *entry;
size_t klen;
Expand Down
6 changes: 3 additions & 3 deletions src/6model/containers.h
Expand Up @@ -45,14 +45,14 @@ struct MVMContainerConfigurer {
* to function tables. */
struct MVMContainerRegistry {
MVMString *name;
MVMContainerConfigurer *configurer;
const MVMContainerConfigurer *configurer;

/* Inline handle to the hash in which this is stored. */
UT_hash_handle hash_handle;
};

void MVM_6model_add_container_config(MVMThreadContext *tc, MVMString *name, MVMContainerConfigurer *configurer);
MVMContainerConfigurer * MVM_6model_get_container_config(MVMThreadContext *tc, MVMString *name);
void MVM_6model_add_container_config(MVMThreadContext *tc, MVMString *name, const MVMContainerConfigurer *configurer);
const MVMContainerConfigurer * MVM_6model_get_container_config(MVMThreadContext *tc, MVMString *name);
void MVM_6model_containers_setup(MVMThreadContext *tc);

/* Macro for decontainerization. */
Expand Down
2 changes: 1 addition & 1 deletion src/6model/serialization.c
Expand Up @@ -1731,7 +1731,7 @@ static void deserialize_stable(MVMThreadContext *tc, MVMSerializationReader *rea

/* Container spec. */
if (read_int_func(tc, reader)) {
MVMContainerConfigurer *cc = MVM_6model_get_container_config(tc,
const MVMContainerConfigurer *cc = MVM_6model_get_container_config(tc,
read_str_func(tc, reader));
cc->set_container_spec(tc, st);
st->container_spec->deserialize(tc, st, reader);
Expand Down
6 changes: 3 additions & 3 deletions src/core/interp.c
Expand Up @@ -1144,7 +1144,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(assign): {
MVMObject *cont = GET_REG(cur_op, 0).o;
MVMObject *obj = GET_REG(cur_op, 2).o;
MVMContainerSpec *spec = STABLE(cont)->container_spec;
const MVMContainerSpec *spec = STABLE(cont)->container_spec;
MVMRegister value;
cur_op += 4;
if (spec) {
Expand All @@ -1158,7 +1158,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(assignunchecked): {
MVMObject *cont = GET_REG(cur_op, 0).o;
MVMObject *obj = GET_REG(cur_op, 2).o;
MVMContainerSpec *spec = STABLE(cont)->container_spec;
const MVMContainerSpec *spec = STABLE(cont)->container_spec;
MVMRegister value;
cur_op += 4;
if (spec) {
Expand Down Expand Up @@ -2827,7 +2827,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
}
OP(setcontspec): {
MVMSTable *st = STABLE(GET_REG(cur_op, 0).o);
MVMContainerConfigurer *cc = MVM_6model_get_container_config(tc, GET_REG(cur_op, 2).s);
const MVMContainerConfigurer *cc = MVM_6model_get_container_config(tc, GET_REG(cur_op, 2).s);
if (st->container_spec) {
MVM_exception_throw_adhoc(tc,
"Cannot change a type's container specification");
Expand Down

0 comments on commit 319a40b

Please sign in to comment.