package gobject-introspection

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file bindings_stubs_g_param.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
[@@@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.Int64_t, "G_PARAM_DEPRECATED" ->
    -2147483648L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_EXPLICIT_NOTIFY" ->
    1073741824L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_STATIC_BLURB" ->
    128L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_STATIC_NICK" ->
    64L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_STATIC_NAME" ->
    32L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_LAX_VALIDATION" ->
    16L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_CONSTRUCT_ONLY" ->
    8L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_CONSTRUCT" ->
    4L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_READWRITE" ->
    3L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_WRITABLE" ->
    2L
  | Ctypes_static.Primitive Cstubs_internals.Int64_t, "G_PARAM_READABLE" ->
    1L
  | _, s -> failwith ("unmatched constant: "^ s)

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