Browse thread
[Caml-list] Some suggested improvements to the Graphics and Bigarray modules
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christopher Quinn <cq@h...> |
| Subject: | [Caml-list] Re: Some suggested improvements to the Graphics and Bigarray modules |
> As a palliative a function for
> inter-converting portions of Bigarrays and strings would be welcome,
> as access to strings is much faster.
>
If you don't mind giving up a bit of safety the following may help.
Chris Q.
module UnsafeStringOps = struct
(* Warning: No bounds checking!!!! Coredump grade hack *)
let ba2str : ('a,'b,'c) Bigarray.Array1.t -> string =
fun arr -> Obj.obj (Obj.field (Obj.repr arr) 1)
(* Or more properly:
external ba2str: ('a,'b,'c) Bigarray.Array1.t -> string ="ba2str"
where from C you put:
#include <bigarray.h>
value ba2str(value arr){ return Data_bigarray_val(arr); }
*)
let blit = String.unsafe_blit
let fill = String.unsafe_fill
let set = String.unsafe_set
let get = String.unsafe_get
end
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr