1 open OcamlExtractionTable
4 let print_ocaml_of_obj0 status ((_uri,_,_,_,_) as obj) =
6 let status,res,resl = Extraction.extract status obj in
10 let status,cmds = Ocaml.pp_spec status ml in
11 print_ppcmds ~in_ml:false status (cmds ++ fnl () ++ fnl ());
16 let status,cmds = Ocaml.pp_decl status ml in
17 print_ppcmds ~in_ml:true status (cmds ++ fnl () ++ fnl ());
21 HExtlib.Localized (_,exn)
23 prerr_endline (Printexc.to_string exn); assert false
25 let do_if_ocaml_set f status =
26 if try ignore (Helm_registry.get "extract_ocaml"); true
27 with Helm_registry.Key_not_found _ -> false
28 then f status else status
30 let print_open status uris =
36 let status,b = to_be_included status uri in
37 status, if b then Some uri else None
39 let uris = HExtlib.filter_map (fun x -> x) uris in
41 List.map (fun uri -> Filename.basename (NUri.string_of_uri uri)) uris in
42 let status,cmds = map_status status Ocaml.pp_open fnames in
43 List.iter (print_ppcmds status ~in_ml:true) cmds;
44 let status,cmds = map_status status Ocaml.pp_open fnames in
45 List.iter (print_ppcmds status ~in_ml:false) cmds;
49 let print_ocaml_of_obj status cmds =
50 do_if_ocaml_set (fun status -> print_ocaml_of_obj0 status cmds) status
52 let open_file status ~baseuri fname =
54 (fun status -> OcamlExtractionTable.open_file status ~baseuri fname) status
56 let close_file status =
57 do_if_ocaml_set OcamlExtractionTable.close_file status