text
stringlengths
0
601k
let pp_print_ref mf_a fmt v = fprintf fmt " [ { @ contents =% a } ] " @ mf_a ( ! v )
let pp_print_list mf_a fmt lst = let open List in fprintf fmt " [ @< 1 [ >% a ] ] " @ ( fun fmt -> iter ( fun x -> fprintf fmt " % a @ " mf_a x ) ) lst
let pp_print_exn fmt ( e : exn ) = fprintf fmt " % s " ( Printexc . to_string e )
let eq_list mf_a xs ys = let rec loop = function | ( [ ] , [ ] ) -> true | ( x :: xs , y :: ys ) -> ( mf_a x y ) && ( loop ( xs , ys ) ) | ( _ , _ ) -> false in loop ( xs , ys )
let eq_array mf_a xs ys = let lx = Array . length xs and ly = Array . length ys in if lx <> ly then false else ( let rec loop i = if i >= lx then true else if mf_a ( xs . ( i ) ) ( ys . ( i ) ) then loop ( i + 1 ) else false in loop 0 )
let pp_print_array mf_a fmt lst = let open Array in fprintf fmt " [ @< 1 [ >|% a ] ] " |@ ( fun fmt -> iter ( fun x -> fprintf fmt " % a @ " mf_a x ) ) lst
let eq_arrow _mf_a _mf_b _a _b = false
let pp_print_arrow _mf_a _f_b fmt _v = fprintf fmt " <<< function " >>> object ( self : ' self_type ) method int = pp_print_int method int32 = pp_print_int32 method int64 = pp_print_int64 method nativeint = pp_print_nativeint method float = pp_print_float method string = pp_print_string method bool = pp_print_bool meth...
let plugin = ` Extra , " StdFiles " , Some OASISConf . version_short
let self_id , all_id = Extra . create plugin
let markdown = OASISFeatures . create " stdfiles_markdown " ~ plugin OASISFeatures . alpha ( fun ( ) -> s_ " Use markdown comment and replace . txt extensions of standard files by . md . " )
type package = | LTool of prog | LFindlibPackage of name * ( OASISVersion . comparator option )
let facts = [ LFindlibPackage ( " ocaml " , None ) , [ " camlp4 " ; " camlp4boot " ; " camlp4o " ; " camlp4of " ; " camlp4of . opt " ; " camlp4oof " ; " camlp4oof . opt " ; " camlp4o . opt " ; " camlp4orf " ; " camlp4orf . opt " ; " camlp4prof " ; " camlp4r " ; " camlp4rf " ; " camlp4rf . opt " ; " camlp4r . opt " ; " ...
let merge_version_opt ver_opt1 ver_opt2 = match ver_opt1 , ver_opt2 with | Some v1 , Some v2 -> Some ( VAnd ( v1 , v2 ) ) | None , v | v , None -> v
let package_of_tool = let mp = MapString . of_list ( List . fold_left ( fun acc ( pkg , tools , _ ) -> List . fold_left ( fun acc tool -> ( tool , pkg ) :: acc ) acc tools ) [ ] facts ) in fun tool -> try MapString . find tool mp with Not_found -> LTool tool
let package_of_library = let mp = MapString . of_list ( List . fold_left ( fun acc ( pkg , _ , libs ) -> List . fold_left ( fun acc lib -> ( lib , pkg ) :: acc ) acc libs ) [ ] facts ) in fun lib ver_opt -> try MapString . find lib mp with Not_found -> LFindlibPackage ( lib , ver_opt )
type t = { readme : unix_filename option ; install : unix_filename option ; authors : unix_filename option ; }
let pivot_data = data_new_property plugin
let default_filenames = let mp = MapString . of_list ( [ " README " , " README . txt " ; " INSTALL " , " INSTALL . txt " ; " AUTHORS " , " AUTHORS . txt " ] ) in fun fn -> try MapString . find fn mp with Not_found -> failwithf ( f_ " No default filename for file % s . " ) fn
let generator = let fn_enable fn sync = let enable = new_field OASISPackage . schema all_id fn ~ default : true boolean ( fun ( ) -> Printf . sprintf ( f_ " Enable % s file generation . " ) fn ) pivot_data ( fun t t ' -> ( sync t t ' ) <> None ) in let fn = new_field OASISPackage . schema all_id ( fn " ^ Filename " ) ~...
module SetSection = Set . Make ( struct type t = section let compare = compare end )
let main ctxt pkg = let data = pkg . schema_data in let all_build_sections_set = let all_build_sections = List . rev ( List . fold_left ( fun acc -> function | Library ( _ , bs , _ ) | Object ( _ , bs , _ ) | Executable ( _ , bs , _ ) as sct -> ( sct , bs ) :: acc | SrcRepo _ | Flag _ | Test _ | Doc _ -> acc ) [ ] pkg ...
let init ( ) = register_help plugin { ( help_default StdFilesData . readme_template_mkd ) with help_order = 50 } ; Extra . register_act self_id main ; register_generator_package all_id pivot_data generator
type input_request = { stdin_prompt : string [ @ key " prompt " ] ; stdin_password : bool [ @ key " password " ] ; } [ @@ deriving yojson ] [ @@ yojson . allow_extra_fields ]
type input_reply = { stdin_value : string [ @ key " value " ] ; } [ @@ deriving yojson ] [ @@ yojson . allow_extra_fields ]
type reply = | STDIN_INPUT_REQ of input_request [ @ name " input_request " ]
type request = | STDIN_INPUT_REP of input_reply [ @ name " input_reply " ]
module type Int = sig type t val zero : t val one : t val max_int : t val min_int : t val bits : int val ( + ) : t -> t -> t val ( - ) : t -> t -> t val ( * ) : t -> t -> t val ( / ) : t -> t -> t val add : t -> t -> t val sub : t -> t -> t val mul : t -> t -> t val div : t -> t -> t val rem : t -> t -> t val succ : t ...
module Int8 = struct module Base = struct include Int_wrapper . Make_signed ( Make_signedstruct let bits = 8 end ) end let fmt = " hh " let name = " Int8 " end include Base external of_nativeint : nativeint -> int8 = " int8_of_nativeint " [ @@ noalloc ] noalloc external of_float : float -> int8 = " int8_of_float " [ @@...
module Int16 = struct module Base = struct include Int_wrapper . Make_signed ( Make_signedstruct let bits = 16 end ) end let fmt = " h " let name = " int16 " end include Base external of_nativeint : nativeint -> int16 = " int16_of_nativeint " [ @@ noalloc ] noalloc external of_float : float -> int16 = " int16_of_float ...
module Int24 = struct module Base = struct include Int_wrapper . Make_signed ( Make_signedstruct let bits = 24 end ) end let fmt = " l " let name = " Int24 " end include Base external of_nativeint : nativeint -> int24 = " int24_of_nativeint " external of_float : float -> int24 = " int24_of_float " external of_int8 : in...
module Int32 = struct module Base = struct include Int32 let bits = 32 let fmt = " l " let name = " int32 " let divmod = ( fun x y -> div x y , rem x y ) y end include Base let of_nativeint = Nativeint . to_int32 let to_nativeint = Nativeint . of_int32 external of_int8 : int8 -> int32 = " int32_of_int8 " external of_in...
module Int64 = struct module Base = struct include Int64 let bits = 64 let fmt = " ll " let name = " int64 " let divmod = ( fun x y -> div x y , rem x y ) y end include Base external of_int8 : int8 -> int64 = " int64_of_int8 " external of_int16 : int16 -> int64 = " int64_of_int16 " external of_int24 : int24 -> int64 = ...
module Int40 = struct module Base = struct include Int64 . Base let bits = 40 let fmt = " ll " let name = " Int40 " external mul : int40 -> int40 -> int40 = " int40_mul " external div : int40 -> int40 -> int40 = " int40_div " external logxor : int40 -> int40 -> int40 = " int40_xor " external shift_right : int40 -> int ...
module Int48 = struct module Base = struct include Int64 . Base let bits = 48 let fmt = " ll " let name = " Int48 " external mul : int48 -> int48 -> int48 = " int48_mul " external div : int48 -> int48 -> int48 = " int48_div " external logxor : int48 -> int48 -> int48 = " int48_xor " external shift_right : int48 -> int ...
module Int56 = struct module Base = struct include Int64 . Base let bits = 56 let fmt = " ll " let name = " Int56 " external mul : int56 -> int56 -> int56 = " int56_mul " external div : int56 -> int56 -> int56 = " int56_div " external logxor : int56 -> int56 -> int56 = " int56_xor " external shift_right : int56 -> int ...
module Int128 = struct module Base = struct type t = int128 let bits = 128 let fmt = " LL " let name = " Int128 " external add : int128 -> int128 -> int128 = " int128_add " external sub : int128 -> int128 -> int128 = " int128_sub " external mul : int128 -> int128 -> int128 = " int128_mul " external div : int128 -> int1...
module Uint8 = struct module Base = struct include Int_wrapper . Make_unsigned ( Make_unsignedstruct let bits = 8 end ) end let fmt = " Uhh " let name = " Uint8 " end include Base external of_nativeint : nativeint -> uint8 = " uint8_of_nativeint " [ @@ noalloc ] noalloc external of_float : float -> uint8 = " uint8_of_f...
module Uint16 = struct module Base = struct include Int_wrapper . Make_unsigned ( Make_unsignedstruct let bits = 16 end ) end let fmt = " Uh " let name = " Uint16 " end include Base external of_nativeint : nativeint -> uint16 = " uint16_of_nativeint " [ @@ noalloc ] noalloc external of_float : float -> uint16 = " uint1...
module Uint24 = struct module Base = struct include Int_wrapper . Make_unsigned ( Make_unsignedstruct let bits = 24 end ) end let fmt = " Ul " let name = " Uint24 " end include Base external of_nativeint : nativeint -> uint24 = " uint24_of_nativeint " [ @@ noalloc ] noalloc external of_float : float -> uint24 = " uint2...
module Uint32 = struct module Base = struct type t = uint32 let bits = 32 let fmt = " Ul " let name = " Uint32 " external add : uint32 -> uint32 -> uint32 = " uint32_add " external sub : uint32 -> uint32 -> uint32 = " uint32_sub " external mul : uint32 -> uint32 -> uint32 = " uint32_mul " external div : uint32 -> uint3...
module Uint64 = struct module Base = struct type t = uint64 let bits = 64 let name = " Uint64 " let fmt = " UL " external add : uint64 -> uint64 -> uint64 = " uint64_add " external sub : uint64 -> uint64 -> uint64 = " uint64_sub " external mul : uint64 -> uint64 -> uint64 = " uint64_mul " external div : uint64 -> uint6...
module Uint40 = struct module Base = struct include Uint64 . Base let bits = 40 let fmt = " Ul " let name = " Uint40 " external mul : uint40 -> uint40 -> uint40 = " uint40_mul " external div : uint40 -> uint40 -> uint40 = " uint40_div " external logxor : uint40 -> uint40 -> uint40 = " uint40_xor " external shift_right ...
module Uint48 = struct module Base = struct include Uint64 . Base let bits = 48 let fmt = " Ul " let name = " Uint48 " external mul : uint48 -> uint48 -> uint48 = " uint48_mul " external div : uint48 -> uint48 -> uint48 = " uint48_div " external logxor : uint48 -> uint48 -> uint48 = " uint48_xor " external shift_right ...
module Uint56 = struct module Base = struct include Uint64 . Base let bits = 56 let fmt = " Ul " let name = " Uint56 " external mul : uint56 -> uint56 -> uint56 = " uint56_mul " external div : uint56 -> uint56 -> uint56 = " uint56_div " external logxor : uint56 -> uint56 -> uint56 = " uint56_xor " external shift_right ...
module Uint128 = struct module Base = struct type t = uint128 let bits = 128 let fmt = " ULL " let name = " Int1128 " external add : uint128 -> uint128 -> uint128 = " uint128_add " external sub : uint128 -> uint128 -> uint128 = " uint128_sub " external mul : uint128 -> uint128 -> uint128 = " uint128_mul " external div ...
module type TESTER = sig val tests : QCheck . Test . t list end
let skip name = QCheck . Test . make ~ count : 0 ~ name
let test name = QCheck . Test . make ~ count : 10 ~ name
let rec binary_string_of_int n = if n = 0 then " 0 " else binary_string_of_int ( n asr 1 ) 1 ^ ( if n land 1 = 0 then " 0 " else " 1 ) "
module IntBounds ( I : Stdint . Int ) Int = struct let mini , maxi = if I ( . to_int max_int ) max_int = - 1 then if I ( . min_int < zero ) zero then min_int / 2 , max_int / 2 else 0 , max_int else I ( . to_int min_int ) min_int , I ( . to_int max_int ) max_int let ( ) = assert ( mini < maxi ) maxi let in_range = QChec...
module Tester ( I : Stdint . Int ) Int : TESTER = struct include IntBounds ( I ) I let ( *** ) = ( * ) open I let tests = [ QCheck . Test . make ~ count : 1 ~ name " : Maximum value is greater than minimum " QCheck . unit ( fun ( ) -> min_int < max_int ) max_int ; test " An integer should not modify an int when convert...
module Tester2 ( I1 : Stdint . Int ) Int ( I2 : Stdint . Int ) Int ( C : sig val of_i2 : I2 . t -> I1 . t end ) end : TESTER = struct let mini , maxi = if I2 ( . to_int max_int ) max_int = - 1 then if I2 ( . min_int < zero ) zero then min_int , max_int else 0 , max_int else I2 ( . to_int min_int ) min_int , I2 ( . to_i...
module OfStringTester ( I : Stdint . Int ) Int = struct let max_str = I ( . to_string max_int ) max_int let max_str_len = String . length max_str let integer_str_gen = QCheck ( . string_gen_of_size ( Gen . return max_str_len ) max_str_len Gen . numeral |> map_same_type ( fun s -> if s <= max_str then s else String . su...
module SignTester ( I : Stdint . Int ) Int = struct include IntBounds ( I ) I open I let tests = [ test " A signed integer should perform negation correctly " pos_int ( fun x -> neg ( of_int x ) x = of_int ( ~- x ) x ) x ; test " Neg is like multiply by minus one " in_range ( fun x -> neg ( of_int x ) x = mul ( neg one...
let ( ) = let ok = ref 0 and ko = ref 0 in let test_mods = Stdint [ . " Int8 " , ( module Tester ( Int8 ) Int8 : TESTER ) TESTER ; " Int16 " , ( module Tester ( Int16 ) Int16 : TESTER ) TESTER ; " Int24 " , ( module Tester ( Int24 ) Int24 : TESTER ) TESTER ; " Int32 " , ( module Tester ( Int32 ) Int32 : TESTER ) TESTER...
type stream = unit ptr
let stream : stream typ = ptr void
let stream_opt : stream option typ = ptr_opt void
let seek_set = foreign " seek_set " ( void @-> returning int )
let fopen = foreign " fopen " ( string @-> string @-> returning stream_opt )
let fseek = foreign " fseek " ( stream @-> long @-> int @-> returning int )
let fread = foreign " fread " ( ptr void @-> size_t @-> size_t @-> stream @-> returning size_t )
let fwrite = foreign " fwrite " ( ptr void @-> size_t @-> size_t @-> stream @-> returning int )
let fclose = foreign " fclose " ( stream @-> returning int )
let rec make_list e len = if len = 0 then [ ] else e ( :: make_list e ( len - 1 ) )
let rec split_list n es = match n , es with | 0 , _ -> [ ] , es | _ , [ ] -> raise ( Failure " split_list : split point beyond length " ) | _ , e :: es -> let fst , snd = split_list ( n - 1 ) es in e :: fst , snd
let fread ' n str = let buf = CArray . make char n in let m = fread ( to_voidp ( CArray . start buf ) ) ( Unsigned . Size_t . of_int 1 ) ( Unsigned . Size_t . of_int n ) str in let res , _ = split_list ( Unsigned . Size_t . to_int m ) ( CArray . to_list buf ) in res
let fwrite ' lst str = let arr = CArray . of_list char lst in let len = Unsigned . Size_t . of_int ( List . length lst ) in fwrite ( to_voidp ( CArray . start arr ) ) ( Unsigned . Size_t . of_int 1 ) len str
module StdioConf = struct type cmd = | Fopen of string * string | Fseek of int | Fread of int | Fwrite of char list | Fclose [ @@ deriving show { with_path = false } ] type state = { status : strstatus ; contents : char list ; pos : int } and strstatus = Open | Closed | Writing | Reading type sut = stream option ref le...
module StdioT = QCSTM . Make ( StdioConf ) ; ; [ StdioT . agree_test ~ count : 200 ~ name " : stdio - model agreement " ]
let ( ) = register_named_value " Pervasives . array_bound_error " ( Invalid_argument " index out of bounds " )
let failwith s = raise ( Failure s )
let invalid_arg s = raise ( Invalid_argument s )
let min x y = if x <= y then x else y
let max x y = if x >= y then x else y
let abs x = if x >= 0 then x else - x
let lnot x = x lxor ( - 1 )
let max_int = ( - 1 ) lsr 1
let min_int = max_int + 1 [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] = " caml_hypot_float " " caml_hypot " [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [...
let infinity = float_of_bits 0x7F_F0_00_00_00_00_00_00L
let neg_infinity = float_of_bits 0xFF_F0_00_00_00_00_00_00L
let nan = float_of_bits 0x7F_F0_00_00_00_00_00_01L
let max_float = float_of_bits 0x7F_EF_FF_FF_FF_FF_FF_FFL
let min_float = float_of_bits 0x00_10_00_00_00_00_00_00L
let epsilon_float = float_of_bits 0x3C_B0_00_00_00_00_00_00L
type fpclass = FP_normal | FP_subnormal | FP_zero | FP_infinite | FP_nan " caml_classify_float " " caml_classify_float_unboxed " [ @@ noalloc ] = " caml_blit_string " [ @@ noalloc ] = " caml_blit_bytes " [ @@ noalloc ]
let ( ^ ) s1 s2 = let l1 = string_length s1 and l2 = string_length s2 in let s = bytes_create ( l1 + l2 ) in string_blit s1 0 s 0 l1 ; string_blit s2 0 s l1 l2 ; bytes_unsafe_to_string s
let char_of_int n = if n < 0 || n > 255 then invalid_arg " char_of_int " else unsafe_char_of_int n
type ' a ref = { mutable contents : ' a }
type ( ' a , ' b ) result = Ok of ' a | Error of ' b
let string_of_bool b = if b then " true " else " false "
let bool_of_string = function | " true " -> true | " false " -> false | _ -> invalid_arg " bool_of_string "
let bool_of_string_opt = function | " true " -> Some true | " false " -> Some false | _ -> None
let string_of_int n = format_int " % d " n
let int_of_string_opt s = try Some ( int_of_string s ) with Failure _ -> None
let valid_float_lexem s = let l = string_length s in let rec loop i = if i >= l then s ^ " . " else match string_get s i with | ' 0 ' . . ' 9 ' | ' ' - -> loop ( i + 1 ) | _ -> s in loop 0
let string_of_float f = valid_float_lexem ( format_float " . % 12g " f )
let float_of_string_opt s = try Some ( float_of_string s ) with Failure _ -> None
let rec ( @ ) l1 l2 = match l1 with [ ] -> l2 | hd :: tl -> hd :: ( tl @ l2 )