text
stringlengths
12
786k
let get_responseURL x = x ## responseURL
let get_responseXML x = Js . Null . toOption x ## responseXML
let get_status x = x ## status
let get_statusText x = x ## statusText
let set_timeout t x = x ## timeout #= t
let get_timeout x = x ## timeout
let set_withCredentials b x = x ## withCredentials #= b
let get_withCredentials x = x ## withCredentials
let set_onabort cb x = x ## onabort #= cb
let get_onabort x = x ## onabort
let set_onerror cb x = x ## onerror #= cb
let get_onerror x = x ## onerror
let set_onload cb x = x ## onload #= cb
let get_onload x = x ## onload
let set_onloadstart cb x = x ## onloadstart #= cb
let get_onloadstart x = x ## onloadstart
let set_onprogress cb x = x ## onprogress #= cb
let get_onprogress x = x ## onprogress
let set_ontimeout cb x = x ## ontimeout #= cb
let get_ontimeout x = x ## ontimeout
let set_onloadend cb x = x ## onloadend #= cb
let get_onloadend x = x ## onloadend
let rec check_break_expr in_loop ( expr , _ ) = match expr with | VarExpr _ -> true | NilExpr -> true | IntExpr _ -> true | StringExpr _ -> true | CallExpr { call_args ; _ } -> List . for_all ( check_break_expr in_loop ) call_args | OpExpr { op_left ; op_right ; _ } -> check...
let assert_break expr = if not ( check_break_expr false expr ) then failwith " break outside of a loop "
let compare_date ( i1 : Rss2 . item ) ( i2 : Rss2 . item ) = let open Rss2 in match i1 . pubDate , i2 . pubDate with | Some d1 , Some d2 -> Syndic . Date . compare d2 d1 | None , Some _ -> 1 | Some _ , None -> - 1 | None , None -> 0
let post = lazy ( let xml = ` String ( 0 , Http . get ( cwn_base_url ^ " cwn . rss " ) ) in let feed = Syndic . Rss2 . parse ( Xmlm . make_input xml ) in let posts = List . sort compare_date feed . Rss2 . items in match posts with p :: _ -> p | [ ] -> failwith " we...
let cwn_date = lazy ( match ( Lazy . force post ) . Rss2 . pubDate with | Some d -> d | None -> failwith " cwn_date " )
let cwn_html_date ( ) = let d = Lazy . force cwn_date in [ Nethtml . Data ( sprintf " % s % d , % d " ( Utils . en_string_of_month ( Date . month d ) ) ( Date . day d ) ( Date . year d ) ) ]
let rec get_elements tag = function | [ ] -> [ ] | Nethtml . Data _ :: tl -> get_elements tag tl | Nethtml . Element ( t , _ , c ) :: tl -> let e = if t = tag then c else get_elements tag c in e @ get_elements tag tl
let rec drop_until n tag = function | [ ] -> [ ] | Nethtml . Data _ :: tl -> drop_until n tag tl | ( Nethtml . Element ( t , _ , _ ) :: tl ) as l -> if t = tag then if n <= 1 then l else drop_until ( n - 1 ) tag tl else drop_until n tag tl
let rec rm_tags tag = function | [ ] -> [ ] | ( Nethtml . Data _ as e ) :: tl -> e :: rm_tags tag tl | Nethtml . Element ( t , args , sub ) :: tl -> if t = tag then rm_tags tag tl else Nethtml . Element ( t , args , rm_tags tag sub ) :: rm_tags tag tl
let cwn_html_page ( ) = let d = Lazy . force cwn_date in let url = cwn_base_url ^ sprintf " % d . % 02d . % 02d . html " ( Date . year d ) ( Utils . int_of_month ( Date . month d ) ) ( Date . day d ) in let content = Http . get url in let html = Nethtml . parse ( ...
let cwn_html_summary ( ) = match ( Lazy . force post ) . Rss2 . story with | Rss2 . All ( _ , _ , content ) -> let open Nethtml in Nethtml . parse ( new Netchannels . input_string content ) ~ dtd : Utils . relaxed_html40_dtd | Rss2 . Title _ | Rss2 . Description _ -> fa...
let ( ) = let contents = ref false in let date = ref false in let specs = [ ( " -- contents " , Arg . Set contents , " output the contents of the latest CWN " ) ; ( " -- date " , Arg . Set date , " output the date of the lastest CWN " ) ; ] in let usage = " weekl...
module Where = Dune_rpc_private . Where . Make ( struct type ' a t = ' a let return a = a module O = struct let ( let + ) x f = f x let ( let * ) x f = f x end end ) ( struct let read_file f = Ok ( Io . String_path . read_file f ) let analyze_path s = match ( Unix . stat s ) ...
let build_dir = lazy ( let build_dir = Path . Build . to_string Path . Build . root in match String . drop_prefix build_dir ~ prefix ( : Sys . getcwd ( ) ^ " " ) / with | None -> build_dir | Some s -> Filename . concat " . " s )
let get ( ) = let env = Env . get Env . initial in match Where . get ~ env ~ build_dir ( : Lazy . force build_dir ) with | Ok s -> s | Error exn -> User_error . raise [ Pp . text " Unable to find dune rpc address " ; Exn . pp exn ]
let default ( ) = Where . default ~ build_dir ( : Lazy . force build_dir ) ( )
let to_socket = function | ` Unix p -> Unix . ADDR_UNIX p | ` Ip ( ` Host host , ` Port port ) -> Unix . ADDR_INET ( Unix . inet_addr_of_string host , port )
module Response = struct module Device_info = struct module Session_info = struct module Connection_info = struct type t = { ip : string option ; last_seen : int option ; user_agent : string option ; } [ @@ deriving accessor ] let encoding = let to_tuple t = t . ip , t . last_seen , t ....
let shared_constants_class_name = " pack . ocamljavaConstants " |> UTF8 . of_string |> Name . make_for_class_from_external |> ref
module ClassNameMap = Map . Make ( struct type t = Name . for_class let compare x y = Name . compare_for_class x y end ) end
let constants_name_to_main_name : Name . for_class ClassNameMap . t ref = ref ClassNameMap . empty
let constant_fields : ( Field . t list ) list ClassNameMap . t ref = ref ClassNameMap . empty
let is_constants_class cn = ClassNameMap . mem cn ! constants_name_to_main_name
let main_class_of_constants_class cn = ClassNameMap . find cn ! constants_name_to_main_name
let additional_fields cn = try ClassNameMap . find cn ! constant_fields with Not_found -> [ ] inherit ClassTraversal . default_class_definition_iterator method ! class_definition ( _ : AccessFlag . for_class list ) list ( cn : Name . for_class ) for_class ( _ : Name . for_class option ) o...
module IntSet = Set . Make ( struct type t = int let compare ( x : int ) int ( y : int ) int = Pervasives . compare x y end ) end
let extract_ints l = List . fold_left ( fun acc elem -> match elem with | Annotation . Int_value x -> IntSet . add ( Int32 . to_int x ) x acc | _ -> assert false ) false IntSet . empty l
let linked_classes : UTF8 . t list option ref = ref None
type indices = { read_indices : IntSet . t ; written_indices : IntSet . t ; }
let indices : ( UTF8 . t * indices ) indices list ClassNameMap . t ref = ref ClassNameMap . empty
let merge_maps ( dst : indices ClassNameMap . t ) t ( name , uses ) uses = let class_name = Name . make_for_class_from_external name in let value = try let old = ClassNameMap . find class_name dst in { read_indices = IntSet . union old . read_indices uses . read_indices ; written_indices = ...
let get_used_indices ( ) = ClassNameMap . fold ( fun user used acc -> let merge = match ! linked_classes with | Some l -> List . exists ( fun x -> UTF8 . equal x ( Name . external_utf8_for_class user ) user ) user l | None -> false in if merge then begin List . fold_left merge_maps acc used...
let make_remove_indices_function ( ) = let used_indices = get_used_indices ( ) in if ! Args . verbose then begin used_indices |> ClassNameMap . iter ( fun cn { read_indices ; written_indices } -> cn |> Name . external_utf8_for_class |> UTF8 . to_string |> Printf . printf " indices for %...
let iter_archive filename = let make_iterator x = new iterator x in ArchiveTraversal . iter_file make_iterator filename
let shared_constants : UTF8 . Set . t ref = ref UTF8 . Set . empty
let add_shared_constant name = shared_constants := UTF8 . Set . add ( Name . utf8_for_field name ) name ! shared_constants
let empty_cstr = let code = Attribute ( { . max_stack = u2 1 ; max_locals = u2 1 ; code = [ Instruction . ALOAD_0 ; Instruction . INVOKESPECIAL ( Names . object_ , Misc . make_method_name " < init " , > ( [ ] , ` Void ) Void ) Void ; Instruction . RETURN ] ; exceptio...
let push_int32 = function | ( - 1l ) 1l -> Instruction . ICONST_M1 | 0l -> Instruction . ICONST_0 | 1l -> Instruction . ICONST_1 | 2l -> Instruction . ICONST_2 | 3l -> Instruction . ICONST_3 | 4l -> Instruction . ICONST_4 | 5l -> Instruction . ICONST_5 | n when n >= ( - 128l ) ...
let push_int64 = function | 0L -> [ Instruction . LCONST_0 ] | 1L -> [ Instruction . LCONST_1 ] | 2L -> [ Instruction . ICONST_2 ; Instruction . I2L ] | 3L -> [ Instruction . ICONST_3 ; Instruction . I2L ] | 4L -> [ Instruction . ICONST_4 ; Instruction . I2L ] | 5L ...
let push_double x = if x = 0 . 0 then Instruction . DCONST_0 else if x = 1 . 0 then Instruction . DCONST_1 else Instruction . LDC2_W ( ` Double x ) x
let compile_shared_constant_class ( ) = let fields_and_inits = List . map ( fun name -> let underscore = UTF8 . index_from name 0 ( UChar . of_char ' _ ' ) ' _ ' in let typ = UTF8 . substring name 0 ( pred underscore ) underscore in let hexa = UTF8 . substring name ( succ underscore ) ...
type syntax_map = string Hstr . t
let driver : syntax_map = Hstr . create 16
let ( ) = List . iter ( fun ( x , y ) -> Hstr . add driver x y ) [ ( " integer " , " int " ) ; ( " int " , " int " ) ; ( " " , + " infix " ) ; + ( " " , * " infix " ) ; * ( " " , - " infix " ) ; - ( " " , ...
let query_syntax str = Hstr . find_opt driver str
type ' a widget = { config : Otoml . t ; func : Defaults . env -> Otoml . t -> ' a Soup . node -> ( unit , string ) result }
type ' a widgets = string list * ( string , ' a widget ) Hashtbl . t
let find_widget plugins name = let plugin_w = Hashtbl . find_opt plugins name in let builtin_w = List . assoc_opt name Builtin_widgets . widgets in match plugin_w , builtin_w with | Some p , Some _ -> let ( ) = Logs . warn @@ fun m -> m " Widget name % s is redefined by a plugin " name in ...
let get_widget_config config widget = let widget_tbl = Config . find_table_opt [ Defaults . widgets_table ; widget ] config in match widget_tbl with | Some widget_tbl -> widget_tbl | None -> failwith @@ Printf . sprintf " Trying to lookup a non - existent widget % s " widget
let list_widgets config = let ws = Config . find_table_opt [ Defaults . widgets_table ] config >>= ( fun x -> Some ( Otoml . list_table_keys x ) ) in match ws with | None -> [ ] | Some ws ' -> ws '
let add_widget hash name widget_func widget_config = let widget_rec = { config = widget_config ; func = widget_func } in Hashtbl . add hash name widget_rec
let rec _load_widgets settings config plugins ws hash = match ws with | [ ] -> ( ) | w :: ws ' -> let widget_config = get_widget_config config w in let name = OH . find_string_opt widget_config [ " widget " ] in let fail msg = Printf . ksprintf failwith " Error in [ widgets . % s ...
let get_widget_order hash = let format_bad_deps ds = let format_bad_dep ( n , ns ) = Printf . sprintf " Widget " \% s " \ depends on non - existent widgets : % s " n ( String . concat " , " ns ) in let bad_deps = List . map format_bad_dep ds |> String . concat " \ n " in P...
let partition_widgets all_widgets index_deps = let rec aux index_deps before_index after_index = match index_deps , after_index with | [ ] , ws -> Ok ( List . rev before_index , ws ) | _ , w :: ws ' -> let index_deps = CCList . remove ~ eq ( ) := ~ key : w index_deps in aux index_...
let load_widgets settings config plugins = let widgets_hash = Hashtbl . create 1024 in match config with | None -> Ok widgets_hash | Some config -> let ws = list_widgets config in try let ( ) = _load_widgets settings config plugins ws widgets_hash in Ok widgets_hash with Failure msg -> Error msg
let get_widgets settings config plugins index_deps = let ( let ) * = Stdlib . Result . bind in let * wh = load_widgets settings config plugins in let * wo = get_widget_order wh in let * before_index , after_index = partition_widgets wo index_deps in let ( ) = Logs . debug @@ fun m -> m " W...
let widget_should_run settings name widget build_profiles site_dir page_file = let disabled = Config . find_bool_or ~ default : false widget . config [ " disabled " ] in if disabled then let ( ) = Logs . debug @@ fun m -> m " Widget " \% s " \ is disabled in the configuration " name i...
type handler = { suffix : string ; label : string ; export : string -> unit }
type configuration = { id : string ; handlers : handler list ; show : bool React . signal }
let export_format_id ( configuration : configuration ) : string = Format . sprintf " export_ % s_select " configuration . id
let export_filename_id ( configuration : configuration ) : string = Format . sprintf " export_ % s_filename " configuration . id
let export_button_id ( configuration : configuration ) : string = Format . sprintf " export_ % s_button " configuration . id
let export_data_label ( configuration : configuration ) : string = Format . sprintf " export_ % s_label " configuration . id
let export_form_id ( configuration : configuration ) : string = Format . sprintf " export_ % s_form " configuration . id
let inline_content ( configuration : configuration ) = let export_filename = Html . input ~ a [ : Html . a_id ( export_filename_id configuration ) ; Html . a_input_type ` Text ; Html . a_class [ " form - control " ] ; Html . a_placeholder " file name " ] ( ) in let ex...
let content configuration = Html . form ~ a [ : Html . a_id ( export_form_id configuration ) ; Html . a_class [ " form - inline " ] ; ] ( inline_content configuration )
let onload ( configuration : configuration ) = let export_button : Dom_html . buttonElement Js . t = Ui_common . id_dom ( export_button_id configuration ) in let export_filename : Dom_html . inputElement Js . t = Ui_common . id_dom ( export_filename_id configuration ) in let export_format ...
let export_svg ? svg_style_id ( ~ svg_div_id : string ) ( ) : handler = { suffix = " svg " ; label = " svg " ; export = fun filename -> Common . plotSVG ? plotStyleId : svg_style_id svg_div_id filename filename }
let export_png ? svg_style_id ( ~ svg_div_id : string ) ( ) : handler = { suffix = " png " ; label = " png " ; export = fun filename -> Common . plotPNG ? plotStyleId : svg_style_id svg_div_id filename filename }
let export_json ( ~ serialize_json : unit -> string ) : handler = { suffix = " json " ; label = " json " ; export = fun filename -> let data = Js . string ( serialize_json ( ) ) in Common . saveFile ~ data ~ mime " : application / json " ~ filename : filename }
type comment = [ ]
type variable_step = [ ]
type fixed_step = [ ]
type bed_graph_value = string * int * int * float
type item = [ comment | variable_step | fixed_step | ` bed_graph_value of bed_graph_value ]
let module_error e = Error ( ` wig e ) e
module Tags = struct type t = { allow_empty_lines : bool ; sharp_comments : bool ; } [ @@ deriving sexp ] sexp let default = { allow_empty_lines = false ; sharp_comments = true } true let to_string t = sexp_of_t t |> Sexplib . Sexp . to_string let of_string s = try Ok ( Sexplib . Sexp ...
module Error = struct type parsing = [ | ` cannot_parse_key_values of Pos . t * string | ` empty_line of Pos . t | ` incomplete_input of Pos . t * string list * string option | ` missing_chrom_value of Pos . t * string | ` missing_start_value of Pos . t * string | ` missing_step_value of...