package guile

  1. Overview
  2. Docs
Bindings to GNU Guile Scheme for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.tar.gz
md5=be5a3dae4018b36103f0af9f769a26f0
sha512=74136c9f933aea8d0403d5f5826cf7acb8824c985639d5a79eb2a7247c1bd1362eb61fd946f148e25e7b0283af2e36435c3d3ffe5f7e7913e27b70d941e97c09

doc/src/guile.guile/bindings_stubs.ml.html

Source file bindings_stubs.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
[@@@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.View { Ctypes_static.read = read1; ty = Ctypes_static.Primitive Cstubs_internals.Int64_t }, "SCM_UNDEFINED" ->
    (read1 (2308L))
  | Ctypes_static.View { Ctypes_static.read = read2; ty = Ctypes_static.Primitive Cstubs_internals.Int64_t }, "SCM_EOL" ->
    (read2 (772L))
  | Ctypes_static.View { Ctypes_static.read = read3; ty = Ctypes_static.Primitive Cstubs_internals.Int64_t }, "SCM_BOOL_T" ->
    (read3 (1028L))
  | Ctypes_static.View { Ctypes_static.read = read4; ty = Ctypes_static.Primitive Cstubs_internals.Int64_t }, "SCM_BOOL_F" ->
    (read4 (4L))
  | _, s -> failwith ("unmatched constant: "^ s)

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

Innovation. Community. Security.