diff --git a/example/example.ml b/example/example.ml index f4662b6..6da56f9 100644 --- a/example/example.ml +++ b/example/example.ml @@ -3,7 +3,7 @@ open Js_of_ocaml open Js_top_worker_rpc module W = Js_top_worker_client.W -let log s = Firebug.console##log (Js.string s) +let log s = Console.console##log (Js.string s) let initialise s callback = let ( let* ) = Lwt_result.bind in diff --git a/lib/uTop.ml b/lib/uTop.ml index e6e57f0..5a94716 100644 --- a/lib/uTop.ml +++ b/lib/uTop.ml @@ -216,9 +216,9 @@ let parse_default parse str eos_is_error = | Syntaxerr.Ill_formed_ast (loc, s) -> Error ([mkloc loc], Printf.sprintf "Error: broken invariant in parsetree: %s" s) - | Syntaxerr.Invalid_package_type (loc, s) -> + | Syntaxerr.Invalid_package_type (loc, _s) -> Error ([mkloc loc], - Printf.sprintf "Invalid package type: %s" s) + Printf.sprintf "Invalid package type") #if OCAML_VERSION >= (5, 0, 0) | Syntaxerr.Removed_string_set loc -> Error ([mkloc loc], @@ -354,4 +354,4 @@ let set_load_path path = Load_path.init path ~auto_include:Load_path.no_auto_include #else let set_load_path path = Load_path.init path -#endif \ No newline at end of file +#endif diff --git a/lib/uTop_complete.ml b/lib/uTop_complete.ml index f7762cb..5f109d9 100644 --- a/lib/uTop_complete.ml +++ b/lib/uTop_complete.ml @@ -379,7 +379,9 @@ let visible_modules () = (Sys.readdir (if dir = "" then Filename.current_dir_name else dir)) with Sys_error _ -> acc) -#if OCAML_VERSION >= (4, 08, 0) +#if OCAML_VERSION >= (5, 2, 0) + String_set.empty @@ Load_path.get_path_list () +#elif OCAML_VERSION >= (4, 08, 0) String_set.empty @@ Load_path.get_paths () #else String_set.empty !Config.load_path @@ -399,8 +401,11 @@ let add_fields_of_type decl acc = acc | Type_record (fields, _) -> List.fold_left (fun acc field -> add (field_name field) acc) acc fields - | Type_abstract -> - acc +#if OCAML_VERSION >= (5, 2, 0) + | Type_abstract _ -> acc +#else + | Type_abstract -> acc +#endif | Type_open -> acc @@ -414,7 +419,11 @@ let add_names_of_type decl acc = List.fold_left (fun acc cstr -> add (constructor_name cstr) acc) acc constructors | Type_record (fields, _) -> List.fold_left (fun acc field -> add (field_name field) acc) acc fields - | Type_abstract -> +#if OCAML_VERSION >= (5, 2, 0) + | Type_abstract _ -> +#else + | Type_abstract -> +#endif acc | Type_open -> acc @@ -950,7 +959,9 @@ let complete ~phrase_terminator ~input = (fun acc d -> add_files filter acc (Filename.concat d dir)) String_map.empty (Filename.current_dir_name :: -#if OCAML_VERSION >= (4, 08, 0) +#if OCAML_VERSION >= (5, 2, 0) + (Load_path.get_path_list ()) +#elif OCAML_VERSION >= (4, 08, 0) (Load_path.get_paths ()) #else !Config.load_path @@ -985,7 +996,9 @@ let complete ~phrase_terminator ~input = (fun acc d -> add_files filter acc (Filename.concat d dir)) String_map.empty (Filename.current_dir_name :: -#if OCAML_VERSION >= (4, 08, 0) +#if OCAML_VERSION >= (5, 2, 0) + (Load_path.get_path_list ()) +#elif OCAML_VERSION >= (4, 08, 0) (Load_path.get_paths ()) #else !Config.load_path diff --git a/lib/worker.cppo.ml b/lib/worker.cppo.ml index b7520d2..5c2a14b 100644 --- a/lib/worker.cppo.ml +++ b/lib/worker.cppo.ml @@ -5,7 +5,7 @@ let optbind : 'a option -> ('a -> 'b option) -> 'b option = fun x fn -> match x let log fmt = Format.kasprintf - (fun s -> Js_of_ocaml.(Firebug.console##log (Js.string s))) + (fun s -> Js_of_ocaml.(Console.console##log (Js.string s))) fmt (* OCamlorg toplevel in a web worker @@ -136,7 +136,7 @@ let sync_get url = Js.Opt.case (File.CoerceTo.arrayBuffer x##.response) (fun () -> - Firebug.console##log (Js.string "Failed to receive file"); + Console.console##log (Js.string "Failed to receive file"); None) (fun b -> Some (Typed_array.String.of_arrayBuffer b)) | _ -> None @@ -198,7 +198,11 @@ let init (init_libs : Toplevel_api_gen.init_libs) = #endif let old_loader = !load in (load := +#if OCAML_VERSION >= (5,2,0) + fun ~allow_hidden ~unit_name -> +#else fun ~unit_name -> +#endif let result = optbind (try Some (List.assoc (String.uncapitalize_ascii unit_name) cmi_files) with _ -> None) @@ -211,15 +215,22 @@ let init (init_libs : Toplevel_api_gen.init_libs) = filename = Sys.executable_name; cmi = read_cmi unit_name (Bytes.of_string x); +#if OCAML_VERSION >= (5,2,0) + visibility = Visible +#endif } +#if OCAML_VERSION >= (5,2,0) + | _ -> old_loader ~allow_hidden ~unit_name); +#else | _ -> old_loader ~unit_name); +#endif Js_of_ocaml.Worker.import_scripts (List.map (fun cma -> cma.Toplevel_api_gen.url) init_libs.cmas); functions := Some (List.map (fun func_name -> - Firebug.console##log (Js.string ("Function: " ^ func_name)); + Console.console##log (Js.string ("Function: " ^ func_name)); let func = Js.Unsafe.js_expr func_name in fun () -> Js.Unsafe.fun_call func [| Js.Unsafe.inject Dom_html.window |]) @@ -376,7 +387,7 @@ let run () = let open Js_of_ocaml in try (Js_top_worker_rpc.Idl.logfn := - fun s -> Js_of_ocaml.(Firebug.console##log s)); + fun s -> Js_of_ocaml.(Console.console##log s)); Server.complete complete; Server.exec execute; Server.setup setup; @@ -384,6 +395,6 @@ let run () = Server.typecheck typecheck_phrase; let rpc_fn = IdlM.server Server.implementation in Js_of_ocaml.Worker.set_onmessage (server rpc_fn); - Firebug.console##log (Js.string "All finished") + Console.console##log (Js.string "All finished") with e -> - Firebug.console##log (Js.string ("Exception: " ^ Printexc.to_string e)) + Console.console##log (Js.string ("Exception: " ^ Printexc.to_string e))