Permalink
Browse files

pmc: convert Fixed*Array and Resizable*Array internal_exceptions to r…

…eal_exceptions

git-svn-id: https://svn.parrot.org/parrot/trunk@11610 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
particle committed Feb 17, 2006
1 parent cb9c882 commit 72981862c1e10ea8dec6456e127c67785e6186f2
@@ -31,7 +31,7 @@ The C<FixedBooleanArray PMC> is extended by the C<ResizableBooleanArray PMC>.
static void
booleanarray_init(Interp *interpreter, PMC *self) {
- PMC_int_val2(self) = 0;
+ PMC_int_val2(self) = 0;
PMC_data(self) = NULL;
}
@@ -47,11 +47,11 @@ booleanarray_clone(Interp *interpreter, PMC *self, PMC *dest) {
static void
booleanarray_clear(Interp *interpreter, PMC *self) {
- PMC_int_val2(self) = 0;
+ PMC_int_val2(self) = 0;
}
pmclass FixedBooleanArray need_ext does array {
-
+
/*
=back
@@ -121,7 +121,7 @@ Creates and returns a copy of the array.
PMC* clone () {
PMC * dest = pmc_new(INTERP, SELF->vtable->base_type);
PMC_int_val(dest) = PMC_int_val(SELF);
-
+
booleanarray_clone(INTERP, SELF, dest);
PObj_active_destroy_SET(dest);
return dest;
@@ -182,9 +182,9 @@ Returns the integer value of the element at index C<key>.
Parrot_UInt1 *sd = PMC_data(SELF);
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedBooleanArray: index out of bounds!");
-
+
return ( sd[key/BITS_PER_CHAR] & ( 1 << ( key % BITS_PER_CHAR ) )) ? 1 : 0;
}
@@ -309,7 +309,8 @@ Resizes the array to C<size> elements.
void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
- internal_exception(OUT_OF_BOUNDS, "FixedBooleanArray: Can't resize!");
+ real_exception(INTERP, NULL, E_IndexError,
+ "FixedBooleanArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_int_val2(SELF) = (size / BITS_PER_CHAR + 1) * BITS_PER_CHAR;
@@ -330,7 +331,7 @@ Sets the integer value of the element at index C<key> to C<value>.
Parrot_UInt1 *sd = PMC_data(SELF);
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedBooleanArray: index out of bounds!");
if ( value ) {
@@ -385,7 +386,7 @@ C<value>.
INTVAL k = key_integer(INTERP, key);
DYNSELF.set_number_keyed_int(k, value);
}
-
+
/*
=item C<void set_string_keyed_int(INTVAL key, STRING *value)>
@@ -528,7 +529,6 @@ sets them all to false.
*/
-
METHOD void fill(INTVAL fill) {
Parrot_UInt1 *sd = PMC_data(SELF);
INTVAL j;
@@ -22,7 +22,7 @@ it uses Float PMCs to do all necessary conversions
#include "parrot/parrot.h"
pmclass FixedFloatArray need_ext does array {
-
+
/*
=back
@@ -89,12 +89,12 @@ Creates and returns a copy of the array.
PMC* clone () {
INTVAL size;
PMC * dest = pmc_new(INTERP, SELF->vtable->base_type);
-
+
if (!PMC_data(SELF))
return dest;
size = PMC_int_val(SELF);
PMC_int_val(dest) = size;
-
+
PMC_data(dest) = mem_sys_allocate(size * sizeof(FLOATVAL));
mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), size*sizeof(FLOATVAL));
PObj_active_destroy_SET(dest);
@@ -187,9 +187,9 @@ Returns the floating-point value of the element at index C<key>.
FLOATVAL get_number_keyed_int (INTVAL key) {
FLOATVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedFloatArray: index out of bounds!");
-
+
data = (FLOATVAL *)PMC_data(SELF);
return data[key];
}
@@ -288,7 +288,8 @@ Resizes the array to C<size> elements.
void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
- internal_exception(OUT_OF_BOUNDS, "FixedFloatArray: Can't resize!");
+ real_exception(INTERP, NULL, E_IndexError,
+ "FixedFloatArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate(size * sizeof(FLOATVAL));
PObj_active_destroy_SET(SELF);
@@ -338,7 +339,7 @@ C<value>.
void set_number_keyed_int (INTVAL key, FLOATVAL value) {
FLOATVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedFloatArray: index out of bounds!");
data = (FLOATVAL*)PMC_data(SELF);
@@ -361,7 +362,7 @@ C<value>.
k = key_integer(INTERP, key);
DYNSELF.set_number_keyed_int(k, value);
}
-
+
/*
=item C<void set_string_keyed_int(INTVAL key, STRING *value)>
@@ -374,7 +374,7 @@ Resizes the array to C<size> elements.
void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedIntegerArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate_zeroed(size * sizeof(INTVAL));
@@ -246,7 +246,7 @@ Returns the Parrot string value of the element at index C<key>.
STRING* get_string_keyed_int (INTVAL key) {
STRING **data;
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedStringArray: index out of bounds!");
data = (STRING **)PMC_data(SELF);
@@ -318,7 +318,8 @@ cause an exception to be thrown.
void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
- internal_exception(OUT_OF_BOUNDS, "FixedStringArray: Can't resize!");
+ real_exception(INTERP, NULL, E_IndexError,
+ "FixedStringArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate_zeroed(size * sizeof(STRING*));
PObj_custom_mark_destroy_SETALL(SELF);
@@ -411,7 +412,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
void set_string_keyed_int (INTVAL key, STRING* value) {
STRING **data;
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"FixedStringArray: index out of bounds!");
data = (STRING**)PMC_data(SELF);
@@ -23,7 +23,7 @@ which stores FLOATVALs. It uses Float PMCs to do all necessary conversions.
#include "parrot/parrot.h"
pmclass ResizableFloatArray extends FixedFloatArray need_ext does array {
-
+
/*
@@ -42,7 +42,7 @@ Returns the floating-point value of the element at index C<key>.
"ResizableFloatArray: index out of bounds!");
if (key >= PMC_int_val(SELF))
DYNSELF.set_integer_native(key+1);
-
+
data = (FLOATVAL *)PMC_data(SELF);
return data[key];
}
@@ -37,7 +37,7 @@ Returns the integer value of the element at index C<key>.
INTVAL get_integer_keyed_int (INTVAL key) {
INTVAL *data;
if (key < 0)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizableIntegerArray: index out of bounds!");
if(key >= PMC_int_val(SELF))
DYNSELF.set_integer_native(key+1);
@@ -59,7 +59,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed_int (INTVAL key, INTVAL value) {
INTVAL *data;
if (key < 0)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizableIntegerArray: index out of bounds!");
if(key >= PMC_int_val(SELF))
DYNSELF.set_integer_native(key+1);
@@ -80,7 +80,7 @@ Resizes the array to C<size> elements.
void set_integer_native (INTVAL size) {
if (size < 0)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizableStringArray: Can't resize!");
if(!PMC_data(SELF)) {
@@ -149,7 +149,7 @@ Removes and returns the last element in the array.
size = PMC_int_val(SELF);
if (size == 0) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizableIntegerArray: Can't pop from an empty array!");
}
value = DYNSELF.get_integer_keyed_int(size-1);
@@ -38,7 +38,7 @@ Resizes the array to C<size> elements.
void set_integer_native (INTVAL size) {
if (size < 0)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't resize!");
if (!PMC_data(SELF)) {
@@ -104,7 +104,7 @@ TODO: Check whether there is already an element that can be shifted
FLOATVAL value;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't shift from an empty array!");
}
@@ -126,7 +126,7 @@ TODO: Check whether there is already an element that can be shifted
INTVAL value;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't shift from an empty array!");
}
@@ -147,13 +147,13 @@ TODO: Check whether there is already an element that can be shifted
PMC** item;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't shift from an empty array!");
}
data= ((PMC**)PMC_data(SELF))[0];
PMC_int_val(SELF)= --size;
-
+
item= (PMC**)PMC_data(SELF);
mem_sys_memmove(item, item + 1, size * sizeof(PMC*));
item[size]= PMCNULL;
@@ -168,7 +168,7 @@ TODO: Check whether there is already an element that can be shifted
STRING* value;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't shift from an empty array!");
}
@@ -200,7 +200,7 @@ Returns the PMC value of the element at index C<key>.
if (key < 0)
key += PMC_int_val(SELF);
if (key < 0)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: index out of bounds!");
if (key >= PMC_int_val(SELF))
DYNSELF.set_integer_native(key+1);
@@ -233,7 +233,7 @@ If key is a slice, do a splice as set that item.
if (key < 0)
key += PMC_int_val(SELF);
if (key < 0)
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: index out of bounds!");
if (key >= PMC_int_val(SELF))
DYNSELF.set_integer_native(key+1);
@@ -342,7 +342,7 @@ Removes and returns the last element in the array.
FLOATVAL value;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't pop from an empty array!");
}
@@ -359,7 +359,7 @@ Removes and returns the last element in the array.
INTVAL value;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't pop from an empty array!");
}
@@ -375,10 +375,10 @@ Removes and returns the last element in the array.
PMC* data;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't pop from an empty array!");
}
-
+
data= ((PMC**)PMC_data(SELF))[--size];
PMC_int_val(SELF)= size;
return data;
@@ -390,7 +390,7 @@ Removes and returns the last element in the array.
STRING* value;
if (0 == size) {
- internal_exception(OUT_OF_BOUNDS,
+ real_exception(INTERP, NULL, E_IndexError,
"ResizablePMCArray: Can't pop from an empty array!");
}
Oops, something went wrong.

0 comments on commit 7298186

Please sign in to comment.