Permalink
Browse files

Fill out positional REPR funcs more reasonably.

  • Loading branch information...
jnthn committed Feb 9, 2013
1 parent 90e12d2 commit 7676c2315d27a7c499af0cc4d00129455871e6f1
Showing with 39 additions and 7 deletions.
  1. +8 −4 src/6model/repr_registry.c
  2. +18 −2 src/6model/reprs/CArray.c
  3. +13 −1 src/6model/sixmodelobject.h
View
@@ -96,16 +96,16 @@ static void default_bind_pos_boxed(PARROT_INTERP, STable *st, void *data, INTVAL
static INTVAL default_elems(PARROT_INTERP, STable *st, void *data) {
die_no_idx(interp, st->REPR->name);
}
-static void default_preallocate(PARROT_INTERP, STable *st, void *data, INTVAL count) {
+static void default_push_boxed(PARROT_INTERP, STable *st, void *data, PMC *obj) {
die_no_idx(interp, st->REPR->name);
}
-static void default_trim_to(PARROT_INTERP, STable *st, void *data, INTVAL count) {
+static PMC * default_pop_boxed(PARROT_INTERP, STable *st, void *data) {
die_no_idx(interp, st->REPR->name);
}
-static void default_make_hole(PARROT_INTERP, STable *st, void *data, INTVAL at_index, INTVAL count) {
+static void default_unshift_boxed(PARROT_INTERP, STable *st, void *data, PMC *obj) {
die_no_idx(interp, st->REPR->name);
}
-static void default_delete_elems(PARROT_INTERP, STable *st, void *data, INTVAL at_index, INTVAL count) {
+static PMC * default_shift_boxed(PARROT_INTERP, STable *st, void *data) {
die_no_idx(interp, st->REPR->name);
}
static STable * default_get_elem_stable(PARROT_INTERP, STable *st) {
@@ -143,6 +143,10 @@ static void add_default_pos_funcs(PARROT_INTERP, REPROps *repr) {
repr->pos_funcs->bind_pos_native = default_bind_pos_native;
repr->pos_funcs->bind_pos_boxed = default_bind_pos_boxed;
repr->pos_funcs->elems = default_elems;
+ repr->pos_funcs->push_boxed = default_push_boxed;
+ repr->pos_funcs->pop_boxed = default_pop_boxed;
+ repr->pos_funcs->unshift_boxed = default_unshift_boxed;
+ repr->pos_funcs->shift_boxed = default_shift_boxed;
repr->pos_funcs->get_elem_stable = default_get_elem_stable;
}
View
@@ -201,9 +201,9 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
}
PARROT_DOES_NOT_RETURN
-static void die_idx_nyi(PARROT_INTERP) {
+static void die_pos_nyi(PARROT_INTERP) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
- "CArray representation does not fully indexed storage yet");
+ "CArray representation does not fully positional storage yet");
}
static void expand(PARROT_INTERP, CArrayREPRData *repr_data, CArrayBody *body, INTVAL min_size) {
INTVAL is_complex = 0;
@@ -453,6 +453,18 @@ static STable * get_elem_stable(PARROT_INTERP, STable *st) {
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
return STABLE(repr_data->elem_type);
}
+static void push_boxed(PARROT_INTERP, STable *st, void *data, PMC *obj) {
+ die_pos_nyi(interp);
+}
+static PMC * pop_boxed(PARROT_INTERP, STable *st, void *data) {
+ die_pos_nyi(interp);
+}
+static void unshift_boxed(PARROT_INTERP, STable *st, void *data, PMC *obj) {
+ die_pos_nyi(interp);
+}
+static PMC * shift_boxed(PARROT_INTERP, STable *st, void *data) {
+ die_pos_nyi(interp);
+}
/* Serializes the REPR data. */
static void serialize_repr_data(PARROT_INTERP, STable *st, SerializationWriter *writer) {
@@ -496,6 +508,10 @@ REPROps * CArray_initialize(PARROT_INTERP,
this_repr->pos_funcs->bind_pos_native = bind_pos_native;
this_repr->pos_funcs->bind_pos_boxed = bind_pos_boxed;
this_repr->pos_funcs->elems = elems;
+ this_repr->pos_funcs->push_boxed = push_boxed;
+ this_repr->pos_funcs->pop_boxed = pop_boxed;
+ this_repr->pos_funcs->unshift_boxed = unshift_boxed;
+ this_repr->pos_funcs->shift_boxed = shift_boxed;
this_repr->pos_funcs->get_elem_stable = get_elem_stable;
this_repr->serialize_repr_data = serialize_repr_data;
this_repr->deserialize_repr_data = deserialize_repr_data;
@@ -258,7 +258,19 @@ typedef struct SixModel_REPROps_Positional {
/* Gets the number of elements. */
INTVAL (*elems) (PARROT_INTERP, STable *st, void *data);
-
+
+ /* Pushes an object. */
+ void (*push_boxed) (PARROT_INTERP, STable *st, void *data, PMC *obj);
+
+ /* Pops an object. */
+ PMC * (*pop_boxed) (PARROT_INTERP, STable *st, void *data);
+
+ /* Unshifts an object. */
+ void (*unshift_boxed) (PARROT_INTERP, STable *st, void *data, PMC *obj);
+
+ /* Shifts an object. */
+ PMC * (*shift_boxed) (PARROT_INTERP, STable *st, void *data);
+
/* Gets the STable representing the declared element type. */
STable * (*get_elem_stable) (PARROT_INTERP, STable *st);
} REPROps_Positional;

0 comments on commit 7676c23

Please sign in to comment.