package spin

  1. Overview
  2. Docs

Source file c_bindings.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
84
85
86
87
(* Generated by: ocaml-crunch
   Creation date: Sat, 17 May 2025 12:17:03 GMT *)

module Internal = struct
  let d_1371a729a5538383c9121b12dc54a9b7 = "# {{ project_name }}\n\n{%- if ci_cd == 'GitHub' and github_username %}\n\n[![Actions Status](https://github.com/{{ github_username }}/{{ project_slug }}/workflows/CI/badge.svg)](https://github.com/{{ github_username }}/{{ project_slug }}/actions)\n{%- endif %}\n\n{%- if project_description %}\n\n{{ project_description }}\n{%- endif %}\n\n## Installation\n\n### Using Opam\n\n```bash\nopam install inquire\n```\n\n### Using Esy\n\n```bash\nesy add @opam/inquire\n```\n\n## Usage\n\n### In OCaml\n\n```ocaml\nlet () = {{ project_snake | capitalize }}.printf \"World\"\n```\n\n## Contributing\n\nTake a look at our [Contributing Guide](CONTRIBUTING.md)."

  let d_1933acd6bf1e31feea7c92c6f9dd6877 = "# This file is generated by dune, edit dune-project instead\nopam-version: \"2.0\"\nsynopsis: \"{{ project_description }}\"\ndescription: \"\"\"\n{{ project_description }}\n\"\"\"\nmaintainer: [\"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\"]\nauthors: [\"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\"]\nlicense: \"ISC\"\n{%- if github_username %}\nhomepage: \"https://github.com/{{ github_username }}/{{ project_slug }}\"\ndoc: \"https://{{ github_username }}.github.io/{{ project_slug }}\"\nbug-reports: \"https://github.com/{{ github_username }}/{{ project_slug }}/issues\"{% endif %}\ndepends: [\n  \"ocaml\" {>= \"4.08.0\"}\n  \"dune\" {>= \"2.0\"}\n  {% if test_framework == 'Alcotest' -%}\n  \"alcotest\" {with-test}\n  {% endif -%}\n  \"odoc\" {with-doc}\n  \"ctypes\"\n]\nbuild: [\n  [\"dune\" \"subst\"] {dev}\n  [\n    \"dune\"\n    \"build\"\n    \"-p\"\n    name\n    \"-j\"\n    jobs\n    \"@install\"\n    \"@runtest\" {with-test}\n    \"@doc\" {with-doc}\n  ]\n]\n{%- if github_username %}\ndev-repo: \"git+https://github.com/{{ github_username }}/{{ project_slug }}.git\"{% endif %}\n"

  let d_237083f093816868da10aacec2935cc4 = "let c_headers = \"#include <stdio.h>\"\n\nlet () =\n  let mode = Sys.argv.(1) in\n  let fname = Sys.argv.(2) in\n  let oc = open_out_bin fname in\n  let format = Format.formatter_of_out_channel oc in\n  let fn =\n    match mode with\n    | \"ml\" ->\n      Cstubs.write_ml\n    | \"c\" ->\n      Format.fprintf format \"%s@\\n\" c_headers;\n      Cstubs.write_c\n    | _ ->\n      assert false\n  in\n  fn ~concurrency:Cstubs.unlocked format ~prefix:\"{{ project_snake }}\" (module {{ project_snake | capitalize }}_stubs.Def);\n  Format.pp_print_flush format ();\n  close_out oc\n"

  let d_487aa9dd122daefc95354914de26f038 = "include {{ project_snake | capitalize }}_stubs.Def ({{ project_snake | capitalize }}_generated_stubs)\n"

  let d_6725c46a49dd6410b1caf78e4042a078 = "(lang dune 2.0)\n\n(name {{ project_slug }})\n\n{% if github_username %}(documentation \"https://{{ github_username }}.github.io/{{ project_slug }}/\"){% endif %}\n\n{% if github_username %}(source\n (github {{ github_username }}/{{ project_slug }})){% endif %}\n\n(license ISC)\n\n(authors\n  \"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\")\n\n(maintainers\n  \"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\")\n\n(generate_opam_files true)\n\n(package\n (name {{ project_slug }})\n (synopsis \"{{ project_description }}\")\n (description \"{{ project_description }}\")\n (depends\n  (ocaml (>= 4.08.0))\n  dune\n  {%- if test_framework == 'Alcotest' %}\n  (alcotest :with-test)\n  {%- endif %}\n  (odoc :with-doc)\n  ctypes))\n"

  let d_74335a910bfb9dba90fed0c40c1f92bc = "open Ctypes\n\nmodule Def (F : Cstubs.FOREIGN) = struct\n  open F\n\n  let printf = F.foreign \"printf\" (string @-> returning void)\nend\n"

  let d_78686f28233f42d837e1c5015b86b7ec = "(** {{ project_description }} *)\n\nval printf : string -> unit\n(** Print a string to the standard output.\n\n    {4 Examples}\n\n    {[ printf \"Hello World!\" ]} *)\n\nval greet : string -> string\n(** Returns a greeting message.\n\n    {4 Examples}\n\n    {[ print_endline @@ greet \"Jane\" ]} *)\n"

  let d_79af8be7d7ace55358689b9b057c4491 = "let printf s = Bindings.printf s\n\nlet greet name = \"Hello \" ^ name ^ \"!\"\n"

  let d_a15caceb195eaea2d2ecdf1372c8b6a3 = "(rule\n (targets {{ project_snake }}_generated_stubs.ml)\n (action\n  (run stubs/gen_stubs.exe ml %{targets})))\n\n(rule\n (targets {{ project_snake }}_generated_stubs.c)\n (action\n  (run stubs/gen_stubs.exe c %{targets})))\n\n(library\n (name {{ project_snake }})\n (public_name {{ project_snake }})\n (libraries ctypes {{ project_snake }}.stubs)\n (foreign_stubs\n  (language c)\n  (names {{ project_snake }}_generated_stubs))\n (flags\n  (:standard -w -4)))\n"

  let d_a3bdf4c002233e51c4d56e5b1a4b70c5 = "(inherit (official lib))\n\n(name c-bindings)\n(description \"Bindings to a C library\")\n"

  let d_a52f7e25e7ece45fadc5db0df929d876 = "(library\n (name {{ project_snake }}_stubs)\n (public_name {{ project_snake }}.stubs)\n (modules\n  (:standard \\ gen_stubs))\n (libraries ctypes.stubs))\n\n(executable\n (name gen_stubs)\n (modules gen_stubs)\n (libraries ctypes.stubs {{ project_snake }}.stubs))\n"

  let d_e556ac7294b77d073aadeeac1ab9b9ec = "# c-bingings\n\nBindings to a C library\n\n```bash\nspin new c-bindings\n```\n\n## Acknowledgments\n\nThis template is inspired by these awesome projects:\n\n- [ocaml-posix](https://github.com/savonet/ocaml-posix) - Bindings to the various POSIX APIs\n"

  let d_e6de82ef5edc707bf9430840826b371d = ".DEFAULT_GOAL := all\n\nARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))\n$(eval $(ARGS):;@:)\n\n.PHONY: all\nall:\n\topam exec -- dune build --root . @install\n\n.PHONY: deps\ndeps: ## Install development dependencies\n\topam install -y dune-release ocamlformat utop ocaml-lsp-server\n\topam install --deps-only --with-test --with-doc -y .\n\n.PHONY: create_switch\ncreate_switch:\n\topam switch create . --no-install -y\n\n.PHONY: switch\nswitch: ## Create an opam switch and install development dependencies\n\topam install . --deps-only --with-doc --with-test\n\topam install -y dune-release ocamlformat utop ocaml-lsp-server\n\n.PHONY: lock\nlock: ## Generate a lock file\n\topam lock -y .\n\n.PHONY: build\nbuild: ## Build the project, including non installable libraries and executables\n\topam exec -- dune build --root .\n\n.PHONY: install\ninstall: all ## Install the packages on the system\n\topam exec -- dune install --root .\n\n.PHONY: example\nexample: all ## Run the example\n\topam exec -- dune exec --root . example/main.exe $(ARGS)\n\n.PHONY: test\ntest: ## Run the unit tests\n\topam exec -- dune runtest --root .\n\n.PHONY: clean\nclean: ## Clean build artifacts and other generated files\n\topam exec -- dune clean --root .\n\n.PHONY: doc\ndoc: ## Generate odoc documentation\n\topam exec -- dune build --root . @doc\n\n.PHONY: servedoc\nservedoc: doc ## Open odoc documentation with default web browser\n\topen _build/default/_doc/_html/index.html\n\n.PHONY: fmt\nfmt: ## Format the codebase with ocamlformat\n\topam exec -- dune build --root . --auto-promote @fmt\n\n.PHONY: watch\nwatch: ## Watch for the filesystem and rebuild on every change\n\topam exec -- dune build --root . --watch\n\n.PHONY: utop\nutop: ## Run a REPL and link with the project's libraries\n\topam exec -- dune utop --root . lib -- -implicit-bindings\n"

  let file_chunks = function
    | "README.md" | "/README.md" -> Some [ d_e556ac7294b77d073aadeeac1ab9b9ec; ]
    | "spin" | "/spin" -> Some [ d_a3bdf4c002233e51c4d56e5b1a4b70c5; ]
    | "template/Makefile" | "/template/Makefile" -> Some [ d_e6de82ef5edc707bf9430840826b371d; ]
    | "template/README.md" | "/template/README.md" -> Some [ d_1371a729a5538383c9121b12dc54a9b7; ]
    | "template/dune-project" | "/template/dune-project" -> Some [ d_6725c46a49dd6410b1caf78e4042a078; ]
    | "template/lib/bindings.ml" | "/template/lib/bindings.ml" -> Some [ d_487aa9dd122daefc95354914de26f038; ]
    | "template/lib/dune" | "/template/lib/dune" -> Some [ d_a15caceb195eaea2d2ecdf1372c8b6a3; ]
    | "template/lib/stubs/dune" | "/template/lib/stubs/dune" -> Some [ d_a52f7e25e7ece45fadc5db0df929d876; ]
    | "template/lib/stubs/gen_stubs.ml" | "/template/lib/stubs/gen_stubs.ml" -> Some [ d_237083f093816868da10aacec2935cc4; ]
    | "template/lib/stubs/{{ project_snake }}_stubs.ml" | "/template/lib/stubs/{{ project_snake }}_stubs.ml" -> Some [ d_74335a910bfb9dba90fed0c40c1f92bc; ]
    | "template/lib/{{ project_snake }}.ml" | "/template/lib/{{ project_snake }}.ml" -> Some [ d_79af8be7d7ace55358689b9b057c4491; ]
    | "template/lib/{{ project_snake }}.mli" | "/template/lib/{{ project_snake }}.mli" -> Some [ d_78686f28233f42d837e1c5015b86b7ec; ]
    | "template/{{ project_slug }}.opam" | "/template/{{ project_slug }}.opam" -> Some [ d_1933acd6bf1e31feea7c92c6f9dd6877; ]
    | _ -> None

  let file_list = [ "README.md"; "spin"; "template/Makefile"; "template/README.md"; "template/dune-project"; "template/lib/bindings.ml"; "template/lib/dune"; "template/lib/stubs/dune"; "template/lib/stubs/gen_stubs.ml"; "template/lib/stubs/{{ project_snake }}_stubs.ml"; "template/lib/{{ project_snake }}.ml"; "template/lib/{{ project_snake }}.mli"; "template/{{ project_slug }}.opam"; ]
