module Blit_intf:sig
..end
blit
functions, and reusable code for validating blit
arguments.val __pa_ounit_275876e34cf609db118f3d84b799a790 : string
blit
functions, and reusable code for validating blit
arguments.type('src, 'dst)
blit =src:'src -> src_pos:int -> dst:'dst -> dst_pos:int -> len:int -> unit
blit : (src, dst) blit
, then blit ~src ~src_pos ~len ~dst ~dst_pos
blits len
values from src
starting at position src_pos
to dst
at position dst_pos
.
Furthermore, blit
raises if src_pos
, len
, and dst_pos
don't specify valid
slices of src
and dst
.type('src, 'dst)
blito =src:'src ->
?src_pos:int -> ?src_len:int -> dst:'dst -> ?dst_pos:int -> unit -> unit
type('src, 'dst)
sub ='src -> pos:int -> len:int -> 'dst
sub : (src, dst) sub
, then sub ~src ~pos ~len
returns a sequence of type dst
containing len
characters of src
starting at pos
.
subo
is like sub
, except pos
and len
are optional.
type('src, 'dst)
subo =?pos:int -> ?len:int -> 'src -> 'dst
module type S =sig
..end
module type S1 =sig
..end
module type S_distinct =sig
..end
S
, S1
, and S1_distinct
only need
to understand the code above. The code below is only for those that need to implement
modules that match those signatures.module type Elt =sig
..end
module type Sequence =sig
..end
module type Blit =sig
..end
blit
functions, and reusable code for validating blit
arguments.blit : (src, dst) blit
, then blit ~src ~src_pos ~len ~dst ~dst_pos
blits len
values from src
starting at position src_pos
to dst
at position dst_pos
.
Furthermore, blit
raises if src_pos
, len
, and dst_pos
don't specify valid
slices of src
and dst
.0
length src - src_pos
0
sub : (src, dst) sub
, then sub ~src ~pos ~len
returns a sequence of type dst
containing len
characters of src
starting at pos
.
subo
is like sub
, except pos
and len
are optional.
default is 0
default is length src - pos
Users of modules matching the blit signatures S
, S1
, and S1_distinct
only need
to understand the code above. The code below is only for those that need to implement
modules that match those signatures.
of_bool
is used to generate two distinct values of type t
, used in unit tests.
It is required that of_bool false <> of_bool true
.
There are various Make*
functors that turn an unsafe_blit
function into a blit
function. The functors differ in whether the sequence type is monomorphic or
polymorphic, and whether the src and dst types are distinct or are the same.
The blit functions make sure the slices are valid and then call unsafe_blit
. They
guarantee at a call unsafe_blit ~src ~src_pos ~dst ~dst_pos ~len
that:
len > 0
&& src_pos >= 0
&& src_pos + len <= get_src_len src
&& dst_pos >= 0
&& dst_pos + len <= get_dst_len dst
The Make*
functors also automatically create unit tests.
Make
is for blitting between two values of the same monomorphic type.
Make_distinct
is for blitting between values of disinct monomorphic types.
Make1
is for blitting between two values of the same polymorphic type.
Make1
guarantees to only call create_like ~len t
with len > 0
if
length t > 0
.