Chris_T avatar Chris_T committed 102414c

Replace the "module type" constructs in the interface which are not understood by OCaml version < 3.12.

Comments (0)

Files changed (1)

lib/make_lacaml_intf.ml

 let file_out_mli = Sys.argv.(1)
 let file_in_mli = Sys.argv.(2)
 
+let ocaml_major, ocaml_minor =
+  Scanf.sscanf Sys.ocaml_version "%i.%i" (fun v1 v2 -> v1, v2)
+
 let comment_re = Str.regexp "(\\* [^*]+\\*)[ \n\r\t]*"
 
 let input_file ?(comments=true) fname =
   Str.regexp "^ *include +\\([A-Za-z0-9]+_[SDCZ]\\|Io\\|Common\\)"
 let open_ba_re = Str.regexp "open Bigarray"
 let prec_re = Str.regexp " *open *\\(Float[0-9]+\\|Complex[0-9]+\\)[ \n\r\t]*"
+let real_io_re = Str.regexp "include module type of Real_io"
+let complex_io_re = Str.regexp "include module type of Complex_io"
 
 let mli =
   let subst s =
     (* "open Bigarray" already present in the main file *)
     let m = Str.global_replace open_ba_re "" m in
     Str.global_replace prec_re "" m in
-  Str.global_substitute include_re subst mli
+  let mli = Str.global_substitute include_re subst mli in
+  if ocaml_major <= 3 && ocaml_minor <= 11 then
+    (* Replace the "module type" not understood before OCaml 3.12 *)
+    let mli = Str.global_replace real_io_re "\
+	val pp_num : Format.formatter -> float -> unit\n    \
+	val pp_vec : (float, 'a) Io.pp_vec\n    \
+	val pp_mat : (float, 'a) Io.pp_mat" mli in
+    Str.global_replace complex_io_re "\
+	val pp_num : Format.formatter -> Complex.t -> unit\n    \
+	val pp_vec : (Complex.t, 'a) Io.pp_vec\n    \
+	val pp_mat : (Complex.t, 'a) Io.pp_mat" mli
+  else mli
 
 
 (* Output the resulting interface *)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.