diff --git a/.ocamlformat b/.ocamlformat index 0619e80..e69de29 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1 +0,0 @@ -profile = janestreet diff --git a/bin/bin.ml b/bin/bin.ml index 7e83555..001a7b3 100644 --- a/bin/bin.ml +++ b/bin/bin.ml @@ -4,21 +4,21 @@ let () = let plen = allocate int 0 in let error_msg = allocate_n ~count:64 char in let input = "asdf" in - let input_length = String.length input |> Unsigned.Size_t.of_int in + let length = String.length input |> Unsigned.Size_t.of_int in let flags = 0 in let bc = - Libregexp.C.Functions.lre_compile plen error_msg 64 input input_length flags null + Libregexp.C.Functions.lre_compile plen error_msg 64 input length flags null in match is_null bc with | true -> print_endline "Error" | false -> - let capture = CArray.make char 410 in - let start = CArray.start capture in - let start_capture = allocate (ptr char) start in - let matching = "asdf" in - let matching_length = String.length matching in - let matched = - Libregexp.C.Functions.lre_exec start_capture bc matching 0 matching_length 0 null - in - print_endline ("The result of the regexp is: " ^ Int.to_string matched) -;; + let capture = CArray.make char 410 in + let start = CArray.start capture in + let start_capture = allocate (ptr char) start in + let matching = "asdf" in + let matching_length = String.length matching in + let matched = + Libregexp.C.Functions.lre_exec start_capture bc matching 0 + matching_length 0 null + in + print_endline ("The result of the regexp is: " ^ Int.to_string matched) diff --git a/function_description.ml b/function_description.ml index b94bd24..a054b57 100644 --- a/function_description.ml +++ b/function_description.ml @@ -3,45 +3,39 @@ module Types = Types_generated module Functions (F : Ctypes.FOREIGN) = struct open F - (* uint8_t *lre_compile( - int *plen, - char *error_msg, - int error_msg_size, - const char *buf, - size_t buf_len, - int re_flags, - void *opaque) *) let lre_compile = - foreign - "lre_compile" + F.foreign "lre_compile" + (* int *plen *) (Ctypes.ptr Ctypes.int - @-> Ctypes.ptr Ctypes.char - @-> Ctypes.int - @-> Ctypes.string - @-> Ctypes.size_t - @-> Ctypes.int - @-> Ctypes.ptr Ctypes.void - @-> F.returning (Ctypes.ptr Ctypes.uint8_t)) - ;; + (* char *error_msg *) + @-> Ctypes.ptr Ctypes.char + (* int error_msg_size *) + @-> Ctypes.int + (* const char *buf *) + @-> Ctypes.string + (* size_t buf_len *) + @-> Ctypes.size_t + (* int re_flags *) + @-> Ctypes.int + (* void *opaque *) + @-> Ctypes.ptr Ctypes.void + @-> F.returning (Ctypes.ptr Ctypes.uint8_t)) - (* int lre_exec( - uint8_t **capture, - const uint8_t *bc_buf, - const uint8_t *cbuf, - int cindex, - int clen, - int cbuf_type, - void *opaque) *) let lre_exec = - foreign - "lre_exec" + F.foreign "lre_exec" + (* uint8_t **capture *) (Ctypes.ptr (Ctypes.ptr Ctypes.char) - @-> Ctypes.ptr Ctypes.uint8_t - @-> Ctypes.string - @-> Ctypes.int - @-> Ctypes.int - @-> Ctypes.int - @-> Ctypes.ptr Ctypes.void - @-> F.returning Ctypes.int) - ;; + (* const uint8_t *bc_buf *) + @-> Ctypes.ptr Ctypes.uint8_t + (* const uint8_t *cbuf *) + @-> Ctypes.string + (* int cindex *) + @-> Ctypes.int + (* int clen *) + @-> Ctypes.int + (* int cbuf_type *) + @-> Ctypes.int + (* void *opaque *) + @-> Ctypes.ptr Ctypes.void + @-> F.returning Ctypes.int) end diff --git a/test/suite.ml b/test/suite.ml index 2eea66a..ae14b3f 100644 --- a/test/suite.ml +++ b/test/suite.ml @@ -1 +1,3 @@ -let _ = Alcotest.run "test suite" [ "test", [ ("test", `Quick, fun () -> assert true) ] ] +let _ = + Alcotest.run "test suite" + [ ("test", [ ("test", `Quick, fun () -> assert true) ]) ]