Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add get_boxed_ref functions; P6opaque one needs filling out more fully.
  • Loading branch information
jnthn committed Nov 8, 2011
1 parent 6d52f98 commit 965804c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/6model/reprs/HashAttrStore.c
Expand Up @@ -120,6 +120,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
"HashAttrStore cannot unbox to a native string");
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"HashAttrStore cannot box other types");
}

/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, STable *st, void *data) {
HashAttrStoreBody *body = (HashAttrStoreBody *)data;
Expand Down Expand Up @@ -167,6 +175,7 @@ REPROps * HashAttrStore_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = gc_mark;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/KnowHOWREPR.c
Expand Up @@ -128,6 +128,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
"KnowHOWREPR cannot unbox to a native string");
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"HashAttrStore cannot box other types");
}

/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, STable *st, void *data) {
KnowHOWREPRBody *body = (KnowHOWREPRBody *)data;
Expand Down Expand Up @@ -176,6 +184,7 @@ REPROps * KnowHOWREPR_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = gc_mark;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/P6bigint.c
Expand Up @@ -141,6 +141,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
"P6bigint cannot unbox to a native string");
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"P6bigint cannot box other types");
}

/* This Parrot-specific addition to the API is used to free an object. */
static void gc_free(PARROT_INTERP, PMC *obj) {
mp_clear(&((P6bigintInstance *)PMC_data(obj))->body.i);
Expand Down Expand Up @@ -194,6 +202,7 @@ REPROps * P6bigint_initialize(PARROT_INTERP,
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = NULL;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = gc_cleanup;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/P6int.c
Expand Up @@ -118,6 +118,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
"P6int cannot unbox to a native string");
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"P6int cannot box other types");
}

/* This Parrot-specific addition to the API is used to free an object. */
static void gc_free(PARROT_INTERP, PMC *obj) {
mem_sys_free(PMC_data(obj));
Expand Down Expand Up @@ -158,6 +166,7 @@ REPROps * P6int_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = NULL;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/P6num.c
Expand Up @@ -119,6 +119,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
"P6num cannot unbox to a native string");
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"P6num cannot box other types");
}

/* This Parrot-specific addition to the API is used to free an object. */
static void gc_free(PARROT_INTERP, PMC *obj) {
mem_sys_free(PMC_data(obj));
Expand Down Expand Up @@ -159,6 +167,7 @@ REPROps * P6num_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = NULL;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/P6opaque.c
Expand Up @@ -653,6 +653,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
}
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"get_boxed_ref NYI in P6opaque");
}

/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, STable *st, void *data) {
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)st->REPR_data;
Expand Down Expand Up @@ -841,6 +849,7 @@ REPROps * P6opaque_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = gc_mark;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/P6str.c
Expand Up @@ -119,6 +119,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
return ((P6strBody *)data)->value;
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"P6str cannot box other types");
}

/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, STable *st, void *data) {
P6strBody *body = (P6strBody *)data;
Expand Down Expand Up @@ -166,6 +174,7 @@ REPROps * P6str_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = gc_mark;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/6model/reprs/Uninstantiable.c
Expand Up @@ -127,6 +127,14 @@ static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
"Uninstantiable object cannot unbox to a native string");
}

/* Some objects serve primarily as boxes of others, inlining them. This gets
* gets the reference to such things, using the representation ID to distinguish
* them. */
static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Uninstantiable object cannot box other types");
}

/* This Parrot-specific addition to the API is used to free an object. */
static void gc_free(PARROT_INTERP, PMC *obj) {
mem_sys_free(PMC_data(obj));
Expand Down Expand Up @@ -166,6 +174,7 @@ REPROps * Uninstantiable_initialize(PARROT_INTERP) {
this_repr->get_num = get_num;
this_repr->set_str = set_str;
this_repr->get_str = get_str;
this_repr->get_boxed_ref = get_boxed_ref;
this_repr->gc_mark = NULL;
this_repr->gc_free = gc_free;
this_repr->gc_cleanup = NULL;
Expand Down

0 comments on commit 965804c

Please sign in to comment.