text stringlengths 0 601k |
|---|
let cCAMLtoTKtextTag x = TkToken x ; ; |
let cTKtoCAMLtextTag x = x ; ; |
let ppTextModifier = function CharOffset n -> if n > 0 then " " + ^ ( string_of_int n ) ^ " chars " else if n = 0 then " " else ( string_of_int n ) ^ " chars " | LineOffset n -> if n > 0 then " " + ^ ( string_of_int n ) ^ " lines " else if n = 0 then " " else ( string_of_int n ) ^ " lines " | LineStart -> " linestart "... |
let ppTextIndex = function | TextIndexNone -> " " | TextIndex ( base , ml ) -> match cCAMLtoTKindex index_text_table base with | TkToken ppbase -> List . fold_left ( ) ^ ppbase ( List . map ppTextModifier ml ) | _ -> assert false ; ; |
let cCAMLtoTKtextIndex i = TkToken ( ppTextIndex i ) ; ; ## else |
let cCAMLtoTKtextIndex ( i : textIndex ) = let ppTextModifier = function | ` Char n -> if n > 0 then " " + ^ ( string_of_int n ) ^ " chars " else if n = 0 then " " else ( string_of_int n ) ^ " chars " | ` Line n -> if n > 0 then " " + ^ ( string_of_int n ) ^ " lines " else if n = 0 then " " else ( string_of_int n ) ^ "... |
let reason_with_fallback env fallback = match Environments . lookup Builtin_variables . reason env with | None -> fallback | Some reason -> reason |
let pass = make " pass " ( fun _log env -> let reason = reason_with_fallback env " the pass action always succeeds " in let result = Result . pass_with_reason reason in ( result , env ) ) |
let skip = make " skip " ( fun _log env -> let reason = reason_with_fallback env " the skip action always skips " in let result = Result . skip_with_reason reason in ( result , env ) ) |
let fail = make " fail " ( fun _log env -> let reason = reason_with_fallback env " the fail action always fails " in let result = Result . fail_with_reason reason in ( result , env ) ) |
let cd = make " cd " ( fun _log env -> let cwd = Environments . safe_lookup Builtin_variables . cwd env in begin try Sys . chdir cwd ; ( Result . pass , env ) with _ -> let reason = " Could not chidir to " " \ ^ cwd ^ " " " \ in let result = Result . fail_with_reason reason in ( result , env ) end ) |
let dumpenv = make " dumpenv " ( fun log env -> Environments . dump log env ; ( Result . pass , env ) ) |
let hasinstrumentedruntime = make " hasinstrumentedruntime " ( Actions_helpers . pass_or_skip ( Ocamltest_config . has_instrumented_runtime ) " instrumented runtime available " " instrumented runtime not available " ) |
let hasunix = make " hasunix " ( Actions_helpers . pass_or_skip ( Ocamltest_config . libunix <> None ) " unix library available " " unix library not available " ) |
let libunix = make " libunix " ( Actions_helpers . pass_or_skip ( Ocamltest_config . libunix = Some true ) " libunix available " " libunix not available " ) |
let libwin32unix = make " libwin32unix " ( Actions_helpers . pass_or_skip ( Ocamltest_config . libunix = Some false ) " libwin32unix available " " libwin32unix not available " ) |
let hassysthreads = make " hassysthreads " ( Actions_helpers . pass_or_skip Ocamltest_config . systhreads " systhreads library available " " systhreads library not available " ) |
let hasstr = make " hasstr " ( Actions_helpers . pass_or_skip Ocamltest_config . str " str library available " " str library not available " ) |
let get_OS ( ) = Sys . safe_getenv " OS " |
let windows = make " windows " ( Actions_helpers . pass_or_skip ( get_OS ( ) = windows_OS ) " running on Windows " " not running on Windows " ) |
let not_windows = make " not - windows " ( Actions_helpers . pass_or_skip ( get_OS ( ) <> windows_OS ) " not running on Windows " " running on Windows " ) |
let is_bsd_system s = match s with | " bsd_elf " | " netbsd " | " freebsd " | " openbsd " -> true | _ -> false |
let bsd = make " bsd " ( Actions_helpers . pass_or_skip ( is_bsd_system Ocamltest_config . system ) " on a BSD system " " not on a BSD system " ) |
let not_bsd = make " not - bsd " ( Actions_helpers . pass_or_skip ( not ( is_bsd_system Ocamltest_config . system ) ) " not on a BSD system " " on a BSD system " ) |
let macos = make " macos " ( Actions_helpers . pass_or_skip ( Ocamltest_config . system = macos_system ) " on a MacOS system " " not on a MacOS system " ) |
let arch32 = make " arch32 " ( Actions_helpers . pass_or_skip ( Sys . word_size = 32 ) " 32 - bit architecture " " non - 32 - bit architecture " ) |
let arch64 = make " arch64 " ( Actions_helpers . pass_or_skip ( Sys . word_size = 64 ) " 64 - bit architecture " " non - 64 - bit architecture " ) |
let arch_arm = make " arch_arm " ( Actions_helpers . pass_or_skip ( String . equal Ocamltest_config . arch " arm " ) " Target is ARM architecture " " Target is not ARM architecture " ) |
let arch_arm64 = make " arch_arm64 " ( Actions_helpers . pass_or_skip ( String . equal Ocamltest_config . arch " arm64 " ) " Target is ARM64 architecture " " Target is not ARM64 architecture " ) let arch_amd64 = make " arch_amd64 " ( Actions_helpers . pass_or_skip ( String . equal Ocamltest_config . arch " amd64 " ) " ... |
let arch_power = make " arch_power " ( Actions_helpers . pass_or_skip ( String . equal Ocamltest_config . arch " power " ) " Target is POWER architecture " " Target is not POWER architecture " ) |
let function_sections = make " function_sections " ( Actions_helpers . pass_or_skip ( Ocamltest_config . function_sections ) " Target supports function sections " " Target does not support function sections " ) |
let naked_pointers = make " naked_pointers " ( Actions_helpers . pass_or_skip ( Ocamltest_config . naked_pointers ) " Runtime system supports naked pointers " " Runtime system does not support naked pointers " ) |
let probes = make " probes " ( Actions_helpers . pass_or_skip ( Ocamltest_config . probes ) " Target supports probes " " Target does not support probes " ) |
let has_symlink = make " has_symlink " ( Actions_helpers . pass_or_skip ( Unix . has_symlink ( ) ) " symlinks available " " symlinks not available " ) |
let setup_build_env = make " setup - build - env " ( Actions_helpers . setup_build_env true [ ] ) |
let setup_simple_build_env = make " setup - simple - build - env " ( Actions_helpers . setup_simple_build_env true [ ] ) |
let run = make " run " Actions_helpers . run_program |
let script = make " script " Actions_helpers . run_script |
let check_program_output = make " check - program - output " ( Actions_helpers . check_output " program " Builtin_variables . output Builtin_variables . reference ) |
let initialize_test_exit_status_variables _log env = Environments . add_bindings [ Builtin_variables . test_pass , " 0 " ; Builtin_variables . test_fail , " 1 " ; Builtin_variables . test_skip , " 125 " ; ] env |
let _ = Environments . register_initializer Environments . Post " test_exit_status_variables " initialize_test_exit_status_variables ; List . iter register [ pass ; skip ; fail ; cd ; dumpenv ; hasinstrumentedruntime ; hasunix ; hassysthreads ; hasstr ; libunix ; libwin32unix ; windows ; not_windows ; bsd ; not_bsd ; m... |
let string_of_cst = function | Pconst_string ( s , _ , _ ) -> Some s | _ -> None |
let int_of_cst = function | Pconst_integer ( i , None ) -> Some ( int_of_string i ) | _ -> None |
let string_of_payload = function | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant c } , _ ) } ] -> string_of_cst c | _ -> None |
let int_of_payload = function | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant c } , _ ) } ] -> int_of_cst c | _ -> None |
let string_of_opt_payload p = match string_of_payload p with | Some s -> s | None -> " " |
let error_of_extension ext = let submessage_from main_loc main_txt = function | { pstr_desc = Pstr_extension ( ( { txt = ( " ocaml . error " " | error " ) ; loc } , p ) , _ ) } -> begin match p with | PStr ( [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( msg , _ , _ ) ) } , _ ) } ] ) -> { Loc... |
let kind_and_message = function | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_apply ( { pexp_desc = Pexp_ident { txt = Longident . Lident id } } , [ Nolabel , { pexp_desc = Pexp_constant ( Pconst_string ( s , _ , _ ) ) } ] ) } , _ ) } ] -> Some ( id , s ) | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_id... |
let cat s1 s2 = if s2 = " " then s1 else s1 ^ " \ n " ^ s2 |
let alert_attr x = match x . attr_name . txt with | " ocaml . deprecated " " | deprecated " -> Some ( x , " deprecated " , string_of_opt_payload x . attr_payload ) | " ocaml . alert " " | alert " -> begin match kind_and_message x . attr_payload with | Some ( kind , message ) -> Some ( x , kind , message ) | None -> Non... |
let alert_attrs l = List . filter_map alert_attr l |
let alerts_of_attrs l = List . fold_left ( fun acc ( _ , kind , message ) -> let upd = function | None | Some " " -> Some message | Some s -> Some ( cat s message ) in Misc . Stdlib . String . Map . update kind upd acc ) Misc . Stdlib . String . Map . empty ( alert_attrs l ) |
let check_alerts loc attrs s = Misc . Stdlib . String . Map . iter ( fun kind message -> Location . alert loc ~ kind ( cat s message ) ) ( alerts_of_attrs attrs ) |
let check_alerts_inclusion ~ def ~ use loc attrs1 attrs2 s = let m2 = alerts_of_attrs attrs2 in Misc . Stdlib . String . Map . iter ( fun kind msg -> if not ( Misc . Stdlib . String . Map . mem kind m2 ) then Location . alert ~ def ~ use ~ kind loc ( cat s msg ) ) ( alerts_of_attrs attrs1 ) |
let rec deprecated_mutable_of_attrs = function | [ ] -> None | { attr_name = { txt = " ocaml . deprecated_mutable " " | deprecated_mutable " ; _ } ; attr_payload = p } :: _ -> Some ( string_of_opt_payload p ) | _ :: tl -> deprecated_mutable_of_attrs tl |
let check_deprecated_mutable loc attrs s = match deprecated_mutable_of_attrs attrs with | None -> ( ) | Some txt -> Location . deprecated loc ( Printf . sprintf " mutating field % s " ( cat s txt ) ) |
let check_deprecated_mutable_inclusion ~ def ~ use loc attrs1 attrs2 s = match deprecated_mutable_of_attrs attrs1 , deprecated_mutable_of_attrs attrs2 with | None , _ | Some _ , Some _ -> ( ) | Some txt , None -> Location . deprecated ~ def ~ use loc ( Printf . sprintf " mutating field % s " ( cat s txt ) ) |
let rec attrs_of_sig = function | { psig_desc = Psig_attribute a } :: tl -> a :: attrs_of_sig tl | _ -> [ ] |
let alerts_of_sig sg = alerts_of_attrs ( attrs_of_sig sg ) |
let rec attrs_of_str = function | { pstr_desc = Pstr_attribute a } :: tl -> a :: attrs_of_str tl | _ -> [ ] |
let alerts_of_str str = alerts_of_attrs ( attrs_of_str str ) |
let check_no_alert attrs = List . iter ( fun ( a , _ , _ ) -> Location . prerr_warning a . attr_loc ( Warnings . Misplaced_attribute a . attr_name . txt ) ) ( alert_attrs attrs ) |
let warn_payload loc txt msg = Location . prerr_warning loc ( Warnings . Attribute_payload ( txt , msg ) ) |
let warning_attribute ( ? ppwarning = true ) = let process loc txt errflag payload = match string_of_payload payload with | Some s -> begin try Warnings . parse_options errflag s with Arg . Bad msg -> warn_payload loc txt msg end | None -> warn_payload loc txt " A single string literal is expected " in let process_aler... |
let warning_scope ? ppwarning attrs f = let prev = Warnings . backup ( ) in try List . iter ( warning_attribute ? ppwarning ) ( List . rev attrs ) ; let ret = f ( ) in Warnings . restore prev ; ret with exn -> Warnings . restore prev ; raise exn |
let warn_on_literal_pattern = List . exists ( fun a -> match a . attr_name . txt with | " ocaml . warn_on_literal_pattern " " | warn_on_literal_pattern " -> true | _ -> false ) |
let explicit_arity = List . exists ( fun a -> match a . attr_name . txt with | " ocaml . explicit_arity " " | explicit_arity " -> true | _ -> false ) |
let immediate = List . exists ( fun a -> match a . attr_name . txt with | " ocaml . immediate " " | immediate " -> true | _ -> false ) |
let immediate64 = List . exists ( fun a -> match a . attr_name . txt with | " ocaml . immediate64 " " | immediate64 " -> true | _ -> false ) |
let check l a = List . mem a . attr_name . txt l |
let has_unboxed attr = List . exists ( check [ " ocaml . unboxed " ; " unboxed " ] ) attr |
let has_boxed attr = List . exists ( check [ " ocaml . boxed " ; " boxed " ] ) attr |
let parse_empty_payload attr = match attr . attr_payload with | PStr [ ] -> Some ( ) | _ -> warn_payload attr . attr_loc attr . attr_name . txt " No attribute payload was expected " ; None |
let parse_int_payload attr = match int_of_payload attr . attr_payload with | Some i -> Some i | None -> warn_payload attr . attr_loc attr . attr_name . txt " A constant payload of type int was expected " ; None |
let clflags_attribute_without_payload attr ~ name clflags_ref = if String . equal attr . attr_name . txt name || String . equal attr . attr_name . txt ( " ocaml . " ^ name ) then begin match parse_empty_payload attr with | Some ( ) -> clflags_ref := true | None -> ( ) end |
let clflags_attribute_without_payload ' attr ~ name ~ f = if String . equal attr . attr_name . txt name || String . equal attr . attr_name . txt ( " ocaml . " ^ name ) then begin match parse_empty_payload attr with | Some ( ) -> f ( ) | None -> ( ) end |
let clflags_attribute_with_int_payload attr ~ name clflags_ref = if String . equal attr . attr_name . txt name || String . equal attr . attr_name . txt ( " ocaml . " ^ name ) then begin match parse_int_payload attr with | Some i -> clflags_ref := i | None -> ( ) end |
let principal_attribute attr = clflags_attribute_without_payload attr ~ name " : principal " Clflags . principal |
let noprincipal_attribute attr = clflags_attribute_without_payload ' attr ~ name " : noprincipal " ~ f ( : fun ( ) -> Clflags . principal := false ) |
let nolabels_attribute attr = clflags_attribute_without_payload attr ~ name " : nolabels " Clflags . classic |
let flambda_oclassic_attribute attr = clflags_attribute_without_payload ' attr ~ name " : flambda_oclassic " ~ f ( : fun ( ) -> if Config . flambda || Config . flambda2 then Clflags . set_oclassic ( ) ) |
let flambda_o3_attribute attr = clflags_attribute_without_payload ' attr ~ name " : flambda_o3 " ~ f ( : fun ( ) -> if Config . flambda || Config . flambda2 then Clflags . set_o3 ( ) ) |
let inline_attribute attr = if String . equal attr . attr_name . txt " inline " || String . equal attr . attr_name . txt " ocaml . inline " then begin let err_msg = " Either specify an integer , or the form accepted by ' - inline ' in quotes " in match string_of_payload attr . attr_payload with | Some s -> Clflags . Fl... |
let afl_inst_ratio_attribute attr = clflags_attribute_with_int_payload attr ~ name " : afl_inst_ratio " Clflags . afl_inst_ratio |
let parse_standard_interface_attributes attr = warning_attribute attr ; principal_attribute attr ; noprincipal_attribute attr ; nolabels_attribute attr |
let parse_standard_implementation_attributes attr = warning_attribute attr ; principal_attribute attr ; noprincipal_attribute attr ; nolabels_attribute attr ; inline_attribute attr ; afl_inst_ratio_attribute attr ; flambda_o3_attribute attr ; flambda_oclassic_attribute attr |
let has_local_opt attr = List . exists ( check [ " ocaml . local_opt " ; " local_opt " ] ) attr |
let has_curry attr = List . exists ( check [ " extension . curry " ; " ocaml . curry " ; " curry " ] ) attr |
let has_global attr = List . exists ( check [ " extension . global " ; " ocaml . global " ; " global " ] ) attr |
let has_nonlocal attr = List . exists ( check [ " extension . nonlocal " ; " ocaml . nonlocal " ; " nonlocal " ] ) attr |
let check_local ext_names other_names attr = if List . exists ( check ext_names ) attr then if not ( Clflags . Extension . is_enabled Local ) then Error ( ) else Ok true else Ok ( List . exists ( check other_names ) attr ) |
let has_local attr = check_local [ " extension . local " ] [ " ocaml . local " ; " local " ] attr |
type xEvent = | Activate | ButtonPress | ButtonPressDetail of int | ButtonRelease | ButtonReleaseDetail of int | Circulate | ColorMap | Configure | Deactivate | Destroy | Enter | Expose | FocusIn | FocusOut | Gravity | KeyPress | KeyPressDetail of string | KeyRelease | KeyReleaseDetail of string | Leave | Map | Motion ... |
type modifier = | Control | Shift | Lock | Button1 | Button2 | Button3 | Button4 | Button5 | Double | Triple | Mod1 | Mod2 | Mod3 | Mod4 | Mod5 | Meta | Alt ; ; |
type eventInfo = { mutable ev_Above : int ; mutable ev_ButtonNumber : int ; mutable ev_Count : int ; mutable ev_Detail : string ; mutable ev_Focus : bool ; mutable ev_Height : int ; mutable ev_KeyCode : int ; mutable ev_Mode : string ; mutable ev_OverrideRedirect : bool ; mutable ev_Place : string ; mutable ev_State : ... |
type eventField = | Ev_Above | Ev_ButtonNumber | Ev_Count | Ev_Detail | Ev_Focus | Ev_Height | Ev_KeyCode | Ev_Mode | Ev_OverrideRedirect | Ev_Place | Ev_State | Ev_Time | Ev_Width | Ev_MouseX | Ev_MouseY | Ev_Char | Ev_BorderWidth | Ev_SendEvent | Ev_KeySymString | Ev_KeySymInt | Ev_RootWindow | Ev_SubWindow | Ev_Type... |
let filleventInfo ev v = function | Ev_Above -> ev . ev_Above <- int_of_string v | Ev_ButtonNumber -> ev . ev_ButtonNumber <- int_of_string v | Ev_Count -> ev . ev_Count <- int_of_string v | Ev_Detail -> ev . ev_Detail <- v | Ev_Focus -> ev . ev_Focus <- v = " 1 " | Ev_Height -> ev . ev_Height <- int_of_string v | Ev_K... |
let wrapeventInfo f what = let ev = { ev_Above = 0 ; ev_ButtonNumber = 0 ; ev_Count = 0 ; ev_Detail = " " ; ev_Focus = false ; ev_Height = 0 ; ev_KeyCode = 0 ; ev_Mode = " " ; ev_OverrideRedirect = false ; ev_Place = " " ; ev_State = " " ; ev_Time = 0 ; ev_Width = 0 ; ev_MouseX = 0 ; ev_MouseY = 0 ; ev_Char = " " ; ev_... |
let rec writeeventField = function | [ ] -> " " | field :: rest -> begin match field with | Ev_Above -> " % a " | Ev_ButtonNumber " -> % b " | Ev_Count -> " % c " | Ev_Detail -> " % d " | Ev_Focus -> " % f " | Ev_Height -> " % h " | Ev_KeyCode -> " % k " | Ev_Mode -> " % m " | Ev_OverrideRedirect -> " % o " | Ev_Place ... |
type event = [ | ` Activate | ` ButtonPress | ` ButtonPressDetail of int | ` ButtonRelease | ` ButtonReleaseDetail of int | ` Circulate | ` Colormap | ` Configure | ` Deactivate | ` Destroy | ` Enter | ` Expose | ` FocusIn | ` FocusOut | ` Gravity | ` KeyPress | ` KeyPressDetail of string | ` KeyRelease | ` KeyReleaseD... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.