123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960(* [Bytes0] defines string functions that are primitives or can be simply
defined in terms of [Caml.Bytes]. [Bytes0] is intended to completely express
the part of [Caml.Bytes] that [Base] uses -- no other file in Base other
than bytes0.ml should use [Caml.Bytes]. [Bytes0] has few dependencies, and
so is available early in Base's build order.
All Base files that need to use strings and come before [Base.Bytes] in
build order should do:
{[
module Bytes = Bytes0
]}
Defining [module Bytes = Bytes0] is also necessary because it prevents
ocamldep from mistakenly causing a file to depend on [Base.Bytes]. *)open!Import0moduleSys=Sys0modulePrimitives=structexternalget:bytes->int->char="%bytes_safe_get"externallength:bytes->int="%bytes_length"externalunsafe_get:bytes->int->char="%bytes_unsafe_get"includeBytes_set_primitives(* [unsafe_blit_string] is not exported in the [stdlib] so we export it here *)externalunsafe_blit_string:src:string->src_pos:int->dst:bytes->dst_pos:int->len:int->unit="caml_blit_string"[@@noalloc]endincludePrimitivesletmax_length=Sys.max_string_lengthletblit=Caml.Bytes.blitletblit_string=Caml.Bytes.blit_stringletcompare=Caml.Bytes.compareletcopy=Caml.Bytes.copyletcreate=Caml.Bytes.createletfill=Caml.Bytes.fillletmake=Caml.Bytes.makeletmap=Caml.Bytes.mapletmapi=Caml.Bytes.mapiletsub=Caml.Bytes.subletunsafe_blit=Caml.Bytes.unsafe_blitletto_string=Caml.Bytes.to_stringletof_string=Caml.Bytes.of_stringletunsafe_to_string~no_mutation_while_string_reachable:s=Caml.Bytes.unsafe_to_strings;;letunsafe_of_string_promise_no_mutation=Caml.Bytes.unsafe_of_string