Browse Source

move external to private module, add some examples

master
zapashcanon 4 years ago
parent
commit
e7ff8e652c
Signed by: zapashcanon GPG Key ID: 8981C3C62D1D28F1
  1. 15
      examples/dune
  2. 1
      examples/exit_failure.ml
  3. 1
      examples/exit_success.ml
  4. 2
      examples/print_code.ml
  5. 4
      src/dune
  6. 8
      src/exit.ml
  7. 3
      src/external.ml

15
examples/dune

@ -1,3 +1,14 @@
(executable
(name print_code)
(libraries exit))
(name print_code)
(modules print_code)
(libraries exit))
(executable
(name exit_failure)
(modules exit_failure)
(libraries exit))
(executable
(name exit_success)
(modules exit_success)
(libraries exit))

1
examples/exit_failure.ml

@ -0,0 +1 @@
let () = Exit.failure ()

1
examples/exit_success.ml

@ -0,0 +1 @@
let () = Exit.success ()

2
examples/print_code.ml

@ -1,4 +1,4 @@
let _ =
let () =
Format.printf "succes code is %d@." Exit.success_code ;
Format.printf "failure code is %d@." Exit.failure_code ;
if Exit.success_code <> 0 || Exit.failure_code <> 1 then (

4
src/dune

@ -1,8 +1,10 @@
(library
(public_name exit)
(modules exit external)
(private_modules external)
(wrapped false)
(preprocess
(pps bisect_ppx -conditional))
(pps bisect_ppx -- --conditional))
(foreign_stubs
(language c)
(names exit_stubs)))

8
src/exit.ml

@ -1,10 +1,6 @@
external success_code : unit -> int = "get_success_code"
let success_code = External.success_code ()
external failure_code : unit -> int = "get_failure_code"
let success_code = success_code ()
let failure_code = failure_code ()
let failure_code = External.failure_code ()
let success () = exit success_code

3
src/external.ml

@ -0,0 +1,3 @@
external failure_code : unit -> int = "get_failure_code"
external success_code : unit -> int = "get_success_code"
Loading…
Cancel
Save