repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
thieryw/snake
Ada
12,366
adb
with snake_types,ada.text_io,ada.integer_text_io,ada.float_text_io,display,nt_console, ada.calendar,ada.numerics.discrete_random ; use ada.text_io,snake_types ; package body snake_functions is function get_user_controls_default return snake_types.User_Controls.Map is user_controls_default: snake_types.User_Controls.Map; begin snake_types.User_Controls.Insert(user_controls_default, 'o', snake_types.UP ); snake_types.User_Controls.Insert(user_controls_default, 'l', snake_types.DOWN ); snake_types.User_Controls.Insert(user_controls_default, 'k', snake_types.LEFT ); snake_types.User_Controls.Insert(user_controls_default, 'm', snake_types.RIGHT ); return user_controls_default; end get_user_controls_default; function are_same_coord(point1 : snake_types.Coordinates ; point2 : snake_types.Coordinates) return boolean is begin return point1.x = point2.x and point1.y = point2.y ; end are_same_coord ; function create_snake return snake_types.Snake is s : snake_types.Snake ; begin for i in 25..29 loop snake_list.append(s,(10,i)) ; end loop ; return s ; end create_snake ; procedure move_snake( s : in out snake_types.Snake ; dir : snake_types.Snake_direction ; fruit_coord : in snake_types.Coordinates ; does_eat_fruit: out boolean; ) is procedure snake_through_wall( s : in out snake_types.snake ; dir : snake_types.snake_direction ; head : in out snake_types.Coordinates ; is_on_edge : out boolean ) is c : snake_list.cursor ; begin if head.x = display.screen'first(1) and dir = UP then snake_list.prepend(s,(x => display.screen'last(1), y => head.y)) ; is_on_edge := true ; elsif head.x = display.screen'last(1) and dir = DOWN then snake_list.prepend(s,(x => display.screen'first(1), y => head.y)) ; is_on_edge := true ; elsif head.y = display.screen'first(2) and dir = LEFT then snake_list.prepend(s,(x => head.x, y => display.screen'last(2))) ; is_on_edge := true ; elsif head.y = display.screen'last(2) and dir = RIGHT then snake_list.prepend(s,(x => head.x, y => display.screen'first(2))) ; is_on_edge := true ; end if ; c := snake_list.first(s) ; head := snake_list.Element(c) ; end snake_through_wall ; head : Coordinates ; begin head := snake_list.Element(snake_list.first(s)) ; case dir is when snake_types.UP => if head.x = display.screen'first(1) then snake_list.prepend(s,(x => display.screen'last(1), y => head.y)) ; else snake_list.prepend(s,(x=>head.x-1,y=>head.y)) ; end if; when snake_types.DOWN => snake_list.prepend(s,(x =>head.x+1,y=>head.y)) ; when snake_types.LEFT => snake_list.prepend(s,(x=> head.x,y=>head.y-1)) ; when snake_types.RIGHT => snake_list.prepend(s,(x=>head.x,y=>head.y+1)) ; end case ; if not are_same_coord(snake_list.Element(snake_list.last(s)), fruit_coord ) then snake_list.delete(s,snake_list.last(s)) ; does_eat_fruit:= false; else does_eat_fruit:= true; end if; end move_snake ; function is_end_of_game(s : snake_types.snake ) return boolean is begin for snake_tail of s loop if are_same_coord(snake_tail, snake_head) then return true; end if ; end loop ; return false; end is_end_of_game ; procedure retreve_user_input( has_new_user_input: out boolean; direction: out snake_types.Snake_direction ; user_controls_value: in snake_types.User_Controls.Map )is char : character ; begin has_new_user_input :=false; if nt_console.Key_Available then char := nt_console.get_key ; if snake_types.User_Controls.Contains(user_controls_value, char) then has_new_user_input := true; direction:= snake_types.User_Controls.Element(user_controls_value, char) ; end if ; end if ; end retreve_user_input; --Prevent snake from going back on itself. procedure update_direction( dir : in out snake_types.Snake_direction ; new_direction : snake_types.Snake_direction ) is begin if ( dir = snake_types.UP and new_direction = snake_types.DOWN ) or ( dir = snake_types.DOWN and new_direction = snake_types.UP ) or ( dir = snake_types.LEFT and new_direction = snake_types.RIGHT ) or ( dir = snake_types.RIGHT and new_direction = snake_types.LEFT ) then return; end if; dir := new_direction ; end update_direction ; procedure generate_fruit( s : snake_types.snake ; fruit : out snake_types.Coordinates ; time_out : out integer ) is procedure random_time_to_generate_fruit(time_out : out integer) is subtype intervall is integer range 40..90 ; package aleatoire is new ada.numerics.discrete_random(intervall) ; hasard : aleatoire.generator ; begin aleatoire.reset(hasard) ; time_out := aleatoire.random(hasard) ; end random_time_to_generate_fruit ; procedure sub_generate_fruit(fruit : out snake_types.Coordinates) is subtype intervall_x is integer range display.screen'range(1) ; package aleatoire_x is new ada.numerics.discrete_random(intervall_x) ; x_generator : aleatoire_x.generator ; subtype intervall_y is integer range display.screen'range(2) ; package aleatoire_y is new ada.numerics.discrete_random(intervall_y) ; y_generator : aleatoire_y.generator ; begin aleatoire_x.reset(x_generator) ; aleatoire_y.reset(y_generator) ; fruit.x := aleatoire_x.random(x_generator) ; fruit.y := aleatoire_y.random(y_generator) ; end sub_generate_fruit ; function is_fruit_on_snake(fruit:snake_types.Coordinates ; s: snake_types.Snake ) return boolean is begin for dot of s loop if are_same_coord(fruit,dot) then return true; end if ; end loop; return false; end is_fruit_on_snake; procedure place_fruit_on_list(fruit : out snake_types.Coordinates ; s : in snake_types.snake) is screen : display.grid := (others => (others => false)) ; length_of_snake : integer := integer( snake_list.length(s)) ; type array_of_coord is array(1..(screen'length(1) * screen'length(2)) - length_of_snake) of snake_types.Coordinates ; coord_not_belonging_to_serpent : array_of_coord ; procedure create_list_not_on_snake(s : in snake_types.snake ; coord_not_belonging_to_serpent : out array_of_coord ; screen : in out display.grid) is count : integer := coord_not_belonging_to_serpent'first ; begin for dot of s loop screen(dot.x,dot.y) := true ; end loop ; for i in screen'range(1) loop for j in screen'range(2) loop if not screen(i,j) then coord_not_belonging_to_serpent(count).x := i ; coord_not_belonging_to_serpent(count).y := j ; count := count + 1 ; end if ; end loop ; end loop ; end create_list_not_on_snake ; subtype intervall is integer range coord_not_belonging_to_serpent'range ; package randomizer is new ada.numerics.discrete_random(intervall) ; hasard : randomizer.generator ; point_on_list : integer ; begin randomizer.reset(hasard) ; point_on_list := randomizer.random(hasard) ; create_list_not_on_snake(s,coord_not_belonging_to_serpent,screen) ; fruit.x := coord_not_belonging_to_serpent(point_on_list).x ; fruit.y := coord_not_belonging_to_serpent(point_on_list).y ; end place_fruit_on_list ; snake_length : integer := integer(snake_list.length(s)) ; fraction : float := 0.7 ; begin if float(snake_length) >= fraction * (float(display.screen'length(1)) * float(display.screen'length(2))) then place_fruit_on_list(fruit,s) ; else loop sub_generate_fruit(fruit) ; if not is_fruit_on_snake(fruit,s) then exit ; end if ; end loop ; end if ; random_time_to_generate_fruit(time_out) ; end generate_fruit ; procedure render_game(s : snake_types.snake ; fruit : Coordinates) is point_coordinates : snake_types.Coordinates ; c : snake_list.cursor ; screen : display.grid := (others => (others => false)) ; begin c := snake_list.first(s) ; for i in 1..snake_list.length(s) loop point_coordinates := snake_list.element(c) ; screen(point_coordinates.x,point_coordinates.y) := true ; snake_list.next(c) ; end loop ; screen(fruit.x,fruit.y) := true ; display.render(screen) ; end render_game ; end snake_functions ;
KLOC-Karsten/adaoled
Ada
44,105
ads
with Bitmap_Graphics; use Bitmap_Graphics; package Bitmap_Graphics.Font16 is Font_Data : aliased Byte_Array := ( -- @0 ' ' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @32 '!' (11 pixels wide) 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @64 '"' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1D#, 16#C0#, -- ### ### 16#1D#, 16#C0#, -- ### ### 16#08#, 16#80#, -- # # 16#08#, 16#80#, -- # # 16#08#, 16#80#, -- # # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @96 '#' (11 pixels wide) 16#00#, 16#00#, -- 16#0D#, 16#80#, -- ## ## 16#0D#, 16#80#, -- ## ## 16#0D#, 16#80#, -- ## ## 16#0D#, 16#80#, -- ## ## 16#3F#, 16#C0#, -- ######## 16#1B#, 16#00#, -- ## ## 16#3F#, 16#C0#, -- ######## 16#1B#, 16#00#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @128 '$' (11 pixels wide) 16#04#, 16#00#, -- # 16#1F#, 16#80#, -- ###### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#38#, 16#00#, -- ### 16#1E#, 16#00#, -- #### 16#0F#, 16#00#, -- #### 16#03#, 16#80#, -- ### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#3F#, 16#00#, -- ###### 16#04#, 16#00#, -- # 16#04#, 16#00#, -- # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @160 '%' (11 pixels wide) 16#00#, 16#00#, -- 16#18#, 16#00#, -- ## 16#24#, 16#00#, -- # # 16#24#, 16#00#, -- # # 16#18#, 16#C0#, -- ## ## 16#07#, 16#80#, -- #### 16#1E#, 16#00#, -- #### 16#31#, 16#80#, -- ## ## 16#02#, 16#40#, -- # # 16#02#, 16#40#, -- # # 16#01#, 16#80#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @192 '&' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#0F#, 16#00#, -- #### 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#1D#, 16#80#, -- ### ## 16#37#, 16#00#, -- ## ### 16#33#, 16#00#, -- ## ## 16#1D#, 16#80#, -- ### ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @224 ''' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#07#, 16#00#, -- ### 16#07#, 16#00#, -- ### 16#02#, 16#00#, -- # 16#02#, 16#00#, -- # 16#02#, 16#00#, -- # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @256 '(' (11 pixels wide) 16#00#, 16#00#, -- 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0E#, 16#00#, -- ### 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0E#, 16#00#, -- ### 16#06#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @288 ')' (11 pixels wide) 16#00#, 16#00#, -- 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#1C#, 16#00#, -- ### 16#18#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @320 '*' (11 pixels wide) 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#3F#, 16#C0#, -- ######## 16#3F#, 16#C0#, -- ######## 16#0F#, 16#00#, -- #### 16#1F#, 16#80#, -- ###### 16#19#, 16#80#, -- ## ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @352 '+' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#04#, 16#00#, -- # 16#04#, 16#00#, -- # 16#04#, 16#00#, -- # 16#3F#, 16#80#, -- ####### 16#04#, 16#00#, -- # 16#04#, 16#00#, -- # 16#04#, 16#00#, -- # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @384 ',' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#0C#, 16#00#, -- ## 16#08#, 16#00#, -- # 16#08#, 16#00#, -- # 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @416 '-' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#3F#, 16#80#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @448 '.' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @480 '/' (11 pixels wide) 16#00#, 16#C0#, -- ## 16#00#, 16#C0#, -- ## 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @512 '0' (11 pixels wide) 16#00#, 16#00#, -- 16#0E#, 16#00#, -- ### 16#1B#, 16#00#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#0E#, 16#00#, -- ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @544 '1' (11 pixels wide) 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#3E#, 16#00#, -- ##### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#3F#, 16#C0#, -- ######## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @576 '2' (11 pixels wide) 16#00#, 16#00#, -- 16#0F#, 16#00#, -- #### 16#19#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#03#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#3F#, 16#80#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @608 '3' (11 pixels wide) 16#00#, 16#00#, -- 16#3F#, 16#00#, -- ###### 16#61#, 16#80#, -- ## ## 16#01#, 16#80#, -- ## 16#03#, 16#00#, -- ## 16#1F#, 16#00#, -- ##### 16#03#, 16#80#, -- ### 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#61#, 16#80#, -- ## ## 16#3F#, 16#00#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @640 '4' (11 pixels wide) 16#00#, 16#00#, -- 16#07#, 16#00#, -- ### 16#07#, 16#00#, -- ### 16#0F#, 16#00#, -- #### 16#0B#, 16#00#, -- # ## 16#1B#, 16#00#, -- ## ## 16#13#, 16#00#, -- # ## 16#33#, 16#00#, -- ## ## 16#3F#, 16#80#, -- ####### 16#03#, 16#00#, -- ## 16#0F#, 16#80#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @672 '5' (11 pixels wide) 16#00#, 16#00#, -- 16#1F#, 16#80#, -- ###### 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#1F#, 16#00#, -- ##### 16#11#, 16#80#, -- # ## 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#21#, 16#80#, -- # ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @704 '6' (11 pixels wide) 16#00#, 16#00#, -- 16#07#, 16#80#, -- #### 16#1C#, 16#00#, -- ### 16#18#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#37#, 16#00#, -- ## ### 16#39#, 16#80#, -- ### ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#19#, 16#80#, -- ## ## 16#0F#, 16#00#, -- #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @736 '7' (11 pixels wide) 16#00#, 16#00#, -- 16#7F#, 16#00#, -- ####### 16#43#, 16#00#, -- # ## 16#03#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @768 '8' (11 pixels wide) 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @800 '9' (11 pixels wide) 16#00#, 16#00#, -- 16#1E#, 16#00#, -- #### 16#33#, 16#00#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#33#, 16#80#, -- ## ### 16#1D#, 16#80#, -- ### ## 16#01#, 16#80#, -- ## 16#03#, 16#00#, -- ## 16#07#, 16#00#, -- ### 16#3C#, 16#00#, -- #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @832 ':' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @864 ';' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#08#, 16#00#, -- # 16#08#, 16#00#, -- # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @896 '<' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#C0#, -- ## 16#03#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#18#, 16#00#, -- ## 16#60#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#03#, 16#00#, -- ## 16#00#, 16#C0#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @928 '=' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#C0#, -- ######### 16#00#, 16#00#, -- 16#7F#, 16#C0#, -- ######### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @960 '>' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#60#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#03#, 16#00#, -- ## 16#00#, 16#C0#, -- ## 16#03#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#18#, 16#00#, -- ## 16#60#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @992 '?' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#01#, 16#80#, -- ## 16#07#, 16#00#, -- ### 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1024 '@' (11 pixels wide) 16#00#, 16#00#, -- 16#0E#, 16#00#, -- ### 16#11#, 16#00#, -- # # 16#21#, 16#00#, -- # # 16#21#, 16#00#, -- # # 16#27#, 16#00#, -- # ### 16#29#, 16#00#, -- # # # 16#29#, 16#00#, -- # # # 16#27#, 16#00#, -- # ### 16#20#, 16#00#, -- # 16#11#, 16#00#, -- # # 16#0E#, 16#00#, -- ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1056 'A' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#3F#, 16#00#, -- ###### 16#0F#, 16#00#, -- #### 16#09#, 16#00#, -- # # 16#19#, 16#80#, -- ## ## 16#19#, 16#80#, -- ## ## 16#1F#, 16#80#, -- ###### 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#79#, 16#E0#, -- #### #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1088 'B' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#00#, -- ####### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#3F#, 16#00#, -- ###### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7F#, 16#00#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1120 'C' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#40#, -- ##### # 16#30#, 16#C0#, -- ## ## 16#60#, 16#40#, -- ## # 16#60#, 16#00#, -- ## 16#60#, 16#00#, -- ## 16#60#, 16#00#, -- ## 16#60#, 16#40#, -- ## # 16#30#, 16#80#, -- ## # 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1152 'D' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#00#, -- ####### 16#31#, 16#80#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7F#, 16#00#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1184 'E' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#80#, -- ######## 16#30#, 16#80#, -- ## # 16#30#, 16#80#, -- ## # 16#32#, 16#00#, -- ## # 16#3E#, 16#00#, -- ##### 16#32#, 16#00#, -- ## # 16#30#, 16#80#, -- ## # 16#30#, 16#80#, -- ## # 16#7F#, 16#80#, -- ######## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1216 'F' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#C0#, -- ######### 16#30#, 16#40#, -- ## # 16#30#, 16#40#, -- ## # 16#32#, 16#00#, -- ## # 16#3E#, 16#00#, -- ##### 16#32#, 16#00#, -- ## # 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#7C#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1248 'G' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1E#, 16#80#, -- #### # 16#31#, 16#80#, -- ## ## 16#60#, 16#80#, -- ## # 16#60#, 16#00#, -- ## 16#60#, 16#00#, -- ## 16#67#, 16#C0#, -- ## ##### 16#61#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1280 'H' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#3F#, 16#80#, -- ####### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7B#, 16#C0#, -- #### #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1312 'I' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#3F#, 16#C0#, -- ######## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#3F#, 16#C0#, -- ######## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1344 'J' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#C0#, -- ####### 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#63#, 16#00#, -- ## ## 16#63#, 16#00#, -- ## ## 16#63#, 16#00#, -- ## ## 16#3E#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1376 'K' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#31#, 16#80#, -- ## ## 16#33#, 16#00#, -- ## ## 16#36#, 16#00#, -- ## ## 16#3C#, 16#00#, -- #### 16#3E#, 16#00#, -- ##### 16#33#, 16#00#, -- ## ## 16#31#, 16#80#, -- ## ## 16#79#, 16#C0#, -- #### ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1408 'L' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7E#, 16#00#, -- ###### 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#40#, -- ## # 16#18#, 16#40#, -- ## # 16#18#, 16#40#, -- ## # 16#7F#, 16#C0#, -- ######### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1440 'M' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#E0#, 16#E0#, -- ### ### 16#60#, 16#C0#, -- ## ## 16#71#, 16#C0#, -- ### ### 16#7B#, 16#C0#, -- #### #### 16#6A#, 16#C0#, -- ## # # ## 16#6E#, 16#C0#, -- ## ### ## 16#64#, 16#C0#, -- ## # ## 16#60#, 16#C0#, -- ## ## 16#FB#, 16#E0#, -- ##### ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1472 'N' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#73#, 16#C0#, -- ### #### 16#31#, 16#80#, -- ## ## 16#39#, 16#80#, -- ### ## 16#3D#, 16#80#, -- #### ## 16#35#, 16#80#, -- ## # ## 16#37#, 16#80#, -- ## #### 16#33#, 16#80#, -- ## ### 16#31#, 16#80#, -- ## ## 16#79#, 16#80#, -- #### ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1504 'O' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1536 'P' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#00#, -- ####### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#3F#, 16#00#, -- ###### 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#7E#, 16#00#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1568 'Q' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#0C#, 16#C0#, -- ## ## 16#1F#, 16#80#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1600 'R' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#00#, -- ####### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#3E#, 16#00#, -- ##### 16#33#, 16#00#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7C#, 16#E0#, -- ##### ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1632 'S' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#80#, -- ###### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#38#, 16#00#, -- ### 16#1F#, 16#00#, -- ##### 16#03#, 16#80#, -- ### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#3F#, 16#00#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1664 'T' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#80#, -- ######## 16#4C#, 16#80#, -- # ## # 16#4C#, 16#80#, -- # ## # 16#4C#, 16#80#, -- # ## # 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#3F#, 16#00#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1696 'U' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1728 'V' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#0A#, 16#00#, -- # # 16#0E#, 16#00#, -- ### 16#0E#, 16#00#, -- ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1760 'W' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#FB#, 16#E0#, -- ##### ##### 16#60#, 16#C0#, -- ## ## 16#64#, 16#C0#, -- ## # ## 16#6E#, 16#C0#, -- ## ### ## 16#6E#, 16#C0#, -- ## ### ## 16#2A#, 16#80#, -- # # # # 16#3B#, 16#80#, -- ### ### 16#3B#, 16#80#, -- ### ### 16#31#, 16#80#, -- ## ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1792 'X' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#31#, 16#80#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#0E#, 16#00#, -- ### 16#0E#, 16#00#, -- ### 16#0E#, 16#00#, -- ### 16#1B#, 16#00#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7B#, 16#C0#, -- #### #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1824 'Y' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#79#, 16#E0#, -- #### #### 16#30#, 16#C0#, -- ## ## 16#19#, 16#80#, -- ## ## 16#0F#, 16#00#, -- #### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#1F#, 16#80#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1856 'Z' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#3F#, 16#80#, -- ####### 16#21#, 16#80#, -- # ## 16#23#, 16#00#, -- # ## 16#06#, 16#00#, -- ## 16#04#, 16#00#, -- # 16#0C#, 16#00#, -- ## 16#18#, 16#80#, -- ## # 16#30#, 16#80#, -- ## # 16#3F#, 16#80#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1888 '[' (11 pixels wide) 16#00#, 16#00#, -- 16#07#, 16#80#, -- #### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#07#, 16#80#, -- #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1920 '\' (11 pixels wide) 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#00#, 16#C0#, -- ## 16#00#, 16#C0#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1952 ']' (11 pixels wide) 16#00#, 16#00#, -- 16#1E#, 16#00#, -- #### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#1E#, 16#00#, -- #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @1984 '^' (11 pixels wide) 16#04#, 16#00#, -- # 16#0A#, 16#00#, -- # # 16#0A#, 16#00#, -- # # 16#11#, 16#00#, -- # # 16#20#, 16#80#, -- # # 16#20#, 16#80#, -- # # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2016 '_' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#FF#, 16#E0#, -- ########### -- @2048 '`' (11 pixels wide) 16#08#, 16#00#, -- # 16#04#, 16#00#, -- # 16#02#, 16#00#, -- # 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2080 'a' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#1F#, 16#80#, -- ###### 16#31#, 16#80#, -- ## ## 16#33#, 16#80#, -- ## ### 16#1D#, 16#C0#, -- ### ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2112 'b' (11 pixels wide) 16#00#, 16#00#, -- 16#70#, 16#00#, -- ### 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#37#, 16#00#, -- ## ### 16#39#, 16#80#, -- ### ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#39#, 16#80#, -- ### ## 16#77#, 16#00#, -- ### ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2144 'c' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1E#, 16#80#, -- #### # 16#31#, 16#80#, -- ## ## 16#60#, 16#80#, -- ## # 16#60#, 16#00#, -- ## 16#60#, 16#80#, -- ## # 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2176 'd' (11 pixels wide) 16#00#, 16#00#, -- 16#03#, 16#80#, -- ### 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#1D#, 16#80#, -- ### ## 16#33#, 16#80#, -- ## ### 16#61#, 16#80#, -- ## ## 16#61#, 16#80#, -- ## ## 16#61#, 16#80#, -- ## ## 16#33#, 16#80#, -- ## ### 16#1D#, 16#C0#, -- ### ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2208 'e' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#7F#, 16#C0#, -- ######### 16#60#, 16#00#, -- ## 16#30#, 16#C0#, -- ## ## 16#1F#, 16#80#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2240 'f' (11 pixels wide) 16#00#, 16#00#, -- 16#07#, 16#E0#, -- ###### 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#3F#, 16#80#, -- ####### 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#3F#, 16#80#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2272 'g' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1D#, 16#C0#, -- ### ### 16#33#, 16#80#, -- ## ### 16#61#, 16#80#, -- ## ## 16#61#, 16#80#, -- ## ## 16#61#, 16#80#, -- ## ## 16#33#, 16#80#, -- ## ### 16#1D#, 16#80#, -- ### ## 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2304 'h' (11 pixels wide) 16#00#, 16#00#, -- 16#70#, 16#00#, -- ### 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#37#, 16#00#, -- ## ### 16#39#, 16#80#, -- ### ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7B#, 16#C0#, -- #### #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2336 'i' (11 pixels wide) 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#00#, 16#00#, -- 16#1E#, 16#00#, -- #### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#3F#, 16#C0#, -- ######## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2368 'j' (11 pixels wide) 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#00#, 16#00#, -- 16#3F#, 16#00#, -- ###### 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#3E#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2400 'k' (11 pixels wide) 16#00#, 16#00#, -- 16#70#, 16#00#, -- ### 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#37#, 16#80#, -- ## #### 16#36#, 16#00#, -- ## ## 16#3C#, 16#00#, -- #### 16#3C#, 16#00#, -- #### 16#36#, 16#00#, -- ## ## 16#33#, 16#00#, -- ## ## 16#77#, 16#C0#, -- ### ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2432 'l' (11 pixels wide) 16#00#, 16#00#, -- 16#1E#, 16#00#, -- #### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#3F#, 16#C0#, -- ######## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2464 'm' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7F#, 16#80#, -- ######## 16#36#, 16#C0#, -- ## ## ## 16#36#, 16#C0#, -- ## ## ## 16#36#, 16#C0#, -- ## ## ## 16#36#, 16#C0#, -- ## ## ## 16#36#, 16#C0#, -- ## ## ## 16#76#, 16#E0#, -- ### ## ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2496 'n' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#77#, 16#00#, -- ### ### 16#39#, 16#80#, -- ### ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#7B#, 16#C0#, -- #### #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2528 'o' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#00#, -- ##### 16#31#, 16#80#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#60#, 16#C0#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1F#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2560 'p' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#77#, 16#00#, -- ### ### 16#39#, 16#80#, -- ### ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#30#, 16#C0#, -- ## ## 16#39#, 16#80#, -- ### ## 16#37#, 16#00#, -- ## ### 16#30#, 16#00#, -- ## 16#30#, 16#00#, -- ## 16#7C#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2592 'q' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1D#, 16#C0#, -- ### ### 16#33#, 16#80#, -- ## ### 16#61#, 16#80#, -- ## ## 16#61#, 16#80#, -- ## ## 16#61#, 16#80#, -- ## ## 16#33#, 16#80#, -- ## ### 16#1D#, 16#80#, -- ### ## 16#01#, 16#80#, -- ## 16#01#, 16#80#, -- ## 16#07#, 16#C0#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2624 'r' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#80#, -- #### ### 16#1C#, 16#C0#, -- ### ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#7F#, 16#00#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2656 's' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#1F#, 16#80#, -- ###### 16#31#, 16#80#, -- ## ## 16#3C#, 16#00#, -- #### 16#1F#, 16#00#, -- ##### 16#03#, 16#80#, -- ### 16#31#, 16#80#, -- ## ## 16#3F#, 16#00#, -- ###### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2688 't' (11 pixels wide) 16#00#, 16#00#, -- 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#7F#, 16#00#, -- ####### 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#18#, 16#80#, -- ## # 16#0F#, 16#00#, -- #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2720 'u' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#73#, 16#80#, -- ### ### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#33#, 16#80#, -- ## ### 16#1D#, 16#C0#, -- ### ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2752 'v' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#31#, 16#80#, -- ## ## 16#31#, 16#80#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#1B#, 16#00#, -- ## ## 16#0E#, 16#00#, -- ### 16#0E#, 16#00#, -- ### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2784 'w' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#F1#, 16#E0#, -- #### #### 16#60#, 16#C0#, -- ## ## 16#64#, 16#C0#, -- ## # ## 16#6E#, 16#C0#, -- ## ### ## 16#3B#, 16#80#, -- ### ### 16#3B#, 16#80#, -- ### ### 16#31#, 16#80#, -- ## ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2816 'x' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#7B#, 16#C0#, -- #### #### 16#1B#, 16#00#, -- ## ## 16#0E#, 16#00#, -- ### 16#0E#, 16#00#, -- ### 16#0E#, 16#00#, -- ### 16#1B#, 16#00#, -- ## ## 16#7B#, 16#C0#, -- #### #### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2848 'y' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#79#, 16#E0#, -- #### #### 16#30#, 16#C0#, -- ## ## 16#19#, 16#80#, -- ## ## 16#19#, 16#80#, -- ## ## 16#0B#, 16#00#, -- # ## 16#0F#, 16#00#, -- #### 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#3E#, 16#00#, -- ##### 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2880 'z' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#3F#, 16#80#, -- ####### 16#21#, 16#80#, -- # ## 16#03#, 16#00#, -- ## 16#0E#, 16#00#, -- ### 16#18#, 16#00#, -- ## 16#30#, 16#80#, -- ## # 16#3F#, 16#80#, -- ####### 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2912 '{' (11 pixels wide) 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#18#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2944 '|' (11 pixels wide) 16#00#, 16#00#, -- 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @2976 '}' (11 pixels wide) 16#00#, 16#00#, -- 16#0C#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#03#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#06#, 16#00#, -- ## 16#0C#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- -- @3008 '~' (11 pixels wide) 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#18#, 16#00#, -- ## 16#24#, 16#80#, -- # # # 16#03#, 16#00#, -- ## 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00#, -- 16#00#, 16#00# -- ); Font16: aliased Font := ( Width => 11, Height => 16, Data => Font_Data'access ); end Bitmap_Graphics.Font16;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
3,903
ads
-- This spec has been automatically generated from STM32F072x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.IWDG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype KR_KEY_Field is STM32_SVD.UInt16; -- Key register type KR_Register is record -- Write-only. Key value KEY : KR_KEY_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for KR_Register use record KEY at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype PR_PR_Field is STM32_SVD.UInt3; -- Prescaler register type PR_Register is record -- Prescaler divider PR : PR_PR_Field := 16#0#; -- unspecified Reserved_3_31 : STM32_SVD.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PR_Register use record PR at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype RLR_RL_Field is STM32_SVD.UInt12; -- Reload register type RLR_Register is record -- Watchdog counter reload value RL : RLR_RL_Field := 16#FFF#; -- unspecified Reserved_12_31 : STM32_SVD.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RLR_Register use record RL at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype SR_PVU_Field is STM32_SVD.Bit; subtype SR_RVU_Field is STM32_SVD.Bit; subtype SR_WVU_Field is STM32_SVD.Bit; -- Status register type SR_Register is record -- Read-only. Watchdog prescaler value update PVU : SR_PVU_Field; -- Read-only. Watchdog counter reload value update RVU : SR_RVU_Field; -- Read-only. Watchdog counter window value update WVU : SR_WVU_Field; -- unspecified Reserved_3_31 : STM32_SVD.UInt29; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record PVU at 0 range 0 .. 0; RVU at 0 range 1 .. 1; WVU at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype WINR_WIN_Field is STM32_SVD.UInt12; -- Window register type WINR_Register is record -- Watchdog counter window value WIN : WINR_WIN_Field := 16#FFF#; -- unspecified Reserved_12_31 : STM32_SVD.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WINR_Register use record WIN at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Independent watchdog type IWDG_Peripheral is record -- Key register KR : aliased KR_Register; -- Prescaler register PR : aliased PR_Register; -- Reload register RLR : aliased RLR_Register; -- Status register SR : aliased SR_Register; -- Window register WINR : aliased WINR_Register; end record with Volatile; for IWDG_Peripheral use record KR at 16#0# range 0 .. 31; PR at 16#4# range 0 .. 31; RLR at 16#8# range 0 .. 31; SR at 16#C# range 0 .. 31; WINR at 16#10# range 0 .. 31; end record; -- Independent watchdog IWDG_Periph : aliased IWDG_Peripheral with Import, Address => System'To_Address (16#40003000#); end STM32_SVD.IWDG;
reznikmm/matreshka
Ada
4,662
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Form_Image_Elements; package Matreshka.ODF_Form.Image_Elements is type Form_Image_Element_Node is new Matreshka.ODF_Form.Abstract_Form_Element_Node and ODF.DOM.Form_Image_Elements.ODF_Form_Image with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Form_Image_Element_Node; overriding function Get_Local_Name (Self : not null access constant Form_Image_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Form_Image_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Form_Image_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Form_Image_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Form.Image_Elements;
NCommander/dnscatcher
Ada
3,510
adb
-- Copyright 2019 Michael Casadevall <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- sell copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. with Ada.Streams; use Ada.Streams; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with DNSCatcher.Utils; use DNSCatcher.Utils; package body DNSCatcher.DNS.Processor.RData.SOA_Parser is -- SOA records are messy. There are two compressed domain names we need to -- decode, then some 32 bit ints that follow afterwards, so let's try and -- get that data first and out of the way pragma Warnings (Off, "formal parameter ""DNS_Header"" is not referenced"); procedure From_Parsed_RR (This : in out Parsed_SOA_RData; DNS_Header : DNS_Packet_Header; Parsed_RR : Parsed_DNS_Resource_Record) is Offset : Stream_Element_Offset := Parsed_RR.RData_Offset; begin -- Convert things back to SEA Types Try to decode MNAME first This.Primary_Nameserver := Parse_DNS_Packet_Name_Records (Parsed_RR.Raw_Packet, Offset); This.Responsible_Contact := Parse_DNS_Packet_Name_Records (Parsed_RR.Raw_Packet, Offset); This.Serial := Read_Unsigned_32 (Parsed_RR.Raw_Packet, Offset); This.Refresh := Read_Unsigned_32 (Parsed_RR.Raw_Packet, Offset); This.Retry := Read_Unsigned_32 (Parsed_RR.Raw_Packet, Offset); This.Expire := Read_Unsigned_32 (Parsed_RR.Raw_Packet, Offset); This.Minimum := Read_Unsigned_32 (Parsed_RR.Raw_Packet, Offset); end From_Parsed_RR; pragma Warnings (On, "formal parameter ""DNS_Header"" is not referenced"); function RData_To_String (This : in Parsed_SOA_RData) return String is begin return To_String (This.Primary_Nameserver) & " " & To_String (This.Responsible_Contact) & This.Serial'Image & This.Refresh'Image & This.Retry'Image & This.Expire'Image & This.Minimum'Image; end RData_To_String; function Print_Packet (This : in Parsed_SOA_RData) return String is begin return "SOA " & This.RData_To_String; end Print_Packet; -- Obliberate ourselves procedure Delete (This : in out Parsed_SOA_RData) is procedure Free_Parsed_SOA_Record is new Ada.Unchecked_Deallocation (Object => Parsed_SOA_RData, Name => Parsed_SOA_RData_Access); Ptr : aliased Parsed_SOA_RData_Access := This'Unchecked_Access; begin Free_Parsed_SOA_Record (Ptr); end Delete; end DNSCatcher.DNS.Processor.RData.SOA_Parser;
redparavoz/ada-wiki
Ada
2,039
adb
----------------------------------------------------------------------- -- wiki-render -- Wiki renderer -- Copyright (C) 2015, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Wiki.Render is -- ------------------------------ -- Render the list of nodes from the document. -- ------------------------------ procedure Render (Engine : in out Renderer'Class; Doc : in Wiki.Documents.Document; List : in Wiki.Nodes.Node_List_Access) is use type Wiki.Nodes.Node_List_Access; procedure Process (Node : in Wiki.Nodes.Node_Type); procedure Process (Node : in Wiki.Nodes.Node_Type) is begin Engine.Render (Doc, Node); end Process; begin if List /= null then Wiki.Nodes.Iterate (List, Process'Access); end if; end Render; -- ------------------------------ -- Render the document. -- ------------------------------ procedure Render (Engine : in out Renderer'Class; Doc : in Wiki.Documents.Document) is procedure Process (Node : in Wiki.Nodes.Node_Type); procedure Process (Node : in Wiki.Nodes.Node_Type) is begin Engine.Render (Doc, Node); end Process; begin Doc.Iterate (Process'Access); Engine.Finish (Doc); end Render; end Wiki.Render;
AdaDoom3/wayland_ada_binding
Ada
3,046
ads
------------------------------------------------------------------------------ -- Copyright (C) 2015-2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ -- Unbounded lists of strings. -- A special allocation strategy is used for strings, so that small strings -- are directly stored in the list's node, and do not require memory -- allocation. This might make things faster in some cases, at the cost of -- using more memory since the nodes are bigger. -- Consider using Conts.Lists.Indefinite_Unbounded_Ref for another list -- usable with strings. pragma Ada_2012; with Ada.Finalization; with Conts.Elements.Arrays; with Conts.Lists.Generics; with Conts.Lists.Storage.Unbounded; package Conts.Lists.Strings is pragma Assertion_Policy (Pre => Suppressible, Ghost => Suppressible, Post => Ignore); package Elements is new Conts.Elements.Arrays (Positive, Character, String, Conts.Global_Pool); package Storage is new Conts.Lists.Storage.Unbounded (Elements => Elements.Traits, Container_Base_Type => Ada.Finalization.Controlled, Pool => Conts.Global_Pool); package Lists is new Conts.Lists.Generics (Storage.Traits); subtype Cursor is Lists.Cursor; type List is new Lists.List with null record with Iterable => (First => First_Primitive, Next => Next_Primitive, Has_Element => Has_Element_Primitive, Element => Element_Primitive); package Cursors renames Lists.Cursors; package Maps renames Lists.Maps; end Conts.Lists.Strings;
zhmu/ananas
Ada
10,343
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- L I B . L O A D -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This child package contains the function used to load a separately -- compiled unit, as well as the routine used to initialize the unit -- table and load the main source file. package Lib.Load is ------------------------------- -- Handling of Renamed Units -- ------------------------------- -- A compilation unit can be a renaming of another compilation unit. -- Such renamed units are not allowed as parent units, that is you -- cannot declare a unit: -- with x; -- package x.y is end; -- where x is a renaming of some other package. However you can refer -- to a renamed unit in a with clause: -- package p is end; -- package p.q is end; -- with p; -- package pr renames p; -- with pr.q .... -- This means that in the context of a with clause, the normal fixed -- correspondence between unit and file names is broken. In the above -- example, there is no file named pr-q.ads, since the actual child -- unit is p.q, and it will be found in file p-q.ads. -- In order to deal with this case, we have to first load pr.ads, and -- then discover that it is a renaming of p, so that we know that pr.q -- really refers to p.q. Furthermore this can happen at any level: -- with p.q; -- package p.r renames p.q; -- with p.q; -- package p.q.s is end; -- with p.r.s ... -- Now we have a case where the parent p.r is a child unit and is -- a renaming. This shows that renaming can occur at any level. -- Finally, consider: -- with pr.q.s ... -- Here the parent pr.q is not itself a renaming, but it really refers -- to the unit p.q, and again we cannot know this without loading the -- parent. The bottom line here is that while the file name of a unit -- always corresponds to the unit name, the unit name as given to the -- Load_Unit function may not be the real unit. ----------------- -- Subprograms -- ----------------- procedure Initialize; -- Initialize internal tables procedure Initialize_Version (U : Unit_Number_Type); -- This is called once the source file corresponding to unit U has been -- fully scanned. At that point the checksum is computed, and can be used -- to initialize the version number. procedure Load_Main_Source; -- Called at the start of compiling a new main source unit to initialize -- the library processing for the new main source. Establishes and -- initializes the units table entry for the new main unit (leaving -- the Unit_File_Name entry of Main_Unit set to No_File if there are no -- more files. Otherwise the main source file has been opened and read -- and then closed on return. function Load_Unit (Load_Name : Unit_Name_Type; Required : Boolean; Error_Node : Node_Id; Subunit : Boolean; Corr_Body : Unit_Number_Type := No_Unit; Renamings : Boolean := False; With_Node : Node_Id := Empty; PMES : Boolean := False) return Unit_Number_Type; -- This function loads and parses the unit specified by Load_Name (or -- returns the unit number for the previously constructed units table -- entry if this is not the first call for this unit). Required indicates -- the behavior on a file not found condition, as further described below, -- and Error_Node is the node in the calling program to which error -- messages are to be attached. -- -- If the corresponding file is found, the value returned by Load is the -- unit number that indexes the corresponding entry in the units table. If -- a serious enough parser error occurs to prevent subsequent semantic -- analysis, then the Fatal_Error flag of the returned entry is set and -- in addition, the fatal error flag of the calling unit is also set. -- -- If the corresponding file is not found, then the behavior depends on -- the setting of Required. If Required is False, then No_Unit is returned -- and no error messages are issued. If Required is True, then an error -- message is posted, and No_Unit is returned. -- -- A special case arises in the call from Rtsfind, where Error_Node is set -- to Empty. In this case Required is False, and the caller in any case -- treats any error as fatal. -- -- The Subunit parameter is True to load a subunit, and False to load -- any other kind of unit (including all specs, package bodies, and -- subprogram bodies). -- -- The Corr_Body argument is normally defaulted. It is set only in the -- case of loading the corresponding spec when the main unit is a body. -- In this case, Corr_Body is the unit number of this corresponding -- body. This is used to set the Serial_Ref_Unit field of the unit -- table entry. It is also used to deal with the special processing -- required by RM 10.1.4(4). See description in lib.ads. -- -- Renamings activates the handling of renamed units as separately -- described in the documentation of this unit. If this parameter is -- set to True, then Load_Name may not be the real unit name and it -- is necessary to load parents to find the real name. -- -- With_Node is set to the with_clause or limited_with_clause causing -- the unit to be loaded, and is used to bypass the circular dependency -- check in the case of a limited_with_clause (Ada 2005, AI-50217). -- -- PMES indicates the required setting of Parsing_Main_Extended_Unit during -- loading of the unit. This flag is saved and restored over the call. -- Note: PMES is false for the subunit case, which seems wrong??? procedure Change_Main_Unit_To_Spec; -- This procedure is called if the main unit file contains a No_Body pragma -- and no other tokens. The effect is, if possible, to change the main unit -- from the body it references now, to the corresponding spec. This has the -- effect of ignoring the body, which is what we want. If it is impossible -- to successfully make the change, then the call has no effect, and the -- file is unchanged (this will lead to an error complaining about the -- inappropriate No_Body spec). function Create_Dummy_Package_Unit (With_Node : Node_Id; Spec_Name : Unit_Name_Type) return Unit_Number_Type; -- With_Node is the Node_Id of a with statement for which the file could -- not be found, and Spec_Name is the corresponding unit name. This call -- creates a dummy package unit so that compilation can continue without -- blowing up when the missing unit is referenced. procedure Make_Child_Decl_Unit (N : Node_Id); -- For a child subprogram body without a spec, we create a subprogram -- declaration in order to attach the required parent link. We create -- a Units_Table entry for this declaration, in order to maintain a -- one-to-one correspondence between compilation units and table entries. procedure Make_Instance_Unit (N : Node_Id; In_Main : Boolean); -- When a compilation unit is an instantiation, it contains both the -- declaration and the body of the instance, each of which can have its -- own elaboration routine. The file itself corresponds to the declaration. -- We create an additional entry for the body, so that the binder can -- generate the proper elaboration calls to both. The argument N is the -- compilation unit node created for the body. -- -- If the instance is not the main program, we still generate the instance -- body even though we do not generate code for it. In that case we still -- generate a compilation unit node for it, and we need to make an entry -- for it in the units table, so as to maintain a one-to-one mapping -- between table and nodes. The table entry is used among other things to -- provide a canonical traversal order for context units for CodePeer. -- The flag In_Main indicates whether the instance is the main unit. procedure Version_Update (U : Node_Id; From : Node_Id); -- This routine is called when unit U is found to be semantically -- dependent on unit From. It updates the version of U to register -- dependence on the version of From. The arguments are compilation -- unit nodes for the relevant library nodes. end Lib.Load;
stcarrez/ada-asf
Ada
6,763
ads
----------------------------------------------------------------------- -- asf-lifecycles -- Lifecycle -- Copyright (C) 2010, 2011, 2012, 2018, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with ASF.Events.Phases; with ASF.Contexts.Faces; with Util.Concurrent.Arrays; with ASF.Applications.Views; -- = Request Processing Lifecycle = -- The request lifecycle is decomposed in two groups: an execute group handles the -- incoming request and a render group handles the production of the response. -- The execution group is decomposed in several phases with some of them being -- executed. After each phase, some decision is made to proceed, to render the -- response or finish the request when it is completed. The request lifecycle -- handles both initial requests (an HTTP GET) and postbacks (an HTTP POST). -- -- The `Restore View` phase is always executed to handle the request and it is -- responsible for building the components in the view. The XHTML file associated -- with the view is read or obtained from the facelet cache and the components -- described by the XHTML tags are created to form the component tree. -- -- The `Apply Request Values` phase is then handled to obtain the request parameters. -- -- The `Process Validators` phase executes the input validators on the component -- tree to validate the request parameters. If a parameter is invalid, some message -- can be posted and associated with the component that triggered it. -- -- [images/asf-lifecycle.png] -- -- The `Update Model Values` phase invokes the `Set_Value` procedure on every -- Ada bean for which an input parameter was submitted and was valid. The Ada bean -- may raise and exception and an error will be associated with the associated component. -- -- The `Invoke Application` phase executes the Ada bean actions that have been triggered -- by the `f:viewAction` for an initial requests or by the postback actions. -- The Ada bean method is invoked so that it gets the control of the request and -- it returns an outcome that serves for the request navigation. -- -- The `Render Response` phase is the final phase that walks the component tree -- and renders the HTML response. -- package ASF.Lifecycles is subtype Phase_Type is Events.Phases.Phase_Type range Events.Phases.RESTORE_VIEW .. Events.Phases.RENDER_RESPONSE; type Phase_Controller is abstract tagged limited private; type Phase_Controller_Access is access all Phase_Controller'Class; type Phase_Controller_Array is array (Phase_Type) of Phase_Controller_Access; -- Execute the phase. procedure Execute (Controller : in Phase_Controller; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is abstract; -- Initialize the phase controller. procedure Initialize (Controller : in out Phase_Controller; Views : ASF.Applications.Views.View_Handler_Access) is null; type Lifecycle is abstract new Ada.Finalization.Limited_Controlled with private; type Lifecycle_Access is access all Lifecycle'Class; -- Creates the phase controllers by invoking the <b>Set_Controller</b> -- procedure for each phase. This is called by <b>Initialize</b> to build -- the lifecycle handler. procedure Create_Phase_Controllers (Controller : in out Lifecycle) is abstract; -- Initialize the the lifecycle handler. procedure Initialize (Controller : in out Lifecycle; Views : ASF.Applications.Views.View_Handler_Access); -- Finalize the lifecycle handler, freeing the allocated storage. overriding procedure Finalize (Controller : in out Lifecycle); -- Set the controller to be used for the given phase. procedure Set_Controller (Controller : in out Lifecycle; Phase : in Phase_Type; Instance : in Phase_Controller_Access); -- Register a bundle and bind it to a facelet variable. procedure Execute (Controller : in Lifecycle; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- Render the response by executing the response phase. procedure Render (Controller : in Lifecycle; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- Add a phase listener in the lifecycle controller. procedure Add_Phase_Listener (Controller : in out Lifecycle; Listener : in ASF.Events.Phases.Phase_Listener_Access); -- Remove a phase listener that was registered in the lifecycle controller. procedure Remove_Phase_Listener (Controller : in out Lifecycle; Listener : in ASF.Events.Phases.Phase_Listener_Access); private type Phase_Controller is abstract tagged limited null record; use type ASF.Events.Phases.Phase_Listener_Access; -- Use the concurrent arrays package so that we can insert phase listeners while -- we also have the lifecycle manager which invokes listeners for the existing requests. package Listener_Vectors is new Util.Concurrent.Arrays (Element_Type => ASF.Events.Phases.Phase_Listener_Access); -- Execute the lifecycle controller associated with the phase defined in <b>Phase</b>. -- Before processing, setup the faces context to update the current phase, then invoke -- the <b>Before_Phase</b> actions of the phase listeners. After execution of the controller -- invoke the <b>After_Phase</b> actions of the phase listeners. -- If an exception is raised, catch it and save it in the faces context. procedure Execute (Controller : in Lifecycle; Context : in out ASF.Contexts.Faces.Faces_Context'Class; Listeners : in Listener_Vectors.Ref; Phase : in Phase_Type); type Lifecycle is abstract new Ada.Finalization.Limited_Controlled with record Controllers : Phase_Controller_Array; Listeners : Listener_Vectors.Vector; end record; end ASF.Lifecycles;
luk9400/nsi
Ada
116
adb
with Ada.Text_IO; with Mult; procedure Main is begin Ada.Text_IO.Put_Line(Mult.Mult(15, 15)'Image); end Main;
annexi-strayline/AURA
Ada
6,677
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Registrar.Last_Run; with Stream_Hashing; separate (Configuration) procedure Step_1 (Target: in out Subsystem) is use Unit_Names; use type Stream_Hashing.Hash_Type; Last_Run_Units: Registrar.Library_Units.Library_Unit_Sets.Set renames Registrar.Last_Run.All_Library_Units; Last_Run_Subsystems: Registrar.Subsystems.Subsystem_Sets.Set renames Registrar.Last_Run.All_Subsystems; Conf_Unit_Name: constant Unit_Name := Config_Unit_Name (Target); Root_Config: constant Boolean := Target.Name.To_String = "aura"; Currently_Have_Conf: constant Boolean := Reg_Qs.Unit_Entered (Conf_Unit_Name); Currently_Have_Manifest: constant Boolean := (not Root_Config) and then Reg_Qs.Unit_Entered (Manifest_Unit_Name (Target)); Current_Conf_Unit: Library_Unit := (if Currently_Have_Conf then Reg_Qs.Lookup_Unit (Conf_Unit_Name) else (others => <>)); Previously_Had_Conf: constant Boolean := Last_Run_Units.Contains (Current_Conf_Unit); Last_Run_Conf_Unit: constant Library_Unit -- This only matters if we also currently have a configuration unit := (if Currently_Have_Conf and then Previously_Had_Conf then Last_Run_Units (Last_Run_Units.Find (Current_Conf_Unit)) else (others => <>)); begin if Currently_Have_Conf then -- See if we can load the last-run data if Previously_Had_Conf and then Current_Conf_Unit.Specification_Hash = Last_Run_Conf_Unit.Specification_Hash and then Current_Conf_Unit.Implementation_Hash = Last_Run_Conf_Unit.Implementation_Hash then -- Nice, this makes things much quicker! declare use Registrar.Subsystems; Last_Run_SS: constant Subsystem := Last_Run_Subsystems (Last_Run_Subsystems.Find (Target)); begin Target.Configuration := Last_Run_SS.Configuration; Step_4 (Target); return; end; else -- We need to re-parse the configuration unit Step_3a (Target); return; end if; else -- No configuration unit if Currently_Have_Manifest then -- Load the manifest. Note that this will never be true for the -- root config since Currently_Have_Manifest will always be false Step_2 (Target); return; else -- No manifest or config. We will generate the barebones one, -- simple because the checkout spec is a child of the config unit, so -- we need something there. -- -- If target is AURA, then this is the root config, and in that case, -- it's fine if we don't have any at all - we definately don't want to -- generate it. We also don't need to invoke complete since there is -- nothing to update in that case if not Root_Config then Generate_Basic_Config (Target); Complete (Target); end if; return; end if; end if; end Step_1;
afrl-rq/OpenUxAS
Ada
3,526
ads
-- see OpenUxAS\src\Communications\AddressedMessage.h package UxAS.Comms.Data.Addressed is -- //address$payload -- uint32_t s_minimumDelimitedAddressMessageStringLength{3}; Minimum_Delimited_Address_Message_String_Length : constant := 3; -- s_addressAttributesDelimiter character (must not be present within address) -- static std::string& -- s_addressAttributesDelimiter() { static std::string s_string("$"); return (s_string); }; Address_Attributes_Delimiter : constant String := "$"; -- static std::string& -- s_fieldDelimiter() { static std::string s_string("|"); return (s_string); }; Field_Delimiter : constant String := "|"; -- static bool -- isValidAddress(const std::string& address) function Is_Valid_Address (Address : String) return Boolean; -- static const std::string& -- s_typeName() { static std::string s_string("AddressedMessage"); return (s_string); }; Type_Name : constant String := "AddressedMessage"; type Addressed_Message is tagged limited private; type Addressed_Message_Ref is access all Addressed_Message; type Addressed_Message_View is access constant Addressed_Message; type Any_Addressed_Message is access Addressed_Message'Class; -- bool -- setAddressAndPayload(const std::string address, const std::string payload) procedure Set_Address_And_Payload (This : in out Addressed_Message; Address : String; Payload : String; Result : out Boolean) with Pre'Class => Address'Length in 1 .. Address_Max_Length and then Payload'Length in 1 .. Payload_Max_Length; -- bool -- setAddressAndPayloadFromDelimitedString(const std::string delimitedString) procedure Set_Address_And_Payload_From_Delimited_String (This : in out Addressed_Message; Delimited_String : String; Result : out Boolean) with Pre'Class => Delimited_String'Length >= Minimum_Delimited_Address_Message_String_Length; -- bool -- isValid() function Is_Valid (This : Addressed_Message) return Boolean; -- const std::string& -- getAddress() const -- { -- return m_address; -- }; function Address (This : Addressed_Message) return String; -- Data payload to be transported. -- const std::string& -- getPayload() const -- { -- return m_payload; -- }; function Payload (This : Addressed_Message) return String; -- Message address and payload combined into a single, delimited string. -- * @return Message string consisting of concatenated address and payload. -- virtual -- const std::string& -- getString() const function Content_String (This : Addressed_Message) return String; private type Addressed_Message is tagged limited record Is_Valid : Boolean := False; Content_String : Dynamic_String (Capacity => Content_String_Max_Length); -- note different name (not m_string) Address : Dynamic_String (Capacity => Address_Max_Length); Payload : Dynamic_String (Capacity => Payload_Max_Length); end record; -- bool -- parseAddressedMessageStringAndSetFields(const std::string delimitedString) procedure Parse_Addressed_Message_String_And_Set_Fields (This : in out Addressed_Message; Delimited_String : String; Result : out Boolean); end UxAS.Comms.Data.Addressed;
charlie5/cBound
Ada
2,145
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_create_picture_value_list_t is -- Item -- type Item is record repeat : aliased Interfaces.Unsigned_32; alphamap : aliased xcb.xcb_render_picture_t; alphaxorigin : aliased Interfaces.Integer_32; alphayorigin : aliased Interfaces.Integer_32; clipxorigin : aliased Interfaces.Integer_32; clipyorigin : aliased Interfaces.Integer_32; clipmask : aliased xcb.xcb_pixmap_t; graphicsexposure : aliased Interfaces.Unsigned_32; subwindowmode : aliased Interfaces.Unsigned_32; polyedge : aliased Interfaces.Unsigned_32; polymode : aliased Interfaces.Unsigned_32; dither : aliased xcb.xcb_atom_t; componentalpha : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_render_create_picture_value_list_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_create_picture_value_list_t.Item, Element_Array => xcb.xcb_render_create_picture_value_list_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_render_create_picture_value_list_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_create_picture_value_list_t.Pointer, Element_Array => xcb.xcb_render_create_picture_value_list_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_create_picture_value_list_t;
Lucretia/so
Ada
23,566
adb
------------------------------------------------------------------------------------------------------------------------ -- See COPYING for licence information. ------------------------------------------------------------------------------------------------------------------------ with Ada.Characters.Handling; with Ada.Characters.Latin_1; with Ada.Unchecked_Deallocation; with Ada.Text_IO; use Ada.Text_IO; package body Oberon.Scanner is function Lexeme (Self : in Tokens; From : in Scanner) return String is begin if Self = EOF_Token then return "EOF"; end if; -- Make sure we always return a lower case string except for EOF. return Ada.Characters.Handling.To_Lower (From.Source (Self.Lexeme_Start .. Self.Lexeme_End)); end Lexeme; function Line (Self : in Tokens) return Lines is begin return Self.Line; end Line; function Column (Self : in Tokens) return Columns is begin return Self.Column; end Column; function "=" (Left, Right : in Tokens) return Boolean is begin if Left.Token = Right.Token and Left.Lexeme_Start = Right.Lexeme_Start and Left.Lexeme_End = Right.Lexeme_End and Left.Line = Right.Line and Left.Column = Right.Column then return True; end if; return False; end "="; -- Scan the entire file in one go creating a list of tokens. procedure Scan (Self : in out Scanner) is package Latin_1 renames Ada.Characters.Latin_1; -- The states the DFA can be in. type States is (Start, In_Identifier, In_Integer, In_Comment, In_White_Space); Current_Token : Tokens := Null_Token; Current_State : States := Start; Current_Character : Natural := Natural'First; Current_Line : Lines := Lines'First; Current_Column : Columns := Columns'First; Do_New_Line : Boolean := False; procedure Push_Back with Inline => True; procedure Push_Back is begin Current_Character := Current_Character - 1; Current_Column := Current_Column - 1; -- Make sure the column is also updated, otherwise we get out of -- sync with the Current_Character value. end Push_Back; begin while Current_Character /= Self.Source'Last loop Current_Character := Current_Character + 1; case Current_State is when Start => case Self.Source (Current_Character) is when 'a' .. 'z' | 'A' .. 'Z' => Current_State := In_Identifier; Current_Token := (Token => T_Identifier, Lexeme_Start => Current_Character, Line => Current_Line, Column => Current_Column, others => <>); when '0' .. '9' => Current_State := In_Integer; Current_Token := (Token => T_Integer, Lexeme_Start => Current_Character, Line => Current_Line, Column => Current_Column, others => <>); when Latin_1.Left_Parenthesis => if Self.Source (Current_Character + 1) = Latin_1.Asterisk then -- Skip over the current character (parenthesis), the top of the loop on the next iteration -- will skip over THe asterisk. Current_Character := Current_Character + 1; Current_State := In_Comment; else Current_Token := (Token => T_Left_Parenthesis, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end if; when Latin_1.Asterisk => Current_Token := (Token => T_Times, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Ampersand => Current_Token := (Token => T_Logic_And, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Plus_Sign => Current_Token := (Token => T_Plus, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Minus_Sign => Current_Token := (Token => T_Minus, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Equals_Sign => Current_Token := (Token => T_Equal, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Pound_Sign => -- Hash sign or #. Current_Token := (Token => T_Not_Equal, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Less_Than_Sign => if Self.Source (Current_Character + 1) = Latin_1.Equals_Sign then Current_Token := (Token => T_Less_Than_Equal, Lexeme_Start => Current_Character, Lexeme_End => Current_Character + 2, Line => Current_Line, Column => Current_Column); Current_Character := Current_Character + 1; Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; else Current_Token := (Token => T_Less_Than, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end if; when Latin_1.Greater_Than_Sign => if Self.Source (Current_Character + 1) = Latin_1.Equals_Sign then Current_Token := (Token => T_Greater_Than_Equal, Lexeme_Start => Current_Character, Lexeme_End => Current_Character + 2, Line => Current_Line, Column => Current_Column); Current_Character := Current_Character + 1; Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; else Current_Token := (Token => T_Greater_Than, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end if; when Latin_1.Full_Stop => CurreNt_Token := (Token => T_Dot, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Comma => Current_Token := (Token => T_Comma, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Colon => if Self.Source (Current_Character + 1) = Latin_1.Equals_Sign then Current_Token := (Token => T_Assignment, Lexeme_Start => Current_Character, Lexeme_End => Current_Character + 2, Line => Current_Line, Column => Current_Column); Current_Character := Current_Character + 1; Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; else Current_Token := (Token => T_Colon, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end if; when Latin_1.Semicolon => Current_Token := (Token => T_Semi_Colon, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Right_Parenthesis => Current_Token := (Token => T_Right_Parenthesis, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Left_Square_Bracket => Current_Token := (Token => T_Left_Bracket, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Right_Square_Bracket => Current_Token := (Token => T_Right_Bracket, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.Tilde => Current_Token := (Token => T_Tilde, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; when Latin_1.NUL .. Latin_1.HT | Latin_1.VT .. Latin_1.FF | Latin_1.SO .. Latin_1.Space => Current_State := In_White_Space; when Latin_1.CR => -- Windows style newline, otherwise MacOS style. if Self.Source (Current_Character + 1) = Latin_1.LF then Current_Character := Current_Character + 1; end if; Do_New_Line := True; when Latin_1.LF => -- Unix style newline. Do_New_Line := True; when others => -- We have an unknown symbol in the source file. Current_Token := (Token => T_Unknown, Lexeme_Start => Current_Character, Lexeme_End => Current_Character, Line => Current_Line, Column => Current_Column); Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end case; when In_Identifier => -- At the end of the identifier, change state and update the lexeme's last position. if Self.Source (Current_Character) not in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' then Push_Back; Current_Token.Lexeme_End := Current_Character; -- Check To Make Sure this isn't a keyword. declare Text : String := Lexeme (Current_Token, Self); Cursor : Keyword_Hashed_Maps.Cursor := Keywords.Find (Text); use type Keyword_Hashed_Maps.Cursor; begin if Cursor /= Keyword_Hashed_Maps.No_Element then Current_Token.Token := Keywords.Element (Text); end if; end; Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end if; when In_Integer => -- At the end of the integer, change state and update the lexeme's last position. if Self.Source (Current_Character) not in '0' .. '9' then Push_Back; Current_Token.Lexeme_End := Current_Character; Self.Token_Stream.Append (New_Item => Current_Token); Current_Token := Null_Token; Current_State := Start; end if; when In_Comment => if Self.Source (Current_Character) = Latin_1.Asterisk then if Self.Source (Current_Character + 1) = Latin_1.Right_Parenthesis then -- Skip over the current character (asterisk), the top of the loop on the next iteration -- will skip over the parenthesis. Current_Character := Current_Character + 1; -- We don't want to keep the comment anywhere as it's not useful for a compiler. Current_State := Start; end if; end if; when In_White_Space => if Self.Source (Current_Character) not in Latin_1.NUL .. Latin_1.HT | Latin_1.VT .. Latin_1.FF | Latin_1.SO .. Latin_1.Space then Push_Back; Current_State := Start; end if; when others => null; end case; if Do_New_Line then Current_Line := Current_Line + 1; Current_Column := Columns'First; Do_New_Line := False; else Current_Column := Current_Column + 1; end if; end loop; -- Make Sure We Add The EOF Token To The Stream, Otherwise We'Ll Never Finish Parsing The File! Self.Token_Stream.Append (New_Item => EOF_Token); -- Dump out The Tokens. Self.Current_Token := Self.Token_Stream.First; Put_Line ("Tokens read:"); New_Line; -- Dump them out! declare package Token_IO is new Ada.Text_IO.Enumeration_IO (Token_Values); use Token_IO; package Line_IO is new Ada.Text_IO.Integer_IO (Lines); use Line_IO; package Column_IO is new Ada.Text_IO.Integer_IO (Columns); use Column_IO; T : Tokens := Token (Self); begin while T /= EOF_Token loop Put ("Token: "); Put (Item => T.Token, Width => 30); Put (" '" & Lexeme (T, Self) & "':"); Put (Item => T.Line, Width => 0); Put (":"); Put (Item => T.Column, Width => 0); New_Line; T := Token (Self); end loop; end; end Scan; function File_Name (Self : in Scanner) return String is begin return Ada.Strings.Unbounded.To_String (Self.Name); end File_Name; function Token (Self : in out Scanner) return Tokens is Current_Cursor : Token_Lists.Cursor := Self.Current_Token; use type Token_Lists.Cursor; begin if Current_Cursor = Token_Lists.No_Element then return EOF_Token; end if; Self.Current_Token := Token_Lists.Next (Current_Cursor); return Token_Lists.Element (Current_Cursor); end Token; package body Makers is function Create (File_Name : in String) return Scanner is begin return S : Scanner do S.Name := Ada.Strings.Unbounded.To_Unbounded_String (File_Name); S.Source := new Oberon.Files.File'(Oberon.Files.Open (File_Name)); end return; end Create; end Makers; overriding procedure Finalize (Object : in out Scanner) is procedure Free is new Ada.Unchecked_Deallocation (Object => Oberon.Files.File, Name => Oberon.Files.File_Access); begin Free (Object.Source); Object.Source := null; end Finalize; begin -- Create a map of keyword strings and Token_Values. Keywords.Include (Key => "div", New_Item => T_Divide); Keywords.Include (Key => "mod", New_Item => T_Modulus); Keywords.Include (Key => "or", New_Item => T_Logic_Or); Keywords.Include (Key => "of", New_Item => T_Of); Keywords.Include (Key => "then", New_Item => T_Then); Keywords.Include (Key => "do", New_Item => T_Do); Keywords.Include (Key => "end", New_Item => T_End); Keywords.Include (Key => "else", New_Item => T_Else); Keywords.Include (Key => "elsif", New_Item => T_Elsif); Keywords.Include (Key => "while", New_Item => T_While); Keywords.Include (Key => "array", New_Item => T_Array); Keywords.Include (Key => "record", New_Item => T_Record); Keywords.Include (Key => "const", New_Item => T_Const); Keywords.Include (Key => "type", New_Item => T_Type); Keywords.Include (Key => "var", New_Item => T_Var); Keywords.Include (Key => "procedure", New_Item => T_Procedure); Keywords.Include (Key => "begin", New_Item => T_Begin); Keywords.Include (Key => "module", New_Item => T_Module); end Oberon.Scanner;
pchapin/acrypto
Ada
481
ads
--------------------------------------------------------------------------- -- FILE : test_stream_ciphers.ads -- SUBJECT : Specification of test package for stream ciphers. -- AUTHOR : (C) Copyright 2009 by Peter Chapin -- -- Please send comments or bug reports to -- -- Peter Chapin <[email protected]> --------------------------------------------------------------------------- package Test_Stream_Ciphers is procedure Execute; end Test_Stream_Ciphers;
apple-oss-distributions/old_ncurses
Ada
6,936
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Terminfo -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control: -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with Ada.Unchecked_Conversion; package body Terminal_Interface.Curses.Terminfo is function Is_MinusOne_Pointer (P : in chars_ptr) return Boolean; function Is_MinusOne_Pointer (P : in chars_ptr) return Boolean is type Weird_Address is new System.Storage_Elements.Integer_Address; Invalid_Pointer : constant Weird_Address := -1; function To_Weird is new Ada.Unchecked_Conversion (Source => chars_ptr, Target => Weird_Address); begin if To_Weird (P) = Invalid_Pointer then return True; else return False; end if; end Is_MinusOne_Pointer; pragma Inline (Is_MinusOne_Pointer); ------------------------------------------------------------------------------ function Get_Flag (Name : String) return Boolean is function tigetflag (id : char_array) return Curses_Bool; pragma Import (C, tigetflag); Txt : char_array (0 .. Name'Length); Length : size_t; begin To_C (Name, Txt, Length); if tigetflag (Txt) = Curses_Bool (Curses_True) then return True; else return False; end if; end Get_Flag; ------------------------------------------------------------------------------ procedure Get_String (Name : String; Value : out Terminfo_String; Result : out Boolean) is function tigetstr (id : char_array) return chars_ptr; pragma Import (C, tigetstr, "tigetstr"); Txt : char_array (0 .. Name'Length); Length : size_t; Txt2 : chars_ptr; begin To_C (Name, Txt, Length); Txt2 := tigetstr (Txt); if Txt2 = Null_Ptr then Result := False; elsif Is_MinusOne_Pointer (Txt2) then raise Curses_Exception; else Value := Terminfo_String (Fill_String (Txt2)); Result := True; end if; end Get_String; ------------------------------------------------------------------------------ function Has_String (Name : String) return Boolean is function tigetstr (id : char_array) return chars_ptr; pragma Import (C, tigetstr, "tigetstr"); Txt : char_array (0 .. Name'Length); Length : size_t; Txt2 : chars_ptr; begin To_C (Name, Txt, Length); Txt2 := tigetstr (Txt); if Txt2 = Null_Ptr then return False; elsif Is_MinusOne_Pointer (Txt2) then raise Curses_Exception; else return True; end if; end Has_String; ------------------------------------------------------------------------------ function Get_Number (Name : String) return Integer is function tigetstr (s : char_array) return C_Int; pragma Import (C, tigetstr); Txt : char_array (0 .. Name'Length); Length : size_t; begin To_C (Name, Txt, Length); return Integer (tigetstr (Txt)); end Get_Number; ------------------------------------------------------------------------------ procedure Put_String (Str : Terminfo_String; affcnt : Natural := 1; putc : putctype := null) is function tputs (str : char_array; affcnt : C_Int; putc : putctype) return C_Int; function putp (str : char_array) return C_Int; pragma Import (C, tputs); pragma Import (C, putp); Txt : char_array (0 .. Str'Length); Length : size_t; Err : C_Int; begin To_C (String (Str), Txt, Length); if putc = null then Err := putp (Txt); else Err := tputs (Txt, C_Int (affcnt), putc); end if; if Err = Curses_Err then raise Curses_Exception; end if; end Put_String; end Terminal_Interface.Curses.Terminfo;
kjseefried/coreland-cgbc
Ada
1,730
adb
with BS_Support; with CGBC; with Test; procedure T_BS_03 is package BS renames BS_Support.Natural_Stacks; TC : Test.Context_t; Overflow : Boolean; Underflow : Boolean; Correct_Value : Boolean; Expected_Value : Natural; Called : Boolean; procedure Process (Element : in Natural) is begin Called := True; Correct_Value := Expected_Value = Element; end Process; procedure Peek is new BS.Peek (Process); use type CGBC.Count_Type; begin Test.Initialize (Test_Context => TC, Program => "t_bs_03", Test_DB => "TEST_DB", Test_Results => "TEST_RESULTS"); Expected_Value := 17; BS.Push (Container => BS_Support.Stack, New_Item => Expected_Value, Overflow => Overflow); pragma Assert (Overflow = False); Called := False; Peek (BS_Support.Stack, Underflow); Test.Check (Test_Context => TC, Test => 115, Condition => Called, Statement => "Called"); Test.Check (Test_Context => TC, Test => 116, Condition => Correct_Value, Statement => "Correct_Value"); Test.Check (Test_Context => TC, Test => 119, Condition => Underflow = False, Statement => "Underflow = False"); BS.Clear (BS_Support.Stack); pragma Assert (BS.Is_Empty (BS_Support.Stack)); Called := False; Peek (BS_Support.Stack, Underflow); Test.Check (Test_Context => TC, Test => 117, Condition => Underflow, Statement => "Underflow"); Test.Check (Test_Context => TC, Test => 118, Condition => Called = False, Statement => "Called = False"); end T_BS_03;
persan/advent-of-code-2020
Ada
6,454
ads
-- https://adventofcode.com/2020/day/8 --- Day 8: Handheld Halting --- -- -- Your flight to the major airline hub reaches cruising altitude without incident. While you consider checking the in-flight menu for one of those drinks that come with a little umbrella, you are interrupted by the kid sitting next to you. -- -- Their handheld game console won't turn on! They ask if you can take a look. -- -- You narrow the problem down to a strange infinite loop in the boot code (your puzzle input) of the device. You should be able to fix it, but first you need to be able to run the code in isolation. -- -- The boot code is represented as a text file with one instruction per line of text. Each instruction consists of an operation (acc, jmp, or nop) and an argument (a signed number like +4 or -20). -- -- acc increases or decreases a single global value called the accumulator by the value given in the argument. For example, acc +7 would increase the accumulator by 7. The accumulator starts at 0. After an acc instruction, the instruction immediately below it is executed next. -- jmp jumps to a new instruction relative to itself. The next instruction to execute is found using the argument as an offset from the jmp instruction; for example, jmp +2 would skip the next instruction, jmp +1 would continue to the instruction immediately below it, and jmp -20 would cause the instruction 20 lines above to be executed next. -- nop stands for No OPeration - it does nothing. The instruction immediately below it is executed next. -- -- For example, consider the following program: -- -- nop +0 -- acc +1 -- jmp +4 -- acc +3 -- jmp -3 -- acc -99 -- acc +1 -- jmp -4 -- acc +6 -- -- These instructions are visited in this order: -- -- nop +0 | 1 -- acc +1 | 2, 8(!) -- jmp +4 | 3 -- acc +3 | 6 -- jmp -3 | 7 -- acc -99 | -- acc +1 | 4 -- jmp -4 | 5 -- acc +6 | -- -- First, the nop +0 does nothing. Then, the accumulator is increased from 0 to 1 (acc +1) and jmp +4 sets the next instruction to the other acc +1 near the bottom. After it increases the accumulator from 1 to 2, jmp -4 executes, setting the next instruction to the only acc +3. It sets the accumulator to 5, and jmp -3 causes the program to continue back at the first acc +1. -- -- This is an infinite loop: with this sequence of jumps, the program will run forever. The moment the program tries to run any instruction a second time, you know it will never terminate. -- -- Immediately before the program would run an instruction a second time, the value in the accumulator is 5. -- -- Run your copy of the boot code. Immediately before any instruction is executed a second time, what value is in the accumulator? -- -- Your puzzle answer was 1586. -- -- The first half of this puzzle is complete! It provides one gold star: * -- --- Part Two --- -- -- After some careful analysis, you believe that exactly one instruction is corrupted. -- -- Somewhere in the program, either a jmp is supposed to be a nop, or a nop is supposed to be a jmp. (No acc instructions were harmed in the corruption of this boot code.) -- -- The program is supposed to terminate by attempting to execute an instruction immediately after the last instruction in the file. By changing exactly one jmp or nop, you can repair the boot code and make it terminate correctly. -- -- For example, consider the same program from above: -- -- nop +0 -- acc +1 -- jmp +4 -- acc +3 -- jmp -3 -- acc -99 -- acc +1 -- jmp -4 -- acc +6 -- -- If you change the first instruction from nop +0 to jmp +0, it would create a single-instruction infinite loop, never leaving that instruction. If you change almost any of the jmp instructions, the program will still eventually find another jmp instruction and loop forever. -- -- However, if you change the second-to-last instruction (from jmp -4 to nop -4), the program terminates! The instructions are visited in this order: -- -- nop +0 | 1 -- acc +1 | 2 -- jmp +4 | 3 -- acc +3 | -- jmp -3 | -- acc -99 | -- acc +1 | 4 -- nop -4 | 5 -- acc +6 | 6 -- -- After the last instruction (acc +6), the program terminates by attempting to run the instruction below the last instruction in the file. With this change, after the program terminates, the accumulator contains the value 8 (acc +1, acc +1, acc +6). -- -- Fix the program so that it terminates normally by changing exactly one jmp (to nop) or nop (to jmp). What is the value of the accumulator after the program terminates? with GNAT.Source_Info; with Ada.Containers.Vectors; package Adventofcode.Day_8 is type Op_Code is (Nop, Acc, Jmp); type Instruction_Type is record Executed : Boolean := False; Code : Op_Code := Nop; Value : Integer := 0; end record; package Memory_Type_Impl is new Ada.Containers.Vectors (Natural, Instruction_Type); type Memory_Type is new Memory_Type_Impl.Vector with null record; procedure Load (Memory : in out Memory_Type; From_Path : String); procedure Assemble (Self : in out Memory_Type; Line : String); type Base_Computer is limited interface; procedure Load (Self : in out Base_Computer; From_Path : String) is abstract; procedure Run (Self : in out Base_Computer) is abstract; procedure Print (Self : in out Base_Computer) is abstract; type Computer_Type is new Base_Computer with record Runing : Boolean := True; Execution_OK : Boolean := False; Trace : Boolean := False; Accumulator : Integer := 0; Program_Counter : Integer := 0; Storage : Memory_Type; end record; overriding procedure Load (Self : in out Computer_Type; From_Path : String); procedure Reset (Self : in out Computer_Type); procedure Acc_Op (Self : in out Computer_Type); procedure Jmp_Op (Self : in out Computer_Type); procedure Nop_Op (Self : in out Computer_Type); procedure Step (Self : in out Computer_Type); overriding procedure Run (Self : in out Computer_Type); overriding procedure Print (Self : in out Computer_Type); procedure Print_Trace (Self : in out Computer_Type; Location : String := GNAT.Source_Info.Enclosing_Entity); private Decoder : array (Op_Code) of access procedure (Self : in out Computer_Type) := (Acc => Acc_Op'Access, Jmp => Jmp_Op'Access, Nop => Nop_Op'Access); end Adventofcode.Day_8;
zhmu/ananas
Ada
522
adb
-- { dg-do run } procedure Enum3 is type Enum is (Aaa, Bbb, Ccc); for Enum use (1,2,4); begin for Lo in Enum loop for Hi in Enum loop declare subtype S is Enum range Lo .. Hi; type Vector is array (S) of Integer; Vec : Vector; begin for I in S loop Vec (I) := 0; end loop; if Vec /= (S => 0) then raise Program_Error; end if; end; end loop; end loop; end;
tum-ei-rcs/StratoX
Ada
5,099
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S T O R A G E _ E L E M E N T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ pragma Compiler_Unit_Warning; with Ada.Unchecked_Conversion; package body System.Storage_Elements is pragma Suppress (All_Checks); -- Conversion to/from address -- Note qualification below of To_Address to avoid ambiguities systems -- where Address is a visible integer type. function To_Address is new Ada.Unchecked_Conversion (Storage_Offset, Address); function To_Offset is new Ada.Unchecked_Conversion (Address, Storage_Offset); -- Conversion to/from integers -- These functions must be place first because they are inlined_always -- and are used and inlined in other subprograms defined in this unit. ---------------- -- To_Address -- ---------------- function To_Address (Value : Integer_Address) return Address is begin return Address (Value); end To_Address; ---------------- -- To_Integer -- ---------------- function To_Integer (Value : Address) return Integer_Address is begin return Integer_Address (Value); end To_Integer; -- Address arithmetic --------- -- "+" -- --------- function "+" (Left : Address; Right : Storage_Offset) return Address is begin return Storage_Elements.To_Address (To_Integer (Left) + To_Integer (To_Address (Right))); end "+"; function "+" (Left : Storage_Offset; Right : Address) return Address is begin return Storage_Elements.To_Address (To_Integer (To_Address (Left)) + To_Integer (Right)); end "+"; --------- -- "-" -- --------- function "-" (Left : Address; Right : Storage_Offset) return Address is begin return Storage_Elements.To_Address (To_Integer (Left) - To_Integer (To_Address (Right))); end "-"; function "-" (Left, Right : Address) return Storage_Offset is begin return To_Offset (Storage_Elements.To_Address (To_Integer (Left) - To_Integer (Right))); end "-"; ----------- -- "mod" -- ----------- function "mod" (Left : Address; Right : Storage_Offset) return Storage_Offset is begin if Right > 0 then return Storage_Offset (To_Integer (Left) mod Integer_Address (Right)); -- The negative case makes no sense since it is a case of a mod where -- the left argument is unsigned and the right argument is signed. In -- accordance with the (spirit of the) permission of RM 13.7.1(16), -- we raise CE, and also include the zero case here. Yes, the RM says -- PE, but this really is so obviously more like a constraint error. else raise Constraint_Error; end if; end "mod"; end System.Storage_Elements;
zhmu/ananas
Ada
288
adb
-- { dg-do link } -- { dg-options "-O -flto" { target lto } } with Lto16_Pkg; use Lto16_Pkg; with Text_IO; use Text_IO; procedure Lto16 is begin if F = 0.0 then Put_Line ("zero"); else Put_Line ("non-zero"); end if; exception when others => Put_Line ("exception"); end;
eqcola/ada-ado
Ada
24,853
adb
----------------------------------------------------------------------- -- ado-statements-sqlite -- SQLite database statements -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Sqlite3_H; with Sqlite3_H.Perfect_Hash; with Interfaces.C.Strings; with Util.Log; with Util.Log.Loggers; with ADO.Drivers.Dialects; package body ADO.Statements.Sqlite is use Ada.Calendar; use type ADO.Schemas.Class_Mapping_Access; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Statements.Sqlite"); type Dialect is new ADO.Drivers.Dialects.Dialect with null record; -- Check if the string is a reserved keyword. overriding function Is_Reserved (D : in Dialect; Name : in String) return Boolean; -- Get the quote character to escape an identifier. overriding function Get_Identifier_Quote (D : in Dialect) return Character; -- Append the item in the buffer escaping some characters if necessary overriding procedure Escape_Sql (D : in Dialect; Buffer : in out Unbounded_String; Item : in ADO.Blob_Ref); Sqlite_Dialect : aliased Dialect; procedure Execute (Connection : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; SQL : in String; Result : out int; Stmt : out System.Address); -- Releases the sqlite statement procedure Release_Stmt (Connection : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Stmt : in out System.Address); procedure Prepare (Stmt : in out Sqlite_Query_Statement; Query : in String); -- ------------------------------ -- Check if the string is a reserved keyword. -- ------------------------------ overriding function Is_Reserved (D : in Dialect; Name : in String) return Boolean is pragma Unreferenced (D); begin return Sqlite3_H.Perfect_Hash.Is_Keyword (Name); end Is_Reserved; -- ------------------------------ -- Get the quote character to escape an identifier. -- ------------------------------ overriding function Get_Identifier_Quote (D : in Dialect) return Character is pragma Unreferenced (D); begin return '`'; end Get_Identifier_Quote; -- ------------------------------ -- Append the item in the buffer escaping some characters if necessary -- ------------------------------ overriding procedure Escape_Sql (D : in Dialect; Buffer : in out Unbounded_String; Item : in ADO.Blob_Ref) is pragma Unreferenced (D); use type Ada.Streams.Stream_Element; C : Ada.Streams.Stream_Element; Blob : constant ADO.Blob_Access := Item.Value; begin for I in Blob.Data'Range loop C := Blob.Data (I); case C is when Character'Pos (ASCII.NUL) => Append (Buffer, '\'); Append (Buffer, '0'); when Character'Pos (''') => Append (Buffer, '''); Append (Buffer, Character'Val (C)); when others => Append (Buffer, Character'Val (C)); end case; end loop; end Escape_Sql; -- ------------------------------ -- Releases the sqlite statement -- ------------------------------ procedure Release_Stmt (Connection : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Stmt : in out System.Address) is use System; Result : int; begin if Stmt /= System.Null_Address then Result := Sqlite3_H.sqlite3_reset (Stmt); ADO.Drivers.Connections.Sqlite.Check_Error (Connection, Result); Result := Sqlite3_H.sqlite3_finalize (Stmt); ADO.Drivers.Connections.Sqlite.Check_Error (Connection, Result); Stmt := System.Null_Address; end if; end Release_Stmt; -- ------------------------------ -- Delete statement -- ------------------------------ -- ------------------------------ -- Execute the query -- ------------------------------ overriding procedure Execute (Stmt : in out Sqlite_Delete_Statement; Result : out Natural) is begin ADO.SQL.Append (Target => Stmt.Query.SQL, SQL => "DELETE FROM "); ADO.SQL.Append_Name (Target => Stmt.Query.SQL, Name => Stmt.Table.Table.all); if Stmt.Query.Has_Join then ADO.SQL.Append (Target => Stmt.Query.SQL, SQL => Stmt.Query.Get_Join); end if; if Stmt.Query.Has_Filter then ADO.SQL.Append (Target => Stmt.Query.SQL, SQL => " WHERE "); ADO.SQL.Append (Target => Stmt.Query.SQL, SQL => Stmt.Query.Get_Filter); end if; declare Sql_Query : constant String := Stmt.Query.Expand; Handle : aliased System.Address; Res : int; begin Execute (Connection => Stmt.Connection, SQL => Sql_Query, Result => Res, Stmt => Handle); ADO.Drivers.Connections.Sqlite.Check_Error (Stmt.Connection, Res); Release_Stmt (Stmt.Connection, Handle); Result := Natural (Sqlite3_H.sqlite3_changes (Stmt.Connection)); end; end Execute; -- ------------------------------ -- Create the delete statement -- ------------------------------ function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access is Result : constant Sqlite_Delete_Statement_Access := new Sqlite_Delete_Statement; begin Result.Connection := Database; Result.Table := Table; Result.Query := Result.Delete_Query'Access; Result.Delete_Query.Set_Dialect (Sqlite_Dialect'Access); return Result.all'Access; end Create_Statement; procedure Execute (Connection : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; SQL : in String; Result : out int; Stmt : out System.Address) is ZSql : Strings.chars_ptr := Strings.New_String (SQL); Handle : aliased System.Address; begin Log.Debug ("Execute: {0}", SQL); Result := Sqlite3_H.sqlite3_prepare_v2 (db => Connection, zSql => ZSql, nByte => int (SQL'Length + 1), ppStmt => Handle'Address, pzTail => System.Null_Address); Strings.Free (ZSql); Stmt := Handle; if Result /= Sqlite3_H.SQLITE_OK then ADO.Drivers.Connections.Sqlite.Check_Error (Connection, Result); return; end if; Result := Sqlite3_H.sqlite3_step (Handle); end Execute; -- ------------------------------ -- Update statement -- ------------------------------ -- ------------------------------ -- Execute the query -- ------------------------------ overriding procedure Execute (Stmt : in out Sqlite_Update_Statement) is Result : Integer; begin Sqlite_Update_Statement'Class (Stmt).Execute (Result); end Execute; -- ------------------------------ -- Execute the query -- ------------------------------ overriding procedure Execute (Stmt : in out Sqlite_Update_Statement; Result : out Integer) is begin ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => "UPDATE "); ADO.SQL.Append_Name (Target => Stmt.This_Query.SQL, Name => Stmt.Table.Table.all); ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => " SET "); ADO.SQL.Append_Fields (Update => Stmt.This_Query); if Stmt.This_Query.Has_Join then ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => Stmt.This_Query.Get_Join); end if; if Stmt.This_Query.Has_Filter then ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => " WHERE "); ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => Stmt.This_Query.Get_Filter); end if; declare Sql_Query : constant String := Stmt.This_Query.Expand; Handle : aliased System.Address; Res : int; begin Execute (Connection => Stmt.Connection, SQL => Sql_Query, Result => Res, Stmt => Handle); ADO.Drivers.Connections.Sqlite.Check_Error (Stmt.Connection, Res); Release_Stmt (Stmt.Connection, Handle); Result := Natural (Sqlite3_H.sqlite3_changes (Stmt.Connection)); end; end Execute; -- ------------------------------ -- Create an update statement -- ------------------------------ function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access is Result : constant Sqlite_Update_Statement_Access := new Sqlite_Update_Statement; begin Result.Connection := Database; Result.Table := Table; Result.Update := Result.This_Query'Access; Result.Query := Result.This_Query'Access; Result.This_Query.Set_Dialect (Sqlite_Dialect'Access); return Result.all'Access; end Create_Statement; -- ------------------------------ -- Insert statement -- ------------------------------ -- ------------------------------ -- Execute the query -- ------------------------------ overriding procedure Execute (Stmt : in out Sqlite_Insert_Statement; Result : out Integer) is begin if Stmt.Table /= null then ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => "INSERT INTO "); ADO.SQL.Append_Name (Target => Stmt.This_Query.SQL, Name => Stmt.Table.Table.all); ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => " ("); ADO.SQL.Append_Fields (Update => Stmt.This_Query, Mode => False); ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => ") VALUES("); ADO.SQL.Append_Fields (Update => Stmt.This_Query, Mode => True); ADO.SQL.Append (Target => Stmt.This_Query.SQL, SQL => ")"); end if; declare Sql_Query : constant String := Stmt.This_Query.Expand; Handle : aliased System.Address; Res : int; begin Execute (Connection => Stmt.Connection, SQL => Sql_Query, Result => Res, Stmt => Handle); ADO.Drivers.Connections.Sqlite.Check_Error (Stmt.Connection, Res); Release_Stmt (Stmt.Connection, Handle); Result := Natural (Sqlite3_H.sqlite3_changes (Stmt.Connection)); end; end Execute; -- ------------------------------ -- Create an insert statement. -- ------------------------------ function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access is Result : constant Sqlite_Insert_Statement_Access := new Sqlite_Insert_Statement; begin Result.Connection := Database; Result.Table := Table; Result.Update := Result.This_Query'Access; Result.Query := Result.This_Query'Access; Result.This_Query.Set_Dialect (Sqlite_Dialect'Access); ADO.SQL.Set_Insert_Mode (Result.This_Query); return Result.all'Access; end Create_Statement; procedure Prepare (Stmt : in out Sqlite_Query_Statement; Query : in String) is Sql : Strings.chars_ptr := Strings.New_String (Query); Result : int; Handle : aliased System.Address; begin Result := Sqlite3_H.sqlite3_prepare_v2 (db => Stmt.Connection, zSql => Sql, nByte => int (Query'Length + 1), ppStmt => Handle'Address, pzTail => System.Null_Address); Strings.Free (Sql); if Result = Sqlite3_H.SQLITE_OK then Stmt.Stmt := Handle; else ADO.Drivers.Connections.Sqlite.Check_Error (Stmt.Connection, Result); end if; end Prepare; -- ------------------------------ -- Execute the query -- ------------------------------ procedure Execute (Query : in out Sqlite_Query_Statement) is use Sqlite3_H; use System; Result : int; begin if Query.This_Query.Has_Join then ADO.SQL.Append (Target => Query.This_Query.SQL, SQL => " "); ADO.SQL.Append (Target => Query.This_Query.SQL, SQL => Query.This_Query.Get_Join); end if; if Query.This_Query.Has_Filter then ADO.SQL.Append (Target => Query.This_Query.SQL, SQL => " WHERE "); ADO.SQL.Append (Target => Query.This_Query.SQL, SQL => Query.This_Query.Get_Filter); end if; declare Expanded_Query : constant String := Query.Query.Expand; begin -- Execute the query Prepare (Query, Expanded_Query); Log.Debug ("Execute: {0}", Expanded_Query); Result := Sqlite3_H.sqlite3_step (Query.Stmt); if Result = Sqlite3_H.SQLITE_ROW then Query.Status := HAS_ROW; elsif Result = Sqlite3_H.SQLITE_DONE then Query.Status := DONE; else Query.Status := ERROR; declare Error : constant Strings.chars_ptr := Sqlite3_H.sqlite3_errmsg (Query.Connection); Message : constant String := Strings.Value (Error); begin Log.Error ("Query failed: '{0}'", Expanded_Query); Log.Error (" with error: '{0}'", Message); raise Invalid_Statement with "Query failed: " & Message; end; end if; end; end Execute; -- ------------------------------ -- Returns True if there is more data (row) to fetch -- ------------------------------ function Has_Elements (Query : in Sqlite_Query_Statement) return Boolean is use type System.Address; begin return Query.Stmt /= System.Null_Address and then Query.Status = HAS_ROW; end Has_Elements; -- ------------------------------ -- Fetch the next element -- ------------------------------ overriding procedure Next (Query : in out Sqlite_Query_Statement) is use type System.Address; Result : int; begin if Query.Stmt = System.Null_Address then Query.Status := ERROR; else Result := Sqlite3_H.sqlite3_step (Query.Stmt); if Result = Sqlite3_H.SQLITE_ROW then Query.Status := HAS_ROW; elsif Result = Sqlite3_H.SQLITE_DONE then Query.Status := DONE; else ADO.Drivers.Connections.Sqlite.Check_Error (Query.Connection, Result); Query.Status := ERROR; end if; end if; end Next; -- ------------------------------ -- Returns true if the column <b>Column</b> is null. -- ------------------------------ overriding function Is_Null (Query : in Sqlite_Query_Statement; Column : in Natural) return Boolean is Res : constant int := Sqlite3_H.sqlite3_column_type (Query.Stmt, int (Column)); begin return Res = Sqlite3_H.SQLITE_NULL; end Is_Null; -- ------------------------------ -- Get the number of rows returned by the query -- ------------------------------ function Get_Row_Count (Query : in Sqlite_Query_Statement) return Natural is pragma Unreferenced (Query); begin return 0; end Get_Row_Count; -- ------------------------------ -- Get the column value at position <b>Column</b> and -- return it as an <b>Int64</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. -- ------------------------------ overriding function Get_Int64 (Query : in Sqlite_Query_Statement; Column : in Natural) return Int64 is Result : constant Sqlite3_H.sqlite_int64 := Sqlite3_H.sqlite3_column_int64 (Query.Stmt, int (Column)); begin return Int64 (Result); end Get_Int64; -- ------------------------------ -- Get the column value at position <b>Column</b> and -- return it as an <b>Unbounded_String</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. -- ------------------------------ overriding function Get_Unbounded_String (Query : in Sqlite_Query_Statement; Column : in Natural) return Unbounded_String is use type Strings.chars_ptr; Text : constant Strings.chars_ptr := Sqlite3_H.sqlite3_column_text (Query.Stmt, int (Column)); begin if Text = Strings.Null_Ptr then return Null_Unbounded_String; else return To_Unbounded_String (Interfaces.C.Strings.Value (Text)); end if; end Get_Unbounded_String; -- ------------------------------ -- Get the column value at position <b>Column</b> and -- return it as an <b>Unbounded_String</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. -- ------------------------------ overriding function Get_String (Query : Sqlite_Query_Statement; Column : Natural) return String is use type Strings.chars_ptr; Text : constant Strings.chars_ptr := Sqlite3_H.sqlite3_column_text (Query.Stmt, int (Column)); begin if Text = Strings.Null_Ptr then return ""; else return Interfaces.C.Strings.Value (Text); end if; end Get_String; -- ------------------------------ -- Get the column value at position <b>Column</b> and -- return it as a <b>Blob</b> reference. -- ------------------------------ overriding function Get_Blob (Query : in Sqlite_Query_Statement; Column : in Natural) return ADO.Blob_Ref is use type System.Address; Text : constant System.Address := Sqlite3_H.sqlite3_column_blob (Query.Stmt, int (Column)); Len : constant int := Sqlite3_H.sqlite3_column_bytes (Query.Stmt, int (Column)); begin if Text = System.Null_Address or Len <= 0 then return Null_Blob; else return Get_Blob (Size => Natural (Len), Data => To_Chars_Ptr (Text)); end if; end Get_Blob; -- ------------------------------ -- Get the column value at position <b>Column</b> and -- return it as an <b>Time</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. -- ------------------------------ function Get_Time (Query : in Sqlite_Query_Statement; Column : in Natural) return Ada.Calendar.Time is Text : constant Strings.chars_ptr := Sqlite3_H.sqlite3_column_text (Query.Stmt, int (Column)); begin return ADO.Statements.Get_Time (ADO.Statements.To_Chars_Ptr (Text)); end Get_Time; -- ------------------------------ -- Get the column type -- ------------------------------ overriding function Get_Column_Type (Query : in Sqlite_Query_Statement; Column : in Natural) return ADO.Schemas.Column_Type is Res : constant int := Sqlite3_H.sqlite3_column_type (Query.Stmt, int (Column)); begin case Res is when Sqlite3_H.SQLITE_NULL => return ADO.Schemas.T_NULL; when Sqlite3_H.SQLITE_INTEGER => return ADO.Schemas.T_INTEGER; when Sqlite3_H.SQLITE_FLOAT => return ADO.Schemas.T_FLOAT; when Sqlite3_H.SQLITE_TEXT => return ADO.Schemas.T_VARCHAR; when Sqlite3_H.SQLITE_BLOB => return ADO.Schemas.T_BLOB; when others => return ADO.Schemas.T_UNKNOWN; end case; end Get_Column_Type; -- ------------------------------ -- Get the column name. -- Raises <b>Invalid_Column</b> if the column does not exist. -- ------------------------------ overriding function Get_Column_Name (Query : in Sqlite_Query_Statement; Column : in Natural) return String is use type Interfaces.C.Strings.chars_ptr; Name : constant Interfaces.C.Strings.chars_ptr := Sqlite3_H.sqlite3_column_name (Query.Stmt, int (Column)); begin if Name = Interfaces.C.Strings.Null_Ptr then return ""; else return Interfaces.C.Strings.Value (Name); end if; end Get_Column_Name; -- ------------------------------ -- Get the number of columns in the result. -- ------------------------------ overriding function Get_Column_Count (Query : in Sqlite_Query_Statement) return Natural is begin return Natural (Sqlite3_H.sqlite3_column_count (Query.Stmt)); end Get_Column_Count; -- ------------------------------ -- Deletes the query statement. -- ------------------------------ overriding procedure Finalize (Query : in out Sqlite_Query_Statement) is begin Release_Stmt (Query.Connection, Query.Stmt); end Finalize; -- ------------------------------ -- Create the query statement. -- ------------------------------ function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access is Result : constant Sqlite_Query_Statement_Access := new Sqlite_Query_Statement; begin Result.Connection := Database; Result.Query := Result.This_Query'Access; Result.This_Query.Set_Dialect (Sqlite_Dialect'Access); if Table /= null then ADO.SQL.Append (Target => Result.This_Query.SQL, SQL => "SELECT "); for I in Table.Members'Range loop if I > Table.Members'First then ADO.SQL.Append (Target => Result.This_Query.SQL, SQL => ", "); end if; ADO.SQL.Append (Target => Result.This_Query.SQL, SQL => "o."); ADO.SQL.Append_Name (Target => Result.This_Query.SQL, Name => Table.Members (I).all); end loop; ADO.SQL.Append (Target => Result.This_Query.SQL, SQL => " FROM "); ADO.SQL.Append_Name (Target => Result.This_Query.SQL, Name => Table.Table.all); ADO.SQL.Append (Target => Result.This_Query.SQL, SQL => " AS o "); end if; return Result.all'Access; end Create_Statement; -- ------------------------------ -- Create the query statement. -- ------------------------------ function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Query : in String) return Query_Statement_Access is Result : constant Sqlite_Query_Statement_Access := new Sqlite_Query_Statement; begin Result.Connection := Database; Result.Query := Result.This_Query'Access; Result.This_Query.Set_Dialect (Sqlite_Dialect'Access); Append (Query => Result.all, SQL => Query); return Result.all'Access; end Create_Statement; end ADO.Statements.Sqlite;
AdaCore/training_material
Ada
3,397
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_SDL_stdinc_h; with SDL_SDL_video_h; with System; package SDL_SDL_mouse_h is -- arg-macro: function SDL_BUTTON (X) -- return 2 ** ((X)-1); SDL_BUTTON_LEFT : constant := 1; -- ../include/SDL/SDL_mouse.h:123 SDL_BUTTON_MIDDLE : constant := 2; -- ../include/SDL/SDL_mouse.h:124 SDL_BUTTON_RIGHT : constant := 3; -- ../include/SDL/SDL_mouse.h:125 SDL_BUTTON_WHEELUP : constant := 4; -- ../include/SDL/SDL_mouse.h:126 SDL_BUTTON_WHEELDOWN : constant := 5; -- ../include/SDL/SDL_mouse.h:127 SDL_BUTTON_X1 : constant := 6; -- ../include/SDL/SDL_mouse.h:128 SDL_BUTTON_X2 : constant := 7; -- ../include/SDL/SDL_mouse.h:129 -- unsupported macro: SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) -- unsupported macro: SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) -- unsupported macro: SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) -- unsupported macro: SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) -- unsupported macro: SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) -- skipped empty struct WMcursor type SDL_Cursor_save_array is array (0 .. 1) of access SDL_SDL_stdinc_h.Uint8; type SDL_Cursor is record area : aliased SDL_SDL_video_h.SDL_Rect; -- ../include/SDL/SDL_mouse.h:42 hot_x : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_mouse.h:43 hot_y : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_mouse.h:43 data : access SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_mouse.h:44 mask : access SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_mouse.h:45 save : aliased SDL_Cursor_save_array; -- ../include/SDL/SDL_mouse.h:46 wm_cursor : System.Address; -- ../include/SDL/SDL_mouse.h:47 end record; pragma Convention (C_Pass_By_Copy, SDL_Cursor); -- ../include/SDL/SDL_mouse.h:41 function SDL_GetMouseState (x : access int; y : access int) return SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_mouse.h:57 pragma Import (C, SDL_GetMouseState, "SDL_GetMouseState"); function SDL_GetRelativeMouseState (x : access int; y : access int) return SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_mouse.h:65 pragma Import (C, SDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"); procedure SDL_WarpMouse (x : SDL_SDL_stdinc_h.Uint16; y : SDL_SDL_stdinc_h.Uint16); -- ../include/SDL/SDL_mouse.h:70 pragma Import (C, SDL_WarpMouse, "SDL_WarpMouse"); function SDL_CreateCursor (data : access SDL_SDL_stdinc_h.Uint8; mask : access SDL_SDL_stdinc_h.Uint8; w : int; h : int; hot_x : int; hot_y : int) return access SDL_Cursor; -- ../include/SDL/SDL_mouse.h:85 pragma Import (C, SDL_CreateCursor, "SDL_CreateCursor"); procedure SDL_SetCursor (cursor : access SDL_Cursor); -- ../include/SDL/SDL_mouse.h:93 pragma Import (C, SDL_SetCursor, "SDL_SetCursor"); function SDL_GetCursor return access SDL_Cursor; -- ../include/SDL/SDL_mouse.h:98 pragma Import (C, SDL_GetCursor, "SDL_GetCursor"); procedure SDL_FreeCursor (cursor : access SDL_Cursor); -- ../include/SDL/SDL_mouse.h:103 pragma Import (C, SDL_FreeCursor, "SDL_FreeCursor"); function SDL_ShowCursor (toggle : int) return int; -- ../include/SDL/SDL_mouse.h:112 pragma Import (C, SDL_ShowCursor, "SDL_ShowCursor"); end SDL_SDL_mouse_h;
AdaCore/Ada_Drivers_Library
Ada
10,266
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body IS31FL3731 is subtype Dispatch is Device'Class; -- Dev_Address : constant UInt10 := 16#E8#; Control_Bank : constant UInt8 := 16#0B#; Enable_Offset : constant := 16#00#; Blink_Offset : constant := 16#12#; Bright_Offset : constant := 16#24#; procedure Select_Bank (This : in out Device; Bank : UInt8); procedure Write (This : in out Device; Data : UInt8_Array); procedure Read (This : in out Device; Reg : UInt8; Data : out UInt8) with Unreferenced; function Dev_Address (This : Device) return I2C_Address is (I2C_Address ((16#74# or UInt10 (This.AD)) * 2)); ----------- -- Write -- ----------- procedure Write (This : in out Device; Data : UInt8_Array) is Status : I2C_Status; begin This.Port.Master_Transmit (This.Dev_Address, Data, Status); if Status /= Ok then raise Program_Error; end if; end Write; ---------- -- Read -- ---------- procedure Read (This : in out Device; Reg : UInt8; Data : out UInt8) is Status : I2C_Status; Tmp : UInt8_Array (0 .. 0); begin This.Write ((0 => Reg)); This.Port.Master_Receive (This.Dev_Address, Tmp, Status); if Status /= Ok then raise Program_Error; end if; Data := Tmp (Tmp'First); end Read; -----------------This. -- Select_Bank -- ----------------- procedure Select_Bank (This : in out Device; Bank : UInt8) is begin This.Write ((0 => 16#FD#, 1 => Bank)); end Select_Bank; ---------------- -- Initialize -- ---------------- procedure Initialize (This : in out Device) is begin This.Select_Bank (Control_Bank); -- Disable Shutdown This.Write ((0 => 16#0A#, 1 => 16#01#)); -- Picture mode This.Write ((0 => 16#00#, 1 => 16#00#)); -- Blink mode This.Write ((0 => 16#05#, 1 => 16#00#)); for Frame in Frame_Id loop This.Select_Bank (UInt8 (Frame)); This.Clear; end loop; This.Select_Bank (UInt8 (This.Frame_Sel)); end Initialize; ------------------- -- Display_Frame -- ------------------- procedure Display_Frame (This : in out Device; Frame : Frame_Id) is begin This.Select_Bank (Control_Bank); This.Write ((0 => 16#01#, 1 => UInt8 (Frame))); This.Select_Bank (UInt8 (This.Frame_Sel)); end Display_Frame; ------------------ -- Select_Frame -- ------------------ procedure Select_Frame (This : in out Device; Frame : Frame_Id) is begin This.Frame_Sel := Frame; This.Select_Bank (UInt8 (This.Frame_Sel)); end Select_Frame; ---------- -- Fill -- ---------- procedure Fill (This : in out Device; Brightness : UInt8; Blink : Boolean := False) is begin -- Enable all LEDs This.Write ((0 => Enable_Offset, 1 .. 18 => 16#FF#)); This.Enable_Bitmask (This.Frame_Sel) := (others => 16#FF#); -- Set all blink This.Write ((0 => Blink_Offset, 1 .. 18 => (if Blink then 16#FF# else 16#00#))); This.Blink_Bitmask (This.Frame_Sel) := (others => (if Blink then 16#FF# else 16#00#)); -- Set all brighness This.Write ((0 => Bright_Offset, 1 .. 144 => Brightness)); end Fill; ----------- -- Clear -- ----------- procedure Clear (This : in out Device) is begin -- Disable all LEDs This.Write ((0 => Enable_Offset, 1 .. 18 => 0)); This.Enable_Bitmask (This.Frame_Sel) := (others => 0); -- Disable all blink This.Write ((0 => Blink_Offset, 1 .. 18 => 0)); This.Blink_Bitmask (This.Frame_Sel) := (others => 0); -- Set all brighness to zero This.Write ((0 => Bright_Offset, 1 .. 144 => 0)); end Clear; ------------ -- Enable -- ------------ procedure Enable (This : in out Device; X : X_Coord; Y : Y_Coord) is LED : constant LED_Id := Dispatch (This).LED_Address (X, Y); Reg_Offset : constant UInt8 := UInt8 (LED) / 8; Bit : constant UInt8 := Shift_Left (UInt8 (1), Integer (LED) mod 8); Mask : UInt8 renames This.Enable_Bitmask (This.Frame_Sel) (LED_Bitmask_Index (Reg_Offset)); begin Mask := Mask or Bit; This.Write ((0 => Enable_Offset + Reg_Offset, 1 => Mask)); end Enable; ------------- -- Disable -- ------------- procedure Disable (This : in out Device; X : X_Coord; Y : Y_Coord) is LED : constant LED_Id := Dispatch (This).LED_Address (X, Y); Reg_Offset : constant UInt8 := UInt8 (LED) / 8; Bit : constant UInt8 := Shift_Left (UInt8 (1), Integer (LED) mod 8); Mask : UInt8 renames This.Enable_Bitmask (This.Frame_Sel) (LED_Bitmask_Index (Reg_Offset)); begin Mask := Mask and not Bit; This.Write ((0 => Enable_Offset + Reg_Offset, 1 => Mask)); end Disable; -------------------- -- Set_Brightness -- -------------------- procedure Set_Brightness (This : in out Device; X : X_Coord; Y : Y_Coord; Brightness : UInt8) is LED : constant LED_Id := Dispatch (This).LED_Address (X, Y); begin This.Write ((0 => Bright_Offset + UInt8 (LED), 1 => Brightness)); end Set_Brightness; ------------------ -- Enable_Blink -- ------------------ procedure Enable_Blink (This : in out Device; X : X_Coord; Y : Y_Coord) is LED : constant LED_Id := Dispatch (This).LED_Address (X, Y); Reg_Offset : constant UInt8 := UInt8 (LED) / 8; Bit : constant UInt8 := Shift_Left (UInt8 (1), Integer (LED) mod 8); Mask : UInt8 renames This.Blink_Bitmask (This.Frame_Sel) (LED_Bitmask_Index (Reg_Offset)); begin Mask := Mask or Bit; This.Write ((0 => Blink_Offset + Reg_Offset, 1 => Mask)); end Enable_Blink; ------------------- -- Disable_Blink -- ------------------- procedure Disable_Blink (This : in out Device; X : X_Coord; Y : Y_Coord) is LED : constant LED_Id := Dispatch (This).LED_Address (X, Y); Reg_Offset : constant UInt8 := UInt8 (LED) / 8; Bit : constant UInt8 := Shift_Left (UInt8 (1), Integer (LED) mod 8); Mask : UInt8 renames This.Blink_Bitmask (This.Frame_Sel) (LED_Bitmask_Index (Reg_Offset)); begin Mask := Mask or Bit; This.Write ((0 => Blink_Offset + Reg_Offset, 1 => Mask)); end Disable_Blink; -------------------- -- Set_Blink_Rate -- -------------------- procedure Set_Blink_Rate (This : in out Device; A : UInt3) is begin This.Select_Bank (Control_Bank); if A = 0 then This.Write ((0 => 16#05#, 1 => 2#0000_0000#)); else This.Write ((0 => 16#05#, 1 => 2#0000_1000# or UInt8 (A))); end if; This.Select_Bank (UInt8 (This.Frame_Sel)); end Set_Blink_Rate; end IS31FL3731;
reznikmm/matreshka
Ada
6,870
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.UML.Abstractions; with AMF.Visitors.Standard_Profile_L2_Iterators; with AMF.Visitors.Standard_Profile_L2_Visitors; package body AMF.Internals.Standard_Profile_L2_Traces is -------------------------- -- Get_Base_Abstraction -- -------------------------- overriding function Get_Base_Abstraction (Self : not null access constant Standard_Profile_L2_Trace_Proxy) return AMF.UML.Abstractions.UML_Abstraction_Access is begin return AMF.UML.Abstractions.UML_Abstraction_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Abstraction (Self.Element))); end Get_Base_Abstraction; -------------------------- -- Set_Base_Abstraction -- -------------------------- overriding procedure Set_Base_Abstraction (Self : not null access Standard_Profile_L2_Trace_Proxy; To : AMF.UML.Abstractions.UML_Abstraction_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Abstraction (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Abstraction; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Trace_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Enter_Trace (AMF.Standard_Profile_L2.Traces.Standard_Profile_L2_Trace_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Trace_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Leave_Trace (AMF.Standard_Profile_L2.Traces.Standard_Profile_L2_Trace_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Trace_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class (Iterator).Visit_Trace (Visitor, AMF.Standard_Profile_L2.Traces.Standard_Profile_L2_Trace_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Standard_Profile_L2_Traces;
persan/A-gst
Ada
5,239
ads
pragma Ada_2005; with glib.String; with System; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_garray_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gstring_h; private with Ada.Finalization; private with GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspmessage_h; package GStreamer.rtsp.message is --* -- * GstRTSPMsgType: -- * @INVALID: invalid message type -- * @REQUEST: RTSP request message -- * @RESPONSE: RTSP response message -- * @HTTP_REQUEST: HTTP request message. Since 0.10.25 -- * @HTTP_RESPONSE: HTTP response message. Since 0.10.25 -- * @DATA: data message -- * -- * The type of a message. -- type GstRTSPMsgType is (INVALID, REQUEST, RESPONSE, HTTP_REQUEST, HTTP_RESPONSE, DATA); pragma Convention (C, GstRTSPMsgType); -- gst/rtsp/gstrtspmessage.h:71 --* -- * GstRTSPMessage: -- * @type: the message type -- * -- * An RTSP message containing request, response or data messages. Depending on -- * the @type, the appropriate structure may be accessed. -- type GstRTSPMessage_Record (<>) is tagged private; type GstRTSPMessage is access all GstRTSPMessage_Record'Class; --< private > -- memory management function Get_Type (Msg : access GstRTSPMessage_Record) return GstRTSPMsgType; -- gst/rtsp/gstrtspmessage.h:115 -- request procedure new_request (msg : System.Address; method : GstRTSPMethod; uri : access GLIB.gchar); -- gst/rtsp/gstrtspmessage.h:118 procedure init_request (msg : access GstRTSPMessage; method : GstRTSPMethod; uri : access GLIB.gchar); -- gst/rtsp/gstrtspmessage.h:121 procedure parse_request (msg : access GstRTSPMessage; method : access GstRTSPMethod; uri : System.Address; version : access GstRTSPVersion); -- gst/rtsp/gstrtspmessage.h:124 -- response procedure new_response (msg : System.Address; code : GstRTSPStatusCode; reason : access GLIB.gchar; request : access constant GstRTSPMessage); -- gst/rtsp/gstrtspmessage.h:130 procedure init_response (msg : access GstRTSPMessage_Record; code : GstRTSPStatusCode; reason : access GLIB.gchar; request : access constant GstRTSPMessage); -- gst/rtsp/gstrtspmessage.h:134 procedure parse_response (msg : access GstRTSPMessage_Record; code : access GstRTSPStatusCode; reason : System.Address; version : access GstRTSPVersion); -- gst/rtsp/gstrtspmessage.h:138 -- data procedure new_data (msg : System.Address; channel : GLIB.guint8); -- gst/rtsp/gstrtspmessage.h:144 procedure init_data (msg : access GstRTSPMessage_Record; channel : GLIB.guint8); -- gst/rtsp/gstrtspmessage.h:146 procedure parse_data (msg : access GstRTSPMessage_Record; channel : access GLIB.guint8); -- gst/rtsp/gstrtspmessage.h:148 -- headers procedure add_header (msg : access GstRTSPMessage_Record; field : GstRTSPHeaderField; value : access GLIB.gchar); -- gst/rtsp/gstrtspmessage.h:152 procedure take_header (msg : access GstRTSPMessage_Record; field : GstRTSPHeaderField; value : access GLIB.gchar); -- gst/rtsp/gstrtspmessage.h:155 procedure remove_header (msg : access GstRTSPMessage_Record; field : GstRTSPHeaderField; indx : GLIB.gint); -- gst/rtsp/gstrtspmessage.h:158 procedure get_header (msg : access constant GstRTSPMessage_Record; field : GstRTSPHeaderField; value : System.Address; indx : GLIB.gint); -- gst/rtsp/gstrtspmessage.h:161 procedure append_headers (msg : access constant GstRTSPMessage; str : access Glib.String.GString); -- gst/rtsp/gstrtspmessage.h:165 -- handling the body procedure set_body (msg : access GstRTSPMessage_Record; data : access GLIB.guint8; size : GLIB.guint); -- gst/rtsp/gstrtspmessage.h:169 procedure take_body (msg : access GstRTSPMessage_Record; data : access GLIB.guint8; size : GLIB.guint); -- gst/rtsp/gstrtspmessage.h:172 procedure get_body (msg : access constant GstRTSPMessage_Record; data : System.Address; size : access GLIB.guint); -- gst/rtsp/gstrtspmessage.h:175 procedure steal_body (msg : access GstRTSPMessage_Record; data : System.Address; size : access GLIB.guint); -- gst/rtsp/gstrtspmessage.h:178 -- debug procedure dump (msg : access GstRTSPMessage_Record); -- gst/rtsp/gstrtspmessage.h:183 private type GstRTSPMessage_Record is new Ada.Finalization.Controlled with record Data : access GStreamer.GST_Low_Level.Gstreamer_0_10_Gst_Rtsp_Gstrtspmessage_H.GstRTSPMessage; end record; procedure gst_new (msg : in out GstRTSPMessage); -- gst/rtsp/gstrtspmessage.h:110 pragma Import (C, gst_new, "new"); procedure init (msg : access GstRTSPMessage_Record); -- gst/rtsp/gstrtspmessage.h:111 procedure unset (msg : access GstRTSPMessage_Record); -- gst/rtsp/gstrtspmessage.h:112 procedure free (msg : access GstRTSPMessage_Record); -- gst/rtsp/gstrtspmessage.h:113 end GStreamer.rtsp.message;
Rodeo-McCabe/orka
Ada
2,081
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Glfw.Input is pragma Preelaborate; type Button_State is (Released, Pressed); type Input_Toggle is (Sticky_Keys, Sticky_Mouse_Buttons, Raw_Mouse_Motion); procedure Poll_Events; -- Process events in the event queue -- -- Task safety: Must only be called from the environment task. procedure Wait_For_Events; -- Wait until at least one event is available and then process -- all events in the event queue -- -- Task safety: Must only be called from the environment task. procedure Wait_For_Events (Timeout : Seconds); -- Wait, for the specified duration, until at least one event is -- available and then process all events in the event queue -- -- Task safety: Must only be called from the environment task. procedure Post_Empty_Event; -- Post an empty event to wake up the task calling procedure -- Wait_For_Events -- -- Task safety: May be called from any task. private for Button_State use (Released => 0, Pressed => 1); for Button_State'Size use Interfaces.C.int'Size; for Input_Toggle use (Sticky_Keys => 16#33002#, Sticky_Mouse_Buttons => 16#33003#, Raw_Mouse_Motion => 16#33005#); for Input_Toggle'Size use Interfaces.C.int'Size; -- Just so we can implement them with rename pragma Convention (C, Post_Empty_Event); end Glfw.Input;
AdaCore/libadalang
Ada
1,437
adb
procedure Test is generic package Foo is X : Integer; --% node.p_fully_qualified_name generic package Bar is Y : Integer; --% node.p_fully_qualified_name package Baz is Z : Integer; --% node.p_fully_qualified_name end Baz; end Bar; package Foo_Bar_Inst is new Bar; generic procedure Lol (X : Integer); --% node.p_fully_qualified_name procedure Foo_Lol is new Lol; end Foo; package Test_Foo_Inst is new Foo; package Test_Bar_Inst is new Test_Foo_Inst.Bar; procedure Test_Lol is new Test_Foo_Inst.Lol; -- Testing instances S : Integer; begin S := Test_Foo_Inst.X; --% node.f_expr.p_referenced_decl().p_fully_qualified_name S := Test_Bar_Inst.Y; --% node.f_expr.p_referenced_decl().p_fully_qualified_name S := Test_Foo_Inst.Foo_Bar_Inst.Y; --% node.f_expr.p_referenced_decl().p_fully_qualified_name S := Test_Bar_Inst.Baz.Z; --% node.f_expr.p_referenced_decl().p_fully_qualified_name S := Test_Foo_Inst.Foo_Bar_Inst.Baz.Z; --% node.f_expr.p_referenced_decl().p_fully_qualified_name Test_Lol (X => 42); --% x = node.f_call.f_suffix[0].f_designator --% x.p_referenced_decl().p_fully_qualified_name Test_Foo_Inst.Foo_Lol (X => 42); --% x = node.f_call.f_suffix[0].f_designator --% x.p_referenced_decl().p_fully_qualified_name end Test;
onox/dcf-ada
Ada
1,257
ads
with Ada.Calendar; package DCF.Streams.Calendar is -- Set_Time again, but with the standard Ada Time type. -- Overriding is useless and potentially harmful, so we prevent it with -- a class-wide profile. procedure Set_Time (S : out Root_Zipstream_Type'Class; Modification_Time : Ada.Calendar.Time); -- Get_Time again, but with the standard Ada Time type. -- Overriding is useless and potentially harmful, so we prevent it with -- a class-wide profile. function Get_Time (S : in Root_Zipstream_Type'Class) return Ada.Calendar.Time; ---------------------------- -- Routines around Time -- ---------------------------- function Convert (Date : in Ada.Calendar.Time) return Time; function Convert (Date : in Time) return Ada.Calendar.Time; use Ada.Calendar; procedure Split (Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Seconds : out Day_Duration); function Time_Of (Year : Year_Number; Month : Month_Number; Day : Day_Number; Seconds : Day_Duration := 0.0) return Time; function ">" (Left, Right : Time) return Boolean; Time_Error : exception; end DCF.Streams.Calendar;
docandrew/troodon
Ada
640
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with bits_types_h; package bits_types_struct_timeval_h is -- A time value that is accurate to the nearest -- microsecond but also has a range of years. -- Seconds. type timeval is record tv_sec : aliased bits_types_h.uu_time_t; -- /usr/include/bits/types/struct_timeval.h:10 tv_usec : aliased bits_types_h.uu_suseconds_t; -- /usr/include/bits/types/struct_timeval.h:11 end record with Convention => C_Pass_By_Copy; -- /usr/include/bits/types/struct_timeval.h:8 -- Microseconds. end bits_types_struct_timeval_h;
google-code/ada-security
Ada
4,166
adb
----------------------------------------------------------------------- -- Security-permissions-tests - Unit tests for Security.Permissions -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; package body Security.Permissions.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Security.Permissions"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Security.Permissions.Add_Permission", Test_Add_Permission'Access); Caller.Add_Test (Suite, "Test Security.Permissions.Get_Permission_Index", Test_Add_Permission'Access); Caller.Add_Test (Suite, "Test Security.Permissions.Definition", Test_Define_Permission'Access); Caller.Add_Test (Suite, "Test Security.Permissions.Get_Permission_Index (invalid name)", Test_Get_Invalid_Permission'Access); end Add_Tests; -- ------------------------------ -- Test Add_Permission and Get_Permission_Index -- ------------------------------ procedure Test_Add_Permission (T : in out Test) is Index1, Index2 : Permission_Index; begin Add_Permission ("test-create-permission", Index1); T.Assert (Index1 = Get_Permission_Index ("test-create-permission"), "Get_Permission_Index failed"); Add_Permission ("test-create-permission", Index2); T.Assert (Index2 = Index1, "Add_Permission failed"); end Test_Add_Permission; -- ------------------------------ -- Test the permission created by the Definition package. -- ------------------------------ procedure Test_Define_Permission (T : in out Test) is Index : Permission_Index; begin Index := Get_Permission_Index ("admin"); T.Assert (P_Admin.Permission = Index, "Invalid permission for admin"); Index := Get_Permission_Index ("create"); T.Assert (P_Create.Permission = Index, "Invalid permission for create"); Index := Get_Permission_Index ("update"); T.Assert (P_Update.Permission = Index, "Invalid permission for update"); Index := Get_Permission_Index ("delete"); T.Assert (P_Delete.Permission = Index, "Invalid permission for delete"); T.Assert (P_Admin.Permission /= P_Create.Permission, "Admin or create permission invalid"); T.Assert (P_Admin.Permission /= P_Update.Permission, "Admin or update permission invalid"); T.Assert (P_Admin.Permission /= P_Delete.Permission, "Admin or delete permission invalid"); T.Assert (P_Create.Permission /= P_Update.Permission, "Create or update permission invalid"); T.Assert (P_Create.Permission /= P_Delete.Permission, "Create or delete permission invalid"); T.Assert (P_Update.Permission /= P_Delete.Permission, "Create or delete permission invalid"); end Test_Define_Permission; -- ------------------------------ -- Test Get_Permission on invalid permission name. -- ------------------------------ procedure Test_Get_Invalid_Permission (T : in out Test) is Index : Permission_Index; pragma Unreferenced (Index); begin Index := Get_Permission_Index ("invalid"); Util.Tests.Fail (T, "No exception raised by Get_Permission_Index for an invalid name"); exception when Invalid_Name => null; end Test_Get_Invalid_Permission; end Security.Permissions.Tests;
Rodeo-McCabe/orka
Ada
3,666
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <[email protected]> -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Types; private with GL.Low_Level; package GL.Viewports is pragma Preelaborate; use GL.Types; ----------------------------------------------------------------------------- -- Viewports -- ----------------------------------------------------------------------------- type Viewport is record X, Y, Width, Height : Single; end record; type Depth_Range is record Near, Far : Double; end record; type Scissor_Rectangle is record Left, Bottom : Int; Width, Height : Size; end record; type Viewport_List is array (UInt range <>) of Viewport with Convention => C; type Depth_Range_List is array (UInt range <>) of Depth_Range with Convention => C; type Scissor_Rectangle_List is array (UInt range <>) of Scissor_Rectangle with Convention => C; function Maximum_Viewports return Size with Post => Maximum_Viewports'Result >= 16; function Viewport_Subpixel_Bits return Size; function Origin_Range return Singles.Vector2; -- Return the minimum and maximum X and Y of the origin (lower left -- corner) of a viewport function Maximum_Extent return Singles.Vector2; -- Return the maximum width and height of a viewport procedure Set_Viewports (List : Viewport_List); function Get_Viewport (Index : UInt) return Viewport; procedure Set_Depth_Ranges (List : Depth_Range_List); function Get_Depth_Range (Index : UInt) return Depth_Range; procedure Set_Scissor_Rectangles (List : Scissor_Rectangle_List); function Get_Scissor_Rectangle (Index : UInt) return Scissor_Rectangle; ----------------------------------------------------------------------------- -- Clipping -- ----------------------------------------------------------------------------- type Viewport_Origin is (Lower_Left, Upper_Left); type Depth_Mode is (Negative_One_To_One, Zero_To_One); procedure Set_Clipping (Origin : Viewport_Origin; Depth : Depth_Mode); -- Set the origin of the viewport and the range of the clip planes -- -- Controls how clip space is mapped to window space. Both Direct3D and -- OpenGL expect a vertex position of (-1, -1) to map to the lower-left -- corner of the viewport. -- -- Direct3D expects the UV coordinate of (0, 0) to correspond to the -- upper-left corner of a randered image, while OpenGL expects it in -- the lower-left corner. function Origin return Viewport_Origin; function Depth return Depth_Mode; private for Viewport_Origin use (Lower_Left => 16#8CA1#, Upper_Left => 16#8CA2#); for Viewport_Origin'Size use Low_Level.Enum'Size; for Depth_Mode use (Negative_One_To_One => 16#935E#, Zero_To_One => 16#935F#); for Depth_Mode'Size use Low_Level.Enum'Size; end GL.Viewports;
zhmu/ananas
Ada
248
adb
-- { dg-do compile } -- { dg-options "-gnatws" } with Ada.Finalization; use Ada.Finalization; procedure finalized is type Rec is new Controlled with null record; Obj : access Rec := new Rec'(Controlled with null record); begin null; end;
davidkristola/vole
Ada
1,765
adb
with Ada.Strings.Unbounded; with Ada.Text_IO; package body kv.avm.Code_Buffers is function "+"(S : String) return String_Type renames Ada.Strings.Unbounded.To_Unbounded_String; function "+"(U : String_Type) return String renames Ada.Strings.Unbounded.To_String; procedure Put_Meta (Self : in out Buffer_Type; Data : in String) is begin Self.Count := Self.Count + 1; Self.Buffer(Self.Count) := +Data; end Put_Meta; procedure Put_Instruction (Self : in out Buffer_Type; Data : in String) is begin Self.Code := Self.Code + 1; Self.Count := Self.Count + 1; Self.Buffer(Self.Count) := +Data; end Put_Instruction; procedure Put_Comment (Self : in out Buffer_Type; Data : in String) is begin Self.Count := Self.Count + 1; Self.Buffer(Self.Count) := +Data; end Put_Comment; procedure Append (Self : in out Buffer_Type; Data : in Buffer_Type) is begin for I in 1 .. Data.Count loop Self.Count := Self.Count + 1; Self.Buffer(Self.Count) := Data.Buffer(I); end loop; Self.Code := Self.Code + Data.Code; end Append; function Code_Count(Self : Buffer_Type) return Natural is begin return Self.Code; end Code_Count; procedure Print (Self : in Buffer_Type) is begin for I in 1 .. Self.Count loop Ada.Text_IO.Put_Line(+Self.Buffer(I)); end loop; end Print; procedure Process_Lines (Self : in Buffer_Type; Processor : access procedure(Line : String)) is begin for I in 1 .. Self.Count loop Processor.all(+Self.Buffer(I)); end loop; end Process_Lines; end kv.avm.Code_Buffers;
zhmu/ananas
Ada
8,934
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S P R I N T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package (source print) contains routines for printing the source -- program corresponding to a specified syntax tree. These routines are -- intended for debugging use in the compiler (not as a user level pretty -- print tool). Only information present in the tree is output (e.g. no -- comments are present in the output), and as far as possible we avoid -- making any assumptions about the correctness of the tree, so a bad -- tree may either blow up on a debugging check, or list incorrect source. with Types; use Types; package Sprint is ----------------------- -- Syntax Extensions -- ----------------------- -- When the generated tree is printed, it contains constructs that are not -- pure Ada. For convenience, syntactic extensions to Ada have been defined -- purely for the purposes of this printout (they are not recognized by the -- parser). -- Could use more documentation for all of these ??? -- Allocator new xxx [storage_pool = xxx] -- Cleanup action at end procedure name; -- Convert wi Conversion_OK target?(source) -- Convert wi Float_Truncate target^(source) -- Convert wi Rounded_Result target@(source) -- Divide wi Rounded_Result x @/ y -- Expression with actions do action; .. action; in expr end -- Expression with range check {expression} -- Free statement free expr [storage_pool = xxx] -- Freeze entity with freeze actions freeze entityname [ actions ] -- Freeze generic entity freeze_generic entityname -- Implicit call to run time routine $routine-name -- Implicit exportation $pragma import (...) -- Implicit importation $pragma export (...) -- Interpretation interpretation type [, entity] -- Intrinsic calls function-name!(arg, arg, arg) -- Itype declaration [(sub)type declaration without ;] -- Itype reference reference itype -- Label declaration labelname : label -- Multiple concatenation expr && expr && expr ... && expr -- Multiply wi Rounded_Result x @* y -- Operator with overflow check {operator} (e.g. {+}) -- Others choice for cleanup when all others -- Pop exception label %pop_xxx_exception_label -- Push exception label %push_xxx_exception_label (label) -- Raise xxx error [xxx_error [when cond]] -- Raise xxx error with msg [xxx_error [when cond], "msg"] -- Rational literal [expression] -- Reference expression'reference -- Shift nodes shift_name!(expr, count) -- Static declaration name : static xxx -- Unchecked conversion target_type!(source_expression) -- Unchecked expression `(expression) -- Validate_Unchecked_Conversion validate unchecked_conversion -- (src-type, target-typ); -- Note: the storage_pool parameters for allocators and the free node are -- omitted if the Storage_Pool field is Empty, indicating use of the -- standard default pool. ----------------- -- Subprograms -- ----------------- procedure Source_Dump; -- This routine is called from the GNAT main program to dump source as -- requested by debug options. The relevant debug options are: -- -ds print source from tree, both original and generated code -- -dg print source from tree, including only the generated code -- -do print source from tree, including only the original code -- -df modify the above to include all units, not just the main unit -- -dz print source from tree for package Standard procedure Sprint_Comma_List (List : List_Id); -- Prints the nodes in a list, with separating commas. If the list is empty -- then no output is generated. procedure Sprint_Paren_Comma_List (List : List_Id); -- Prints the nodes in a list, surrounded by parentheses, and separated by -- commas. If the list is empty, then no output is generated. A blank is -- output before the initial left parenthesis. procedure Sprint_Opt_Paren_Comma_List (List : List_Id); -- Same as normal Sprint_Paren_Comma_List procedure, except that an extra -- blank is output if List is non-empty, and nothing at all is printed it -- the argument is No_List. procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False); -- Prints the nodes in a list with no separating characters. This is used -- in the case of lists of items which are printed on separate lines using -- the current indentation amount. New_Lines controls the generation of -- New_Line calls. If False, no New_Line calls are generated. If True, -- then New_Line calls are generated as needed to ensure that each list -- item starts at the beginning of a line. procedure Sprint_Opt_Node_List (List : List_Id); -- Like Sprint_Node_List, but prints nothing if List = No_List procedure Sprint_Indented_List (List : List_Id); -- Like Sprint_Line_List, except that the indentation level is increased -- before outputting the list of items, and then decremented (back to its -- original level) before returning to the caller. procedure Sprint_Node (Node : Node_Id); -- Prints a single node. No new lines are output, except as required for -- splitting lines that are too long to fit on a single physical line. -- No output is generated at all if Node is Empty. No trailing or leading -- blank characters are generated. procedure Sprint_Opt_Node (Node : Node_Id); -- Same as normal Sprint_Node procedure, except that one leading blank is -- output before the node if it is non-empty. procedure pg (Arg : Union_Id); pragma Export (Ada, pg); -- Print generated source for argument N (like -gnatdg output). Intended -- only for use from gdb for debugging purposes. Currently, Arg may be a -- List_Id or a Node_Id (anything else outputs a blank line). procedure po (Arg : Union_Id); pragma Export (Ada, po); -- Like pg, but prints original source for the argument (like -gnatdo -- output). Intended only for use from gdb for debugging purposes. In -- the list case, an end of line is output to separate list elements. procedure ps (Arg : Union_Id); pragma Export (Ada, ps); -- Like pg, but prints generated and original source for the argument (like -- -gnatds output). Intended only for use from gdb for debugging purposes. -- In the list case, an end of line is output to separate list elements. end Sprint;
reznikmm/matreshka
Ada
4,005
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Office_Mimetype_Attributes; package Matreshka.ODF_Office.Mimetype_Attributes is type Office_Mimetype_Attribute_Node is new Matreshka.ODF_Office.Abstract_Office_Attribute_Node and ODF.DOM.Office_Mimetype_Attributes.ODF_Office_Mimetype_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Office_Mimetype_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Office_Mimetype_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Office.Mimetype_Attributes;
AdaCore/libadalang
Ada
268
ads
package Lists is type List is tagged null record with Variable_Indexing => Get; type Ref_Type (E : access Integer) is null record with Implicit_Dereference => E; function Get (Self : List; I : Integer) return Ref_Type is (E => null); end Lists;
zhmu/ananas
Ada
4,993
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- I T Y P E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Einfo.Utils; use Einfo.Utils; with Sem; use Sem; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Stand; use Stand; with Targparm; use Targparm; package body Itypes is ------------------ -- Create_Itype -- ------------------ function Create_Itype (Ekind : Entity_Kind; Related_Nod : Node_Id; Related_Id : Entity_Id := Empty; Suffix : Character := ' '; Suffix_Index : Int := 0; Scope_Id : Entity_Id := Current_Scope) return Entity_Id is Typ : Entity_Id; begin -- Should comment setting of Public_Status here ??? if Related_Id = Empty then Typ := New_Internal_Entity (Ekind, Scope_Id, Sloc (Related_Nod), 'T'); Set_Public_Status (Typ); else Typ := New_External_Entity (Ekind, Scope_Id, Sloc (Related_Nod), Related_Id, Suffix, Suffix_Index, 'T'); end if; -- Make sure Esize (Typ) was properly initialized, it should be since -- New_Internal_Entity/New_External_Entity call Reinit_Size_Align. pragma Assert (not Known_Esize (Typ)); Set_Etype (Typ, Any_Type); Set_Is_Itype (Typ); Set_Associated_Node_For_Itype (Typ, Related_Nod); if In_Deleted_Code then Set_Is_Frozen (Typ); end if; if Ekind in Access_Subprogram_Kind then Set_Can_Use_Internal_Rep (Typ, not Always_Compatible_Rep_On_Target); end if; return Typ; end Create_Itype; --------------------------------- -- Create_Null_Excluding_Itype -- --------------------------------- function Create_Null_Excluding_Itype (T : Entity_Id; Related_Nod : Node_Id; Scope_Id : Entity_Id := Current_Scope) return Entity_Id is I_Typ : Entity_Id; begin pragma Assert (Is_Access_Type (T)); I_Typ := Create_Itype (Ekind => E_Access_Subtype, Related_Nod => Related_Nod, Scope_Id => Scope_Id); Set_Directly_Designated_Type (I_Typ, Directly_Designated_Type (T)); Set_Etype (I_Typ, Base_Type (T)); Set_Depends_On_Private (I_Typ, Depends_On_Private (T)); Set_Is_Public (I_Typ, Is_Public (T)); Set_From_Limited_With (I_Typ, From_Limited_With (T)); Set_Is_Access_Constant (I_Typ, Is_Access_Constant (T)); Set_Is_Generic_Type (I_Typ, Is_Generic_Type (T)); Set_Is_Volatile (I_Typ, Is_Volatile (T)); Set_Treat_As_Volatile (I_Typ, Treat_As_Volatile (T)); Set_Is_Atomic (I_Typ, Is_Atomic (T)); Set_Is_Ada_2005_Only (I_Typ, Is_Ada_2005_Only (T)); Set_Is_Ada_2012_Only (I_Typ, Is_Ada_2012_Only (T)); Set_Is_Ada_2022_Only (I_Typ, Is_Ada_2022_Only (T)); Set_Can_Never_Be_Null (I_Typ); return I_Typ; end Create_Null_Excluding_Itype; end Itypes;
Abhiroop/cpa-lang-shootout
Ada
2,573
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with Ada.Real_Time; use Ada.Real_Time; procedure CommsTime is -- Parameters for the experimental run. -- Experiments - number of data points collected -- Iterations_Experiment - number of cycles round commstime for a single data point Experiments : CONSTANT INTEGER := 100; Iterations_Experiment : CONSTANT INTEGER := 10000; task PREFIX is entry Send(Value : in INTEGER); end PREFIX; task SEQ_DELTA is entry Send(Value : in INTEGER); end SEQ_DELTA; task SUCC is entry Send(Value : in INTEGER); end SUCC; task PRINTER is entry Send(Value : in INTEGER); end PRINTER; task body PREFIX is N : INTEGER; begin for i in 0..Experiments loop SEQ_DELTA.Send(0); for j in 0..Iterations_Experiment loop accept Send(Value : in INTEGER) do N := Value; end; SEQ_DELTA.Send(N); end loop; -- Accept last value in accept Send(Value : in INTEGER); end loop; end PREFIX; task body SEQ_DELTA is N : INTEGER; begin for i in 0..Experiments loop for j in 0..Iterations_Experiment loop accept Send(Value : in INTEGER) do N := Value; end; PRINTER.Send(Value => N); SUCC.Send(Value => N); end loop; end loop; end SEQ_DELTA; task body SUCC is N : INTEGER; begin for i in 0..Experiments loop for j in 0..Iterations_Experiment loop accept Send(Value : in INTEGER) do N := Value; end; PREFIX.Send(N + 1); end loop; end loop; end SUCC; task body PRINTER is N : INTEGER; Start : Time; Total : Time_Span; Results : File_Type; begin Create(File => Results, Mode => Out_File, Name => "ct_ada.csv"); for i in 0..Experiments loop Start := Clock; for j in 0..Iterations_Experiment loop accept Send(Value : in INTEGER) do N := Value; end; end loop; -- Divide by iterations, then convert to nanos. -- Four communications. Total := (((Clock - Start) / Iterations_Experiment) * 1000000000) / 4; Put_Line(results, Float'Image(Float(To_Duration(Total)))); Put("."); end loop; Close(Results); end PRINTER; begin Put_Line("Communication Time Benchmark"); end CommsTime;
reznikmm/matreshka
Ada
3,527
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This is root package of Ada Web Framework and Components. ------------------------------------------------------------------------------ package AWFC is pragma Pure; end AWFC;
reznikmm/matreshka
Ada
3,993
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Transform_Attributes; package Matreshka.ODF_Draw.Transform_Attributes is type Draw_Transform_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Transform_Attributes.ODF_Draw_Transform_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Transform_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Transform_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Transform_Attributes;
AdaCore/gpr
Ada
37
adb
package body JVM_Ada is end JVM_Ada;
charlie5/cBound
Ada
1,907
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_convolution_parameteriv_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; pad1 : aliased swig.int8_t_Array (0 .. 3); n : aliased Interfaces.Unsigned_32; datum : aliased Interfaces.Integer_32; pad2 : aliased swig.int8_t_Array (0 .. 11); end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_convolution_parameteriv_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_convolution_parameteriv_reply_t.Item, Element_Array => xcb.xcb_glx_get_convolution_parameteriv_reply_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_convolution_parameteriv_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_convolution_parameteriv_reply_t.Pointer, Element_Array => xcb.xcb_glx_get_convolution_parameteriv_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_convolution_parameteriv_reply_t;
reznikmm/matreshka
Ada
3,624
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.OCL.Null_Literal_Exps.Hash is new AMF.Elements.Generic_Hash (OCL_Null_Literal_Exp, OCL_Null_Literal_Exp_Access);
reznikmm/matreshka
Ada
4,567
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Color_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Color_Attribute_Node is begin return Self : Draw_Color_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Color_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Color_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Color_Attribute, Draw_Color_Attribute_Node'Tag); end Matreshka.ODF_Draw.Color_Attributes;
AdaCore/gpr
Ada
7,272
adb
-- -- Copyright (C) 2019-2023, AdaCore -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- package body Gpr_Parser.Public_Converters is type File_Reader_Wrapper_Access is access all File_Reader_Wrapper; type Unit_Provider_Wrapper_Access is access all Unit_Provider_Wrapper; ------------- -- Inc_Ref -- ------------- overriding procedure Inc_Ref (Self : in out File_Reader_Wrapper) is begin Self.Ref_Count := Self.Ref_Count + 1; end Inc_Ref; ------------- -- Dec_Ref -- ------------- overriding function Dec_Ref (Self : in out File_Reader_Wrapper) return Boolean is begin Self.Ref_Count := Self.Ref_Count - 1; if Self.Ref_Count = 0 then return True; else return False; end if; end Dec_Ref; ---------- -- Read -- ---------- overriding procedure Read (Self : File_Reader_Wrapper; Filename : String; Charset : String; Read_BOM : Boolean; Contents : out Decoded_File_Contents; Diagnostics : in out Diagnostics_Vectors.Vector) is begin Self.Internal.Get.Read (Filename, Charset, Read_BOM, Contents, Diagnostics); end Read; ----------------------------- -- Wrap_Public_File_Reader -- ----------------------------- function Wrap_Public_File_Reader (File_Reader : File_Reader_Reference) return Internal_File_Reader_Access is use type File_Reader_Reference; begin if File_Reader = No_File_Reader_Reference then return null; end if; declare Result : constant File_Reader_Wrapper_Access := new File_Reader_Wrapper'(Ref_Count => 1, Internal => File_Reader); begin return Internal_File_Reader_Access (Result); end; end Wrap_Public_File_Reader; ------------- -- Inc_Ref -- ------------- overriding procedure Inc_Ref (Provider : in out Unit_Provider_Wrapper) is begin Provider.Ref_Count := Provider.Ref_Count + 1; end Inc_Ref; ------------- -- Dec_Ref -- ------------- overriding function Dec_Ref (Provider : in out Unit_Provider_Wrapper) return Boolean is begin Provider.Ref_Count := Provider.Ref_Count - 1; if Provider.Ref_Count = 0 then return True; else return False; end if; end Dec_Ref; ----------------------- -- Get_Unit_Location -- ----------------------- overriding procedure Get_Unit_Location (Provider : Unit_Provider_Wrapper; Name : Text_Type; Kind : Analysis_Unit_Kind; Filename : out Unbounded_String; PLE_Root_Index : out Positive) is -- If Get_Unit_Location is not implemented (Index left to 0), fallback -- to the Get_Unit_Filename primitive. Index : Natural := 0; begin Provider.Internal.Get.Get_Unit_Location (Name, Kind, Filename, Index); if Index = 0 then Filename := To_Unbounded_String (Provider.Internal.Get.Get_Unit_Filename (Name, Kind)); PLE_Root_Index := 1; else PLE_Root_Index := Index; end if; end Get_Unit_Location; --------------------------- -- Get_Unit_And_PLE_Root -- --------------------------- overriding procedure Get_Unit_And_PLE_Root (Provider : Unit_Provider_Wrapper; Context : Internal_Context; Name : Text_Type; Kind : Analysis_Unit_Kind; Charset : String := ""; Reparse : Boolean := False; Unit : out Internal_Unit; PLE_Root_Index : out Positive) is -- If Get_Unit_And_PLE_Root is not implemented (Index left to 0), -- fallback to the Get_Unit primitive. Ctx : constant Analysis_Context := Wrap_Context (Context); U : Analysis_Unit := Analysis.No_Analysis_Unit; Index : Natural := 0; begin Provider.Internal.Get.Get_Unit_And_PLE_Root (Ctx, Name, Kind, Charset, Reparse, U, Index); if Index = 0 then U := Analysis_Unit (Provider.Internal.Get.Get_Unit (Ctx, Name, Kind, Charset, Reparse)); PLE_Root_Index := 1; else PLE_Root_Index := Index; end if; Unit := Unwrap_Unit (U); end Get_Unit_And_PLE_Root; ----------------------------- -- Unit_Requested_Callback -- ----------------------------- overriding procedure Unit_Requested_Callback (Self : in out Event_Handler_Wrapper; Context : Internal_Context; Name : Text_Type; From : Internal_Unit; Found : Boolean; Is_Not_Found_Error : Boolean) is Ctx : constant Analysis_Context := Wrap_Context (Context); Frm : constant Analysis_Unit := Wrap_Unit (From); begin Self.Internal.Get.Unit_Requested_Callback (Ctx, Name, Frm, Found, Is_Not_Found_Error); end Unit_Requested_Callback; -------------------------- -- Unit_Parsed_Callback -- -------------------------- overriding procedure Unit_Parsed_Callback (Self : in out Event_Handler_Wrapper; Context : Internal_Context; Unit : Internal_Unit; Reparsed : Boolean) is Ctx : constant Analysis_Context := Wrap_Context (Context); Unt : constant Analysis_Unit := Wrap_Unit (Unit); begin Self.Internal.Get.Unit_Parsed_Callback (Ctx, Unt, Reparsed); end Unit_Parsed_Callback; -------------------------- -- Wrap_Public_Provider -- -------------------------- function Wrap_Public_Provider (Provider : Unit_Provider_Reference) return Internal_Unit_Provider_Access is use type Unit_Provider_Reference; begin if Provider = No_Unit_Provider_Reference then return null; end if; declare Result : constant Unit_Provider_Wrapper_Access := new Unit_Provider_Wrapper'(Ref_Count => 1, Internal => Provider); begin return Internal_Unit_Provider_Access (Result); end; end Wrap_Public_Provider; ------------------------------- -- Wrap_Public_Event_Handler -- ------------------------------- function Wrap_Public_Event_Handler (Self : Event_Handler_Reference) return Internal_Event_Handler_Access is use type Event_Handler_Reference; begin if Self = No_Event_Handler_Ref then return null; end if; declare Result : constant Internal_Event_Handler_Access := new Event_Handler_Wrapper'(Ref_Count => 1, Internal => Self); begin return Result; end; end Wrap_Public_Event_Handler; ------------- -- Inc_Ref -- ------------- overriding procedure Inc_Ref (Self : in out Event_Handler_Wrapper) is begin Self.Ref_Count := Self.Ref_Count + 1; end Inc_Ref; ------------- -- Dec_Ref -- ------------- overriding function Dec_Ref (Self : in out Event_Handler_Wrapper) return Boolean is begin Self.Ref_Count := Self.Ref_Count - 1; if Self.Ref_Count = 0 then return True; else return False; end if; end Dec_Ref; end Gpr_Parser.Public_Converters;
charlie5/cBound
Ada
1,421
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_query_version_cookie_t is -- Item -- type Item is record sequence : aliased Interfaces.C.unsigned; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_query_version_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_query_version_cookie_t.Item, Element_Array => xcb.xcb_render_query_version_cookie_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_query_version_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_query_version_cookie_t.Pointer, Element_Array => xcb.xcb_render_query_version_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_query_version_cookie_t;
onox/orka
Ada
867
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Futures is procedure Internal_Release (Value : in out Future_Access) is begin Releasable_Future'Class (Value.all).Release (Value); end Internal_Release; end Orka.Futures;
arangodb/arangodb
Ada
20,847
adb
----------------------------------------------------------------------- -- stemmer -- Multi-language stemmer with Snowball generator -- Written by Stephane Carrez ([email protected]) -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- -- 1. Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- 3. Neither the name of the Snowball project nor the names of its contributors -- may be used to endorse or promote products derived from this software -- without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------- with Interfaces; package body Stemmer with SPARK_Mode is subtype Byte is Interfaces.Unsigned_8; use type Interfaces.Unsigned_8; procedure Stem_Word (Context : in out Context_Type'Class; Word : in String; Result : out Boolean) is begin Context.P (1 .. Word'Length) := Word; Context.C := 0; Context.L := Word'Length; Context.Lb := 0; Stemmer.Stem (Context, Result); end Stem_Word; function Get_Result (Context : in Context_Type'Class) return String is begin return Context.P (1 .. Context.L); end Get_Result; function Eq_S (Context : in Context_Type'Class; S : in String) return Char_Index is begin if Context.L - Context.C < S'Length then return 0; end if; if Context.P (Context.C + 1 .. Context.C + S'Length) /= S then return 0; end if; return S'Length; end Eq_S; function Eq_S_Backward (Context : in Context_Type'Class; S : in String) return Char_Index is begin if Context.C - Context.Lb < S'Length then return 0; end if; if Context.P (Context.C + 1 - S'Length .. Context.C) /= S then return 0; end if; return S'Length; end Eq_S_Backward; function Length (Context : in Context_Type'Class) return Natural is begin return Context.L - Context.Lb; end Length; function Length_Utf8 (Context : in Context_Type'Class) return Natural is Count : Natural := 0; Pos : Positive := 1; Val : Byte; begin while Pos <= Context.L loop Val := Character'Pos (Context.P (Pos)); Pos := Pos + 1; if Val >= 16#C0# or Val < 16#80# then Count := Count + 1; end if; end loop; return Count; end Length_Utf8; function Check_Among (Context : in Context_Type'Class; Pos : in Char_Index; Shift : in Natural; Mask : in Mask_Type) return Boolean is use Interfaces; Val : constant Byte := Character'Pos (Context.P (Pos + 1)); begin if Natural (Shift_Right (Val, 5)) /= Shift then return True; end if; return (Shift_Right (Unsigned_64 (Mask), Natural (Val and 16#1f#)) and 1) = 0; end Check_Among; procedure Find_Among (Context : in out Context_Type'Class; Amongs : in Among_Array_Type; Pattern : in String; Execute : access procedure (Ctx : in out Context_Type'Class; Operation : in Operation_Index; Status : out Boolean); Result : out Integer) is I : Natural := Amongs'First; J : Natural := Amongs'Last + 1; Common_I : Natural := 0; Common_J : Natural := 0; First_Key_Inspected : Boolean := False; C : constant Natural := Context.C; L : constant Integer := Context.L; begin loop declare K : constant Natural := I + (J - I) / 2; W : constant Among_Type := Amongs (K); Common : Natural := (if Common_I < Common_J then Common_I else Common_J); Diff : Integer := 0; begin for I2 in W.First + Common .. W.Last loop if C + Common = L then Diff := -1; exit; end if; Diff := Character'Pos (Context.P (C + Common + 1)) - Character'Pos (Pattern (I2)); exit when Diff /= 0; Common := Common + 1; end loop; if Diff < 0 then J := K; Common_J := Common; else I := K; Common_I := Common; end if; end; if J - I <= 1 then exit when I > 0 or J = I or First_Key_Inspected; First_Key_Inspected := True; end if; end loop; loop declare W : constant Among_Type := Amongs (I); Len : constant Natural := W.Last - W.First + 1; Status : Boolean; begin if Common_I >= Len then Context.C := C + Len; if W.Operation = 0 then Result := W.Result; return; end if; Execute (Context, W.Operation, Status); Context.C := C + Len; if Status then Result := W.Result; return; end if; end if; exit when W.Substring_I < 0; I := W.Substring_I; end; end loop; Result := 0; end Find_Among; procedure Find_Among_Backward (Context : in out Context_Type'Class; Amongs : in Among_Array_Type; Pattern : in String; Execute : access procedure (Ctx : in out Context_Type'Class; Operation : in Operation_Index; Status : out Boolean); Result : out Integer) is I : Natural := Amongs'First; J : Natural := Amongs'Last + 1; Common_I : Natural := 0; Common_J : Natural := 0; First_Key_Inspected : Boolean := False; C : constant Integer := Context.C; Lb : constant Integer := Context.Lb; begin loop declare K : constant Natural := I + (J - I) / 2; W : constant Among_Type := Amongs (K); Common : Natural := (if Common_I < Common_J then Common_I else Common_J); Diff : Integer := 0; begin for I2 in reverse W.First .. W.Last - Common loop if C - Common = Lb then Diff := -1; exit; end if; Diff := Character'Pos (Context.P (C - Common)) - Character'Pos (Pattern (I2)); exit when Diff /= 0; Common := Common + 1; end loop; if Diff < 0 then J := K; Common_J := Common; else I := K; Common_I := Common; end if; end; if J - I <= 1 then exit when I > 0 or J = I or First_Key_Inspected; First_Key_Inspected := True; end if; end loop; loop declare W : constant Among_Type := Amongs (I); Len : constant Natural := W.Last - W.First + 1; Status : Boolean; begin if Common_I >= Len then Context.C := C - Len; if W.Operation = 0 then Result := W.Result; return; end if; Execute (Context, W.Operation, Status); Context.C := C - Len; if Status then Result := W.Result; return; end if; end if; exit when W.Substring_I < 0; I := W.Substring_I; end; end loop; Result := 0; end Find_Among_Backward; function Skip_Utf8 (Context : in Context_Type'Class) return Result_Index is Pos : Char_Index := Context.C; Val : Byte; begin if Pos >= Context.L then return -1; end if; Pos := Pos + 1; Val := Character'Pos (Context.P (Pos)); if Val >= 16#C0# then while Pos < Context.L loop Val := Character'Pos (Context.P (Pos + 1)); exit when Val >= 16#C0# or Val < 16#80#; Pos := Pos + 1; end loop; end if; return Pos; end Skip_Utf8; function Skip_Utf8 (Context : in Context_Type'Class; N : in Integer) return Result_Index is Pos : Char_Index := Context.C; Val : Byte; begin if N < 0 then return -1; end if; for I in 1 .. N loop if Pos >= Context.L then return -1; end if; Pos := Pos + 1; Val := Character'Pos (Context.P (Pos)); if Val >= 16#C0# then while Pos < Context.L loop Val := Character'Pos (Context.P (Pos + 1)); exit when Val >= 16#C0# or Val < 16#80#; Pos := Pos + 1; end loop; end if; end loop; return Pos; end Skip_Utf8; function Skip_Utf8_Backward (Context : in Context_Type'Class) return Result_Index is Pos : Char_Index := Context.C; Val : Byte; begin if Pos <= Context.Lb then return -1; end if; Val := Character'Pos (Context.P (Pos)); Pos := Pos - 1; if Val >= 16#80# then while Pos > Context.Lb loop Val := Character'Pos (Context.P (Pos + 1)); exit when Val >= 16#C0#; Pos := Pos - 1; end loop; end if; return Pos; end Skip_Utf8_Backward; function Skip_Utf8_Backward (Context : in Context_Type'Class; N : in Integer) return Result_Index is Pos : Char_Index := Context.C; Val : Byte; begin if N < 0 then return -1; end if; for I in 1 .. N loop if Pos <= Context.Lb then return -1; end if; Val := Character'Pos (Context.P (Pos)); Pos := Pos - 1; if Val >= 16#80# then while Pos > Context.Lb loop Val := Character'Pos (Context.P (Pos + 1)); exit when Val >= 16#C0#; Pos := Pos - 1; end loop; end if; end loop; return Pos; end Skip_Utf8_Backward; function Shift_Left (Value : in Utf8_Type; Shift : in Natural) return Utf8_Type is (Utf8_Type (Interfaces.Shift_Left (Interfaces.Unsigned_32 (Value), Shift))); procedure Get_Utf8 (Context : in Context_Type'Class; Value : out Utf8_Type; Count : out Natural) is B0, B1, B2, B3 : Byte; begin if Context.C >= Context.L then Value := 0; Count := 0; return; end if; B0 := Character'Pos (Context.P (Context.C + 1)); if B0 < 16#C0# or Context.C + 1 >= Context.L then Value := Utf8_Type (B0); Count := 1; return; end if; B1 := Character'Pos (Context.P (Context.C + 2)) and 16#3F#; if B0 < 16#E0# or Context.C + 2 >= Context.L then Value := Shift_Left (Utf8_Type (B0 and 16#1F#), 6) or Utf8_Type (B1); Count := 2; return; end if; B2 := Character'Pos (Context.P (Context.C + 3)) and 16#3F#; if B0 < 16#F0# or Context.C + 3 >= Context.L then Value := Shift_Left (Utf8_Type (B0 and 16#0F#), 12) or Shift_Left (Utf8_Type (B1), 6) or Utf8_Type (B2); Count := 3; return; end if; B3 := Character'Pos (Context.P (Context.C + 4)) and 16#3F#; Value := Shift_Left (Utf8_Type (B0 and 16#07#), 18) or Shift_Left (Utf8_Type (B1), 12) or Shift_Left (Utf8_Type (B2), 6) or Utf8_Type (B3); Count := 4; end Get_Utf8; procedure Get_Utf8_Backward (Context : in Context_Type'Class; Value : out Utf8_Type; Count : out Natural) is B0, B1, B2, B3 : Byte; begin if Context.C <= Context.Lb then Value := 0; Count := 0; return; end if; B3 := Character'Pos (Context.P (Context.C)); if B3 < 16#80# or Context.C - 1 <= Context.Lb then Value := Utf8_Type (B3); Count := 1; return; end if; B2 := Character'Pos (Context.P (Context.C - 1)); if B2 >= 16#C0# or Context.C - 2 <= Context.Lb then B3 := B3 and 16#3F#; Value := Shift_Left (Utf8_Type (B2 and 16#1F#), 6) or Utf8_Type (B3); Count := 2; return; end if; B1 := Character'Pos (Context.P (Context.C - 2)); if B1 >= 16#E0# or Context.C - 3 <= Context.Lb then B3 := B3 and 16#3F#; B2 := B2 and 16#3F#; Value := Shift_Left (Utf8_Type (B1 and 16#0F#), 12) or Shift_Left (Utf8_Type (B2), 6) or Utf8_Type (B3); Count := 3; return; end if; B0 := Character'Pos (Context.P (Context.C - 3)); B1 := B1 and 16#1F#; B2 := B2 and 16#3F#; B3 := B3 and 16#3F#; Value := Shift_Left (Utf8_Type (B0 and 16#07#), 18) or Shift_Left (Utf8_Type (B1), 12) or Shift_Left (Utf8_Type (B2), 6) or Utf8_Type (B3); Count := 4; end Get_Utf8_Backward; procedure Out_Grouping (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index) is Ch : Utf8_Type; Count : Natural; begin if Context.C >= Context.L then Result := -1; return; end if; loop Get_Utf8 (Context, Ch, Count); if Count = 0 then Result := -1; return; end if; if Ch <= Max and Ch >= Min then Ch := Ch - Min; if S (Ch) then Result := Count; return; end if; end if; Context.C := Context.C + Count; exit when not Repeat; end loop; Result := 0; end Out_Grouping; procedure Out_Grouping_Backward (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index) is Ch : Utf8_Type; Count : Natural; begin if Context.C = 0 then Result := -1; return; end if; loop Get_Utf8_Backward (Context, Ch, Count); if Count = 0 then Result := -1; return; end if; if Ch <= Max and Ch >= Min then Ch := Ch - Min; if S (Ch) then Result := Count; return; end if; end if; Context.C := Context.C - Count; exit when not Repeat; end loop; Result := 0; end Out_Grouping_Backward; procedure In_Grouping (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index) is Ch : Utf8_Type; Count : Natural; begin if Context.C >= Context.L then Result := -1; return; end if; loop Get_Utf8 (Context, Ch, Count); if Count = 0 then Result := -1; return; end if; if Ch > Max or Ch < Min then Result := Count; return; end if; Ch := Ch - Min; if not S (Ch) then Result := Count; return; end if; Context.C := Context.C + Count; exit when not Repeat; end loop; Result := 0; end In_Grouping; procedure In_Grouping_Backward (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index) is Ch : Utf8_Type; Count : Natural; begin if Context.C = 0 then Result := -1; return; end if; loop Get_Utf8_Backward (Context, Ch, Count); if Count = 0 then Result := -1; return; end if; if Ch > Max or Ch < Min then Result := Count; return; end if; Ch := Ch - Min; if not S (Ch) then Result := Count; return; end if; Context.C := Context.C - Count; exit when not Repeat; end loop; Result := 0; end In_Grouping_Backward; procedure Replace (Context : in out Context_Type'Class; C_Bra : in Char_Index; C_Ket : in Char_Index; S : in String; Adjustment : out Integer) is begin Adjustment := S'Length - (C_Ket - C_Bra); if Adjustment > 0 then Context.P (C_Bra + S'Length + 1 .. Context.Lb + Adjustment + 1) := Context.P (C_Ket + 1 .. Context.Lb + 1); end if; if S'Length > 0 then Context.P (C_Bra + 1 .. C_Bra + S'Length) := S; end if; if Adjustment < 0 then Context.P (C_Bra + S'Length + 1 .. Context.L + Adjustment + 1) := Context.P (C_Ket + 1 .. Context.L + 1); end if; Context.L := Context.L + Adjustment; if Context.C >= C_Ket then Context.C := Context.C + Adjustment; elsif Context.C > C_Bra then Context.C := C_Bra; end if; end Replace; procedure Slice_Del (Context : in out Context_Type'Class) is Result : Integer; begin Replace (Context, Context.Bra, Context.Ket, "", Result); end Slice_Del; procedure Slice_From (Context : in out Context_Type'Class; Text : in String) is Result : Integer; begin Replace (Context, Context.Bra, Context.Ket, Text, Result); end Slice_From; function Slice_To (Context : in Context_Type'Class) return String is begin return Context.P (Context.Bra + 1 .. Context.Ket); end Slice_To; procedure Insert (Context : in out Context_Type'Class; C_Bra : in Char_Index; C_Ket : in Char_Index; S : in String) is Result : Integer; begin Replace (Context, C_Bra, C_Ket, S, Result); if C_Bra <= Context.Bra then Context.Bra := Context.Bra + Result; end if; if C_Bra <= Context.Ket then Context.Ket := Context.Ket + Result; end if; end Insert; end Stemmer;
burratoo/Acton
Ada
4,785
ads
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.STORAGE.PRIORITY_QUEUE -- -- -- -- Copyright (C) 2013-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ generic type Item_Type is private; pragma Preelaborable_Initialization (Item_Type); type Index_Type is mod <>; -- Index_Type is mod so it can pack the most elements in the smallest -- base type. No_Item : Item_Type; with function ">" (Left, Right : Item_Type) return Boolean is <>; with function ">=" (Left, Right : Item_Type) return Boolean is <>; package Oak.Storage.Priority_Queue with Pure is Queue_Capacity_Error : exception; type Queue_Type is private with Preelaborable_Initialization; procedure Enqueue_Item (To_Queue : in out Queue_Type; Item : in Item_Type; Add_To_Head : in Boolean := False); -- Adds an item to the priority queue function Head_Of_Queue (From_Queue : in out Queue_Type) return Item_Type; procedure Remove_Queue_Head (From_Queue : in out Queue_Type; Item : out Item_Type); -- Removes the first item from the priority queue. Returns an empty element -- if the queue is empty. function Is_Queue_Full (Queue : in Queue_Type) return Boolean; private No_Node_Value : constant := 0; First_Node_Value : constant := No_Node_Value + 1; -- The constant that represents the No_Node. Needed to satisfy the -- preelaborable initialization constraints on the types below. ??? Should -- check to see if there is a bug in the compiler preventing the direct use -- of No_Node. No_Node : constant Index_Type := No_Node_Value; -- The Index_Type that represents the null node, or that no node exists -- at all. type Node_Colour is (Red, Black); -- Colour of a node in the red-black tree. type Node_Type is record -- This type represents a Node in the tree. Each node has a link to its -- parent to allow a bottom-up transversal of the tree without using -- recursion. Its presence does not impact of the effective size of the -- node if the Index_Type and priority types' base type is a byte. On a -- 32 bit aligned system should be able to pack the infrustructure -- components into just two registers, or two 32 bit words in memory, with -- two bytes free. Colour : Node_Colour := Black; Parent : Index_Type := No_Node_Value; Left, Right : Index_Type := No_Node_Value; Item : Item_Type; end record; type Node_Array is array (Index_Type) of Node_Type; type Queue_Type is record -- This type represents the set which is actually a red-black tree. Root : Index_Type := No_Node_Value; -- The node pointing to the root of the tree. Free_List : Index_Type := No_Node_Value; -- The first node in the free list. This list consists of free nodes -- that are not part of the bulk free store of the array, since they -- have been allocated and subsquently deallocated. -- -- No_Node means the list is empty. Bulk_Free : Index_Type := First_Node_Value; -- The first node in the bulk free store. This is the free area on the -- right side of the array that has not been allocate. The bulk store -- saves from having to populate the free list in the first place, which -- may be an expensive operation (it is an O (n) operation). -- -- No_Node means bulk free store is empty. First_Node : Index_Type := No_Node_Value; First_Node_Valid : Boolean := False; -- Caches the first node in the priority queue. Nodes : Node_Array; -- The node pool. The first node is the No_Node which needs to be -- initialised here. end record; -------------------------- -- Function Expressions -- -------------------------- function Is_Queue_Full (Queue : in Queue_Type) return Boolean is (Queue.Free_List = No_Node and Queue.Bulk_Free = No_Node); end Oak.Storage.Priority_Queue;
zhmu/ananas
Ada
3,531
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . C O N C A T _ 6 -- -- -- -- B o d y -- -- -- -- Copyright (C) 2008-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Concat_5; package body System.Concat_6 is pragma Suppress (All_Checks); ------------------ -- Str_Concat_6 -- ------------------ procedure Str_Concat_6 (R : out String; S1, S2, S3, S4, S5, S6 : String) is F, L : Natural; begin F := R'First; L := F + S1'Length - 1; R (F .. L) := S1; F := L + 1; L := F + S2'Length - 1; R (F .. L) := S2; F := L + 1; L := F + S3'Length - 1; R (F .. L) := S3; F := L + 1; L := F + S4'Length - 1; R (F .. L) := S4; F := L + 1; L := F + S5'Length - 1; R (F .. L) := S5; F := L + 1; L := R'Last; R (F .. L) := S6; end Str_Concat_6; ------------------------- -- Str_Concat_Bounds_6 -- ------------------------- procedure Str_Concat_Bounds_6 (Lo, Hi : out Natural; S1, S2, S3, S4, S5, S6 : String) is begin System.Concat_5.Str_Concat_Bounds_5 (Lo, Hi, S2, S3, S4, S5, S6); if S1 /= "" then Hi := S1'Last + Hi - Lo + 1; Lo := S1'First; end if; end Str_Concat_Bounds_6; end System.Concat_6;
stcarrez/ada-util
Ada
13,034
ads
----------------------------------------------------------------------- -- util-encoders-base64 -- Encode/Decode a stream in Base64 -- Copyright (C) 2009, 2010, 2011, 2012, 2016, 2017, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; with Interfaces; -- The <b>Util.Encodes.Base64</b> packages encodes and decodes streams -- in Base64 (See rfc4648: The Base16, Base32, and Base64 Data Encodings). package Util.Encoders.Base64 is pragma Preelaborate; -- Encode the 64-bit value to LEB128 and then base64url. function Encode (Value : in Interfaces.Unsigned_64) return String; -- Decode the base64url string and then the LEB128 integer. -- Raise the Encoding_Error if the string is invalid and cannot be decoded. function Decode (Value : in String) return Interfaces.Unsigned_64; -- ------------------------------ -- Base64 encoder -- ------------------------------ -- This <b>Encoder</b> translates the (binary) input stream into -- a Base64 ascii stream. type Encoder is new Util.Encoders.Transformer with private; -- Encodes the binary input stream represented by <b>Data</b> into -- the a base64 output stream <b>Into</b>. -- -- If the transformer does not have enough room to write the result, -- it must return in <b>Encoded</b> the index of the last encoded -- position in the <b>Data</b> stream. -- -- The transformer returns in <b>Last</b> the last valid position -- in the output stream <b>Into</b>. -- -- The <b>Encoding_Error</b> exception is raised if the input -- stream cannot be transformed. overriding procedure Transform (E : in out Encoder; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Encoded : out Ada.Streams.Stream_Element_Offset); -- Finish encoding the input array. overriding procedure Finish (E : in out Encoder; Into : in out Ada.Streams.Stream_Element_Array; Last : in out Ada.Streams.Stream_Element_Offset); -- Set the encoder to use the base64 URL alphabet when <b>Mode</b> is True. -- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters. procedure Set_URL_Mode (E : in out Encoder; Mode : in Boolean); -- Create a base64 encoder using the URL alphabet. -- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters. function Create_URL_Encoder return Transformer_Access; -- ------------------------------ -- Base64 decoder -- ------------------------------ -- The <b>Decoder</b> decodes a Base64 ascii stream into a binary stream. type Decoder is new Util.Encoders.Transformer with private; -- Decodes the base64 input stream represented by <b>Data</b> into -- the binary output stream <b>Into</b>. -- -- If the transformer does not have enough room to write the result, -- it must return in <b>Encoded</b> the index of the last encoded -- position in the <b>Data</b> stream. -- -- The transformer returns in <b>Last</b> the last valid position -- in the output stream <b>Into</b>. -- -- The <b>Encoding_Error</b> exception is raised if the input -- stream cannot be transformed. overriding procedure Transform (E : in out Decoder; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Encoded : out Ada.Streams.Stream_Element_Offset); -- Set the decoder to use the base64 URL alphabet when <b>Mode</b> is True. -- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters. procedure Set_URL_Mode (E : in out Decoder; Mode : in Boolean); -- Set the ignore ligne break mode when reading the input stream. procedure Set_Ignore_Line_Break (E : in out Decoder; Ignore : in Boolean); -- Create a base64 decoder using the URL alphabet. -- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters. function Create_URL_Decoder return Transformer_Access; private type Alphabet is array (Interfaces.Unsigned_8 range 0 .. 63) of Ada.Streams.Stream_Element; type Alphabet_Access is not null access constant Alphabet; BASE64_ALPHABET : aliased constant Alphabet := (Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'), Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'), Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'), Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'), Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'), Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'), Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'), Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'), Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'), Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'), Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'), Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'), Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'), Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'), Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'), Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('+'), Character'Pos ('/')); BASE64_URL_ALPHABET : aliased constant Alphabet := (Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'), Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'), Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'), Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'), Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'), Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'), Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'), Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'), Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'), Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'), Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'), Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'), Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'), Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'), Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'), Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('-'), Character'Pos ('_')); type Encoder is new Util.Encoders.Transformer with record Alphabet : Alphabet_Access := BASE64_ALPHABET'Access; Column : Natural := 0; Count : Natural := 0; Value : Interfaces.Unsigned_8; end record; type Alphabet_Values is array (Ada.Streams.Stream_Element) of Interfaces.Unsigned_8; type Alphabet_Values_Access is not null access constant Alphabet_Values; BASE64_VALUES : aliased constant Alphabet_Values := (Character'Pos ('A') => 0, Character'Pos ('B') => 1, Character'Pos ('C') => 2, Character'Pos ('D') => 3, Character'Pos ('E') => 4, Character'Pos ('F') => 5, Character'Pos ('G') => 6, Character'Pos ('H') => 7, Character'Pos ('I') => 8, Character'Pos ('J') => 9, Character'Pos ('K') => 10, Character'Pos ('L') => 11, Character'Pos ('M') => 12, Character'Pos ('N') => 13, Character'Pos ('O') => 14, Character'Pos ('P') => 15, Character'Pos ('Q') => 16, Character'Pos ('R') => 17, Character'Pos ('S') => 18, Character'Pos ('T') => 19, Character'Pos ('U') => 20, Character'Pos ('V') => 21, Character'Pos ('W') => 22, Character'Pos ('X') => 23, Character'Pos ('Y') => 24, Character'Pos ('Z') => 25, Character'Pos ('a') => 26, Character'Pos ('b') => 27, Character'Pos ('c') => 28, Character'Pos ('d') => 29, Character'Pos ('e') => 30, Character'Pos ('f') => 31, Character'Pos ('g') => 32, Character'Pos ('h') => 33, Character'Pos ('i') => 34, Character'Pos ('j') => 35, Character'Pos ('k') => 36, Character'Pos ('l') => 37, Character'Pos ('m') => 38, Character'Pos ('n') => 39, Character'Pos ('o') => 40, Character'Pos ('p') => 41, Character'Pos ('q') => 42, Character'Pos ('r') => 43, Character'Pos ('s') => 44, Character'Pos ('t') => 45, Character'Pos ('u') => 46, Character'Pos ('v') => 47, Character'Pos ('w') => 48, Character'Pos ('x') => 49, Character'Pos ('y') => 50, Character'Pos ('z') => 51, Character'Pos ('0') => 52, Character'Pos ('1') => 53, Character'Pos ('2') => 54, Character'Pos ('3') => 55, Character'Pos ('4') => 56, Character'Pos ('5') => 57, Character'Pos ('6') => 58, Character'Pos ('7') => 59, Character'Pos ('8') => 60, Character'Pos ('9') => 61, Character'Pos ('+') => 62, Character'Pos ('/') => 63, others => 16#FF#); BASE64_URL_VALUES : aliased constant Alphabet_Values := (Character'Pos ('A') => 0, Character'Pos ('B') => 1, Character'Pos ('C') => 2, Character'Pos ('D') => 3, Character'Pos ('E') => 4, Character'Pos ('F') => 5, Character'Pos ('G') => 6, Character'Pos ('H') => 7, Character'Pos ('I') => 8, Character'Pos ('J') => 9, Character'Pos ('K') => 10, Character'Pos ('L') => 11, Character'Pos ('M') => 12, Character'Pos ('N') => 13, Character'Pos ('O') => 14, Character'Pos ('P') => 15, Character'Pos ('Q') => 16, Character'Pos ('R') => 17, Character'Pos ('S') => 18, Character'Pos ('T') => 19, Character'Pos ('U') => 20, Character'Pos ('V') => 21, Character'Pos ('W') => 22, Character'Pos ('X') => 23, Character'Pos ('Y') => 24, Character'Pos ('Z') => 25, Character'Pos ('a') => 26, Character'Pos ('b') => 27, Character'Pos ('c') => 28, Character'Pos ('d') => 29, Character'Pos ('e') => 30, Character'Pos ('f') => 31, Character'Pos ('g') => 32, Character'Pos ('h') => 33, Character'Pos ('i') => 34, Character'Pos ('j') => 35, Character'Pos ('k') => 36, Character'Pos ('l') => 37, Character'Pos ('m') => 38, Character'Pos ('n') => 39, Character'Pos ('o') => 40, Character'Pos ('p') => 41, Character'Pos ('q') => 42, Character'Pos ('r') => 43, Character'Pos ('s') => 44, Character'Pos ('t') => 45, Character'Pos ('u') => 46, Character'Pos ('v') => 47, Character'Pos ('w') => 48, Character'Pos ('x') => 49, Character'Pos ('y') => 50, Character'Pos ('z') => 51, Character'Pos ('0') => 52, Character'Pos ('1') => 53, Character'Pos ('2') => 54, Character'Pos ('3') => 55, Character'Pos ('4') => 56, Character'Pos ('5') => 57, Character'Pos ('6') => 58, Character'Pos ('7') => 59, Character'Pos ('8') => 60, Character'Pos ('9') => 61, Character'Pos ('-') => 62, Character'Pos ('_') => 63, others => 16#FF#); type Decode_State_Type is new Natural range 0 .. 3; type Decoder is new Util.Encoders.Transformer with record Values : Alphabet_Values_Access := BASE64_VALUES'Access; State : Decode_State_Type := 0; Remain : Interfaces.Unsigned_8 := 0; Ignore_Line_Break : Boolean := False; end record; end Util.Encoders.Base64;
pdaxrom/Kino2
Ada
6,793
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Text_IO_Demo -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en -- Version Control -- $Revision: 1.10 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Numerics.Generic_Elementary_Functions; with Ada.Numerics.Complex_Types; use Ada.Numerics.Complex_Types; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Text_IO; use Terminal_Interface.Curses.Text_IO; with Terminal_Interface.Curses.Text_IO.Integer_IO; with Terminal_Interface.Curses.Text_IO.Float_IO; with Terminal_Interface.Curses.Text_IO.Enumeration_IO; with Terminal_Interface.Curses.Text_IO.Complex_IO; with Terminal_Interface.Curses.Text_IO.Fixed_IO; with Terminal_Interface.Curses.Text_IO.Decimal_IO; with Terminal_Interface.Curses.Text_IO.Modular_IO; with Sample.Manifest; use Sample.Manifest; with Sample.Function_Key_Setting; use Sample.Function_Key_Setting; with Sample.Keyboard_Handler; use Sample.Keyboard_Handler; with Sample.Explanation; use Sample.Explanation; package body Sample.Text_IO_Demo is type Weekday is (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday); type Fix is delta 0.1 range 0.0 .. 4.0; type Dec is delta 0.01 digits 5 range 0.0 .. 4.0; type Md is mod 5; package Math is new Ada.Numerics.Generic_Elementary_Functions (Float); package Int_IO is new Terminal_Interface.Curses.Text_IO.Integer_IO (Integer); use Int_IO; package Real_IO is new Terminal_Interface.Curses.Text_IO.Float_IO (Float); use Real_IO; package Enum_IO is new Terminal_Interface.Curses.Text_IO.Enumeration_IO (Weekday); use Enum_IO; package C_IO is new Terminal_Interface.Curses.Text_IO.Complex_IO (Ada.Numerics.Complex_Types); use C_IO; package F_IO is new Terminal_Interface.Curses.Text_IO.Fixed_IO (Fix); use F_IO; package D_IO is new Terminal_Interface.Curses.Text_IO.Decimal_IO (Dec); use D_IO; package M_IO is new Terminal_Interface.Curses.Text_IO.Modular_IO (Md); use M_IO; procedure Demo is W : Window; P : Panel := Create (Standard_Window); K : Real_Key_Code; Im : Complex := (0.0, 1.0); Fx : Fix := 3.14; Dc : Dec := 2.72; L : Md; begin Push_Environment ("TEXTIO"); Default_Labels; Notepad ("TEXTIO-PAD00"); Set_Echo_Mode (False); Set_Meta_Mode; Set_KeyPad_Mode; W := Sub_Window (Standard_Window, Lines - 2, Columns - 2, 1, 1); Box; Refresh_Without_Update; Set_Meta_Mode (W); Set_KeyPad_Mode (W); Immediate_Update_Mode (W, True); Set_Window (W); for I in 1 .. 10 loop Put ("Square root of "); Put (Item => I, Width => 5); Put (" is "); Put (Item => Math.Sqrt (Float (I)), Exp => 0, Aft => 7); New_Line; end loop; for W in Weekday loop Put (Item => W); Put (' '); end loop; New_Line; L := Md'First; for I in 1 .. 2 loop for J in Md'Range loop Put (L); Put (' '); L := L + 1; end loop; end loop; New_Line; Put (Im); New_Line; Put (Fx); New_Line; Put (Dc); New_Line; loop K := Get_Key; if K in Special_Key_Code'Range then case K is when QUIT_CODE => exit; when HELP_CODE => Explain_Context; when EXPLAIN_CODE => Explain ("TEXTIOKEYS"); when others => null; end case; end if; end loop; Set_Window (Null_Window); Erase; Refresh_Without_Update; Delete (P); Delete (W); Pop_Environment; end Demo; end Sample.Text_IO_Demo;
reznikmm/matreshka
Ada
6,167
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A templateable element is an element that can optionally be defined as a -- template and bound to other templates. ------------------------------------------------------------------------------ with AMF.UML.Elements; limited with AMF.UML.Parameterable_Elements.Collections; limited with AMF.UML.Template_Bindings.Collections; limited with AMF.UML.Template_Signatures; package AMF.UML.Templateable_Elements is pragma Preelaborate; type UML_Templateable_Element is limited interface and AMF.UML.Elements.UML_Element; type UML_Templateable_Element_Access is access all UML_Templateable_Element'Class; for UML_Templateable_Element_Access'Storage_Size use 0; not overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Templateable_Element) return AMF.UML.Template_Signatures.UML_Template_Signature_Access is abstract; -- Getter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. not overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Templateable_Element; To : AMF.UML.Template_Signatures.UML_Template_Signature_Access) is abstract; -- Setter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. not overriding function Get_Template_Binding (Self : not null access constant UML_Templateable_Element) return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding is abstract; -- Getter of TemplateableElement::templateBinding. -- -- The optional bindings from this element to templates. not overriding function Is_Template (Self : not null access constant UML_Templateable_Element) return Boolean is abstract; -- Operation TemplateableElement::isTemplate. -- -- The query isTemplate() returns whether this templateable element is -- actually a template. not overriding function Parameterable_Elements (Self : not null access constant UML_Templateable_Element) return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element is abstract; -- Operation TemplateableElement::parameterableElements. -- -- The query parameterableElements() returns the set of elements that may -- be used as the parametered elements for a template parameter of this -- templateable element. By default, this set includes all the owned -- elements. Subclasses may override this operation if they choose to -- restrict the set of parameterable elements. end AMF.UML.Templateable_Elements;
reznikmm/matreshka
Ada
4,807
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Table_Cell_Range_Source_Elements; package Matreshka.ODF_Table.Cell_Range_Source_Elements is type Table_Cell_Range_Source_Element_Node is new Matreshka.ODF_Table.Abstract_Table_Element_Node and ODF.DOM.Table_Cell_Range_Source_Elements.ODF_Table_Cell_Range_Source with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Cell_Range_Source_Element_Node; overriding function Get_Local_Name (Self : not null access constant Table_Cell_Range_Source_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Table_Cell_Range_Source_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Table_Cell_Range_Source_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Table_Cell_Range_Source_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Table.Cell_Range_Source_Elements;
meowthsli/veriflight_boards
Ada
1,853
ads
package ADL_Config is Vendor : constant String := "STMicro"; -- From board definition Max_Mount_Points : constant := 2; -- From default value Max_Mount_Name_Length : constant := 128; -- From default value Runtime_Profile : constant String := "ravenscar-full"; -- From command line Device_Name : constant String := "STM32F405RGTx"; -- From board definition Device_Family : constant String := "STM32F4"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition Runtime_Name : constant String := "ravenscar-full-stm32f4"; -- From default value Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition Board : constant String := "Cc3df4revo"; -- From command line Has_ZFP_Runtime : constant String := "False"; -- From board definition Number_Of_Interrupts : constant := 91; -- From default value High_Speed_External_Clock : constant := 8000000; -- From board definition Max_Path_Length : constant := 1024; -- From default value Runtime_Name_Suffix : constant String := "stm32f4"; -- From board definition Architecture : constant String := "ARM"; -- From board definition Use_Startup_Gen : constant Boolean := False; -- From command line end ADL_Config;
riccardo-bernardini/eugen
Ada
1,459
adb
pragma Ada_2012; with GNAT.Regpat; use GNAT.Regpat; with Ada.Text_IO; use Ada.Text_IO; package body Regexp_Readers.Generic_Readers is Matcher : constant Pattern_Matcher := Compile (To_String (Regexp.Regexp)); N_Paren : constant Natural := Paren_Count (Matcher); Sub_Expression_Index : constant Natural := Regexp.Sub_Expression_Index; procedure Reader (Input : in String; Success : out Boolean; Consumed : out Natural; Result : out Result_Type) is Matches : Match_Array (0 .. Sub_Expression_Index); begin -- Put_Line (To_String (Regexp.Regexp) & Sub_Expression_Index'Image); if N_Paren < Sub_Expression_Index then raise Constraint_Error; end if; Match (Self => Matcher, Data => Input, Matches => Matches); if Matches (Sub_Expression_Index) = No_Match then Success := False; Consumed := 0; else declare M : constant Match_Location := Matches (Sub_Expression_Index); begin -- Put_Line ("(" & Input & ")" & M.First'Image & M.Last'Image & "**" -- & "(" & Input (M.First .. M.Last) & ")"); Success := True; Result := Convert (Input (M.First .. M.Last)); Consumed := Matches (0).Last - Input'First + 1; end; end if; end Reader; end Regexp_Readers.Generic_Readers;
stcarrez/ada-ado
Ada
5,964
adb
----------------------------------------------------------------------- -- ado-sessions-factory -- Session Factory -- Copyright (C) 2009, 2010, 2011, 2012, 2017, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ADO.Sequences.Hilo; with ADO.Schemas.Entities; with ADO.Queries.Loaders; package body ADO.Sessions.Factory is -- ------------------------------ -- Get a read-only session from the factory. -- ------------------------------ function Get_Session (Factory : in Session_Factory) return Session is R : Session; S : constant Session_Record_Access := new Session_Record; begin R.Impl := S; S.Entities := Factory.Entities; S.Values := Factory.Cache_Values; S.Queries := Factory.Queries'Unrestricted_Access; Factory.Source.Create_Connection (S.Database); return R; end Get_Session; -- ------------------------------ -- Get a read-only session from the session proxy. -- If the session has been invalidated, raise the Session_Error exception. -- ------------------------------ function Get_Session (Proxy : in Session_Record_Access) return Session is R : Session; begin if Proxy = null then raise Session_Error; end if; R.Impl := Proxy; Util.Concurrent.Counters.Increment (R.Impl.Counter); return R; end Get_Session; -- ------------------------------ -- Get a read-write session from the factory. -- ------------------------------ function Get_Master_Session (Factory : in Session_Factory) return Master_Session is R : Master_Session; S : constant Session_Record_Access := new Session_Record; begin R.Impl := S; R.Sequences := Factory.Sequences; R.Audit := Factory.Audit; S.Entities := Factory.Entities; S.Values := Factory.Cache_Values; S.Queries := Factory.Queries'Unrestricted_Access; Factory.Source.Create_Connection (S.Database); return R; end Get_Master_Session; -- ------------------------------ -- Initialize the sequence factory associated with the session factory. -- ------------------------------ procedure Initialize_Sequences (Factory : in out Session_Factory) is use ADO.Sequences; begin Factory.Sequences := Factory.Seq_Factory'Unchecked_Access; Set_Default_Generator (Factory.Seq_Factory, ADO.Sequences.Hilo.Create_HiLo_Generator'Access, Factory'Unchecked_Access, not Factory.Source.Has_Limited_Transactions); end Initialize_Sequences; -- ------------------------------ -- Create the session factory to connect to the database represented -- by the data source. -- ------------------------------ procedure Create (Factory : out Session_Factory; Source : in ADO.Sessions.Sources.Data_Source) is begin Factory.Source := Source; Factory.Entities := new ADO.Schemas.Entities.Entity_Cache; Factory.Cache_Values := Factory.Cache'Unchecked_Access; Factory.Cache.Add_Cache (ENTITY_CACHE_NAME, Factory.Entities.all'Access); ADO.Queries.Loaders.Initialize (Factory.Queries, Factory.Source); Initialize_Sequences (Factory); if Factory.Source.Get_Database /= "" and then not Configs.Is_On (Configs.NO_ENTITY_LOAD) then declare S : Session := Factory.Get_Session; begin ADO.Schemas.Entities.Initialize (Factory.Entities.all, S); end; end if; end Create; -- ------------------------------ -- Create the session factory to connect to the database identified -- by the URI. -- ------------------------------ procedure Create (Factory : out Session_Factory; URI : in String) is begin Factory.Source.Set_Connection (URI); Factory.Entities := new ADO.Schemas.Entities.Entity_Cache; Factory.Cache_Values := Factory.Cache'Unchecked_Access; Factory.Cache.Add_Cache (ENTITY_CACHE_NAME, Factory.Entities.all'Access); ADO.Queries.Loaders.Initialize (Factory.Queries, Factory.Source); Initialize_Sequences (Factory); if Factory.Source.Get_Database /= "" and then not Configs.Is_On (Configs.NO_ENTITY_LOAD) then declare S : Session := Factory.Get_Session; begin ADO.Schemas.Entities.Initialize (Factory.Entities.all, S); end; end if; end Create; -- ------------------------------ -- Set the audit manager to be used for the object auditing support. -- ------------------------------ procedure Set_Audit_Manager (Factory : in out Session_Factory; Manager : in ADO.Audits.Audit_Manager_Access) is begin Factory.Audit := Manager; end Set_Audit_Manager; -- ------------------------------ -- Set a static query loader to load SQL queries. -- ------------------------------ procedure Set_Query_Loader (Factory : in out Session_Factory; Loader : in ADO.Queries.Static_Loader_Access) is begin Factory.Queries.Set_Query_Loader (Loader); end Set_Query_Loader; end ADO.Sessions.Factory;
AdaCore/Ada_Drivers_Library
Ada
7,795
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body Serial_Port is --------------- -- As_String -- --------------- function As_String (This : Message) return String is begin return This.Content (1 .. This.Logical_Size); end As_String; --------- -- Set -- --------- procedure Set (This : in out Message; To : String) is begin This.Content (1 .. To'Length) := To; This.Logical_Size := To'Length; end Set; ---------------- -- Controller -- ---------------- protected body Controller is --------------------- -- Errors_Detected -- --------------------- function Errors_Detected return Error_Conditions is begin return Errors; end Errors_Detected; ------------------- -- Detect_Errors -- ------------------- procedure Detect_Errors is begin -- check for parity error if Status (Device.all, Parity_Error_Indicated) and Interrupt_Enabled (Device.all, Parity_Error) then Clear_Status (Device.all, Parity_Error_Indicated); Errors := Errors or Parity_Error_Detected; end if; -- check for framing error if Status (Device.all, Framing_Error_Indicated) and Interrupt_Enabled (Device.all, Error) then Clear_Status (Device.all, Framing_Error_Indicated); Errors := Errors or Frame_Error_Detected; end if; -- check for noise error if Status (Device.all, USART_Noise_Error_Indicated) and Interrupt_Enabled (Device.all, Error) then Clear_Status (Device.all, USART_Noise_Error_Indicated); Errors := Errors or Noise_Error_Detected; end if; -- check for overrun error if Status (Device.all, Overrun_Error_Indicated) and Interrupt_Enabled (Device.all, Error) then Clear_Status (Device.all, Overrun_Error_Indicated); Errors := Errors or Overrun_Error_Detected; end if; end Detect_Errors; ------------------------- -- Handle_Transmission -- ------------------------- procedure Handle_Transmission is begin -- if Word_Lenth = 9 then -- -- handle the extra byte required for the 9th bit -- else -- 8 data bits so no extra byte involved Transmit (Device.all, Character'Pos (Outgoing_Msg.Content (Next_Out))); Next_Out := Next_Out + 1; -- end if; Awaiting_Transfer := Awaiting_Transfer - 1; if Awaiting_Transfer = 0 then Disable_Interrupts (Device.all, Source => Transmit_Data_Register_Empty); Set_True (Outgoing_Msg.Transmission_Complete); end if; end Handle_Transmission; ---------------------- -- Handle_Reception -- ---------------------- procedure Handle_Reception is Received_Char : constant Character := Character'Val (Current_Input (Device.all)); begin Incoming_Msg.Content (Next_In) := Received_Char; if Received_Char = Incoming_Msg.Terminator or Next_In = Incoming_Msg.Physical_Size then -- reception complete Incoming_Msg.Logical_Size := Next_In; loop exit when not Status (Device.all, Read_Data_Register_Not_Empty); end loop; Disable_Interrupts (Device.all, Source => Received_Data_Not_Empty); Set_True (Incoming_Msg.Reception_Complete); else Next_In := Next_In + 1; end if; end Handle_Reception; ----------------- -- IRQ_Handler -- ----------------- procedure IRQ_Handler is begin Detect_Errors; -- check for data arrival if Status (Device.all, Read_Data_Register_Not_Empty) and Interrupt_Enabled (Device.all, Received_Data_Not_Empty) then Handle_Reception; Clear_Status (Device.all, Read_Data_Register_Not_Empty); end if; -- check for transmission ready if Status (Device.all, Transmit_Data_Register_Empty) and Interrupt_Enabled (Device.all, Transmit_Data_Register_Empty) then Handle_Transmission; Clear_Status (Device.all, Transmit_Data_Register_Empty); end if; end IRQ_Handler; ------------------- -- Start_Sending -- ------------------- procedure Start_Sending (Msg : not null access Message) is begin Outgoing_Msg := Msg; Awaiting_Transfer := Msg.Logical_Size; Next_Out := Msg.Content'First; Enable_Interrupts (Device.all, Source => Parity_Error); Enable_Interrupts (Device.all, Source => Error); Enable_Interrupts (Device.all, Source => Transmit_Data_Register_Empty); end Start_Sending; --------------------- -- Start_Receiving -- --------------------- procedure Start_Receiving (Msg : not null access Message) is begin Incoming_Msg := Msg; Next_In := Incoming_Msg.Content'First; Enable_Interrupts (Device.all, Source => Parity_Error); Enable_Interrupts (Device.all, Source => Error); Enable_Interrupts (Device.all, Source => Received_Data_Not_Empty); end Start_Receiving; end Controller; end Serial_Port;
Jellix/virtual_clocks
Ada
676
ads
------------------------------------------------------------------------ -- Copyright (C) 2010-2020 by <[email protected]> -- -- -- -- This work is free. You can redistribute it and/or modify it under -- -- the terms of the Do What The Fuck You Want To Public License, -- -- Version 2, as published by Sam Hocevar. See the LICENSE file for -- -- more details. -- ------------------------------------------------------------------------ pragma License (Unrestricted); package Test_Clocks is procedure Run; end Test_Clocks;
reznikmm/matreshka
Ada
9,004
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.DG.Clip_Paths; with AMF.DG.Graphical_Elements.Collections; with AMF.DG.Groups; with AMF.DG.Styles.Collections; with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.DD_Attributes; with AMF.Visitors.DG_Iterators; with AMF.Visitors.DG_Visitors; package body AMF.Internals.DG_Groups is ---------------- -- Get_Member -- ---------------- overriding function Get_Member (Self : not null access constant DG_Group_Proxy) return AMF.DG.Graphical_Elements.Collections.Ordered_Set_Of_DG_Graphical_Element is begin return AMF.DG.Graphical_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.DD_Attributes.Internal_Get_Member (Self.Element))); end Get_Member; --------------- -- Get_Group -- --------------- overriding function Get_Group (Self : not null access constant DG_Group_Proxy) return AMF.DG.Groups.DG_Group_Access is begin return AMF.DG.Groups.DG_Group_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Group (Self.Element))); end Get_Group; --------------- -- Set_Group -- --------------- overriding procedure Set_Group (Self : not null access DG_Group_Proxy; To : AMF.DG.Groups.DG_Group_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Group (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Group; --------------------- -- Get_Local_Style -- --------------------- overriding function Get_Local_Style (Self : not null access constant DG_Group_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is begin return AMF.DG.Styles.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.DD_Attributes.Internal_Get_Local_Style (Self.Element))); end Get_Local_Style; ---------------------- -- Get_Shared_Style -- ---------------------- overriding function Get_Shared_Style (Self : not null access constant DG_Group_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is begin return AMF.DG.Styles.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.DD_Attributes.Internal_Get_Shared_Style (Self.Element))); end Get_Shared_Style; ------------------- -- Get_Transform -- ------------------- overriding function Get_Transform (Self : not null access constant DG_Group_Proxy) return AMF.DG.Sequence_Of_DG_Transform is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Transform (Self.Element); end Get_Transform; ------------------- -- Get_Clip_Path -- ------------------- overriding function Get_Clip_Path (Self : not null access constant DG_Group_Proxy) return AMF.DG.Clip_Paths.DG_Clip_Path_Access is begin return AMF.DG.Clip_Paths.DG_Clip_Path_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Clip_Path (Self.Element))); end Get_Clip_Path; ------------------- -- Set_Clip_Path -- ------------------- overriding procedure Set_Clip_Path (Self : not null access DG_Group_Proxy; To : AMF.DG.Clip_Paths.DG_Clip_Path_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Clip_Path (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Clip_Path; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant DG_Group_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then AMF.Visitors.DG_Visitors.DG_Visitor'Class (Visitor).Enter_Group (AMF.DG.Groups.DG_Group_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant DG_Group_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then AMF.Visitors.DG_Visitors.DG_Visitor'Class (Visitor).Leave_Group (AMF.DG.Groups.DG_Group_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant DG_Group_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.DG_Iterators.DG_Iterator'Class then AMF.Visitors.DG_Iterators.DG_Iterator'Class (Iterator).Visit_Group (Visitor, AMF.DG.Groups.DG_Group_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.DG_Groups;
cborao/Ada-P4-chat
Ada
1,373
adb
--PRÁCTICA 4: César Borao Moratinos (chat_server_2) with Handlers; with Ada.Text_IO; with Ada.Calendar; with Chat_Messages; with Ordered_Maps_G; with Chat_Procedures; with Lower_Layer_UDP; with Ada.Command_Line; with Ada.Strings.Unbounded; procedure Chat_Server_2 is package ATI renames Ada.Text_IO; package CM renames Chat_Messages; package CP renames Chat_Procedures; package LLU renames Lower_Layer_UDP; package ACL renames Ada.Command_Line; package ASU renames Ada.Strings.Unbounded; use type CM.Message_Type; use type Ada.Calendar.Time; Port: Integer; Server_EP: LLU.End_Point_Type; Request: Character; begin --Binding Port := Integer'Value(ACL.Argument(1)); Server_EP := LLU.Build (LLU.To_IP(LLU.Get_Host_Name), Port); if ACL.Argument_Count = 2 and CP.Max_Valid(Natural'Value(ACL.Argument(2))) then loop --Server Handler LLU.Bind(Server_EP, Handlers.Server_Handler'Access); loop ATI.Get_Immediate(Request); ATI.Put_Line(Character'Image(Request)); case Request is when 'o'|'O' => CP.Print_Old_Map; when 'l'|'L' => CP.Print_Active_Map; when others => ATI.Put_Line("Not implemented"); end case; end loop; end loop; else ATI.New_Line; ATI.Put_Line("Server Usage: [Port] <Max_Clients (2-50)>"); ATI.New_Line; end if; LLU.finalize; end Chat_Server_2;
MinimSecure/unum-sdk
Ada
811
adb
-- Copyright 2012-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is procedure Do_Nothing is begin null; end Do_Nothing; end Pck;
RREE/ada-util
Ada
4,994
adb
----------------------------------------------------------------------- -- json -- JSON Reader -- Copyright (C) 2010, 2011, 2014, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Command_Line; with Util.Serialize.IO.JSON; with Ada.Containers; with Mapping; with Util.Serialize.Mappers.Vector_Mapper; with Util.Streams.Texts; with Util.Streams.Buffered; procedure Json is use Util.Streams.Buffered; use Ada.Strings.Unbounded; use type Ada.Containers.Count_Type; use Mapping; Reader : Util.Serialize.IO.JSON.Parser; Mapper : Util.Serialize.Mappers.Processing; Count : constant Natural := Ada.Command_Line.Argument_Count; package Person_Vector_Mapper is new Util.Serialize.Mappers.Vector_Mapper (Vectors => Person_Vector, Element_Mapper => Person_Mapper); -- Mapping for a list of Person records (stored as a Vector). Person_Vector_Mapping : aliased Person_Vector_Mapper.Mapper; procedure Print (P : in Mapping.Person_Vector.Cursor); procedure Print (P : in Mapping.Person); procedure Print (P : in Mapping.Person) is begin Ada.Text_IO.Put_Line ("Name : " & To_String (P.Name)); Ada.Text_IO.Put_Line ("first_name : " & To_String (P.First_Name)); Ada.Text_IO.Put_Line ("last_name : " & To_String (P.Last_Name)); Ada.Text_IO.Put_Line ("Age : " & Natural'Image (P.Age)); Ada.Text_IO.Put_Line ("Street : " & To_String (P.Addr.Street)); Ada.Text_IO.Put_Line ("City : " & To_String (P.Addr.City)); Ada.Text_IO.Put_Line ("Zip : " & Natural'Image (P.Addr.Zip)); Ada.Text_IO.Put_Line ("Country : " & To_String (P.Addr.Country)); Ada.Text_IO.Put_Line ("Info : " & To_String (P.Addr.Info.Name) & "=" & To_String (P.Addr.Info.Value)); end Print; procedure Print (P : in Mapping.Person_Vector.Cursor) is begin Print (Mapping.Person_Vector.Element (P)); end Print; begin if Count = 0 then Ada.Text_IO.Put_Line ("Usage: json file..."); return; end if; Person_Vector_Mapping.Set_Mapping (Mapping.Get_Person_Mapper); Mapper.Add_Mapping ("/list", Person_Vector_Mapping'Unchecked_Access); Mapper.Add_Mapping ("/person", Mapping.Get_Person_Mapper.all'Access); for I in 1 .. Count loop declare S : constant String := Ada.Command_Line.Argument (I); List : aliased Mapping.Person_Vector.Vector; P : aliased Mapping.Person; begin Person_Vector_Mapper.Set_Context (Mapper, List'Unchecked_Access); Mapping.Person_Mapper.Set_Context (Mapper, P'Unchecked_Access); Reader.Parse (S, Mapper); -- The list now contains our elements. List.Iterate (Process => Print'Access); if List.Length = 0 then Print (P); end if; declare Buffer : aliased Util.Streams.Buffered.Output_Buffer_Stream; Print : aliased Util.Streams.Texts.Print_Stream; Output : Util.Serialize.IO.JSON.Output_Stream; begin Buffer.Initialize (Size => 10000); Print.Initialize (Buffer'Unchecked_Access); Output.Initialize (Print'Unchecked_Access); Mapping.Get_Person_Mapper.Write (Output, P); Ada.Text_IO.Put_Line ("Person: " & Util.Streams.Texts.To_String (Print)); end; declare Buffer : aliased Util.Streams.Buffered.Output_Buffer_Stream; Print : aliased Util.Streams.Texts.Print_Stream; Output : Util.Serialize.IO.JSON.Output_Stream; begin Buffer.Initialize (Size => 10000); Print.Initialize (Buffer'Unchecked_Access); Output.Initialize (Print'Unchecked_Access); Output.Write ("{""list"":"); Person_Vector_Mapping.Write (Output, List); Output.Write ("}"); Ada.Text_IO.Put_Line ("IO:"); Ada.Text_IO.Put_Line (Util.Streams.Texts.To_String (Print)); end; end; end loop; end Json;
Irvise/Ada_SaxonSOC
Ada
507
adb
-- Blink a led with Interfaces.SaxonSOC.GPIO; use Interfaces.SaxonSOC.GPIO; procedure Blink is type Large is mod 2 ** 32; Counter_1 : Large := 0; begin -- GPIO_A_Output_Enable := 16#1111_1111#; GPIO_A_Output_Enable := 16#01#; GPIO_A_Output := 0; loop GPIO_A_Output := GPIO_A_Output xor 16#1111_1111#; while Counter_1 < Large'Last / 800 loop -- About a period of 2 seconds Counter_1 := Counter_1 + 1; end loop; Counter_1 := 0; end loop; end Blink;
stcarrez/ada-util
Ada
1,180
adb
----------------------------------------------------------------------- -- util-log-loggers-traceback-none -- Dummy traceback -- Copyright (C) 2012, 2013, 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- separate (Util.Log.Loggers) -- ------------------------------ -- Return a (dummy) printable traceback that correspond to the exception. -- ------------------------------ function Traceback (E : in Exception_Occurrence) return String is pragma Unreferenced (E); begin return ""; end Traceback;
AdaCore/libadalang
Ada
44
ads
package Pkg_A is I : Integer; end Pkg_A;
AdaCore/gpr
Ada
25,323
adb
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- package body Gpr_Parser_Support.Token_Data_Handlers is function Internal_Get_Trivias (TDH : Token_Data_Handler; Index : Token_Index) return Token_Index_Vectors.Elements_Array; procedure Compute_Lines_Starts (TDH : in out Token_Data_Handler) with Pre => TDH.Source_Buffer /= null; -- Compute the table of lines starting indices, that will allow us to -- go between offsets and line/columns. generic type Key_Type is private; -- Type of the value used to sort vector elements with package Element_Vectors is new Gpr_Parser_Support.Vectors (<>); with function Compare (K : Key_Type; E_Index : Positive; E : Element_Vectors.Element_Type) return Relative_Position is <>; -- Tell where K is with respect to E (E_Index is the index of E in the -- vector). function Floor (K : Key_Type; Vector : Element_Vectors.Vector) return Natural; -- Assuming that Vector contains a sorted sequence of elements, return the -- element index for which K is either inside or right after. If K actuals -- points right before the first Vector element, return the index of the -- first element. ----------- -- Floor -- ----------- function Floor (K : Key_Type; Vector : Element_Vectors.Vector) return Natural is Before, After : Natural; begin if Vector.Is_Empty then return 0; end if; Before := Vector.First_Index; After := Vector.Last_Index; while Before < After loop declare Last_Step : constant Boolean := Before + 1 = After; Middle : constant Natural := (After + Before) / 2; begin case Compare (K, Middle, Vector.Get (Middle)) is when Slocs.Before => After := Middle; when Slocs.Inside => return Middle; when Slocs.After => Before := Middle; end case; if Last_Step then case Compare (K, After, Vector.Get (After)) is when Slocs.Before => return Before; when Slocs.Inside | Slocs.After => return After; end case; end if; end; end loop; return Before; end Floor; ----------------- -- Initialized -- ----------------- function Initialized (TDH : Token_Data_Handler) return Boolean is begin return TDH.Symbols /= No_Symbol_Table; end Initialized; ----------------------- -- Has_Source_Buffer -- ----------------------- function Has_Source_Buffer (TDH : Token_Data_Handler) return Boolean is begin return TDH.Source_Buffer /= null; end Has_Source_Buffer; ---------------- -- Initialize -- ---------------- procedure Initialize (TDH : out Token_Data_Handler; Symbols : Symbol_Table; Owner : System.Address; Tab_Stop : Positive := Default_Tab_Stop) is begin TDH := (Version => 0, Source_Buffer => null, Source_First => <>, Source_Last => <>, Filename => <>, Charset => <>, Tokens => <>, Symbols => Symbols, Tokens_To_Trivias => <>, Trivias => <>, Lines_Starts => <>, Tab_Stop => Tab_Stop, Owner => Owner); end Initialize; ----------- -- Reset -- ----------- procedure Reset (TDH : in out Token_Data_Handler; Source_Buffer : Text_Access; Source_First : Positive; Source_Last : Natural) is begin Free (TDH.Source_Buffer); TDH.Source_Buffer := Source_Buffer; TDH.Source_First := Source_First; TDH.Source_Last := Source_Last; TDH.Lines_Starts.Clear; Compute_Lines_Starts (TDH); Clear (TDH.Tokens); Clear (TDH.Trivias); Clear (TDH.Tokens_To_Trivias); end Reset; -------------------------- -- Compute_Lines_Starts -- -------------------------- procedure Compute_Lines_Starts (TDH : in out Token_Data_Handler) is T : Text_Type renames TDH.Source_Buffer (TDH.Source_First .. TDH.Source_Last); Idx : Natural := T'First - 1; -- Index in T of the newline character that ends the currently processed -- line. function Index (Buffer : Text_Type; Char : Wide_Wide_Character; Start_Pos : Positive) return Natural; -- Helper function. Return the index of the first occurrence of ``Char`` -- in ``Buffer (Start_Pos .. End_Pos)``, or ``0`` if not found. ----------- -- Index -- ----------- function Index (Buffer : Text_Type; Char : Wide_Wide_Character; Start_Pos : Positive) return Natural is begin for I in Start_Pos .. T'Last loop if Buffer (I) = Char then return I; end if; end loop; return 0; end Index; begin TDH.Lines_Starts.Append (1); loop -- Search the index of the newline char that follows the current line Idx := Index (T, Chars.LF, Idx + 1); -- Append the index of the first character of line N+1 to -- Self.Line_Starts. This is the character at Idx+1. -- -- For regular cases, this is Idx + 1. If no next newline found, -- emulate the presence of this trailing LF (at T'Last+1) and return. if Idx = 0 then Idx := T'Last + 1; TDH.Lines_Starts.Append (Idx + 1); return; end if; TDH.Lines_Starts.Append (Idx + 1); end loop; end Compute_Lines_Starts; ---------- -- Free -- ---------- procedure Free (TDH : in out Token_Data_Handler) is begin Free (TDH.Source_Buffer); TDH.Tokens.Destroy; TDH.Trivias.Destroy; TDH.Tokens_To_Trivias.Destroy; TDH.Lines_Starts.Destroy; TDH.Symbols := No_Symbol_Table; end Free; ---------- -- Move -- ---------- procedure Move (Destination, Source : in out Token_Data_Handler) is begin Destination := Source; Source := (Version => 0, Source_Buffer => null, Source_First => <>, Source_Last => <>, Filename => <>, Charset => <>, Tokens => <>, Symbols => No_Symbol_Table, Tokens_To_Trivias => <>, Trivias => <>, Lines_Starts => <>, Tab_Stop => <>, Owner => System.Null_Address); end Move; -------------------------- -- Internal_Get_Trivias -- -------------------------- function Internal_Get_Trivias (TDH : Token_Data_Handler; Index : Token_Index) return Token_Index_Vectors.Elements_Array is subtype Index_Type is Trivia_Vectors.Index_Type; First_Trivia_Index : constant Token_Index := (if Length (TDH.Tokens_To_Trivias) = 0 then No_Token_Index else Token_Index (Get (TDH.Tokens_To_Trivias, Index_Type (Index + 1)))); Last_Trivia_Index : Token_Index := First_Trivia_Index; begin if First_Trivia_Index /= No_Token_Index then while Get (TDH.Trivias, Index_Type (Last_Trivia_Index)).Has_Next loop Last_Trivia_Index := Last_Trivia_Index + 1; end loop; declare Trivia_Count : constant Natural := Natural (Last_Trivia_Index) - Natural (First_Trivia_Index) + 1; Result : Token_Index_Vectors.Elements_Array (1 .. Trivia_Count); begin for Index in First_Trivia_Index .. Last_Trivia_Index loop Result (Index_Type (Index - First_Trivia_Index + 1)) := Index; end loop; return Result; end; end if; return Token_Index_Vectors.Empty_Array; end Internal_Get_Trivias; --------------- -- Get_Token -- --------------- function Get_Token (TDH : Token_Data_Handler; Index : Token_Index) return Stored_Token_Data is begin return Token_Vectors.Get (TDH.Tokens, Natural (Index)); end Get_Token; ---------------- -- Last_Token -- ---------------- function Last_Token (TDH : Token_Data_Handler) return Token_Index is begin return Token_Index (Token_Vectors.Last_Index (TDH.Tokens)); end Last_Token; --------------------------- -- First_Token_Or_Trivia -- --------------------------- function First_Token_Or_Trivia (TDH : Token_Data_Handler) return Token_Or_Trivia_Index is begin if TDH.Tokens_To_Trivias.Is_Empty or else TDH.Tokens_To_Trivias.First_Element = Integer (No_Token_Index) then -- There is no leading trivia: return the first token return (if TDH.Tokens.Is_Empty then No_Token_Or_Trivia_Index else (Token_Index (TDH.Tokens.First_Index), No_Token_Index)); else return (No_Token_Index, Token_Index (TDH.Tokens.First_Index)); end if; end First_Token_Or_Trivia; -------------------------- -- Last_Token_Or_Trivia -- -------------------------- function Last_Token_Or_Trivia (TDH : Token_Data_Handler) return Token_Or_Trivia_Index is begin if TDH.Tokens_To_Trivias.Is_Empty or else TDH.Tokens_To_Trivias.Last_Element = Integer (No_Token_Index) then -- There is no trailing trivia: return the last token return (if TDH.Tokens.Is_Empty then No_Token_Or_Trivia_Index else (Token_Index (TDH.Tokens.Last_Index), No_Token_Index)); else return (No_Token_Index, Token_Index (TDH.Trivias.First_Index)); end if; end Last_Token_Or_Trivia; ---------- -- Next -- ---------- function Next (Token : Token_Or_Trivia_Index; TDH : Token_Data_Handler; Exclude_Trivia : Boolean := False) return Token_Or_Trivia_Index is function Next_Token (Current : Token_Or_Trivia_Index) return Token_Or_Trivia_Index is (if Current.Token < Token_Index (TDH.Tokens.Last_Index) then (Current.Token + 1, No_Token_Index) else No_Token_Or_Trivia_Index); -- Return a reference to the next token (not trivia) or no token if -- Token was the last one. function Next_Step (Current : Token_Or_Trivia_Index) return Token_Or_Trivia_Index; -- Compute what Next must return when called with Exclude_Trivia left -- to False. --------------- -- Next_Step -- --------------- function Next_Step (Current : Token_Or_Trivia_Index) return Token_Or_Trivia_Index is begin if Current = No_Token_Or_Trivia_Index then return Current; end if; if Current.Trivia /= No_Token_Index then -- Current is a reference to a trivia: take the next trivia if it -- exists, or escalate to the next token otherwise. declare Tr : constant Trivia_Node := TDH.Trivias.Get (Natural (Current.Trivia)); begin return (if Tr.Has_Next then (Current.Token, Current.Trivia + 1) else Next_Token (Current)); end; else -- Thanks to the guard above, we cannot get to the declare block -- for the No_Token case, so if Token does not refers to a trivia, -- it must be a token. pragma Assert (Current.Token /= No_Token_Index); -- If there is no trivia, just go to the next token if TDH.Tokens_To_Trivias.Is_Empty then return Next_Token (Current); end if; -- If this token has trivia, return a reference to the first one, -- otherwise get the next token. declare Tr_Index : constant Token_Index := Token_Index (TDH.Tokens_To_Trivias.Get (Natural (Current.Token) + 1)); begin return (if Tr_Index = No_Token_Index then Next_Token (Current) else (Current.Token, Tr_Index)); end; end if; end Next_Step; Result : Token_Or_Trivia_Index := Next_Step (Token); begin if not Exclude_Trivia then return Result; end if; while Result /= No_Token_Or_Trivia_Index and then Result.Trivia /= No_Token_Index loop Result := Next_Step (Result); end loop; return Result; end Next; -------------- -- Previous -- -------------- function Previous (Token : Token_Or_Trivia_Index; TDH : Token_Data_Handler; Exclude_Trivia : Boolean := False) return Token_Or_Trivia_Index is function Next_Step (Current : Token_Or_Trivia_Index) return Token_Or_Trivia_Index; -- Compute what Previous must return when called with Exclude_Trivia -- left to False. --------------- -- Next_Step -- --------------- function Next_Step (Current : Token_Or_Trivia_Index) return Token_Or_Trivia_Index is begin if Current = No_Token_Or_Trivia_Index then return Current; end if; if Current.Trivia = No_Token_Index then -- Current is a regular token, so the previous token is either the -- last trivia of the previous regular token, either the previous -- regular token itself. declare Prev_Trivia : Token_Index; begin -- Get the index of the trivia that is right before Current (if -- any). if TDH.Tokens_To_Trivias.Length = 0 then Prev_Trivia := No_Token_Index; else Prev_Trivia := Token_Index (TDH.Tokens_To_Trivias.Get (Natural (Current.Token))); while Prev_Trivia /= No_Token_Index and then TDH.Trivias.Get (Natural (Prev_Trivia)).Has_Next loop Prev_Trivia := Prev_Trivia + 1; end loop; end if; -- If there is no such trivia and Current was the first one, -- then this was the start of the token stream: no previous -- token. if Prev_Trivia = No_Token_Index and then Current.Token <= First_Token_Index then return No_Token_Or_Trivia_Index; else return (Current.Token - 1, Prev_Trivia); end if; end; -- Past this point: Current is known to be a trivia elsif Current.Trivia = First_Token_Index then -- This is the first trivia for some token, so the previous token -- cannot be a trivia. return (if Current.Token = No_Token_Index then No_Token_Or_Trivia_Index else (Current.Token, No_Token_Index)); elsif Current.Token = No_Token_Index then -- This is a leading trivia and not the first one, so the previous -- token has to be a trivia. return (No_Token_Index, Current.Trivia - 1); -- Past this point: Current is known to be a trivia *and* it is not a -- leading trivia. else return (Current.Token, (if TDH.Trivias.Get (Natural (Current.Trivia - 1)).Has_Next then Current.Trivia - 1 else No_Token_Index)); end if; end Next_Step; Result : Token_Or_Trivia_Index := Next_Step (Token); begin if not Exclude_Trivia then return Result; end if; while Result /= No_Token_Or_Trivia_Index and then Result.Trivia /= No_Token_Index loop Result := Next_Step (Result); end loop; return Result; end Previous; -------------------- -- Previous_Token -- -------------------- function Previous_Token (Trivia : Token_Index; TDH : Token_Data_Handler) return Token_Index is function Compare (Key_Trivia : Token_Index; Element_Index : Positive; Element : Integer) return Relative_Position; ------------- -- Compare -- ------------- function Compare (Key_Trivia : Token_Index; Element_Index : Positive; Element : Integer) return Relative_Position is Triv_Index : constant Natural := Natural (Key_Trivia); begin -- Index can be zero if the corresponding token is not followed by -- any trivia. In this case, rely on the sloc to compare them. if Element = 0 then declare Triv_Index : constant Natural := Natural (Key_Trivia); Tok_Index : constant Natural := Element_Index - 1; Key_Start_Sloc : constant Source_Location := Sloc_Start (TDH, TDH.Trivias.Get (Triv_Index).T); begin return Compare (Sloc_Range (TDH, TDH.Tokens.Get (Tok_Index)), Key_Start_Sloc); end; end if; if Element < Triv_Index then return After; elsif Element > Triv_Index then return Before; else return Inside; end if; end Compare; function Token_Floor is new Floor (Key_Type => Token_Index, Element_Vectors => Integer_Vectors); begin -- Perform a binary search over Tokens_To_Trivias to find the index of -- the Token that precedes Trivia. return Token_Index (Token_Floor (Trivia, TDH.Tokens_To_Trivias) - 1); -- Token_Floor deals with indexes for the Tokens_To_Trivia vector, so -- their corresponding to token indexes, but off by one (token index 1 -- corresponding to Tokens_To_Trivia index 2, ...). Hence the X-1 -- operation when returning. end Previous_Token; ------------------ -- Lookup_Token -- ------------------ function Lookup_Token (TDH : Token_Data_Handler; Sloc : Source_Location) return Token_Or_Trivia_Index is function Compare (Sloc : Source_Location; Dummy_Index : Positive; Token : Stored_Token_Data) return Relative_Position is (Compare (Sloc_Range (TDH, Token), Sloc)); function Compare (Sloc : Source_Location; Dummy_Index : Positive; Trivia : Trivia_Node) return Relative_Position is (Compare (Sloc_Range (TDH, Trivia.T), Sloc)); function Token_Floor is new Floor (Key_Type => Source_Location, Element_Vectors => Token_Vectors); function Trivia_Floor is new Floor (Key_Type => Source_Location, Element_Vectors => Trivia_Vectors); -- Look for a candidate token and a candidate trivia, then take the one -- that is the closest to Sloc. Token : constant Natural := Token_Floor (Sloc, TDH.Tokens); Trivia : constant Natural := Trivia_Floor (Sloc, TDH.Trivias); function Result_From_Token return Token_Or_Trivia_Index is ((Token_Index (Token), No_Token_Index)); function Result_From_Trivia return Token_Or_Trivia_Index is ((Previous_Token (Token_Index (Trivia), TDH), Token_Index (Trivia))); begin if Trivia = 0 then return Result_From_Token; elsif Token = 0 then return Result_From_Trivia; end if; declare function SS (Token : Stored_Token_Data) return Source_Location is (Sloc_Start (TDH, Token)); Tok_Sloc : constant Source_Location := SS (TDH.Tokens.Get (Token)); Triv_Sloc : constant Source_Location := SS (TDH.Trivias.Get (Trivia).T); begin if Tok_Sloc < Triv_Sloc then if Sloc < Triv_Sloc then return Result_From_Token; end if; elsif Tok_Sloc < Sloc or else Tok_Sloc = Sloc then return Result_From_Token; end if; return Result_From_Trivia; end; end Lookup_Token; ---------- -- Data -- ---------- function Data (Token : Token_Or_Trivia_Index; TDH : Token_Data_Handler) return Stored_Token_Data is begin return (if Token.Trivia = No_Token_Index then TDH.Tokens.Get (Natural (Token.Token)) else TDH.Trivias.Get (Natural (Token.Trivia)).T); end Data; ----------------- -- Get_Trivias -- ----------------- function Get_Trivias (TDH : Token_Data_Handler; Index : Token_Index) return Token_Index_Vectors.Elements_Array is begin if Index = No_Token_Index then return Token_Index_Vectors.Empty_Array; end if; return Internal_Get_Trivias (TDH, Index); end Get_Trivias; ------------------------- -- Get_Leading_Trivias -- ------------------------- function Get_Leading_Trivias (TDH : Token_Data_Handler) return Token_Index_Vectors.Elements_Array is begin return Internal_Get_Trivias (TDH, No_Token_Index); end Get_Leading_Trivias; -------------- -- Get_Line -- -------------- function Get_Line (TDH : Token_Data_Handler; Line_Number : Positive) return Text_Type is begin -- Return slice from... return TDH.Source_Buffer ( -- The first character in the requested line TDH.Lines_Starts.Get (Line_Number) .. -- The character before the LF that precedes the first character of -- the next line. TDH.Lines_Starts.Get (Line_Number + 1) - 2 ); end Get_Line; -------------- -- Get_Sloc -- -------------- function Get_Sloc (TDH : Token_Data_Handler; Index : Natural) return Source_Location is function Compare (Sought : Positive; Dummy_Index : Positive; Line_Start : Positive) return Relative_Position is (if Sought > Line_Start then After elsif Sought = Line_Start then Inside else Before); function Get_Line_Index is new Floor (Positive, Index_Vectors); -- Return the index of the first character of Line `N` in a given -- `TDH.Line_Starts` vector. begin -- Allow 0 as an offset because it's a common value when the text buffer -- is empty: in that case just return a null source location. if Index = 0 then return No_Source_Location; end if; declare Line_Index : constant Positive := Get_Line_Index (Index, TDH.Lines_Starts); Line_Offset : constant Positive := TDH.Lines_Starts.Get (Line_Index); Line_End : constant Integer := Natural'Min (Index - 1, TDH.Source_Last); Column : Column_Number; begin -- Allow an offset that reference the character that would follow the -- end of the source buffer (i.e. ``'Last + 1``), but no further. if Index > TDH.Source_Buffer'Last + 1 then raise Constraint_Error with "out of bound access"; end if; -- Column number at the start of the current line is 1. We must then -- add the columns for anything between the start of the line and the -- requested offset. Column := 1 + Column_Count (TDH.Source_Buffer (Line_Offset .. Line_End), TDH.Tab_Stop); return Source_Location'(Line_Number (Line_Index), Column); end; end Get_Sloc; ---------------- -- Sloc_Start -- ---------------- function Sloc_Start (TDH : Token_Data_Handler; Token : Stored_Token_Data) return Source_Location is begin return Get_Sloc (TDH, Token.Source_First); end Sloc_Start; -------------- -- Sloc_End -- -------------- function Sloc_End (TDH : Token_Data_Handler; Token : Stored_Token_Data) return Source_Location is begin return Get_Sloc (TDH, Token.Source_Last + 1); end Sloc_End; ---------------- -- Sloc_Range -- ---------------- function Sloc_Range (TDH : Token_Data_Handler; Token : Stored_Token_Data) return Source_Location_Range is begin return Make_Range (Sloc_Start (TDH, Token), Sloc_End (TDH, Token)); end Sloc_Range; end Gpr_Parser_Support.Token_Data_Handlers;
MinimSecure/unum-sdk
Ada
925
adb
-- Copyright 2016-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is function Ident (I : Integer) return Integer is begin return I; end Ident; procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
optikos/oasis
Ada
2,378
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Aspect_Specifications; package Program.Elements.Protected_Body_Stubs is pragma Pure (Program.Elements.Protected_Body_Stubs); type Protected_Body_Stub is limited interface and Program.Elements.Declarations.Declaration; type Protected_Body_Stub_Access is access all Protected_Body_Stub'Class with Storage_Size => 0; not overriding function Name (Self : Protected_Body_Stub) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; not overriding function Aspects (Self : Protected_Body_Stub) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is abstract; type Protected_Body_Stub_Text is limited interface; type Protected_Body_Stub_Text_Access is access all Protected_Body_Stub_Text'Class with Storage_Size => 0; not overriding function To_Protected_Body_Stub_Text (Self : aliased in out Protected_Body_Stub) return Protected_Body_Stub_Text_Access is abstract; not overriding function Protected_Token (Self : Protected_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Body_Token (Self : Protected_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Is_Token (Self : Protected_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Separate_Token (Self : Protected_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function With_Token (Self : Protected_Body_Stub_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Protected_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Protected_Body_Stubs;
reznikmm/matreshka
Ada
15,601
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.UML_Dependencies is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Dependency_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Dependency (AMF.UML.Dependencies.UML_Dependency_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Dependency_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Dependency (AMF.UML.Dependencies.UML_Dependency_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Dependency_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Dependency (Visitor, AMF.UML.Dependencies.UML_Dependency_Access (Self), Control); end if; end Visit_Element; ---------------- -- Get_Client -- ---------------- overriding function Get_Client (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client (Self.Element))); end Get_Client; ------------------ -- Get_Supplier -- ------------------ overriding function Get_Supplier (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Supplier (Self.Element))); end Get_Supplier; ---------------- -- Get_Source -- ---------------- overriding function Get_Source (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Source (Self.Element))); end Get_Source; ---------------- -- Get_Target -- ---------------- overriding function Get_Target (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Target (Self.Element))); end Get_Target; ------------------------- -- Get_Related_Element -- ------------------------- overriding function Get_Related_Element (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element (Self.Element))); end Get_Related_Element; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UML_Dependency_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UML_Dependency_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; ----------------------------------- -- Get_Owning_Template_Parameter -- ----------------------------------- overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter (Self.Element))); end Get_Owning_Template_Parameter; ----------------------------------- -- Set_Owning_Template_Parameter -- ----------------------------------- overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Dependency_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Owning_Template_Parameter; ---------------------------- -- Get_Template_Parameter -- ---------------------------- overriding function Get_Template_Parameter (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter (Self.Element))); end Get_Template_Parameter; ---------------------------- -- Set_Template_Parameter -- ---------------------------- overriding procedure Set_Template_Parameter (Self : not null access UML_Dependency_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Template_Parameter; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure UML_Dependency_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant UML_Dependency_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure UML_Dependency_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UML_Dependency_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure UML_Dependency_Proxy.Namespace"; return Namespace (Self); end Namespace; ------------------------ -- Is_Compatible_With -- ------------------------ overriding function Is_Compatible_With (Self : not null access constant UML_Dependency_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented"); raise Program_Error with "Unimplemented procedure UML_Dependency_Proxy.Is_Compatible_With"; return Is_Compatible_With (Self, P); end Is_Compatible_With; --------------------------- -- Is_Template_Parameter -- --------------------------- overriding function Is_Template_Parameter (Self : not null access constant UML_Dependency_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented"); raise Program_Error with "Unimplemented procedure UML_Dependency_Proxy.Is_Template_Parameter"; return Is_Template_Parameter (Self); end Is_Template_Parameter; end AMF.Internals.UML_Dependencies;
stcarrez/ada-keystore
Ada
1,784
adb
----------------------------------------------------------------------- -- keystore-testsuite -- Testsuite for keystore -- Copyright (C) 2019, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Keystore.Files.Tests; with Keystore.IO.Tests; with Keystore.Tests; with Keystore.Tools.Tests; with Keystore.Passwords.Tests; with Keystore.GPG_Tests; with Keystore.Properties.Tests; with Keystore.Coverage; with Keystore.Fuse_Tests; package body Keystore.Testsuite is Tests : aliased Util.Tests.Test_Suite; function Suite return Util.Tests.Access_Test_Suite is begin Keystore.Fuse_Tests.Add_Tests (Tests'Access); Keystore.Passwords.Tests.Add_Tests (Tests'Access); Keystore.IO.Tests.Add_Tests (Tests'Access); Keystore.Files.Tests.Add_Tests (Tests'Access); Keystore.Properties.Tests.Add_Tests (Tests'Access); Keystore.Tools.Tests.Add_Tests (Tests'Access); Keystore.Tests.Add_Tests (Tests'Access); Keystore.GPG_Tests.Add_Tests (Tests'Access); Keystore.Coverage.Add_Tests (Tests'Access); return Tests'Access; end Suite; end Keystore.Testsuite;
sf17k/sdlada
Ada
24,363
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; with Interfaces.C.Strings; private with SDL.C_Pointers; with SDL.Error; package body SDL.Video.GL is package C renames Interfaces.C; use type C.int; use type SDL.C_Pointers.GL_Context_Pointer; type Attributes is (Attribute_Red_Size, Attribute_Green_Size, Attribute_Blue_Size, Attribute_Alpha_Size, Attribute_Buffer_Size, Attribute_Double_Buffer, Attribute_Depth_Buffer_Size, Attribute_Stencil_Size, Attribute_Accumulator_Red_Size, Attribute_Accumulator_Green_Size, Attribute_Accumulator_Blue_Size, Attribute_Accumulator_Alpha_Size, Attribute_Stereo, Attribute_Multisample_Buffers, Attribute_Multisample_Samples, Attribute_Accelerated, Attribute_Retained_Backing, Attribute_Context_Major_Version, Attribute_Context_Minor_Version, Attribute_Context_EGL, Attribute_Context_Flags, Attribute_Context_Profile, Attribute_Share_With_Current_Context) with Convention => C; Profile_Values : constant array (Profiles) of Interfaces.Unsigned_32 := (16#0000_0001#, 16#0000_0002#, 16#0000_0004#); function SDL_GL_Set_Attribute (Attr : in Attributes; Value : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_SetAttribute"; function SDL_GL_Get_Attribute (Attr : in Attributes; Value : out C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_GetAttribute"; function Red_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Red_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Red_Size; procedure Set_Red_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Red_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Red_Size; function Green_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Green_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Green_Size; procedure Set_Green_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Green_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Green_Size; function Blue_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Blue_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Blue_Size; procedure Set_Blue_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Blue_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Blue_Size; function Alpha_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Alpha_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Alpha_Size; procedure Set_Alpha_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Alpha_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Alpha_Size; function Buffer_Size return Buffer_Sizes is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Buffer_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Buffer_Sizes (Data); end Buffer_Size; procedure Set_Buffer_Size (Size : in Buffer_Sizes) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Buffer_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Buffer_Size; function Is_Double_Buffered return Boolean is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Double_Buffer, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return (Data = 1); end Is_Double_Buffered; procedure Set_Double_Buffer (On : in Boolean) is Data : C.int := (if On = True then 1 else 0); Result : C.int := SDL_GL_Set_Attribute (Attribute_Double_Buffer, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Double_Buffer; function Depth_Buffer_Size return Depth_Buffer_Sizes is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Depth_Buffer_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Depth_Buffer_Sizes (Data); end Depth_Buffer_Size; procedure Set_Depth_Buffer_Size (Size : in Depth_Buffer_Sizes) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Depth_Buffer_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Depth_Buffer_Size; function Stencil_Buffer_Size return Stencil_Buffer_Sizes is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Stencil_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Stencil_Buffer_Sizes (Data); end Stencil_Buffer_Size; procedure Set_Stencil_Buffer_Size (Size : in Stencil_Buffer_Sizes) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Stencil_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Stencil_Buffer_Size; function Accumulator_Red_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Accumulator_Red_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Accumulator_Red_Size; procedure Set_Accumulator_Red_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Accumulator_Red_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Accumulator_Red_Size; function Accumulator_Green_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Accumulator_Green_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Accumulator_Green_Size; procedure Set_Accumulator_Green_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Accumulator_Green_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Accumulator_Green_Size; function Accumulator_Blue_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Accumulator_Blue_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Accumulator_Blue_Size; procedure Set_Accumulator_Blue_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Accumulator_Blue_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Accumulator_Blue_Size; function Accumulator_Alpha_Size return Colour_Bit_Size is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Accumulator_Alpha_Size, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Colour_Bit_Size (Data); end Accumulator_Alpha_Size; procedure Set_Accumulator_Alpha_Size (Size : in Colour_Bit_Size) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Accumulator_Alpha_Size, C.int (Size)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Accumulator_Alpha_Size; function Is_Stereo return Boolean is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Stereo, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return (Data = 1); end Is_Stereo; procedure Set_Stereo (On : in Boolean) is Data : C.int := (if On = True then 1 else 0); Result : C.int := SDL_GL_Set_Attribute (Attribute_Stereo, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Stereo; function Is_Multisampled return Boolean is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Multisample_Buffers, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return (Data = 1); end Is_Multisampled; procedure Set_Multisampling (On : in Boolean) is Data : C.int := (if On = True then 1 else 0); Result : C.int := SDL_GL_Set_Attribute (Attribute_Multisample_Buffers, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Multisampling; function Multisampling_Samples return Multisample_Samples is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Multisample_Samples, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Multisample_Samples (Data); end Multisampling_Samples; procedure Set_Multisampling_Samples (Samples : in Multisample_Samples) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Multisample_Samples, C.int (Samples)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Multisampling_Samples; function Is_Accelerated return Boolean is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Accelerated, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return (Result = 1); end Is_Accelerated; procedure Set_Accelerated (On : in Boolean) is Data : C.int := (if On = True then 1 else 0); Result : C.int := SDL_GL_Set_Attribute (Attribute_Accelerated, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Accelerated; function Context_Major_Version return Major_Versions is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Context_Major_Version, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Major_Versions (Data); end Context_Major_Version; procedure Set_Context_Major_Version (Version : Major_Versions) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Context_Major_Version, C.int (Version)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Context_Major_Version; function Context_Minor_Version return Minor_Versions is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Context_Minor_Version, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Minor_Versions (Data); end Context_Minor_Version; procedure Set_Context_Minor_Version (Version : Minor_Versions) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Context_Minor_Version, C.int (Version)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Context_Minor_Version; function Is_Context_EGL return Boolean is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Context_EGL, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return (Data = 1); end Is_Context_EGL; procedure Set_Context_EGL (On : in Boolean) is Data : C.int := (if On = True then 1 else 0); Result : C.int := SDL_GL_Set_Attribute (Attribute_Context_EGL, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Context_EGL; function Context_Flags return Flags is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Context_Flags, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Flags (Data); end Context_Flags; procedure Set_Context_Flags (Context_Flags : in Flags) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Context_Flags, C.int (Context_Flags)); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Context_Flags; function Context_Profile return Profiles is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Context_Profile, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return Profiles'Val (Data); end Context_Profile; procedure Set_Context_Profile (Profile : in Profiles) is Result : C.int := SDL_GL_Set_Attribute (Attribute_Context_Profile, C.int (Profile_Values (Profile))); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Context_Profile; function Is_Sharing_With_Current_Context return Boolean is Data : C.int; Result : C.int := SDL_GL_Get_Attribute (Attribute_Share_With_Current_Context, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; return (Data = 1); end Is_Sharing_With_Current_Context; procedure Set_Share_With_Current_Context (On : in Boolean) is Data : C.int := (if On = True then 1 else 0); Result : C.int := SDL_GL_Set_Attribute (Attribute_Share_With_Current_Context, Data); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Share_With_Current_Context; -- Some helper functions to get make this type work ok. function Get_Internal_Window (Self : in SDL.Video.Windows.Window) return SDL.C_Pointers.Windows_Pointer with Import => True, Convention => Ada; function Get_Internal_Texture (Self : in SDL.Video.Textures.Texture) return SDL.C_Pointers.Texture_Pointer with Import => True, Convention => Ada; -- The GL context. procedure Create (Self : in out Contexts; From : in SDL.Video.Windows.Window) is function SDL_GL_Create_Context (W : in SDL.C_Pointers.Windows_Pointer) return SDL.C_Pointers.GL_Context_Pointer with Import => True, Convention => C, External_Name => "SDL_GL_CreateContext"; C : SDL.C_Pointers.GL_Context_Pointer := SDL_GL_Create_Context (Get_Internal_Window (From)); begin if C = null then raise SDL_GL_Error with SDL.Error.Get; end if; Self.Internal := C; Self.Owns := True; end Create; overriding procedure Finalize (Self : in out Contexts) is procedure SDL_GL_Delete_Context (W : in SDL.C_Pointers.GL_Context_Pointer) with Import => True, Convention => C, External_Name => "SDL_GL_DeleteContext"; begin -- We have to own this pointer before we go any further... -- and make sure we don't delete this twice if we do! if Self.Internal /= null and then Self.Owns then SDL_GL_Delete_Context (Self.Internal); Self.Internal := null; end if; end Finalize; -- TODO: Make sure we make all similar functions across the API match this pattern. -- Create a temporary Context. function Get_Current return Contexts is function SDL_GL_Get_Current_Context return SDL.C_Pointers.GL_Context_Pointer with Import => True, Convention => C, External_Name => "SDL_GL_GetCurrentContext"; begin return C : constant Contexts := (Ada.Finalization.Limited_Controlled with Internal => SDL_GL_Get_Current_Context, Owns => False) do if C.Internal = null then raise SDL_GL_Error with SDL.Error.Get; end if; end return; end Get_Current; procedure Set_Current (Self : in Contexts; To : in SDL.Video.Windows.Window) is function SDL_GL_Make_Current (W : in SDL.C_Pointers.Windows_Pointer; Context : in SDL.C_Pointers.GL_Context_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_MakeCurrent"; Result : C.int := SDL_GL_Make_Current (Get_Internal_Window (To), Self.Internal); begin if Result /= Success then raise SDL_GL_Error with SDL.Error.Get; end if; end Set_Current; procedure Bind_Texture (Texture : in SDL.Video.Textures.Texture) is function SDL_GL_Bind_Texture (T : in SDL.C_Pointers.Texture_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_BindTexture"; begin if SDL_GL_Bind_Texture (Get_Internal_Texture (Texture)) /= SDL.Success then raise SDL_GL_Error with "Cannot bind texture, unsupported operation in this context."; end if; end Bind_Texture; procedure Bind_Texture (Texture : in SDL.Video.Textures.Texture; Size : out SDL.Video.Rectangles.Size) is function SDL_GL_Bind_Texture (T : in SDL.C_Pointers.Texture_Pointer; W, H : out C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_BindTexture"; begin if SDL_GL_Bind_Texture (Get_Internal_Texture (Texture), Size.Width, Size.Height) /= SDL.Success then raise SDL_GL_Error with "Cannot bind texture, unsupported operation in this context."; end if; end Bind_Texture; procedure Unbind_Texture (Texture : in SDL.Video.Textures.Texture) is function SDL_GL_Unbind_Texture (T : in SDL.C_Pointers.Texture_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_UnbindTexture"; begin if SDL_GL_Unbind_Texture (Get_Internal_Texture (Texture)) /= SDL.Success then raise SDL_GL_Error with "Cannot unbind texture, unsupported operation in this context."; end if; end Unbind_Texture; function Get_Sub_Program (Name : in String) return Access_To_Sub_Program is function SDL_GL_Get_Proc_Address (P : in C.Strings.chars_ptr) return Access_To_Sub_Program with Import => True, Convention => C, External_Name => "SDL_GL_GetProcAddress"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Sub_Program : Access_To_Sub_Program := SDL_GL_Get_Proc_Address (C_Name_Str); begin C.Strings.Free (C_Name_Str); return Sub_Program; end Get_Sub_Program; function Supports (Extension : in String) return Boolean is function SDL_GL_Extension_Supported (E : in C.Strings.chars_ptr) return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_GL_ExtensionSupported"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Extension); Result : SDL_Bool := SDL_GL_Extension_Supported (C_Name_Str); begin C.Strings.Free (C_Name_Str); return (Result = SDL_True); end Supports; function Get_Swap_Interval return Swap_Intervals is function SDL_GL_Get_Swap_Interval return Swap_Intervals with Import => True, Convention => C, External_Name => "SDL_GL_GetSwapInterval"; begin return SDL_GL_Get_Swap_Interval; end Get_Swap_Interval; function Set_Swap_Interval (Interval : in Allowed_Swap_Intervals; Late_Swap_Tear : in Boolean) return Boolean is function SDL_GL_Set_Swap_Interval (Interval : in Swap_Intervals) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_SetSwapInterval"; Late_Tearing : Swap_Intervals renames Not_Supported; Result : C.int; begin if Late_Swap_Tear then -- Override the interval passed. Result := SDL_GL_Set_Swap_Interval (Late_Tearing); if Result = -1 then -- Try again with synchronised. Result := SDL_GL_Set_Swap_Interval (Synchronised); return (if Result = -1 then False else True); elsif Result = Success then return True; else raise SDL_GL_Error with "Something unexpected happend whilst setting swap interval."; end if; end if; Result := SDL_GL_Set_Swap_Interval (Synchronised); return (if Result = -1 then False else True); end Set_Swap_Interval; procedure Swap (Window : in out SDL.Video.Windows.Window) is procedure SDL_GL_Swap_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_GL_SwapWindow"; begin SDL_GL_Swap_Window (Get_Internal_Window (Window)); end Swap; procedure Load_Library (Path : in String) is function SDL_GL_Load_Library (P : in C.Strings.chars_ptr) return C.int with Import => True, Convention => C, External_Name => "SDL_GL_LoadLibrary"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Path); Result : C.int := SDL_GL_Load_Library (C_Name_Str); begin C.Strings.Free (C_Name_Str); if Result /= SDL.Success then raise SDL_GL_Error with "Unable to load OpenGL library """ & Path & '"'; end if; end Load_Library; procedure Unload_Library is procedure SDL_GL_Unload_Library with Import => True, Convention => C, External_Name => "SDL_GL_UnloadLibrary"; begin SDL_GL_Unload_Library; end Unload_Library; end SDL.Video.GL;
reznikmm/matreshka
Ada
3,727
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package AMF3.Slots.Integers is pragma Preelaborate; type Integer_Slot is new Abstract_Slot with private; private type Integer_Value is array (Boolean) of Integer; type Integer_Slot is new Abstract_Slot with record Value : Integer_Value; end record; overriding function Get (Self : Integer_Slot) return League.Holders.Holder; end AMF3.Slots.Integers;
reznikmm/matreshka
Ada
3,754
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Layout_Grid_Print_Attributes is pragma Preelaborate; type ODF_Style_Layout_Grid_Print_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Layout_Grid_Print_Attribute_Access is access all ODF_Style_Layout_Grid_Print_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Layout_Grid_Print_Attributes;
MinimSecure/unum-sdk
Ada
868
adb
-- Copyright 2015-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Reprod; use Reprod; procedure Reprod_Main is O : Obj_T (Len => 1); begin O.Data := (others => (I => 1)); Do_Nothing (O); end Reprod_Main;
jorge-real/TTS-Runtime-Ravenscar
Ada
63
ads
package TTS_Example_A is procedure Main; end TTS_Example_A;
AdaCore/Ada_Drivers_Library
Ada
2,694
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- Root package for the drivers of the STM32 family of MCU pragma Warnings (Off); with Interfaces; use Interfaces; with HAL; use HAL; pragma Warnings (On); package STM32 is pragma Pure; type GPIO_Alternate_Function is private; private type GPIO_Alternate_Function is new UInt4; end STM32;
stcarrez/ada-awa
Ada
1,752
ads
----------------------------------------------------------------------- -- awa-questions-modules-tests -- Unit tests for question service -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; package AWA.Questions.Modules.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with record Manager : AWA.Questions.Modules.Question_Module_Access; end record; -- Test creation of a question. procedure Test_Create_Question (T : in out Test); -- Test deletion of a question. procedure Test_Delete_Question (T : in out Test); -- Test list of questions. procedure Test_List_Questions (T : in out Test); -- Test anonymous user voting for a question. procedure Test_Question_Vote_Anonymous (T : in out Test); -- Test voting for a question. procedure Test_Question_Vote (T : in out Test); private -- Do a vote on a question through the question vote bean. procedure Do_Vote (T : in out Test); end AWA.Questions.Modules.Tests;
burratoo/Acton
Ada
1,104
ads
------------------------------------------------------------------------------------------ -- -- -- OAK CORE SUPPORT PACKAGE -- -- FREESCALE e200 -- -- -- -- OAK.CORE_SUPPORT_PACKAGE.PROCESSOR -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with Oak.Agent; use Oak.Agent; package Oak.Core_Support_Package.Processor with Pure is function Proccessor_Id return Kernel_Id with Inline_Always; end Oak.Core_Support_Package.Processor;
Fabien-Chouteau/samd51-hal
Ada
12,636
adb
-- Generated by a script from an "avr tools device file" (atdf) with HAL; use HAL; with System; package body SAM.Main_Clock is Base_Address : constant := 16#40000800#; AHBMASK : UInt32 with Volatile, Address => System'To_Address (Base_Address + 16#10#); APBAMASK : UInt32 with Volatile, Address => System'To_Address (Base_Address + 16#14#); APBBMASK : UInt32 with Volatile, Address => System'To_Address (Base_Address + 16#18#); APBCMASK : UInt32 with Volatile, Address => System'To_Address (Base_Address + 16#1C#); APBDMASK : UInt32 with Volatile, Address => System'To_Address (Base_Address + 16#20#); -- HPB0 -- procedure HPB0_On is begin AHBMASK := AHBMASK or 16#1#; end HPB0_On; procedure HPB0_Off is begin AHBMASK := AHBMASK and not 16#1#; end HPB0_Off; -- HPB1 -- procedure HPB1_On is begin AHBMASK := AHBMASK or 16#2#; end HPB1_On; procedure HPB1_Off is begin AHBMASK := AHBMASK and not 16#2#; end HPB1_Off; -- HPB2 -- procedure HPB2_On is begin AHBMASK := AHBMASK or 16#4#; end HPB2_On; procedure HPB2_Off is begin AHBMASK := AHBMASK and not 16#4#; end HPB2_Off; -- HPB3 -- procedure HPB3_On is begin AHBMASK := AHBMASK or 16#8#; end HPB3_On; procedure HPB3_Off is begin AHBMASK := AHBMASK and not 16#8#; end HPB3_Off; -- DSU -- procedure DSU_On is begin AHBMASK := AHBMASK or 16#10#; APBBMASK := APBBMASK or 16#2#; end DSU_On; procedure DSU_Off is begin AHBMASK := AHBMASK and not 16#10#; APBBMASK := APBBMASK and not 16#2#; end DSU_Off; -- HMATRIX -- procedure HMATRIX_On is begin AHBMASK := AHBMASK or 16#20#; APBBMASK := APBBMASK or 16#40#; end HMATRIX_On; procedure HMATRIX_Off is begin AHBMASK := AHBMASK and not 16#20#; APBBMASK := APBBMASK and not 16#40#; end HMATRIX_Off; -- NVMCTRL -- procedure NVMCTRL_On is begin AHBMASK := AHBMASK or 16#40#; APBBMASK := APBBMASK or 16#4#; end NVMCTRL_On; procedure NVMCTRL_Off is begin AHBMASK := AHBMASK and not 16#40#; APBBMASK := APBBMASK and not 16#4#; end NVMCTRL_Off; -- HSRAM -- procedure HSRAM_On is begin AHBMASK := AHBMASK or 16#80#; end HSRAM_On; procedure HSRAM_Off is begin AHBMASK := AHBMASK and not 16#80#; end HSRAM_Off; -- CMCC -- procedure CMCC_On is begin AHBMASK := AHBMASK or 16#100#; end CMCC_On; procedure CMCC_Off is begin AHBMASK := AHBMASK and not 16#100#; end CMCC_Off; -- DMAC -- procedure DMAC_On is begin AHBMASK := AHBMASK or 16#200#; end DMAC_On; procedure DMAC_Off is begin AHBMASK := AHBMASK and not 16#200#; end DMAC_Off; -- USB -- procedure USB_On is begin AHBMASK := AHBMASK or 16#400#; APBBMASK := APBBMASK or 16#1#; end USB_On; procedure USB_Off is begin AHBMASK := AHBMASK and not 16#400#; APBBMASK := APBBMASK and not 16#1#; end USB_Off; -- BKUPRAM -- procedure BKUPRAM_On is begin AHBMASK := AHBMASK or 16#800#; end BKUPRAM_On; procedure BKUPRAM_Off is begin AHBMASK := AHBMASK and not 16#800#; end BKUPRAM_Off; -- PAC -- procedure PAC_On is begin AHBMASK := AHBMASK or 16#1000#; APBAMASK := APBAMASK or 16#1#; end PAC_On; procedure PAC_Off is begin AHBMASK := AHBMASK and not 16#1000#; APBAMASK := APBAMASK and not 16#1#; end PAC_Off; -- QSPI -- procedure QSPI_On is begin AHBMASK := AHBMASK or 16#2000#; APBCMASK := APBCMASK or 16#2000#; end QSPI_On; procedure QSPI_Off is begin AHBMASK := AHBMASK and not 16#2000#; APBCMASK := APBCMASK and not 16#2000#; end QSPI_Off; -- SDHC0 -- procedure SDHC0_On is begin AHBMASK := AHBMASK or 16#8000#; end SDHC0_On; procedure SDHC0_Off is begin AHBMASK := AHBMASK and not 16#8000#; end SDHC0_Off; -- ICM -- procedure ICM_On is begin AHBMASK := AHBMASK or 16#80000#; APBCMASK := APBCMASK or 16#800#; end ICM_On; procedure ICM_Off is begin AHBMASK := AHBMASK and not 16#80000#; APBCMASK := APBCMASK and not 16#800#; end ICM_Off; -- PUKCC -- procedure PUKCC_On is begin AHBMASK := AHBMASK or 16#100000#; end PUKCC_On; procedure PUKCC_Off is begin AHBMASK := AHBMASK and not 16#100000#; end PUKCC_Off; -- QSPI_2X -- procedure QSPI_2X_On is begin AHBMASK := AHBMASK or 16#200000#; end QSPI_2X_On; procedure QSPI_2X_Off is begin AHBMASK := AHBMASK and not 16#200000#; end QSPI_2X_Off; -- NVMCTRL_SMEEPROM -- procedure NVMCTRL_SMEEPROM_On is begin AHBMASK := AHBMASK or 16#400000#; end NVMCTRL_SMEEPROM_On; procedure NVMCTRL_SMEEPROM_Off is begin AHBMASK := AHBMASK and not 16#400000#; end NVMCTRL_SMEEPROM_Off; -- NVMCTRL_CACHE -- procedure NVMCTRL_CACHE_On is begin AHBMASK := AHBMASK or 16#800000#; end NVMCTRL_CACHE_On; procedure NVMCTRL_CACHE_Off is begin AHBMASK := AHBMASK and not 16#800000#; end NVMCTRL_CACHE_Off; -- PM -- procedure PM_On is begin APBAMASK := APBAMASK or 16#2#; end PM_On; procedure PM_Off is begin APBAMASK := APBAMASK and not 16#2#; end PM_Off; -- MCLK -- procedure MCLK_On is begin APBAMASK := APBAMASK or 16#4#; end MCLK_On; procedure MCLK_Off is begin APBAMASK := APBAMASK and not 16#4#; end MCLK_Off; -- RSTC -- procedure RSTC_On is begin APBAMASK := APBAMASK or 16#8#; end RSTC_On; procedure RSTC_Off is begin APBAMASK := APBAMASK and not 16#8#; end RSTC_Off; -- OSCCTRL -- procedure OSCCTRL_On is begin APBAMASK := APBAMASK or 16#10#; end OSCCTRL_On; procedure OSCCTRL_Off is begin APBAMASK := APBAMASK and not 16#10#; end OSCCTRL_Off; -- OSC32KCTRL -- procedure OSC32KCTRL_On is begin APBAMASK := APBAMASK or 16#20#; end OSC32KCTRL_On; procedure OSC32KCTRL_Off is begin APBAMASK := APBAMASK and not 16#20#; end OSC32KCTRL_Off; -- SUPC -- procedure SUPC_On is begin APBAMASK := APBAMASK or 16#40#; end SUPC_On; procedure SUPC_Off is begin APBAMASK := APBAMASK and not 16#40#; end SUPC_Off; -- GCLK -- procedure GCLK_On is begin APBAMASK := APBAMASK or 16#80#; end GCLK_On; procedure GCLK_Off is begin APBAMASK := APBAMASK and not 16#80#; end GCLK_Off; -- WDT -- procedure WDT_On is begin APBAMASK := APBAMASK or 16#100#; end WDT_On; procedure WDT_Off is begin APBAMASK := APBAMASK and not 16#100#; end WDT_Off; -- RTC -- procedure RTC_On is begin APBAMASK := APBAMASK or 16#200#; end RTC_On; procedure RTC_Off is begin APBAMASK := APBAMASK and not 16#200#; end RTC_Off; -- EIC -- procedure EIC_On is begin APBAMASK := APBAMASK or 16#400#; end EIC_On; procedure EIC_Off is begin APBAMASK := APBAMASK and not 16#400#; end EIC_Off; -- FREQM -- procedure FREQM_On is begin APBAMASK := APBAMASK or 16#800#; end FREQM_On; procedure FREQM_Off is begin APBAMASK := APBAMASK and not 16#800#; end FREQM_Off; -- SERCOM0 -- procedure SERCOM0_On is begin APBAMASK := APBAMASK or 16#1000#; end SERCOM0_On; procedure SERCOM0_Off is begin APBAMASK := APBAMASK and not 16#1000#; end SERCOM0_Off; -- SERCOM1 -- procedure SERCOM1_On is begin APBAMASK := APBAMASK or 16#2000#; end SERCOM1_On; procedure SERCOM1_Off is begin APBAMASK := APBAMASK and not 16#2000#; end SERCOM1_Off; -- TC0 -- procedure TC0_On is begin APBAMASK := APBAMASK or 16#4000#; end TC0_On; procedure TC0_Off is begin APBAMASK := APBAMASK and not 16#4000#; end TC0_Off; -- TC1 -- procedure TC1_On is begin APBAMASK := APBAMASK or 16#8000#; end TC1_On; procedure TC1_Off is begin APBAMASK := APBAMASK and not 16#8000#; end TC1_Off; -- PORT -- procedure PORT_On is begin APBBMASK := APBBMASK or 16#10#; end PORT_On; procedure PORT_Off is begin APBBMASK := APBBMASK and not 16#10#; end PORT_Off; -- EVSYS -- procedure EVSYS_On is begin APBBMASK := APBBMASK or 16#80#; end EVSYS_On; procedure EVSYS_Off is begin APBBMASK := APBBMASK and not 16#80#; end EVSYS_Off; -- SERCOM2 -- procedure SERCOM2_On is begin APBBMASK := APBBMASK or 16#200#; end SERCOM2_On; procedure SERCOM2_Off is begin APBBMASK := APBBMASK and not 16#200#; end SERCOM2_Off; -- SERCOM3 -- procedure SERCOM3_On is begin APBBMASK := APBBMASK or 16#400#; end SERCOM3_On; procedure SERCOM3_Off is begin APBBMASK := APBBMASK and not 16#400#; end SERCOM3_Off; -- TCC0 -- procedure TCC0_On is begin APBBMASK := APBBMASK or 16#800#; end TCC0_On; procedure TCC0_Off is begin APBBMASK := APBBMASK and not 16#800#; end TCC0_Off; -- TCC1 -- procedure TCC1_On is begin APBBMASK := APBBMASK or 16#1000#; end TCC1_On; procedure TCC1_Off is begin APBBMASK := APBBMASK and not 16#1000#; end TCC1_Off; -- TC2 -- procedure TC2_On is begin APBBMASK := APBBMASK or 16#2000#; end TC2_On; procedure TC2_Off is begin APBBMASK := APBBMASK and not 16#2000#; end TC2_Off; -- TC3 -- procedure TC3_On is begin APBBMASK := APBBMASK or 16#4000#; end TC3_On; procedure TC3_Off is begin APBBMASK := APBBMASK and not 16#4000#; end TC3_Off; -- RAMECC -- procedure RAMECC_On is begin APBBMASK := APBBMASK or 16#10000#; end RAMECC_On; procedure RAMECC_Off is begin APBBMASK := APBBMASK and not 16#10000#; end RAMECC_Off; -- TCC2 -- procedure TCC2_On is begin APBCMASK := APBCMASK or 16#8#; end TCC2_On; procedure TCC2_Off is begin APBCMASK := APBCMASK and not 16#8#; end TCC2_Off; -- PDEC -- procedure PDEC_On is begin APBCMASK := APBCMASK or 16#80#; end PDEC_On; procedure PDEC_Off is begin APBCMASK := APBCMASK and not 16#80#; end PDEC_Off; -- AC -- procedure AC_On is begin APBCMASK := APBCMASK or 16#100#; end AC_On; procedure AC_Off is begin APBCMASK := APBCMASK and not 16#100#; end AC_Off; -- AES -- procedure AES_On is begin APBCMASK := APBCMASK or 16#200#; end AES_On; procedure AES_Off is begin APBCMASK := APBCMASK and not 16#200#; end AES_Off; -- TRNG -- procedure TRNG_On is begin APBCMASK := APBCMASK or 16#400#; end TRNG_On; procedure TRNG_Off is begin APBCMASK := APBCMASK and not 16#400#; end TRNG_Off; -- CCL -- procedure CCL_On is begin APBCMASK := APBCMASK or 16#4000#; end CCL_On; procedure CCL_Off is begin APBCMASK := APBCMASK and not 16#4000#; end CCL_Off; -- SERCOM4 -- procedure SERCOM4_On is begin APBDMASK := APBDMASK or 16#1#; end SERCOM4_On; procedure SERCOM4_Off is begin APBDMASK := APBDMASK and not 16#1#; end SERCOM4_Off; -- SERCOM5 -- procedure SERCOM5_On is begin APBDMASK := APBDMASK or 16#2#; end SERCOM5_On; procedure SERCOM5_Off is begin APBDMASK := APBDMASK and not 16#2#; end SERCOM5_Off; -- ADC0 -- procedure ADC0_On is begin APBDMASK := APBDMASK or 16#80#; end ADC0_On; procedure ADC0_Off is begin APBDMASK := APBDMASK and not 16#80#; end ADC0_Off; -- ADC1 -- procedure ADC1_On is begin APBDMASK := APBDMASK or 16#100#; end ADC1_On; procedure ADC1_Off is begin APBDMASK := APBDMASK and not 16#100#; end ADC1_Off; -- DAC -- procedure DAC_On is begin APBDMASK := APBDMASK or 16#200#; end DAC_On; procedure DAC_Off is begin APBDMASK := APBDMASK and not 16#200#; end DAC_Off; -- PCC -- procedure PCC_On is begin APBDMASK := APBDMASK or 16#800#; end PCC_On; procedure PCC_Off is begin APBDMASK := APBDMASK and not 16#800#; end PCC_Off; end SAM.Main_Clock;
jscparker/math_packages
Ada
5,824
adb
-- Simple test of "*", "/", "+", and "-" using random arguments. -- Doesn't test endpoints very well. with Extended_Real; with Extended_Real.e_Rand; with Extended_Real.IO; with Text_IO; use Text_IO; procedure e_real_io_tst_2 is type Real is digits 15; package ext is new Extended_Real (Real); use ext; package eio is new ext.IO; use eio; package rnd is new ext.e_Rand; use rnd; package rio is new Text_IO.Float_IO(Real); use rio; package iio is new Text_IO.Integer_IO(e_Integer); use iio; X, Z1 : e_Real; Last : Integer; Max_Error, Err : e_Real; Exp_First, Exp_Last : e_Integer; type Integer32 is range -2**31+1..2**31-1; Mult_Limit : constant Integer32 := 8_000_000; -- usually > N * 10^6 -- Number of iterations of multiplication div test. The +/- tests -- are 8 times this numbers. Some_Seed : constant Integer := 7251738; -- Start at different rand stream. -------------------- -- Get_Random_Exp -- -------------------- -- Make Random e_Integer in range Exp_First..Exp_Last -- function Random_Exp (Exp_First : in e_Integer; Exp_Last : in e_Integer) return e_Integer is Exp : e_Integer; X : Real; begin -- returns random Real in range [0, 1): --X := Real (rnd.Next_Random_Int mod 2**12) * 2.0**(-12); -- returns random Real in range (0, 1]: X := Real (1 + rnd.Next_Random_Int mod 2**24) * 2.0**(-24); Exp := Exp_First + e_Integer (X * (Real (Exp_Last) - Real (Exp_First))); return Exp; end; ------------- -- Get_999 -- ------------- -- Make an e_real full of digits that have the max value that any -- any digit can have. -- function Get_999 return e_Real is Max_Digit : constant e_Digit := Make_e_Digit (e_Real_Machine_Radix-1.0); Next_Digit : e_Digit; Delta_Exp : e_Integer; Result : e_Real; -- Init to 0 important begin for I in 0 .. e_Real_Machine_Mantissa-1 loop Delta_Exp := -I - 1; Next_Digit := Scaling (Max_Digit, Delta_Exp); Result := Next_Digit + Result; end loop; return Result; end; ---------------------------------- -- Print_Extended_Real_Settings -- ---------------------------------- procedure Print_Extended_Real_Settings is Bits_In_Radix : constant := Desired_No_Of_Bits_In_Radix; begin new_line(1); put (" Desired_Decimal_Digit_Precision ="); put (Integer'Image(Desired_Decimal_Digit_Precision)); new_line(1); new_line(1); put ("Number of decimal digits of precision requested: "); put (Integer'Image(Desired_Decimal_Digit_Precision)); new_line(1); put ("Number of digits in use (including 2 guard digits): "); put (e_Integer'Image(e_Real_Machine_Mantissa)); new_line(1); put ("These digits are not decimal; they have Radix: 2**("); put (e_Integer'Image(Bits_In_Radix)); put(")"); new_line(1); put ("In other words, each of these digits is in range: 0 .. 2**("); put (e_Integer'Image(Bits_In_Radix)); put(")"); put (" - 1."); new_line(1); put ("Number of decimal digits per actual digit is approx: 9"); new_line(2); put("Guard digits (digits of extra precision) are appended to the end of"); new_line(1); put("each number. There are always 2 guard digits. This adds up to 18"); new_line(1); put("decimal digits of extra precision. The arithmetic operators, (""*"","); new_line(1); put("""/"", ""+"" etc) usually produce results that are correct to all"); new_line(1); put("digits except the final (guard) digit."); new_line(2); put("If a number is correct to all digits except the final (guard) digit,"); new_line(1); put("expect errors of the order:"); new_line(2); put(e_Real_Image (e_Real_Model_Epsilon / (One+One)**Bits_In_Radix, aft => 10)); new_line(2); put("If you lose 2 digits of accuracy (i.e. both guard digits) instead"); new_line(1); put("of 1 (as in the above case) then you lose another 9 decimal digits"); new_line(1); put("of accuracy. In this case expect errors of the order:"); new_line(2); put(e_Real_Image (e_Real_Model_Epsilon, aft => 10)); new_line(2); put("The above number, by the way, is e_Real_Model_Epsilon."); new_line(3); end Print_Extended_Real_Settings; begin rnd.Reset (Some_Seed); Print_Extended_Real_Settings; put ("The test translates binary to text, then back to binary, and prints"); new_line(1); put ("the difference: prints X - e_Real_Val (e_Real_Image (X)) over randomly"); new_line(1); put ("generated X's. 8_000_000 X's are used, and the max error is printed."); new_line(1); put ("The testing goes on for as many hours as you let it:"); new_line(2); for repetitions in 1 .. 1_000_000 loop Exp_First := e_Real_Machine_Emin+1; -- cause X has exp of -1 intitially. Exp_Last := e_Real_Machine_Emax-1; -- The random num we make by scaling with Exp in [Exp_First, Exp_Last] -- The function Random returns a rand in the range [0.0 .. 1.0). -- The smallest exp of Random is Max_Available_Digits - 1. Max_Error := Zero; for I in Integer32 range 1 .. Mult_Limit loop X := Random * Get_999; X := Scaling (X, Random_Exp (Exp_First, Exp_Last)); e_Real_Val (e_Real_Image (X), Z1, Last); Err := (Z1/X - One); if Err > Max_Error then Max_Error := Err; end if; end loop; new_line; put ("Max Error ="); put (e_Real_Image (Max_Error)); end loop; end;
Rodeo-McCabe/orka
Ada
1,853
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.SIMD.SSE.Singles; with Orka.SIMD.AVX.Singles; package Orka.SIMD.FMA.Singles.Arithmetic is pragma Pure; use SSE.Singles; use AVX.Singles; function Multiply_Add (A, B, C : m128) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddps"; function Multiply_Add_Sub (A, B, C : m128) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddsubps"; function Multiply_Add (A, B, C : m256) return m256 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddps256"; function Multiply_Add_Sub (A, B, C : m256) return m256 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddsubps256"; function "*" (Left, Right : m128_Array) return m128_Array with Inline; -- Multiplies the left matrix with the right matrix. Matrix multiplication -- is associative, but not commutative. function "*" (Left : m128_Array; Right : m128) return m128 with Inline; -- Multiplies the left matrix with the right vector. Matrix multiplication -- is associative, but not commutative. end Orka.SIMD.FMA.Singles.Arithmetic;
jhumphry/LALG
Ada
8,759
adb
-- LALG -- An Ada 2012 binding to BLAS and other linear algebra routines -- Unit tests for Level 1 BLAS routines -- Copyright (c) 2015-2021, James Humphry - see LICENSE file for details -- SPDX-License-Identifier: ISC with AUnit.Assertions; use AUnit.Assertions; package body BLAS_Real_Level1 is -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T : in out Level1_Test) is use AUnit.Test_Cases.Registration; begin for I of Test_Details_List loop Register_Routine(T, I.T, To_String(I.D)); end loop; end Register_Tests; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out Level1_Test) is begin null; end Set_Up; --------------- -- Check_Rot -- --------------- procedure Check_Rot (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); A : constant Concrete_Real_Matrix := Make(( (6.0, 5.0, 0.0), (5.0, 1.0, 4.0), (0.0, 4.0, 3.0) )); a1, b1 : Real; c, s : Real; begin a1 := A(1,1); b1 := A(2,1); rotg(a1, b1, c, s); Assert(abs(a1 - 7.810249675906654) <= Soft_Epsilon, "Givens rotation r not set correctly"); Assert(abs(c - 0.76822127959737585) <= Soft_Epsilon, "Givens rotation c not set correctly"); Assert(abs(s - 0.64018439966447993) <= Soft_Epsilon, "Givens rotation s not set correctly"); -- TODO : test rot routine once high-precision result is available -- rot(R1, R2, c, s); -- Assert(Approx_Equal(A, Expected_Result, Soft_Epsilon), "Givens rotation not applied correctly"); end Check_Rot; ---------------- -- Check_Rotm -- ---------------- procedure Check_Rotm (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); A : Concrete_Real_Matrix := Make(((6.0, 5.0, 0.0), (5.0, 1.0, 4.0), (0.0, 4.0, 3.0))); R1 : Real_Matrix_Vector := A.Row(1); R2 : Real_Matrix_Vector := A.Row(2); a1, b1, d1, d2 : Real; Params : Modified_Givens_Params; begin d1 := 0.707; d2 := 0.707; a1 := A(1,1); b1 := A(2,1); rotmg(d1, d2, a1, b1, Params); rotm(R1, R2, Params); Assert(abs(A(2,1))<Epsilon, "Modified Givens rotation not applied correctly"); end Check_Rotm; ---------------- -- Check_Swap -- ---------------- procedure Check_Swap (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : aliased Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); X2 : Real_Vector_View := Make(X'Access, Start => 2, Stride => 1, Length => 2); Y : aliased Concrete_Real_Vector := Make((4.0, 5.0, 6.0)); Y2 : Real_Vector_View := Make(Y'Access, Start => 1, Stride => 2, Length => 2); begin swap(X, Y); Assert(X = Real_1D_Array'(4.0, 5.0, 6.0), "X not swapped correctly."); Assert(Y = Real_1D_Array'(1.0, 2.0, 3.0), "Y not swapped correctly."); swap(X2, Y2); Assert(X = Real_1D_Array'(4.0, 1.0, 3.0), "X not swapped correctly via view."); Assert(Y = Real_1D_Array'(5.0, 2.0, 6.0), "Y not swapped correctly via view."); end Check_Swap; ---------------- -- Check_Scal -- ---------------- procedure Check_Scal (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : aliased Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); Y : Real_Vector_View := Make(X'Access, Start => 2, Stride => 1, Length => 2); begin Assert(X = Real_1D_Array'(1.0, 2.0, 3.0), "Vector equality"); Assert(Y = Real_1D_Array'(2.0, 3.0), "Vector equality on views"); scal(X, 1.0); Assert(X = Real_1D_Array'(1.0, 2.0, 3.0), "Scaling by 1.0"); Assert(Y = Real_1D_Array'(2.0, 3.0), "Scaling by 1.0 with views"); scal(X, -1.0); Assert(X = Real_1D_Array'(-1.0, -2.0, -3.0), "Scaling by -1.0"); scal(X, -2.0); Assert(X = Real_1D_Array'(2.0, 4.0, 6.0), "Scaling by -2.0"); scal(X, 100.0); Assert(X = Real_1D_Array'(200.0, 400.0, 600.0), "Scaling by 100.0"); Assert(Y = Real_1D_Array'(400.0, 600.0), "Scaling by 100.0 on views"); scal(Y, 0.25); Assert(X = Real_1D_Array'(200.0, 100.0, 150.0), "Scaling by 0.25 via viewsk"); Assert(Y = Real_1D_Array'(100.0, 150.0), "Scaling by 0.25 on views"); end Check_Scal; ---------------- -- Check_Copy -- ---------------- procedure Check_Copy (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : aliased Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); X2 : constant Real_Vector_View := Make(X'Access, Start => 2, Stride => 1, Length => 2); Y : aliased Concrete_Real_Vector := Make((4.0, 5.0, 6.0)); Y2 : Real_Vector_View := Make(Y'Access, Start => 1, Stride => 2, Length => 2); begin copy(X, Y); Assert(X = Real_1D_Array'(1.0, 2.0, 3.0), "X modified by a copy operation."); Assert(Y = Real_1D_Array'(1.0, 2.0, 3.0), "Y not copied correctly."); copy(X2, Y2); pragma Unreferenced(Y2); Assert(X = Real_1D_Array'(1.0, 2.0, 3.0), "X modified by a copy via view."); Assert(Y = Real_1D_Array'(2.0, 2.0, 3.0), "Y not copied correctly via view."); end Check_Copy; ---------------- -- Check_Axpy -- ---------------- procedure Check_Axpy (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : aliased Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); X2 : constant Real_Vector_View := Make(X'Access, Start => 2, Stride => 1, Length => 2); Y : aliased Concrete_Real_Vector := Make((4.0, 5.0, 6.0)); Y2 : Real_Vector_View := Make(Y'Access, Start => 1, Stride => 2, Length => 2); begin axpy(X, Y, 1.0); Assert(X = Real_1D_Array'(1.0, 2.0, 3.0), "X modified by an Y<-aX+Y op."); Assert(Y = Real_1D_Array'(5.0, 7.0, 9.0), "Y not correct following an Y<-aX+Y op."); axpy(X2, Y2, 2.0); Assert(X = Real_1D_Array'(1.0, 2.0, 3.0), "X modified by an Y<-aX+Y op via view."); Assert(Y = Real_1D_Array'(9.0, 7.0, 15.0), "Y not correct following an Y<-aX+Y op via view."); end Check_Axpy; ---------------------- -- Check_Dot_Sdsdot -- ---------------------- procedure Check_Dot_Sdsdot (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : aliased Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); X2 : constant Real_Vector_View := Make(X'Access, Start => 2, Stride => 1, Length => 2); Y : aliased Concrete_Real_Vector := Make((4.0, 5.0, 6.0)); Y2 : constant Real_Vector_View := Make(Y'Access, Start => 1, Stride => 2, Length => 2); begin Assert(dot(X, Y) = 32.0, "dot incorrect."); Assert(sdsdot(X, Y, 4.0) = 36.0, "sdsdot incorrect."); Assert(dot(X2, Y2) = 26.0, "dot incorrect applied to views."); Assert(sdsdot(X2, Y2, -4.0) = 22.0, "sdsdot incorrect applied to views."); end Check_Dot_Sdsdot; ---------------- -- Check_Nrm2 -- ---------------- procedure Check_Nrm2 (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : aliased Concrete_Real_Vector := Make((2.0, 3.0, 4.0)); X2 : constant Real_Vector_View := Make(X'Access, Start => 2, Stride => 1, Length => 2); begin Assert(abs(nrm2(X)-5.3851648071345037)<Soft_Epsilon, "Nrm2 incorrect."); Assert(abs(nrm2(X2)-5.0)<Soft_Epsilon, "Nrm2 incorrect applied to view."); end Check_Nrm2; ---------------- -- Check_Asum -- ---------------- procedure Check_Asum (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : constant Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); Y : constant Concrete_Real_Vector := Make((-4.0, 5.0, -6.0)); begin Assert(asum(X) = 6.0, "asum(X) not working"); Assert(asum(Y) = 15.0, "asum(Y) not working (not absolute values?)"); end Check_Asum; ----------------- -- Check_Iamax -- ----------------- procedure Check_Iamax (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); X : constant Concrete_Real_Vector := Make((1.0, 2.0, 3.0)); Y : aliased Concrete_Real_Vector := Make((4.0, -5.0, -6.0)); Y2 : constant Real_Vector_View := Make(Y'Access, Start => 1, Stride => 1, Length => 2); begin Assert(iamax(X) = 3, "iamax(X) not working"); Assert(iamax(Y) = 3, "iamax(Y) not working"); Assert(iamax(Y2) = 2, "iamax(Y2) not working on view"); end Check_Iamax; end BLAS_Real_Level1;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 1 2 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 12 package System.Pack_12 is pragma Preelaborate; Bits : constant := 12; type Bits_12 is mod 2 ** Bits; for Bits_12'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_12 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_12 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_12 (Arr : System.Address; N : Natural; E : Bits_12; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_12 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_12 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_12 (Arr : System.Address; N : Natural; E : Bits_12; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_12;
reznikmm/matreshka
Ada
1,770
ads
with League.Strings; use League.Strings; with league.Characters; use league.characters; with Matreshka.Opts.options; use Matreshka.Opts.options; with League.String_Vectors; use League.String_Vectors; with Matreshka.Opts.internal.application_options; use Matreshka.Opts.internal.application_options; with Matreshka.Opts.internal.available_options_maps; use Matreshka.Opts.internal.available_options_maps; package Matreshka.Opts.parsers is type parser is tagged limited private; type parser_access is access all parser; not overriding procedure Add_Option (Self : in out parser; Name : in Universal_String; Long : in Universal_String; Short : in Universal_Character; Help : in Universal_String; Required : in Boolean := False; Has_Value : in Boolean := False); -- Add new option to the list of available options not overriding function Has_Option (Self : in out parser; Name : in Universal_String) return Boolean; -- Returns true if option has been specified in command line not overriding function Get_Value (Self : in out Parser; Name : in Universal_String) return Universal_String; -- Returns value of the option (if option is valued) or -- empty_universal_string if not not overriding procedure Parse (Self : in out Parser; Option_List : in Universal_String_Vector); -- Parse command line (transformed to Option_List private type parser is tagged limited null record; option_list : available_options_map_access := new available_options_map; application_list : application_option_access := new application_option; end Matreshka.Opts.parsers;
reznikmm/gela
Ada
970
adb
with Gela.Int.Visiters; package body Gela.Int.Placeholders is ------------ -- Create -- ------------ function Create (Down : Gela.Interpretations.Interpretation_Index_Array; Kind : Gela.Interpretations.Placeholder_Kind) return Placeholder is begin return (Index => 0, Length => Down'Length, Placeholder_Kind => Kind, Down => Down); end Create; --------------------- -- Placeholder_Kind -- --------------------- function Placeholder_Kind (Self : Placeholder) return Gela.Interpretations.Placeholder_Kind is begin return Self.Placeholder_Kind; end Placeholder_Kind; ----------- -- Visit -- ----------- overriding procedure Visit (Self : Placeholder; Visiter : access Gela.Int.Visiters.Visiter'Class) is begin Visiter.Placeholder (Self); end Visit; end Gela.Int.Placeholders;
jrcarter/Ada_GUI
Ada
8,095
adb
-- -- -- package Strings_Edit Copyright (c) Dmitry A. Kazakov -- -- Implementation Luebeck -- -- Spring, 2000 -- -- -- -- Last revision : 10:24 26 Dec 2009 -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public License as -- -- published by the Free Software Foundation; either version 2 of -- -- the License, or (at your option) any later version. This library -- -- is distributed in the hope that it will be useful, but WITHOUT -- -- ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have -- -- received a copy of the GNU General Public License along with -- -- this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- --____________________________________________________________________-- with Ada.IO_Exceptions; use Ada.IO_Exceptions; package body Strings_Edit is function GetDigit (Symbol : Character) return Natural is begin case Symbol is when '0' => return 0; when '1' => return 1; when '2' => return 2; when '3' => return 3; when '4' => return 4; when '5' => return 5; when '6' => return 6; when '7' => return 7; when '8' => return 8; when '9' => return 9; when 'A' | 'a' => return 10; when 'B' | 'b' => return 11; when 'C' | 'c' => return 12; when 'D' | 'd' => return 13; when 'E' | 'e' => return 14; when 'F' | 'f' => return 15; when others => return 16; end case; end GetDigit; function Is_Prefix (Prefix, Source : String) return Boolean is begin return ( Prefix'Length = 0 or else ( Prefix'Length <= Source'Length and then ( Prefix = Source ( Source'First .. Source'First + Prefix'Length - 1 ) ) ) ); end Is_Prefix; function Is_Prefix (Prefix, Source : String; Pointer : Integer) return Boolean is begin return ( Pointer >= Source'First and then ( Pointer <= Source'Last or else Pointer = Source'Last + 1 ) and then Source'Last - Pointer + 1 >= Prefix'Length and then Prefix = Source (Pointer..Pointer + Prefix'Length - 1) ); end Is_Prefix; function Is_Prefix ( Prefix, Source : String; Map : Character_Mapping ) return Boolean is begin if Prefix'Length = 0 then return True; elsif Prefix'Length > Source'Length then return False; end if; declare J : Integer := Source'First; begin for I in Prefix'First..Prefix'Last - 1 loop if Value (Map, Prefix (I)) /= Value (Map, Source (J)) then return False; end if; J := J + 1; end loop; return Value (Map, Prefix (Prefix'Last)) = Value (Map, Source (J)); end; end Is_Prefix; function Is_Prefix ( Prefix, Source : String; Pointer : Integer; Map : Character_Mapping ) return Boolean is begin if ( Pointer < Source'First or else ( Pointer > Source'Last and then Pointer /= Source'Last + 1 ) or else Source'Last - Pointer + 1 < Prefix'Length ) then return False; end if; declare J : Integer := Pointer; begin for I in Prefix'First..Prefix'Last - 1 loop if Value (Map, Prefix (I)) /= Value (Map, Source (J)) then return False; end if; J := J + 1; end loop; return Value (Map, Prefix (Prefix'Last)) = Value (Map, Source (J)); end; end Is_Prefix; -- -- Text_Edit -- -- This is an internal package containing implementation of all text -- editing subprograms. -- package Text_Edit is function TrimCharacter ( Source : String; Blank : Character := ' ' ) return String; function TrimSet ( Source : String; Blanks : Character_Set ) return String; procedure GetCharacter ( Source : String; Pointer : in out Integer; Blank : Character := ' ' ); procedure GetSet ( Source : String; Pointer : in out Integer; Blanks : Character_Set ); procedure PutString ( Destination : in out String; Pointer : in out Integer; Value : String; Field : Natural := 0; Justify : Alignment := Left; Fill : Character := ' ' ); procedure PutCharacter ( Destination : in out String; Pointer : in out Integer; Value : Character; Field : Natural := 0; Justify : Alignment := Left; Fill : Character := ' ' ); end Text_Edit; package body Text_Edit is separate; function Trim ( Source : String; Blank : Character := ' ' ) return String renames Text_Edit.TrimCharacter; function Trim ( Source : String; Blanks : Character_Set ) return String renames Text_Edit.TrimSet; procedure Get ( Source : String; Pointer : in out Integer; Blank : Character := ' ' ) renames Text_Edit.GetCharacter; procedure Get ( Source : String; Pointer : in out Integer; Blanks : Character_Set ) renames Text_Edit.GetSet; procedure Put ( Destination : in out String; Pointer : in out Integer; Value : String; Field : Natural := 0; Justify : Alignment := Left; Fill : Character := ' ' ) renames Text_Edit.PutString; procedure Put ( Destination : in out String; Pointer : in out Integer; Value : Character; Field : Natural := 0; Justify : Alignment := Left; Fill : Character := ' ' ) renames Text_Edit.PutCharacter; end Strings_Edit;
damaki/SPARKNaCl
Ada
6,591
adb
with SPARKNaCl.PDebug; with SPARKNaCl.Debug; with SPARKNaCl.Utils; with SPARKNaCl.Car; with Ada.Text_IO; use Ada.Text_IO; package body SPARKNaCl.Tests is GF_2 : constant Normal_GF := (2, others => 0); P : constant Normal_GF := (0 => 16#FFED#, 15 => 16#7FFF#, others => 16#FFFF#); P_Minus_1 : constant Normal_GF := (0 => 16#FFEC#, 15 => 16#7FFF#, others => 16#FFFF#); P_Plus_1 : constant Normal_GF := (0 => 16#FFEE#, 15 => 16#7FFF#, others => 16#FFFF#); procedure GF_Stress is A, B, C : Normal_GF; C2 : GF32; D : Product_GF; begin Put_Line ("GF_Stress case 1 - 0 * 0"); A := (others => 0); B := (others => 0); C := A * B; PDebug.DH16 ("Result is", C); Put_Line ("GF_Stress case 2 - FFFF * FFFF"); A := (others => 16#FFFF#); B := (others => 16#FFFF#); C := A * B; PDebug.DH16 ("Result is", C); Put_Line ("GF_Stress case 3 - Seminormal Product GF Max"); D := (0 => 132_051_011, others => 16#FFFF#); C2 := Car.Product_To_Seminormal (D); PDebug.DH32 ("Result is", C2); Put_Line ("GF_Stress case 4 - Seminormal Product tricky case"); D := (0 => 131_071, others => 16#FFFF#); C2 := Car.Product_To_Seminormal (D); PDebug.DH32 ("Result is", C2); end GF_Stress; procedure Car_Stress is A : GF64; C : Product_GF; SN : Seminormal_GF; NGF : Nearlynormal_GF; R : Normal_GF; begin -- Case 1 - using typed API A := (0 .. 14 => 65535, 15 => 65535 + 2**32); PDebug.DH64 ("Case 1 - A is", A); SN := Car.Product_To_Seminormal (A); PDebug.DH32 ("Case 1 - SN is", SN); NGF := Car.Seminormal_To_Nearlynormal (SN); PDebug.DH32 ("Case 1 - NGF is", NGF); R := Car.Nearlynormal_To_Normal (NGF); PDebug.DH16 ("Case 1 - R is", R); -- Case 2 Upper bounds on all limbs of a Product_GF C := (0 => MGFLC * MGFLP, 1 => (MGFLC - 37 * 1) * MGFLP, 2 => (MGFLC - 37 * 2) * MGFLP, 3 => (MGFLC - 37 * 3) * MGFLP, 4 => (MGFLC - 37 * 4) * MGFLP, 5 => (MGFLC - 37 * 5) * MGFLP, 6 => (MGFLC - 37 * 6) * MGFLP, 7 => (MGFLC - 37 * 7) * MGFLP, 8 => (MGFLC - 37 * 8) * MGFLP, 9 => (MGFLC - 37 * 9) * MGFLP, 10 => (MGFLC - 37 * 10) * MGFLP, 11 => (MGFLC - 37 * 11) * MGFLP, 12 => (MGFLC - 37 * 12) * MGFLP, 13 => (MGFLC - 37 * 13) * MGFLP, 14 => (MGFLC - 37 * 14) * MGFLP, 15 => (MGFLC - 37 * 15) * MGFLP); PDebug.DH64 ("Case 2 - C is", C); SN := Car.Product_To_Seminormal (C); PDebug.DH32 ("Case 2 - SN is", SN); NGF := Car.Seminormal_To_Nearlynormal (SN); PDebug.DH32 ("Case 2 - NGF is", NGF); R := Car.Nearlynormal_To_Normal (NGF); PDebug.DH16 ("Case 2 - R is", R); -- Intermediate (pre-normalization) result of -- Square (Normal_GF'(others => 16#FFFF)) A := (16#23AFB8A023B#, 16#215FBD40216#, 16#1F0FC1E01F1#, 16#1CBFC6801CC#, 16#1A6FCB201A7#, 16#181FCFC0182#, 16#15CFD46015D#, 16#137FD900138#, 16#112FDDA0113#, 16#EDFE2400EE#, 16#C8FE6E00C9#, 16#A3FEB800A4#, 16#7EFF02007F#, 16#59FF4C005A#, 16#34FF960035#, 16#FFFE00010#); PDebug.DH64 ("Case 3 - A is", A); SN := Car.Product_To_Seminormal (A); PDebug.DH32 ("Case 3 - SN is", SN); NGF := Car.Seminormal_To_Nearlynormal (SN); PDebug.DH32 ("Case 3 - NGF is", NGF); R := Car.Nearlynormal_To_Normal (NGF); PDebug.DH16 ("Case 3 - R is", R); end Car_Stress; procedure Diff_Car_Stress is C : Nearlynormal_GF; R : Normal_GF; begin C := (others => 0); PDebug.DH32 ("Case 1 - C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 1 - R is", R); C := (others => 16#ffff#); PDebug.DH32 ("Case 2 - C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 2 - R is", R); for I in I32 range 65536 .. 65573 loop C (0) := I; PDebug.DH32 ("Case 3," & I'Img & " C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 3 - R is", R); end loop; C := (others => 0); for I in I32 range -38 .. -1 loop C (0) := I; PDebug.DH32 ("Case 4," & I'Img & " C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 4 - R is", R); end loop; end Diff_Car_Stress; procedure Pack_Stress is A : Normal_GF; R : Bytes_32; Two_P : constant Normal_GF := P * GF_2; Two_P_Minus_1 : constant Normal_GF := Two_P - GF_1; Two_P_Plus_1 : constant Normal_GF := Two_P + GF_1; begin A := (others => 0); PDebug.DH16 ("Pack Stress - Case 1 - A is", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 1 - R is", R); A := (others => 65535); PDebug.DH16 ("Pack Stress - Case 2 - A is", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 2 - R is", R); A := P; PDebug.DH16 ("Pack Stress - Case 3 - A is P", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 3 - R is", R); A := P_Minus_1; PDebug.DH16 ("Pack Stress - Case 4 - A is P_Minus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 4 - R is", R); A := P_Plus_1; PDebug.DH16 ("Pack Stress - Case 5 - A is P_Plus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 5 - R is", R); A := Two_P; PDebug.DH16 ("Pack Stress - Case 6 - A is Two_P", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 6 - R is", R); A := Two_P_Minus_1; PDebug.DH16 ("Pack Stress - Case 7 - A is Two_P_Minus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 7 - R is", R); A := Two_P_Plus_1; PDebug.DH16 ("Pack Stress - Case 8 - A is Two_P_Plus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 8 - R is", R); end Pack_Stress; end SPARKNaCl.Tests;
msrLi/portingSources
Ada
799
ads
-- Copyright 2011-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is task Dummy_Task is entry Start; end Dummy_Task; end Pck;
reznikmm/gela
Ada
798
adb
package body String_Sources is -------------- -- Get_Next -- -------------- overriding function Get_Next (Self : not null access String_Source) return Abstract_Sources.Code_Unit_32 is begin if Self.Cursor.Has_Element then return Result : Abstract_Sources.Code_Unit_32 do Result := Wide_Wide_Character'Pos (Self.Cursor.Element); Self.Cursor.Next; end return; else return Abstract_Sources.End_Of_Input; end if; end Get_Next; ------------ -- Create -- ------------ procedure Create (Self : out String_Source; Text : League.Strings.Universal_String) is begin Self.Text := Text; Self.Cursor.First (Self.Text); end Create; end String_Sources;
fnarenji/BoiteMaker
Ada
2,214
ads
generic type element_t is private; package generic_linked_list is -- Exception levée en l'absence de noeud no_node : exception; -- Forward declaration du type node_t -- car celui contient de pointeur de son type -- et qu'on souhaite utiliser l'alias node_ptr type node_t is private; -- Déclaration du type pointeur vers node_t type node_ptr is access node_t; -- Créer une liste chaine avec un élément -- Renvoie le noeud de la chaine crée -- ATTENTION: destroy la liste une fois son utilisation terminée -- sinon risque de fuite mémoire function create(element : element_t) return node_ptr; -- Ajoute un élément à la fin de la liste chainée function add_after(node : node_ptr; element : element_t) return node_ptr; procedure add_after(node : node_ptr; element : element_t); -- Retire l'élement suivant l'élément passé en -- paramètre de la liste chainée -- Exception: no_node si aucun noeud suivant procedure remove_next(node : node_ptr); -- Indique si la liste contient un élément suivant function has_next(node : node_ptr) return boolean; -- Avance au noeud suivant -- Exception: no_node si aucun noeud suivant function move_next(node : node_ptr) return node_ptr; -- Renvoie l'élément porté par le noeud function elem(node : node_ptr) return element_t; -- Détruit la liste (noeud courrant & noeuds suivants) -- Les noeuds avant le noeud passé en paramètre sont ignorés procedure destroy(node : in out node_ptr); -- Définit un pointeur de fonction pour une fonction to_string sur element_t type to_string_function_t is access function (elem : element_t) return string; -- Donne une représentation textuelle de la liste (chacun des éléments) function to_string(node : node_ptr; to_string : to_string_function_t) return string; private -- Implémentation du type node_t -- privé type node_t is record -- l'élément porté par le noeud element : element_t; -- le noeud suivant next_node : node_ptr; end record; end generic_linked_list;
stcarrez/ada-util
Ada
2,487
ads
----------------------------------------------------------------------- -- util-tests-server - A small non-compliant-inefficient HTTP server used for unit tests -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with Util.Streams.Sockets; with Util.Streams.Texts; package Util.Tests.Servers is -- A small TCP/IP server for unit tests. type Server is new Ada.Finalization.Limited_Controlled with private; type Server_Access is access all Server'Class; -- Get the server port. function Get_Port (From : in Server) return Natural; -- Get the server name. function Get_Host (From : in Server) return String; -- Process the line received by the server. procedure Process_Line (Into : in out Server; Line : in Ada.Strings.Unbounded.Unbounded_String; Stream : in out Util.Streams.Texts.Reader_Stream'Class; Client : in out Util.Streams.Sockets.Socket_Stream'Class); -- Start the server task. procedure Start (S : in out Server); -- Stop the server task. procedure Stop (S : in out Server); private -- A small server that listens to HTTP requests and replies with fake -- responses. This server is intended to be used by unit tests and not to serve -- real pages. task type Server_Task is entry Start (S : in Server_Access); -- entry Stop; end Server_Task; type Server is new Ada.Finalization.Limited_Controlled with record Port : Natural := 0; Need_Shutdown : Boolean := False; Server : Server_Task; Client : aliased Util.Streams.Sockets.Socket_Stream; end record; end Util.Tests.Servers;
zhmu/ananas
Ada
4,645
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C O M M A N D _ L I N E . R E M O V E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package body Ada.Command_Line.Remove is ----------------------- -- Local Subprograms -- ----------------------- procedure Initialize; -- Initialize the Remove_Count and Remove_Args variables ---------------- -- Initialize -- ---------------- procedure Initialize is begin if Remove_Args = null then Remove_Count := Argument_Count; Remove_Args := new Arg_Nums (1 .. Argument_Count); for J in Remove_Args'Range loop Remove_Args (J) := J; end loop; end if; end Initialize; --------------------- -- Remove_Argument -- --------------------- procedure Remove_Argument (Number : Positive) is begin Initialize; if Number > Remove_Count then raise Constraint_Error; end if; Remove_Count := Remove_Count - 1; for J in Number .. Remove_Count loop Remove_Args (J) := Remove_Args (J + 1); end loop; end Remove_Argument; procedure Remove_Argument (Argument : String) is begin for J in reverse 1 .. Argument_Count loop if Argument = Ada.Command_Line.Argument (J) then Remove_Argument (J); end if; end loop; end Remove_Argument; ---------------------- -- Remove_Arguments -- ---------------------- procedure Remove_Arguments (From : Positive; To : Natural) is begin Initialize; if From > Remove_Count or else To > Remove_Count then raise Constraint_Error; end if; if To >= From then Remove_Count := Remove_Count - (To - From + 1); for J in From .. Remove_Count loop Remove_Args (J) := Remove_Args (J + (To - From + 1)); end loop; end if; end Remove_Arguments; procedure Remove_Arguments (Argument_Prefix : String) is begin for J in reverse 1 .. Argument_Count loop declare Arg : constant String := Argument (J); begin if Arg'Length >= Argument_Prefix'Length and then Arg (1 .. Argument_Prefix'Length) = Argument_Prefix then Remove_Argument (J); end if; end; end loop; end Remove_Arguments; end Ada.Command_Line.Remove;
twdroeger/ada-awa
Ada
22,371
adb
----------------------------------------------------------------------- -- awa-wikis-modules -- Module wikis -- Copyright (C) 2015, 2016, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with AWA.Services.Contexts; with AWA.Workspaces.Models; with AWA.Workspaces.Modules; with AWA.Modules.Get; with AWA.Permissions; with AWA.Users.Models; with AWA.Wikis.Beans; with AWA.Modules.Beans; with AWA.Storages.Models; with AWA.Storages.Services; with AWA.Storages.Modules; with Ada.Strings; with ADO.Objects; with ADO.SQL; with ADO.Queries; with ADO.Statements; with Util.Log.Loggers; with Util.Strings.Tokenizers; package body AWA.Wikis.Modules is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Awa.Wikis.Module"); package Register is new AWA.Modules.Beans (Module => Wiki_Module, Module_Access => Wiki_Module_Access); -- ------------------------------ -- Initialize the wikis module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Wiki_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the wikis module"); -- Setup the resource bundles. App.Register ("wikiMsg", "wikis"); -- Register here any bean class, servlet, filter. Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_Space_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_Space_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_Admin_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_Admin_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_Page_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_Page_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_Image_Info_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_Image_Info_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_Page_Info_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_Page_Info_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_List_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_List_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Format_List_Bean", Handler => AWA.Wikis.Beans.Create_Format_List_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_View_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_View_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Wikis.Beans.Wiki_Version_List_Bean", Handler => AWA.Wikis.Beans.Create_Wiki_Version_List_Bean'Access); App.Add_Servlet ("wiki-image", Plugin.Image_Servlet'Unchecked_Access); AWA.Modules.Module (Plugin).Initialize (App, Props); -- Add here the creation of manager instances. end Initialize; -- ------------------------------ -- Configures the module after its initialization and after having read its XML configuration. -- ------------------------------ overriding procedure Configure (Plugin : in out Wiki_Module; Props : in ASF.Applications.Config) is pragma Unreferenced (Props); Image_Prefix : constant String := Plugin.Get_Config (PARAM_IMAGE_PREFIX); Page_Prefix : constant String := Plugin.Get_Config (PARAM_PAGE_PREFIX); begin Plugin.Image_Prefix := Wiki.Strings.To_UString (Wiki.Strings.To_WString (Image_Prefix)); Plugin.Page_Prefix := Wiki.Strings.To_UString (Wiki.Strings.To_WString (Page_Prefix)); end Configure; -- ------------------------------ -- Get the image prefix that was configured for the Wiki module. -- ------------------------------ function Get_Image_Prefix (Module : in Wiki_Module) return Wiki.Strings.UString is begin return Module.Image_Prefix; end Get_Image_Prefix; -- ------------------------------ -- Get the page prefix that was configured for the Wiki module. -- ------------------------------ function Get_Page_Prefix (Module : in Wiki_Module) return Wiki.Strings.UString is begin return Module.Page_Prefix; end Get_Page_Prefix; -- ------------------------------ -- Get the wikis module. -- ------------------------------ function Get_Wiki_Module return Wiki_Module_Access is function Get is new AWA.Modules.Get (Wiki_Module, Wiki_Module_Access, NAME); begin return Get; end Get_Wiki_Module; -- ------------------------------ -- Create the wiki space. -- ------------------------------ procedure Create_Wiki_Space (Module : in Wiki_Module; Wiki : in out AWA.Wikis.Models.Wiki_Space_Ref'Class) is procedure Copy_Page (Item : in String; Done : out Boolean); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; User : constant ADO.Identifier := Ctx.Get_User_Identifier; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); WS : AWA.Workspaces.Models.Workspace_Ref; procedure Copy_Page (Item : in String; Done : out Boolean) is begin Module.Copy_Page (DB, Wiki, ADO.Identifier'Value (Item)); Done := False; exception when Constraint_Error => Log.Error ("Invalid configuration wiki page id {0}", Item); end Copy_Page; begin Log.Info ("Creating new wiki space {0}", String '(Wiki.Get_Name)); Ctx.Start; AWA.Workspaces.Modules.Get_Workspace (DB, Ctx, WS); -- Check that the user has the create permission on the given workspace. AWA.Permissions.Check (Permission => ACL_Create_Wiki_Space.Permission, Entity => WS); Wiki.Set_Workspace (WS); Wiki.Set_Create_Date (Ada.Calendar.Clock); Wiki.Save (DB); -- Add the permission for the user to use the new wiki space. AWA.Workspaces.Modules.Add_Permission (Session => DB, User => User, Entity => Wiki, Workspace => WS.Get_Id, List => (ACL_Update_Wiki_Space.Permission, ACL_Delete_Wiki_Space.Permission, ACL_Create_Wiki_Pages.Permission, ACL_Delete_Wiki_Pages.Permission, ACL_Update_Wiki_Pages.Permission, ACL_View_Wiki_Page.Permission)); Util.Strings.Tokenizers.Iterate_Tokens (Content => Module.Get_Config (PARAM_WIKI_COPY_LIST), Pattern => ",", Process => Copy_Page'Access, Going => Ada.Strings.Forward); Ctx.Commit; Log.Info ("Wiki {0} created for user {1}", ADO.Identifier'Image (Wiki.Get_Id), ADO.Identifier'Image (User)); end Create_Wiki_Space; -- ------------------------------ -- Save the wiki space. -- ------------------------------ procedure Save_Wiki_Space (Module : in Wiki_Module; Wiki : in out AWA.Wikis.Models.Wiki_Space_Ref'Class) is pragma Unreferenced (Module); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin Log.Info ("Updating wiki space {0}", String '(Wiki.Get_Name)); Ctx.Start; -- Check that the user has the update permission on the given wiki space. AWA.Permissions.Check (Permission => ACL_Update_Wiki_Space.Permission, Entity => Wiki); Wiki.Save (DB); Ctx.Commit; end Save_Wiki_Space; -- ------------------------------ -- Load the wiki space. -- ------------------------------ procedure Load_Wiki_Space (Module : in Wiki_Module; Wiki : in out AWA.Wikis.Models.Wiki_Space_Ref'Class; Id : in ADO.Identifier) is pragma Unreferenced (Module); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Session := AWA.Services.Contexts.Get_Session (Ctx); Found : Boolean; begin Wiki.Load (DB, Id, Found); end Load_Wiki_Space; -- ------------------------------ -- Create the wiki page into the wiki space. -- ------------------------------ procedure Create_Wiki_Page (Model : in Wiki_Module; Into : in AWA.Wikis.Models.Wiki_Space_Ref'Class; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class; Content : in out AWA.Wikis.Models.Wiki_Content_Ref'Class) is begin Log.Info ("Create wiki page {0}", String '(Page.Get_Name)); -- Check that the user has the create wiki page permission on the given wiki space. AWA.Permissions.Check (Permission => ACL_Create_Wiki_Pages.Permission, Entity => Into); Page.Set_Wiki (Into); Model.Save_Wiki_Content (Page, Content); end Create_Wiki_Page; -- ------------------------------ -- Save the wiki page. -- ------------------------------ procedure Save (Model : in Wiki_Module; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class) is pragma Unreferenced (Model); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin -- Check that the user has the update wiki page permission on the given wiki space. AWA.Permissions.Check (Permission => ACL_Update_Wiki_Pages.Permission, Entity => Page); Ctx.Start; Page.Save (DB); Ctx.Commit; end Save; -- ------------------------------ -- Delete the wiki page as well as all its versions. -- ------------------------------ procedure Delete (Model : in Wiki_Module; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class) is Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin -- Check that the user has the delete wiki page permission on the given wiki page. AWA.Permissions.Check (Permission => ACL_Delete_Wiki_Pages.Permission, Entity => Page); Ctx.Start; -- Before deleting the wiki page, delete the version content. declare Stmt : ADO.Statements.Delete_Statement := DB.Create_Statement (AWA.Wikis.Models.WIKI_CONTENT_TABLE); begin Stmt.Set_Filter (Filter => "page_id = ?"); Stmt.Add_Param (Value => Page); Stmt.Execute; end; -- Notify the deletion of the wiki page (before the real delete). Wiki_Lifecycle.Notify_Delete (Model, Page); Page.Delete (DB); Ctx.Commit; end Delete; -- ------------------------------ -- Load the wiki page and its content. -- ------------------------------ procedure Load_Page (Model : in Wiki_Module; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class; Content : in out AWA.Wikis.Models.Wiki_Content_Ref'Class; Tags : in out AWA.Tags.Beans.Tag_List_Bean; Id : in ADO.Identifier) is DB : ADO.Sessions.Session := Model.Get_Session; Found : Boolean; begin -- Check that the user has the view page permission on the given wiki page. AWA.Permissions.Check (Permission => ACL_View_Wiki_Page.Permission, Entity => Id); Page.Load (DB, Id, Found); Tags.Load_Tags (DB, Id); Content := Page.Get_Content; if not Content.Is_Null then Content.Load (DB, Content.Get_Id, Found); end if; end Load_Page; -- ------------------------------ -- Load the wiki page and its content from the wiki space Id and the page name. -- ------------------------------ procedure Load_Page (Model : in Wiki_Module; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class; Content : in out AWA.Wikis.Models.Wiki_Content_Ref'Class; Tags : in out AWA.Tags.Beans.Tag_List_Bean; Wiki : in ADO.Identifier; Name : in String) is DB : ADO.Sessions.Session := Model.Get_Session; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (1, Wiki); Query.Bind_Param (2, Name); Query.Set_Filter ("o.wiki_id = ? AND o.name = ?"); Page.Find (DB, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; -- Check that the user has the view page permission on the given wiki page. AWA.Permissions.Check (Permission => ACL_View_Wiki_Page.Permission, Entity => Page.Get_Id); Tags.Load_Tags (DB, Page.Get_Id); Content := Page.Get_Content; if not Content.Is_Null then Content.Load (DB, Content.Get_Id, Found); end if; end Load_Page; -- ------------------------------ -- Create a new wiki content for the wiki page. -- ------------------------------ procedure Create_Wiki_Content (Model : in Wiki_Module; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class; Content : in out AWA.Wikis.Models.Wiki_Content_Ref'Class) is begin -- Check that the user has the update wiki content permission on the given wiki page. AWA.Permissions.Check (Permission => ACL_Update_Wiki_Pages.Permission, Entity => Page); Model.Save_Wiki_Content (Page, Content); end Create_Wiki_Content; -- ------------------------------ -- Copy the wiki page with its last version to the wiki space. -- ------------------------------ procedure Copy_Page (Module : in Wiki_Module; DB : in out ADO.Sessions.Master_Session; Wiki : in AWA.Wikis.Models.Wiki_Space_Ref'Class; Page_Id : in ADO.Identifier) is Page : AWA.Wikis.Models.Wiki_Page_Ref; Found : Boolean; begin Page.Load (DB, Page_Id, Found); if not Found then Log.Warn ("Wiki page copy is abandoned: page {0} was not found", ADO.Identifier'Image (Page_Id)); return; end if; Module.Copy_Page (DB, Wiki, Page); end Copy_Page; -- ------------------------------ -- Copy the wiki page with its last version to the wiki space. -- ------------------------------ procedure Copy_Page (Module : in Wiki_Module; DB : in out ADO.Sessions.Master_Session; Wiki : in AWA.Wikis.Models.Wiki_Space_Ref'Class; Page : in AWA.Wikis.Models.Wiki_Page_Ref'Class) is New_Content : AWA.Wikis.Models.Wiki_Content_Ref; New_Page : AWA.Wikis.Models.Wiki_Page_Ref; begin New_Page.Set_Wiki (Wiki); New_Page.Set_Title (String '(Page.Get_Title)); New_Page.Set_Name (String '(Page.Get_Name)); New_Page.Set_Is_Public (Wiki.Get_Is_Public); New_Page.Set_Last_Version (0); New_Content.Set_Content (String '(Page.Get_Content.Get_Content)); Module.Save_Wiki_Content (DB, New_Page, New_Content); end Copy_Page; -- ------------------------------ -- Save a new wiki content for the wiki page. -- ------------------------------ procedure Save_Wiki_Content (Model : in Wiki_Module; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class; Content : in out AWA.Wikis.Models.Wiki_Content_Ref'Class) is Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin Ctx.Start; Model.Save_Wiki_Content (DB, Page, Content); Ctx.Commit; end Save_Wiki_Content; -- ------------------------------ -- Save a new wiki content for the wiki page. -- ------------------------------ procedure Save_Wiki_Content (Model : in Wiki_Module; DB : in out ADO.Sessions.Master_Session; Page : in out AWA.Wikis.Models.Wiki_Page_Ref'Class; Content : in out AWA.Wikis.Models.Wiki_Content_Ref'Class) is Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; Created : constant Boolean := not Page.Is_Inserted; Query : ADO.Queries.Context; Stmt : ADO.Statements.Query_Statement; begin -- Check if the wiki page name is already used. Query.Set_Query (AWA.Wikis.Models.Query_Wiki_Page_Name_Count); Query.Bind_Param ("name", String '(Page.Get_Name)); Query.Bind_Param ("id", Page.Get_Id); Query.Bind_Param ("wiki_id", Page.Get_Wiki.Get_Id); Stmt := DB.Create_Statement (Query); Stmt.Execute; if Stmt.Get_Result_Integer /= 0 then raise Name_Used; end if; Page.Set_Last_Version (Page.Get_Last_Version + 1); if Created then Page.Save (DB); end if; Content.Set_Page_Id (ADO.Objects.Get_Value (Page.Get_Key)); Content.Set_Create_Date (Ada.Calendar.Clock); Content.Set_Author (User); Content.Set_Page_Version (Page.Get_Last_Version); Content.Save (DB); Page.Set_Content (Content); Page.Save (DB); if Created then Wiki_Lifecycle.Notify_Create (Model, Page); else Wiki_Lifecycle.Notify_Update (Model, Page); end if; end Save_Wiki_Content; procedure Load_Image (Model : in Wiki_Module; Wiki_Id : in ADO.Identifier; Image_Id : in ADO.Identifier; Width : in out Natural; Height : in out Natural; Mime : out Ada.Strings.Unbounded.Unbounded_String; Date : out Ada.Calendar.Time; Into : out ADO.Blob_Ref) is pragma Unreferenced (Model); use type AWA.Storages.Models.Storage_Type; Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; User : constant ADO.Identifier := Ctx.Get_User_Identifier; DB : constant ADO.Sessions.Session := AWA.Services.Contexts.Get_Session (Ctx); Query : ADO.Statements.Query_Statement; Kind : AWA.Storages.Models.Storage_Type; begin if Width = Natural'Last or Height = Natural'Last then Query := DB.Create_Statement (Models.Query_Wiki_Image_Get_Data); elsif Width > 0 then Query := DB.Create_Statement (Models.Query_Wiki_Image_Width_Get_Data); Query.Bind_Param ("width", Width); elsif Height > 0 then Query := DB.Create_Statement (Models.Query_Wiki_Image_Height_Get_Data); Query.Bind_Param ("height", Height); else Query := DB.Create_Statement (Models.Query_Wiki_Image_Get_Data); end if; Query.Bind_Param ("wiki_id", Wiki_Id); Query.Bind_Param ("store_id", Image_Id); Query.Bind_Param ("user_id", User); Query.Execute; if not Query.Has_Elements then Log.Warn ("Wiki image entity {0} not found", ADO.Identifier'Image (Image_Id)); raise ADO.Objects.NOT_FOUND; end if; Mime := Query.Get_Unbounded_String (1); Date := Query.Get_Time (2); Width := Query.Get_Natural (5); Height := Query.Get_Natural (6); Kind := AWA.Storages.Models.Storage_Type'Val (Query.Get_Integer (4)); if Kind = AWA.Storages.Models.DATABASE then Into := Query.Get_Blob (7); else declare Storage : constant AWA.Storages.Services.Storage_Service_Access := AWA.Storages.Modules.Get_Storage_Manager; begin Storage.Load (Query.Get_Identifier (0), Kind, Into); end; end if; end Load_Image; end AWA.Wikis.Modules;
reznikmm/matreshka
Ada
3,724
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Filter_Name_Attributes is pragma Preelaborate; type ODF_Table_Filter_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Filter_Name_Attribute_Access is access all ODF_Table_Filter_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Filter_Name_Attributes;
PThierry/ewok-kernel
Ada
1,180
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- package ewok.devices_shared with spark_mode => on is type t_device_id is (ID_DEV_UNUSED, ID_DEV1, ID_DEV2, ID_DEV3, ID_DEV4, ID_DEV5, ID_DEV6, ID_DEV7, ID_DEV8, ID_DEV9, ID_DEV10, ID_DEV11, ID_DEV12, ID_DEV13, ID_DEV14, ID_DEV15, ID_DEV16, ID_DEV17, ID_DEV18); subtype t_registered_device_id is t_device_id range ID_DEV1 .. ID_DEV18; end ewok.devices_shared;
Fabien-Chouteau/AGATE
Ada
4,580
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2020, Fabien Chouteau -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with System.Machine_Code; use System.Machine_Code; with Cortex_M_SVD.SCB; use Cortex_M_SVD.SCB; -- AGATE.Traps is necessary for fault handlers but not imported anywhere at the -- moment... with AGATE.Traps; pragma Unreferenced (AGATE.Traps); package body AGATE.Arch is -------------------- -- Idle_Procedure -- -------------------- procedure Idle_Procedure is begin loop Asm ("wfi", Volatile => True); end loop; end Idle_Procedure; ----------------------------- -- Initialize_Task_Context -- ----------------------------- procedure Initialize_Task_Context (T : Task_ID) is type Stack_Array is array (1 .. 8) of Word with Pack, Size => 8 * 32; Context : Stack_Array with Address => T.Stack (T.Stack'Last)'Address + 1 - 8 * 32; begin -- xPSR Context (8) := 2**24; -- Set the thumb bit -- PC Context (7) := Word (To_Integer (T.Proc.all'Address)); Ada.Text_IO.Put_Line ("Set start PC address: " & Hex (UInt32 (Context (7)))); -- LR Context (6) := 0; -- R12 Context (5) := 0; -- R3 Context (4) := 0; -- R2 Context (3) := 0; -- R1 Context (2) := 0; -- R0 Context (1) := 0; T.Stack_Pointer := Process_Stack_Pointer (Context (1)'Address); end Initialize_Task_Context; ------------------ -- Jump_In_Task -- ------------------ procedure Jump_In_Task (T : Task_ID) is begin Ada.Text_IO.Put_Line ("Starting task at PSP: " & Image (T.Stack_Pointer)); Asm ( -- Set thread mode stack (PSP) "msr psp, %0" & ASCII.LF & -- Switch thread mode to use PSP, and thread mode unpriviledge "msr control, %1" & ASCII.LF & -- Call task procedure "blx %2", Inputs => (Process_Stack_Pointer'Asm_Input ("r", T.Stack_Pointer), Word'Asm_Input ("r", 2#11#), Task_Procedure'Asm_Input ("r", T.Proc)), Volatile => True); raise Program_Error; end Jump_In_Task; end AGATE.Arch;
persan/a-cups
Ada
2,812
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with System; with CUPS.sys_types_h; with CUPS.stdio_h; with Interfaces.C_Streams; private package CUPS.bits_uio_h is UIO_MAXIOV : constant := 1024; -- bits/uio.h:39 -- Copyright (C) 1996-2016 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- The GNU C Library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- The GNU C Library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library; if not, see -- <http://www.gnu.org/licenses/>. -- We should normally use the Linux kernel header file to define this -- type and macros but this calls for trouble because of the header -- includes other kernel headers. -- Size of object which can be written atomically. -- This macro has different values in different kernel versions. The -- latest versions of the kernel use 1024 and this is good choice. Since -- the C library implementation of readv/writev is able to emulate the -- functionality even if the currently running kernel does not support -- this large value the readv/writev call will not fail because of this. -- Structure for scatter/gather I/O. -- Pointer to data. type iovec is record iov_base : System.Address; -- bits/uio.h:45 iov_len : aliased size_t; -- bits/uio.h:46 end record; pragma Convention (C_Pass_By_Copy, iovec); -- bits/uio.h:43 -- Length of data. -- Read from another process' address space. function process_vm_readv (uu_pid : CUPS.sys_types_h.pid_t; uu_lvec : access constant iovec; uu_liovcnt : unsigned_long; uu_rvec : access constant iovec; uu_riovcnt : unsigned_long; uu_flags : unsigned_long) return size_t; -- bits/uio.h:59 pragma Import (C, process_vm_readv, "process_vm_readv"); -- Write to another process' address space. function process_vm_writev (uu_pid : CUPS.sys_types_h.pid_t; uu_lvec : access constant iovec; uu_liovcnt : unsigned_long; uu_rvec : access constant iovec; uu_riovcnt : unsigned_long; uu_flags : unsigned_long) return size_t; -- bits/uio.h:67 pragma Import (C, process_vm_writev, "process_vm_writev"); end CUPS.bits_uio_h;
burratoo/Acton
Ada
6,639
adb
------------------------------------------------------------------------------------------ -- -- -- OAK PROCESSOR SUPPORT PACKAGE -- -- FREESCALE MPC5544 -- -- -- -- OAK.PROCESSOR_SUPPORT_PACKAGE.INTERRUPTS -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with MPC5554.Flash; with Oak.Core_Support_Package.Interrupts; use Oak.Core_Support_Package.Interrupts; with Oak.Brokers.Protected_Objects; use Oak.Brokers.Protected_Objects; with System.Machine_Code; use System.Machine_Code; with ISA; use ISA; with ISA.Power.e200.Processor_Control_Registers; use ISA.Power.e200.Processor_Control_Registers; package body Oak.Processor_Support_Package.Interrupts is procedure External_Interrupt_Handler (Interrupt_Id : External_Interrupt_Id) is begin INTC_Vector_Table (Interrupt_Id).all; End_Of_Interrupt_Register := End_Interrupt; end External_Interrupt_Handler; function Get_External_Interrupt_Id return External_Interrupt_Id is begin return Interrupt_Acknowledge_Component.Interrupt_Vector; end Get_External_Interrupt_Id; procedure Initialise_Interrupts is use MPC5554.Flash; begin Oak.Core_Support_Package.Interrupts.Disable_External_Interrupts; Module_Config_Register := (Vector_Table_Entry_Size => Four_Bytes, Hardware_Vector_Enable => Software_Vector_Mode); Interrupt_Acknowledge_Register := Null_Address; Current_Priority_Register := MPC5554_Interrupt_Priority'First; Initialise_For_Flash_Programming; Unlock_Space_Block_Locking_Register (Space => Low_Primary); Low_Mid_Address_Space_Block_Locking_Register := (Locks => Editable, Shadow_Lock => Locked, Mid_Address_Locks => (others => Locked), Low_Address_Locks => (B3 => Unlocked, others => Locked)); Unlock_Space_Block_Locking_Register (Space => Low_Secondary); Secondary_Low_Mid_Address_Space_Block_Locking_Register := (Locks => Editable, Shadow_Lock => Locked, Mid_Address_Locks => (others => Locked), Low_Address_Locks => (B3 => Unlocked, others => Locked)); end Initialise_Interrupts; procedure Complete_Interrupt_Initialisation is use MPC5554.Flash; begin Low_Mid_Address_Space_Block_Locking_Register := (Locks => Editable, Shadow_Lock => Locked, Mid_Address_Locks => (others => Locked), Low_Address_Locks => (others => Locked)); Completed_Flash_Programming; end Complete_Interrupt_Initialisation; procedure Attach_Handler (Interrupt : External_Interrupt_Id; Handler : Parameterless_Handler; Priority : Interrupt_Priority) is use MPC5554.Flash; begin if INTC_Vector_Table (Interrupt) /= Handler then if Programmed_Vector_Table (Interrupt) /= Default_Handler then raise Program_Error; end if; Program_Protected_Access (P => Handler, Destination => INTC_Vector_Table (Interrupt)'Address); end if; Priority_Select_Register_Array (Interrupt) := MPC5554_Interrupt_Priority (Priority - System.Priority'Last); end Attach_Handler; function Current_Interrupt_Priority return Any_Priority is begin -- The first priority of the interrupt hardware is mapped to -- Priority'Last - the priority level that comes before -- Interrupt_Priority'First. return Any_Priority (Current_Priority_Register) + Priority'Last; end Current_Interrupt_Priority; procedure Set_Hardware_Priority (P : Any_Priority) is begin if P in Interrupt_Priority then Current_Priority_Register := MPC5554_Interrupt_Priority (P - Priority'Last); else Current_Priority_Register := MPC5554_Interrupt_Priority'First; end if; end Set_Hardware_Priority; procedure Clear_Hardware_Priority is begin Current_Priority_Register := MPC5554_Interrupt_Priority'First; end Clear_Hardware_Priority; function Handler_Protected_Object (Interrupt : External_Interrupt_Id) return Protected_Id_With_No is begin return Protected_Object_From_Access (Parameterless_Access (INTC_Vector_Table (Interrupt))); end Handler_Protected_Object; function Has_Outstanding_Interrupts (Above_Priority : Any_Priority) return Boolean is pragma Unreferenced (Above_Priority); Interrupt_Present : Boolean := False; Oak_Current_MSR : Machine_State_Register_Type; Oak_New_MSR : Machine_State_Register_Type; begin -- Setup external interrupt vector to External_Interrupt_Present to -- see if an external interrupt is present and then enable external -- interrupts. Asm ("mtivor4 %1" & ASCII.LF & ASCII.HT & "mfmsr %0", Inputs => System.Address'Asm_Input ("r", External_Interrupt_Present'Address), Outputs => Machine_State_Register_Type'Asm_Output ("=r", Oak_Current_MSR), Volatile => True); Oak_New_MSR := Oak_Current_MSR; Oak_New_MSR.External_Interrupts := Enable; Asm ("mtmsr %1" & ASCII.LF & ASCII.HT & "mtmsr %2" & ASCII.LF & ASCII.HT & "mtivor4 %3", -- register Inputs => (Machine_State_Register_Type'Asm_Input ("r", Oak_New_MSR), Machine_State_Register_Type'Asm_Input ("r", Oak_Current_MSR), System.Address'Asm_Input ("r", Oak.Core_Support_Package.Interrupts. External_Interrupt_Handler'Address)), Outputs => Boolean'Asm_Output ("+r", Interrupt_Present), Volatile => True); return Interrupt_Present; end Has_Outstanding_Interrupts; end Oak.Processor_Support_Package.Interrupts;