package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/src/ocgtk.common/uInt8.ml.html

Source file uInt8.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(**************************************************************************)
(*                ocgtk - OCaml bindings for GTK4                         *)
(*                                                                        *)
(*    This program is free software; you can redistribute it              *)
(*    and/or modify it under the terms of the GNU Library General         *)
(*    Public License version 2, as published by the                       *)
(*    Free Software Foundation with the exception described in file       *)
(*    COPYING which comes with the library.                               *)
(*                                                                        *)
(*    Based on lablgtk3 (https://github.com/garrigue/lablgtk)             *)
(*                                                                        *)
(**************************************************************************)

type t = private int

external unsafe_of_int : int -> t = "%identity"

let min_value = 0
let max_value = 255

let of_int n =
  if n < min_value || n > max_value then
    invalid_arg
      (Printf.sprintf "UInt8.of_int: %d is out of range [%d, %d]" n min_value
         max_value);
  unsafe_of_int n

let to_int (v : t) = (v :> int)
let min_int = unsafe_of_int min_value
let max_int = unsafe_of_int max_value
let zero = unsafe_of_int 0