PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/visualiser/msg.ml

http://github.com/hhughes/ocaml-frui
OCaml | 43 lines | 35 code | 8 blank | 0 comment | 2 complexity | ccf02477b3594876e96bd8229052ad43 MD5 | raw file
 1open Javascript
 2open Fvar
 3
 4class msg =
 5object
 6  val mutable froc_loc = Froc.return ()
 7  method froc_loc = froc_loc
 8  method set_froc_loc f = froc_loc <- f
 9end
10
11class fn =
12object
13  inherit msg
14  val mutable start = new fvar (-1.)
15  val mutable finish = new fvar (-1.)
16  val mutable name = ""
17  method set_name n = name <- n
18  method name = name
19  method start = start
20  method finish = finish
21end
22
23type event = E_msg of msg | E_fn of fn | Dummy
24
25module Msg =
26struct
27  external threadId : msg -> int = ".tid"
28  external ty : msg -> string = ".ty"
29  external timestamp : msg -> float = ".ts"
30  external name : msg -> string = ".name"
31  external desc : msg -> string = ".desc"
32  external misc : msg -> 'a = ".misc"
33end
34
35external new_Object : string -> msg js_array = "@eval"
36
37let unmarshall_json json = new_Object json
38
39let rec js_to_list msgs =
40  if msgs#_get_length > 0 then
41    msgs#pop :: (js_to_list msgs)
42  else []
43