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 11#include <stdlib.h>
22#include <stdio.h>
3+ void caml_bytes_of_array () {
4+ fprintf (stderr , "Unimplemented Javascript primitive caml_bytes_of_array!\n" );
5+ exit (1 );
6+ }
37void caml_custom_identifier () {
48 fprintf (stderr , "Unimplemented Javascript primitive caml_custom_identifier!\n" );
59 exit (1 );
@@ -24,6 +28,10 @@ void caml_js_on_ie () {
2428 fprintf (stderr , "Unimplemented Javascript primitive caml_js_on_ie!\n" );
2529 exit (1 );
2630}
31+ void caml_uint8_array_of_bytes () {
32+ fprintf (stderr , "Unimplemented Javascript primitive caml_uint8_array_of_bytes!\n" );
33+ exit (1 );
34+ }
2735void caml_xmlhttprequest_create () {
2836 fprintf (stderr , "Unimplemented Javascript primitive caml_xmlhttprequest_create!\n" );
2937 exit (1 );
Original file line number Diff line number Diff line change @@ -277,3 +277,13 @@ module String = struct
277277 let uint8 = new % js uint8Array_fromBuffer ab in
278278 of_uint8Array uint8
279279end
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
273273
274274 val of_uint8Array : uint8Array Js .t -> string
275275end
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