text
stringlengths
0
601k
let surface_flags s = ( surface_info s ) . flags
let surface_bpp s = ( surface_format s ) . bits_pp
type color = int * int * int
let black : color = ( 0 , 0 , 0 )
let white : color = ( 255 , 255 , 255 )
let red : color = ( 255 , 0 , 0 )
let green : color = ( 0 , 255 , 0 )
let blue : color = ( 0 , 0 , 255 )
let yellow : color = ( 255 , 255 , 0 )
let cyan : color = ( 0 , 255 , 255 )
let magenta : color = ( 255 , 0 , 255 ) = " ml_sdl_surface_use_palette "
type palette_flag = | LOGPAL | PHYSPAL | LOGPHYSPAL = " ml_SDL_SetPalette " = " ml_SDL_GetVideoSurface " = " ml_SDL_SetVideoMode " = " ml_SDL_UpdateRect " = " ml_SDL_UpdateRects " = " ml_SDL_Flip " = " ml_SDL_SetGamma " = " ml_SDL_MapRGB " = " ml_SDL_GetRGB " = " ml_SDL_GetRGBA " [ ` SWSURFACE | ` HWSURFACE | ` ASYNCBL...
let create_RGB_surface_from_32 = _create_RGB_surface_from ~ bpp : 32
let create_RGB_surface_from_24 a ~ w ~ h ~ pitch ~ rmask ~ gmask ~ bmask ~ amask = _create_RGB_surface_from a ~ w ~ h ~ pitch ~ bpp : 24 ~ rmask ( : Int32 . of_int rmask ) ~ gmask ( : Int32 . of_int gmask ) ~ bmask ( : Int32 . of_int bmask ) ~ amask ( : Int32 . of_int amask )
let create_RGB_surface_from_16 a ~ w ~ h ~ pitch ~ rmask ~ gmask ~ bmask ~ amask = _create_RGB_surface_from a ~ w ~ h ~ pitch ~ bpp : 16 ~ rmask ( : Int32 . of_int rmask ) ~ gmask ( : Int32 . of_int gmask ) ~ bmask ( : Int32 . of_int bmask ) ~ amask ( : Int32 . of_int amask )
let create_RGB_surface_from_8 a ~ w ~ h ~ pitch ~ rmask ~ gmask ~ bmask ~ amask = _create_RGB_surface_from a ~ w ~ h ~ pitch ~ bpp : 8 ~ rmask ( : Int32 . of_int rmask ) ~ gmask ( : Int32 . of_int gmask ) ~ bmask ( : Int32 . of_int bmask ) ~ amask ( : Int32 . of_int amask ) = " ml_SDL_MustLock " " noalloc " = " ml_SDL_...
let load_BMP_from_mem buff = load_BMP_RW ( Sdl . rwops_from_mem buff ) = " ml_SDL_SaveBMP " = " ml_SDL_unset_color_key " = " ml_SDL_SetColorKey " = " ml_SDL_get_color_key " = " ml_SDL_unset_alpha " = " ml_SDL_SetAlpha " = " ml_SDL_get_alpha " = " ml_SDL_UnsetClipRect " = " ml_SDL_SetClipRect " = " ml_SDL_GetClipRect " ...
let _pixel_data_final s ba = ( )
let _pixel_data surf bpp = let ba = __pixel_data surf bpp in Gc . finalise ( _pixel_data_final surf ) ba ; ba
let pixel_data s = ( _pixel_data s 0 : ( int , int8_unsigned_elt , c_layout ) Array1 . t )
let pixel_data_8 s = ( _pixel_data s 1 : ( int , int8_unsigned_elt , c_layout ) Array1 . t )
let pixel_data_16 s = ( _pixel_data s 2 : ( int , int16_unsigned_elt , c_layout ) Array1 . t )
let pixel_data_24 s = ( _pixel_data s 3 : ( int , int8_unsigned_elt , c_layout ) Array1 . t )
let pixel_data_32 s = ( _pixel_data s 4 : ( int32 , int32_elt , c_layout ) Array1 . t ) = " ml_SDL_get_pixel " = " ml_SDL_put_pixel " = " ml_SDL_get_pixel_color " = " ml_SDL_put_pixel_color "
type window_flags = | FullScreen | OpenGL | Shown | Hidden | Borderless | Resizable | Minimized | Maximized | Input_Grabbed | Input_Focus | Mouse_Focus | FullScreen_Desktop | Foreign | Allow_HighDPI
type window_pos = [ ` centered | ` undefined | ` pos of int ] title : string -> pos : window_pos * window_pos -> dims : int * int -> flags : window_flags list -> t = " caml_SDL_CreateWindow " title : string -> x : window_pos -> y : window_pos -> width : int -> height : int -> flags : window_flags list -> t = " caml_SDL...
module Make ( Structure : Structure . S ) = struct open Structure ; fun [ Dlevels levels -> let rec search_levels = fun [ [ ] -> tree | [ level :: levels ] -> match search_level level with [ Some tree -> tree | None -> search_levels levels ] ] and search_level level = match search_tree level . lsuffix with [ Some t -> ...
let start_env = ref initial
let module_list = ref [ ]
type pkind = Pvalue | Ptype | Plabel | Pconstructor | Pmodule | Pmodtype | Pclass | Pcltype
let string_of_kind = function Pvalue -> " v " | Ptype -> " t " | Plabel -> " l " | Pconstructor -> " cn " | Pmodule -> " m " | Pmodtype -> " s " | Pclass -> " c " | Pcltype -> " ct "
let rec longident_of_path = function Pident id -> Lident ( Ident . name id ) | Pdot ( path , s , _ ) -> Ldot ( longident_of_path path , s ) | Papply ( p1 , p2 ) -> Lapply ( longident_of_path p1 , longident_of_path p2 )
let rec remove_prefix lid ~ prefix = let rec remove_hd lid ~ name = match lid with Ldot ( Lident s1 , s2 ) when s1 = name -> Lident s2 | Ldot ( l , s ) -> Ldot ( remove_hd ~ name l , s ) | _ -> raise Not_found in match prefix with [ ] -> lid | name :: prefix -> try remove_prefix ~ prefix ( remove_hd ~ name lid ) with N...
let rec permutations l = match l with [ ] | [ _ ] -> [ l ] | [ a ; b ] -> [ l ; [ b ; a ] ] | _ -> let _ , perms = List . fold_left l ~ init ( : l , [ ] ) ~ f : begin fun ( l , perms ) a -> let l = List . tl l in l @ [ a ] , List . map ( permutations l ) ~ f ( : fun l -> a :: l ) @ perms end in perms
let rec choose n ~ card : l = let len = List . length l in if n = len then [ l ] else if n = 1 then List . map l ~ f ( : fun x -> [ x ] ) else if n = 0 then [ [ ] ] else if n > len then [ ] else match l with [ ] -> [ ] | a :: l -> List . map ( choose ( n - 1 ) ~ card : l ) ~ f ( : fun l -> a :: l ) @ choose n ~ card : ...
let rec arr p ~ card : n = if p = 0 then 1 else n * arr ( p - 1 ) ~ card ( : n - 1 )
let rec all_args ty = let ty = repr ty in match ty . desc with Tarrow ( l , ty1 , ty2 , _ ) -> let ( tl , ty ) = all_args ty2 in ( ( l , ty1 ) :: tl , ty ) | _ -> ( [ ] , ty )
let rec equal ~ prefix t1 t2 = match ( repr t1 ) . desc , ( repr t2 ) . desc with Tvar , Tvar -> true | Tvariant row1 , Tvariant row2 -> let row1 = row_repr row1 and row2 = row_repr row2 in let fields1 = filter_row_fields false row1 . row_fields and fields2 = filter_row_fields false row1 . row_fields in let r1 , r2 , p...
let is_opt s = s <> " " && s . [ 0 ] = ' ' ?
let get_options = List . filter ~ f : is_opt
let rec included ~ prefix t1 t2 = match ( repr t1 ) . desc , ( repr t2 ) . desc with Tvar , _ -> true | Tvariant row1 , Tvariant row2 -> let row1 = row_repr row1 and row2 = row_repr row2 in let fields1 = filter_row_fields false row1 . row_fields and fields2 = filter_row_fields false row2 . row_fields in let r1 , r2 , p...
let mklid = function [ ] -> raise ( Invalid_argument " Searchid . mklid " ) | x :: l -> List . fold_left l ~ init ( : Lident x ) ~ f ( : fun acc x -> Ldot ( acc , x ) )
let mkpath = function [ ] -> raise ( Invalid_argument " Searchid . mklid " ) | x :: l -> List . fold_left l ~ init ( : Pident ( Ident . create x ) ) ~ f ( : fun acc x -> Pdot ( acc , x , 0 ) )
let get_fields ~ prefix ~ sign self = let env = open_signature ( mkpath prefix ) sign initial in match ( expand_head env self ) . desc with Tobject ( ty_obj , _ ) -> let l , _ = flatten_fields ty_obj in l | _ -> [ ]
let rec search_type_in_signature t ~ sign ~ prefix ~ mode = let matches = match mode with ` Included -> included t ~ prefix | ` Exact -> equal t ~ prefix and lid_of_id id = mklid ( prefix @ [ Ident . name id ] ) in List2 . flat_map sign ~ f : begin fun item -> match item with Tsig_value ( id , vd ) -> if matches vd . v...
let search_all_types t ~ mode = let tl = match mode , t . desc with ` Exact , _ -> [ t ] | ` Included , Tarrow _ -> [ t ] | ` Included , _ -> [ t ; newty ( Tarrow ( " " , t , newvar ( ) , Cok ) ) ; newty ( Tarrow ( " " , newvar ( ) , t , Cok ) ) ] in List2 . flat_map ! module_list ~ f : begin fun modname -> let mlid = ...
let search_string_type text ~ mode = try let sexp = Parse . interface ( Lexing . from_string ( " val z : " ^ text ) ) in let sign = try Typemod . transl_signature ! start_env sexp with _ -> let env = List . fold_left ! module_list ~ init : initial ~ f : begin fun acc m -> try open_pers_signature m acc with Env . Error ...
let longident_of_string text = let exploded = ref [ ] and l = ref 0 in for i = 0 to String . length text - 2 do if text . [ i ] ' . ' = then ( exploded := String . sub text ~ pos :! l ~ len ( : i - ! l ) :: ! exploded ; l := i + 1 ) done ; let sym = String . sub text ~ pos :! l ~ len ( : String . length text - ! l ) in...
let explode s = let l = ref [ ] in for i = String . length s - 1 downto 0 do l := s . [ i ] :: ! l done ; ! l
let rec check_match ~ pattern s = match pattern , s with [ ] , [ ] -> true | ' ' *:: l , l ' -> check_match ~ pattern : l l ' || check_match ~ pattern ( ' ' ' ' :?::*:: l ) l ' | ' ' ?:: l , _ :: l ' -> check_match ~ pattern : l l ' | x :: l , y :: l ' when x == y -> check_match ~ pattern : l l ' | _ -> false
let search_pattern_symbol text = if text = " " then [ ] else let pattern = explode text in let check i = check_match ~ pattern ( explode ( Ident . name i ) ) in let l = List . map ! module_list ~ f : begin fun modname -> Lident modname , try match lookup_module ( Lident modname ) initial with _ , Tmty_signature sign ->...
let search_string_symbol text = if text = " " then [ ] else let lid = snd ( longident_of_string text ) [ ] in let try_lookup f k = try let _ = f lid Env . initial in [ lid , k ] with Not_found | Env . Error _ -> [ ] in try_lookup lookup_constructor Pconstructor @ try_lookup lookup_module Pmodule @ try_lookup lookup_mod...
let rec bound_variables pat = match pat . ppat_desc with Ppat_any | Ppat_constant _ | Ppat_type _ -> [ ] | Ppat_var s -> [ s ] | Ppat_alias ( pat , s ) -> s :: bound_variables pat | Ppat_tuple l -> List2 . flat_map l ~ f : bound_variables | Ppat_construct ( _ , None , _ ) -> [ ] | Ppat_construct ( _ , Some pat , _ ) ->...
let search_structure str ~ name ~ kind ~ prefix = let loc = ref 0 in let rec search_module str ~ prefix = match prefix with [ ] -> str | modu :: prefix -> let str = List . fold_left ~ init [ ] : str ~ f : begin fun acc item -> match item . pstr_desc with Pstr_module ( s , mexp ) when s = modu -> loc := mexp . pmod_loc ...
let search_signature sign ~ name ~ kind ~ prefix = let loc = ref 0 in let rec search_module_type sign ~ prefix = match prefix with [ ] -> sign | modu :: prefix -> let sign = List . fold_left ~ init [ ] : sign ~ f : begin fun acc item -> match item . psig_desc with Psig_module ( s , mtyp ) when s = modu -> loc := mtyp ....
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " SearchLocalGatewayRoutes " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " SearchLocalGatewayRoutesResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp SearchLocalGatewayRoutesResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed SearchLocalGate...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
type t = | Root of PyrePath . t | Subdirectory of { root : PyrePath . t ; subdirectory : string ; } | Submodule of { root : PyrePath . t ; submodule : string ; }
type search_result = { relative_path : PyrePath . RelativePath . t ; priority : int ; }
let equal = [ % compare . equal : t ]
let get_root path = match path with | Root root -> root | Subdirectory { root ; _ } | Submodule { root ; _ } -> root
let to_path path = match path with | Root root -> root | Subdirectory { root ; subdirectory = relative } | Submodule { root ; submodule = relative } -> PyrePath . create_relative ~ root ~ relative
let pp formatter = function | Root root -> PyrePath . pp formatter root | Subdirectory { root ; subdirectory = relative } | Submodule { root ; submodule = relative } -> Format . fprintf formatter " % a $% s " PyrePath . pp root relative
let show path = Format . asprintf " % a " pp path
let create serialized = match String . split serialized ~ on ' ' :$ with | [ root ] -> Root ( PyrePath . create_absolute root ) | [ root ; path ] -> ( match String . split path ~ on ' . ' : with | [ subdirectory ] -> Subdirectory { root = PyrePath . create_absolute root ; subdirectory } | _ -> Submodule { root = PyrePa...
let normalize = function | Root root -> Root ( PyrePath . create_absolute ~ follow_symbolic_links : true ( PyrePath . absolute root ) ) | Subdirectory { root ; subdirectory } -> Subdirectory { root = PyrePath . create_absolute ~ follow_symbolic_links : true ( PyrePath . absolute root ) ; subdirectory ; } | Submodule { ...
let create_normalized serialized = create serialized |> normalize
let search_for_path ~ search_paths analysis_path = let raw_path = ArtifactPath . raw analysis_path in let under_root search_path = let open Option in let found = match search_path with | Submodule _ -> PyrePath . equal ( to_path search_path ) raw_path | _ -> PyrePath . directory_contains ~ directory ( : to_path search_...
let ( ! ) = PyrePath . create_absolute
let test_create_search_path _ = let root = PyrePath . create_absolute " / root " in let subdirectory = PyrePath . create_relative ~ root ~ relative " : subdirectory " in assert_equal ~ cmp : SearchPath . equal ( SearchPath . Root root ) ( SearchPath . create ( PyrePath . show root ) ) ; assert_equal ~ cmp : SearchPath ...
let test_show_search_path _ = let assert_round_trip search_path = let round_trip_search_path = SearchPath . show search_path |> SearchPath . create in assert_equal ~ cmp : SearchPath . equal ~ printer : SearchPath . show search_path round_trip_search_path in assert_round_trip ( SearchPath . Root " ! foo " ) ; assert_ro...
let test_normalize context = let good_root = bracket_tmpdir context in let bad_root = " nonexist / directory " in let good_subroot = good_root ^ " / subroot " in Sys_utils . mkdir_no_fail good_subroot ; let create_input ? subdirectory ? submodule root = let search_path = match subdirectory , submodule with | Some subdi...
let test_search_for_path context = let root = bracket_tmpdir context |> PyrePath . create_absolute in let assert_path ~ search_paths ~ path ~ expected = assert_equal ( Some expected ) ( SearchPath . search_for_path ~ search_paths path >>| fun SearchPath . { relative_path ; _ } -> PyrePath . RelativePath . relative rela...
let ( ) = " searchPath " >::: [ " create_search_path " >:: test_create_search_path ; " show_search_path " >:: test_show_search_path ; " normalize " >:: test_normalize ; " search_for_path " >:: test_search_for_path ; ] |> Test . run
let ( ) ~! = Jg_memo . fast ~ f : Str . regexp
let lines_to_chars n ~ text : s = let l = String . length s in let rec ltc n ~ pos = if n = 1 || pos >= l then pos else if s . [ pos ] = ' \ n ' then ltc ( n - 1 ) ~ pos ( : pos + 1 ) else ltc n ~ pos ( : pos + 1 ) in ltc n ~ pos : 0
let in_loc loc ~ pos = loc . loc_ghost || pos >= loc . loc_start . Lexing . pos_cnum && pos < loc . loc_end . Lexing . pos_cnum
let le_loc loc1 loc2 = loc1 . loc_start . Lexing . pos_cnum <= loc2 . loc_start . Lexing . pos_cnum && loc1 . loc_end . Lexing . pos_cnum >= loc2 . loc_end . Lexing . pos_cnum
let add_found ~ found sol ~ env ~ loc = if loc . loc_ghost then ( ) else if List . exists ! found ~ f ( : fun ( _ , _ , loc ' ) -> le_loc loc loc ' ) then ( ) else found := ( sol , env , loc ) :: List . filter ! found ~ f ( : fun ( _ , _ , loc ' ) -> not ( le_loc loc ' loc ) )
let observe ~ ref ? init f x = let old = ! ref in begin match init with None -> ( ) | Some x -> ref := x end ; try ( f x : unit ) ; let v = ! ref in ref := old ; v with exn -> ref := old ; raise exn
let rec string_of_longident = function Lident s -> s | Ldot ( id , s ) -> string_of_longident id ^ " . " ^ s | Lapply ( id1 , id2 ) -> string_of_longident id1 ^ " ( " ^ string_of_longident id2 ^ " ) "
let string_of_path p = string_of_longident ( Searchid . longident_of_path p )
let parent_path = function Pdot ( path , _ , _ ) -> Some path | Pident _ | Papply _ -> None
let ident_of_path ~ default = function Pident i -> i | Pdot ( _ , s , _ ) -> Ident . create s | Papply _ -> Ident . create default
let rec head_id = function Pident id -> id | Pdot ( path , _ , _ ) -> head_id path | Papply ( path , _ ) -> head_id path
let rec list_of_path = function Pident id -> [ Ident . name id ] | Pdot ( path , s , _ ) -> list_of_path path @ [ s ] | Papply ( path , _ ) -> list_of_path path val buffer = Buffer . create size method out buf = Buffer . add_substring buffer buf method get = Buffer . contents buffer end
let found_sig = ref ( [ ] : ( ( skind * Longident . t ) * Env . t * Location . t ) list )
let add_found_sig = add_found ~ found : found_sig
let rec search_pos_type t ~ pos ~ env = if in_loc ~ pos t . ptyp_loc then begin match t . ptyp_desc with Ptyp_any | Ptyp_var _ -> ( ) | Ptyp_variant ( tl , _ , _ ) -> List . iter tl ~ f : begin function Rtag ( _ , _ , tl ) -> List . iter tl ~ f ( : search_pos_type ~ pos ~ env ) | Rinherit st -> search_pos_type ~ pos ~ ...
let rec search_pos_class_type cl ~ pos ~ env = if in_loc cl . pcty_loc ~ pos then begin match cl . pcty_desc with Pcty_constr ( lid , _ ) -> add_found_sig ( ` Class , lid ) ~ env ~ loc : cl . pcty_loc | Pcty_signature ( _ , cfl ) -> List . iter cfl ~ f : begin function Pctf_inher cty -> search_pos_class_type cty ~ pos ...
let search_pos_type_decl td ~ pos ~ env = if in_loc ~ pos td . ptype_loc then begin begin match td . ptype_manifest with Some t -> search_pos_type t ~ pos ~ env | None -> ( ) end ; let rec search_tkind = function Ptype_abstract -> ( ) | Ptype_variant dl -> List . iter dl ~ f ( : fun ( _ , tl , _ ) -> List . iter tl ~ f...
let rec search_pos_signature l ~ pos ~ env = ignore ( List . fold_left l ~ init : env ~ f : begin fun env pt -> let env = match pt . psig_desc with Psig_open id -> let path , mt = lookup_module id env in begin match mt with Tmty_signature sign -> open_signature path sign env | _ -> env end | sign_item -> try add_signat...
let search_pos_signature l ~ pos ~ env = observe ~ ref : found_sig ( search_pos_signature ~ pos ~ env ) l
type module_widgets = { mw_frame : Widget . frame Widget . widget ; mw_title : Widget . label Widget . widget option ; mw_detach : Widget . button Widget . widget ; mw_edit : Widget . button Widget . widget ; mw_intf : Widget . button Widget . widget }
let shown_modules = Hashtbl . create 17
let default_frame = ref None
let set_path = ref ( fun _ ~ sign -> assert false )
let filter_modules ( ) = Hashtbl . iter ( fun key data -> if not ( Winfo . exists data . mw_frame ) then Hashtbl . remove shown_modules key ) shown_modules
let add_shown_module path ~ widgets = Hashtbl . add shown_modules path widgets