this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use Js bytestring for interop

+18 -13
+1 -1
src/client/dune
··· 1 1 (library 2 2 (name merlin_client) 3 3 (public_name merlin-js.client) 4 - (libraries protocol brr)) 4 + (libraries js_of_ocaml protocol brr))
+4 -3
src/client/merlin_client.ml
··· 70 70 include Brr_webworkers.Worker 71 71 72 72 let post t action = 73 - let bytes = Marshal.to_bytes action [] in 73 + let bytes = Marshal.to_string action [] 74 + |> Js_of_ocaml.Js.bytestring in 74 75 post t bytes 75 76 end 76 77 ··· 80 81 let worker = make_worker @@ Webworker.create @@ Jstr.of_string url in 81 82 let on_message m = 82 83 let m = Brr.Ev.as_type m in 83 - let data_marshaled : bytes = Brr_io.Message.Ev.data m in 84 - let data : Protocol.answer = Marshal.from_bytes data_marshaled 0 in 84 + let data_marshaled = Brr_io.Message.Ev.data m |> Js_of_ocaml.Js.to_bytestring in 85 + let data : Protocol.answer = Marshal.from_string data_marshaled 0 in 85 86 on_message worker data 86 87 in 87 88 let _listen =
+13 -9
src/worker/worker.ml
··· 1 1 open Merlin_utils 2 2 open Std 3 + open Js_of_ocaml 3 4 open Merlin_kernel 4 5 module Location = Ocaml_parsing.Location 5 6 6 7 let stdlib_path = "/static/cmis" 7 8 8 9 let sync_get url = 9 - let open Js_of_ocaml in 10 10 let x = XmlHttpRequest.create () in 11 11 x##.responseType := Js.string "arraybuffer"; 12 12 x##_open (Js.string "GET") (Js.string url) Js._false; ··· 16 16 Js.Opt.case 17 17 (File.CoerceTo.arrayBuffer x##.response) 18 18 (fun () -> 19 - Js_of_ocaml.Console.console##log (Js.string "Failed to receive file"); 19 + Console.console##log (Js.string "Failed to receive file"); 20 20 None) 21 21 (fun b -> Some (Typed_array.String.of_arrayBuffer b)) 22 22 | _ -> None ··· 46 46 match fetch (filename_of_module name) with 47 47 | Some content -> 48 48 let name = Filename.(concat stdlib_path filename) in 49 - Js_of_ocaml.Sys_js.create_file ~name ~content 49 + Sys_js.create_file ~name ~content 50 50 | None -> ()) dcs.dcs_toplevel_modules; 51 51 52 52 let new_load ~allow_hidden ~unit_name = ··· 62 62 then begin 63 63 match fetch filename with 64 64 | Some x -> 65 - Js_of_ocaml.Sys_js.create_file ~name:fs_name ~content:x; 65 + Sys_js.create_file ~name:fs_name ~content:x; 66 66 (* At this point we need to tell merlin that the dir contents 67 67 have changed *) 68 68 reset_dirs () ··· 78 78 List.iter static_cmis ~f:(fun { Protocol.sc_name; sc_content } -> 79 79 let filename = Printf.sprintf "%s.cmi" (String.uncapitalize_ascii sc_name) in 80 80 let name = Filename.(concat stdlib_path filename) in 81 - Js_of_ocaml.Sys_js.create_file ~name ~content:sc_content); 81 + Sys_js.create_file ~name ~content:sc_content); 82 82 Option.iter ~f:add_dynamic_cmis dynamic_cmis; 83 83 Protocol.Added_cmis 84 84 ··· 252 252 add_cmis cmis 253 253 254 254 let run () = 255 - Js_of_ocaml.Worker.set_onmessage @@ fun marshaled_message -> 256 - let action : Protocol.action = Marshal.from_bytes marshaled_message 0 in 255 + Console.console##log (Js.string "Worker running"); 256 + Worker.set_onmessage @@ fun marshaled_message -> 257 + Console.console##log (Js.string "Received message"); 258 + let action : Protocol.action = 259 + let str = Js.to_bytestring marshaled_message in 260 + Marshal.from_string str 0 in 257 261 let res = on_message action in 258 - let res = Marshal.to_bytes res [] in 259 - Js_of_ocaml.Worker.post_message res 262 + let res = Marshal.to_string res [] |> Js.bytestring in 263 + Worker.post_message res