text stringlengths 12 786k |
|---|
let may x name f = match x with None -> [ ] | Some a -> [ TkToken name ; TkToken ( f a ) ] |
let cbool x = if x then " 1 " else " 0 " |
let id x = x |
let togl_options_optionals f = fun ? accum ? accumalphasize ? accumbluesize ? accumgreensize ? accumredsize ? alpha ? alphasize ? auxbuffers ? bluesize ? depth ? depthsize ? double ? greensize ? height ? overlay ? privatecmap ? redsize ? rgba ? stencil ? stencilsize ? stereo ? width -> f ( may... |
type font = [ ` Fixed_8x13 | ` Fixed_9x15 | ` Times_10 | ` Times_24 | ` Helvetica_10 | ` Helvetica_12 | ` Helvetica_18 | ` Xfont of string ] = " ml_Togl_LoadBitmapFont " = " ml_Togl_UnloadBitmapFont " = " ml_Togl_GetOverlayTransparentValue " = " ml_Togl_DumpToEpsFile " |
type widget = w Widget . widget |
let togl_table = Hashtbl . create 7 |
let wrap f ( w : widget ) = let togl = try Hashtbl . find togl_table w with Not_found -> raise ( TkError " Unreferenced togl widget " ) in f togl |
let render = wrap _post_redisplay |
let swap_buffers = wrap _swap_buffers |
let height = wrap _height |
let width = wrap _width |
let load_bitmap_font = wrap _load_bitmap_font |
let unload_bitmap_font = wrap _unload_bitmap_font |
let use_layer = wrap _use_layer |
let show_overlay = wrap _show_overlay |
let hide_overlay = wrap _hide_overlay |
let overlay_redisplay = wrap _post_overlay_redisplay |
let exists_overlay = wrap _exists_overlay |
let get_overlay_transparent_value = wrap _get_overlay_transparent_value |
let make_current togl = ignore ( tkEval [ | TkToken ( Widget . name togl ) ; TkToken " makecurrent " ] ) | |
let null_func _ = ( ) |
let display_table = Hashtbl . create 7 |
let cb_of_togl table togl = try let key = _ident togl in let cb = Hashtbl . find table key in ignore ( tkEval [ | TkToken key ; TkToken " makecurrent " ] ) ; | cb ( ) with Not_found -> ( ) |
let callback_table = [ | null_func ; cb_of_togl display_table ; cb_of_togl reshape_table ; null_func ; null_func ; cb_of_togl overlay_table ; null_func ] | |
let ( ) = Callback . register " togl_callbacks " callback_table ; Callback . register " togl_prerr " ( fun msg -> prerr_string msg ; flush stderr ) |
let callback_func table ( w : widget ) ~ cb = let key = Widget . name w in ( try Hashtbl . remove table key with Not_found -> ( ) ) ; Hashtbl . add table key cb |
let display_func = callback_func display_table |
let reshape_func w ~ cb = make_current w ; cb ( ) ; callback_func reshape_table w ~ cb |
let overlay_display_func = callback_func overlay_table |
let dump_to_eps_file ~ filename ( ? rgba = false ) ? render togl = let render = match render with Some f -> f | None -> in callback_table . ( render_id ) <- ( fun _ -> render ( ) ) ; _dump_to_eps_file togl filename rgba |
let dump_to_eps_file ~ filename ? rgba ? render = wrap ( dump_to_eps_file ~ filename ? rgba ? render ) |
let rec timer_func ~ ms ~ cb = ignore ( Timer . add ~ ms ~ callback ( : fun ( ) -> cb ( ) ; timer_func ~ ms ~ cb ) ) |
let configure ? height ? width w = let options = may height " - height " cint @ may width " - width " cint in tkEval [ | TkToken ( Widget . name w ) ; TkTokenList options ] | |
let ready = ref false |
let init_togl ( ) = init ( ) ; _create_func ( ) ; _display_func ( ) ; _reshape_func ( ) ; _overlay_display_func ( ) ; _destroy_func ( ) ; ready := true |
let create ? name = togl_options_optionals ( fun options parent -> prerr_endline " Before init " ; if not ! ready then init_togl ( ) ; prerr_endline " After init " ; let w : widget = let togl = ref None in callback_table . ( create_id ) <- callback_table . ( destroy_id ) <- ( ... |
module Make ( Loc : Sig . Loc ) module Loc = Loc ; open Sig ; type t = camlp4_token ; type token = t ; value to_string = fun [ KEYWORD s -> sprintf " KEYWORD % S " s | SYMBOL s -> sprintf " SYMBOL % S " s | LIDENT s -> sprintf " LIDENT % S " s | UIDENT s -> sprintf " UIDENT ... |
module Eval = struct value valch x = Char . code x - Char . code ' 0 ' ; value valch_hex x = let d = Char . code x in if d >= 97 then d - 87 else if d >= 65 then d - 55 else d - 48 ; value rec skip_indent = parser [ [ : ` ' ' | ' \ t ' ; s ] : -> skip_indent s | [ ... |
let niter = ref 0 |
let token = ref 0 |
let process ( n , ins , outs , nprocs ) = let buf = String . make 1 ' . ' in while buf <> " " - do Unix . read ins . ( n ) buf 0 1 ; if n = 0 then begin decr niter ; if ! niter <= 0 then buf . [ 0 ] <- ' ' ; - end ; let next = if n + 1 >= nprocs then 0 ... |
let main ( ) = let nprocs = try int_of_string Sys . argv . ( 1 ) with _ -> 100 in let iter = try int_of_string Sys . argv . ( 2 ) with _ -> 1000 in let ins = Array . make nprocs Unix . stdin in let outs = Array . make nprocs Unix . stdout in let threads = Array . make nprocs ... |
type domain = [ ` Absolute of string list | ` Sub of string list ] |
type name = { domain : domain ; name : string } |
let pp_print_domains : domain Formatf . t = fun fmt -> function | ` Absolute ( _a0 : string list ) -> Format . fprintf fmt " . % s " ( String . concat " . " _a0 ) | ` Sub _a0 -> Format . fprintf fmt " % s " ( String . concat " . " _a0 ) |
let pp_print_name fmt ( x : name ) = Format . fprintf fmt " % a . % a " pp_print_domains x . domain Format . pp_print_string x . name |
let string_of_name = Formatf . to_string pp_print_name |
type quot = { loc : loc ; txt : string ; name : name ; meta : string option ; shift : int ; retract : int ; } |
type txt = { loc : loc ; txt : string ; } |
type op = { loc : loc ; txt : string ; level : int ; } |
type ant = { loc : loc ; txt : string ; cxt : string option ; kind : string ; shift : int ; retract : int ; } |
let ant_expand p ( x : ant ) = let content = String . sub x . txt x . shift ( String . length x . txt - x . retract - x . shift ) in let loc = Location_util . join { x . loc with loc_start = { x . loc . loc_start with pos_cnum = x . loc . loc_start . pos_cnum + x . shi... |
let mk_ant ? c ( x : ant ) = match c with | None -> ` Ant ( x . loc , x ) | Some _ -> ` Ant ( x . loc , { x with cxt = c } ) |
let pp_print_ant fmt ( x : ant ) = Format . fprintf fmt " cxt :% S ; content :% S " ( match x . cxt with None " " ->| Some s -> s ) x . txt |
let pp_print_quot : Format . formatter -> quot -> unit = fun fmt { name ; meta ; shift ; txt ; loc ; retract } -> Format . fprintf fmt " [ @< 1 { > name =% a ; ; @ loc =% a ; @ meta =% a ; ; @ shift =% a ; @ retract =% a ; ; @ txt =% a } ] " @ pp_print_n... |
type ' a expand_fun = Locf . t -> string option -> string -> ' a |
type quotation = [ ` Quot of quot ] |
type dir_quotation = [ ` DirQuotation of quot ] |
type line = { loc : loc ; txt : string ; line : int ; name : string option ; } |
type space_token = [ ` Comment of txt | ` Blank of txt | ` Newline of txt | ` LINE_DIRECTIVE of line ] |
type t = [ ` Key of txt | ` Lid of txt | ` Uid of txt | ` Int of txt | ` Int32 of txt | ` Int64 of txt | ` Nativeint of txt | ` Flo of txt | ` Chr of txt | ` Label of txt | ` Optlabel of txt | ` Str of txt | ` EOI of txt | ` Pre of txt | ` Inf of op | ` Quot of quot | ... |
type tag = [ ` Key | ` Lid | ` Uid | ` Int | ` Int32 | ` Int64 | ` Nativeint | ` Flo | ` Chr | ` Label | ` Optlabel | ` Str | ` EOI | ` Pre | ` Inf | ` Quot | ` DirQuotation | ` Ant ] |
type word = | Any | A of string | Kind of string | Level of int tag : tag ; word : word ; tag_name : string ; } |
type pattern = { descr : descr } |
let string_of_descr ( x : descr ) = match x . word with | Any -> x . tag_name | Kind s -> x . tag_name ^ " " ^ s | A s -> Printf . sprintf " % S " s | Level d -> x . tag_name ^ Printf . sprintf " Level % d " d |
let string_of_pattern ( x : pattern ) = string_of_descr x . descr |
let eq_pattern ( x : pattern ) ( y : pattern ) : bool = x . descr = y . descr |
let quot_expand ( expander ' : a expand_fun ) ( x : quot ) = let loc = Location_util . join { x . loc with loc_start = { x . loc . loc_start with pos_cnum = x . loc . loc_start . pos_cnum + x . shift } } in let content = String . sub x . txt x . shift ( String . lengt... |
let pp_print_quotation : Format . formatter -> quotation -> unit = fun fmt ( ` Quot x ) -> Format . fprintf fmt " [ @< 1 ( ` > Quot % a ) ] " @ pp_print_quot x |
let pp_print_dir_quotation : Format . formatter -> dir_quotation -> unit = fun fmt ( ` DirQuotation x ) -> Format . fprintf fmt " [ @< 1 ( ` > DirQuotation % a ) ] " @ pp_print_quot x |
let pp_print_t ( fmt : Format . formatter ) ( x : t ) : unit = match x with | ` Inf x -> Format . fprintf fmt " [ @< 1 ( ` > Inf @ % a ) ] " @ Format . pp_print_string x . txt | ` Pre x -> Format . fprintf fmt " [ @< 1 ( ` > Pre @ % a ) ] " @ Format ... |
type stream = t Streamf . t |
type ' a parse = stream -> ' a |
type ' a lex = Locf . t -> char Streamf . t -> ' a |
type filter = stream -> stream |
let to_string = Formatf . to_string pp_print_t |
let print ppf x = Format . pp_print_string ppf ( to_string x ) |
let strip ( x : t ) : Obj . t = Obj . field ( Obj . repr x ) 1 |
let get_tag ( x : t ) : tag = ( Obj . magic ( Obj . field ( Obj . repr x ) 0 ) : tag ) |
let destruct ( x : t ) = ( ( Obj . magic ( Obj . field ( Obj . repr x ) 0 ) : tag ) , Obj . field ( Obj . repr x ) 1 ) |
let get_string ( x : t ) : string = match x with | ` Pre x | ` Key x | ` Lid x | ` Uid x | ` Int x | ` Int32 x | ` Int64 x | ` Nativeint x | ` Flo x | ` Chr x | ` Str x | ` Label x | ` Optlabel x | ` EOI x -> x . txt | ` Quot x -> x . txt | ` DirQuotation x ... |
let get_loc ( x : t ) = match x with | ` Key x | ` Lid x | ` Uid x | ` Int x | ` Int32 x | ` Int64 x | ` Nativeint x | ` Flo x | ` Chr x | ` Pre x | ` Str x | ` Label x | ` Optlabel x | ` EOI x -> x . loc | ` Ant x -> x . loc | ` Quot x -> x . loc | ` Di... |
let empty_name : name = { domain = ` Sub [ ] ; name = " " } |
let name_of_string s : name = match s . [ 0 ] with | ' . ' -> ( match List . rev @@ List . filter Stringf . not_empty ( Stringf . nsplit s " . " ) with | x :: xs -> { domain = ` Absolute ( List . rev xs ) ; name = x } | _ -> assert false ) ' | A ' . .... |
let match_token ( x : pattern ) = let tag = x . descr . tag in let word = x . descr . word in fun ( token_tag , obj ) -> ( tag = token_tag && ( match word with | Any -> true | Kind s -> ( Obj . magic ( Obj . field obj 3 ) : string ) = s | A s -> ( Obj . magic ( Ob... |
type t = { grant_type : string ; scope : Scopes . t list ; code : string ; client_id : string ; client_secret : string option ; redirect_uri : Uri . t ; } |
let make ( ~ client : Client . t ) ~ grant_type ~ scope ~ redirect_uri ~ code = { grant_type ; scope ; code ; client_id = client . id ; client_secret = client . secret ; redirect_uri ; } |
let to_body_string t = [ ( " grant_type " , [ t . grant_type ] ) ; ( " scope " , [ Scopes . to_scope_parameter t . scope ] ) ; ( " code " , [ t . code ] ) ; ( " client_id " , [ t . client_id ] ) ; ( " client_secret " , [ t . client... |
let of_body_string body = let query = Uri . query_of_encoded body |> Uri . with_query Uri . empty in let gt = Uri . get_query_param query " grant_type " in let s = Uri . get_query_param query " scope " in let c = Uri . get_query_param query " code " in let ci = Uri . get_query_param que... |
type t = { token_type : token_type ; scope : Scopes . t list ; expires_in : int option ; access_token : string option ; refresh_token : string option ; id_token : string option ; } |
let make ( ? token_type = Bearer ) ( ? scope = [ ] ) ? expires_in ? access_token ? refresh_token ? id_token ( ) = { token_type ; scope ; expires_in ; access_token ; refresh_token ; id_token } |
let of_yojson json = try let module Json = Yojson . Safe . Util in let scope = match Json . member " scope " json with | ` Null -> [ ] | ` String scope -> Scopes . of_scope_parameter scope | ` List json -> List . map Json . to_string json |> List . map Scopes . of_string | json ... |
let of_query query = let scope = let qp = Uri . get_query_param query " scope " in Option . value ~ default [ ] : ( Option . map Scopes . of_scope_parameter qp ) in { token_type = Bearer ; scope ; expires_in = Uri . get_query_param query " expires_in " |> Option . map int_of_st... |
let of_string str = Yojson . Safe . from_string str |> of_yojson |
let validate ? clock_tolerance ? nonce ~ jwks ( ~ client : Client . t ) ( ~ discovery : Discover . t ) t = match Jose . Jwt . of_string ( Option . get t . id_token ) with | Ok jwt -> ( if jwt . header . alg = ` None then IDToken . validate ? clock_tolerance ? nonce ~ clie... |
let to_yojson { scope ; expires_in ; access_token ; refresh_token ; id_token ; _ } = let or_null = Option . value ~ default ` : Null in let json_str = Option . map ( fun x -> ` String x ) in ` Assoc [ ( " scope " , match scope with | [ ] -> ` Null | _ -> ` Strin... |
let show input = Eml . Location . reset ( ) ; let underlying = Stream . of_string input in let input_stream = Eml . Location . stream ( fun ( ) -> try Some ( Stream . next underlying ) with _ -> None ) in try input_stream |> Eml . Tokenizer . scan |> List . map Eml . Token ... |
module type TokenKindSig = sig type kind val next : Loc . source -> Lexing . lexbuf -> kind token val kindStr : kind -> string val tokenStr : kind token -> string val isEOF : kind -> bool val getEOF : kind end |
module TokenStream ( S : TokenKindSig ) = struct type stream = { lexbuf : Lexing . lexbuf ; mutable has_errors : bool ; mutable errors : Error . t list ; mutable peeked : S . kind token ; mutable prev : S . kind token ; source : Loc . source } let backup ( s : stream ) = let l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.