Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 10 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
37 src/6model/reprs/CArray.c
@@ -12,8 +12,8 @@
static REPROps *this_repr;
/* Some functions we have to get references to. */
-static PMC * (* wrap_object_func) (PARROT_INTERP, void *obj);
-static PMC * (* create_stable_func) (PARROT_INTERP, REPROps *REPR, PMC *HOW);
+static wrap_object_t wrap_object_func;
+static create_stable_t create_stable_func;
/* Gets size and type information to put it into the REPR data. */
static void fill_repr_data(PARROT_INTERP, STable *st) {
@@ -130,7 +130,7 @@ static void initialize(PARROT_INTERP, STable *st, void *data) {
if (repr_data->elem_kind == CARRAY_ELEM_KIND_NUMERIC)
body->child_objs = NULL;
else
- body->child_objs = mem_sys_allocate_zeroed(4*sizeof(PMC *));
+ body->child_objs = (PMC **) mem_sys_allocate_zeroed(4*sizeof(PMC *));
body->allocated = 4;
body->elems = 0;
}
@@ -190,6 +190,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
spec.inlineable = STORAGE_SPEC_REFERENCE;
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
spec.can_box = 0;
+ spec.bits = sizeof(void *) * 8;
return spec;
}
@@ -211,7 +212,7 @@ static void expand(PARROT_INTERP, CArrayREPRData *repr_data, CArrayBody *body, I
|| repr_data->elem_kind == CARRAY_ELEM_KIND_CSTRUCT
|| repr_data->elem_kind == CARRAY_ELEM_KIND_STRING);
if (is_complex)
- body->child_objs = mem_sys_realloc_zeroed(body->child_objs, next_size * sizeof(PMC *), body->allocated * sizeof(PMC *));
+ body->child_objs = (PMC **) mem_sys_realloc_zeroed(body->child_objs, next_size * sizeof(PMC *), body->allocated * sizeof(PMC *));
body->allocated = next_size;
}
static void * at_pos_ref(PARROT_INTERP, STable *st, void *data, INTVAL index) {
@@ -230,6 +231,7 @@ static void * at_pos_ref(PARROT_INTERP, STable *st, void *data, INTVAL index) {
static PMC * make_object(PARROT_INTERP, STable *st, void *data) {
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
CArrayBody *body = (CArrayBody *)data;
+ PMC *retval;
switch (repr_data->elem_kind) {
case CARRAY_ELEM_KIND_STRING:
@@ -240,15 +242,24 @@ static PMC * make_object(PARROT_INTERP, STable *st, void *data) {
REPR(obj)->initialize(interp, STABLE(obj), OBJECT_BODY(obj));
REPR(obj)->box_funcs->set_str(interp, STABLE(obj), OBJECT_BODY(obj), str);
PARROT_GC_WRITE_BARRIER(interp, obj);
- return obj;
+ retval = obj;
+ break;
}
case CARRAY_ELEM_KIND_CARRAY:
- return make_carray_result(interp, repr_data->elem_type, data);
+ retval = make_carray_result(interp, repr_data->elem_type, data);
+ break;
case CARRAY_ELEM_KIND_CPOINTER:
- return make_cpointer_result(interp, repr_data->elem_type, data);
+ retval = make_cpointer_result(interp, repr_data->elem_type, data);
+ break;
case CARRAY_ELEM_KIND_CSTRUCT:
- return make_cstruct_result(interp, repr_data->elem_type, data);
+ retval = make_cstruct_result(interp, repr_data->elem_type, data);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Fatal error: unknown CArray elem_kind (%d) in make_object", repr_data->elem_kind);
}
+
+ return retval;
}
static PMC * at_pos_boxed(PARROT_INTERP, STable *st, void *data, INTVAL index) {
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
@@ -367,6 +378,9 @@ static void bind_pos_boxed(PARROT_INTERP, STable *st, void *data, INTVAL index,
case CARRAY_ELEM_KIND_CPOINTER:
cptr = ((CPointerBody *) OBJECT_BODY(obj))->ptr;
break;
+ default:
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Fatal error: unknown CArray elem_kind (%d) in bind_pos_boxed", repr_data->elem_kind);
}
}
else {
@@ -418,16 +432,17 @@ static void serialize_repr_data(PARROT_INTERP, STable *st, SerializationWriter *
/* Deserializes the REPR data. */
static void deserialize_repr_data(PARROT_INTERP, STable *st, SerializationReader *reader) {
- CArrayREPRData *repr_data = st->REPR_data = (CArrayREPRData *) mem_sys_allocate_zeroed(sizeof(CArrayREPRData));
+ CArrayREPRData *repr_data = (CArrayREPRData *) mem_sys_allocate_zeroed(sizeof(CArrayREPRData));
+ st->REPR_data = (CArrayREPRData *) repr_data;
repr_data->elem_size = reader->read_int(interp, reader);
repr_data->elem_type = reader->read_ref(interp, reader);
repr_data->elem_kind = reader->read_int(interp, reader);
}
/* Initializes the CArray representation. */
REPROps * CArray_initialize(PARROT_INTERP,
- PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
- PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW)) {
+ wrap_object_t wrap_object_func_ptr,
+ create_stable_t create_stable_func_ptr) {
/* Stash away functions passed wrapping functions. */
wrap_object_func = wrap_object_func_ptr;
create_stable_func = create_stable_func_ptr;
View
9 src/6model/reprs/CPointer.c
@@ -8,8 +8,8 @@
static REPROps *this_repr;
/* Some functions we have to get references to. */
-static PMC * (* wrap_object_func) (PARROT_INTERP, void *obj);
-static PMC * (* create_stable_func) (PARROT_INTERP, REPROps *REPR, PMC *HOW);
+static wrap_object_t wrap_object_func;
+static create_stable_t create_stable_func;
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
@@ -63,13 +63,14 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
spec.inlineable = STORAGE_SPEC_REFERENCE;
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
spec.can_box = 0;
+ spec.bits = sizeof(void *) * 8;
return spec;
}
/* Initializes the CPointer representation. */
REPROps * CPointer_initialize(PARROT_INTERP,
- PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
- PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW)) {
+ wrap_object_t wrap_object_func_ptr,
+ create_stable_t create_stable_func_ptr) {
/* Stash away functions passed wrapping functions. */
wrap_object_func = wrap_object_func_ptr;
create_stable_func = create_stable_func_ptr;
View
11 src/6model/reprs/CStr.c
@@ -8,14 +8,14 @@
static REPROps *this_repr;
/* Some functions we have to get references to. */
-static PMC * (* wrap_object_func) (PARROT_INTERP, void *obj);
-static PMC * (* create_stable_func) (PARROT_INTERP, REPROps *REPR, PMC *HOW);
+static wrap_object_t wrap_object_func;
+static create_stable_t create_stable_func;
static void set_str(PARROT_INTERP, STable *st, void *data, STRING *value) {
CStrBody *body = (CStrBody *) data;
PMC *old_ctx, *cappy, *meth, *enc_pmc;
STRING *enc;
- void *encoding;
+ STR_VTABLE *encoding;
if(body->cstr)
mem_sys_free(body->cstr);
@@ -99,12 +99,13 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
spec.inlineable = STORAGE_SPEC_REFERENCE;
spec.boxed_primitive = STORAGE_SPEC_BP_STR;
spec.can_box = 0;
+ spec.bits = sizeof(void *) * 8;;
return spec;
}
REPROps *CStr_initialize(PARROT_INTERP,
- PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
- PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW)) {
+ wrap_object_t wrap_object_func_ptr,
+ create_stable_t create_stable_func_ptr) {
/* Stash away functions passed wrapping functions. */
wrap_object_func = wrap_object_func_ptr;
create_stable_func = create_stable_func_ptr;
View
11 src/6model/reprs/CStruct.c
@@ -11,8 +11,8 @@
static REPROps *this_repr;
/* Some functions we have to get references to. */
-static PMC * (* wrap_object_func) (PARROT_INTERP, void *obj);
-static PMC * (* create_stable_func) (PARROT_INTERP, REPROps *REPR, PMC *HOW);
+static wrap_object_t wrap_object_func;
+static create_stable_t create_stable_func;
/* How do we go from type-object to a hash value? For now, we make an integer
* that is the address of the STable struct, which not being subject to GC will
@@ -366,7 +366,7 @@ static PMC * allocate(PARROT_INTERP, STable *st) {
/* Allocate child obj array. */
if(repr_data->num_child_objs > 0) {
size_t bytes = repr_data->num_child_objs*sizeof(PMC *);
- obj->body.child_objs = mem_sys_allocate(bytes);
+ obj->body.child_objs = (PMC **) mem_sys_allocate(bytes);
memset(obj->body.child_objs, 0, bytes);
}
@@ -627,6 +627,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
spec.inlineable = STORAGE_SPEC_REFERENCE;
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
spec.can_box = 0;
+ spec.bits = sizeof(void *) * 8;
return spec;
}
@@ -644,8 +645,8 @@ static void deserialize_repr_data(PARROT_INTERP, STable *st, SerializationReader
/* Initializes the CStruct representation. */
REPROps * CStruct_initialize(PARROT_INTERP,
- PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
- PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW)) {
+ wrap_object_t wrap_object_func_ptr,
+ create_stable_t create_stable_func_ptr) {
/* Stash away functions passed wrapping functions. */
wrap_object_func = wrap_object_func_ptr;
create_stable_func = create_stable_func_ptr;
View
13 src/6model/reprs/NativeCall.c
@@ -8,8 +8,8 @@
static REPROps *this_repr;
/* Some functions we have to get references to. */
-static PMC * (* wrap_object_func) (PARROT_INTERP, void *obj);
-static PMC * (* create_stable_func) (PARROT_INTERP, REPROps *REPR, PMC *HOW);
+static wrap_object_t wrap_object_func;
+static create_stable_t create_stable_func;
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
@@ -51,7 +51,7 @@ static void copy_to(PARROT_INTERP, STable *st, void *src, void *dest) {
/* Need a fresh handle for resource management purposes. */
if (src_body->lib_name) {
- dest_body->lib_name = mem_sys_allocate(strlen(src_body->lib_name) + 1);
+ dest_body->lib_name = (char *) mem_sys_allocate(strlen(src_body->lib_name) + 1);
strcpy(dest_body->lib_name, src_body->lib_name);
dest_body->lib_handle = dlLoadLibrary(dest_body->lib_name);
}
@@ -61,7 +61,7 @@ static void copy_to(PARROT_INTERP, STable *st, void *src, void *dest) {
dest_body->convention = src_body->convention;
dest_body->num_args = src_body->num_args;
if (src_body->arg_types) {
- dest_body->arg_types = mem_sys_allocate(sizeof(INTVAL) * (src_body->num_args ? src_body->num_args : 1));
+ dest_body->arg_types = (INTVAL *) mem_sys_allocate(sizeof(INTVAL) * (src_body->num_args ? src_body->num_args : 1));
memcpy(dest_body->arg_types, src_body->arg_types, src_body->num_args * sizeof(INTVAL));
}
dest_body->ret_type = src_body->ret_type;
@@ -92,6 +92,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
spec.inlineable = STORAGE_SPEC_INLINED;
spec.bits = sizeof(NativeCallBody) * 8;
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
+ spec.can_box = 0;
return spec;
}
@@ -105,8 +106,8 @@ static void deserialize(PARROT_INTERP, STable *st, void *data, SerializationRead
/* Initializes the NativeCall representation. */
REPROps * NativeCall_initialize(PARROT_INTERP,
- PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
- PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW)) {
+ wrap_object_t wrap_object_func_ptr,
+ create_stable_t create_stable_func_ptr) {
/* Stash away functions passed wrapping functions. */
wrap_object_func = wrap_object_func_ptr;
create_stable_func = create_stable_func_ptr;
View
10 src/6model/reprs/P6bigint.c
@@ -11,8 +11,8 @@
static REPROps *this_repr;
/* Some functions we have to get references to. */
-static PMC * (* wrap_object_func) (PARROT_INTERP, void *obj);
-static PMC * (* create_stable_func) (PARROT_INTERP, REPROps *REPR, PMC *HOW);
+static wrap_object_t wrap_object_func;
+static create_stable_t create_stable_func;
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
@@ -150,7 +150,7 @@ static void serialize(PARROT_INTERP, STable *st, void *data, SerializationWriter
int len;
char *buf;
mp_radix_size(i, 10, &len);
- buf = mem_sys_allocate(len);
+ buf = (char *) mem_sys_allocate(len);
mp_toradix_n(i, buf, 10, len);
/* len - 1 because buf is \0-terminated */
writer->write_str(interp, writer, Parrot_str_new(interp, buf, len - 1));
@@ -167,8 +167,8 @@ static void deserialize(PARROT_INTERP, STable *st, void *data, SerializationRead
/* Initializes the P6bigint representation. */
REPROps * P6bigint_initialize(PARROT_INTERP,
- PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
- PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW)) {
+ wrap_object_t wrap_object_func_ptr,
+ create_stable_t create_stable_func_ptr) {
/* Stash away functions passed wrapping functions. */
wrap_object_func = wrap_object_func_ptr;
create_stable_func = create_stable_func_ptr;
View
4 src/6model/sixmodelobject.h
@@ -378,7 +378,9 @@ PMC * create_stable(PARROT_INTERP, REPROps *REPR, PMC *HOW);
PMC * decontainerize(PARROT_INTERP, PMC *var);
/* Dynamic representation registration. */
-typedef INTVAL (* rf) (PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INTERP, void *, void *));
+typedef PMC * (*wrap_object_t)(PARROT_INTERP, void *obj);
+typedef PMC * (*create_stable_t)(PARROT_INTERP, REPROps *REPR, PMC *HOW);
+typedef INTVAL (* rf) (PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INTERP, wrap_object_t, create_stable_t));
#define REGISTER_DYNAMIC_REPR(interp, name, reg_func) \
((rf) \
VTABLE_get_pointer(interp, \
View
6 src/ops/nqp_bigint.ops
@@ -263,7 +263,7 @@ inline op nqp_bigint_lcm(out PMC, in PMC, in PMC, in PMC) :base_core {
}
inline op nqp_bigint_from_str(out PMC, in STR, in PMC) :base_core {
- char *buf = Parrot_str_cstring(interp, $2);
+ const char *buf = Parrot_str_cstring(interp, $2);
$1 = REPR($3)->allocate(interp, STABLE($3));
REPR($1)->initialize(interp, STABLE($1), OBJECT_BODY($1));
mp_read_radix(get_bigint(interp, $1), buf, 10);
@@ -274,7 +274,7 @@ inline op nqp_bigint_to_str(out STR, in PMC) :base_core {
int len;
char *buf;
mp_radix_size(i, 10, &len);
- buf = mem_sys_allocate(len);
+ buf = (char *) mem_sys_allocate(len);
mp_toradix_n(i, buf, 10, len);
/* len - 1 because buf is \0-terminated */
$1 = Parrot_str_new(interp, buf, len - 1);
@@ -286,7 +286,7 @@ inline op nqp_bigint_to_str_base(out STR, in PMC, in INT) :base_core {
int len;
char *buf;
mp_radix_size(i, $3, &len);
- buf = mem_sys_allocate(len);
+ buf = (char *) mem_sys_allocate(len);
mp_toradix_n(i, buf, $3, len);
/* len - 1 because buf is \0-terminated */
$1 = Parrot_str_new(interp, buf, len - 1);
View
33 src/ops/nqp_dyncall.ops
@@ -70,8 +70,8 @@ BEGIN_OPS_PREAMBLE
#define DYNCALL_ARG_FREE_STR_MASK 1
/* Predeclare some mutually recursive functions. */
-static void dyncall_wb_ca(PMC *);
-static void dyncall_wb_cs(PMC *);
+static void dyncall_wb_ca(PARROT_INTERP, PMC *);
+static void dyncall_wb_cs(PARROT_INTERP, PMC *);
/* The ID of the NativeCall, CPointer and CStruct REPRs. */
static INTVAL nc_repr_id = 0;
@@ -303,7 +303,7 @@ PMC * decontainerize(PARROT_INTERP, PMC *var) {
return var;
}
-static void dyncall_wb_ca(PMC *obj) {
+static void dyncall_wb_ca(PARROT_INTERP, PMC *obj) {
CArrayBody *body = (CArrayBody *) OBJECT_BODY(obj);
CArrayREPRData *repr_data = (CArrayREPRData *) STABLE(obj)->REPR_data;
void **storage = (void **) body->storage;
@@ -333,8 +333,12 @@ static void dyncall_wb_ca(PMC *obj) {
case CARRAY_ELEM_KIND_CSTRUCT:
objptr = (CStructBody *) OBJECT_BODY(body->child_objs[i]);
break;
+ case CARRAY_ELEM_KIND_STRING:
+ objptr = NULL; /* TODO */
+ break;
default:
- objptr = NULL;
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Fatal error: bad elem_kind (%d) in dyncall_wb_ca", repr_data->elem_kind);
}
}
else {
@@ -345,15 +349,15 @@ static void dyncall_wb_ca(PMC *obj) {
body->child_objs[i] = NULL;
}
else if (repr_data->elem_kind == CARRAY_ELEM_KIND_CARRAY) {
- dyncall_wb_ca(body->child_objs[i]);
+ dyncall_wb_ca(interp, body->child_objs[i]);
}
else if (repr_data->elem_kind == CARRAY_ELEM_KIND_CSTRUCT) {
- dyncall_wb_cs(body->child_objs[i]);
+ dyncall_wb_cs(interp, body->child_objs[i]);
}
}
}
-static void dyncall_wb_cs(PMC *obj) {
+static void dyncall_wb_cs(PARROT_INTERP, PMC *obj) {
CStructBody *body = (CStructBody *) OBJECT_BODY(obj);
CStructREPRData *repr_data = (CStructREPRData *) STABLE(obj)->REPR_data;
char *storage = (char *) body->cstruct;
@@ -380,6 +384,12 @@ static void dyncall_wb_cs(PMC *obj) {
case CSTRUCT_ATTR_CSTRUCT:
objptr = (CStructBody *) OBJECT_BODY(body->child_objs[slot]);
break;
+ case CSTRUCT_ATTR_STRING:
+ objptr = NULL;
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Fatal error: bad kind (%d) in dyncall_wb_cs", kind);
}
}
else {
@@ -390,10 +400,10 @@ static void dyncall_wb_cs(PMC *obj) {
body->child_objs[slot] = NULL;
}
else if (kind == CSTRUCT_ATTR_CARRAY) {
- dyncall_wb_ca(body->child_objs[slot]);
+ dyncall_wb_ca(interp, body->child_objs[slot]);
}
else if (kind == CSTRUCT_ATTR_CSTRUCT) {
- dyncall_wb_cs(body->child_objs[slot]);
+ dyncall_wb_cs(interp, body->child_objs[slot]);
}
}
}
@@ -674,11 +684,12 @@ inline op nqp_native_call(out PMC, invar PMC, invar PMC, invar PMC) :base_core {
switch (body->arg_types[i]) {
case DYNCALL_ARG_CARRAY:
- dyncall_wb_ca(value);
+ dyncall_wb_ca(interp, value);
break;
case DYNCALL_ARG_CSTRUCT:
- dyncall_wb_cs(value);
+ dyncall_wb_cs(interp, value);
break;
+ default: /* Noop to eliminate warning. */
}
}

No commit comments for this range

Something went wrong with that request. Please try again.