Skip to content

Commit de47195

Browse files
committed
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-0dff7051ff02
1 parent 9198733 commit de47195

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: byterun/array.c

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121
#include "misc.h"
2222
#include "mlvalues.h"
2323

24+
CAMLexport mlsize_t caml_array_length(value array){
25+
tag_t tag = Tag_val(array);
26+
if (tag == Double_array_tag)
27+
return Wosize_val(array) / Double_wosize;
28+
else return Wosize_val(array);
29+
}
30+
31+
CAMLexport int caml_is_double_array(value array){
32+
return (Tag_val(array) == Double_array_tag);
33+
}
34+
2435
CAMLprim value caml_array_get_addr(value array, value index)
2536
{
2637
intnat idx = Long_val(index);

Diff for: byterun/mlvalues.h

+3
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ CAMLextern void caml_Store_double_val (value,double);
245245
double caml__temp_d = (d); \
246246
Store_double_val((value)((double *) (v) + caml__temp_i), caml__temp_d); \
247247
}while(0)
248+
CAMLextern mlsize_t caml_array_length (value); /* size in items */
249+
CAMLextern int caml_is_double_array (value); /* 0 is false, 1 is true */
250+
248251

249252
/* Custom blocks. They contain a pointer to a "method suite"
250253
of functions (for finalization, comparison, hashing, etc)

0 commit comments

Comments
 (0)