File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1
1
#include <stdlib.h>
2
2
#include <stdio.h>
3
+ void caml_bytes_of_array () {
4
+ fprintf (stderr , "Unimplemented Javascript primitive caml_bytes_of_array!\n" );
5
+ exit (1 );
6
+ }
3
7
void caml_custom_identifier () {
4
8
fprintf (stderr , "Unimplemented Javascript primitive caml_custom_identifier!\n" );
5
9
exit (1 );
@@ -24,6 +28,10 @@ void caml_js_on_ie () {
24
28
fprintf (stderr , "Unimplemented Javascript primitive caml_js_on_ie!\n" );
25
29
exit (1 );
26
30
}
31
+ void caml_uint8_array_of_bytes () {
32
+ fprintf (stderr , "Unimplemented Javascript primitive caml_uint8_array_of_bytes!\n" );
33
+ exit (1 );
34
+ }
27
35
void caml_xmlhttprequest_create () {
28
36
fprintf (stderr , "Unimplemented Javascript primitive caml_xmlhttprequest_create!\n" );
29
37
exit (1 );
Original file line number Diff line number Diff line change @@ -277,3 +277,13 @@ module String = struct
277
277
let uint8 = new % js uint8Array_fromBuffer ab in
278
278
of_uint8Array uint8
279
279
end
280
+
281
+ module Bytes = struct
282
+ external of_uint8Array : uint8Array Js .t -> bytes = " caml_bytes_of_array"
283
+
284
+ external to_uint8Array : bytes -> uint8Array Js .t = " caml_uint8_array_of_bytes"
285
+
286
+ let of_arrayBuffer ab =
287
+ let uint8 = new % js uint8Array_fromBuffer ab in
288
+ of_uint8Array uint8
289
+ end
Original file line number Diff line number Diff line change @@ -273,3 +273,20 @@ module String : sig
273
273
274
274
val of_uint8Array : uint8Array Js .t -> string
275
275
end
276
+
277
+ module Bytes : sig
278
+ val of_uint8Array : uint8Array Js .t -> bytes
279
+ (* * This efficiently converts a typed array to [bytes] because it will usually
280
+ not copy its input.
281
+
282
+ Modifying its input may also modify its output, and vice versa when
283
+ modifying its output. This is not a guarantee, however, since certain
284
+ [bytes] operations may require the runtime to make a copy. One should not
285
+ use this on input that is sensitive to modification. *)
286
+
287
+ val to_uint8Array : bytes -> uint8Array Js .t
288
+ (* * See the words of caution for {!of_uint8Array}. *)
289
+
290
+ val of_arrayBuffer : arrayBuffer Js .t -> bytes
291
+ (* * See the words of caution for {!of_uint8Array}. *)
292
+ end
You can’t perform that action at this time.
0 commit comments