package lintcstubs-arity

  1. Overview
  2. Docs
Generate headers for C bindings

Install

Dune Dependency

Authors

Maintainers

Sources

lintcstubs-arity-0.2.1.tbz
sha256=39a8e357ecc08fced6e9020edb0526e57999a0bf833700d6d9f759b85792c49b
sha512=0a509a862916f541692aed9569dc212b7fcf1c5d1eb08a01d77007c3d211b4e5dcba9f5ddd86689b16149c3799d185d885d768c08e21c1ab153b8831909f6edf

doc/lintcstubs-arity.primitives_of_cmt/Primitives_of_cmt/index.html

Module Primitives_of_cmtSource

Typedtree has an unstable API (depends on compiler version), so extract the parts we need and convert to types defined in this file. If the build breaks with new compiler versions then only this module needs to be updated (perhaps by using Dune's support to conditionally select files based on compiler versions)

Sourcetype native_arg =
  1. | Value
  2. | Double
  3. | Int32
  4. | Int64
  5. | Intnat of {
    1. untagged_int : bool;
    }
  6. | Bytecode_argv
  7. | Bytecode_argn
Sourceval ctype_of_native_arg : native_arg -> string

ctype_of_native_arg arg returns the C type used when implementing primitives for native code mode.

Sourcetype t = {
  1. byte_name : string;
    (*

    name of C function implementing the primitive in bytecode mode

    *)
  2. native_name : string;
    (*

    name of C function implementinmg the primitive in native code mode

    *)
  3. arity : int;
    (*

    number of arguments to C function in native code mode

    *)
  4. alloc : bool;
    (*

    whether it allocates/raises exceptions

    *)
  5. native_result : native_arg;
    (*

    result type of the C function implementing the primitive in native code mode

    *)
  6. native_args : native_arg list;
    (*

    type of the arguments of the C function implementing the primitive in native code mode

    *)
}
Sourceval iter_primitives_exn : path:string -> (Types.type_expr -> t -> unit) -> unit

iter_primitives_exn ~path primitive_description will load the .cmt/.cmti file path and iterate on any primitives defined using primitive_description.

Exceptions from compiler-libs may escape, so it is recommended to wrap calls using with_report_exceptions.

Sourceval with_report_exceptions : (unit -> 'a) -> 'a

with_report_exceptions f will report any compiler-libs exceptions escaping from f and exit the process with code 2.

OCaml

Innovation. Community. Security.