end

let file_list = Internal.file_list

let read name =
  match Internal.file_chunks name with
  | None -> None
  | Some c -> Some (String.concat "" c)

let hash = function
  | "README.md" | "/README.md" -> Some "e556ac7294b77d073aadeeac1ab9b9ec"
  | "spin" | "/spin" -> Some "a3bdf4c002233e51c4d56e5b1a4b70c5"
  | "template/Makefile" | "/template/Makefile" -> Some "e6de82ef5edc707bf9430840826b371d"
  | "template/README.md" | "/template/README.md" -> Some "1371a729a5538383c9121b12dc54a9b7"
  | "template/dune-project" | "/template/dune-project" -> Some "6725c46a49dd6410b1caf78e4042a078"
  | "template/lib/bindings.ml" | "/template/lib/bindings.ml" -> Some "487aa9dd122daefc95354914de26f038"
  | "template/lib/dune" | "/template/lib/dune" -> Some "a15caceb195eaea2d2ecdf1372c8b6a3"
  | "template/lib/stubs/dune" | "/template/lib/stubs/dune" -> Some "a52f7e25e7ece45fadc5db0df929d876"
  | "template/lib/stubs/gen_stubs.ml" | "/template/lib/stubs/gen_stubs.ml" -> Some "237083f093816868da10aacec2935cc4"
  | "template/lib/stubs/{{ project_snake }}_stubs.ml" | "/template/lib/stubs/{{ project_snake }}_stubs.ml" -> Some "74335a910bfb9dba90fed0c40c1f92bc"
  | "template/lib/{{ project_snake }}.ml" | "/template/lib/{{ project_snake }}.ml" -> Some "79af8be7d7ace55358689b9b057c4491"
  | "template/lib/{{ project_snake }}.mli" | "/template/lib/{{ project_snake }}.mli" -> Some "78686f28233f42d837e1c5015b86b7ec"
  | "template/{{ project_slug }}.opam" | "/template/{{ project_slug }}.opam" -> Some "1933acd6bf1e31feea7c92c6f9dd6877"
  | _ -> None

let size = function
  | "README.md" | "/README.md" -> Some 239
  | "spin" | "/spin" -> Some 84
  | "template/Makefile" | "/template/Makefile" -> Some 1781
  | "template/README.md" | "/template/README.md" -> Some 615
  | "template/dune-project" | "/template/dune-project" -> Some 741
  | "template/lib/bindings.ml" | "/template/lib/bindings.ml" -> Some 102
  | "template/lib/dune" | "/template/lib/dune" -> Some 444
  | "template/lib/stubs/dune" | "/template/lib/stubs/dune" -> Some 253
  | "template/lib/stubs/gen_stubs.ml" | "/template/lib/stubs/gen_stubs.ml" -> Some 549
  | "template/lib/stubs/{{ project_snake }}_stubs.ml" | "/template/lib/stubs/{{ project_snake }}_stubs.ml" -> Some 130
  | "template/lib/{{ project_snake }}.ml" | "/template/lib/{{ project_snake }}.ml" -> Some 73
  | "template/lib/{{ project_snake }}.mli" | "/template/lib/{{ project_snake }}.mli" -> Some 283
  | "template/{{ project_slug }}.opam" | "/template/{{ project_slug }}.opam" -> Some 1061
  | _ -> None
OCaml

Innovation. Community. Security.