New function ecl_array_rank()

This commit is contained in:
Juan Jose Garcia Ripoll 2012-06-12 22:41:21 +02:00
parent dac086195d
commit 7c3f72776d
2 changed files with 20 additions and 4 deletions

View file

@ -847,10 +847,25 @@ ecl_array_elttype(cl_object x)
cl_object
cl_array_rank(cl_object a)
{
if (ecl_unlikely(!ECL_ARRAYP(a)))
FEwrong_type_only_arg(@[array-rank], a, @[array]);
@(return ((type_of(a) == t_array) ? ecl_make_fixnum(a->array.rank)
: ecl_make_fixnum(1)))
@(return ecl_make_fixnum(ecl_array_rank(a)))
}
cl_index
ecl_array_rank(cl_object a)
{
switch (type_of(a)) {
case t_array:
return a->array.rank;
#ifdef ECL_UNICODE
case t_string:
#endif
case t_base_string:
case t_vector:
case t_bitvector:
return 1;
default:
FEwrong_type_only_arg(@[array-dimension], a, @[array]);
}
}
cl_object

View file

@ -357,6 +357,7 @@ extern ECL_API cl_object si_fill_array_with_elt(cl_object array, cl_object elt,
extern ECL_API void FEwrong_dimensions(cl_object a, cl_index rank) ecl_attr_noreturn;
extern ECL_API cl_index ecl_to_index(cl_object n);
extern ECL_API cl_index ecl_array_dimension(cl_object x, cl_index n);
extern ECL_API cl_index ecl_array_rank(cl_object x);
extern ECL_API cl_object ecl_aref_unsafe(cl_object x, cl_index index);
extern ECL_API cl_object ecl_aset_unsafe(cl_object x, cl_index index, cl_object value);
extern ECL_API cl_object ecl_aref(cl_object x, cl_index index);