text
stringlengths
12
786k
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 " ) " Target is AMD64 architecture " " Target is not AMD64 architecture " ) let arch_i386 = make " arch_i386 " ( Actions_helpers . pass_or_skip ( String . equal Ocamltest_config . arch " i386 " ) " Target is i386 architecture " " Target is not i386 architecture " )
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 ; macos ; arch32 ; arch64 ; has_symlink ; setup_build_env ; setup_simple_build_env ; run ; script ; check_program_output ; arch_arm ; arch_arm64 ; arch_amd64 ; arch_i386 ; arch_power ; function_sections ; naked_pointers ; probes ; ]
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 , _ , _ ) ) } , _ ) } ] ) -> { Location . loc ; txt = fun ppf -> Format . pp_print_text ppf msg } | _ -> { Location . loc ; txt = fun ppf -> Format . fprintf ppf " Invalid syntax for sub - message of extension ' % s ' . " main_txt } end | { pstr_desc = Pstr_extension ( ( { txt ; loc } , _ ) , _ ) } -> { Location . loc ; txt = fun ppf -> Format . fprintf ppf " Uninterpreted extension ' % s ' . " txt } | _ -> { Location . loc = main_loc ; txt = fun ppf -> Format . fprintf ppf " Invalid syntax for sub - message of extension ' % s ' . " main_txt } in match ext with | ( { txt = ( " ocaml . error " " | error " ) as txt ; loc } , p ) -> begin match p with | PStr [ ] -> raise Location . Already_displayed_error | PStr ( { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( msg , _ , _ ) ) } , _ ) } :: inner ) -> let sub = List . map ( submessage_from loc txt ) inner in Location . error_of_printer ~ loc ~ sub Format . pp_print_text msg | _ -> Location . errorf ~ loc " Invalid syntax for extension ' % s ' . " txt end | ( { txt ; loc } , _ ) -> Location . errorf ~ loc " Uninterpreted extension ' % s ' . " txt
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_ident { txt = Longident . Lident id } } , _ ) } ] -> Some ( id , " " ) | _ -> None
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 -> None end | _ -> None
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_alert loc txt = function | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( s , _ , _ ) ) } , _ ) } ] -> begin try Warnings . parse_alert_option s with Arg . Bad msg -> warn_payload loc txt msg end | k -> match kind_and_message k with | Some ( " all " , _ ) -> warn_payload loc txt " The alert name ' all ' is reserved " | Some _ -> ( ) | None -> warn_payload loc txt " Invalid payload " in function | { attr_name = { txt = ( " ocaml . warning " " | warning " ) as txt ; _ } ; attr_loc ; attr_payload ; } -> process attr_loc txt false attr_payload | { attr_name = { txt = ( " ocaml . warnerror " " | warnerror " ) as txt ; _ } ; attr_loc ; attr_payload } -> process attr_loc txt true attr_payload | { attr_name = { txt " = ocaml . ppwarning " " | ppwarning " ; _ } ; attr_loc = _ ; attr_payload = PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( s , _ , _ ) ) } , _ ) ; pstr_loc } ] ; } when ppwarning -> Location . prerr_warning pstr_loc ( Warnings . Preprocessor s ) | { attr_name = { txt = ( " ocaml . alert " " | alert " ) as txt ; _ } ; attr_loc ; attr_payload ; } -> process_alert attr_loc txt attr_payload | _ -> ( )
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 . Float_arg_helper . parse s err_msg Clflags . inline_threshold | None -> match int_of_payload attr . attr_payload with | Some i -> let s = string_of_int i in Clflags . Float_arg_helper . parse s err_msg Clflags . inline_threshold | None -> warn_payload attr . attr_loc attr . attr_name . txt err_msg end
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 | Property | Reparent | Unmap | Visibility | Virtual of string ; ;
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 : string ; mutable ev_Time : int ; mutable ev_Width : int ; mutable ev_MouseX : int ; mutable ev_MouseY : int ; mutable ev_Char : string ; mutable ev_BorderWidth : int ; mutable ev_SendEvent : bool ; mutable ev_KeySymString : string ; mutable ev_KeySymInt : int ; mutable ev_RootWindow : int ; mutable ev_SubWindow : int ; mutable ev_Type : int ; mutable ev_Widget : widget ; mutable ev_RootX : int ; mutable ev_RootY : int } ; ;
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 | Ev_Widget | Ev_RootX | Ev_RootY ; ;
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_KeyCode -> ev . ev_KeyCode <- int_of_string v | Ev_Mode -> ev . ev_Mode <- v | Ev_OverrideRedirect -> ev . ev_OverrideRedirect <- v = " 1 " | Ev_Place -> ev . ev_Place <- v | Ev_State -> ev . ev_State <- v | Ev_Time -> ev . ev_Time <- int_of_string v | Ev_Width -> ev . ev_Width <- int_of_string v | Ev_MouseX -> ev . ev_MouseX <- int_of_string v | Ev_MouseY -> ev . ev_MouseY <- int_of_string v | Ev_Char -> ev . ev_Char <- v | Ev_BorderWidth -> ev . ev_BorderWidth <- int_of_string v | Ev_SendEvent -> ev . ev_SendEvent <- v = " 1 " | Ev_KeySymString -> ev . ev_KeySymString <- v | Ev_KeySymInt -> ev . ev_KeySymInt <- int_of_string v | Ev_RootWindow -> ev . ev_RootWindow <- int_of_string v | Ev_SubWindow -> ev . ev_SubWindow <- int_of_string v | Ev_Type -> ev . ev_Type <- int_of_string v | Ev_Widget -> ev . ev_Widget <- cTKtoCAMLwidget v | Ev_RootX -> ev . ev_RootX <- int_of_string v | Ev_RootY -> ev . ev_RootY <- int_of_string v ; ;
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_BorderWidth = 0 ; ev_SendEvent = false ; ev_KeySymString = " " ; ev_KeySymInt = 0 ; ev_RootWindow = 0 ; ev_SubWindow = 0 ; ev_Type = 0 ; ev_Widget = Widget . default_toplevel ; ev_RootX = 0 ; ev_RootY = 0 } in function args -> let l = ref args in List . iter ( function field -> match ! l with [ ] -> ( ) | v :: rest -> filleventInfo ev v field ; l := rest ) what ; f 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 -> " % p " | Ev_State -> " % s " | Ev_Time -> " % t " | Ev_Width -> " % w " | Ev_MouseX -> " % x " | Ev_MouseY -> " % y " | Ev_Char -> " % A " | Ev_BorderWidth -> " % B " | Ev_SendEvent -> " % E " | Ev_KeySymString -> " % K " | Ev_KeySymInt -> " % N " | Ev_RootWindow " -> % R " | Ev_SubWindow -> " % S " | Ev_Type -> " % T " | Ev_Widget " -> % W " | Ev_RootX -> " % X " | Ev_RootY -> " % Y " end ^ writeeventField rest ; ; ## else
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 | ` KeyReleaseDetail of string | ` Leave | ` Map | ` Motion | ` Property | ` Reparent | ` Unmap | ` Visibility | ` Virtual of string | ` Modified of modifier list * event ] | ` 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 : string ; mutable ev_Time : int ; mutable ev_Width : int ; mutable ev_MouseX : int ; mutable ev_MouseY : int ; mutable ev_Char : string ; mutable ev_BorderWidth : int ; mutable ev_SendEvent : bool ; mutable ev_KeySymString : string ; mutable ev_KeySymInt : int ; mutable ev_RootWindow : int ; mutable ev_SubWindow : int ; mutable ev_Type : int ; mutable ev_Widget : any widget ; mutable ev_RootX : int ; mutable ev_RootY : int } ; ;
type eventField = [ | ` Above | ` ButtonNumber | ` Count | ` Detail | ` Focus | ` Height | ` KeyCode | ` Mode | ` OverrideRedirect | ` Place | ` State | ` Time | ` Width | ` MouseX | ` MouseY | ` Char | ` BorderWidth | ` SendEvent | ` KeySymString | ` KeySymInt | ` RootWindow | ` SubWindow | ` Type | ` Widget | ` RootX | ` RootY ] ; ;
let filleventInfo ev v : eventField -> unit = function | ` Above -> ev . ev_Above <- int_of_string v | ` ButtonNumber -> ev . ev_ButtonNumber <- int_of_string v | ` Count -> ev . ev_Count <- int_of_string v | ` Detail -> ev . ev_Detail <- v | ` Focus -> ev . ev_Focus <- v = " 1 " | ` Height -> ev . ev_Height <- int_of_string v | ` KeyCode -> ev . ev_KeyCode <- int_of_string v | ` Mode -> ev . ev_Mode <- v | ` OverrideRedirect -> ev . ev_OverrideRedirect <- v = " 1 " | ` Place -> ev . ev_Place <- v | ` State -> ev . ev_State <- v | ` Time -> ev . ev_Time <- int_of_string v | ` Width -> ev . ev_Width <- int_of_string v | ` MouseX -> ev . ev_MouseX <- int_of_string v | ` MouseY -> ev . ev_MouseY <- int_of_string v | ` Char -> ev . ev_Char <- v | ` BorderWidth -> ev . ev_BorderWidth <- int_of_string v | ` SendEvent -> ev . ev_SendEvent <- v = " 1 " | ` KeySymString -> ev . ev_KeySymString <- v | ` KeySymInt -> ev . ev_KeySymInt <- int_of_string v | ` RootWindow -> ev . ev_RootWindow <- int_of_string v | ` SubWindow -> ev . ev_SubWindow <- int_of_string v | ` Type -> ev . ev_Type <- int_of_string v | ` Widget -> ev . ev_Widget <- cTKtoCAMLwidget v | ` RootX -> ev . ev_RootX <- int_of_string v | ` RootY -> ev . ev_RootY <- int_of_string v ; ;
let wrapeventInfo f ( what : eventField list ) = 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_BorderWidth = 0 ; ev_SendEvent = false ; ev_KeySymString = " " ; ev_KeySymInt = 0 ; ev_RootWindow = 0 ; ev_SubWindow = 0 ; ev_Type = 0 ; ev_Widget = forget_type default_toplevel ; ev_RootX = 0 ; ev_RootY = 0 } in function args -> let l = ref args in List . iter what ~ f : begin fun field -> match ! l with | [ ] -> ( ) | v :: rest -> filleventInfo ev v field ; l := rest end ; f ev ; ;
let rec writeeventField : eventField list -> string = function | [ ] -> " " | field :: rest -> begin match field with | ` Above -> " % a " | ` ButtonNumber " -> % b " | ` Count -> " % c " | ` Detail -> " % d " | ` Focus -> " % f " | ` Height -> " % h " | ` KeyCode -> " % k " | ` Mode -> " % m " | ` OverrideRedirect -> " % o " | ` Place -> " % p " | ` State -> " % s " | ` Time -> " % t " | ` Width -> " % w " | ` MouseX -> " % x " | ` MouseY -> " % y " | ` Char -> " % A " | ` BorderWidth -> " % B " | ` SendEvent -> " % E " | ` KeySymString -> " % K " | ` KeySymInt -> " % N " | ` RootWindow " -> % R " | ` SubWindow -> " % S " | ` Type -> " % T " | ` Widget -> " % W " | ` RootX -> " % X " | ` RootY -> " % Y " end ^ writeeventField rest ; ; ## endif
type color = | NamedColor of string | Black | White | Red | Green | Blue | Yellow ; ; ## else
type color = [ | ` Color of string | ` Black | ` White | ` Red | ` Green | ` Blue | ` Yellow ] ; ; ## endif
type cursor = | XCursor of string | XCursorFg of string * color | XCursortFgBg of string * color * color | CursorFileFg of string * color | CursorMaskFile of string * string * color * color ; ; ## else
type cursor = [ | ` Xcursor of string | ` Xcursorfg of string * color | ` Xcursorfgbg of string * color * color | ` Cursorfilefg of string * color | ` Cursormaskfile of string * string * color * color ] ; ; ## endif
type index = | Number of int | ActiveElement | End | Last | NoIndex | Insert | SelFirst | SelLast | At of int | AtXY of int * int | AnchorPoint | Pattern of string | LineChar of int * int | Mark of string | TagFirst of string | TagLast of string | Embedded of widget ; ; ## else
type canvas_index = [ | ` Num of int | ` End | ` Insert | ` Selfirst | ` Sellast | ` Atxy of int * int ] ; ;
type entry_index = [ | ` Num of int | ` End | ` Insert | ` Selfirst | ` Sellast | ` At of int | ` Anchor ] ; ;
type listbox_index = [ | ` Num of int | ` Active | ` Anchor | ` End | ` Atxy of int * int ] ; ;
type menu_index = [ | ` Num of int | ` Active | ` End | ` Last | ` None | ` At of int | ` Pattern of string ] ; ;
type text_index = [ | ` Linechar of int * int | ` Atxy of int * int | ` End | ` Mark of string | ` Tagfirst of string | ` Taglast of string | ` Window of any widget | ` Image of string ] ; ;
type linechar_index = int * int ; ;
type num_index = int ; ; ## endif
type textModifier = | CharOffset of int | LineOffset of int | LineStart | LineEnd | WordStart | WordEnd ; ;
type textIndex = | TextIndex of index * textModifier list | TextIndexNone ; ; ## else
type textModifier = [ | ` Char of int | ` Line of int | ` Linestart | ` Lineend | ` Wordstart | ` Wordend ] ; ;
type textIndex = text_index * textModifier list ; ; ## endif
let arguments = Variables . make ( " arguments " , " Arguments passed to executed programs and scripts " )
let cwd = Variables . make ( " cwd " , " Used to change current working directory , but not updated " )
let commandline = Variables . make ( " commandline " , " Specify the commandline of a tool " )
let exit_status = Variables . make ( " exit_status " , " Expected program exit status " )
let files = Variables . make ( " files " , " Files used by the tests " )