package posix-stat

  1. Overview
  2. Docs

Source file posix_stat_generated_constants.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
[@@@warning "-9-27"]
include Ctypes
let lift x = x
open Ctypes_static

let rec field : type t a. t typ -> string -> a typ -> (a, t) field =
  fun s fname ftype -> match s, fname with
  | View { ty; _ }, _ ->
    let { ftype; foffset; fname } = field ty fname ftype in
    { ftype; foffset; fname }
  | _ -> failwith ("Unexpected field "^ fname)

let rec seal : type a. a typ -> unit = function
  | Struct { tag; spec = Complete _; _ } ->
    raise (ModifyingSealedType tag)
  | Union { utag; uspec = Some _; _ } ->
    raise (ModifyingSealedType utag)
  | View { ty; _ } -> seal ty
  | _ ->
    raise (Unsupported "Sealing a non-structured type")

type 'a const = 'a
let constant (type t) name (t : t typ) : t = match t, name with
  | Ctypes_static.Primitive Cstubs_internals.Int, "AT_EACCESS" ->
    512
  | Ctypes_static.Primitive Cstubs_internals.Int, "AT_REMOVEDIR" ->
    512
  | Ctypes_static.Primitive Cstubs_internals.Int, "AT_SYMLINK_NOFOLLOW" ->
    256
  | Ctypes_static.Primitive Cstubs_internals.Int, "AT_FDCWD" ->
    -100
  | Ctypes_static.View { Ctypes_static.read = read1; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IXOTH" ->
    (read1 (Unsigned.UInt32.of_string "1"))
  | Ctypes_static.View { Ctypes_static.read = read2; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IWOTH" ->
    (read2 (Unsigned.UInt32.of_string "2"))
  | Ctypes_static.View { Ctypes_static.read = read3; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IROTH" ->
    (read3 (Unsigned.UInt32.of_string "4"))
  | Ctypes_static.View { Ctypes_static.read = read4; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IRWXO" ->
    (read4 (Unsigned.UInt32.of_string "7"))
  | Ctypes_static.View { Ctypes_static.read = read5; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IXGRP" ->
    (read5 (Unsigned.UInt32.of_string "8"))
  | Ctypes_static.View { Ctypes_static.read = read6; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IWGRP" ->
    (read6 (Unsigned.UInt32.of_string "16"))
  | Ctypes_static.View { Ctypes_static.read = read7; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IRGRP" ->
    (read7 (Unsigned.UInt32.of_string "32"))
  | Ctypes_static.View { Ctypes_static.read = read8; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IRWXG" ->
    (read8 (Unsigned.UInt32.of_string "56"))
  | Ctypes_static.View { Ctypes_static.read = read9; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IXUSR" ->
    (read9 (Unsigned.UInt32.of_string "64"))
  | Ctypes_static.View { Ctypes_static.read = read10; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IWUSR" ->
    (read10 (Unsigned.UInt32.of_string "128"))
  | Ctypes_static.View { Ctypes_static.read = read11; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IRUSR" ->
    (read11 (Unsigned.UInt32.of_string "256"))
  | Ctypes_static.View { Ctypes_static.read = read12; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IRWXU" ->
    (read12 (Unsigned.UInt32.of_string "448"))
  | Ctypes_static.View { Ctypes_static.read = read13; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_ISVTX" ->
    (read13 (Unsigned.UInt32.of_string "512"))
  | Ctypes_static.View { Ctypes_static.read = read14; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_ISGID" ->
    (read14 (Unsigned.UInt32.of_string "1024"))
  | Ctypes_static.View { Ctypes_static.read = read15; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_ISUID" ->
    (read15 (Unsigned.UInt32.of_string "2048"))
  | Ctypes_static.View { Ctypes_static.read = read16; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFSOCK" ->
    (read16 (Unsigned.UInt32.of_string "49152"))
  | Ctypes_static.View { Ctypes_static.read = read17; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFIFO" ->
    (read17 (Unsigned.UInt32.of_string "4096"))
  | Ctypes_static.View { Ctypes_static.read = read18; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFBLK" ->
    (read18 (Unsigned.UInt32.of_string "24576"))
  | Ctypes_static.View { Ctypes_static.read = read19; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFCHR" ->
    (read19 (Unsigned.UInt32.of_string "8192"))
  | Ctypes_static.View { Ctypes_static.read = read20; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFLNK" ->
    (read20 (Unsigned.UInt32.of_string "40960"))
  | Ctypes_static.View { Ctypes_static.read = read21; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFDIR" ->
    (read21 (Unsigned.UInt32.of_string "16384"))
  | Ctypes_static.View { Ctypes_static.read = read22; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFREG" ->
    (read22 (Unsigned.UInt32.of_string "32768"))
  | Ctypes_static.View { Ctypes_static.read = read23; ty = Ctypes_static.Primitive Cstubs_internals.Uint32_t }, "S_IFMT" ->
    (read23 (Unsigned.UInt32.of_string "61440"))
  | _, s -> failwith ("unmatched constant: "^ s)

let enum (type a) name ?typedef ?unexpected (alist : (a * int64) list) =
  match name with
  | s ->
    failwith ("unmatched enum: "^ s)