Added public functions "caml_array_length" and "caml_is_double_array"
to abstract (slightly) over the concrete representation of arrays. Contributed by F. Le Fessant. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11006 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
919873347f
commit
de47195103
|
@ -21,6 +21,17 @@
|
|||
#include "misc.h"
|
||||
#include "mlvalues.h"
|
||||
|
||||
CAMLexport mlsize_t caml_array_length(value array){
|
||||
tag_t tag = Tag_val(array);
|
||||
if (tag == Double_array_tag)
|
||||
return Wosize_val(array) / Double_wosize;
|
||||
else return Wosize_val(array);
|
||||
}
|
||||
|
||||
CAMLexport int caml_is_double_array(value array){
|
||||
return (Tag_val(array) == Double_array_tag);
|
||||
}
|
||||
|
||||
CAMLprim value caml_array_get_addr(value array, value index)
|
||||
{
|
||||
intnat idx = Long_val(index);
|
||||
|
|
|
@ -245,6 +245,9 @@ CAMLextern void caml_Store_double_val (value,double);
|
|||
double caml__temp_d = (d); \
|
||||
Store_double_val((value)((double *) (v) + caml__temp_i), caml__temp_d); \
|
||||
}while(0)
|
||||
CAMLextern mlsize_t caml_array_length (value); /* size in items */
|
||||
CAMLextern int caml_is_double_array (value); /* 0 is false, 1 is true */
|
||||
|
||||
|
||||
/* Custom blocks. They contain a pointer to a "method suite"
|
||||
of functions (for finalization, comparison, hashing, etc)
|
||||
|
|
Loading…
Reference in New Issue