text
stringlengths
12
786k
let rec print_approx_infos ppf = function Value_closure ( fundesc , approx ) -> Format . fprintf ppf " [ @< 2 > function % s @ arity % i " fundesc . fun_label fundesc . fun_arity ; if fundesc . fun_closed then begin Format . fprintf ppf " @ ( closed ) " end ; if fundesc . fu...
let print_spaced_string s = printf " % s " s
let print_cma_infos ( lib : Cmo_format . library ) = printf " Force custom : % s \ n " ( if lib . lib_custom then " YES " else " no " ) ; printf " Extra C object files " ; : List . iter print_spaced_string ( List . rev lib . lib_ccobjs ) ; printf " \ nExtra C options...
let print_cmi_infos name sign comps crcs = printf " Unit name : % s \ n " name ; printf " Interfaces imported :\ n " ; List . iter print_name_crc crcs
let print_general_infos name crc defines cmi cmx = printf " Name : % s \ n " name ; printf " CRC of implementation : % s \ n " ( Digest . to_hex crc ) ; printf " Globals defined :\ n " ; List . iter print_line defines ; printf " Interfaces imported :\ n " ; List . iter print...
let print_cmx_infos ( ui , crc ) = print_general_infos ui . ui_name crc ui . ui_defines ui . ui_imports_cmi ui . ui_imports_cmx ; printf " Approximation :\ n " ; Format . fprintf Format . std_formatter " % a . " @ print_approx_infos ui . ui_approx ; let pr_funs _ fns = List . ...
let print_cmxs_infos header = List . iter ( fun ui -> print_general_infos ui . dynu_name ui . dynu_crc ui . dynu_defines ui . dynu_imports_cmi ui . dynu_imports_cmx ) header . dynu_units
let p_title title = printf " % s :\ n " title
let p_section title = function | [ ] -> ( ) | l -> p_title title ; List . iter print_name_crc l
let p_list title print = function | [ ] -> ( ) | l -> p_title title ; List . iter print l
let dump_byte ic = Bytesections . read_toc ic ; let toc = Bytesections . toc ( ) in let toc = List . sort Pervasives . compare toc in List . iter ( fun ( section , _ ) -> try let len = Bytesections . seek_section ic section in if len > 0 then match section with | " CRCS " -> p_se...
let read_dyn_header filename ic = let tempfile = Filename . temp_file " objinfo " " . out " in let helper = Filename . concat Config . standard_library " objinfo_helper " in try try_finally ( fun ( ) -> let rc = Sys . command ( sprintf " % s % s > % s " ( Filename . quote ...
let dump_obj filename = printf " File % s \ n " filename ; let ic = open_in_bin filename in let len_magic_number = String . length cmo_magic_number in let magic_number = String . create len_magic_number in really_input ic magic_number 0 len_magic_number ; if magic_number = cmo_magic_number then begi...
let main ( ) = for i = 1 to Array . length Sys . argv - 1 do dump_obj Sys . argv . ( i ) done ; exit 0
let _ = main ( )
let camlp4o = ref " camlp4o "
let camlp4r = ref " camlp4r "
let ocamllex = ref " ocamllex "
let ocamlyacc = ref " ocamlyacc "
let ocamlc = ref " ocamlc "
let ocamlopt = ref " ocamlopt "
let ocamlfind = ref " ocamlfind "
let packs = ref [ ]
let sources = ref [ ]
let use_ocamllex = ref false
let use_camlp4 = ref true
let use_ocamlc = ref false
let use_ocamlfind = ref false
let revised = ref false
let ppopt = ref [ ]
type pp = string -> ( Pipeline . command * string list )
let pp : pp option ref = ref None
let ppsrcloc = ref None
let exe s = match Sys . os_type with | " Win32 " | " Cygwin " -> if Filename . check_suffix s " . exe " then s else s ^ " . exe " | " Unix " | _ -> s
let import path = let src = !+ path in let dst = Filename . basename src in let head = match ! pp , ! ppsrcloc , ! revised with | Some _ , Some f , _ -> f src | _ , _ , false -> sprintf " # 1 % S ; ; \ n " src | _ , _ , true -> sprintf " # 1 % S ; \ n " src in...
let file_kind file = if Filename . check_suffix file " . mli " then ` Mli else if Filename . check_suffix file " . ml " then ` Ml else if Filename . check_suffix file " . mll " then ` Mll else if Filename . check_suffix file " . mly " then ` Mly else try let prefix = Filename ....
let extra_command file = match file_kind file with | ` Mli | ` Ml -> ( [ ] , [ file ] ) | ` Mll -> ( [ command [ ! ocamllex ; file ; " - q " ] ] , [ ( Filename . chop_extension file ) ^ " . ml " ] ) | ` Mly -> let p = Filename . chop_extension fi...
let pp_command file = match ! pp with | None -> [ ] , [ file ] | Some f -> let cmd , files = f file in ( [ cmd ] , files )
let extra_commands sources = let input_files1 = List . map Filename . basename sources in let cmds1 , input_files2 = List . split ( List . map pp_command input_files1 ) in let cmds2 , files = List . split ( List . map extra_command ( List . flatten input_files2 ) ) in ( List . flat...
let ocaml_command input = let really_use_ocamlfind = match ! use_ocamlfind , ! packs with | true , _ | _ , _ :: _ -> true | _ -> false in let compiler = if really_use_ocamlfind then if ! use_ocamlc then [ ! ocamlfind ; " ocamlc " ] else [ ! ocamlfind ; " ocamlopt " ] else if...
let compile source result = let internal_input = if ! use_ocamllex then " ocamlscript_main . mll " else " ocamlscript_main . ml " in let before , xcommands , main_command , internal_output = ocaml_command internal_input in let input = [ internal_input , source ] in let output = [ interna...
let input_buffer = Buffer . create 16383
let input_function ic buf len = let len = input ic buf 0 len in Buffer . add_substring input_buffer buf 0 len ; len
let output_buffer = Buffer . create 16383
let modified = ref false
let convert buffer = let input_pos = ref 0 in let copy_input stop = Buffer . add_substring output_buffer ( Buffer . contents input_buffer ) ! input_pos ( stop - ! input_pos ) ; input_pos := stop in let last = ref ( EOF , 0 , 0 ) in try while true do let token = Lexer299 . token buffe...
let convert_file name = let ic = open_in name in Buffer . clear input_buffer ; Buffer . clear output_buffer ; modified := false ; begin try convert ( Lexing . from_function ( input_function ic ) ) ; close_in ic with exn -> close_in ic ; raise exn end ; if ! modified then begin let backup ...
let _ = if Array . length Sys . argv < 2 || Sys . argv . ( 1 ) = " - h " || Sys . argv . ( 1 ) = " - help " then begin print_endline " Usage : ocaml299to3 < source file > . . . " ; print_endline " Description " ; : print_endline " Convert Objective Caml 2 ...
module GSourceView_params = struct let syntax ( ) = let syntax_mgr = GSourceView3 . source_language_manager ~ default : true in if syntax_mgr # search_path <> [ ! Cfg . datadir ] then syntax_mgr # set_search_path [ ! Cfg . datadir ] ; let syn = syntax_mgr # language " ocp - edit - oc...
type reindent_needed = No_reindent | Reindent_delayed of int | Reindent_line of int | Reindent_after of int | Reindent_full
type t = { mutable filename : string option ; gbuffer : GSourceView3 . source_buffer ; mutable need_reindent : reindent_needed ; eval_mark : GSourceView3 . source_mark ; eval_mark_end : GSourceView3 . source_mark ; mutable block_marks : ( GSourceView3 . source_mark * GSourceView3 . sourc...
let is_modified buf = buf . gbuffer # modified
let unmodify buf = buf . gbuffer # set_modified false
let filename buf = buf . filename
let filename_default ( ? default " = New ml file " ) buf = match buf . filename with | Some f -> Filename . basename f | None -> default
let set_filename buf name = buf . filename <- Some name
module Tags = struct let phrase = let t = GText . tag ~ name " : phrase " ( ) in t # set_property ( ` FOREGROUND " grey60 " ) ; t # set_property ( ` INDENT ( 2 * ! Cfg . char_width ) ) ; t let stdout = let t = GText . tag ~ name " : stdout " ( ) in t # set_pr...
let phrase_bounds buf ( iter : GText . iter ) = let rec find ( start , stop ) = function | ( start_mark , end_mark ) :: r -> let bop = buf . gbuffer # get_iter_at_mark start_mark # coerce in let eop = buf . gbuffer # get_iter_at_mark end_mark # coerce in if eop # offset >= iter # of...
let get_phrases buf ~ start ~ stop = let min a b = if a # offset <= b # offset then a else b in let max a b = if a # offset >= b # offset then a else b in let rec find = function | ( start_mark , end_mark ) :: r -> let bop = buf . gbuffer # get_iter_at_mark start_mark # coerce in let eop = bu...
let last_end_of_phrase buf ( iter : GText . iter ) = let rec find acc = function | ( _ , end_mark ) :: r -> let eop = buf . gbuffer # get_iter_at_mark end_mark # coerce in if eop # offset >= iter # offset then acc else find eop r | [ ] -> acc in find buf . gbuffer # start_iter buf . ...
let reindent_line n = Reindent_line n
let reindent_after n = Reindent_after n
let reindent_max r1 r2 = match r1 , r2 with | No_reindent , r | r , No_reindent -> r | Reindent_full , _ | _ , Reindent_full -> Reindent_full | Reindent_delayed l1 , Reindent_delayed l2 when l1 = l2 -> Reindent_delayed l1 | ( Reindent_line l1 | Reindent_delayed l1 ) , ( Reindent_line l...
let indent_config = IndentConfig . update_from_string IndentConfig . default " apprentice "
let reindent t = let buf = t . gbuffer in if buf # end_iter # line_offset > 0 then ( let cursor = buf # create_mark ( buf # get_iter_at_mark ` INSERT ) in buf # insert ~ iter : buf # end_iter " \ n " ; buf # place_cursor ~ where ( : buf # get_iter_at_mark ( ` MARK cursor ) ) ...
let trigger_reindent ? cont t reindent_needed = ( match cont with | None -> ( ) | Some ct -> t . on_reindent <- fun ( ) -> t . on_reindent ( ) ; ct ( ) ) ; match t . need_reindent with | No_reindent | Reindent_delayed _ -> t . need_reindent <- reindent_max t . need_reinden...
let raw_contents buf = buf . gbuffer # get_text ( )
let get_indented_text ~ start ~ stop buf = let indent_at it = List . fold_left ( fun indent tag -> match Tags . get_indent tag with | None -> indent | Some n -> n ) 0 it # tags in let out = Buffer . create 256 in let rec get_lines start = if start # offset >= stop # offset then ( ) else l...
let contents buf = get_indented_text ~ start : buf . gbuffer # start_iter ~ stop : buf . gbuffer # end_iter buf
let create ? name ( ? contents " " ) = ( ) = let gbuffer = if not ( Glib . Utf8 . validate contents ) then Tools . recover_error " Could not open % s because it contains invalid utf - 8 \ characters . Please fix it or choose another file " ( match name with Some n -> n | None -...
let setup_indent buf = let gbuf = buf . gbuffer in let rec contains_sp text i = if i >= String . length text then false else match text . [ i ] with | ' a ' . . ' z ' | ' A ' . . ' Z ' | ' 0 ' . . ' 9 ' | ' ' ' \ | ' ` ' ' | _ ' -> contains_sp...
let get_selection buf = let gbuf = buf . gbuffer in if gbuf # has_selection then let start , stop = gbuf # selection_bounds in Some ( get_indented_text buf ~ start ~ stop ) else None
module type ELIOM = sig val server_dir : Ocamlbuild_plugin . Pathname . t val type_dir : Ocamlbuild_plugin . Pathname . t val client_dir : Ocamlbuild_plugin . Pathname . t end
module type INTERNALS = sig val with_eliom_ppx : ( [ < ` Client | ` Server ] -> string ) option val with_package : string -> string end
module MakeIntern ( I : INTERNALS ) ( Eliom : ELIOM ) = struct let inferred_type_prefix = " eliom_inferred_type_ " let sed_rule name ~ dep ~ prod scripts = rule name ~ dep ~ prod ( fun env _build -> let dep = env dep and prod = env prod in let script_args = List . map ( fun script -> S ...
module Make ( Eliom : ELIOM ) = MakeIntern ( struct let with_eliom_ppx = None let with_package = Printf . sprintf " package ( % s ) " end ) ( Eliom )
type error = | Subcommand_failed | Subcommand_got_signal | Io_error | Exceptionl_condition
type task = unit -> string ; ;
type job = { job_id : int * int ; job_command : string ; job_next : task list ; job_result : bool ref ; job_stdout : in_channel ; job_stdin : out_channel ; job_stderr : in_channel ; job_buffer : Buffer . t ; mutable job_dying : bool ; } ; ;
module JS = Set . Make ( struct type t = job let compare = compare end ) ; ;
module FDM = Map . Make ( struct type t = file_descr let compare = compare end ) ; ;
let print_unix_status oc = function | WEXITED x -> fp oc " exit % d " x | WSIGNALED i -> fp oc " signal % d " i | WSTOPPED i -> fp oc " stop % d " i ; ;
let print_job_id oc ( x , y ) = fp oc " % d . % d " x y ; ;
let output_lines prefix oc buffer = let u = Buffer . contents buffer in let m = String . length u in let output_line i j = output_string oc prefix ; output oc u i ( j - i ) ; output_char oc ' \ n ' in let rec loop i = if i = m then ( ) else begin try let j = String . index_from u i ' \...
let execute ( ? max_jobs = max_int ) ( ? ticker = ignore ) ( ? period = 0 . 1 ) ( ? display ( = fun f -> f Pervasives . stdout ) ) ~ exit ( commands : task list list ) = let batch_id = ref 0 in let env = environment ( ) in let jobs = ref JS . empty in let jobs_active ...
type command = Command . t = Seq of command list | Cmd of spec | Echo of string list * string | Nop | N | S of spec list | A of string | P of string | Px of string | Sh of string | T of Tags . t | V of string | Quote of spec
type env = Pathname . t -> Pathname . t
type builder = Pathname . t list list -> ( Pathname . t , exn ) Ocamlbuild_pack . My_std . Outcome . t list
type action = env -> builder -> Command . t
type hook = Ocamlbuild_pack . Hooks . message = | Before_hygiene | After_hygiene | Before_options | After_options | Before_rules | After_rules
let report_error f = function | Unix . Unix_error ( err , fun_name , arg ) -> fprintf f " % s : % S failed " Sys . argv . ( 0 ) fun_name ; if String . length arg > 0 then fprintf f " on % S " arg ; fprintf f " : % s " ( Unix . error_message err ) | exn -> raise ex...
let mkstat unix_stat x = let st = try unix_stat x with Unix . Unix_error _ as e -> raise ( Sys_error ( My_std . sbprintf " % a " report_error e ) ) in { stat_key = sprintf " ( % d , % d ) " st . Unix . st_dev st . Unix . st_ino ; stat_file_kind = match st . Unix . st_k...
let is_link s = ( Unix . lstat s ) . Unix . st_kind = Unix . S_LNK
let at_exit_once callback = let pid = Unix . getpid ( ) in at_exit begin fun ( ) -> if pid = Unix . getpid ( ) then callback ( ) end
let run_and_open s kont = let ic = Unix . open_process_in s in let close ( ) = match Unix . close_process_in ic with | Unix . WEXITED 0 -> ( ) | Unix . WEXITED _ | Unix . WSIGNALED _ | Unix . WSTOPPED _ -> failwith ( Printf . sprintf " Error while running : % s " s ) in let ...
let stdout_isatty ( ) = Unix . isatty Unix . stdout && try Unix . getenv " TERM " <> " dumb " with Not_found -> true
let execute_many = let exit i = raise ( My_std . Exit_with_code i ) in let exit = function | Ocamlbuild_executor . Subcommand_failed -> exit Exit_codes . rc_executor_subcommand_failed | Ocamlbuild_executor . Subcommand_got_signal -> exit Exit_codes . rc_executor_subcommand_got_signal | Ocamlbuild_...
let setup ( ) = implem . is_degraded <- false ; implem . stdout_isatty <- stdout_isatty ; implem . gettimeofday <- Unix . gettimeofday ; implem . report_error <- report_error ; implem . execute_many <- execute_many ; implem . readlink <- Unix . readlink ; implem . run_and_open ...
let compargs = ref ( [ ] : string list )
let profargs = ref ( [ ] : string list )