text
stringlengths
12
786k
type t_graph = B . G . t * GnoCanvas . pixbuf
let get_graph g = fst g
let get_pixbuf g = snd g
let get_node_info n = B . G . V . label n
let get_coord n = Node . coord ( get_node_info n )
let get_id n = Node . id ( get_node_info n )
let get_obj n = Node . item ( get_node_info n )
let get_info attr_list_list = let get ( shp , p , w , h ) ( attr , val_opt ) = match attr , val_opt with | ( Dot_ast . Ident " shape " ) , Some ( Dot_ast . String s ) -> ( Some s ) , p , w , h | ( Dot_ast . Ident " pos " ) , Some ( Dot_ast . String s ) ...
let compute_coord pos w h = let dot_ppi = 72 . in let dot_png_ppi = 96 . in try let w = float_of_string w in let h = float_of_string h in let x , y = Scanf . sscanf pos " % d , % d " ( fun x y -> ( x , y ) ) in let pad = 4 in let x = float_of_int ( x + pad ) in let y = float_...
module DotParser ( C : sig val mk_node : t_shape -> t_coord -> t_gtk_obj end ) = Dot . Parse ( B ) ( struct let node ( id , _ ) attr_list = let name = match id with | Dot_ast . Ident s | Dot_ast . Number s | Dot_ast . String s | Dot_ast . Html s -> s in let info = match get_info ...
let png_graph_image dot_cmd dot_file png_file = let cmd = Printf . sprintf " % s - T png % s > % s " dot_cmd dot_file png_file in match Sys . command cmd with | 0 -> png_file | _ -> raise ( DotError cmd )
let build_graph dot_cmd dot_file annot_dot_file mk_node_item = let cmd = Printf . sprintf " % s - y % s > % s " dot_cmd dot_file annot_dot_file in match Sys . command cmd with | 0 -> let module Parser = DotParser ( struct let mk_node = mk_node_item end ) in let graph = Parser . parse annot_do...
let get_neighbours graph n = let graph = get_graph graph in let preds = B . G . pred graph n in let succs = B . G . succ graph n in ( preds , succs )
module type SigCb = sig type t_env val button_one_press_on_graph : t_env -> unit val button_two_press_on_graph : t_env -> unit val button_three_press_on_graph : t_env -> unit val button_one_press_on_node : t_env -> t_node -> unit val button_two_press_on_node : t_env -> t_node -> unit val button_three_press...
module EmptyCb = struct type t_env = unit let button_one_press_on_graph _env = ( ) let button_two_press_on_graph _env = ( ) let button_three_press_on_graph _env = ( ) let button_one_press_on_node _env _n = ( ) let button_two_press_on_node _env _n = ( ) let button_three_press_on_node _e...
module M ( Cb : SigCb ) = struct let mk_node_item canvas shp ( ( x1 , y1 ) , ( x2 , y2 ) ) = let no_color = [ ` FILL_COLOR " black " ; ` FILL_STIPPLE ( Gdk . Bitmap . create_from_data ~ width : 1 ~ height : 1 " \ 000 " ) ] in let props = [ ` X1 x1 ; ` ...
module CircLists = struct type t_elem = ViewGraph_core . t_node type t_lists = t_elem list * t_elem list * t_elem list type t = bool * t_lists let mk ( l1 , l2 ) = match l1 , l2 with | [ ] , [ ] -> true , ( [ ] , [ ] , [ ] ) | [ ] , l2 -> false , ( l2 , ...
type t_options = { sel_1_color : string ; sel_2_color : string ; center_node_when_selected : bool ; }
let default_options = { sel_1_color = " red " ; sel_2_color = " green " ; center_node_when_selected = true ; }
type t_widgets = { canvas : GnoCanvas . canvas ; sel_1_txt : GMisc . label ; sel_edge_txt : GMisc . label ; sel_2_txt : GMisc . label ; }
type t_state = { w : t_widgets ; opt : t_options ; mutable graph : ViewGraph_core . t_graph option ; mutable ppu : float ; mutable selected : ViewGraph_core . t_node option ; mutable neighbours : CircLists . t option ; mutable gui_sel : ( ViewGraph_core . t_gtk_obj option ) array ; }...
let change_zoom state delta = state . ppu <- state . ppu . + delta ; state . w . canvas # set_pixels_per_unit state . ppu
let center_selected_node state = match state . selected with | None -> ( ) | Some n -> match ViewGraph_core . get_coord n with | None -> ( ) | Some ( ( x1 , y1 ) , ( x2 , y2 ) ) -> let canvas = state . w . canvas in let x = x1 . + ( x2 . - x1 ) . / 2 . in let...
let key_press state ev = let canvas = state . w . canvas in let ( x , y ) = canvas # get_scroll_offsets in match GdkEvent . Key . keyval ev with | k when k = GdkKeysyms . _Up -> canvas # scroll_to ~ x ~ y ( : y - 20 ) ; true | k when k = GdkKeysyms . _Down -> canvas # scroll_t...
let init options ( canvas : GnoCanvas . canvas ) pack_txt = let _ = GMisc . label ~ text " : Selected : " ~ packing : pack_txt ( ) in let sel_1_txt = GMisc . label ~ packing : pack_txt ( ) in let sel_edge_txt = GMisc . label ~ packing : pack_txt ( ) in let sel_2_txt = GMisc ....
let sel_1_bitmap ( ) = Gdk . Bitmap . create_from_data ~ width : 2 ~ height : 2 " \ 002 \ 001 "
let sel_2_bitmap ( ) = Gdk . Bitmap . create_from_data ~ width : 2 ~ height : 2 " \ 002 \ 001 "
let no_bitmap ( ) = Gdk . Bitmap . create_from_data ~ width : 1 ~ height : 1 " \ 000 "
let move_selection state n_opt1 n_opt2 = let set_props o col bitmap = match o with None -> ( ) | Some o -> o # set [ ` FILL_COLOR col ; ` FILL_STIPPLE bitmap ] in let n_obj n_opt = match n_opt with | None -> None | Some n -> ViewGraph_core . get_obj n in let obj1 = n_obj n_opt1 in let obj2 ...
let show_selection state = let n_opt , txt1 , txt2 , txt3 = match state . selected with | None -> None , " ( none ) " , " " , " " | Some n -> let txt1 = ViewGraph_core . get_id n in let n_opt , txt2 , txt3 = match state . neighbours with | None -> None , " " , " ...
let select_node state n_opt = state . selected <- n_opt ; state . neighbours <- None ; show_selection state
let select_neighbour state = match state . graph with None -> ( ) | Some graph -> match state . selected with None -> ( ) | Some n -> let new_info = match state . neighbours with | None -> let neighbours = ViewGraph_core . get_neighbours graph n in CircLists . mk neighbours | Some info ->...
let goto_neighbour state = match state . graph with None -> ( ) | Some graph -> match state . neighbours with | None -> ( ) | Some info -> match CircLists . current_node info with | None -> ( ) | Some ( _ , n ) -> match state . selected with | None -> assert false | Some old_n ...
let clear_state state = state . graph <- None ; state . ppu <- 1 . ; state . selected <- None ; state . neighbours <- None ; state . gui_sel <- [ | None ; None ] ; | show_selection state
module SelectCb ( UserCb : ViewGraph_core . SigCb ) = struct type t_env = UserCb . t_env * t_state let button_one_press_on_graph ( u_env , state ) = select_node state None ; UserCb . button_one_press_on_graph ( u_env ) let button_two_press_on_graph ( u_env , state ) = select_neighbour ...
module VG ( UserCb : ViewGraph_core . SigCb ) = struct module Cb = SelectCb ( UserCb ) module V = ViewGraph_core . M ( Cb ) let open_dot_file u_env state ( ? dot_cmd " = dot " ) file = let canvas = state . w . canvas in ( match state . graph with None -> ( ) | Some g -> V ...
let show_help ( ) = GToolbox . message_box ~ title " : Help " " Selection :\ n - use the mouse button - 1 to select a node : \ it should turn red and ( optionally ) be centered . - when a node is selected , button - 2 selects one of its neighbour : \ it should turn green . - using b...
module CbTest = struct type t_env = unit let button_one_press_on_graph _env = Format . printf " [ CbTest ] button_one_press_on_graph . " @ let button_two_press_on_graph _env = Format . printf " [ CbTest ] button_two_press_on_graph . " @ let button_three_press_on_graph _env = Format . ...
module V = ViewGraph_select . VG ( CbTest )
let open_file select_init_env file = try let env = ( ) in let _graph = V . open_dot_file env select_init_env file in ( ) with ViewGraph . DotError cmd -> GToolbox . message_box " Error " ( Printf . sprintf " % s failed \ nDidn ' t succed to build graph for % s \ nSorry " ! cmd file...
let open_cb select_init_env ( ) = match GToolbox . select_file ~ title " : Select a dot file " ( ) with | None -> ( ) | Some filename -> open_file select_init_env filename
let help_act_cb _ac = ViewGraph_select . show_help ( )
let error_act_cb ac = GToolbox . message_box " Error " ( Printf . sprintf " Action ' % s ' activated : no callback ?\ n " ac # name )
let quit_cb ( ) = GMain . Main . quit ( )
let quit_act_cb _a = quit_cb ( )
let menu_desc = " < ui >\ < menubar name ' = MenuBar ' >\ < menu action ' = FileMenu ' >\ < menuitem action ' = Open ' />\ < separator />\ < menuitem action ' = Quit ' />\ </ menu >\ < menu action ' = HelpMenu ' >\ < menuitem action ' = Help ' />\ </ menu >\ </ menu...
let create_menu ( ) = let ui_m = GAction . ui_manager ( ) in let actions = GAction . action_group ~ name " : Actions " ( ) in GAction . add_actions actions [ GAction . add_action " FileMenu " ~ label " : File " ; GAction . add_action " Open " ~ label " : Open " ~ ...
let create_gui ( ) = let window = GWindow . window ~ title " : ViewGraph " ~ allow_shrink : true ~ allow_grow : true ( ) in let vbox = GPack . vbox ~ border_width : 4 ~ spacing : 4 ~ packing : window # add ( ) in let ui_m = create_menu ( ) in window # add_accel_group ui_m # ...
let main ( ) = let _ = GMain . Main . init ( ) in let canvas , select_init_env = create_gui ( ) in if Array . length Sys . argv = 2 then open_file select_init_env Sys . argv . ( 1 ) ; GMain . Main . main ( )
let _ = Printexc . print main ( )
let create_scrolled_canvas packing = let frame = GBin . frame ~ shadow_type ` : IN ( ) in let canvas = let aa = false in GnoCanvas . canvas ~ aa ~ width : 600 ~ height : 400 ~ packing : frame # add ( ) in let _ = canvas # set_center_scroll_region true in let table = GPack . table ~ ...
let create_graph_win title = let window = GWindow . window ~ title ~ allow_shrink : true ~ allow_grow : true ( ) in let vbox = GPack . vbox ~ border_width : 4 ~ spacing : 4 ~ packing : window # add ( ) in let help_but = GButton . button ~ label " : Help " ~ packing ( : vbox # ...
let left_click = ref GLUT_UP ; ;
let right_click = ref GLUT_UP ; ;
let xold = ref 0 ; ;
let yold = ref 0 ; ;
let width = ref 0 ; ;
let height = ref 0 ; ;
let rotate_x = ref 30 . 0 ; ;
let rotate_y = ref 15 . 0 ; ;
let alpha = ref 0 . 0 ; ;
let beta = ref 0 . 0 ; ;
let teapot ( ) = glBegin ( GL_LINES ) ; glColor3 ( 1 . 0 ) ( 0 . 0 ) ( 0 . 0 ) ; glVertex3 ( - 1 . 0 ) ( - 1 . 0 ) ( - 1 . 0 ) ; glVertex3 ( 1 . 0 ) ( - 1 . 0 ) ( - 1 . 0 ) ; glColor3 ( 0 . 0 ) ( 1 . 0 ) ( 0 ...
let a = ref 0 . 0 ; ;
let b = ref 0 . 0 ; ;
let display ( ) = a := float ! height . / float ! width ; b := float ! width . / float ! height ; glClear [ GL_COLOR_BUFFER_BIT ] ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluPerspective ( 20 . 0 . * sqrt ( 1 . 0 . + ! a . * ! a ) ) ( ! b ) ( ...
let reshape ~ width ( : new_width ) ~ height ( : new_height ) = width := new_width ; height := new_height ; glutPostRedisplay ( ) ; ; ;
let keyboard ~ key ~ x ~ y = match key with ' q ' | ' Q ' | ' \ 027 ' -> exit 0 | _ -> ( ) ; ;
let mouse ~ button ~ state ~ x ~ y = begin match button with | GLUT_LEFT_BUTTON -> left_click := state ; | GLUT_RIGHT_BUTTON -> right_click := state ; | _ -> ( ) end ; xold := x ; yold := y ; ; ;
let motion ~ x ~ y = if ( GLUT_DOWN = ! left_click ) then begin rotate_y := ! rotate_y . + float ( y - ! yold ) . / 5 . 0 ; rotate_x := ! rotate_x . + float ( x - ! xold ) . / 5 . 0 ; if ( ! rotate_y > 90 . 0 ) then rotate_y := 90 . 0 ; if ( ! rotate_...
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_RGB ; GLUT_DOUBLE ] ; glutInitWindowSize 500 500 ; ignore ( glutCreateWindow " Viewport " ) ; glClearColor 0 . 0 0 . 0 0 . 0 0 . 0 ; glEnable GL_CULL_FACE ; glEnable GL_BLEND ; glutDisplayFunc ...
let register_callers_src = { | CDR ; SOURCE ; CONS ; NIL operation ; PAIR ; } ; } |
let check_caller_src = { | CAR ; DUP ; UNIT ; VIEW " calls_count " nat ; IF_NONE { UNIT ; FAILWITH } { } ; DIP { UNIT ; VIEW " last_caller " ( option address ) ; } ; PUSH nat 0 ; /* Check if the caller address is consistent with given calls count . */ IFCMPEQ { IF_...
let hooks = let rec mask_temp_dir = function | [ ] -> [ ] | " -- base - dir " :: _ :: rest -> " -- base - dir " :: " < masked " > :: rest | arg :: args -> arg :: mask_temp_dir args in { Regression . hooks with on_spawn = ( fun cmd args -> mask_temp_dir args |> Regressio...
let register ~ protocols ( ) = Protocol . register_regression_test ~ __FILE__ ~ title " : Run views " ~ tags [ " : client " ; " michelson " ] ~ output_file " : run_views " ~ protocols @@ fun protocol -> let * client = Client . init_mockup ~ protocol ( ) in let * regist...
let domain_name = " View domain "
module Domain = struct type static_information = { global_static_information : Analyzer_headers . global_static_information ; domain_static_information : Bdu_static_views . bdu_analysis_static ; domain_static_information_pattern : Bdu_static_views . bdu_analysis_static_pattern ; domain_static_informa...
let travel_in_site_correspondence parameters error cv_id site_correspondence = let error , site_correspondence = let rec aux list = match list with | [ ] -> Exception . warn parameters error __POS__ Exit [ ] | ( h , list , _ ) :: _ when h = cv_id -> error , list | _ :: tail -> aux ...
let get_site_correspondence parameters error agent_type site_correspondence = let error , site_correspondence = match Ckappa_sig . Agent_type_quick_nearly_Inf_Int_storage_Imperatif . get parameters error agent_type site_correspondence with | error , None -> Exception . warn parameters error __POS__ Exit ...
let get_list_of_sites_correspondence parameters error agent_type cv_id site_correspondence = let error , site_correspondence = get_site_correspondence parameters error agent_type site_correspondence in let error , site_correspondence = travel_in_site_correspondence parameters error cv_id site_correspondence in e...
let get_list_of_sites_correspondence_map parameters error agent_type cv_id site_correspondence = let error , cv_id_array_opt = Ckappa_sig . Agent_type_quick_nearly_Inf_Int_storage_Imperatif . get parameters error agent_type site_correspondence in match cv_id_array_opt with | None -> let error , map1 = Ckap...
let check ( ) = has_command " vim " && List . exists Re . ( execp @@ compile @@ str " + syntax " ) ( lines_of_command " vim -- version " )
let dotvimrc = let ( / ) = Filename . concat in let vimrc = " vimrc " in let dotvimrc = " . " ^ vimrc in let dotvim = " . vim " in if not ( Sys . file_exists ( home / dotvimrc ) ) && Sys . file_exists ( home / dotvim / vimrc ) then dotvim / vimrc else dotvimrc
let base_template = [ dotvimrc , lines_of_string { vim | finish else let g : loaded_sensible = 1 endif filetype plugin indent on endif syntax enable endif nnoremap < silent > < C - L > : nohlsearch < CR >< C - L > endif set scrolloff = 1 endif set sidescrolloff = 5 endif set encoding = utf - ...
let base_setup = [ dotvimrc , Text ( lines_of_string { vim |
let s : opam_share_dir = system ( " opam config var share " )
let s : opam_share_dir = substitute ( s : opam_share_dir , ' [ \ r \ n ] ' , *$ ' ' , ' ' )
let s : opam_configuration = { } execute " set rtp " ^= . s : opam_share_dir . " / ocp - indent / vim " endfunction
let s : opam_configuration [ ' ocp - indent ' ] = function ( ' OpamConfOcpIndent ' ) execute " set rtp " += . s : opam_share_dir . " / ocp - index / vim " endfunction
let s : opam_configuration [ ' ocp - index ' ] = function ( ' OpamConfOcpIndex ' ) let l : dir = s : opam_share_dir . " / merlin / vim " execute " set rtp " += . l : dir endfunction
let s : opam_packages = [ " ocp - indent " , " ocp - index " , " merlin " ]
let s : opam_available_tools = [ ] " Respect package order ( merlin should be after ocp - index ) if isdirectory ( s : opam_share_dir . " " / . tool ) call add ( s : opam_available_tools , tool ) call s : opam_configuration [ tool ] ( ) endif endfor
let comment = ( ) ^ " " \ "
let share_dir = opam_var " share "
module OcpIndent = struct let name = " ocp - indent " let chunks = let contents = Printf . sprintf { vim | source % S endif | vim } ( share_dir " / ocp - indent " " / vim " " / indent " " / ocaml . vim " ) in [ dotvimrc , Text ( lines_of_string contents ) ] let fil...
module OcpIndex = struct let name = " ocp - index " let chunks = [ ] let files = [ ] let post_install = [ ] let pre_remove = [ ] end
module Merlin = struct let name = " ocp - index " let chunks = [ ] let files = [ ] let post_install = [ ] let pre_remove = [ ] end
let tools = [ ( module OcpIndent : ToolConfig ) ; ( module OcpIndex : ToolConfig ) ; ( module Merlin : ToolConfig ) ; ]
type t = { vlib : Lib . t ; impl : Dune_file . Library . t ; vlib_modules : Modules . t ; vlib_foreign_objects : Path . t list ; impl_cm_kind : Cm_kind . t ; vlib_obj_map : Module . t Module_name . Unique . Map . t }
let vlib_modules t = t . vlib_modules