Skip to content

Commit 4b9e196

Browse files
damiendoligezdra27
authored andcommitted
restore compatibility for String.{unsafe_set,create,fill}
1 parent a393349 commit 4b9e196

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Changes

+4
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,10 @@ OCaml 4.03.0 (25 Apr 2016):
912912
caml_fill_bytes and caml_create_bytes for migration
913913
(Hongbo Zhang, review by Damien Doligez, Alain Frisch, and Hugo Heuzard)
914914

915+
- GPR#772 %string_safe_set and %string_unsafe_set are deprecated aliases
916+
for %bytes_safe_set and %bytes_unsafe_set.
917+
(Hongbo Zhang and Damien Doligez)
918+
915919
- PR#3612, PR#92: allow allocating custom block with finalizers
916920
in the minor heap.
917921
(Pierre Chambart)

bytecomp/translcore.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,12 @@ let primitives_table = create_hashtable 57 [
231231
"%gefloat", Pfloatcomp Cge;
232232
"%string_length", Pstringlength;
233233
"%string_safe_get", Pstringrefs;
234+
"%string_safe_set", Pbytessets;
234235
"%string_unsafe_get", Pstringrefu;
236+
"%string_unsafe_set", Pbytessetu;
235237
"%bytes_length", Pbyteslength;
236238
"%bytes_safe_get", Pbytesrefs;
237239
"%bytes_safe_set", Pbytessets;
238-
"%string_safe_set", Pbytessets;
239240
"%bytes_unsafe_get", Pbytesrefu;
240241
"%bytes_unsafe_set", Pbytessetu;
241242
"%array_length", Parraylength Pgenarray;

stdlib/string.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
external length : string -> int = "%string_length"
2525
external get : string -> int -> char = "%string_safe_get"
2626
external set : bytes -> int -> char -> unit = "%string_safe_set"
27-
external create : int -> bytes = "caml_create_bytes"
27+
external create : int -> bytes = "caml_create_string"
2828
external unsafe_get : string -> int -> char = "%string_unsafe_get"
29-
external unsafe_set : bytes -> int -> char -> unit = "%bytes_unsafe_set"
29+
external unsafe_set : bytes -> int -> char -> unit = "%string_unsafe_set"
3030
external unsafe_blit : string -> int -> bytes -> int -> int -> unit
3131
= "caml_blit_string" [@@noalloc]
3232
external unsafe_fill : bytes -> int -> int -> char -> unit
33-
= "caml_fill_bytes" [@@noalloc]
33+
= "caml_fill_string" [@@noalloc]
3434

3535
module B = Bytes
3636

stdlib/string.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ external set : bytes -> int -> char -> unit = "%string_safe_set"
6868
6969
@deprecated This is a deprecated alias of {!Bytes.set}.[ ] *)
7070

71-
external create : int -> bytes = "caml_create_bytes"
71+
external create : int -> bytes = "caml_create_string"
7272
[@@ocaml.deprecated "Use Bytes.create instead."]
7373
(** [String.create n] returns a fresh byte sequence of length [n].
7474
The sequence is uninitialized and contains arbitrary bytes.
@@ -338,11 +338,11 @@ val split_on_char: char -> string -> string list
338338
(* The following is for system use only. Do not call directly. *)
339339

340340
external unsafe_get : string -> int -> char = "%string_unsafe_get"
341-
external unsafe_set : bytes -> int -> char -> unit = "%bytes_unsafe_set"
341+
external unsafe_set : bytes -> int -> char -> unit = "%string_unsafe_set"
342342
[@@ocaml.deprecated]
343343
external unsafe_blit :
344344
string -> int -> bytes -> int -> int -> unit
345345
= "caml_blit_string" [@@noalloc]
346346
external unsafe_fill :
347-
bytes -> int -> int -> char -> unit = "caml_fill_bytes" [@@noalloc]
347+
bytes -> int -> int -> char -> unit = "caml_fill_string" [@@noalloc]
348348
[@@ocaml.deprecated]

stdlib/stringLabels.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ external set : bytes -> int -> char -> unit = "%string_safe_set"
3434
3535
@deprecated This is a deprecated alias of {!BytesLabels.set}. *)
3636

37-
external create : int -> bytes = "caml_create_bytes"
37+
external create : int -> bytes = "caml_create_string"
3838
[@@ocaml.deprecated "Use BytesLabels.create instead."]
3939
(** [String.create n] returns a fresh byte sequence of length [n].
4040
The sequence is uninitialized and contains arbitrary bytes.
@@ -243,11 +243,11 @@ val compare: t -> t -> int
243243
(* The following is for system use only. Do not call directly. *)
244244

245245
external unsafe_get : string -> int -> char = "%string_unsafe_get"
246-
external unsafe_set : bytes -> int -> char -> unit = "%bytes_unsafe_set"
246+
external unsafe_set : bytes -> int -> char -> unit = "%string_unsafe_set"
247247
[@@ocaml.deprecated]
248248
external unsafe_blit :
249249
src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int ->
250250
unit = "caml_blit_string" [@@noalloc]
251251
external unsafe_fill :
252-
bytes -> pos:int -> len:int -> char -> unit = "caml_fill_bytes" [@@noalloc]
252+
bytes -> pos:int -> len:int -> char -> unit = "caml_fill_string" [@@noalloc]
253253
[@@ocaml.deprecated]

0 commit comments

Comments
 (0)