New function EXT:ARRAY-RAW-DATA returns an array of octets that overlaps with the data of a given array.

This commit is contained in:
Juan Jose Garcia Ripoll 2009-11-08 15:04:37 +01:00
parent c567ef5d1c
commit 9c2297058c
5 changed files with 43 additions and 0 deletions

View file

@ -1,6 +1,12 @@
ECL 9.10.3:
===========
* Visible changes:
- New function EXT:ARRAY-RAW-DATA returns a non-adjustable vector of type
(UNSIGNED-BYTE 8) with the content of an array. The returned array overlaps
with the original, so any change on one will affect the other.
* Bugs fixed:
- In single-threaded builds, ECL did not properly restore the signal mask

View file

@ -759,6 +759,38 @@ because the total size of the to-array is too small.", 0);
from->array.self.t = address_inc(base, j, fromtype);
}
cl_object
si_array_raw_data(cl_object x)
{
cl_elttype et = ecl_array_elttype(x);
cl_index total_size = x->vector.dim * ecl_aet_size[et];
cl_object output, to_array;
uint8_t *data;
if (et == aet_object) {
FEerror("EXT:ARRAY-RAW-DATA can not get data "
"from an array with element type T.", 0);
}
data = x->vector.self.b8;
to_array = x->array.displaced;
if (to_array == Cnil || ((to_array = ECL_CONS_CAR(to_array)) == Cnil)) {
output = ecl_alloc_object(t_vector);
output->vector.elttype = aet_b8;
output->vector.self.b8 = data;
output->vector.dim = output->vector.fillp = total_size;
output->vector.flags = 0; /* no fill pointer, not adjustable */
output->vector.displaced = Cnil;
} else {
cl_index displ = data - to_array->vector.self.b8;
output = si_make_vector(@'ext::byte8',
MAKE_FIXNUM(total_size),
Cnil,
Cnil,
si_array_raw_data(to_array),
MAKE_FIXNUM(displ));
}
@(return output)
}
cl_elttype
ecl_array_elttype(cl_object x)
{

View file

@ -1837,5 +1837,7 @@ cl_symbols[] = {
{SYS_ "*QUIT-TAG*", SI_SPECIAL, NULL, -1, OBJNULL},
{EXT_ "ARRAY-RAW-DATA", EXT_ORDINARY, si_array_raw_data, 1, OBJNULL},
/* Tag for end of list */
{NULL, CL_ORDINARY, NULL, -1, OBJNULL}};

View file

@ -1837,5 +1837,7 @@ cl_symbols[] = {
{SYS_ "*QUIT-TAG*",NULL},
{EXT_ "ARRAY-RAW-DATA","si_array_raw_data"},
/* Tag for end of list */
{NULL,NULL}};

View file

@ -318,6 +318,7 @@ extern ECL_API cl_object cl_array_dimension(cl_object a, cl_object index);
extern ECL_API cl_object cl_array_total_size(cl_object a);
extern ECL_API cl_object cl_adjustable_array_p(cl_object a);
extern ECL_API cl_object cl_array_displacement(cl_object a);
extern ECL_API cl_object si_array_raw_data(cl_object array);
extern ECL_API cl_object cl_svref(cl_object x, cl_object index);
extern ECL_API cl_object si_svset(cl_object x, cl_object index, cl_object v);
extern ECL_API cl_object cl_array_has_fill_pointer_p(cl_object a);