text
stringlengths
0
601k
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
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 " , [ " RegisterInstanceEventNotificationAttributes " ] ) ] ( Util . drop_empty ( Uri . query...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RegisterInstanceEventNotificationAttributesResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RegisterInstanceEventNotificationAttributesResult . parse ) ( let open Error in BadResponse { body ; message = " Coul...
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
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 " , [ " 2012 - 06 - 01 " ] ) ; ( " Action " , [ " RegisterInstancesWithLoadBalancer " ] ) ] ( Util . drop_empty ( Uri . query_of_encode...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RegisterInstancesWithLoadBalancerResponse " ( snd xml ) ) ( Xml . member " RegisterInstancesWithLoadBalancerResult " ) in try Util . or_error ( Util . option_bind resp RegisterEndPointsOutput . parse ) ( let ope...
let parse_error code err = let errors = [ Errors_internal . InvalidInstance ; Errors_internal . LoadBalancerNotFound ] @ 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 ...
type paired_register = [ ` Af | ` Bc | ` De | ` Hl ] [ @@ deriving sexp ]
let register_of_sexp _ = assert false
let sexp_of_register reg = let name = match reg with | 0 -> ' A ' | 1 -> ' F ' | 2 -> ' B ' | 3 -> ' C ' | 4 -> ' D ' | 5 -> ' E ' | 6 -> ' H ' | 7 -> ' L ' | _ -> ' ' ? in sexp_of_char name
let flag_of_sexp _ = assert false
let sexp_of_flag flag = let name = match flag with | 4 -> ' Z ' | 5 -> ' N ' | 6 -> ' H ' | 7 -> ' C ' | _ -> ' ' ? in sexp_of_char name
let make ( ) = let t = Bigstringaf . create 8 in Bigstringaf . set t a ' \ 000 ' ; Bigstringaf . set t f ' \ 000 ' ; Bigstringaf . set t b ' \ 000 ' ; Bigstringaf . set t c ' \ 000 ' ; Bigstringaf . set t d ' \ 000 ' ; Bigstringaf . set t e ' \ 000 ' ; Bigstringaf . set t h ' \ 000 ' ; Bigstringaf . set t l ' \ 000 ' ;...
let get t register = Bigstringaf . get t register
let set t register = Bigstringaf . set t register
let get_pair t = function | ` Af -> ( Bigstringaf . get_int16_be t a ) land 0xFFF0 | ` Bc -> Bigstringaf . get_int16_be t b | ` De -> Bigstringaf . get_int16_be t d | ` Hl -> Bigstringaf . get_int16_be t h
let set_pair t = function | ` Af -> Bigstringaf . set_int16_be t ( a land 0xFFF0 ) | ` Bc -> Bigstringaf . set_int16_be t b | ` De -> Bigstringaf . set_int16_be t d | ` Hl -> Bigstringaf . set_int16_be t h
let set_flag t flag = let flags = get t f in set t f ( Uint8 . set_bit flags flag )
let unset_flag t flag = let flags = get t f in set t f ( Uint8 . unset_bit flags flag )
let toggle_flag t flag = let flags = get t f in set t f ( Uint8 . toggle_bit flags flag )
let is_flag_set t flag = let flags = get t f in Uint8 . is_bit_set flags flag
let clear_flags t = unset_flag t z ; unset_flag t n ; unset_flag t hc ; unset_flag t ca
let write_flag registers flag = function true -> set_flag registers flag | false -> unset_flag registers flag
let write_flags ? z : f1 ? n : f2 ? hc : f3 ? ca : f4 r = let iter_opt f = function | Some v -> f v | None -> ( ) in iter_opt ( write_flag r z ) f1 ; iter_opt ( write_flag r n ) f2 ; iter_opt ( write_flag r hc ) f3 ; iter_opt ( write_flag r ca ) f4
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 " , [ " RegisterTransitGatewayMulticastGroupMembers " ] ) ] ( Util . drop_empty ( Uri . query...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RegisterTransitGatewayMulticastGroupMembersResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RegisterTransitGatewayMulticastGroupMembersResult . parse ) ( let open Error in BadResponse { body ; message = " Coul...
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
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 " , [ " RegisterTransitGatewayMulticastGroupSources " ] ) ] ( Util . drop_empty ( Uri . query...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RegisterTransitGatewayMulticastGroupSourcesResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RegisterTransitGatewayMulticastGroupSourcesResult . parse ) ( let open Error in BadResponse { body ; message = " Coul...
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
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 " , [ " 2010 - 05 - 15 " ] ) ; ( " Action " , [ " RegisterType " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query . render ( ...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RegisterTypeResponse " ( snd xml ) ) ( Xml . member " RegisterTypeResult " ) in try Util . or_error ( Util . option_bind resp RegisterTypeOutput . parse ) ( let open Error in BadResponse { body ; message = " Cou...
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
module Conv_to_ppx_deriving = Migrate_parsetree . Convert ( Selected_ast ) Selected_ast ( Migrate_parsetree . OCaml_current ) OCaml_current
module Conv_from_ppx_deriving = Migrate_parsetree . Convert ( Migrate_parsetree . OCaml_current ) OCaml_current ( Selected_ast ) Selected_ast
let digest s = Md5 . digest_string s |> Md5 . to_hex
let checked_interpolations_statically ~ loc msg label_names = match msg with | { pexp_desc = Pexp_constant ( Pconst_string ( s , _ ) _ ) _ ; _ } -> ( match Interpolator_lib . Interpolator . parse s with | Error err -> Location . raise_errorf ~ loc " Encountered an error while parsing the msg : % s " err | Ok items -> L...
let generate_loggers_and_parsers ~ loc : _ ~ path ty_ext msg_opt = let ctor , label_decls = match ty_ext . ptyext_constructors with | [ { pext_name ; pext_kind = Pext_decl ( Pcstr_record labels , None ) None ; _ } ] -> ( pext_name . txt , labels ) labels | [ { pext_name ; pext_kind = Pext_decl ( Pcstr_tuple [ ] , None ...
let generate_signature_items ~ loc ~ path : _ ty_ext = List . concat_map ty_ext . ptyext_constructors ~ f ( : fun { pext_name ; _ } -> let event_name = String . lowercase pext_name . txt in let ( module Ast_builder ) Ast_builder = Ast_builder . make loc in let open Ast_builder in [ psig_value ( value_description ~ name...
let str_type_ext = let args = let open Ppxlib . Deriving . Args in empty +> arg " msg " __ in Ppxlib . Deriving . Generator . make args generate_loggers_and_parsers
let sig_type_ext = Ppxlib . Deriving . Generator . make_noarg generate_signature_items
let ( ) = Ppxlib . Deriving . add deriver ~ str_type_ext ~ sig_type_ext |> Ppxlib . Deriving . ignore
let check_client_node_proto_agree ( rpc_context : # RPC_context . simple ) ( proto_hash : Protocol_hash . t ) ( chain : Block_services . chain ) ( block : Block_services . block ) : unit tzresult Lwt . t = let open Lwt_tzresult_syntax in let * { current_protocol ; _ } = Block_services . protocols rpc_context ~ chain ~ ...
let get_node_protocol ( rpc_context : # RPC_context . simple ) ( chain : Block_services . chain ) ( block : Block_services . block ) : Protocol_hash . t tzresult Lwt . t = let open Lwt_tzresult_syntax in let * { current_protocol ; _ } = Block_services . protocols rpc_context ~ chain ~ block ( ) in return current_protoc...
module type Proxy_sig = sig val protocol_hash : Protocol_hash . t val directory : Tezos_protocol_environment . rpc_context RPC_directory . t val hash : # RPC_context . simple -> ? chain : Block_services . chain -> ? block : Block_services . block -> unit -> Block_hash . t tzresult Lwt . t val init_env_rpc_context : Tez...
type proxy_environment = ( module Proxy_sig )
let registered : proxy_environment list ref = ref [ ]
let register_proxy_context m = let ( module INCOMING_P : Proxy_sig ) = m in if List . exists ( fun ( module P : Proxy_sig ) -> Protocol_hash . ( P . protocol_hash = INCOMING_P . protocol_hash ) ) ! registered then raise @@ Invalid_argument ( Format . asprintf " A proxy environment for protocol % a is registered already...
let get_all_registered ( ) : proxy_environment list = ! registered
let get_registered_proxy ( printer : Tezos_client_base . Client_context . printer ) ( rpc_context : # RPC_context . simple ) ( mode : [ < ` Mode_light | ` Mode_proxy ] ) ( ? chain = ` Main ) ( ? block = ` Head 0 ) ( protocol_hash_opt : Protocol_hash . t option ) : proxy_environment tzresult Lwt . t = let open Lwt_tzres...
type t = { chain : Chain_id . t ; rpc_context : Tezos_protocol_environment . rpc_context ; protocol_data : bytes ; }
module type PROTOCOL = sig val hash : Protocol_hash . t include Tezos_protocol_environment . PROTOCOL end
module type MOCKUP = sig type parameters type protocol_constants val parameters_encoding : parameters Data_encoding . t val default_parameters : parameters val protocol_constants_encoding : protocol_constants Data_encoding . t val default_protocol_constants : Tezos_client_base . Client_context . full -> protocol_consta...
module type S = sig module type MOCKUP = MOCKUP module type PROTOCOL = PROTOCOL type mockup_context = t type mockup_environment = ( module MOCKUP ) val register_mockup_environment : mockup_environment -> unit val get_registered_environments : unit -> mockup_environment list end
module type T = sig include S module type S = S module Internal_for_tests : sig module Make ( ) : S end end
type entry = { name : int32 ; version : int32 ; }
type t = { db : ( string , entry ) Hashtbl . t ; registry : [ ` V1 ] Wl_registry . t ; }
type ( ' a , ' v ) handler = < ( ' a , ' v , [ ` Client ] ) Proxy . Service_handler . t ; bind_version : ' v ; >
let add db ~ name ~ interface ~ version = Hashtbl . add db interface { name ; version }
let remove db ~ name = db |> Hashtbl . filter_map_inplace ( fun _iface v -> if v . name = name then None else Some v )
let of_display d = let db = Hashtbl . create 20 in let registry = Wl_display . get_registry ( Client . wl_display d ) @@ object inherit [ _ ] Wl_registry . v1 method on_global _ = add db method on_global_remove _ = remove db end in let * ( ) = Client . sync d in Lwt . return { db ; registry }
let get t = Hashtbl . find_all t . db
let get_exn t interface = match get t interface with | [ ] -> Fmt . failwith " Required interface % S not found in registry " ! interface | e :: _ -> e
let bind t handler = let iface = Proxy . Service_handler . interface handler in let min_version = handler # min_version in let { name ; version = service_max_version } = get_exn t iface in if service_max_version < min_version then Fmt . failwith " Can ' t use version % ld of % s ; registry only supports <= % ld " min_v...
let wl_registry t = t . registry
let regress_files = let blank_fun = ( fun ( _ : Config . config ) -> ( ) ) in let def = { t_short = None ; t_long = None ; t_name " " ; = t_atom = T_unknown ; t_descr = None ; t_default = None } in [ ( " strings . conf " , Pass , ] , ( fun conf -> print_endline ( sprintf " POST : strings . conf , config1 = % s " ( stri...
let result file ex ac =
let _ = let regress_files = try ignore ( Sys . getenv ( " REGRESS_CMDLINE " ) ) ; [ List . hd regress_files ] with Not_found -> regress_files in List . iter ( fun ( file , res , ty , postfn ) -> printf " ===> Testing : % s \ n " file ; try v # dump ; postfn v ; with ) regress_files
let capture_output : out_channel option ref = ref None
let capture line = match ! capture_output with | None -> ( ) | Some channel -> output_string channel line ; output_string channel " \ n "
let hooks = Process . { on_spawn = ( fun command arguments -> let message = Log . quote_shell_command command arguments in capture " " ; capture message ) ; on_log = capture ; }
let run_and_capture_output ~ output_file ( f : unit -> ' a Lwt . t ) = let rec create_parent filename = let parent = Filename . dirname filename in if String . length parent < String . length filename then ( create_parent parent ; if not ( Sys . file_exists parent ) then Unix . mkdir parent 0o755 ) in create_parent out...
let log_regression_diff diff = List . iter ( fun line -> if String . length line = 0 then Log . log ~ level : Error " " else let color = match line . [ 0 ] with | ' ' + -> Log . Color . FG . green | ' ' - -> Log . Color . FG . red | ' ' @ -> Log . Color . FG . cyan | _ -> Log . Color . reset in Log . log ~ level : Erro...
let register ~ __FILE__ ~ title ~ tags ~ output_file ( ? regression_output_path = " tezt / _regressions " ) f = let tags = " regression " :: tags in let output_file = Format . asprintf " % s . out " output_file in let stored_output_file = regression_output_path // output_file in Test . register ~ __FILE__ ~ title ~ tag...
let test_versions = ( " 13 . 0 . 0 " , " 14 . 0 . 0 ) "
let interval s e = Array . to_list ( Array . init ( e - s ) s ( fun pos -> s + pos ) pos ) pos
let test_exception name x = try let l = List . assoc name regressions in List . iter ( fun ( s , e ) e -> if s <= x && x <= e then raise Found ) Found l with Not_found -> ( )
let compare name old_l new_l = let code_points = List . fold_left ( fun res ( s , e ) e -> res @ interval s e ) e [ ] old_l in let test x = try test_exception name x ; List . iter ( fun ( s , e ) e -> if s <= x && x <= e then raise Found ) Found new_l ; false with Found -> true in List . iter ( fun x -> if not ( test x...
let test new_l ( name , old_l ) old_l = if name <> " cn " then compare name old_l ( List . assoc name new_l ) new_l
let ( ) = if ( Unicode_old . version , Sedlex_ppx . Unicode . version ) version <> test_versions then failwith ( Printf . sprintf " Test written for versions : % s => % s \ n " %! Unicode_old . version Sedlex_ppx . Unicode . version ) version ; Printf . printf " Testing Unicode regression : % s => % s \ n " %! Unicode_...
type ' a p = P of ' a * ' a object ( self ) method virtual m_P : ' i -> ( ( ' i -> ' a p -> ' s ) * ' a p ) -> ( ( ' i -> ' a -> ' s ) * ' a ) -> ( ( ' i -> ' a -> ' s ) * ' a ) -> ' s method virtual t_p : ( ' i -> ' a -> ' s ) -> ' i -> ' a p -> ' s end
let rec transform_p : ( ' i -> ' a -> ' s ) -> ( ' a , ' i , ' s ) # p_t -> ' i -> ' a p -> ' s = fun fa t acc x -> let self = transform_p fa t in match x with | P ( a , b ) -> t # m_P acc ( self , x ) ( fa , a ) ( fa , b ) object ( self ) inherit [ ' a , unit , string ] p_t method m_P ( ) ( _ , _ ) ( fa , a ) ( fb , b...
type ' a q = N | C of ' a * ' a q object ( self ) method virtual m_N : ' i -> ( ( ' i -> ' a q -> ' s ) * ' a q ) -> ' s method virtual m_C : ' i -> ( ( ' i -> ' a q -> ' s ) * ' a q ) -> ( ( ' i -> ' a -> ' s ) * ' a ) -> ( ( ' i -> ' a q -> ' s ) * ' a q ) -> ' s method virtual t_q : ( ' i -> ' a -> ' s ) -> ' i -> '...
let rec transform_q : ( ' i -> ' a -> ' s ) -> ( ' a , ' i , ' s ) # q_t -> ' i -> ' a q -> ' s = fun fa t acc x -> let self = transform_q fa t in match x with | N -> t # m_N acc ( self , x ) | C ( a , b ) -> t # m_C acc ( self , x ) ( fa , a ) ( self , b ) object ( self ) inherit [ ' a , unit , string ] q_t method m_N...
type ( ' a , ' b ) t = A of ' a * ( ' b , ' a ) t p | B of ' b * ( ' a , ' b ) t q object ( self ) method virtual m_A : ' i -> ( ( ' i -> ( ' a , ' b ) t -> ' s ) * ( ' a , ' b ) t ) -> ( ( ' i -> ' a -> ' s ) * ' a ) -> ( ( ' i -> ( ' b , ' a ) t p -> ' s ) * ( ' b , ' a ) t p ) -> ' s method virtual m_B : ' i -> ( ( ...
let rec transform_t = fun fa fb t acc x -> let self = transform_t fa fb t in let self_b_a = transform_t fb fa t in match x with | A ( a , p ) -> t # m_A acc ( self , x ) ( fa , a ) ( t # t_p self_b_a , p ) | B ( b , q ) -> t # m_B acc ( self , x ) ( fb , b ) ( t # t_q self , q ) object ( self ) inherit [ ' a , ' b , un...
let _ = let x = B ( " 1 " , C ( A ( 2 , P ( B ( 3 , N ) , B ( 4 , N ) ) ) , N ) ) in Printf . printf " % s \ n " ( transform_t ( fun ( ) x -> string_of_int x ) ( fun ( ) x -> x ) ( new show_t ) ( ) x )
type t = | Ok of RD . Set . t | Unreachable
let inter regs1 regs2 = match regs1 , regs2 with | Unreachable , _ -> regs2 | _ , Unreachable -> regs1 | Ok avail1 , Ok avail2 -> let result = RD . Set . fold ( fun reg1 result -> match RD . Set . find_reg_exn avail2 ( RD . reg reg1 ) with | exception Not_found -> result | reg2 -> let debug_info1 = RD . debug_info reg1...
let equal t1 t2 = match t1 , t2 with | Unreachable , Unreachable -> true | Unreachable , Ok _ | Ok _ , Unreachable -> false | Ok regs1 , Ok regs2 -> RD . Set . equal regs1 regs2
let canonicalise availability = match availability with | Unreachable -> Unreachable | Ok availability -> let regs_by_ident = V . Tbl . create 42 in RD . Set . iter ( fun reg -> match RD . debug_info reg with | None -> ( ) | Some debug_info -> let name = RD . Debug_info . holds_value_of debug_info in if not ( V . persi...
let print ~ print_reg ppf = function | Unreachable -> Format . fprintf ppf " < unreachable " > | Ok availability -> Format . fprintf ppf " { % a } " ( Format . pp_print_list ~ pp_sep ( : fun ppf ( ) -> Format . fprintf ppf " , @ " ) ( Reg_with_debug_info . print ~ print_reg ) ) ( RD . Set . elements availability )
module Debug_info = struct type t = { holds_value_of : V . t ; part_of_value : int ; num_parts_of_value : int ; which_parameter : int option ; provenance : unit option ; } let compare t1 t2 = let c = V . compare t1 . holds_value_of t2 . holds_value_of in if c <> 0 then c else Stdlib . compare ( t1 . part_of_value , t1 ...
module T = struct type t = { reg : Reg . t ; debug_info : Debug_info . t option ; } module Order = struct type t = Reg . t let compare ( t1 : t ) ( t2 : t ) = t1 . stamp - t2 . stamp end let compare t1 t2 = Order . compare t1 . reg t2 . reg end
let create ~ reg ~ holds_value_of ~ part_of_value ~ num_parts_of_value ~ which_parameter ~ provenance = assert ( num_parts_of_value >= 1 ) ; assert ( part_of_value >= 0 && part_of_value < num_parts_of_value ) ; assert ( match which_parameter with None -> true | Some index -> index >= 0 ) ; let debug_info : Debug_info ....
let create_with_debug_info ~ reg ~ debug_info = { reg ; debug_info ; }
let create_without_debug_info ~ reg = { reg ; debug_info = None ; }
let create_copying_debug_info ~ reg ~ debug_info_from = { reg ; debug_info = debug_info_from . debug_info ; }
let reg t = t . reg
let location t = t . reg . loc