content
stringlengths
23
1.05M
with TEXT_IO; with STRINGS_PACKAGE; use STRINGS_PACKAGE; with LATIN_FILE_NAMES; use LATIN_FILE_NAMES; with INFLECTIONS_PACKAGE; use INFLECTIONS_PACKAGE; with IO_EXCEPTIONS; procedure MAKEINFL is package INTEGER_IO is new TEXT_IO.INTEGER_IO(INTEGER); use TEXT_IO; use INTEGER_IO; use STEM_KEY_TYPE_IO; use INFLECTION_RECORD_IO; use QUALITY_RECORD_IO; use ENDING_RECORD_IO; use AGE_TYPE_IO; use FREQUENCY_TYPE_IO; use LEL_SECTION_IO; PORTING : constant BOOLEAN := TRUE; --FALSE for WAKEINFL; M, N : INTEGER := 0; N1, N2, N3, N4, N5 : INTEGER := 0; OUTPUT : TEXT_IO.FILE_TYPE; INFLECTIONS_SECTIONS_FILE : LEL_SECTION_IO.FILE_TYPE; procedure FILE_INFLECTIONS_SECTIONS is -- Reads the INFLECTS. file and prepares an inflections list -- Then it writes that list into an array -- Loads the inflection array into a file for later retrieval use TEXT_IO; use INFLECTION_RECORD_IO; use INTEGER_IO; INFLECTIONS_FILE : TEXT_IO.FILE_TYPE; INFLECTIONS_SECTIONS_FILE : LEL_SECTION_IO.FILE_TYPE; IR : INFLECTION_RECORD; LINE, BLANKS : STRING(1..100) := (others => ' '); LAST, L : INTEGER := 0; SN : ENDING_SIZE_TYPE := ENDING_SIZE_TYPE'FIRST; SX : CHARACTER := ' '; type INFLECTION_ITEM; type INFLECTION_LIST is access INFLECTION_ITEM; type INFLECTION_ITEM is record IR : INFLECTION_RECORD; SUCC : INFLECTION_LIST; end record; type LATIN_INFLECTIONS is array (INTEGER range 0..MAX_ENDING_SIZE, CHARACTER range ' '..'z') of INFLECTION_LIST; NULL_LATIN_INFLECTIONS : LATIN_INFLECTIONS := (others => (others => null)); L_I : LATIN_INFLECTIONS := NULL_LATIN_INFLECTIONS; LEL : LEL_SECTION := (others => NULL_INFLECTION_RECORD); J1, J2, J3, J4, J5 : INTEGER := 0; procedure NULL_LEL is begin for I in LEL'RANGE loop LEL(I) := NULL_INFLECTION_RECORD; end loop; end NULL_LEL; procedure LOAD_INFLECTIONS_LIST is -- Takes the INFLECT. file and populates the L_I list of inflections -- indexed on ending size and last letter of ending begin PUT_LINE("Begin LOAD_INFLECTIONS_LIST"); NUMBER_OF_INFLECTIONS := 0; L_I := NULL_LATIN_INFLECTIONS; OPEN(INFLECTIONS_FILE, IN_FILE, INFLECTIONS_FULL_NAME); TEXT_IO.PUT("INFLECTIONS file loading"); while not END_OF_FILE(INFLECTIONS_FILE) loop READ_A_LINE: begin GET_NON_COMMENT_LINE(INFLECTIONS_FILE, LINE, LAST); if LAST > 0 then GET(LINE(1..LAST), IR, L); SN := IR.ENDING.SIZE; if SN = 0 then SX := ' '; else SX := IR.ENDING.SUF(SN); end if; L_I(SN, SX) := new INFLECTION_ITEM'(IR, L_I(SN, SX)); NUMBER_OF_INFLECTIONS := NUMBER_OF_INFLECTIONS + 1; --TEXT_IO.PUT(INTEGER'IMAGE(NUMBER_OF_INFLECTIONS) & " "); INFLECTION_RECORD_IO.PUT(IR); NEW_LINE; end if; exception when CONSTRAINT_ERROR | IO_EXCEPTIONS.DATA_ERROR => PUT_LINE("****" & LINE(1..LAST)); end READ_A_LINE; end loop; CLOSE(INFLECTIONS_FILE); PUT_LINE("INFLECTIONS_LIST LOADED " & INTEGER'IMAGE(NUMBER_OF_INFLECTIONS)); end LOAD_INFLECTIONS_LIST; procedure LIST_TO_LEL_FILE is -- From ILC (=L_I) list of inflections, prepares the LEL inflections array use LEL_SECTION_IO; I : INTEGER := 0; ILC : LATIN_INFLECTIONS := L_I; begin CREATE(INFLECTIONS_SECTIONS_FILE, OUT_FILE, INFLECTIONS_SECTIONS_NAME); NULL_LEL; ILC := L_I; -- Resetting the list to start over while ILC(0, ' ') /= null loop J5 := J5 + 1; LEL(J5) := ILC(0, ' ').IR; ILC(0, ' ') := ILC(0, ' ').SUCC; end loop; WRITE(INFLECTIONS_SECTIONS_FILE, LEL, 5); N5 := J5; NULL_LEL; ILC := L_I; -- Resetting the list to start over for CH in CHARACTER range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop while ILC(N, CH) /= null loop if not (ILC(N, CH).IR.QUAL.POFS = PRON and then (ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 1 or ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 2)) then if CH in INFLECTIONS_SECTION_1 then J1 := J1 + 1; LEL(J1) := ILC(N, CH).IR; end if; end if; ILC(N, CH) := ILC(N, CH).SUCC; end loop; end loop; end loop; WRITE(INFLECTIONS_SECTIONS_FILE, LEL, 1); N1 := J1; NULL_LEL; ILC := L_I; -- Resetting the list to start over for CH in CHARACTER range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop while ILC(N, CH) /= null loop if not (ILC(N, CH).IR.QUAL.POFS = PRON and then (ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 1 or ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 2)) then if CH in INFLECTIONS_SECTION_2 then J2 := J2 + 1; LEL(J2) := ILC(N, CH).IR; end if; end if; ILC(N, CH) := ILC(N, CH).SUCC; end loop; end loop; end loop; WRITE(INFLECTIONS_SECTIONS_FILE, LEL, 2); N2 := J2; NULL_LEL; ILC := L_I; -- Resetting the list to start over for CH in CHARACTER range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop while ILC(N, CH) /= null loop if not (ILC(N, CH).IR.QUAL.POFS = PRON and then (ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 1 or ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 2)) then if CH in INFLECTIONS_SECTION_3 then J3 := J3 + 1; LEL(J3) := ILC(N, CH).IR; end if; end if; ILC(N, CH) := ILC(N, CH).SUCC; end loop; end loop; end loop; WRITE(INFLECTIONS_SECTIONS_FILE, LEL, 3); N3 := J3; NULL_LEL; ILC := L_I; -- Resetting the list to start over for CH in CHARACTER range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop while ILC(N, CH) /= null loop if not (ILC(N, CH).IR.QUAL.POFS = PRON and then (ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 1 or ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 2)) then if (CH in INFLECTIONS_SECTION_4) then J4 := J4 + 1; LEL(J4) := ILC(N, CH).IR; end if; end if; ILC(N, CH) := ILC(N, CH).SUCC; end loop; end loop; end loop; -- Now put the PACK in 4 -- Maybe it should be in 5 ???? ILC := L_I; -- Resetting the list to start over for CH in CHARACTER range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop while ILC(N, CH) /= null loop if (ILC(N, CH).IR.QUAL.POFS = PRON and then (ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 1 or ILC(N, CH).IR.QUAL.PRON.DECL.WHICH = 2)) then -- 2 no longer PACK J4 := J4 + 1; LEL(J4) := ILC(N, CH).IR; end if; ILC(N, CH) := ILC(N, CH).SUCC; end loop; end loop; end loop; WRITE(INFLECTIONS_SECTIONS_FILE, LEL, 4); N4 := J4; CLOSE(INFLECTIONS_SECTIONS_FILE); end LIST_TO_LEL_FILE; begin LOAD_INFLECTIONS_LIST; TEXT_IO.SET_COL(33); TEXT_IO.PUT("-- "); INTEGER_IO.PUT(NUMBER_OF_INFLECTIONS); TEXT_IO.PUT_LINE(" entries -- Loaded correctly"); LIST_TO_LEL_FILE; -- Load arrays to file TEXT_IO.PUT_LINE("File INFLECTS.SEC -- Loaded"); exception when others => TEXT_IO.PUT_LINE("Exception in FILE_INFLECTIONS_SECTIONS"); end FILE_INFLECTIONS_SECTIONS; use INFLECTIONS_PACKAGE; begin PUT_LINE("Produces INFLECTS.SEC file from INFLECTS."); FILE_INFLECTIONS_SECTIONS; if not PORTING then PUT_LINE("using FILE_INFLECTIONS_SECTIONS, also produces INFLECTS.LIN file"); CREATE(OUTPUT, OUT_FILE, "INFLECTS.LIN"); end if; ESTABLISH_INFLECTIONS_SECTION; LEL_SECTION_IO.OPEN(INFLECTIONS_SECTIONS_FILE, IN_FILE, INFLECTIONS_SECTIONS_NAME); if not PORTING then for I in BEL'RANGE loop -- Blank endings if BEL(I) /= NULL_INFLECTION_RECORD then M := M + 1; PUT(OUTPUT, BEL(I).QUAL); SET_COL(OUTPUT, 50); PUT(OUTPUT, BEL(I).KEY, 1); SET_COL(OUTPUT, 52); PUT(OUTPUT, BEL(I).ENDING); SET_COL(OUTPUT, 62); PUT(OUTPUT, BEL(I).AGE); SET_COL(OUTPUT, 64); PUT(OUTPUT, BEL(I).FREQ); NEW_LINE(OUTPUT); end if; end loop; end if; for N in 1..4 loop READ(INFLECTIONS_SECTIONS_FILE, LEL, LEL_SECTION_IO.POSITIVE_COUNT(N)); if not PORTING then for I in LEL'RANGE loop -- Non-blank endings if LEL(I) /= NULL_INFLECTION_RECORD then M := M + 1; PUT(OUTPUT, LEL(I).QUAL); SET_COL(OUTPUT, 50); PUT(OUTPUT, LEL(I).KEY, 1); SET_COL(OUTPUT, 52); PUT(OUTPUT, LEL(I).ENDING); SET_COL(OUTPUT, 62); PUT(OUTPUT, LEL(I).AGE); SET_COL(OUTPUT, 64); PUT(OUTPUT, LEL(I).FREQ); NEW_LINE(OUTPUT); end if; end loop; end if; end loop; NEW_LINE; PUT("LINE_INFLECTIONS finds "); PUT(M); PUT_LINE(" inflections"); NEW_LINE; for I in Character range ' '..' ' loop INTEGER_IO.PUT(0); PUT(" "); PUT(I); PUT(" "); PUT(BELF(0, I)); PUT(" "); PUT(BELL(0, I)); PUT(" "); PUT(BELL(0, I) - BELF(0, I) + 1); NEW_LINE; end loop; NEW_LINE; for I in Character range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop if (LELL(N, I) > 0) and then (LELF(N, I) <= LELL(N, I)) then PUT(N); PUT(" "); PUT(I); PUT(" "); PUT(LELF(N, I)); PUT(" "); PUT(LELL(N, I)); PUT(" "); PUT(LELL(N, I) - LELF(N, I) + 1); NEW_LINE; end if; end loop; end loop; NEW_LINE; for I in Character range 'a'..'z' loop for N in reverse 1..MAX_ENDING_SIZE loop if (PELL(N, I) > 0) and then (PELF(N, I) <= PELL(N, I)) then PUT(N); PUT(" "); PUT(I); PUT(" "); PUT(PELF(N, I)); PUT(" "); PUT(PELL(N, I)); PUT(" "); PUT(PELL(N, I) - PELF(N, I) + 1); NEW_LINE; end if; end loop; end loop; NEW_LINE; NEW_LINE; PUT(N5); PUT(" "); PUT(N1); PUT(" "); PUT(N2); PUT(" "); PUT(N3); PUT(" "); PUT(N4); PUT(" "); NEW_LINE; end MAKEINFL;
-- LANGUAGE: Ada -- AUTHOR: Niall Cartwright -- GITHUB: https://github.com/Nairu with Ada.Text_IO; use Ada.Text_IO; procedure HelloWorld is begin Put_Line ("Hello World!"); end HelloWorld;
generic Subset_Size, More_Elements: Positive; package Iterate_Subsets is All_Elements: Positive := Subset_Size + More_Elements; subtype Index is Integer range 1 .. All_Elements; type Subset is array (1..Subset_Size) of Index; -- iterate over all subsets of size Subset_Size -- from the set {1, 2, ..., All_Element} function First return Subset; procedure Next(S: in out Subset); function Last(S: Subset) return Boolean; end Iterate_Subsets;
with Ada.Text_IO; use Ada.Text_IO; procEdure TesT is bEGin PUT('a'); EnD TeSt;
-- @file ibv_controller_process_main.adb -- @date 13 May 2018 -- @author Chester Gillon -- @details Example program created to demonstrate a GDB crash when using: -- - Eclipse Oxygen 4.7.3a -- - GNATbench Integration with CDT 2.8.1.20140109 -- - GNAT GPL 2017 -- - GDB 7.10 (in the GNAT GPL installation) -- -- Steps to recreate: -- 1) When single stepping the program when get to the first statement with msgs in scope, in the Variables -- window double-click on msgs to try and expand the contents (which fails). -- 2) On the next single step, when msgs is still in scope, GDB crashes with a SISEGV. -- -- Following an upgrade to GNAT Community 2018 which uses GDB 8.1: -- - GDB no longer crashes -- - msgs can be expanded and the contents viewed. with System; with Interfaces.C; use Interfaces.C; with stddef_h; with ibv_controller_worker_messages_h; procedure ibv_message_overlay_gdb_test is function malloc (size : stddef_h.size_t) return System.Address; pragma Import (C, malloc, "malloc"); procedure free (buffer : System.Address); pragma Import (C, free, "free"); tx_buffer : constant System.Address := malloc (ibv_controller_worker_messages_h.controller_to_worker_msgs'Size / 8); begin declare msgs : ibv_controller_worker_messages_h.controller_to_worker_msgs; pragma Import (C, msgs); for msgs'Address use tx_buffer; begin msgs.sum_integers.request_id := Interfaces.C.unsigned (10); msgs.sum_integers.num_integers_to_sum := 30; msgs.sum_integers.integers_to_sum := (others => 16#deaddead#); end; free (tx_buffer); end ibv_message_overlay_gdb_test;
pragma Check_Policy (Validate => Disable); with Ada.Strings.Naked_Maps.Canonical_Composites; -- with Ada.Strings.Naked_Maps.Debug; with Ada.Strings.Naked_Maps.Set_Constants; with System.Once; with System.Reference_Counting; package body Ada.Strings.Naked_Maps.Basic is -- Basic_Set type Character_Set_Access_With_Pool is access Character_Set_Data; Basic_Set_Data : Character_Set_Access_With_Pool; Basic_Set_Flag : aliased System.Once.Flag := 0; procedure Basic_Set_Init; procedure Basic_Set_Init is Letter_Set : constant not null Character_Set_Access := Set_Constants.Letter_Set; Base_Set : constant not null Character_Set_Access := Canonical_Composites.Base_Set; Ranges : Character_Ranges (1 .. Letter_Set.Length + Base_Set.Length); Ranges_Last : Natural; begin Intersection (Ranges, Ranges_Last, Letter_Set.Items, Base_Set.Items); Basic_Set_Data := new Character_Set_Data'( Length => Ranges_Last, Reference_Count => System.Reference_Counting.Static, Items => Ranges (1 .. Ranges_Last)); pragma Check (Validate, Debug.Valid (Basic_Set_Data.all)); end Basic_Set_Init; -- implementation of Basic_Set function Basic_Set return not null Character_Set_Access is begin System.Once.Initialize (Basic_Set_Flag'Access, Basic_Set_Init'Access); return Character_Set_Access (Basic_Set_Data); end Basic_Set; end Ada.Strings.Naked_Maps.Basic;
-- Swaggy Jenkins -- Jenkins API clients generated from Swagger / Open API specification -- ------------ EDIT NOTE ------------ -- This file was generated with openapi-generator. You can modify it to implement -- the server. After you modify this file, you should add the following line -- to the .openapi-generator-ignore file: -- -- src/-servers.ads -- -- Then, you can drop this edit note comment. -- ------------ EDIT NOTE ------------ with Swagger.Servers; with .Models; with .Skeletons; package .Servers is pragma Warnings (Off, "*use clause for package*"); use .Models; type Server_Type is limited new .Skeletons.Server_Type with null record; -- -- Retrieve CSRF protection token overriding procedure Get_Crumb (Server : in out Server_Type ; Result : out .Models.DefaultCrumbIssuer_Type; Context : in out Swagger.Servers.Context_Type); -- -- Delete queue item from an organization pipeline queue overriding procedure Delete_Pipeline_Queue_Item (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Queue : in Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve authenticated user details for an organization overriding procedure Get_Authenticated_User (Server : in out Server_Type; Organization : in Swagger.UString; Result : out .Models.User_Type; Context : in out Swagger.Servers.Context_Type); -- -- Get a list of class names supported by a given class overriding procedure Get_Classes (Server : in out Server_Type; Class : in Swagger.UString; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve JSON Web Key overriding procedure Get_Json_Web_Key (Server : in out Server_Type; Key : in Integer; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve JSON Web Token overriding procedure Get_Json_Web_Token (Server : in out Server_Type; Expiry_Time_In_Mins : in Swagger.Nullable_Integer; Max_Expiry_Time_In_Mins : in Swagger.Nullable_Integer; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve organization details overriding procedure Get_Organisation (Server : in out Server_Type; Organization : in Swagger.UString; Result : out .Models.Organisation_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve all organizations details overriding procedure Get_Organisations (Server : in out Server_Type ; Result : out .Models.Organisation_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve pipeline details for an organization overriding procedure Get_Pipeline (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Result : out .Models.Pipeline_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve all activities details for an organization pipeline overriding procedure Get_Pipeline_Activities (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Result : out .Models.PipelineActivity_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve branch details for an organization pipeline overriding procedure Get_Pipeline_Branch (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Branch : in Swagger.UString; Result : out .Models.BranchImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve branch run details for an organization pipeline overriding procedure Get_Pipeline_Branch_Run (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Branch : in Swagger.UString; Run : in Swagger.UString; Result : out .Models.PipelineRun_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve all branches details for an organization pipeline overriding procedure Get_Pipeline_Branches (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Result : out .Models.MultibranchPipeline_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve pipeline folder for an organization overriding procedure Get_Pipeline_Folder (Server : in out Server_Type; Organization : in Swagger.UString; Folder : in Swagger.UString; Result : out .Models.PipelineFolderImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve pipeline details for an organization folder overriding procedure Get_Pipeline_Folder_Pipeline (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Folder : in Swagger.UString; Result : out .Models.PipelineImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve queue details for an organization pipeline overriding procedure Get_Pipeline_Queue (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Result : out .Models.QueueItemImpl_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve run details for an organization pipeline overriding procedure Get_Pipeline_Run (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Result : out .Models.PipelineRun_Type; Context : in out Swagger.Servers.Context_Type); -- -- Get log for a pipeline run overriding procedure Get_Pipeline_Run_Log (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Start : in Swagger.Nullable_Integer; Download : in Swagger.Nullable_Boolean; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve run node details for an organization pipeline overriding procedure Get_Pipeline_Run_Node (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Node : in Swagger.UString; Result : out .Models.PipelineRunNode_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve run node details for an organization pipeline overriding procedure Get_Pipeline_Run_Node_Step (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Node : in Swagger.UString; Step : in Swagger.UString; Result : out .Models.PipelineStepImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Get log for a pipeline run node step overriding procedure Get_Pipeline_Run_Node_Step_Log (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Node : in Swagger.UString; Step : in Swagger.UString; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve run node steps details for an organization pipeline overriding procedure Get_Pipeline_Run_Node_Steps (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Node : in Swagger.UString; Result : out .Models.PipelineStepImpl_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve run nodes details for an organization pipeline overriding procedure Get_Pipeline_Run_Nodes (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Result : out .Models.PipelineRunNode_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve all runs details for an organization pipeline overriding procedure Get_Pipeline_Runs (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Result : out .Models.PipelineRun_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve all pipelines details for an organization overriding procedure Get_Pipelines (Server : in out Server_Type; Organization : in Swagger.UString; Result : out .Models.Pipeline_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve SCM details for an organization overriding procedure Get_SCM (Server : in out Server_Type; Organization : in Swagger.UString; Scm : in Swagger.UString; Result : out .Models.GithubScm_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve SCM organization repositories details for an organization overriding procedure Get_SCMOrganisation_Repositories (Server : in out Server_Type; Organization : in Swagger.UString; Scm : in Swagger.UString; Scm_Organisation : in Swagger.UString; Credential_Id : in Swagger.Nullable_UString; Page_Size : in Swagger.Nullable_Integer; Page_Number : in Swagger.Nullable_Integer; Result : out .Models.GithubOrganization_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve SCM organization repository details for an organization overriding procedure Get_SCMOrganisation_Repository (Server : in out Server_Type; Organization : in Swagger.UString; Scm : in Swagger.UString; Scm_Organisation : in Swagger.UString; Repository : in Swagger.UString; Credential_Id : in Swagger.Nullable_UString; Result : out .Models.GithubOrganization_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve SCM organizations details for an organization overriding procedure Get_SCMOrganisations (Server : in out Server_Type; Organization : in Swagger.UString; Scm : in Swagger.UString; Credential_Id : in Swagger.Nullable_UString; Result : out .Models.GithubOrganization_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve user details for an organization overriding procedure Get_User (Server : in out Server_Type; Organization : in Swagger.UString; User : in Swagger.UString; Result : out .Models.User_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve user favorites details for an organization overriding procedure Get_User_Favorites (Server : in out Server_Type; User : in Swagger.UString; Result : out .Models.FavoriteImpl_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve users details for an organization overriding procedure Get_Users (Server : in out Server_Type; Organization : in Swagger.UString; Result : out .Models.User_Type; Context : in out Swagger.Servers.Context_Type); -- -- Replay an organization pipeline run overriding procedure Post_Pipeline_Run (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Result : out .Models.QueueItemImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Start a build for an organization pipeline overriding procedure Post_Pipeline_Runs (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Result : out .Models.QueueItemImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Favorite/unfavorite a pipeline overriding procedure Put_Pipeline_Favorite (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; P_Body : in Boolean; Result : out .Models.FavoriteImpl_Type; Context : in out Swagger.Servers.Context_Type); -- -- Stop a build of an organization pipeline overriding procedure Put_Pipeline_Run (Server : in out Server_Type; Organization : in Swagger.UString; Pipeline : in Swagger.UString; Run : in Swagger.UString; Blocking : in Swagger.Nullable_UString; Time_Out_In_Secs : in Swagger.Nullable_Integer; Result : out .Models.PipelineRun_Type; Context : in out Swagger.Servers.Context_Type); -- -- Search for any resource details overriding procedure Search (Server : in out Server_Type; Q : in Swagger.UString; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Get classes details overriding procedure Search_Classes (Server : in out Server_Type; Q : in Swagger.UString; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve computer details overriding procedure Get_Computer (Server : in out Server_Type; Depth : in Integer; Result : out .Models.ComputerSet_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve Jenkins details overriding procedure Get_Jenkins (Server : in out Server_Type ; Result : out .Models.Hudson_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve job details overriding procedure Get_Job (Server : in out Server_Type; Name : in Swagger.UString; Result : out .Models.FreeStyleProject_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve job configuration overriding procedure Get_Job_Config (Server : in out Server_Type; Name : in Swagger.UString; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve job's last build details overriding procedure Get_Job_Last_Build (Server : in out Server_Type; Name : in Swagger.UString; Result : out .Models.FreeStyleBuild_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve job's build progressive text output overriding procedure Get_Job_Progressive_Text (Server : in out Server_Type; Name : in Swagger.UString; Number : in Swagger.UString; Start : in Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve queue details overriding procedure Get_Queue (Server : in out Server_Type ; Result : out .Models.Queue_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve queued item details overriding procedure Get_Queue_Item (Server : in out Server_Type; Number : in Swagger.UString; Result : out .Models.Queue_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve view details overriding procedure Get_View (Server : in out Server_Type; Name : in Swagger.UString; Result : out .Models.ListView_Type; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve view configuration overriding procedure Get_View_Config (Server : in out Server_Type; Name : in Swagger.UString; Result : out Swagger.UString; Context : in out Swagger.Servers.Context_Type); -- -- Retrieve Jenkins headers overriding procedure Head_Jenkins (Server : in out Server_Type ; Context : in out Swagger.Servers.Context_Type); -- -- Create a new job using job configuration, or copied from an existing job overriding procedure Post_Create_Item (Server : in out Server_Type; Name : in Swagger.UString; From : in Swagger.Nullable_UString; Mode : in Swagger.Nullable_UString; Jenkins_Crumb : in Swagger.Nullable_UString; Content_Type : in Swagger.Nullable_UString; P_Body : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Create a new view using view configuration overriding procedure Post_Create_View (Server : in out Server_Type; Name : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Content_Type : in Swagger.Nullable_UString; P_Body : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Build a job overriding procedure Post_Job_Build (Server : in out Server_Type; Name : in Swagger.UString; Json : in Swagger.UString; Token : in Swagger.Nullable_UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Update job configuration overriding procedure Post_Job_Config (Server : in out Server_Type; Name : in Swagger.UString; P_Body : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Delete a job overriding procedure Post_Job_Delete (Server : in out Server_Type; Name : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Disable a job overriding procedure Post_Job_Disable (Server : in out Server_Type; Name : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Enable a job overriding procedure Post_Job_Enable (Server : in out Server_Type; Name : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Stop a job overriding procedure Post_Job_Last_Build_Stop (Server : in out Server_Type; Name : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); -- -- Update view configuration overriding procedure Post_View_Config (Server : in out Server_Type; Name : in Swagger.UString; P_Body : in Swagger.UString; Jenkins_Crumb : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type); package Server_Impl is new .Skeletons.Shared_Instance (Server_Type); end .Servers;
--////////////////////////////////////////////////////////// -- SFML - Simple and Fast Multimedia Library -- Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) -- 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 Sf.System.Vector3; package Sf.Window.Sensor is --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --/ @brief Sensor Types --/ --////////////////////////////////////////////////////////// --/< Measures the raw acceleration (m/s^2) --/< Measures the raw rotation rates (degrees/s) --/< Measures the ambient magnetic field (micro-teslas) --/< Measures the direction and intensity of gravity, independent of device acceleration (m/s^2) --/< Measures the direction and intensity of device acceleration, independent of the gravity (m/s^2) --/< Measures the absolute 3D orientation (degrees) --/< Keep last -- the total number of sensor types type sfSensorType is (sfSensorAccelerometer, sfSensorGyroscope, sfSensorMagnetometer, sfSensorGravity, sfSensorUserAcceleration, sfSensorOrientation, sfSensorCount); pragma Convention (C, sfSensorType); --////////////////////////////////////////////////////////// --/ @brief Check if a sensor is available on the underlying platform --/ --/ @param sensor Sensor to check --/ --/ @return sfTrue if the sensor is available, sfFalse otherwise --/ --////////////////////////////////////////////////////////// function isAvailable (sensor : sfSensorType) return sfBool; --////////////////////////////////////////////////////////// --/ @brief Enable or disable a sensor --/ --/ All sensors are disabled by default, to avoid consuming too --/ much battery power. Once a sensor is enabled, it starts --/ sending events of the corresponding type. --/ --/ This function does nothing if the sensor is unavailable. --/ --/ @param sensor Sensor to enable --/ @param enabled sfTrue to enable, sfFalse to disable --/ --////////////////////////////////////////////////////////// procedure setEnabled (sensor : sfSensorType; enabled : sfBool); --////////////////////////////////////////////////////////// --/ @brief Get the current sensor value --/ --/ @param sensor Sensor to read --/ --/ @return The current sensor value --/ --////////////////////////////////////////////////////////// function getValue (sensor : sfSensorType) return Sf.System.Vector3.sfVector3f; private pragma Import (C, isAvailable, "sfSensor_isAvailable"); pragma Import (C, setEnabled, "sfSensor_setEnabled"); pragma Import (C, getValue, "sfSensor_getValue"); end Sf.Window.Sensor;
package Listas is type Lista is limited private; -- Tipo lista ordenada creciente procedure Crear_Vacia ( L : out Lista); -- Post: crea la lista vacia L procedure Colocar ( L : in out Lista; E : in Integer); -- Pre: L es una lista ordenada crecientemente -- Post: Coloca en orden creciente el elemento E en L si hay espacio en la lista -- Si la lista est� llena dar� un mensaje de Lista_Llena procedure Obtener_Primero ( L : in Lista; P: out Integer); -- Pre: L es una lista ordenada crecientemente -- Post: P es el primer elemento de la lista L, si L no est� vac�a. -- Si la lista est� vac�a dar� un mensaje de Lista_Vacia function Esta ( L : in Lista; N : in Integer) return Boolean; -- Post: True sii C esta en la lista L procedure Borrar_Primero ( L : in out Lista); -- Pre: L es una lista ordenada crecientemente -- Si la lista est� vac�a dar� un mensaje de Lista_Vacia function Es_Vacia ( L : in Lista) return Boolean; -- Pre: L es una lista ordenada crecientemente -- Post: True sii la lista L es vacia function Igual ( L1, L2 : in Lista) return Boolean; -- Pre: L1 y L2 son listas ordenadas -- Post: True sii L1 y L2 son iguales (representan listas iguales) procedure Copiar ( L1 : out Lista; L2 : in Lista); -- Pre: L2 es lista ordenada -- Post: L1 es una lista ordenada copia de L2. generic with function Filtro(I: Integer) return Boolean; Cuantos: in Integer; procedure Crear_Sublista( L : in Lista; Sl: out Lista ); -- Pre: L es una lista ordenada crecientemente -- Post: La sublista Sl esta formada por los n (donde n está condicionado por el parametro CUANTOS) -- primeros elementos pares de la lista L. -- Si no hay 4, la crear� con los elementos que pares que haya en L. private -- implementacion dinamica, ligadura simple type Nodo; type Lista is access Nodo; type Nodo is record Info : Integer; Sig : Lista; end record; end Listas;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2018, 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 STMicroelectronics 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 HAL; use HAL; with HAL.I2C; use HAL.I2C; with System; with System.Address_Image; with Interfaces; with Interfaces.C; use Interfaces.C; with Posix; use Posix; with Ada.Unchecked_Conversion; -- TODO: Remove this after finishing Debuging with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; package Native.I2C is type I2C_Port is new HAL.I2C.I2C_Port with private; -- TODO: Check whether this is even supported by I2CDev type I2C_Acknowledgement is (Ack_Disable, Ack_Enable); type I2C_Addressing_Mode is (Addressing_Mode_7bit, Addressing_Mode_10bit); type I2C_Device_Mode is (I2C_Mode, SMBusDevice_Mode, SMBusHost_Mode); type I2C_Configuration is record Addressing_Mode : I2C_Addressing_Mode; Ack : I2C_Acknowledgement; Device_Mode : I2C_Device_Mode; end record; function Configure (Device : String; Conf : I2C_Configuration; Status : out HAL.I2C.I2C_Status) return I2C_Port; overriding procedure Master_Transmit (This : in out I2C_Port; Addr : HAL.I2C.I2C_Address; Data : HAL.I2C.I2C_Data; Status : out HAL.I2C.I2C_Status; Timeout : Natural := 1000); overriding procedure Master_Receive (This : in out I2C_Port; Addr : HAL.I2C.I2C_Address; Data : out HAL.I2C.I2C_Data; Status : out HAL.I2C.I2C_Status; Timeout : Natural := 1000); overriding procedure Mem_Write (This : in out I2C_Port; Addr : HAL.I2C.I2C_Address; Mem_Addr : UInt16; Mem_Addr_Size : HAL.I2C.I2C_Memory_Address_Size; Data : HAL.I2C.I2C_Data; Status : out HAL.I2C.I2C_Status; Timeout : Natural := 1000); overriding procedure Mem_Read (This : in out I2C_Port; Addr : HAL.I2C.I2C_Address; Mem_Addr : UInt16; Mem_Addr_Size : HAL.I2C.I2C_Memory_Address_Size; Data : out HAL.I2C.I2C_Data; Status : out HAL.I2C.I2C_Status; Timeout : Natural := 1000); private type I2C_Port is new HAL.I2C.I2C_Port with record File_Desc : File_Id; Config : I2C_Configuration; end record; -- These values originate from linux/i2c-dev.h I2C_RETRIES : constant HAL.UInt32 := 16#0701#; I2C_TIMEOUT : constant HAL.UInt32 := 16#0702#; I2C_SLAVE : constant HAL.UInt32 := 16#0703#; I2C_SLAVE_FORCE : constant HAL.UInt32 := 16#0706#; I2C_TENBIT : constant HAL.UInt32 := 16#0704#; I2C_FUNCS : constant HAL.UInt32 := 16#0705#; I2C_RDWR : constant HAL.UInt32 := 16#0707#; I2C_PEC : constant HAL.UInt32 := 16#0708#; I2C_SMBUS : constant HAL.UInt32 := 16#0720#; end Native.I2C;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . F O R M A T T E D _ S T R I N G -- -- -- -- S p e c -- -- -- -- Copyright (C) 2014-2020, 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. -- -- -- ------------------------------------------------------------------------------ -- This package add support for formatted string as supported by C printf() -- A simple usage is: -- -- Put_Line (-(+"%s" & "a string")); -- -- or with a constant for the format: -- -- declare -- Format : constant Formatted_String := +"%s"; -- begin -- Put_Line (-(Format & "a string")); -- end; -- -- Finally a more complex example: -- -- declare -- F : Formatted_String := +"['%c' ; %10d]"; -- C : Character := 'v'; -- I : Integer := 98; -- begin -- F := F & C & I; -- Put_Line (-F); -- end; -- Which will display: -- ['v' ; 98] -- Each format specifier is: %[flags][width][.precision][length]specifier -- Specifiers: -- d or i Signed decimal integer -- u Unsigned decimal integer -- o Unsigned octal -- x Unsigned hexadecimal integer -- X Unsigned hexadecimal integer (uppercase) -- f Decimal floating point, lowercase -- F Decimal floating point, uppercase -- e Scientific notation (mantissa/exponent), lowercase -- E Scientific notation (mantissa/exponent), uppercase -- g Use the shortest representation: %e or %f -- G Use the shortest representation: %E or %F -- c Character -- s String of characters -- p Pointer address -- % A % followed by another % character will write a single % -- Flags: -- - Left-justify within the given field width; -- Right justification is the default. -- + Forces to preceed the result with a plus or minus sign (+ or -) -- even for positive numbers. By default, only negative numbers -- are preceded with a - sign. -- (space) If no sign is going to be written, a blank space is inserted -- before the value. -- # Used with o, x or X specifiers the value is preceeded with -- 0, 0x or 0X respectively for values different than zero. -- Used with a, A, e, E, f, F, g or G it forces the written -- output to contain a decimal point even if no more digits -- follow. By default, if no digits follow, no decimal point is -- written. -- ~ As above, but using Ada style based <base>#<number># -- 0 Left-pads the number with zeroes (0) instead of spaces when -- padding is specified. -- Width: -- number Minimum number of characters to be printed. If the value to -- be printed is shorter than this number, the result is padded -- with blank spaces. The value is not truncated even if the -- result is larger. -- * The width is not specified in the format string, but as an -- additional integer value argument preceding the argument that -- has to be formatted. -- Precision: -- number For integer specifiers (d, i, o, u, x, X): precision specifies -- the minimum number of digits to be written. If the value to be -- written is shorter than this number, the result is padded with -- leading zeros. The value is not truncated even if the result -- is longer. A precision of 0 means that no character is written -- for the value 0. -- For e, E, f and F specifiers: this is the number of digits to -- be printed after the decimal point (by default, this is 6). -- For g and G specifiers: This is the maximum number of -- significant digits to be printed. -- For s: this is the maximum number of characters to be printed. -- By default all characters are printed until the ending null -- character is encountered. -- If the period is specified without an explicit value for -- precision, 0 is assumed. -- .* The precision is not specified in the format string, but as an -- additional integer value argument preceding the argument that -- has to be formatted. with Ada.Text_IO; with System; private with Ada.Finalization; private with Ada.Strings.Unbounded; package GNAT.Formatted_String is use Ada; type Formatted_String (<>) is private; -- A format string as defined for printf routine. This string is the -- actual format for all the parameters added with the "&" routines below. -- Note that a Formatted_String object can't be reused as it serves as -- recipient for the final result. That is, each use of "&" will build -- incrementally the final result string which can be retrieved with -- the "-" routine below. Format_Error : exception; -- Raised for every mismatch between the parameter and the expected format -- and for malformed format. function "+" (Format : String) return Formatted_String; -- Create the format string function "-" (Format : Formatted_String) return String; -- Get the result of the formatted string corresponding to the current -- rendering (up to the last parameter formated). function "&" (Format : Formatted_String; Var : Character) return Formatted_String; -- A character, expect a %c function "&" (Format : Formatted_String; Var : String) return Formatted_String; -- A string, expect a %s function "&" (Format : Formatted_String; Var : Boolean) return Formatted_String; -- A boolean image, expect a %s function "&" (Format : Formatted_String; Var : Integer) return Formatted_String; -- An integer, expect a %d, %o, %x, %X function "&" (Format : Formatted_String; Var : Long_Integer) return Formatted_String; -- As above function "&" (Format : Formatted_String; Var : System.Address) return Formatted_String; -- An address, expect a %p function "&" (Format : Formatted_String; Var : Float) return Formatted_String; -- A float, expect %f, %e, %F, %E, %g, %G function "&" (Format : Formatted_String; Var : Long_Float) return Formatted_String; -- As above function "&" (Format : Formatted_String; Var : Duration) return Formatted_String; -- As above -- Some generics generic type Int is range <>; with procedure Put (To : out String; Item : Int; Base : Text_IO.Number_Base); function Int_Format (Format : Formatted_String; Var : Int) return Formatted_String; -- As for Integer above generic type Int is mod <>; with procedure Put (To : out String; Item : Int; Base : Text_IO.Number_Base); function Mod_Format (Format : Formatted_String; Var : Int) return Formatted_String; -- As for Integer above generic type Flt is digits <>; with procedure Put (To : out String; Item : Flt; Aft : Text_IO.Field; Exp : Text_IO.Field); function Flt_Format (Format : Formatted_String; Var : Flt) return Formatted_String; -- As for Float above generic type Flt is delta <>; with procedure Put (To : out String; Item : Flt; Aft : Text_IO.Field; Exp : Text_IO.Field); function Fixed_Format (Format : Formatted_String; Var : Flt) return Formatted_String; -- As for Float above generic type Flt is delta <> digits <>; with procedure Put (To : out String; Item : Flt; Aft : Text_IO.Field; Exp : Text_IO.Field); function Decimal_Format (Format : Formatted_String; Var : Flt) return Formatted_String; -- As for Float above generic type Enum is (<>); function Enum_Format (Format : Formatted_String; Var : Enum) return Formatted_String; -- As for String above, output the string representation of the enumeration private use Ada.Strings.Unbounded; type I_Vars is array (Positive range 1 .. 2) of Integer; -- Used to keep 2 numbers for the possible * for the width and precision type Data (Size : Natural) is record Ref_Count : Natural := 1; Index : Positive := 1; -- format index for next value Result : Unbounded_String; -- current value Current : Natural; -- the current format number Stored_Value : Natural := 0; -- number of stored values in Stack Stack : I_Vars; Format : String (1 .. Size); -- the format string end record; type Data_Access is access Data; -- The formatted string record is controlled and do not need an initialize -- as it requires an explit initial value. This is given with "+" and -- properly initialize the record at this point. type Formatted_String is new Finalization.Controlled with record D : Data_Access; end record; overriding procedure Adjust (F : in out Formatted_String); overriding procedure Finalize (F : in out Formatted_String); end GNAT.Formatted_String;
-- Copyright 2017-2021 Bartek thindil Jasicki -- -- This file is part of Steam Sky. -- -- Steam Sky 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. -- -- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>. with Ada.Numerics.Discrete_Random; package body Utils with SPARK_Mode is function Get_Random(Min, Max: Integer) return Integer with SPARK_Mode => Off is use Ada.Numerics; subtype Rand_Range is Integer range Min .. Max; package Rand_Roll is new Discrete_Random(Result_Subtype => Rand_Range); Generator: Rand_Roll.Generator; begin Rand_Roll.Reset(Gen => Generator); return Rand_Roll.Random(Gen => Generator); end Get_Random; function Generate_Robotic_Name return Unbounded_String is Letters_Amount: constant Positive := Get_Random(Min => 2, Max => 5); Numbers_Amount: constant Positive := Get_Random(Min => 2, Max => 4); subtype Letters is Character range 'A' .. 'Z'; subtype Numbers is Character range '0' .. '9'; New_Name: Unbounded_String := To_Unbounded_String (Source => "" & Letters'Val (Get_Random (Min => Letters'Pos(Letters'First), Max => Letters'Pos(Letters'Last)))); begin First_Name_Part_Loop : for I in 2 .. Letters_Amount loop pragma Loop_Invariant(Length(Source => New_Name) = I - 1); Append (Source => New_Name, New_Item => Letters'Val (Get_Random (Min => Letters'Pos(Letters'First), Max => Letters'Pos(Letters'Last)))); end loop First_Name_Part_Loop; Append(Source => New_Name, New_Item => '-'); Second_Name_Part_Loop : for I in 1 .. Numbers_Amount loop pragma Loop_Invariant (Length(Source => New_Name) = Length(Source => New_Name'Loop_Entry) + (I - 1)); Append (Source => New_Name, New_Item => Numbers'Val (Get_Random (Min => Numbers'Pos(Numbers'First), Max => Numbers'Pos(Numbers'Last)))); end loop Second_Name_Part_Loop; return New_Name; end Generate_Robotic_Name; end Utils;
with Ada.Exception_Identification.From_Here; with System.Native_Credentials; with System.Zero_Terminated_Strings; with C.errno; with C.stdint; package body System.Native_Directories.Volumes is use Ada.Exception_Identification.From_Here; use type File_Size; use type C.signed_int; use type C.size_t; use type C.stdint.uint32_t; -- implementation function Is_Assigned (FS : File_System) return Boolean is begin return FS.Statistics.f_version /= 0; end Is_Assigned; procedure Get (Name : String; FS : aliased out File_System) is C_Name : C.char_array ( 0 .. Name'Length * Zero_Terminated_Strings.Expanding); begin Zero_Terminated_Strings.To_C (Name, C_Name (0)'Access); if C.sys.mount.statfs (C_Name (0)'Access, FS.Statistics'Access) < 0 then Raise_Exception (Named_IO_Exception_Id (C.errno.errno)); end if; end Get; function Size (FS : File_System) return File_Size is begin return File_Size (FS.Statistics.f_blocks) * File_Size (FS.Statistics.f_bsize); end Size; function Free_Space (FS : File_System) return File_Size is begin return File_Size (FS.Statistics.f_bfree) * File_Size (FS.Statistics.f_bsize); end Free_Space; function Owner (FS : File_System) return String is begin return Native_Credentials.User_Name (FS.Statistics.f_owner); end Owner; function Format_Name (FS : File_System) return String is begin return Zero_Terminated_Strings.Value ( FS.Statistics.f_fstypename (0)'Access); end Format_Name; function Directory (FS : File_System) return String is begin return Zero_Terminated_Strings.Value ( FS.Statistics.f_mntonname (0)'Access); end Directory; function Device (FS : File_System) return String is begin return Zero_Terminated_Strings.Value ( FS.Statistics.f_mntfromname (0)'Access); end Device; function Identity (FS : File_System) return File_System_Id is begin return FS.Statistics.f_fsid; end Identity; end System.Native_Directories.Volumes;
-- This spec has been automatically generated from STM32F7x9.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.DMA is pragma Preelaborate; --------------- -- Registers -- --------------- -- low interrupt status register type LISR_Register is record -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF0 : Boolean; -- unspecified Reserved_1_1 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF0 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF0 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF0 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF0 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF1 : Boolean; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF1 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF1 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF1 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF1 : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF2 : Boolean; -- unspecified Reserved_17_17 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF2 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF2 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF2 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF2 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF3 : Boolean; -- unspecified Reserved_23_23 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF3 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF3 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF3 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF3 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LISR_Register use record FEIF0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DMEIF0 at 0 range 2 .. 2; TEIF0 at 0 range 3 .. 3; HTIF0 at 0 range 4 .. 4; TCIF0 at 0 range 5 .. 5; FEIF1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DMEIF1 at 0 range 8 .. 8; TEIF1 at 0 range 9 .. 9; HTIF1 at 0 range 10 .. 10; TCIF1 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; FEIF2 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DMEIF2 at 0 range 18 .. 18; TEIF2 at 0 range 19 .. 19; HTIF2 at 0 range 20 .. 20; TCIF2 at 0 range 21 .. 21; FEIF3 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; DMEIF3 at 0 range 24 .. 24; TEIF3 at 0 range 25 .. 25; HTIF3 at 0 range 26 .. 26; TCIF3 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- high interrupt status register type HISR_Register is record -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF4 : Boolean; -- unspecified Reserved_1_1 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF4 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF4 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF4 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF4 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF5 : Boolean; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF5 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF5 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF5 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF5 : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF6 : Boolean; -- unspecified Reserved_17_17 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF6 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF6 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF6 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF6 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF7 : Boolean; -- unspecified Reserved_23_23 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF7 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF7 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF7 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF7 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HISR_Register use record FEIF4 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DMEIF4 at 0 range 2 .. 2; TEIF4 at 0 range 3 .. 3; HTIF4 at 0 range 4 .. 4; TCIF4 at 0 range 5 .. 5; FEIF5 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DMEIF5 at 0 range 8 .. 8; TEIF5 at 0 range 9 .. 9; HTIF5 at 0 range 10 .. 10; TCIF5 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; FEIF6 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DMEIF6 at 0 range 18 .. 18; TEIF6 at 0 range 19 .. 19; HTIF6 at 0 range 20 .. 20; TCIF6 at 0 range 21 .. 21; FEIF7 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; DMEIF7 at 0 range 24 .. 24; TEIF7 at 0 range 25 .. 25; HTIF7 at 0 range 26 .. 26; TCIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- low interrupt flag clear register type LIFCR_Register is record -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF0 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF0 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF0 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF0 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF0 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF1 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF1 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF1 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF1 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF1 : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF2 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF2 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF2 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF2 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF2 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF3 : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF3 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF3 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF3 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF3 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LIFCR_Register use record CFEIF0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CDMEIF0 at 0 range 2 .. 2; CTEIF0 at 0 range 3 .. 3; CHTIF0 at 0 range 4 .. 4; CTCIF0 at 0 range 5 .. 5; CFEIF1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CDMEIF1 at 0 range 8 .. 8; CTEIF1 at 0 range 9 .. 9; CHTIF1 at 0 range 10 .. 10; CTCIF1 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CFEIF2 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CDMEIF2 at 0 range 18 .. 18; CTEIF2 at 0 range 19 .. 19; CHTIF2 at 0 range 20 .. 20; CTCIF2 at 0 range 21 .. 21; CFEIF3 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; CDMEIF3 at 0 range 24 .. 24; CTEIF3 at 0 range 25 .. 25; CHTIF3 at 0 range 26 .. 26; CTCIF3 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- high interrupt flag clear register type HIFCR_Register is record -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF4 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF4 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF4 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF4 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF4 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF5 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF5 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF5 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF5 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF5 : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF6 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF6 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF6 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF6 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF6 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF7 : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF7 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF7 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF7 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF7 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HIFCR_Register use record CFEIF4 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CDMEIF4 at 0 range 2 .. 2; CTEIF4 at 0 range 3 .. 3; CHTIF4 at 0 range 4 .. 4; CTCIF4 at 0 range 5 .. 5; CFEIF5 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CDMEIF5 at 0 range 8 .. 8; CTEIF5 at 0 range 9 .. 9; CHTIF5 at 0 range 10 .. 10; CTCIF5 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CFEIF6 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CDMEIF6 at 0 range 18 .. 18; CTEIF6 at 0 range 19 .. 19; CHTIF6 at 0 range 20 .. 20; CTCIF6 at 0 range 21 .. 21; CFEIF7 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; CDMEIF7 at 0 range 24 .. 24; CTEIF7 at 0 range 25 .. 25; CHTIF7 at 0 range 26 .. 26; CTCIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -------------------------------- -- Stream cluster's Registers -- -------------------------------- subtype SxCR_Stream_DIR_Field is HAL.UInt2; subtype SxCR_Stream_PSIZE_Field is HAL.UInt2; subtype SxCR_Stream_MSIZE_Field is HAL.UInt2; subtype SxCR_Stream_PL_Field is HAL.UInt2; subtype SxCR_Stream_PBURST_Field is HAL.UInt2; subtype SxCR_Stream_MBURST_Field is HAL.UInt2; subtype SxCR_Stream_CHSEL_Field is HAL.UInt4; -- stream x configuration register type SxCR_Stream_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : SxCR_Stream_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : SxCR_Stream_PSIZE_Field := 16#0#; -- Memory data size MSIZE : SxCR_Stream_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : SxCR_Stream_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Peripheral burst transfer configuration PBURST : SxCR_Stream_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : SxCR_Stream_MBURST_Field := 16#0#; -- Channel selection CHSEL : SxCR_Stream_CHSEL_Field := 16#0#; -- unspecified Reserved_29_31 : HAL.UInt3 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SxCR_Stream_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; Reserved_20_20 at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; subtype SxNDTR_Stream_NDT_Field is HAL.UInt16; -- stream x number of data register type SxNDTR_Stream_Register is record -- Number of data items to transfer NDT : SxNDTR_Stream_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SxNDTR_Stream_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SxFCR_Stream_FTH_Field is HAL.UInt2; subtype SxFCR_Stream_FS_Field is HAL.UInt3; -- stream x FIFO control register type SxFCR_Stream_Register is record -- FIFO threshold selection FTH : SxFCR_Stream_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : SxFCR_Stream_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SxFCR_Stream_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Stream registers type Stream_Cluster is record -- stream x configuration register SxCR : aliased SxCR_Stream_Register; -- stream x number of data register SxNDTR : aliased SxNDTR_Stream_Register; -- stream x peripheral address register SxPAR : aliased HAL.UInt32; -- stream x memory 0 address register SxM0AR : aliased HAL.UInt32; -- stream x memory 1 address register SxM1AR : aliased HAL.UInt32; -- stream x FIFO control register SxFCR : aliased SxFCR_Stream_Register; end record with Volatile, Size => 192; for Stream_Cluster use record SxCR at 16#0# range 0 .. 31; SxNDTR at 16#4# range 0 .. 31; SxPAR at 16#8# range 0 .. 31; SxM0AR at 16#C# range 0 .. 31; SxM1AR at 16#10# range 0 .. 31; SxFCR at 16#14# range 0 .. 31; end record; -- Stream registers type Stream_Clusters is array (0 .. 7) of Stream_Cluster; -------------------------------- -- Stream cluster's Registers -- -------------------------------- ----------------- -- Peripherals -- ----------------- -- DMA controller type DMA_Peripheral is record -- low interrupt status register LISR : aliased LISR_Register; -- high interrupt status register HISR : aliased HISR_Register; -- low interrupt flag clear register LIFCR : aliased LIFCR_Register; -- high interrupt flag clear register HIFCR : aliased HIFCR_Register; -- Stream registers Stream : aliased Stream_Clusters; end record with Volatile; for DMA_Peripheral use record LISR at 16#0# range 0 .. 31; HISR at 16#4# range 0 .. 31; LIFCR at 16#8# range 0 .. 31; HIFCR at 16#C# range 0 .. 31; Stream at 16#10# range 0 .. 1535; end record; -- DMA controller DMA1_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40026000#); -- DMA controller DMA2_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40026400#); end STM32_SVD.DMA;
----------------------------------------------------------------------------- -- Helpers package for different functions/procedures to minimize -- code duplication -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with HAL.I2C; with RP.GPIO; with RP.I2C_Master; with EEPROM_I2C; package Helpers is type LED_Off is access procedure; procedure Initialize (SDA : in out RP.GPIO.GPIO_Point; SCL : in out RP.GPIO.GPIO_Point; I2C_Port : in out RP.I2C_Master.I2C_Master_Port; Trigger_Port : RP.GPIO.GPIO_Point; Frequency : Natural); procedure Trigger_Enable; procedure Trigger_Disable; function Trigger_Is_Enabled return Boolean; procedure Wait_For_Trigger_Fired; procedure Wait_For_Trigger_Resume; procedure Fill_With (Fill_Data : out HAL.I2C.I2C_Data; Byte : HAL.UInt8 := 16#FF#); procedure Check_Full_Size (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Check_Header_Only (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Check_Header_And_Full_Pages (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Check_Header_And_Tailing (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Check_Header_And_Full_Pages_And_Tailing (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Check_Full_Pages (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Check_Full_Pages_And_Tailing (EEP : in out EEPROM_I2C.EEPROM_Memory'Class; CB_LED_Off : LED_Off); procedure Verify_Data (Expected : HAL.I2C.I2C_Data; Actual : HAL.I2C.I2C_Data; CB_LED_Off : LED_Off); procedure ItsyBitsy_Led_Off; procedure Pico_Led_Off; procedure Tiny_Led_Off; end Helpers;
with ada.text_io; use ada.text_IO; Package body sor is procedure push(s : in out sora; e : elem) is begin s.hossz := s.hossz+1; s.t(s.hossz) := e; end; procedure pop(s : in out sora) is begin for i in 2 .. s.hossz loop s.t(i-1) := s.t(i); end loop; s.hossz := s.hossz-1; end; procedure kiir(s : sora) is begin for i in 1..s.hossz loop kiirok(s.t(i)); end loop; end; procedure feltetelesKiiras(s : sora) is begin Put_Line(elem'image(s.t(felt(s.hossz)))); end; end;
-- { dg-do run } with Init9; use Init9; with Ada.Numerics; use Ada.Numerics; with Text_IO; use Text_IO; with Dump; procedure P9 is Local_R1 : R1; Local_R2 : R2; begin Put ("My_R1 :"); Dump (My_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "My_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Put ("My_R2 :"); Dump (My_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "My_R2 : 40 09 21 fb 54 44 2d 18.*\n" } Local_R1 := My_R1; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Local_R2 := My_R2; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 40 09 21 fb 54 44 2d 18.*\n" } Local_R1.F := Pi; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Local_R2.F := Pi; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 40 09 21 fb 54 44 2d 18.*\n" } Local_R1.F := Local_R2.F; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Local_R2.F := Local_R1.F; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 40 09 21 fb 54 44 2d 18.*\n" } end;
with Qt; use Qt; with xph_covid19; use xph_covid19; package xph_model is -- procedure set_inputs(country_val : country; -- start_day_index_val : integer; -- end_day_index_val : integer; -- steps_val : integer; -- minimize_by_density_val : boolean; -- zoom_factor_val : float; -- minimal_improvement_percentage_val : float; -- fore_term_val : integer; -- bend_percent_val : float); procedure init_model (form_widget: QWidgetH; chart_widget : QChartH); procedure slot_compute_xph; pragma Convention (C, slot_compute_xph); procedure slot_change_country_choice (country_name : QStringH); pragma Convention (C, slot_change_country_choice); procedure slot_start_date_changed (date: QDateH); pragma Convention (C, slot_start_date_changed); procedure slot_end_date_changed (date: QDateH); pragma Convention (C, slot_end_date_changed); procedure slot_change_forecast_days (foracast_days_val: Integer); pragma Convention (C, slot_change_forecast_days); procedure slot_change_refine_search (state: integer); pragma Convention (C, slot_change_refine_search); end xph_model;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . B I T F I E L D _ U T I L S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2019-2020, 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 System.Bitfield_Utils is -- This package provides a procedure for copying arbitrarily large and -- arbitrarily bit-aligned bit fields. -- Type Val is used to represent small bit fields. Val_2 represents a -- contiguous pair of Vals. Val_2'Alignment is half of its size in bytes, -- which is likely not the natural alignment. This is done to ensure that -- any bit field that fits in a Val can fit in an aligned Val_2, starting -- somewhere in the first half, and possibly crossing over into the second -- half. This allows us to isolate a Val value by shifting and masking the -- Val_2. -- -- Val can be 8, 16, or 32 bits; larger values are more efficient. It can't -- be 64 bits, because we need Val_2 to be a double-wide shiftable type, -- and 128 bits is not supported. Instantiating with an 8-bit Val is useful -- for testing and debugging; 32 bits should be used for production. -- -- We use modular types here, not because we want modular arithmetic, but -- so we can do shifting and masking. The actual for Val_2 should have -- pragma Provide_Shift_Operators, so that the Shift_Left and Shift_Right -- intrinsics can be passed in. It is impossible to put that pragma on a -- generic formal, or on a type derived from a generic formal, so they have -- to be passed in. -- -- Endian indicates whether we're on little-endian or big-endian machine. pragma Elaborate_Body; Little : constant Bit_Order := Low_Order_First; Big : constant Bit_Order := High_Order_First; generic type Val is mod <>; type Val_2 is mod <>; with function Shift_Left (Value : Val_2; Amount : Natural) return Val_2 is <>; with function Shift_Right (Value : Val_2; Amount : Natural) return Val_2 is <>; Endian : Bit_Order := Default_Bit_Order; package G is -- Assert that Val has one of the allowed sizes, and that Val_2 is twice -- that. pragma Assert (Val'Size in 8 | 16 | 32); pragma Assert (Val_2'Size = Val'Size * 2); -- Assert that both are aligned the same, to the size in bytes of Val -- (not Val_2). pragma Assert (Val'Alignment = Val'Size / Storage_Unit); pragma Assert (Val_2'Alignment = Val'Alignment); type Val_Array is array (Positive range <>) of Val; -- It might make more sense to have: -- subtype Val is Val_2 range 0 .. 2**Val'Size - 1; -- But then GNAT gets the component size of Val_Array wrong. pragma Assert (Val_Array'Alignment = Val'Alignment); pragma Assert (Val_Array'Component_Size = Val'Size); subtype Bit_Size is Natural; -- Size in bits of a bit field subtype Small_Size is Bit_Size range 0 .. Val'Size; -- Size of a small one subtype Bit_Offset is Small_Size range 0 .. Val'Size - 1; -- Starting offset subtype Bit_Offset_In_Byte is Bit_Offset range 0 .. Storage_Unit - 1; procedure Copy_Bitfield (Src_Address : Address; Src_Offset : Bit_Offset_In_Byte; Dest_Address : Address; Dest_Offset : Bit_Offset_In_Byte; Size : Bit_Size); -- An Address and a Bit_Offset together form a "bit address". This -- copies the source bit field to the destination. Size is the size in -- bits of the bit field. The bit fields can be arbitrarily large, but -- the starting offsets must be within the first byte that the Addresses -- point to. The Address values need not be aligned. -- -- For example, a slice assignment of a packed bit field: -- -- D (D_First .. D_Last) := S (S_First .. S_Last); -- -- can be implemented using: -- -- Copy_Bitfield -- (S (S_First)'Address, S (S_First)'Bit, -- D (D_First)'Address, D (D_First)'Bit, -- Size); end G; end System.Bitfield_Utils;
package body Complex is function II return Complex is begin return Complex'(0.0, 1.0); end II; end Complex;
with freetype.face_Size, freetype.charMap, freeType_C.FT_Face, freeType_C.FT_GlyphSlot, interfaces.C; package freetype.Face -- -- The Face class provides an abstraction layer for the Freetype Face. -- is type Item is tagged private; type View is access all Item'Class; --------- -- Types -- type FT_Encodings is array (Positive range <>) of freeType_C.FT_Encoding; type FT_Encodings_view is access all FT_Encodings; --------- -- Forge -- use Interfaces; package Forge is function to_Face (fontFilePath : in String; precomputeKerning : in Boolean) return Face.item; -- -- Opens and reads a face file. Error is set. function to_Face (pBufferBytes : access C.unsigned_char; -- The in-memory buffer. bufferSizeInBytes : in Positive; -- The length of the buffer in bytes. precomputeKerning : in Boolean) return Face.item; -- -- Read face data from an in-memory buffer. Error is set. procedure destruct (Self : in out Item); -- Disposes of the current Freetype face. end Forge; -------------- -- Attributes -- function attach (Self : access Item; fontFilePath : in String) return Boolean; -- -- Attach auxilliary file to font (e.g., font metrics). -- -- fontFilePath: Auxilliary font file path. -- -- Returns true if file has opened successfully. function attach (Self : access Item; pBufferBytes : access C.unsigned_char; bufferSizeInBytes : in Positive) return Boolean; -- -- Attach auxilliary data to font (e.g., font metrics) from memory. -- -- pBufferBytes: The in-memory buffer. -- bufferSizeInBytes: The length of the buffer in bytes. -- -- Returns true if file has opened successfully. function freetype_Face (Self : in Item) return freeType_C.FT_Face.item; -- -- Get the freetype face object. -- -- Returns a pointer to an FT_Face. function Size (Self : access Item; Size : in Natural; x_Res, y_Res : in Natural) return freetype.face_Size.item; -- -- Sets the char size for the current face. -- This doesn't guarantee that the size was set correctly. Clients should check errors. -- -- Size: The face size in points (1/72 inch). -- x_Res, y_Res: The resolution of the target device. -- -- Returns FTSize object. function CharMapCount (Self : in Item) return Natural; -- -- Get the number of character maps in this face. -- -- Return character map count. function CharMapList (Self : access Item) return FT_Encodings_view; -- -- Get a list of character maps in this face. -- -- Returns a pointer to the first encoding. function KernAdvance (Self : access Item; Index1 : in Natural; Index2 : in Natural) return Vector_3; -- -- Gets the kerning vector between two glyphs. function GlyphCount (Self : in Item) return Natural; -- -- Gets the number of glyphs in the current face. function Glyph (Self : access Item; Index : in freetype.charMap.glyphIndex; load_Flags : in freeType_C.FT_Int) return freeType_C.FT_GlyphSlot.item; function Error (Self : in Item) return freeType_C.FT_Error; -- -- Return the current error code. private use freeType_C; type Float_array is array (C.size_t range <>) of aliased C.c_float; type Float_array_view is access all Float_array; type Item is tagged record ftFace : FT_Face .item; -- The Freetype face. charSize : aliased face_Size.item; -- The size object associated with this face. numGlyphs : Natural; -- The number of glyphs in this face. fontEncodingList : FT_Encodings_view; hasKerningTable : Boolean; -- This face has kerning tables. kerningCache : Float_array_view; -- If this face has kerning tables, we can cache them. Err : FT_Error; -- Current error code. Zero means no error. end record; max_Precomputed : constant := 128; procedure BuildKerningCache (Self : in out Item); end freetype.Face;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with GBA.Input; use GBA.Input; package GBA.Input.Unbuffered is function Is_Key_Down(K : Key) return Boolean with Inline_Always; function Are_Any_Down(F : Key_Flags) return Boolean with Inline_Always; function Are_All_Down(F : Key_Flags) return Boolean with Inline_Always; end GBA.Input.Unbuffered;
with Ada.Text_IO; with Ada.Long_Long_Integer_Text_IO; with Ada.Numerics.Long_Long_Elementary_Functions; use Ada.Numerics.Long_Long_Elementary_Functions; with PrimeInstances; package body Problem_03 is package IO renames Ada.Text_IO; procedure Solve is function Largest_Prime_Factor(number : in Long_Long_Integer) return Long_Long_Integer is package Long_Long_Primes renames PrimeInstances.Long_Long_Primes; square_root : constant Long_Long_Integer := Long_Long_Integer(Sqrt(Long_Long_Float(number))); sieve : constant Long_Long_Primes.Sieve := Long_Long_Primes.Generate_Sieve(square_root); quotient : Long_Long_Integer := number; largest : Long_Long_Integer := 1; begin for index in sieve'Range loop declare prime : constant Long_Long_Integer := sieve(index); begin while quotient mod prime = 0 loop quotient := quotient / prime; largest := prime; end loop; end; end loop; if quotient /= 1 then return quotient; else return largest; end if; end Largest_Prime_Factor; begin Ada.Long_Long_Integer_Text_IO.Put(Largest_Prime_Factor(600_851_475_143)); IO.New_Line; end Solve; end Problem_03;
pragma License (Unrestricted); -- implementation unit required by compiler with Ada.Exceptions; with System.Tasking.Protected_Objects.Entries; package System.Tasking.Protected_Objects.Operations is -- required by compiler type Communication_Block is null record; pragma Suppress_Initialization (Communication_Block); -- required by compiler -- protected subprograms are sandwiched between -- Lock_Entries and Service_Entries procedure Service_Entries ( Object : not null access Entries.Protection_Entries'Class); -- required by compiler procedure Complete_Entry_Body ( Object : not null access Entries.Protection_Entries'Class); -- required by compiler procedure Exceptional_Complete_Entry_Body ( Object : not null access Entries.Protection_Entries'Class; Id : Ada.Exceptions.Exception_Id); -- required by compiler procedure Protected_Entry_Call ( Object : not null access Entries.Protection_Entries'Class; E : Protected_Entry_Index; Uninterpreted_Data : Address; Mode : Call_Modes; Block : out Communication_Block); -- required for synchronized interface by compiler procedure Timed_Protected_Entry_Call ( Object : not null access Entries.Protection_Entries'Class; E : Protected_Entry_Index; Uninterpreted_Data : Address; Timeout : Duration; Mode : Integer; -- Tasking.Delay_Modes; Entry_Call_Successful : out Boolean); -- required for select else by compiler function Enqueued (Block : Communication_Block) return Boolean; -- required for synchronized interface by compiler function Cancelled (Block : Communication_Block) return Boolean; -- required for select then abort by compiler procedure Cancel_Protected_Entry_Call ( Block : in out Communication_Block); -- required by compiler procedure Requeue_Protected_Entry ( Object : not null access Entries.Protection_Entries'Class; New_Object : not null access Entries.Protection_Entries'Class; E : Protected_Entry_Index; With_Abort : Boolean); -- required for synchronized interface by compiler procedure Requeue_Task_To_Protected_Entry ( New_Object : not null access Entries.Protection_Entries'Class; E : Protected_Entry_Index; With_Abort : Boolean); -- required for 'Caller by compiler function Protected_Entry_Caller ( Object : Entries.Protection_Entries'Class) return Task_Id; -- required for 'Count by compiler function Protected_Count ( Object : Entries.Protection_Entries'Class; E : Protected_Entry_Index) return Natural; end System.Tasking.Protected_Objects.Operations;
with Ada.Text_IO; with Ada.Strings.Fixed; use Ada.Text_IO; procedure Main is begin Put_Line (Ada.Strings.Fixed.Trim (Integer'Image (2 * (Integer'Value (Get_Line))), Ada.Strings.Left)); end;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . E X P E C T -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 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. -- -- -- -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- Currently this package is implemented on all native GNAT ports except -- for VMS. It is not yet implemented for any of the cross-ports (e.g. it -- is not available for VxWorks or LynxOS). -- -- Usage -- ===== -- -- This package provides a set of subprograms similar to what is available -- with the standard Tcl Expect tool. -- It allows you to easily spawn and communicate with an external process. -- You can send commands or inputs to the process, and compare the output -- with some expected regular expression. -- -- Usage example: -- -- Non_Blocking_Spawn (Fd, "ftp machine@domaine"); -- Timeout := 10000; -- 10 seconds -- Expect (Fd, Result, Regexp_Array'(+"\(user\)", +"\(passwd\)"), -- Timeout); -- case Result is -- when 1 => Send (Fd, "my_name"); -- matched "user" -- when 2 => Send (Fd, "my_passwd"); -- matched "passwd" -- when Expect_Timeout => null; -- timeout -- when others => null; -- end case; -- Close (Fd); -- -- You can also combine multiple regular expressions together, and get the -- specific string matching a parenthesis pair by doing something like. If you -- expect either "lang=optional ada" or "lang=ada" from the external process, -- you can group the two together, which is more efficient, and simply get the -- name of the language by doing: -- -- declare -- Matched : Regexp_Array (0 .. 2); -- begin -- Expect (Fd, Result, "lang=(optional)? ([a-z]+)", Matched); -- Put_Line ("Seen: " & -- Expect_Out (Fd) (Matched (2).First .. Matched (2).Last)); -- end; -- -- Alternatively, you might choose to use a lower-level interface to the -- processes, where you can give your own input and output filters every -- time characters are read from or written to the process. -- -- procedure My_Filter (Descriptor : Process_Descriptor; Str : String) is -- begin -- Put_Line (Str); -- end; -- -- Fd := Non_Blocking_Spawn ("tail -f a_file"); -- Add_Filter (Fd, My_Filter'Access, Output); -- Expect (Fd, Result, "", 0); -- wait forever -- -- The above example should probably be run in a separate task, since it is -- blocking on the call to Expect. -- -- Both examples can be combined, for instance to systematically print the -- output seen by expect, even though you still want to let Expect do the -- filtering. You can use the Trace_Filter subprogram for such a filter. -- -- If you want to get the output of a simple command, and ignore any previous -- existing output, it is recommended to do something like: -- -- Expect (Fd, Result, ".*", Timeout => 0); -- -- empty the buffer, by matching everything (after checking -- -- if there was any input). -- Send (Fd, "command"); -- Expect (Fd, Result, ".."); -- match only on the output of command -- -- Task Safety -- =========== -- -- This package is not task-safe. However, you can easily make is task safe -- by encapsulating the type Process_Descriptor in a protected record. -- There should not be concurrent calls to Expect. with System; with GNAT.OS_Lib; with GNAT.Regpat; package GNAT.Expect is type Process_Id is new Integer; Invalid_Pid : constant Process_Id := -1; Null_Pid : constant Process_Id := 0; type Filter_Type is (Output, Input, Died); -- The signals that are emitted by the Process_Descriptor upon state -- changed in the child. One can connect to any of this signal through -- the Add_Filter subprograms. -- -- Output => Every time new characters are read from the process -- associated with Descriptor, the filter is called with -- these new characters in argument. -- -- Note that output is only generated when the program is -- blocked in a call to Expect. -- -- Input => Every time new characters are written to the process -- associated with Descriptor, the filter is called with -- these new characters in argument. -- Note that input is only generated by calls to Send. -- -- Died => The child process has died, or was explicitly killed type Process_Descriptor is tagged private; -- Contains all the components needed to describe a process handled -- in this package, including a process identifier, file descriptors -- associated with the standard input, output and error, and the buffer -- needed to handle the expect calls. type Process_Descriptor_Access is access Process_Descriptor'Class; ------------------------ -- Spawning a process -- ------------------------ procedure Non_Blocking_Spawn (Descriptor : out Process_Descriptor'Class; Command : String; Args : GNAT.OS_Lib.Argument_List; Buffer_Size : Natural := 4096; Err_To_Out : Boolean := False); -- This call spawns a new process and allows sending commands to -- the process and/or automatic parsing of the output. -- -- The expect buffer associated with that process can contain at most -- Buffer_Size characters. Older characters are simply discarded when -- this buffer is full. Beware that if the buffer is too big, this could -- slow down the Expect calls if not output is matched, since Expect has -- to match all the regexp against all the characters in the buffer. -- If Buffer_Size is 0, there is no limit (ie all the characters are kept -- till Expect matches), but this is slower. -- -- If Err_To_Out is True, then the standard error of the spawned process is -- connected to the standard output. This is the only way to get the -- Except subprograms also match on output on standard error. -- -- Invalid_Process is raised if the process could not be spawned. procedure Close (Descriptor : in out Process_Descriptor); -- Terminate the process and close the pipes to it. It implicitly -- does the 'wait' command required to clean up the process table. -- This also frees the buffer associated with the process id. procedure Send_Signal (Descriptor : Process_Descriptor; Signal : Integer); -- Send a given signal to the process. procedure Interrupt (Descriptor : in out Process_Descriptor); -- Interrupt the process (the equivalent of Ctrl-C on unix and windows) -- and call close if the process dies. function Get_Input_Fd (Descriptor : Process_Descriptor) return GNAT.OS_Lib.File_Descriptor; -- Return the input file descriptor associated with Descriptor. function Get_Output_Fd (Descriptor : Process_Descriptor) return GNAT.OS_Lib.File_Descriptor; -- Return the output file descriptor associated with Descriptor. function Get_Error_Fd (Descriptor : Process_Descriptor) return GNAT.OS_Lib.File_Descriptor; -- Return the error output file descriptor associated with Descriptor. function Get_Pid (Descriptor : Process_Descriptor) return Process_Id; -- Return the process id associated with a given process descriptor. -------------------- -- Adding filters -- -------------------- -- This is a rather low-level interface to subprocesses, since basically -- the filtering is left entirely to the user. See the Expect subprograms -- below for higher level functions. type Filter_Function is access procedure (Descriptor : Process_Descriptor'Class; Str : String; User_Data : System.Address := System.Null_Address); -- Function called every time new characters are read from or written -- to the process. -- -- Str is a string of all these characters. -- -- User_Data, if specified, is a user specific data that will be passed to -- the filter. Note that no checks are done on this parameter that should -- be used with cautiousness. procedure Add_Filter (Descriptor : in out Process_Descriptor; Filter : Filter_Function; Filter_On : Filter_Type := Output; User_Data : System.Address := System.Null_Address; After : Boolean := False); -- Add a new filter for one of the filter type. This filter will be -- run before all the existing filters, unless After is set True, -- in which case it will be run after existing filters. User_Data -- is passed as is to the filter procedure. procedure Remove_Filter (Descriptor : in out Process_Descriptor; Filter : Filter_Function); -- Remove a filter from the list of filters (whatever the type of the -- filter). procedure Trace_Filter (Descriptor : Process_Descriptor'Class; Str : String; User_Data : System.Address := System.Null_Address); -- Function that can be used a filter and that simply outputs Str on -- Standard_Output. This is mainly used for debugging purposes. -- User_Data is ignored. procedure Lock_Filters (Descriptor : in out Process_Descriptor); -- Temporarily disables all output and input filters. They will be -- reactivated only when Unlock_Filters has been called as many times as -- Lock_Filters; procedure Unlock_Filters (Descriptor : in out Process_Descriptor); -- Unlocks the filters. They are reactivated only if Unlock_Filters -- has been called as many times as Lock_Filters. ------------------ -- Sending data -- ------------------ procedure Send (Descriptor : in out Process_Descriptor; Str : String; Add_LF : Boolean := True; Empty_Buffer : Boolean := False); -- Send a string to the file descriptor. -- -- The string is not formatted in any way, except if Add_LF is True, -- in which case an ASCII.LF is added at the end, so that Str is -- recognized as a command by the external process. -- -- If Empty_Buffer is True, any input waiting from the process (or in the -- buffer) is first discarded before the command is sent. The output -- filters are of course called as usual. ----------------------------------------------------------- -- Working on the output (single process, simple regexp) -- ----------------------------------------------------------- type Expect_Match is new Integer; Expect_Full_Buffer : constant Expect_Match := -1; -- If the buffer was full and some characters were discarded. Expect_Timeout : constant Expect_Match := -2; -- If not output matching the regexps was found before the timeout. function "+" (S : String) return GNAT.OS_Lib.String_Access; -- Allocate some memory for the string. This is merely a convenience -- convenience function to help create the array of regexps in the -- call to Expect. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexp : String; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Wait till a string matching Fd can be read from Fd, and return 1 -- if a match was found. -- -- It consumes all the characters read from Fd until a match found, and -- then sets the return values for the subprograms Expect_Out and -- Expect_Out_Match. -- -- The empty string "" will never match, and can be used if you only want -- to match after a specific timeout. Beware that if Timeout is -1 at the -- time, the current task will be blocked forever. -- -- This command times out after Timeout milliseconds (or never if Timeout -- is -1). In that case, Expect_Timeout is returned. The value returned by -- Expect_Out and Expect_Out_Match are meaningless in that case. -- -- Note that using a timeout of 0ms leads to unpredictable behavior, since -- the result depends on whether the process has already sent some output -- the first time Expect checks, and this depends on the operating system. -- -- The regular expression must obey the syntax described in GNAT.Regpat. -- -- If Full_Buffer is True, then Expect will match if the buffer was too -- small and some characters were about to be discarded. In that case, -- Expect_Full_Buffer is returned. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexp : GNAT.Regpat.Pattern_Matcher; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as the previous one, but with a precompiled regular expression. -- This is more efficient however, especially if you are using this -- expression multiple times, since this package won't need to recompile -- the regexp every time. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexp : String; Matched : out GNAT.Regpat.Match_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as above, but it is now possible to get the indexes of the -- substrings for the parentheses in the regexp (see the example at the -- top of this package, as well as the documentation in the package -- GNAT.Regpat). -- -- Matched'First should be 0, and this index will contain the indexes for -- the whole string that was matched. The index 1 will contain the indexes -- for the first parentheses-pair, and so on. ------------ -- Expect -- ------------ procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexp : GNAT.Regpat.Pattern_Matcher; Matched : out GNAT.Regpat.Match_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as above, but with a precompiled regular expression. ------------------------------------------------------------- -- Working on the output (single process, multiple regexp) -- ------------------------------------------------------------- type Regexp_Array is array (Positive range <>) of GNAT.OS_Lib.String_Access; type Pattern_Matcher_Access is access GNAT.Regpat.Pattern_Matcher; type Compiled_Regexp_Array is array (Positive range <>) of Pattern_Matcher_Access; function "+" (P : GNAT.Regpat.Pattern_Matcher) return Pattern_Matcher_Access; -- Allocate some memory for the pattern matcher. -- This is only a convenience function to help create the array of -- compiled regular expressoins. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexps : Regexp_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Wait till a string matching one of the regular expressions in Regexps -- is found. This function returns the index of the regexp that matched. -- This command is blocking, but will timeout after Timeout milliseconds. -- In that case, Timeout is returned. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexps : Compiled_Regexp_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as the previous one, but with precompiled regular expressions. -- This can be much faster if you are using them multiple times. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexps : Regexp_Array; Matched : out GNAT.Regpat.Match_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as above, except that you can also access the parenthesis -- groups inside the matching regular expression. -- The first index in Matched must be 0, or Constraint_Error will be -- raised. The index 0 contains the indexes for the whole string that was -- matched, the index 1 contains the indexes for the first parentheses -- pair, and so on. procedure Expect (Descriptor : in out Process_Descriptor; Result : out Expect_Match; Regexps : Compiled_Regexp_Array; Matched : out GNAT.Regpat.Match_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as above, but with precompiled regular expressions. -- The first index in Matched must be 0, or Constraint_Error will be -- raised. ------------------------------------------- -- Working on the output (multi-process) -- ------------------------------------------- type Multiprocess_Regexp is record Descriptor : Process_Descriptor_Access; Regexp : Pattern_Matcher_Access; end record; type Multiprocess_Regexp_Array is array (Positive range <>) of Multiprocess_Regexp; procedure Expect (Result : out Expect_Match; Regexps : Multiprocess_Regexp_Array; Matched : out GNAT.Regpat.Match_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as above, but for multi processes. procedure Expect (Result : out Expect_Match; Regexps : Multiprocess_Regexp_Array; Timeout : Integer := 10000; Full_Buffer : Boolean := False); -- Same as the previous one, but for multiple processes. -- This procedure finds the first regexp that match the associated process. ------------------------ -- Getting the output -- ------------------------ procedure Flush (Descriptor : in out Process_Descriptor; Timeout : Integer := 0); -- Discard all output waiting from the process. -- -- This output is simply discarded, and no filter is called. This output -- will also not be visible by the next call to Expect, nor will any -- output currently buffered. -- -- Timeout is the delay for which we wait for output to be available from -- the process. If 0, we only get what is immediately available. function Expect_Out (Descriptor : Process_Descriptor) return String; -- Return the string matched by the last Expect call. -- -- The returned string is in fact the concatenation of all the strings -- read from the file descriptor up to, and including, the characters -- that matched the regular expression. -- -- For instance, with an input "philosophic", and a regular expression -- "hi" in the call to expect, the strings returned the first and second -- time would be respectively "phi" and "losophi". function Expect_Out_Match (Descriptor : Process_Descriptor) return String; -- Return the string matched by the last Expect call. -- -- The returned string includes only the character that matched the -- specific regular expression. All the characters that came before are -- simply discarded. -- -- For instance, with an input "philosophic", and a regular expression -- "hi" in the call to expect, the strings returned the first and second -- time would both be "hi". ---------------- -- Exceptions -- ---------------- Invalid_Process : exception; -- Raised by most subprograms above when the parameter Descriptor is not a -- valid process or is a closed process. Process_Died : exception; -- Raised by all the expect subprograms if Descriptor was originally a -- valid process that died while Expect was executing. It is also raised -- when Expect receives an end-of-file. ------------------------ -- Internal functions -- ------------------------ -- The following subprograms are provided so that it is easy to write -- extensions to this package. However, clients should not use these -- routines directly. procedure Portable_Execvp (Cmd : String; Args : System.Address); -- Executes, in a portable way, the command Cmd (full path must be -- specified), with the given Args. Note that the first element in Args -- must be the executable name, and the last element must be a null -- pointer private type Filter_List_Elem; type Filter_List is access Filter_List_Elem; type Filter_List_Elem is record Filter : Filter_Function; User_Data : System.Address; Filter_On : Filter_Type; Next : Filter_List; end record; type Pipe_Type is record Input, Output : GNAT.OS_Lib.File_Descriptor; end record; -- This type represents a pipe, used to communicate between two processes. procedure Set_Up_Communications (Pid : in out Process_Descriptor; Err_To_Out : Boolean; Pipe1 : access Pipe_Type; Pipe2 : access Pipe_Type; Pipe3 : access Pipe_Type); -- Set up all the communication pipes and file descriptors prior to -- spawning the child process. procedure Set_Up_Parent_Communications (Pid : in out Process_Descriptor; Pipe1 : in out Pipe_Type; Pipe2 : in out Pipe_Type; Pipe3 : in out Pipe_Type); -- Finish the set up of the pipes while in the parent process procedure Set_Up_Child_Communications (Pid : in out Process_Descriptor; Pipe1 : in out Pipe_Type; Pipe2 : in out Pipe_Type; Pipe3 : in out Pipe_Type; Cmd : String; Args : System.Address); -- Finish the set up of the pipes while in the child process -- This also spawns the child process (based on Cmd). -- On systems that support fork, this procedure is executed inside the -- newly created process. type Process_Descriptor is tagged record Pid : Process_Id := Invalid_Pid; Input_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Output_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Error_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Filters_Lock : Integer := 0; Filters : Filter_List := null; Buffer : GNAT.OS_Lib.String_Access := null; Buffer_Size : Natural := 0; Buffer_Index : Natural := 0; Last_Match_Start : Natural := 0; Last_Match_End : Natural := 0; end record; pragma Import (C, Portable_Execvp, "__gnat_expect_portable_execvp"); end GNAT.Expect;
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with System; package ftsystem is --*************************************************************************** -- * -- * ftsystem.h -- * -- * FreeType low-level system interface definition (specification). -- * -- * Copyright (C) 1996-2020 by -- * David Turner, Robert Wilhelm, and Werner Lemberg. -- * -- * This file is part of the FreeType project, and may only be used, -- * modified, and distributed under the terms of the FreeType project -- * license, LICENSE.TXT. By continuing to use, modify, or distribute -- * this file you indicate that you have read the license and -- * understand and accept it fully. -- * -- --************************************************************************* -- * -- * @section: -- * system_interface -- * -- * @title: -- * System Interface -- * -- * @abstract: -- * How FreeType manages memory and i/o. -- * -- * @description: -- * This section contains various definitions related to memory management -- * and i/o access. You need to understand this information if you want to -- * use a custom memory manager or you own i/o streams. -- * -- --************************************************************************* -- * -- * M E M O R Y M A N A G E M E N T -- * -- --************************************************************************* -- * -- * @type: -- * FT_Memory -- * -- * @description: -- * A handle to a given memory manager object, defined with an -- * @FT_MemoryRec structure. -- * -- type FT_MemoryRec_u; type FT_Memory is access all FT_MemoryRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:64 --************************************************************************* -- * -- * @functype: -- * FT_Alloc_Func -- * -- * @description: -- * A function used to allocate `size` bytes from `memory`. -- * -- * @input: -- * memory :: -- * A handle to the source memory manager. -- * -- * size :: -- * The size in bytes to allocate. -- * -- * @return: -- * Address of new memory block. 0~in case of failure. -- * -- type FT_Alloc_Func is access function (arg1 : FT_Memory; arg2 : long) return System.Address with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:87 --************************************************************************* -- * -- * @functype: -- * FT_Free_Func -- * -- * @description: -- * A function used to release a given block of memory. -- * -- * @input: -- * memory :: -- * A handle to the source memory manager. -- * -- * block :: -- * The address of the target memory block. -- * -- type FT_Free_Func is access procedure (arg1 : FT_Memory; arg2 : System.Address) with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:108 --************************************************************************* -- * -- * @functype: -- * FT_Realloc_Func -- * -- * @description: -- * A function used to re-allocate a given block of memory. -- * -- * @input: -- * memory :: -- * A handle to the source memory manager. -- * -- * cur_size :: -- * The block's current size in bytes. -- * -- * new_size :: -- * The block's requested new size. -- * -- * block :: -- * The block's current address. -- * -- * @return: -- * New block address. 0~in case of memory shortage. -- * -- * @note: -- * In case of error, the old block must still be available. -- * -- type FT_Realloc_Func is access function (arg1 : FT_Memory; arg2 : long; arg3 : long; arg4 : System.Address) return System.Address with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:141 --************************************************************************* -- * -- * @struct: -- * FT_MemoryRec -- * -- * @description: -- * A structure used to describe a given memory manager to FreeType~2. -- * -- * @fields: -- * user :: -- * A generic typeless pointer for user data. -- * -- * alloc :: -- * A pointer type to an allocation function. -- * -- * free :: -- * A pointer type to an memory freeing function. -- * -- * realloc :: -- * A pointer type to a reallocation function. -- * -- type FT_MemoryRec_u is record user : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:171 alloc : FT_Alloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:172 free : FT_Free_Func; -- /usr/include/freetype2/freetype/ftsystem.h:173 realloc : FT_Realloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:174 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:169 --************************************************************************* -- * -- * I / O M A N A G E M E N T -- * -- --************************************************************************* -- * -- * @type: -- * FT_Stream -- * -- * @description: -- * A handle to an input stream. -- * -- * @also: -- * See @FT_StreamRec for the publicly accessible fields of a given stream -- * object. -- * -- type FT_StreamRec_u; type FT_Stream is access all FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:198 --************************************************************************* -- * -- * @struct: -- * FT_StreamDesc -- * -- * @description: -- * A union type used to store either a long or a pointer. This is used -- * to store a file descriptor or a `FILE*` in an input stream. -- * -- type FT_StreamDesc_u (discr : unsigned := 0) is record case discr is when 0 => value : aliased long; -- /usr/include/freetype2/freetype/ftsystem.h:213 when others => pointer : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:214 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/freetype2/freetype/ftsystem.h:211 subtype FT_StreamDesc is FT_StreamDesc_u; -- /usr/include/freetype2/freetype/ftsystem.h:216 --************************************************************************* -- * -- * @functype: -- * FT_Stream_IoFunc -- * -- * @description: -- * A function used to seek and read data from a given input stream. -- * -- * @input: -- * stream :: -- * A handle to the source stream. -- * -- * offset :: -- * The offset of read in stream (always from start). -- * -- * buffer :: -- * The address of the read buffer. -- * -- * count :: -- * The number of bytes to read from the stream. -- * -- * @return: -- * The number of bytes effectively read by the stream. -- * -- * @note: -- * This function might be called to perform a seek or skip operation with -- * a `count` of~0. A non-zero return value then indicates an error. -- * -- type FT_Stream_IoFunc is access function (arg1 : FT_Stream; arg2 : unsigned_long; arg3 : access unsigned_char; arg4 : unsigned_long) return unsigned_long with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:249 --************************************************************************* -- * -- * @functype: -- * FT_Stream_CloseFunc -- * -- * @description: -- * A function used to close a given input stream. -- * -- * @input: -- * stream :: -- * A handle to the target stream. -- * -- type FT_Stream_CloseFunc is access procedure (arg1 : FT_Stream) with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:269 --************************************************************************* -- * -- * @struct: -- * FT_StreamRec -- * -- * @description: -- * A structure used to describe an input stream. -- * -- * @input: -- * base :: -- * For memory-based streams, this is the address of the first stream -- * byte in memory. This field should always be set to `NULL` for -- * disk-based streams. -- * -- * size :: -- * The stream size in bytes. -- * -- * In case of compressed streams where the size is unknown before -- * actually doing the decompression, the value is set to 0x7FFFFFFF. -- * (Note that this size value can occur for normal streams also; it is -- * thus just a hint.) -- * -- * pos :: -- * The current position within the stream. -- * -- * descriptor :: -- * This field is a union that can hold an integer or a pointer. It is -- * used by stream implementations to store file descriptors or `FILE*` -- * pointers. -- * -- * pathname :: -- * This field is completely ignored by FreeType. However, it is often -- * useful during debugging to use it to store the stream's filename -- * (where available). -- * -- * read :: -- * The stream's input function. -- * -- * close :: -- * The stream's close function. -- * -- * memory :: -- * The memory manager to use to preload frames. This is set internally -- * by FreeType and shouldn't be touched by stream implementations. -- * -- * cursor :: -- * This field is set and used internally by FreeType when parsing -- * frames. In particular, the `FT_GET_XXX` macros use this instead of -- * the `pos` field. -- * -- * limit :: -- * This field is set and used internally by FreeType when parsing -- * frames. -- * -- type FT_StreamRec_u is record base : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:329 size : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:330 pos : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:331 descriptor : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:333 pathname : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:334 read : FT_Stream_IoFunc; -- /usr/include/freetype2/freetype/ftsystem.h:335 close : FT_Stream_CloseFunc; -- /usr/include/freetype2/freetype/ftsystem.h:336 memory : FT_Memory; -- /usr/include/freetype2/freetype/ftsystem.h:338 cursor : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:339 limit : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:340 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:327 subtype FT_StreamRec is FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:342 -- -- END end ftsystem;
----------------------------------------------------------------------- -- asf-contexts-exceptions -- Exception handlers in faces context -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Ada.Exceptions; with ASF.Events.Exceptions; -- The <b>ASF.Contexts.Exceptions</b> package holds the exception handler framework which -- allows an application to handle unexpected exceptions and perform specific actions to -- somehow recover and notify the user. This package defines a default exception handler -- which provides some reasonable behavior to report the error or redirect the user to an -- error page. Applications can provide their own mechanisms by inheriting from the -- base exception handler and overriding the <b>Handle</b procedure. -- -- See JSR 314 - JavaServer Faces Specification 6.2 ExceptionHandler package ASF.Contexts.Exceptions is -- Message used when an exception without a message is raised. EXCEPTION_MESSAGE_BASIC_ID : constant String := "asf.exceptions.unexpected.basic"; -- Message used when an exception with a message is raised. EXCEPTION_MESSAGE_EXTENDED_ID : constant String := "asf.exceptions.unexpected.extended"; -- ------------------------------ -- Exception Handler -- ------------------------------ type Exception_Handler is new Ada.Finalization.Limited_Controlled with private; type Exception_Handler_Access is access all Exception_Handler'Class; -- Take action to handle the <b>Exception_Event</b> instances that have been queued by -- calls to <b>Application.Publish_Event</b>. -- -- This operation is called after each ASF phase by the life cycle manager. procedure Handle (Handler : in out Exception_Handler); -- ------------------------------ -- Exception Queue -- ------------------------------ -- The <b>Exception_Queue</b> contains the pending exception events that have been raised -- while processing an ASF phase. The queue contains two lists of events: -- <ul> -- <li>A list of exceptions that have not yet been processed, -- <li>A list of exceptions that were processed by an exception handler -- </ul> -- When an exception handler has processed an exception event and indicated it as being -- <b>PROCESSED</b>, the exception event is moved to the second list. type Exception_Queue is new Ada.Finalization.Limited_Controlled with private; -- Queue an exception event to the exception handler. The exception event will be -- processed at the end of the current ASF phase. procedure Queue_Exception (Queue : in out Exception_Queue; Ex : in Ada.Exceptions.Exception_Occurrence); -- Clear the exception queue. overriding procedure Finalize (Queue : in out Exception_Queue); private type Exception_Queue is new Ada.Finalization.Limited_Controlled with record Unhandled_Events : ASF.Events.Exceptions.Exception_Event_Vector; Handled_Events : ASF.Events.Exceptions.Exception_Event_Vector; end record; type Exception_Handler is new Ada.Finalization.Limited_Controlled with null record; end ASF.Contexts.Exceptions;
with Protypo.Api.Engine_Values.Handlers; with protypo.Api.Engine_Values.engine_value_holders; -- -- ## What is this? -- -- A constant wrapper is just a wrapper around a constant value -- package Protypo.Api.Engine_Values.Constant_Wrappers is type Constant_Wrapper is new handlers.Constant_Interface with private; type Constant_Wrapper_Access is access Constant_Wrapper; function Read (X : Constant_Wrapper) return Engine_Value; function Make_Wrapper (Value : Engine_Value) return Constant_Wrapper_Access; function Make_Wrapper (Value : Integer) return Constant_Wrapper_Access; function Make_Wrapper (Value : Boolean) return Constant_Wrapper_Access; function Make_Wrapper (Value : Float) return Constant_Wrapper_Access; function Make_Wrapper (Value : String) return Constant_Wrapper_Access; function To_Handler_Value (Value : Engine_Value) return Handler_Value; -- Equivalent to Create(Make_Wrapper(Value)) function To_Handler_Value (Value : Integer) return Handler_Value; -- Equivalent to Create(Make_Wrapper(Value)) function To_Handler_Value (Value : Boolean) return Handler_Value; -- Equivalent to Create(Make_Wrapper(Value)) function To_Handler_Value (Value : Float) return Handler_Value; -- Equivalent to Create(Make_Wrapper(Value)) function To_Handler_Value (Value : String) return Handler_Value; -- Equivalent to Create(Make_Wrapper(Value)) function To_Handler_Value (Value : Unbounded_String) return Handler_Value; -- Equivalent to Create(Make_Wrapper(Value)) private type Constant_Wrapper is new handlers.Constant_Interface with record Value : engine_value_holders.Holder; end record; function Read (X : Constant_Wrapper) return Engine_Value is (X.Value.Element); function Make_Wrapper (Value : Engine_Value) return Constant_Wrapper_Access is (new Constant_Wrapper'(Value => Engine_Value_Holders.To_Holder (Value))); function Make_Wrapper (Value : Integer) return Constant_Wrapper_Access is (Make_Wrapper (Create (Value))); function Make_Wrapper (Value : Boolean) return Constant_Wrapper_Access is (Make_Wrapper (Create (Value))); function Make_Wrapper (Value : Float) return Constant_Wrapper_Access is (Make_Wrapper (Create (Value))); function Make_Wrapper (Value : String) return Constant_Wrapper_Access is (Make_Wrapper (Create (Value))); function To_Handler_Value (Value : Integer) return Handler_Value is (To_Handler_Value (Create (Value))); function To_Handler_Value (Value : Float) return Handler_Value is (To_Handler_Value (Create (Value))); function To_Handler_Value (Value : String) return Handler_Value is (To_Handler_Value (Create (Value))); function To_Handler_Value (Value : Boolean) return Handler_Value is (To_Handler_Value (Create (Value))); function To_Handler_Value (Value : Unbounded_String) return Handler_Value is (To_Handler_Value (To_String (Value))); end Protypo.Api.Engine_Values.Constant_Wrappers;
------------------------------------------------------------------------------ -- Copyright (c) 2015-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Natools.S_Expressions.Caches; with Natools.S_Expressions.Test_Tools; package body Natools.S_Expressions.Conditionals.Strings.Tests is procedure Check (Test : in out NT.Test; Context : in Strings.Context; Expression : in Caches.Reference; Image : in String; Expected : in Boolean := True); procedure Check (Test : in out NT.Test; Value : in String; Expression : in Caches.Reference; Image : in String; Expected : in Boolean := True); ------------------------------ -- Local Helper Subprograms -- ------------------------------ procedure Check (Test : in out NT.Test; Context : in Strings.Context; Expression : in Caches.Reference; Image : in String; Expected : in Boolean := True) is function Match_Image return String; Cursor : Caches.Cursor := Expression.First; function Match_Image return String is begin if Expected then return " does not match "; else return " does match "; end if; end Match_Image; begin if Evaluate (Context, Cursor) /= Expected then Test.Fail ('"' & Context.Data.all & '"' & Match_Image & Image); end if; end Check; procedure Check (Test : in out NT.Test; Value : in String; Expression : in Caches.Reference; Image : in String; Expected : in Boolean := True) is function Match_Image return String; Cursor : Caches.Cursor := Expression.First; function Match_Image return String is begin if Expected then return " does not match "; else return " does match "; end if; end Match_Image; begin if Evaluate (Value, Cursor) /= Expected then Test.Fail ('"' & Value & '"' & Match_Image & Image); end if; end Check; ------------------------- -- Complete Test Suite -- ------------------------- procedure All_Tests (Report : in out NT.Reporter'Class) is begin Basic_Usage (Report); Fallbacks (Report); end All_Tests; ---------------------- -- Individual Tests -- ---------------------- procedure Basic_Usage (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Basic usage"); begin declare procedure Check (Value : in String; Expected : in Boolean := True); Image : constant String := "Expression 1"; Exp : constant Caches.Reference := Test_Tools.To_S_Expression ("(or is-empty (starts-with Hi)" & "(is BY) (case-insensitive (is HELLO))" & "(and (contains 1:.) (contains-any-of 1:! 1:?))" & "(case-insensitive (or (contains aLiCe)" & " (case-sensitive (contains Bob))))" & "(not is-ascii))"); procedure Check (Value : in String; Expected : in Boolean := True) is begin Check (Test, Value, Exp, Image, Expected); end Check; begin Check (""); Check ("A", False); Check ("Hi, my name is John."); Check ("Hello, my name is John.", False); Check ("Hello. My name is John!"); Check ("Hello. My name is John?"); Check ("Alice and Bob"); Check ("BOBBY!", False); Check ("AlicE and Malory"); Check ("©"); Check ("BY"); Check ("By", False); Check ("Hello"); Check ("Hell", False); end; exception when Error : others => Test.Report_Exception (Error); end Basic_Usage; procedure Fallbacks (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Fallback functions"); begin declare procedure Check (Value : in String; With_Fallback : in Boolean); procedure Check_Counts (Expected_Parametric, Expected_Simple : in Natural); function Parametric_Fallback (Settings : in Strings.Settings; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) return Boolean; function Simple_Fallback (Settings : in Strings.Settings; Name : in Atom) return Boolean; Parametric_Count : Natural := 0; Simple_Count : Natural := 0; Exp : constant Caches.Reference := Test_Tools.To_S_Expression ("(or" & "(and (starts-with a) non-existant)" & "(does-not-exist ohai ()))"); procedure Check (Value : in String; With_Fallback : in Boolean) is Copy : aliased constant String := Value; Context : Strings.Context (Data => Copy'Access, Parametric_Fallback => (if With_Fallback then Parametric_Fallback'Access else null), Simple_Fallback => (if With_Fallback then Simple_Fallback'Access else null)); begin Context.Settings.Case_Sensitive := False; begin Check (Test, Context, Exp, "Fallback expression"); if not With_Fallback then Test.Fail ("Exception expected from """ & Value & '"'); end if; exception when Constraint_Error => if With_Fallback then raise; end if; end; end Check; procedure Check_Counts (Expected_Parametric, Expected_Simple : in Natural) is begin if Parametric_Count /= Expected_Parametric then Test.Fail ("Parametric_Count is" & Natural'Image (Parametric_Count) & ", expected" & Natural'Image (Expected_Parametric)); end if; if Simple_Count /= Expected_Simple then Test.Fail ("Simple_Count is" & Natural'Image (Simple_Count) & ", expected" & Natural'Image (Expected_Simple)); end if; end Check_Counts; function Parametric_Fallback (Settings : in Strings.Settings; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) return Boolean is pragma Unreferenced (Settings, Arguments); begin Parametric_Count := Parametric_Count + 1; return To_String (Name) = "does-not-exist"; end Parametric_Fallback; function Simple_Fallback (Settings : in Strings.Settings; Name : in Atom) return Boolean is pragma Unreferenced (Settings); begin Simple_Count := Simple_Count + 1; return To_String (Name) = "non-existant"; end Simple_Fallback; begin Check ("Oook?", False); Check ("Alice", False); Check ("Alpha", True); Check_Counts (0, 1); Check ("Bob", True); Check_Counts (1, 1); end; exception when Error : others => Test.Report_Exception (Error); end Fallbacks; end Natools.S_Expressions.Conditionals.Strings.Tests;
with Ada.Wide_Wide_Text_IO; with League.Application; with League.Strings; procedure Main is function "+" (Item : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; begin Ada.Wide_Wide_Text_IO.Put_Line (League.Application.Environment.Value (+"HOME").To_Wide_Wide_String); end Main;
with agar.core.event; with agar.core.timeout; with agar.core.types; with agar.gui.surface; with agar.gui.text; package agar.gui.widget.button is use type c.unsigned; type flags_t is new c.unsigned; BUTTON_STICKY : constant flags_t := 16#002#; BUTTON_MOUSEOVER : constant flags_t := 16#004#; BUTTON_REPEAT : constant flags_t := 16#008#; BUTTON_HFILL : constant flags_t := 16#010#; BUTTON_VFILL : constant flags_t := 16#020#; BUTTON_INVSTATE : constant flags_t := 16#400#; BUTTON_EXPAND : constant flags_t := BUTTON_HFILL or BUTTON_VFILL; type button_t is limited private; type button_access_t is access all button_t; pragma convention (c, button_access_t); function allocate (parent : widget_access_t; flags : flags_t := 0; label : string) return button_access_t; pragma inline (allocate); function allocate_function (parent : widget_access_t; flags : flags_t := 0; label : string; callback : agar.core.event.callback_t) return button_access_t; pragma inline (allocate_function); function allocate_integer (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access integer) return button_access_t; pragma inline (allocate_integer); function allocate_uint8 (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access agar.core.types.uint8_t) return button_access_t; pragma inline (allocate_uint8); function allocate_uint16 (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access agar.core.types.uint16_t) return button_access_t; pragma inline (allocate_uint16); function allocate_uint32 (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access agar.core.types.uint32_t) return button_access_t; pragma inline (allocate_uint32); function allocate_flag (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access integer; mask : integer) return button_access_t; pragma inline (allocate_flag); function allocate_flag8 (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access agar.core.types.uint8_t; mask : agar.core.types.uint8_t) return button_access_t; pragma inline (allocate_flag8); function allocate_flag16 (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access agar.core.types.uint16_t; mask : agar.core.types.uint16_t) return button_access_t; pragma inline (allocate_flag16); function allocate_flag32 (parent : widget_access_t; flags : flags_t := 0; label : string; ptr : access agar.core.types.uint32_t; mask : agar.core.types.uint32_t) return button_access_t; pragma inline (allocate_flag32); procedure set_padding (button : button_access_t; left_pad : natural; right_pad : natural; top_pad : natural; bottom_pad : natural); pragma inline (set_padding); procedure set_focusable (button : button_access_t; flag : boolean); pragma inline (set_focusable); procedure set_sticky (button : button_access_t; flag : boolean); pragma inline (set_sticky); procedure invert_state (button : button_access_t; flag : boolean); pragma inline (invert_state); procedure justify (button : button_access_t; justify : agar.gui.text.justify_t); pragma import (c, justify, "AG_ButtonJustify"); procedure set_repeat_mode (button : button_access_t; flag : boolean); pragma inline (set_repeat_mode); procedure surface (button : button_access_t; surface : agar.gui.surface.surface_access_t); pragma import (c, surface, "AG_ButtonSurface"); procedure surface_no_copy (button : button_access_t; surface : agar.gui.surface.surface_access_t); pragma import (c, surface_no_copy, "AG_ButtonSurfaceNODUP"); procedure text (button : button_access_t; text : string); pragma inline (text); function widget (button : button_access_t) return widget_access_t; pragma inline (widget); private type button_t is record widget : aliased widget_t; state : c.int; text : cs.chars_ptr; surface : c.int; surface_src : agar.gui.surface.surface_access_t; justify : agar.gui.text.justify_t; valign : agar.gui.text.valign_t; flags : flags_t; left_pad : c.int; right_pad : c.int; top_pad : c.int; bottom_pad : c.int; delay_to : agar.core.timeout.timeout_t; repeat_to : agar.core.timeout.timeout_t; end record; pragma convention (c, button_t); end agar.gui.widget.button;
-- This package has been generated automatically by GNATtest. -- You are allowed to add your code to the bodies of test routines. -- Such changes will be kept during further regeneration of this file. -- All code placed outside of test routine bodies will be lost. The -- code intended to set up and tear down the test environment should be -- placed into Ships.Movement.Test_Data. with AUnit.Assertions; use AUnit.Assertions; with System.Assertions; -- begin read only -- id:2.2/00/ -- -- This section can be used to add with clauses if necessary. -- -- end read only with Ada.Text_IO; use Ada.Text_IO; -- begin read only -- end read only package body Ships.Movement.Test_Data.Tests is -- begin read only -- id:2.2/01/ -- -- This section can be used to add global variables and other elements. -- -- end read only -- begin read only -- end read only -- begin read only function Wrap_Test_MoveShip_143def_3bb6cb (X, Y: Integer; Message: in out Unbounded_String) return Natural is begin declare Test_MoveShip_143def_3bb6cb_Result: constant Natural := GNATtest_Generated.GNATtest_Standard.Ships.Movement.MoveShip (X, Y, Message); begin return Test_MoveShip_143def_3bb6cb_Result; end; end Wrap_Test_MoveShip_143def_3bb6cb; -- end read only -- begin read only procedure Test_MoveShip_test_moveship(Gnattest_T: in out Test); procedure Test_MoveShip_143def_3bb6cb(Gnattest_T: in out Test) renames Test_MoveShip_test_moveship; -- id:2.2/143def44414090ef/MoveShip/1/0/test_moveship/ procedure Test_MoveShip_test_moveship(Gnattest_T: in out Test) is function MoveShip (X, Y: Integer; Message: in out Unbounded_String) return Natural renames Wrap_Test_MoveShip_143def_3bb6cb; -- end read only pragma Unreferenced(Gnattest_T); OldX: constant Natural := Player_Ship.Sky_X; OldY: constant Natural := Player_Ship.Sky_Y; Message: Unbounded_String; NewX, NewY: Natural := 0; begin Player_Ship.Speed := FULL_SPEED; if Player_Ship.Sky_X + 1 <= 1_024 then NewX := 1; end if; if Player_Ship.Sky_Y + 1 <= 1_024 then NewY := 1; end if; if MoveShip(NewX, NewY, Message) = 0 then Ada.Text_IO.Put_Line(To_String(Message)); end if; Assert (Player_Ship.Sky_X - NewX = OldX, "Failed to move player ship in X axis"); Assert (Player_Ship.Sky_Y - NewY = OldY, "Failed to move player ship in Y axis"); Player_Ship.Sky_X := OldX; Player_Ship.Sky_Y := OldY; Player_Ship.Speed := DOCKED; -- begin read only end Test_MoveShip_test_moveship; -- end read only -- begin read only function Wrap_Test_DockShip_bfbe82_875e5b (Docking: Boolean; Escape: Boolean := False) return String is begin declare Test_DockShip_bfbe82_875e5b_Result: constant String := GNATtest_Generated.GNATtest_Standard.Ships.Movement.DockShip (Docking, Escape); begin return Test_DockShip_bfbe82_875e5b_Result; end; end Wrap_Test_DockShip_bfbe82_875e5b; -- end read only -- begin read only procedure Test_DockShip_test_dockship(Gnattest_T: in out Test); procedure Test_DockShip_bfbe82_875e5b(Gnattest_T: in out Test) renames Test_DockShip_test_dockship; -- id:2.2/bfbe82e1179e6b20/DockShip/1/0/test_dockship/ procedure Test_DockShip_test_dockship(Gnattest_T: in out Test) is function DockShip (Docking: Boolean; Escape: Boolean := False) return String renames Wrap_Test_DockShip_bfbe82_875e5b; -- end read only pragma Unreferenced(Gnattest_T); Message: Unbounded_String; begin Message := To_Unbounded_String(DockShip(False)); Assert (Message = Null_Unbounded_String, "Failed to undock from the base."); Message := To_Unbounded_String(DockShip(True)); Assert(Message = Null_Unbounded_String, "Failed to dock to the base."); -- begin read only end Test_DockShip_test_dockship; -- end read only -- begin read only function Wrap_Test_ChangeShipSpeed_a103ef_17b968 (SpeedValue: Ship_Speed) return String is begin declare Test_ChangeShipSpeed_a103ef_17b968_Result: constant String := GNATtest_Generated.GNATtest_Standard.Ships.Movement.ChangeShipSpeed (SpeedValue); begin return Test_ChangeShipSpeed_a103ef_17b968_Result; end; end Wrap_Test_ChangeShipSpeed_a103ef_17b968; -- end read only -- begin read only procedure Test_ChangeShipSpeed_test_changeshipspeed (Gnattest_T: in out Test); procedure Test_ChangeShipSpeed_a103ef_17b968 (Gnattest_T: in out Test) renames Test_ChangeShipSpeed_test_changeshipspeed; -- id:2.2/a103efdf9c3f9d91/ChangeShipSpeed/1/0/test_changeshipspeed/ procedure Test_ChangeShipSpeed_test_changeshipspeed (Gnattest_T: in out Test) is function ChangeShipSpeed(SpeedValue: Ship_Speed) return String renames Wrap_Test_ChangeShipSpeed_a103ef_17b968; -- end read only pragma Unreferenced(Gnattest_T); Message: Unbounded_String; begin Player_Ship.Crew(2).Order := Pilot; Player_Ship.Crew(3).Order := Engineer; Message := To_Unbounded_String(ChangeShipSpeed(FULL_SPEED)); if Message /= Null_Unbounded_String then Ada.Text_IO.Put_Line(To_String(Message)); Assert(False, "Failed to change speed of docked ship."); end if; Player_Ship.Crew(2).Order := Pilot; Player_Ship.Crew(3).Order := Engineer; Message := To_Unbounded_String(DockShip(False)); if Message /= Null_Unbounded_String then Ada.Text_IO.Put_Line(To_String(Message)); Assert(False, "Failed to dock ship again."); end if; Player_Ship.Crew(2).Order := Pilot; Player_Ship.Crew(3).Order := Engineer; Message := To_Unbounded_String(ChangeShipSpeed(FULL_STOP)); if Message /= Null_Unbounded_String then Ada.Text_IO.Put_Line(To_String(Message)); Assert(False, "Failed to change speed of ship."); end if; Player_Ship.Crew(2).Order := Pilot; Player_Ship.Crew(3).Order := Engineer; Message := To_Unbounded_String(DockShip(True)); if Message /= Null_Unbounded_String then Ada.Text_IO.Put_Line(To_String(Message)); Assert(False, "Failed to dock ship again second time."); end if; -- begin read only end Test_ChangeShipSpeed_test_changeshipspeed; -- end read only -- begin read only function Wrap_Test_RealSpeed_da7fcb_f7fd56 (Ship: Ship_Record; InfoOnly: Boolean := False) return Natural is begin declare Test_RealSpeed_da7fcb_f7fd56_Result: constant Natural := GNATtest_Generated.GNATtest_Standard.Ships.Movement.RealSpeed (Ship, InfoOnly); begin return Test_RealSpeed_da7fcb_f7fd56_Result; end; end Wrap_Test_RealSpeed_da7fcb_f7fd56; -- end read only -- begin read only procedure Test_RealSpeed_test_realspeed(Gnattest_T: in out Test); procedure Test_RealSpeed_da7fcb_f7fd56(Gnattest_T: in out Test) renames Test_RealSpeed_test_realspeed; -- id:2.2/da7fcba60b6babad/RealSpeed/1/0/test_realspeed/ procedure Test_RealSpeed_test_realspeed(Gnattest_T: in out Test) is function RealSpeed (Ship: Ship_Record; InfoOnly: Boolean := False) return Natural renames Wrap_Test_RealSpeed_da7fcb_f7fd56; -- end read only pragma Unreferenced(Gnattest_T); begin Assert (RealSpeed(Player_Ship) = 0, "Failed to get speed of docked ship."); Player_Ship.Speed := FULL_SPEED; Assert (RealSpeed(Player_Ship) /= 0, "Failed to get speed of ship with full speed."); Player_Ship.Speed := DOCKED; Assert (RealSpeed(Player_Ship, True) /= 0, "Failed to get potential speed of docked ship."); -- begin read only end Test_RealSpeed_test_realspeed; -- end read only -- begin read only function Wrap_Test_CountFuelNeeded_db602d_18e85d return Integer is begin declare Test_CountFuelNeeded_db602d_18e85d_Result: constant Integer := GNATtest_Generated.GNATtest_Standard.Ships.Movement.CountFuelNeeded; begin return Test_CountFuelNeeded_db602d_18e85d_Result; end; end Wrap_Test_CountFuelNeeded_db602d_18e85d; -- end read only -- begin read only procedure Test_CountFuelNeeded_test_countfuelneeded (Gnattest_T: in out Test); procedure Test_CountFuelNeeded_db602d_18e85d (Gnattest_T: in out Test) renames Test_CountFuelNeeded_test_countfuelneeded; -- id:2.2/db602d4cda90f238/CountFuelNeeded/1/0/test_countfuelneeded/ procedure Test_CountFuelNeeded_test_countfuelneeded (Gnattest_T: in out Test) is function CountFuelNeeded return Integer renames Wrap_Test_CountFuelNeeded_db602d_18e85d; -- end read only pragma Unreferenced(Gnattest_T); begin Assert(CountFuelNeeded < 1, "Failed to count needed fuel to travel."); -- begin read only end Test_CountFuelNeeded_test_countfuelneeded; -- end read only -- begin read only procedure Wrap_Test_WaitInPlace_a6040e_d787da(Minutes: Positive) is begin GNATtest_Generated.GNATtest_Standard.Ships.Movement.WaitInPlace(Minutes); end Wrap_Test_WaitInPlace_a6040e_d787da; -- end read only -- begin read only procedure Test_WaitInPlace_test_waitinplace(Gnattest_T: in out Test); procedure Test_WaitInPlace_a6040e_d787da(Gnattest_T: in out Test) renames Test_WaitInPlace_test_waitinplace; -- id:2.2/a6040ed3f85f9963/WaitInPlace/1/0/test_waitinplace/ procedure Test_WaitInPlace_test_waitinplace(Gnattest_T: in out Test) is procedure WaitInPlace(Minutes: Positive) renames Wrap_Test_WaitInPlace_a6040e_d787da; -- end read only pragma Unreferenced(Gnattest_T); begin WaitInPlace(1); Assert(True, "This test can only crash."); -- begin read only end Test_WaitInPlace_test_waitinplace; -- end read only -- begin read only -- id:2.2/02/ -- -- This section can be used to add elaboration code for the global state. -- begin -- end read only null; -- begin read only -- end read only end Ships.Movement.Test_Data.Tests;
with Orka.Transforms.Doubles.Matrices; package Planets is pragma Pure; AU : constant := 149_597_870_700.0; type Planet_Characteristics is tagged record Axial_Tilt_Deg : Orka.Float_64; Mass_Kg : Orka.Float_64; Sidereal : Duration; Flattening : Orka.Float_64; Semi_Major_Axis : Orka.Float_64; end record; -- Axial tilt (deg) and rotation (hours) of planets in solar system at [1] -- -- [1] https://en.wikipedia.org/wiki/Axial_tilt#Solar_System_bodies use type Orka.Float_64; function Semi_Minor_Axis (Object : Planet_Characteristics) return Orka.Float_64 is (Object.Semi_Major_Axis * (1.0 - Object.Flattening)); function To_Duration (Hours, Minutes, Seconds : Orka.Float_64) return Duration is (Duration (Hours) * 3600.0 + Duration (Minutes) * 60.0 + Duration (Seconds)); package Matrices renames Orka.Transforms.Doubles.Matrices; function Flattened_Vector (Planet : Planet_Characteristics; Direction : Matrices.Vector4; Altitude : Orka.Float_64) return Matrices.Vectors.Vector4; function Geodetic_To_ECEF (Planet : Planet_Characteristics; Latitude, Longitude, Altitude : Orka.Float_64) return Matrices.Vector4; -- Return a vector to the given geodetic position in ECEF coordinates -- -- Latitude 0.0 deg (equator), longitude 0.0 deg (prime meridian), altitude 0 m -- gives a vector (<semi-major axis>, 0.0, 0.0, 1.0) function Radius (Planet : Planet_Characteristics; Latitude, Longitude : Orka.Float_64) return Orka.Float_64; function Radius (Planet : Planet_Characteristics; Direction : Matrices.Vector4) return Orka.Float_64; -- with Pre => Matrices.Vectors.Normalized (Direction); end Planets;
pragma License (Unrestricted); -- implementation unit specialized for Windows package System.Native_IO.Names is pragma Preelaborate; procedure Open_Ordinary ( Method : Open_Method; Handle : aliased out Handle_Type; Mode : File_Mode; Name : String; Out_Name : aliased out Name_Pointer; -- null Form : Packed_Form); procedure Get_Full_Name ( Handle : Handle_Type; Has_Full_Name : in out Boolean; Name : in out Name_Pointer; Is_Standard : Boolean; Raise_On_Error : Boolean); end System.Native_IO.Names;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> -- -- 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.Internals.Elements; with AMF.Internals.Extents; with AMF.Internals.Helpers; with AMF.Internals.Links; with AMF.Internals.Listener_Registry; with AMF.Internals.Tables.OCL_Constructors; with AMF.Internals.Tables.OCL_Metamodel; with AMF.OCL.Holders.Collection_Kinds; package body AMF.Internals.Factories.OCL_Factories is Collection_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Collection"); Set_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Set"); Ordered_Set_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("OrderedSet"); Bag_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Bag"); Sequence_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Sequence"); ----------------- -- Constructor -- ----------------- function Constructor (Extent : AMF.Internals.AMF_Extent) return not null AMF.Factories.Factory_Access is begin return new OCL_Factory'(Extent => Extent); end Constructor; ----------------------- -- Convert_To_String -- ----------------------- overriding function Convert_To_String (Self : not null access OCL_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Value : League.Holders.Holder) return League.Strings.Universal_String is pragma Unreferenced (Self); DT : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element; begin if DT = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Kind then declare Item : constant AMF.OCL.OCL_Collection_Kind := AMF.OCL.Holders.Collection_Kinds.Element (Value); begin case Item is when AMF.OCL.Collection => return Collection_Img; when AMF.OCL.Set => return Set_Img; when AMF.OCL.Ordered_Set => return Ordered_Set_Img; when AMF.OCL.Bag => return Bag_Img; when AMF.OCL.Sequence => return Sequence_Img; end case; end; else raise Program_Error; end if; end Convert_To_String; ------------ -- Create -- ------------ overriding function Create (Self : not null access OCL_Factory; Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class) return not null AMF.Elements.Element_Access is MC : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element; Element : AMF.Internals.AMF_Element; begin if MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Any_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Any_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Association_Class_Call_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Association_Class_Call_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Bag_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Bag_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Boolean_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Boolean_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Item then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Item; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Range then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Range; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Enum_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Enum_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Expression_In_Ocl then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Expression_In_Ocl; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_If_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_If_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Integer_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Integer_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Invalid_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Invalid_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterate_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Iterate_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterator_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Iterator_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Let_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Let_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Message_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Message_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Null_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Null_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Operation_Call_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Operation_Call_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Ordered_Set_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Ordered_Set_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Property_Call_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Property_Call_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Real_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Real_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Sequence_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Sequence_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Set_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Set_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_State_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_State_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_String_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_String_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Template_Parameter_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Template_Parameter_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Tuple_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Part then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Tuple_Literal_Part; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Tuple_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Type_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Type_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unlimited_Natural_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Unlimited_Natural_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unspecified_Value_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Unspecified_Value_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Variable; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Variable_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Void_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Void_Type; else raise Program_Error; end if; AMF.Internals.Extents.Internal_Append (Self.Extent, Element); AMF.Internals.Listener_Registry.Notify_Instance_Create (AMF.Internals.Helpers.To_Element (Element)); return AMF.Internals.Helpers.To_Element (Element); end Create; ------------------------ -- Create_From_String -- ------------------------ overriding function Create_From_String (Self : not null access OCL_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Image : League.Strings.Universal_String) return League.Holders.Holder is pragma Unreferenced (Self); use type League.Strings.Universal_String; DT : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element; begin if DT = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Kind then if Image = Collection_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Collection); elsif Image = Set_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Set); elsif Image = Ordered_Set_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Ordered_Set); elsif Image = Bag_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Bag); elsif Image = Sequence_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Sequence); else raise Constraint_Error; end if; else raise Program_Error; end if; end Create_From_String; ----------------- -- Create_Link -- ----------------- overriding function Create_Link (Self : not null access OCL_Factory; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) return not null AMF.Links.Link_Access is pragma Unreferenced (Self); begin return AMF.Internals.Links.Proxy (AMF.Internals.Links.Create_Link (AMF.Internals.Elements.Element_Base'Class (Association.all).Element, AMF.Internals.Helpers.To_Element (First_Element), AMF.Internals.Helpers.To_Element (Second_Element))); end Create_Link; ----------------- -- Get_Package -- ----------------- overriding function Get_Package (Self : not null access constant OCL_Factory) return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package is pragma Unreferenced (Self); begin return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do Result.Add (Get_Package); end return; end Get_Package; ----------------- -- Get_Package -- ----------------- function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is begin return AMF.CMOF.Packages.CMOF_Package_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MM_OCL_OCL)); end Get_Package; --------------------- -- Create_Any_Type -- --------------------- overriding function Create_Any_Type (Self : not null access OCL_Factory) return AMF.OCL.Any_Types.OCL_Any_Type_Access is begin return AMF.OCL.Any_Types.OCL_Any_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Any_Type)))); end Create_Any_Type; --------------------------------------- -- Create_Association_Class_Call_Exp -- --------------------------------------- overriding function Create_Association_Class_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access is begin return AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Association_Class_Call_Exp)))); end Create_Association_Class_Call_Exp; --------------------- -- Create_Bag_Type -- --------------------- overriding function Create_Bag_Type (Self : not null access OCL_Factory) return AMF.OCL.Bag_Types.OCL_Bag_Type_Access is begin return AMF.OCL.Bag_Types.OCL_Bag_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Bag_Type)))); end Create_Bag_Type; -------------------------------- -- Create_Boolean_Literal_Exp -- -------------------------------- overriding function Create_Boolean_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access is begin return AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Boolean_Literal_Exp)))); end Create_Boolean_Literal_Exp; ---------------------------- -- Create_Collection_Item -- ---------------------------- overriding function Create_Collection_Item (Self : not null access OCL_Factory) return AMF.OCL.Collection_Items.OCL_Collection_Item_Access is begin return AMF.OCL.Collection_Items.OCL_Collection_Item_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Item)))); end Create_Collection_Item; ----------------------------------- -- Create_Collection_Literal_Exp -- ----------------------------------- overriding function Create_Collection_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access is begin return AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Literal_Exp)))); end Create_Collection_Literal_Exp; ----------------------------- -- Create_Collection_Range -- ----------------------------- overriding function Create_Collection_Range (Self : not null access OCL_Factory) return AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access is begin return AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Range)))); end Create_Collection_Range; ---------------------------- -- Create_Collection_Type -- ---------------------------- overriding function Create_Collection_Type (Self : not null access OCL_Factory) return AMF.OCL.Collection_Types.OCL_Collection_Type_Access is begin return AMF.OCL.Collection_Types.OCL_Collection_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Type)))); end Create_Collection_Type; ----------------------------- -- Create_Enum_Literal_Exp -- ----------------------------- overriding function Create_Enum_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access is begin return AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Enum_Literal_Exp)))); end Create_Enum_Literal_Exp; ------------------------------ -- Create_Expression_In_Ocl -- ------------------------------ overriding function Create_Expression_In_Ocl (Self : not null access OCL_Factory) return AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access is begin return AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Expression_In_Ocl)))); end Create_Expression_In_Ocl; ------------------- -- Create_If_Exp -- ------------------- overriding function Create_If_Exp (Self : not null access OCL_Factory) return AMF.OCL.If_Exps.OCL_If_Exp_Access is begin return AMF.OCL.If_Exps.OCL_If_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_If_Exp)))); end Create_If_Exp; -------------------------------- -- Create_Integer_Literal_Exp -- -------------------------------- overriding function Create_Integer_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access is begin return AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Integer_Literal_Exp)))); end Create_Integer_Literal_Exp; -------------------------------- -- Create_Invalid_Literal_Exp -- -------------------------------- overriding function Create_Invalid_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access is begin return AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Literal_Exp)))); end Create_Invalid_Literal_Exp; ------------------------- -- Create_Invalid_Type -- ------------------------- overriding function Create_Invalid_Type (Self : not null access OCL_Factory) return AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access is begin return AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Type)))); end Create_Invalid_Type; ------------------------ -- Create_Iterate_Exp -- ------------------------ overriding function Create_Iterate_Exp (Self : not null access OCL_Factory) return AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access is begin return AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterate_Exp)))); end Create_Iterate_Exp; ------------------------- -- Create_Iterator_Exp -- ------------------------- overriding function Create_Iterator_Exp (Self : not null access OCL_Factory) return AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access is begin return AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterator_Exp)))); end Create_Iterator_Exp; -------------------- -- Create_Let_Exp -- -------------------- overriding function Create_Let_Exp (Self : not null access OCL_Factory) return AMF.OCL.Let_Exps.OCL_Let_Exp_Access is begin return AMF.OCL.Let_Exps.OCL_Let_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Let_Exp)))); end Create_Let_Exp; ------------------------ -- Create_Message_Exp -- ------------------------ overriding function Create_Message_Exp (Self : not null access OCL_Factory) return AMF.OCL.Message_Exps.OCL_Message_Exp_Access is begin return AMF.OCL.Message_Exps.OCL_Message_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Exp)))); end Create_Message_Exp; ------------------------- -- Create_Message_Type -- ------------------------- overriding function Create_Message_Type (Self : not null access OCL_Factory) return AMF.OCL.Message_Types.OCL_Message_Type_Access is begin return AMF.OCL.Message_Types.OCL_Message_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Type)))); end Create_Message_Type; ----------------------------- -- Create_Null_Literal_Exp -- ----------------------------- overriding function Create_Null_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access is begin return AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Null_Literal_Exp)))); end Create_Null_Literal_Exp; ------------------------------- -- Create_Operation_Call_Exp -- ------------------------------- overriding function Create_Operation_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access is begin return AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Operation_Call_Exp)))); end Create_Operation_Call_Exp; ----------------------------- -- Create_Ordered_Set_Type -- ----------------------------- overriding function Create_Ordered_Set_Type (Self : not null access OCL_Factory) return AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access is begin return AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Ordered_Set_Type)))); end Create_Ordered_Set_Type; ------------------------------ -- Create_Property_Call_Exp -- ------------------------------ overriding function Create_Property_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access is begin return AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Property_Call_Exp)))); end Create_Property_Call_Exp; ----------------------------- -- Create_Real_Literal_Exp -- ----------------------------- overriding function Create_Real_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access is begin return AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Real_Literal_Exp)))); end Create_Real_Literal_Exp; -------------------------- -- Create_Sequence_Type -- -------------------------- overriding function Create_Sequence_Type (Self : not null access OCL_Factory) return AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access is begin return AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Sequence_Type)))); end Create_Sequence_Type; --------------------- -- Create_Set_Type -- --------------------- overriding function Create_Set_Type (Self : not null access OCL_Factory) return AMF.OCL.Set_Types.OCL_Set_Type_Access is begin return AMF.OCL.Set_Types.OCL_Set_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Set_Type)))); end Create_Set_Type; ---------------------- -- Create_State_Exp -- ---------------------- overriding function Create_State_Exp (Self : not null access OCL_Factory) return AMF.OCL.State_Exps.OCL_State_Exp_Access is begin return AMF.OCL.State_Exps.OCL_State_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_State_Exp)))); end Create_State_Exp; ------------------------------- -- Create_String_Literal_Exp -- ------------------------------- overriding function Create_String_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access is begin return AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_String_Literal_Exp)))); end Create_String_Literal_Exp; ------------------------------------ -- Create_Template_Parameter_Type -- ------------------------------------ overriding function Create_Template_Parameter_Type (Self : not null access OCL_Factory) return AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access is begin return AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Template_Parameter_Type)))); end Create_Template_Parameter_Type; ------------------------------ -- Create_Tuple_Literal_Exp -- ------------------------------ overriding function Create_Tuple_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access is begin return AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Exp)))); end Create_Tuple_Literal_Exp; ------------------------------- -- Create_Tuple_Literal_Part -- ------------------------------- overriding function Create_Tuple_Literal_Part (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access is begin return AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Part)))); end Create_Tuple_Literal_Part; ----------------------- -- Create_Tuple_Type -- ----------------------- overriding function Create_Tuple_Type (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access is begin return AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Type)))); end Create_Tuple_Type; --------------------- -- Create_Type_Exp -- --------------------- overriding function Create_Type_Exp (Self : not null access OCL_Factory) return AMF.OCL.Type_Exps.OCL_Type_Exp_Access is begin return AMF.OCL.Type_Exps.OCL_Type_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Type_Exp)))); end Create_Type_Exp; ------------------------------------------ -- Create_Unlimited_Natural_Literal_Exp -- ------------------------------------------ overriding function Create_Unlimited_Natural_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access is begin return AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unlimited_Natural_Literal_Exp)))); end Create_Unlimited_Natural_Literal_Exp; ---------------------------------- -- Create_Unspecified_Value_Exp -- ---------------------------------- overriding function Create_Unspecified_Value_Exp (Self : not null access OCL_Factory) return AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access is begin return AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unspecified_Value_Exp)))); end Create_Unspecified_Value_Exp; --------------------- -- Create_Variable -- --------------------- overriding function Create_Variable (Self : not null access OCL_Factory) return AMF.OCL.Variables.OCL_Variable_Access is begin return AMF.OCL.Variables.OCL_Variable_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable)))); end Create_Variable; ------------------------- -- Create_Variable_Exp -- ------------------------- overriding function Create_Variable_Exp (Self : not null access OCL_Factory) return AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access is begin return AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable_Exp)))); end Create_Variable_Exp; ---------------------- -- Create_Void_Type -- ---------------------- overriding function Create_Void_Type (Self : not null access OCL_Factory) return AMF.OCL.Void_Types.OCL_Void_Type_Access is begin return AMF.OCL.Void_Types.OCL_Void_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Void_Type)))); end Create_Void_Type; end AMF.Internals.Factories.OCL_Factories;
with Tkmrpc.Transport.Client; with Tkmrpc.Request.Ees.Esa_Acquire.Convert; with Tkmrpc.Request.Ees.Esa_Expire.Convert; with Tkmrpc.Response.Ees.Esa_Acquire.Convert; with Tkmrpc.Response.Ees.Esa_Expire.Convert; package body Tkmrpc.Clients.Ees is ------------------------------------------------------------------------- procedure Esa_Acquire (Result : out Results.Result_Type; Sp_Id : Types.Sp_Id_Type) is Req : Request.Ees.Esa_Acquire.Request_Type; Res : Response.Ees.Esa_Acquire.Response_Type; Data : Response.Data_Type; begin if not (Sp_Id'Valid) then Result := Results.Invalid_Parameter; return; end if; Req := Request.Ees.Esa_Acquire.Null_Request; Req.Data.Sp_Id := Sp_Id; Transport.Client.Send_Receive (Req_Data => Request.Ees.Esa_Acquire.Convert.To_Request (S => Req), Res_Data => Data); Res := Response.Ees.Esa_Acquire.Convert.From_Response (S => Data); Result := Res.Header.Result; end Esa_Acquire; ------------------------------------------------------------------------- procedure Esa_Expire (Result : out Results.Result_Type; Sp_Id : Types.Sp_Id_Type; Spi_Rem : Types.Esp_Spi_Type; Protocol : Types.Protocol_Type; Hard : Types.Expiry_Flag_Type) is Req : Request.Ees.Esa_Expire.Request_Type; Res : Response.Ees.Esa_Expire.Response_Type; Data : Response.Data_Type; begin if not (Sp_Id'Valid and Spi_Rem'Valid and Protocol'Valid and Hard'Valid) then Result := Results.Invalid_Parameter; return; end if; Req := Request.Ees.Esa_Expire.Null_Request; Req.Data.Sp_Id := Sp_Id; Req.Data.Spi_Rem := Spi_Rem; Req.Data.Protocol := Protocol; Req.Data.Hard := Hard; Transport.Client.Send_Receive (Req_Data => Request.Ees.Esa_Expire.Convert.To_Request (S => Req), Res_Data => Data); Res := Response.Ees.Esa_Expire.Convert.From_Response (S => Data); Result := Res.Header.Result; end Esa_Expire; ------------------------------------------------------------------------- procedure Init (Result : out Results.Result_Type; Address : Interfaces.C.Strings.chars_ptr) is separate; end Tkmrpc.Clients.Ees;
----------------------------------------------------------------------- -- awa-components-factory -- Factory for AWA UI Components -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 ASF.Components.Base; with AWA.Components.Redirect; with AWA.Components.Inputs; with AWA.Components.Wikis; with ASF.Views.Nodes; package body AWA.Components.Factory is use ASF.Components.Base; function Create_Redirect return UIComponent_Access; function Create_Input return UIComponent_Access; function Create_Wiki return UIComponent_Access; -- ------------------------------ -- Create an UIRedirect component -- ------------------------------ function Create_Redirect return UIComponent_Access is begin return new AWA.Components.Redirect.UIRedirect; end Create_Redirect; -- ------------------------------ -- Create an UIInput component -- ------------------------------ function Create_Input return UIComponent_Access is begin return new AWA.Components.Inputs.UIInput; end Create_Input; -- ------------------------------ -- Create an UIWiki component -- ------------------------------ function Create_Wiki return UIComponent_Access is begin return new AWA.Components.Wikis.UIWiki; end Create_Wiki; use ASF.Views.Nodes; URI : aliased constant String := "http://code.google.com/p/ada-awa/jsf"; REDIRECT_TAG : aliased constant String := "redirect"; INPUT_TEXT_TAG : aliased constant String := "inputText"; WIKI_TAG : aliased constant String := "wiki"; AWA_Bindings : aliased constant ASF.Factory.Binding_Array := (1 => (Name => INPUT_TEXT_TAG'Access, Component => Create_Input'Access, Tag => Create_Component_Node'Access), 2 => (Name => REDIRECT_TAG'Access, Component => Create_Redirect'Access, Tag => Create_Component_Node'Access), 3 => (Name => WIKI_TAG'Access, Component => Create_Wiki'Access, Tag => Create_Component_Node'Access) ); AWA_Factory : aliased constant ASF.Factory.Factory_Bindings := (URI => URI'Access, Bindings => AWA_Bindings'Access); -- ------------------------------ -- Get the AWA component factory. -- ------------------------------ function Definition return ASF.Factory.Factory_Bindings_Access is begin return AWA_Factory'Access; end Definition; end AWA.Components.Factory;
with Ada.Characters.Latin_1; package Support.Strings is function str (source : Real; -- the number to print width : Integer := 10) -- width of the printed number return string; function str (source : Integer; -- the number to print width : Integer := 0) -- width of the printed number return string; function str (source : string; width : integer; pad : Character := Ada.Characters.Latin_1.NUL) return string; function str (source : character; width : integer := 1) return string; function str (source : in string) return String; function fill_str (the_num : Integer; -- the number to print width : Integer; -- width of the printed number fill_chr : Character := ' ') -- the leading fill character return String; function spc (width : integer) return string; function cut (the_line : string) return string; -- delete (cut) trailing null characters procedure null_string (source : in out string); function get_strlen (source : string) return Integer; procedure set_strlen (source : in out string; length : Integer); function make_str (n : Integer; m : Integer) return String; procedure readstr (source : string; target : out integer); procedure readstr (source : string; target : out real); procedure writestr (target : out string; source : integer); procedure writestr (target : out string; source : real); procedure writestr (target : out string; source : string); function centre (the_string : String; the_length : Integer; the_offset : Integer := 0) return String; procedure trim_head (the_string : in out String); function trim_head (the_string : String) return String; procedure trim_tail (the_string : in out String); function trim_tail (the_string : String) return String; procedure trim (the_string : in out String); function trim (the_string : String) return String; function lower_case (source : String) return String; function upper_case (source : String) return String; end Support.Strings;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ T Y P E -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2013, 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 unit contains the routines used to handle type determination, -- including the routine used to support overload resolution. with Types; use Types; package Sem_Type is --------------------------------------------- -- Data Structures for Overload Resolution -- --------------------------------------------- -- To determine the unique meaning of an identifier, overload resolution -- may have to be performed if the visibility rules alone identify more -- than one possible entity as the denotation of a given identifier. When -- the visibility rules find such a potential ambiguity, the set of -- possible interpretations must be attached to the identifier, and -- overload resolution must be performed over the innermost enclosing -- complete context. At the end of the resolution, either a single -- interpretation is found for all identifiers in the context, or else a -- type error (invalid type or ambiguous reference) must be signalled. -- The set of interpretations of a given name is stored in a data structure -- that is separate from the syntax tree, because it corresponds to -- transient information. The interpretations themselves are stored in -- table All_Interp. A mapping from tree nodes to sets of interpretations -- called Interp_Map, is maintained by the overload resolution routines. -- Both these structures are initialized at the beginning of every complete -- context. -- Corresponding to the set of interpretations for a given overloadable -- identifier, there is a set of possible types corresponding to the types -- that the overloaded call may return. We keep a 1-to-1 correspondence -- between interpretations and types: for user-defined subprograms the type -- is the declared return type. For operators, the type is determined by -- the type of the arguments. If the arguments themselves are overloaded, -- we enter the operator name in the names table for each possible result -- type. In most cases, arguments are not overloaded and only one -- interpretation is present anyway. type Interp is record Nam : Entity_Id; Typ : Entity_Id; Abstract_Op : Entity_Id := Empty; end record; -- Entity Abstract_Op is set to the abstract operation which potentially -- disables the interpretation in Ada 2005 mode. No_Interp : constant Interp := (Empty, Empty, Empty); type Interp_Index is new Int; --------------------- -- Error Reporting -- --------------------- -- A common error is the use of an operator in infix notation on arguments -- of a type that is not directly visible. Rather than diagnosing a type -- mismatch, it is better to indicate that the type can be made use-visible -- with the appropriate use clause. The global variable Candidate_Type is -- set in Add_One_Interp whenever an interpretation might be legal for an -- operator if the type were directly visible. This variable is used in -- sem_ch4 when no legal interpretation is found. Candidate_Type : Entity_Id; ----------------- -- Subprograms -- ----------------- procedure Init_Interp_Tables; -- Invoked by gnatf when processing multiple files procedure Collect_Interps (N : Node_Id); -- Invoked when the name N has more than one visible interpretation. This -- is the high level routine which accumulates the possible interpretations -- of the node. The first meaning and type of N have already been stored -- in N. If the name is an expanded name, the homonyms are only those that -- belong to the same scope. function Is_Invisible_Operator (N : Node_Id; T : Entity_Id) return Boolean; -- Check whether a predefined operation with universal operands appears in -- a context in which the operators of the expected type are not visible. procedure List_Interps (Nam : Node_Id; Err : Node_Id); -- List candidate interpretations of an overloaded name. Used for various -- error reports. procedure Add_One_Interp (N : Node_Id; E : Entity_Id; T : Entity_Id; Opnd_Type : Entity_Id := Empty); -- Add (E, T) to the list of interpretations of the node being resolved. -- For calls and operators, i.e. for nodes that have a name field, E is an -- overloadable entity, and T is its type. For constructs such as indexed -- expressions, the caller sets E equal to T, because the overloading comes -- from other fields, and the node itself has no name to resolve. Hidden -- denotes whether an interpretation has been disabled by an abstract -- operator. Add_One_Interp includes semantic processing to deal with -- adding entries that hide one another etc. -- -- For operators, the legality of the operation depends on the visibility -- of T and its scope. If the operator is an equality or comparison, T is -- always Boolean, and we use Opnd_Type, which is a candidate type for one -- of the operands of N, to check visibility. procedure End_Interp_List; -- End the list of interpretations of current node procedure Get_First_Interp (N : Node_Id; I : out Interp_Index; It : out Interp); -- Initialize iteration over set of interpretations for Node N. The first -- interpretation is placed in It, and I is initialized for subsequent -- calls to Get_Next_Interp. procedure Get_Next_Interp (I : in out Interp_Index; It : out Interp); -- Iteration step over set of interpretations. Using the value in I, which -- was set by a previous call to Get_First_Interp or Get_Next_Interp, the -- next interpretation is placed in It, and I is updated for the next call. -- The end of the list of interpretations is signalled by It.Nam = Empty. procedure Remove_Interp (I : in out Interp_Index); -- Remove an interpretation that is hidden by another, or that does not -- match the context. The value of I on input was set by a call to either -- Get_First_Interp or Get_Next_Interp and references the interpretation -- to be removed. The only allowed use of the exit value of I is as input -- to a subsequent call to Get_Next_Interp, which yields the interpretation -- following the removed one. procedure Save_Interps (Old_N : Node_Id; New_N : Node_Id); -- If an overloaded node is rewritten during semantic analysis, its -- possible interpretations must be linked to the copy. This procedure -- transfers the overload information (Is_Overloaded flag, and list of -- interpretations) from Old_N, the old node, to New_N, its new copy. -- It has no effect in the non-overloaded case. function Covers (T1, T2 : Entity_Id) return Boolean; -- This is the basic type compatibility routine. T1 is the expected type, -- imposed by context, and T2 is the actual type. The processing reflects -- both the definition of type coverage and the rules for operand matching; -- that is, this does not exactly match the RM definition of "covers". function Disambiguate (N : Node_Id; I1, I2 : Interp_Index; Typ : Entity_Id) return Interp; -- If more than one interpretation of a name in a call is legal, apply -- preference rules (universal types first) and operator visibility in -- order to remove ambiguity. I1 and I2 are the first two interpretations -- that are compatible with the context, but there may be others. function Entity_Matches_Spec (Old_S, New_S : Entity_Id) return Boolean; -- To resolve subprogram renaming and default formal subprograms in generic -- definitions. Old_S is a possible interpretation of the entity being -- renamed, New_S has an explicit signature. If Old_S is a subprogram, as -- opposed to an operator, type and mode conformance are required. function Find_Unique_Type (L : Node_Id; R : Node_Id) return Entity_Id; -- Used in second pass of resolution, for equality and comparison nodes. L -- is the left operand, whose type is known to be correct, and R is the -- right operand, which has one interpretation compatible with that of L. -- Return the type intersection of the two. function Has_Compatible_Type (N : Node_Id; Typ : Entity_Id) return Boolean; -- Verify that some interpretation of the node N has a type compatible with -- Typ. If N is not overloaded, then its unique type must be compatible -- with Typ. Otherwise iterate through the interpretations of N looking for -- a compatible one. function Hides_Op (F : Entity_Id; Op : Entity_Id) return Boolean; -- A user-defined function hides a predefined operator if it is matches the -- signature of the operator, and is declared in an open scope, or in the -- scope of the result type. function Interface_Present_In_Ancestor (Typ : Entity_Id; Iface : Entity_Id) return Boolean; -- Ada 2005 (AI-251): Typ must be a tagged record type/subtype and Iface -- must be an abstract interface type (or a class-wide abstract interface). -- This function is used to check if Typ or some ancestor of Typ implements -- Iface (returning True only if so). function Intersect_Types (L, R : Node_Id) return Entity_Id; -- Find the common interpretation to two analyzed nodes. If one of the -- interpretations is universal, choose the non-universal one. If either -- node is overloaded, find single common interpretation. function In_Generic_Actual (Exp : Node_Id) return Boolean; -- Determine whether the expression is part of a generic actual. At the -- time the actual is resolved the scope is already that of the instance, -- but conceptually the resolution of the actual takes place in the -- enclosing context and no special disambiguation rules should be applied. function Is_Ancestor (T1 : Entity_Id; T2 : Entity_Id; Use_Full_View : Boolean := False) return Boolean; -- T1 is a tagged type (not class-wide). Verify that it is one of the -- ancestors of type T2 (which may or not be class-wide). If Use_Full_View -- is True then the full-view of private parents is used when climbing -- through the parents of T2. -- -- Note: For analysis purposes the flag Use_Full_View must be set to False -- (otherwise we break the privacy contract since this routine returns true -- for hidden ancestors of private types). For expansion purposes this flag -- is generally set to True since the expander must know with precision the -- ancestors of a tagged type. For example, if a private type derives from -- an interface type then the interface may not be an ancestor of its full -- view since the full-view is only required to cover the interface (RM 7.3 -- (7.3/2))) and this knowledge affects construction of dispatch tables. function Is_Progenitor (Iface : Entity_Id; Typ : Entity_Id) return Boolean; -- Determine whether the interface Iface is implemented by Typ. It requires -- traversing the list of abstract interfaces of the type, as well as that -- of the ancestor types. The predicate is used to determine when a formal -- in the signature of an inherited operation must carry the derived type. function Is_Subtype_Of (T1 : Entity_Id; T2 : Entity_Id) return Boolean; -- Checks whether T1 is any subtype of T2 directly or indirectly. Applies -- only to scalar subtypes??? function Operator_Matches_Spec (Op, New_S : Entity_Id) return Boolean; -- Used to resolve subprograms renaming operators, and calls to user -- defined operators. Determines whether a given operator Op, matches -- a specification, New_S. procedure Set_Abstract_Op (I : Interp_Index; V : Entity_Id); -- Set the abstract operation field of an interpretation function Valid_Comparison_Arg (T : Entity_Id) return Boolean; -- A valid argument to an ordering operator must be a discrete type, a -- real type, or a one dimensional array with a discrete component type. function Valid_Boolean_Arg (T : Entity_Id) return Boolean; -- A valid argument of a boolean operator is either some boolean type, or a -- one-dimensional array of boolean type. procedure Write_Interp (It : Interp); -- Debugging procedure to display an Interp procedure Write_Interp_Ref (Map_Ptr : Int); -- Debugging procedure to display entry in Interp_Map. Would not be needed -- if it were possible to debug instantiations of Table. procedure Write_Overloads (N : Node_Id); -- Debugging procedure to output info on possibly overloaded entities for -- specified node. end Sem_Type;
with Lv.Style; package Lv.Objx.Lmeter is subtype Instance is Obj_T; -- Create a line meter objects -- @param par pointer to an object, it will be the parent of the new line meter -- @param copy pointer to a line meter object, if not NULL then the new object will be copied from it -- @return pointer to the created line meter function Create (Parent : Obj_T; Copy : Instance) return Instance; ---------------------- -- Setter functions -- ---------------------- -- Set a new value on the line meter -- @param self pointer to a line meter object -- @param value new value procedure Set_Value (Self : Instance; Value : Int16_T); -- Set minimum and the maximum values of a line meter -- @param self pointer to he line meter object -- @param min minimum value -- @param max maximum value procedure Set_Range (Self : Instance; Min : Int16_T; Max : Int16_T); -- Set the scale settings of a line meter -- @param self pointer to a line meter object -- @param angle angle of the scale (0..360) -- @param line_cnt number of lines procedure Set_Scale (Self : Instance; Angle : Uint16_T; Line_Cnt : Uint8_T); -- Set the styles of a line meter -- @param self pointer to a line meter object -- @param bg set the style of the line meter procedure Set_Style (Self : Instance; Style : access Lv.Style.Style); ---------------------- -- Getter functions -- ---------------------- -- Get the value of a line meter -- @param self pointer to a line meter object -- @return the value of the line meter function Value (Self : Instance) return Int16_T; -- Get the minimum value of a line meter -- @param self pointer to a line meter object -- @return the minimum value of the line meter function Min_Value (Self : Instance) return Int16_T; -- Get the maximum value of a line meter -- @param self pointer to a line meter object -- @return the maximum value of the line meter function Max_Value (Self : Instance) return Int16_T; -- Get the scale number of a line meter -- @param self pointer to a line meter object -- @return number of the scale units function Line_Count (Self : Instance) return Uint8_T; -- Get the scale angle of a line meter -- @param self pointer to a line meter object -- @return angle of the scale function Scale_Angle (Self : Instance) return Uint16_T; -- Get the style of a line meter -- @param self pointer to a line meter object -- @return pointer to the line meter's style function Style (Self : Instance) return access Lv.Style.Style; ------------- -- Imports -- ------------- pragma Import (C, Create, "lv_lmeter_create"); pragma Import (C, Set_Value, "lv_lmeter_set_value"); pragma Import (C, Set_Range, "lv_lmeter_set_range"); pragma Import (C, Set_Scale, "lv_lmeter_set_scale"); pragma Import (C, Set_Style, "lv_lmeter_set_style_inline"); pragma Import (C, Value, "lv_lmeter_get_value"); pragma Import (C, Min_Value, "lv_lmeter_get_min_value"); pragma Import (C, Max_Value, "lv_lmeter_get_max_value"); pragma Import (C, Line_Count, "lv_lmeter_get_line_count"); pragma Import (C, Scale_Angle, "lv_lmeter_get_scale_angle"); pragma Import (C, Style, "lv_lmeter_get_style_inline"); end Lv.Objx.Lmeter;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A S I S . D A T A _ D E C O M P O S I T I O N . S E T _ G E T -- -- -- -- S p e c -- -- -- -- Copyright (c) 1995-2005, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 59 Temple Place -- -- - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc -- -- (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- This package contains access and update routines for abstractions -- declared in Asis.Data_Decomposition. -- -- It also contains routines for creating lists of record and array -- components with A4G.Asis_Tables; use A4G.Asis_Tables; with A4G.DDA_Aux; use A4G.DDA_Aux; with Table; private package Asis.Data_Decomposition.Set_Get is -- Tables used to create query results which are of list types: package Record_Component_Table is new Table.Table ( Table_Component_Type => Record_Component, Table_Index_Type => Asis.ASIS_Natural, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Record_Componnet_List"); RC_Table : Record_Component_Table.Table_Ptr renames Record_Component_Table.Table; Def_N_Table : Asis_Element_Table.Table_Ptr renames Asis_Element_Table.Table; Nil_Record_Component_List : Record_Component_List (1 .. 0); -- Nil constant for Record_Component_List is not provided in the -- Asis.Data_Decomposition package. Parent_Type_Definition : Element; -- Global variable used to store the type definition from which componnets -- are extracted Record_Type_Entity : Entity_Id; -- Global variable used to store the type entity defining the type of -- a record. This is a type entity which actually defines the -- type, that is, it may be an implicit type as well procedure Set_Parent_Type_Definition (E : Element); -- Sets Parent_Type_Definition (Currently this is a trivial assignment, -- but we would better keep procedural interface in case if something -- more smart is really required here. procedure Set_Record_Type_Entity (RC : Record_Component); -- Sets Record_Type_Entity for RC, if Is_Record (RC) procedure Set_Record_Type_Entity (AC : Array_Component); -- Sets Record_Type_Entity for AC, if Is_Record (AC) procedure Set_Record_Type_Entity; -- Sets Record_Type_Entity by using the valuse of Parent_Type_Definition -- global variable -- Access functions to Record_Component fields: subtype RC is Record_Component; function Parent_Record_Type (Comp : RC) return Asis.Declaration; function Component_Name (Comp : RC) return Asis.Defining_Name; function Is_Record_Comp (Comp : RC) return Boolean; function Is_Array_Comp (Comp : RC) return Boolean; function Parent_Discrims (Comp : RC) return Discrim_List; function Get_Type_Entity (Comp : RC) return Entity_Id; -- Returns type Entity describing the subtype of the component. -- It may be implicit type as well function Get_Comp_Entity (Comp : RC) return Entity_Id; -- Returns the Entity Id of the given record component function Get_Record_Entity (Comp : RC) return Entity_Id; -- Returns the Entity Id of the enclosing record type declaration -- for a given component (it may be a type derived from a record type) -- Array Components: subtype AC is Array_Component; function Parent_Array_Type (Comp : AC) return Asis.Declaration; function Is_Record_Comp (Comp : AC) return Boolean; function Is_Array_Comp (Comp : AC) return Boolean; function Dimension (Comp : AC) return ASIS_Natural; function Parent_Discrims (Comp : AC) return Discrim_List; function Get_Array_Type_Entity (Comp : AC) return Entity_Id; -- Returns the Entity_Id for the array type from which this array -- component is extracted. It may be the Id of some implicit array type -- as well procedure Set_Parent_Discrims (Comp : in out AC; Discs : Discrim_List); -- Sets Discs as Parent_Discrims for Comp. In case if Discs is -- Null_Discrims sets Parent_Discrims as null. type List_Kinds is (New_List, Append); -- The way of creating a list in Element or Component Table procedure Set_Named_Components (E : Element; List_Kind : List_Kinds); -- Stores all the A_Defining_Identifier components contained in E in -- Asis_Element_Table. If List_Kind is set to New_List, it resets -- Asis_Element_Table before putting any information in it. If List_Kind -- is set to Append, the Table is not reset, and the created list -- is appended to the list already stored in the table. procedure Set_All_Named_Components (E : Element); -- Provided that E is a record type definition or a definition of a -- derived type derived from some record type, this function -- stores all the A_Defining_Identifier Elements defining the -- componnets for this type in Asis_Element_Table. Before doing this, -- the procedure resets Asis_Element_Table. procedure Set_Record_Components_From_Names (Parent_First_Bit : ASIS_Natural := 0; Data_Stream : Portable_Data := Nil_Portable_Data; Discriminants : Boolean := False); -- Supposing that an appropriate list of component defining names is set -- in the Asis_Element_Table, this procedure converts them into -- the corresponding list of record componnets in Record_Component_Table. -- -- Parent_First_Bit is needed to compute the first bit and position of -- the component that is extracted from another (record or array) -- component. Usually everything is alligned at least bytewise, but in case -- if representation clauses are used to create heavily packed data -- structure, we may need to know where to start to compute the component -- beginning -- -- If Data_Stream parameter is set, it is used to define which -- components from the list set in Asis_Element_Table should be -- presented in the result. -- -- Discriminants flag is used to indicate the case when (only) -- discriminant components should be constructed, in this case no -- discriminant constraint (explicit or default) should be taken into -- account (they may be dynamic in case of A_Complex_Dynamic_Model type). function Set_Array_Componnet (Array_Type_Definition : Element; Enclosing_Record_Component : Record_Component := Nil_Record_Component; Parent_Indication : Element := Nil_Element; Parent_Discriminants : Discrim_List := Null_Discrims; Parent_First_Bit_Offset : ASIS_Natural := 0; Dynamic_Array : Boolean := False) return Array_Component; -- Sets and returns an Array_Component value. Array_Type_Definition -- parameter should represent a (constrained or unconstrained) array type -- definition or a derived type definition for which an ancestor type is -- an array type. The returned value represent the component of this array -- type. Enclosing_Record_Component is set when the array componnet to be -- created is a part of some Record_Component, in this case the -- corresponding component definition may contain index constraints. -- Parent_Indication is set when the array componnet to be created is a -- part of some other array component, in this case the corresponding -- component subtype indication may contain an index constraint -- ???? Documentation needs revising!!! end Asis.Data_Decomposition.Set_Get;
-- Copyright 2019 Simon Symeonidis (psyomn) -- -- 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 AUnit.Assertions; use AUnit.Assertions; with Common_Utils; with File_Utils; use File_Utils; with Ada.Text_IO; use Ada.Text_IO; package body File_Utils_Test is Fixture_File_Name : constant String := "./test/fixtures/file.txt"; Expected_Contents : constant String := "hello world" & ASCII.LF; procedure Test_Read_File_With_Normal_Named_String (T : in out Test) is pragma Unreferenced (T); Contents : constant String := Read (Fixture_File_Name); begin Assert (Contents'Length = Expected_Contents'Length, "lengths of returned string must be the same; " & "expected: " & Contents'Length'Image & "actual: " & Expected_Contents'Length'Image); Assert (Contents = Expected_Contents, "expected: " & Expected_Contents & " actual: " & Contents); end Test_Read_File_With_Normal_Named_String; procedure Test_Read_File_With_Null_Named_String (T : in out Test) is pragma Unreferenced (T); Fname_Buff : String (1 .. 548) := (others => Character'Val (0)); begin Fname_Buff (1 .. Fixture_File_Name'Last) := Fixture_File_Name; declare Contents : constant String := Read (Fname_Buff); begin Assert (Contents'Length = Expected_Contents'Length, "lengths of returned string must be the same; " & "expected: " & Contents'Length'Image & "actual: " & Expected_Contents'Length'Image); Assert (Contents = Expected_Contents, "expected: " & Expected_Contents & " actual: " & Contents); end; end Test_Read_File_With_Null_Named_String; procedure Test_Read_File_From_Null_Concat_Name (T : in out Test) is pragma Unreferenced (T); Path : constant String := "./test/fixtures/"; File : constant String := "file.txt"; Buff_1 : String (1 .. 548) := (others => Character'Val (0)); Buff_2 : String (1 .. 548) := (others => Character'Val (0)); Buff_3 : String (1 .. Buff_1'Length + Buff_2'Length) := (others => Character'Val (0)); begin Buff_1 (1 .. Path'Last) := Path; Buff_2 (1 .. File'Last) := File; Buff_3 := Buff_1 & Buff_2; Put_Line (Buff_3); declare Contents : constant String := Read (Buff_3); pragma Unreferenced (Contents); begin -- NOTE: this should fail, and that's ok Assert (False, "should fail trying using bad buffers"); end; exception when Name_Error => null; end Test_Read_File_From_Null_Concat_Name; procedure Test_Read_File_From_Null_Concat_Name_Fix (T : in out Test) is pragma Unreferenced (T); Path : constant String := "./test/fixtures/"; File : constant String := "file.txt"; Buff_1 : String (1 .. 548) := (others => Character'Val (0)); Buff_2 : String (1 .. 548) := (others => Character'Val (0)); Buff_3 : String (1 .. Buff_1'Length + Buff_2'Length) := (others => Character'Val (0)); begin Buff_1 (1 .. Path'Last) := Path; Buff_2 (1 .. File'Last) := File; Buff_3 := Buff_1 & Buff_2; Put_Line (Buff_3); declare Path : constant String := Common_Utils.Concat_Null_Strings (Buff_1, Buff_2); Contents : constant String := Read (Path); pragma Unreferenced (Contents); begin -- NOTE: this should fail, and that's ok Assert (True, "ayyyay"); end; exception when Name_Error => Assert (False, "should not raise, path should be sound"); end Test_Read_File_From_Null_Concat_Name_Fix; end File_Utils_Test;
-- CD2B11F.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT IF A COLLECTION SIZE SPECIFICATION IS GIVEN FOR AN -- ACCESS TYPE WHOSE DESIGNATED TYPE IS A DISCRIMINATED RECORD, THEN -- OPERATIONS ON VALUES OF THE ACCESS TYPE ARE NOT AFFECTED. -- HISTORY: -- BCB 09/29/87 CREATED ORIGINAL TEST. -- PWB 05/11/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA'. WITH REPORT; USE REPORT; PROCEDURE CD2B11F IS BASIC_SIZE : CONSTANT := 1024; TYPE RECORD_TYPE(DISC : INTEGER := 100) IS RECORD COMP1 : INTEGER; COMP2 : INTEGER; COMP3 : INTEGER; END RECORD; TYPE ACC_RECORD IS ACCESS RECORD_TYPE; FOR ACC_RECORD'STORAGE_SIZE USE BASIC_SIZE; CHECK_RECORD1 : ACC_RECORD; CHECK_RECORD2 : ACC_RECORD; BEGIN TEST ("CD2B11F", "CHECK THAT IF A COLLECTION SIZE SPECIFICATION " & "IS GIVEN FOR AN ACCESS TYPE WHOSE " & "DESIGNATED TYPE IS A DISCRIMINATED RECORD, " & "THEN OPERATIONS ON VALUES OF THE ACCESS TYPE " & "ARE NOT AFFECTED"); CHECK_RECORD1 := NEW RECORD_TYPE; CHECK_RECORD1.COMP1 := 25; CHECK_RECORD1.COMP2 := 25; CHECK_RECORD1.COMP3 := 150; IF ACC_RECORD'STORAGE_SIZE < BASIC_SIZE THEN FAILED ("INCORRECT VALUE FOR RECORD TYPE ACCESS " & "STORAGE_SIZE"); END IF; IF CHECK_RECORD1.DISC /= IDENT_INT (100) THEN FAILED ("INCORRECT VALUE FOR RECORD DISCRIMINANT"); END IF; IF ((CHECK_RECORD1.COMP1 /= CHECK_RECORD1.COMP2) OR (CHECK_RECORD1.COMP1 = CHECK_RECORD1.COMP3)) THEN FAILED ("INCORRECT VALUE FOR RECORD COMPONENT"); END IF; IF EQUAL (3,3) THEN CHECK_RECORD2 := CHECK_RECORD1; END IF; IF CHECK_RECORD2 /= CHECK_RECORD1 THEN FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATOR"); END IF; RESULT; END CD2B11F;
-- -- Copyright (C) 2021 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- with RP.Device; with RP; use RP; package body Piezo is procedure Beep (This : Beeper; Duration : Milliseconds := 1_000; Frequency : Hertz := 440; Count : Positive := 1) is use RP.GPIO; use RP.PWM; Period : constant := 10_000; Half : constant := Period / 2; begin if This.Point_A /= null then Configure (This.Point_A.all, Output, Floating, RP.GPIO.PWM); end if; if This.Point_B /= null then Configure (This.Point_B.all, Output, Floating, RP.GPIO.PWM); end if; Set_Mode (This.Slice, Free_Running); Set_Frequency (This.Slice, Frequency * Period); Set_Interval (This.Slice, Period); Set_Invert (This.Slice, Channel_A => False, Channel_B => True); Set_Duty_Cycle (This.Slice, 0, 0); Enable (This.Slice); for I in 1 .. Count loop Set_Duty_Cycle (This.Slice, Half, Half); RP.Device.Timer.Delay_Milliseconds (Duration); Set_Duty_Cycle (This.Slice, 0, 0); if I /= Count then RP.Device.Timer.Delay_Milliseconds (Duration); end if; end loop; end Beep; end Piezo;
with gel.World, openGL.Surface, openGL.Camera; package gel.Camera -- -- Models a camera. -- is type Item is new openGL.Camera.item with private; type View is access all Camera.item'Class; type Views is array (Positive range <>) of View; --------- -- Forge -- procedure free (Self : in out View); -------------- -- Operations -- procedure render (Self : in out Item; the_World : in gel.World.view; To : in openGL.Surface.view); private type Item is new openGL.Camera.item with null record; end gel.Camera;
with Ada.Text_IO; procedure PE1 is S : Integer; begin S := 0; for i in 1 .. 999 loop if (i mod 3) = 0 or (i mod 5) = 0 then S := S + i; end if; end loop; Ada.Text_IO.Put_Line(Item => Integer'Image(S)); end PE1;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with Markdown.Visitors; with League.Regexps; with League.Strings; package body Markdown.Paragraphs is Blank_Pattern : constant League.Regexps.Regexp_Pattern := League.Regexps.Compile (League.Strings.To_Universal_String ("^[\ \t]*$")); Pattern : constant League.Regexps.Regexp_Pattern := League.Regexps.Compile (League.Strings.To_Universal_String ("^\ {0,3}(\-{2,}|\=+)\ *$")); ----------------- -- Append_Line -- ----------------- overriding procedure Append_Line (Self : in out Paragraph; Line : Markdown.Blocks.Text_Line; CIP : Can_Interrupt_Paragraph; Ok : in out Boolean) is Blank_Match : constant League.Regexps.Regexp_Match := Blank_Pattern.Find_Match (Line.Line); Match : constant League.Regexps.Regexp_Match := Pattern.Find_Match (Line.Line); begin Ok := not Blank_Match.Is_Matched and Self.Setext_Level = 0; if Ok then if Match.Is_Matched then if Line.Line.Element (Match.First_Index (1)).To_Wide_Wide_Character = '-' then Self.Setext_Level := 2; else Self.Setext_Level := 1; end if; elsif CIP then Ok := False; else Self.Lines.Append (Line.Line); end if; end if; end Append_Line; ------------ -- Create -- ------------ overriding function Create (Line : not null access Markdown.Blocks.Text_Line) return Paragraph is begin pragma Assert (not Line.Line.Is_Empty); return Result : Paragraph do Result.Lines.Append (Line.Line); Line.Line.Clear; end return; end Create; ------------ -- Filter -- ------------ procedure Filter (Line : Markdown.Blocks.Text_Line; Tag : in out Ada.Tags.Tag; CIP : out Can_Interrupt_Paragraph) is Blank_Match : constant League.Regexps.Regexp_Match := Blank_Pattern.Find_Match (Line.Line); begin if not Blank_Match.Is_Matched then Tag := Paragraph'Tag; CIP := False; end if; end Filter; ----------- -- Lines -- ----------- function Lines (Self : Paragraph'Class) return League.String_Vectors.Universal_String_Vector is begin return Self.Lines; end Lines; -------------------- -- Setext_Heading -- -------------------- function Setext_Heading (Self : Paragraph'Class) return Heading_Level is begin return Self.Setext_Level; end Setext_Heading; ----------- -- Visit -- ----------- overriding procedure Visit (Self : in out Paragraph; Visitor : in out Markdown.Visitors.Visitor'Class) is begin Visitor.Paragraph (Self); end Visit; end Markdown.Paragraphs;
-- -*- Mode: Ada -*- -- Filename : tamp.adb -- Description : A "hello world" style OS kernel written in Ada. -- Author : Luke A. Guest -- Created On : Thu Jun 14 11:59:53 2012 -- Licence : See LICENCE in the root directory. pragma Restrictions (No_Obsolescent_Features); with Console; use Console; with Multiboot; use Multiboot; -- with System.Address_To_Access_Conversions; -- with Ada.Unchecked_Conversion; use type Multiboot.Magic_Values; procedure TAMP is Line : Screen_Height_Range := Screen_Height_Range'First; begin null; Clear; Put ("Hello, TAMP in Ada", Screen_Width_Range'First, Line); Line := Line + 1; if Magic = Magic_Value then Put ("Magic numbers match!", Screen_Width_Range'First, Line); else Put ("Magic numbers don't match!", Screen_Width_Range'First, Line); raise Program_Error; end if; -- Line := Line + 1; -- if Info.Flags.Memory then -- Put ("Memory info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.Boot_Device then -- Put ("Boot device info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.Command_Line then -- Put ("Command line info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.Modules then -- Put ("Modules info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- if Info.Modules.Count = 2 then -- declare -- type My_Modules_Array is new Modules_Array -- (1 .. Natural (Info.Modules.Count)); -- type My_Modules_Array_Access is access all My_Modules_Array; -- -- My_Modules : aliased Modules_Array -- -- (1 .. Natural (Info.Modules.Count)); -- -- pragma Unreferenced (My_Modules); -- package To_Modules is new System.Address_To_Access_Conversions -- (Object => My_Modules_Array_Access); -- function Conv is new Ada.Unchecked_Conversion -- (Source => To_Modules.Object_Pointer, -- Target => My_Modules_Array_Access); -- Modules : constant My_Modules_Array_Access := -- Conv (To_Modules.To_Pointer -- (Info.Modules.First)); -- M : Multiboot.Modules; -- pragma Unreferenced (M); -- begin -- Put ("2 modules loaded is correct", -- Screen_Width_Range'First, Line); -- for I in 1 .. Info.Modules.Count loop -- M := Modules (Natural (I)); -- end loop; -- Line := Line + 1; -- end; -- end if; -- end if; -- if Info.Flags.Symbol_Table then -- Put ("Symbol table info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.Section_Header_Table then -- Put ("Section header table info present", -- Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.BIOS_Memory_Map then -- Put ("BIOS memory map info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- declare -- Map : Memory_Map_Entry_Access := Multiboot.First_Memory_Map_Entry; -- begin -- while Map /= null loop -- Map := Multiboot.Next_Memory_Map_Entry (Map); -- end loop; -- end; -- end if; -- if Info.Flags.Drives then -- Put ("Drives info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.ROM_Configuration then -- Put ("ROM configuration info present", -- Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.Boot_Loader then -- Put ("Boot loader info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.APM_Table then -- Put ("APM table info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- if Info.Flags.Graphics_Table then -- Put ("Graphics table info present", Screen_Width_Range'First, Line); -- Line := Line + 1; -- end if; -- raise Constraint_Error; -- raise Console.TE; -- raise Constraint_Error; -- Put (Natural 'Image (54), -- Screen_Width_Range'First, -- Screen_Height_Range'First + 1); -- exception -- when Constraint_Error => -- Put ("Constraint Error caught", 1, 15); -- when Program_Error => -- null; -- when Console.TE => -- Put ("TE caught", 1, 2); end TAMP; pragma No_Return (TAMP);
-- { dg-do run } -- { dg-options "-gnatVi" } procedure valid1 is type m is range 0 .. 10; for m'size use 8; type r is record a, b : m; c, d, e, f : boolean; end record; pragma Pack (r); for R'size use 20; type G is array (1 .. 3, 1 .. 3) of R; pragma Pack (G); procedure h (c : m) is begin null; end; GG : G := (others => (others => (2, 3, true, true, true, true))); begin h (GG (3, 2).a); end;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <vgodunko@gmail.com> -- -- 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$ ------------------------------------------------------------------------------ -- Declaration of WSDL assertions and violation reporting utilities. ------------------------------------------------------------------------------ with League.Strings; with WSDL.Diagnoses; package WSDL.Assertions is type WSDL_Assertion is (Description_1001, -- The value of the targetNamespace attribute information item SHOULD be -- dereferencable. Description_1002, -- It SHOULD resolve to a human or machine processable document that -- directly or indirectly defines the intended semantics of those -- components. Description_1003, -- It MAY resolve to a WSDL 2.0 document that provides service -- description information for that namespace. Description_1004, -- If a WSDL 2.0 document is split into multiple WSDL 2.0 documents -- (which may be combined as needed via 4.1 Including Descriptions), -- then the targetNamespace attribute information item SHOULD resolve to -- a master WSDL 2.0 document that includes all the WSDL 2.0 documents -- needed for that service description. Description_1005, -- Zero or more element information items amongst its [children], in -- order as follows: Description_1006, -- Its value MUST be an absolute IRI (see [IETF RFC 3987]) and should be -- dereferencable. Types_1007, -- Each XML Schema element declaration MUST have a unique QName. Types_1008, -- Each XML Schema type definition MUST have a unique QName. Interface_1009, -- To avoid circular definitions, an interface MUST NOT appear in the -- set of interfaces it extends, either directly or indirectly. Interface_1010, -- For each Interface component in the {interfaces} property of a -- Description component, the {name} property MUST be unique. Interface_1011, -- The list of xs:QName in an extends attribute information item MUST -- NOT contain duplicates. Interface_1012, -- Its value, if present, MUST contain absolute IRIs (see [IETF RFC -- 3987]). InterfaceFault_1013, -- An xs:token with one of the values #any, #none, #other, or #element. InterfaceFault_1014, -- When the {message content model} property has the value #any or #none -- the {element declaration} property MUST be empty. InterfaceFault_1015, -- In cases where, due to an interface extending one or more other -- interfaces, two or more Interface Fault components have the same -- value for their {name} property, then the component models of those -- Interface Fault components MUST be equivalent (see 2.15 Equivalence -- of Components). InterfaceFault_1016, -- For the above reason, it is considered good practice to ensure, where -- necessary, that the local name of the {name} property of Interface -- Fault components within a namespace SHOULD be unique, thus allowing -- such derivation to occur without inadvertent error. InterfaceFault_1017, -- If the element attribute information item has a value, then it MUST -- resolve to an Element Declaration component from the {element -- declarations} property of the Description component. InterfaceOperation_1018, -- This xs:anyURI MUST be an absolute IRI (see [IETF RFC 3987]). InterfaceOperation_1019, -- These xs:anyURIs MUST be absolute IRIs (see [IETF RFC 3986]). InterfaceOperation_1020, -- In cases where, due to an interface extending one or more other -- interfaces, two or more Interface Operation components have the same -- value for their {name} property, then the component models of those -- Interface Operation components MUST be equivalent (see 2.15 -- Equivalence of Components). InterfaceOperation_1021, -- For the above reason, it is considered good practice to ensure, where -- necessary, that the {name} property of Interface Operation components -- within a namespace SHOULD be unique, thus allowing such derivation to -- occur without inadvertent error. MEP_1022, -- A message exchange pattern is itself uniquely identified by an -- absolute IRI, which is used as the value of the {message exchange -- pattern} property of the Interface Operation component, and which -- specifies the fault propagation ruleset that its faults obey. InterfaceOperation_1023, -- An Interface Operation component MUST satisfy the specification -- defined by each operation style identified by its {style} property. MessageLabel_1024, -- The value of this property MUST match the name of a placeholder -- message defined by the message exchange pattern. InterfaceMessageReference_1025, -- An xs:token with one of the values in or out, indicating whether the -- message is coming to the service or going from the service, -- respectively. InterfaceMessageReference_1026, -- The direction MUST be the same as the direction of the message -- identified by the {message label} property in the {message exchange -- pattern} of the Interface Operation component this is contained -- within. InterfaceMessageReference_1027, -- An xs:token with one of the values #any, #none, #other, or #element. InterfaceMessageReference_1028, -- When the {message content model} property has the value #any or -- #none, the {element declaration} property MUST be empty. InterfaceMessageReference_1029, -- For each Interface Message Reference component in the {interface -- message references} property of an Interface Operation component, its -- {message label} property MUST be unique. MessageLabel_1030, -- If the messageLabel attribute information item of an interface -- message reference element information item is present, then its -- actual value MUST match the {message label} of some placeholder -- message with {direction} equal to the message direction. MessageLabel_1031, -- If the messageLabel attribute information item of an interface -- message reference element information item is absent then there MUST -- be a unique placeholder message with {direction} equal to the message -- direction. MessageLabel_1032, -- If the local name is input then the message exchange pattern MUST -- have at least one placeholder message with direction "In". MessageLabel_1033, -- If the local name is output then the message exchange pattern MUST -- have at least one placeholder message with direction "Out". MessageLabel_1034, -- If the local name is infault then the message exchange pattern MUST -- support at least one fault in the "In" direction. MessageLabel_1035, -- If the local name is outfault then the message exchange pattern MUST -- support at least one fault in the "Out" direction. InterfaceFaultReference_1037, -- The value of this property MUST match the name of a placeholder -- message defined by the message exchange pattern. InterfaceFaultReference_1038, -- The direction MUST be consistent with the direction implied by the -- fault propagation ruleset used in the message exchange pattern of the -- operation. InterfaceFaultReference_1039, -- For each Interface Fault Reference component in the {interface fault -- references} property of an Interface Operation component, the -- combination of its {interface fault} and {message label} properties -- MUST be unique. InterfaceFaultReference_1040, -- The messageLabel attribute information item MUST be present in the -- XML representation of an Interface Fault Reference component with a -- given {direction}, if the {message exchange pattern} of the parent -- Interface Operation component has more than one fault with that -- direction. MessageLabel_1041, -- The messageLabel attribute information item of an interface fault -- reference element information item MUST be present if the message -- exchange pattern has more than one placeholder message with -- {direction} equal to the message direction. MessageLabel_1042, -- If the messageLabel attribute information item of an interface fault -- reference element information item is present then its actual value -- MUST match the {message label} of some placeholder message with -- {direction} equal to the message direction. MessageLabel_1043, -- If the messageLabel attribute information item of an interface fault -- reference element information item is absent then there MUST be a -- unique placeholder message with {direction} equal to the message -- direction. Binding_1044, -- If a Binding component specifies any operation-specific binding -- details (by including Binding Operation components) or any fault -- binding details (by including Binding Fault components), then it MUST -- specify an interface the Binding component applies to, so as to -- indicate which interface the operations come from. Binding_1045, -- A Binding component that defines bindings for an Interface component -- MUST define bindings for all the operations of that Interface -- component. Binding_1046, -- Similarly, whenever a reusable Binding component (i.e. one that does -- not specify an Interface component) is applied to a specific -- Interface component in the context of an Endpoint component (see -- 2.13.1 The Endpoint Component), the Binding component MUST define -- bindings for each Interface Operation and Interface Fault component -- of the Interface component, via a combination of properties defined -- on the Binding component itself and default binding rules specific to -- its binding type. Binding_1047, -- A Binding component that defines bindings for an Interface component -- MUST define bindings for all the faults of that Interface component -- that are referenced from any of the operations in that Interface -- component. Binding_1048, -- This xs:anyURI MUST be an absolute IRI as defined by [IETF RFC 3987]. Binding_1049, -- For each Binding component in the {bindings} property of a -- Description component, the {name} property MUST be unique. BindingFault_1050, -- For each Binding Fault component in the {binding faults} property of -- a Binding component, the {interface fault} property MUST be unique. BindingOperation_1051); -- For each Binding Operation component in the {binding operations} -- property of a Binding component, the {interface operation} property -- MUST be unique. procedure Report (File : League.Strings.Universal_String; Line : WSDL.Diagnoses.Line_Number; Column : WSDL.Diagnoses.Column_Number; Assertion : WSDL_Assertion); -- Reports assertion. end WSDL.Assertions;
-- { dg-do compile } package body Renaming9 is procedure Proc is begin Obj.I := 0; end; begin Obj.I := 0; end Renaming9;
-- SPDX-FileCopyrightText: 2019-2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- private with Ada.Containers.Vectors; private with Ada.Finalization; with Program.Visibility; with Program.Symbols; with Program.Type_Matchers; package Program.Interpretations is pragma Preelaborate; type Solution_Kind is (Placeholder_Solution, Defining_Name_Solution, Expression_Solution, Tuple_Solution); type Solution_Array; type Solution_Tuple_Access is access constant Solution_Array; type Solution (Kind : Solution_Kind := Solution_Kind'First) is record case Kind is when Placeholder_Solution => null; when Defining_Name_Solution => Name_View : Program.Visibility.View; when Expression_Solution => Type_View : Program.Visibility.View; when Tuple_Solution => Tuple : Solution_Tuple_Access; end case; end record; type Solution_Array is array (Natural range <>) of Solution; Empty_Solution_Array : constant Solution_Array := (1 .. 0 => <>); type Context (Env : not null Program.Visibility.Context_Access) is tagged limited private; type Context_Access is access all Context'Class with Storage_Size => 0; type Interpretation_Set is tagged private; type Interpretation_Set_Array is array (Positive range <>) of Interpretation_Set; function Create_Interpretation_Set (Self : in out Context'Class) return Interpretation_Set; procedure Add_Symbol (Self : in out Interpretation_Set'Class; Symbol : Program.Symbols.Symbol); -- Extend Self with symbol interpretation procedure Add_Defining_Name (Self : in out Interpretation_Set'Class; Name_View : Program.Visibility.View; Down : Solution_Array := Empty_Solution_Array); type Apply_Kind is (Unknown, Function_Call, Type_Convertion, Indexed_Component); procedure Add_Expression (Self : in out Interpretation_Set'Class; Tipe : Program.Visibility.View; -- Apply : Apply_Kind := Unknown; ??? Down : Solution_Array := Empty_Solution_Array); procedure Add_Expression_Category (Self : in out Interpretation_Set'Class; Matcher : not null Program.Type_Matchers.Type_Matcher_Access); private type Solution_Array_Access is access all Solution_Array; type Interpretation_Kind is (Symbol, Name, Expression, Expression_Category); type Interpretation (Kind : Interpretation_Kind := Symbol) is record case Kind is when Symbol => Symbol : Program.Symbols.Symbol; when Name => Name_View : Program.Visibility.View; when Expression => Type_View : Program.Visibility.View; Solutions : Solution_Array_Access; when Expression_Category => Matcher : not null Program.Type_Matchers.Type_Matcher_Access; end case; end record; package Interpretation_Vectors is new Ada.Containers.Vectors (Positive, Interpretation); type Context (Env : not null Program.Visibility.Context_Access) is new Ada.Finalization.Limited_Controlled with record Data : Interpretation_Vectors.Vector; end record; overriding procedure Finalize (Self : in out Context); type Interpretation_Set is tagged record Context : Context_Access; From : Positive; To : Natural; end record; end Program.Interpretations;
package Loop_Optimization7_Pkg is pragma Pure; type Rec is record F : Float; end record; function Conv (Trig : Rec) return Rec; end Loop_Optimization7_Pkg;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ O P T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ -- This package contains global switches set by the -- Asis_Environment.Initialize routine from the Parameters siting and -- referenced throughout the ASIS-for-GNAT -- -- This package may be considered as an ASIS analog of the GNAT Opt -- package package A4G.A_Opt is Is_Initialized : Boolean := False; -- flag indicating if the environment has already been initialized. Was_Initialized_At_Least_Once : Boolean := False; -- flag indicating if the environment was initialized at least -- once during the current launch of an ASIS application type ASIS_Warning_Mode_Type is (Suppress, Normal, Treat_As_Error); ASIS_Warning_Mode : ASIS_Warning_Mode_Type := Normal; -- Controls treatment of warning messages. If set to Suppress, warning -- messages are not generated at all. In Normal mode, they are generated -- but do not count as errors. In Treat_As_Error mode, a warning is -- treated as an error: ASIS_Failed is raised and the warning message is -- sent to an ASIS Diagnosis string. Strong_Version_Check : Boolean := True; -- Strong version check means that version strings read from the tree and -- stored in Gnatvsn are compared. Weak check means comparing ASIS version -- numbers. See BA23-002 Generate_Bug_Box : Boolean := True; -- Flag indicating if the ASIS bug box should be generated into Stderr -- when an ASIS implementation bug is detected. Keep_Going : Boolean := False; -- Flag indicating if the exit to OS should NOT be generated in case if -- ASIS internal implementation error. Set ON by Initialize '-k' parameter. ASIS_2005_Mode_Internal : Boolean := True; -- If this switch is ON, ASIS detects as predefined units also units listed -- as predefined in the 2005 revision of the Ada Standard. Now this flag is -- always ON, and we do not have any parameter to tell ASIS that only -- Ada 95 predefined units should be classified as predefined Compilation -- Units in ASIS. procedure Process_Initialization_Parameters (Parameters : String); -- Processes a Parameters string passed to the -- Asis.Implementation.Initialize query: check parameters and makes the -- corresponding settings for ASIS global switches and flags. procedure Process_Finalization_Parameters (Parameters : String); -- Processes a Parameters string passed to the -- Asis.Implementation.Finalize query. procedure Set_Off; -- Sets Is_Initialized flag OFF and then sets all the global switches -- except Was_Initialized_At_Least_Once in the initial (default) position. -- Is to be called by Asis_Environment.Finalize -- the type declarations below should probably be moved into A_Types??? type Context_Mode is -- different ways to define an ASIS Context: (One_Tree, -- a Context is made up by only one tree file N_Trees, -- a Context is made up by N tree files Partition, -- a partition Context All_Trees); -- all the tree files in tree search path are considered as making up a -- given Context type Tree_Mode is -- how ASIS deals with tree files (On_The_Fly, -- trees are created on the fly, created trees are reused as long as a -- Context remains opened Pre_Created, -- only those trees which have been created before a Context is opened -- are used Mixed, -- mixed approach - if ASIS cannot find a needed tree, it tries to -- create it on the fly Incremental, -- Similar to Mixed, but these mode goes beyond the ASIS standard and -- allows to change the environment when the Context remains open: -- - when the Context is opened, all the existing trees are processed; -- - if ASIS can not find a needed tree, it tries to create it on the -- fly, and it refreshes the information in the Context unit table -- using the data from this newly created tree; -- - any access to a unit or to an element checks that a tree to be -- accessed is consistent with the sources -- ???? This documentation definitely needs revising??? GNSA -- Any tree is created on the fly by calling GNSA. It is not written -- in a tree file and then read back by ASIS, but it is left in the -- same data structures where it has been created, and after that ASIS -- works on the same data structures. ); type Source_Mode is -- how ASIS takes into account source files when checking the consistency (All_Sources, -- sources of all the units from a given Context (except the predefined -- Standard package) should be around, and they should be the same as -- the sources from which tree files making up the Context were created Existing_Sources, -- If for a given unit from the Context the corresponding source file -- exists, it should be the same as those used to create tree files -- making up the Context No_Sources); -- Existing source files are not taken into account when checking the -- consistency of tree files end A4G.A_Opt;
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, 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. -------------------------------------------------------------------------------------------------------------------- -- SDL.Versions -- -- Library version information. -------------------------------------------------------------------------------------------------------------------- package SDL.Versions is type Version_Level is mod 2 ** 8 with Size => 8, Convention => C; -- TODO: Check this against the library, as they use an int. type Revision_Level is mod 2 ** 32; type Version is record Major : Version_Level; Minor : Version_Level; Patch : Version_Level; end record with Convention => C; -- These allow the user to determine which version of SDLAda they compiled with. Compiled_Major : constant Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_Major_Version"; Compiled_Minor : constant Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_Minor_Version"; Compiled_Patch : constant Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_Patch_Version"; Compiled : constant Version := (Major => Compiled_Major, Minor => Compiled_Minor, Patch => Compiled_Patch); function Revision return String with Inline => True; function Revision return Revision_Level; procedure Linked_With (Info : in out Version); end SDL.Versions;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . A S T _ H A N D L I N G -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1996-2001 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the OpenVMS/Alpha version. with System; use System; with System.IO; with System.Machine_Code; with System.Storage_Elements; with System.Tasking; with System.Tasking.Rendezvous; with System.Tasking.Initialization; with System.Tasking.Utilities; with System.Task_Primitives; with System.Task_Primitives.Operations; with System.Task_Primitives.Operations.DEC; -- with Ada.Finalization; -- removed, because of problem with controlled attribute ??? with Ada.Task_Attributes; with Ada.Task_Identification; with Ada.Exceptions; use Ada.Exceptions; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; package body System.AST_Handling is package ATID renames Ada.Task_Identification; package ST renames System.Tasking; package STR renames System.Tasking.Rendezvous; package STI renames System.Tasking.Initialization; package STU renames System.Tasking.Utilities; package SSE renames System.Storage_Elements; package STPO renames System.Task_Primitives.Operations; package STPOD renames System.Task_Primitives.Operations.DEC; AST_Lock : aliased System.Task_Primitives.RTS_Lock; -- This is a global lock; it is used to execute in mutual exclusion -- from all other AST tasks. It is only used by Lock_AST and -- Unlock_AST. procedure Lock_AST (Self_ID : ST.Task_ID); -- Locks out other AST tasks. Preceding a section of code by Lock_AST and -- following it by Unlock_AST creates a critical region. procedure Unlock_AST (Self_ID : ST.Task_ID); -- Releases lock previously set by call to Lock_AST. -- All nested locks must be released before other tasks competing for the -- tasking lock are released. --------------- -- Lock_AST -- --------------- procedure Lock_AST (Self_ID : ST.Task_ID) is begin STI.Defer_Abort_Nestable (Self_ID); STPO.Write_Lock (AST_Lock'Access); end Lock_AST; ----------------- -- Unlock_AST -- ----------------- procedure Unlock_AST (Self_ID : ST.Task_ID) is begin STPO.Unlock (AST_Lock'Access); STI.Undefer_Abort_Nestable (Self_ID); end Unlock_AST; --------------------------------- -- AST_Handler Data Structures -- --------------------------------- -- As noted in the private part of the spec of System.Aux_DEC, the -- AST_Handler type is simply a pointer to a procedure that takes -- a single 64bit parameter. The following is a local copy -- of that definition. -- We need our own copy because we need to get our hands on this -- and we cannot see the private part of System.Aux_DEC. We don't -- want to be a child of Aux_Dec because of complications resulting -- from the use of pragma Extend_System. We will use unchecked -- conversions between the two versions of the declarations. type AST_Handler is access procedure (Param : Long_Integer); -- However, this declaration is somewhat misleading, since the values -- referenced by AST_Handler values (all produced in this package by -- calls to Create_AST_Handler) are highly stylized. -- The first point is that in VMS/Alpha, procedure pointers do not in -- fact point to code, but rather to a 48-byte procedure descriptor. -- So a value of type AST_Handler is in fact a pointer to one of these -- 48-byte descriptors. type Descriptor_Type is new SSE.Storage_Array (1 .. 48); for Descriptor_Type'Alignment use Standard'Maximum_Alignment; type Descriptor_Ref is access all Descriptor_Type; -- Normally, there is only one such descriptor for a given procedure, but -- it works fine to make a copy of the single allocated descriptor, and -- use the copy itself, and we take advantage of this in the design here. -- The idea is that AST_Handler values will all point to a record with the -- following structure: -- Note: When we say it works fine, there is one delicate point, which -- is that the code for the AST procedure itself requires the original -- descriptor address. We handle this by saving the orignal descriptor -- address in this structure and restoring in Process_AST. type AST_Handler_Data is record Descriptor : Descriptor_Type; Original_Descriptor_Ref : Descriptor_Ref; Taskid : ATID.Task_Id; Entryno : Natural; end record; type AST_Handler_Data_Ref is access all AST_Handler_Data; function To_AST_Handler is new Ada.Unchecked_Conversion (AST_Handler_Data_Ref, System.Aux_DEC.AST_Handler); function To_AST_Data_Handler_Ref is new Ada.Unchecked_Conversion (System.Aux_DEC.AST_Handler, AST_Handler_Data_Ref); function To_AST_Data_Handler_Ref is new Ada.Unchecked_Conversion (AST_Handler, AST_Handler_Data_Ref); -- Each time Create_AST_Handler is called, a new value of this record -- type is created, containing a copy of the procedure descriptor for -- the routine used to handle all AST's (Process_AST), and the Task_Id -- and entry number parameters identifying the task entry involved. -- The AST_Handler value returned is a pointer to this record. Since -- the record starts with the procedure descriptor, it can be used -- by the system in the normal way to call the procedure. But now -- when the procedure gets control, it can determine the address of -- the procedure descriptor used to call it (since the ABI specifies -- that this is left sitting in register r27 on entry), and then use -- that address to retrieve the Task_Id and entry number so that it -- knows on which entry to queue the AST request. -- The next issue is where are these records placed. Since we intend -- to pass pointers to these records to asynchronous system service -- routines, they have to be on the heap, which means we have to worry -- about when to allocate them and deallocate them. -- We solve this problem by introducing a task attribute that points to -- a vector, indexed by the entry number, of AST_Handler_Data records -- for a given task. The pointer itself is a controlled object allowing -- us to write a finalization routine that frees the referenced vector. -- An entry in this vector is either initialized (Entryno non-zero) and -- can be used for any subsequent reference to the same entry, or it is -- unused, marked by the Entryno value being zero. type AST_Handler_Vector is array (Natural range <>) of AST_Handler_Data; type AST_Handler_Vector_Ref is access all AST_Handler_Vector; procedure Free is new Ada.Unchecked_Deallocation (Object => AST_Handler_Vector, Name => AST_Handler_Vector_Ref); -- type AST_Vector_Ptr is new Ada.Finalization.Controlled with record -- removed due to problem with controlled attribute, consequence is that -- we have a memory leak if a task that has AST attribute entries is -- terminated. ??? type AST_Vector_Ptr is record Vector : AST_Handler_Vector_Ref; end record; procedure Finalize (Object : in out AST_Vector_Ptr); -- Used to get rid of allocated AST_Vector's AST_Vector_Init : AST_Vector_Ptr; -- Initial value, treated as constant, Vector will be null. package AST_Attribute is new Ada.Task_Attributes (Attribute => AST_Vector_Ptr, Initial_Value => AST_Vector_Init); use AST_Attribute; ----------------------- -- AST Service Queue -- ----------------------- -- The following global data structures are used to queue pending -- AST requests. When an AST is signalled, the AST service routine -- Process_AST is called, and it makes an entry in this structure. type AST_Instance is record Taskid : ATID.Task_Id; Entryno : Natural; Param : Long_Integer; end record; -- The Taskid and Entryno indicate the entry on which this AST is to -- be queued, and Param is the parameter provided from the AST itself. AST_Service_Queue_Size : constant := 256; AST_Service_Queue_Limit : constant := 250; type AST_Service_Queue_Index is mod AST_Service_Queue_Size; -- Index used to refer to entries in the circular buffer which holds -- active AST_Instance values. The upper bound reflects the maximum -- number of AST instances that can be stored in the buffer. Since -- these entries are immediately serviced by the high priority server -- task that does the actual entry queuing, it is very unusual to have -- any significant number of entries simulaneously queued. AST_Service_Queue : array (AST_Service_Queue_Index) of AST_Instance; pragma Volatile_Components (AST_Service_Queue); -- The circular buffer used to store active AST requests. AST_Service_Queue_Put : AST_Service_Queue_Index := 0; AST_Service_Queue_Get : AST_Service_Queue_Index := 0; pragma Atomic (AST_Service_Queue_Put); pragma Atomic (AST_Service_Queue_Get); -- These two variables point to the next slots in the AST_Service_Queue -- to be used for putting a new entry in and taking an entry out. This -- is a circular buffer, so these pointers wrap around. If the two values -- are equal the buffer is currently empty. The pointers are atomic to -- ensure proper synchronization between the single producer (namely the -- Process_AST procedure), and the single consumer (the AST_Service_Task). -------------------------------- -- AST Server Task Structures -- -------------------------------- -- The basic approach is that when an AST comes in, a call is made to -- the Process_AST procedure. It queues the request in the service queue -- and then wakes up an AST server task to perform the actual call to the -- required entry. We use this intermediate server task, since the AST -- procedure itself cannot wait to return, and we need some caller for -- the rendezvous so that we can use the normal rendezvous mechanism. -- It would work to have only one AST server task, but then we would lose -- all overlap in AST processing, and furthermore, we could get priority -- inversion effects resulting in starvation of AST requests. -- We therefore maintain a small pool of AST server tasks. We adjust -- the size of the pool dynamically to reflect traffic, so that we have -- a sufficient number of server tasks to avoid starvation. Max_AST_Servers : constant Natural := 16; -- Maximum number of AST server tasks that can be allocated Num_AST_Servers : Natural := 0; -- Number of AST server tasks currently active Num_Waiting_AST_Servers : Natural := 0; -- This is the number of AST server tasks that are either waiting for -- work, or just about to go to sleep and wait for work. Is_Waiting : array (1 .. Max_AST_Servers) of Boolean := (others => False); -- An array of flags showing which AST server tasks are currently waiting AST_Task_Ids : array (1 .. Max_AST_Servers) of ST.Task_ID; -- Task Id's of allocated AST server tasks task type AST_Server_Task (Num : Natural) is pragma Priority (Priority'Last); end AST_Server_Task; -- Declaration for AST server task. This task has no entries, it is -- controlled by sleep and wakeup calls at the task primitives level. type AST_Server_Task_Ptr is access all AST_Server_Task; -- Type used to allocate server tasks function To_Integer is new Ada.Unchecked_Conversion (ATID.Task_Id, Integer); ----------------------- -- Local Subprograms -- ----------------------- procedure Allocate_New_AST_Server; -- Allocate an additional AST server task procedure Process_AST (Param : Long_Integer); -- This is the central routine for processing all AST's, it is referenced -- as the code address of all created AST_Handler values. See detailed -- description in body to understand how it works to have a single such -- procedure for all AST's even though it does not get any indication of -- the entry involved passed as an explicit parameter. The single explicit -- parameter Param is the parameter passed by the system with the AST. ----------------------------- -- Allocate_New_AST_Server -- ----------------------------- procedure Allocate_New_AST_Server is Dummy : AST_Server_Task_Ptr; begin if Num_AST_Servers = Max_AST_Servers then return; else -- Note: it is safe to increment Num_AST_Servers immediately, since -- no one will try to activate this task until it indicates that it -- is sleeping by setting its entry in Is_Waiting to True. Num_AST_Servers := Num_AST_Servers + 1; Dummy := new AST_Server_Task (Num_AST_Servers); end if; end Allocate_New_AST_Server; --------------------- -- AST_Server_Task -- --------------------- task body AST_Server_Task is Taskid : ATID.Task_Id; Entryno : Natural; Param : aliased Long_Integer; Self_Id : constant ST.Task_ID := ST.Self; pragma Volatile (Param); begin -- By making this task independent of master, when the environment -- task is finalizing, the AST_Server_Task will be notified that it -- should terminate. STU.Make_Independent; -- Record our task Id for access by Process_AST AST_Task_Ids (Num) := Self_Id; -- Note: this entire task operates with the main task lock set, except -- when it is sleeping waiting for work, or busy doing a rendezvous -- with an AST server. This lock protects the data structures that -- are shared by multiple instances of the server task. Lock_AST (Self_Id); -- This is the main infinite loop of the task. We go to sleep and -- wait to be woken up by Process_AST when there is some work to do. loop Num_Waiting_AST_Servers := Num_Waiting_AST_Servers + 1; Unlock_AST (Self_Id); STI.Defer_Abort (Self_Id); STPO.Write_Lock (Self_Id); Is_Waiting (Num) := True; Self_Id.Common.State := ST.AST_Server_Sleep; STPO.Sleep (Self_Id, ST.AST_Server_Sleep); Self_Id.Common.State := ST.Runnable; STPO.Unlock (Self_Id); -- If the process is finalizing, Undefer_Abort will simply end -- this task. STI.Undefer_Abort (Self_Id); -- We are awake, there is something to do! Lock_AST (Self_Id); Num_Waiting_AST_Servers := Num_Waiting_AST_Servers - 1; -- Loop here to service outstanding requests. We are always -- locked on entry to this loop. while AST_Service_Queue_Get /= AST_Service_Queue_Put loop Taskid := AST_Service_Queue (AST_Service_Queue_Get).Taskid; Entryno := AST_Service_Queue (AST_Service_Queue_Get).Entryno; Param := AST_Service_Queue (AST_Service_Queue_Get).Param; AST_Service_Queue_Get := AST_Service_Queue_Get + 1; -- This is a manual expansion of the normal call simple code declare type AA is access all Long_Integer; P : AA := Param'Unrestricted_Access; function To_ST_Task_Id is new Ada.Unchecked_Conversion (ATID.Task_Id, ST.Task_ID); begin Unlock_AST (Self_Id); STR.Call_Simple (Acceptor => To_ST_Task_Id (Taskid), E => ST.Task_Entry_Index (Entryno), Uninterpreted_Data => P'Address); exception when E : others => System.IO.Put_Line ("%Debugging event"); System.IO.Put_Line (Exception_Name (E) & " raised when trying to deliver an AST."); if Exception_Message (E)'Length /= 0 then System.IO.Put_Line (Exception_Message (E)); end if; System.IO.Put_Line ("Task type is " & "Receiver_Type"); System.IO.Put_Line ("Task id is " & ATID.Image (Taskid)); end; Lock_AST (Self_Id); end loop; end loop; end AST_Server_Task; ------------------------ -- Create_AST_Handler -- ------------------------ function Create_AST_Handler (Taskid : ATID.Task_Id; Entryno : Natural) return System.Aux_DEC.AST_Handler is Attr_Ref : Attribute_Handle; Process_AST_Ptr : constant AST_Handler := Process_AST'Access; -- Reference to standard procedure descriptor for Process_AST function To_Descriptor_Ref is new Ada.Unchecked_Conversion (AST_Handler, Descriptor_Ref); Original_Descriptor_Ref : Descriptor_Ref := To_Descriptor_Ref (Process_AST_Ptr); begin if ATID.Is_Terminated (Taskid) then raise Program_Error; end if; Attr_Ref := Reference (Taskid); -- Allocate another server if supply is getting low if Num_Waiting_AST_Servers < 2 then Allocate_New_AST_Server; end if; -- No point in creating more if we have zillions waiting to -- be serviced. while AST_Service_Queue_Put - AST_Service_Queue_Get > AST_Service_Queue_Limit loop delay 0.01; end loop; -- If no AST vector allocated, or the one we have is too short, then -- allocate one of right size and initialize all entries except the -- one we will use to unused. Note that the assignment automatically -- frees the old allocated table if there is one. if Attr_Ref.Vector = null or else Attr_Ref.Vector'Length < Entryno then Attr_Ref.Vector := new AST_Handler_Vector (1 .. Entryno); for E in 1 .. Entryno loop Attr_Ref.Vector (E).Descriptor := Original_Descriptor_Ref.all; Attr_Ref.Vector (E).Original_Descriptor_Ref := Original_Descriptor_Ref; Attr_Ref.Vector (E).Taskid := Taskid; Attr_Ref.Vector (E).Entryno := E; end loop; end if; return To_AST_Handler (Attr_Ref.Vector (Entryno)'Unrestricted_Access); end Create_AST_Handler; ---------------------------- -- Expand_AST_Packet_Pool -- ---------------------------- procedure Expand_AST_Packet_Pool (Requested_Packets : in Natural; Actual_Number : out Natural; Total_Number : out Natural) is begin -- The AST implementation of GNAT does not permit dynamic expansion -- of the pool, so we simply add no entries and return the total. If -- it is necessary to expand the allocation, then this package body -- must be recompiled with a larger value for AST_Service_Queue_Size. Actual_Number := 0; Total_Number := AST_Service_Queue_Size; end Expand_AST_Packet_Pool; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out AST_Vector_Ptr) is begin Free (Object.Vector); end Finalize; ----------------- -- Process_AST -- ----------------- procedure Process_AST (Param : Long_Integer) is Handler_Data_Ptr : AST_Handler_Data_Ref; -- This variable is set to the address of the descriptor through -- which Process_AST is called. Since the descriptor is part of -- an AST_Handler value, this is also the address of this value, -- from which we can obtain the task and entry number information. function To_Address is new Ada.Unchecked_Conversion (ST.Task_ID, System.Address); begin System.Machine_Code.Asm (Template => "addl $27,0,%0", Outputs => AST_Handler_Data_Ref'Asm_Output ("=r", Handler_Data_Ptr), Volatile => True); System.Machine_Code.Asm (Template => "ldl $27,%0", Inputs => Descriptor_Ref'Asm_Input ("m", Handler_Data_Ptr.Original_Descriptor_Ref), Volatile => True); AST_Service_Queue (AST_Service_Queue_Put) := AST_Instance' (Taskid => Handler_Data_Ptr.Taskid, Entryno => Handler_Data_Ptr.Entryno, Param => Param); -- ??? What is the protection of this variable ? -- It seems that trying to use any lock in this procedure will get -- an ACCVIO. AST_Service_Queue_Put := AST_Service_Queue_Put + 1; -- Need to wake up processing task. If there is no waiting server -- then we have temporarily run out, but things should still be -- OK, since one of the active ones will eventually pick up the -- service request queued in the AST_Service_Queue. for J in 1 .. Num_AST_Servers loop if Is_Waiting (J) then Is_Waiting (J) := False; -- Sleeps are handled by ASTs on VMS, so don't call Wakeup. -- ??? We should lock AST_Task_Ids (J) here. What's the story ? STPOD.Interrupt_AST_Handler (To_Address (AST_Task_Ids (J))); exit; end if; end loop; end Process_AST; begin STPO.Initialize_Lock (AST_Lock'Access, STPO.Global_Task_Level); end System.AST_Handling;
-- -- PQueue -- Generic protected queue package -- -- This code was adapted from two different chunks of code in Norman -- H. Cohen's excellent book Ada as a Second Language. It implements a simple -- protected generic queue type. generic type Data_Type is private; package PQueue is pragma Preelaborate; ------------------------------------------------------------------------------ -- -- Public types -- ------------------------------------------------------------------------------ -- The implementation details of the queue aren't important to users type Queue_Type is limited private; -- The protected type, providing an interface to manage the queue protected type Protected_Queue_Type is -- Place an item on the back of the queue. Doesn't block. procedure Enqueue (Item : in Data_Type); -- Remove an item from the front of the queue. Blocks if no items are -- present. entry Dequeue (Item : out Data_Type); -- Return the number of items presently on the queue. Doesn't block. function Length return natural; private -- The actual queue we're protecting Queue : Queue_Type; end Protected_Queue_Type; ------------------------------------------------------------------------------ -- -- Private types -- ------------------------------------------------------------------------------ private -- Implementation of a simple queue, using a linked list. First, define -- the list node type, with a data item of whatever type the user specifies -- when they instantiate this generic package. type Queue_Element_Type; type Queue_Element_Pointer is access Queue_Element_Type; type Queue_Element_Type is record Data : Data_Type; Next : Queue_Element_Pointer; end record; -- Now the queue itself, with its length, and pointers to the front and -- back items. type Queue_Type is record Len : natural := 0; Front : Queue_Element_Pointer := null; Back : Queue_Element_Pointer := null; end record; --------------------------------------------------------------------------- end PQueue;
pragma Ada_2012; pragma Style_Checks (Off); pragma Warnings ("U"); with Interfaces.C; use Interfaces.C; with sys_ustdint_h; package cmsis_gcc_h is pragma Compile_Time_Warning (True, "probably incorrect record layout"); type T_UINT32 is record v : aliased sys_ustdint_h.uint32_t; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:74 end record with Convention => C_Pass_By_Copy; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:74 pragma Compile_Time_Warning (True, "probably incorrect record layout"); type T_UINT16_WRITE is record v : aliased sys_ustdint_h.uint16_t; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:82 end record with Convention => C_Pass_By_Copy; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:82 pragma Compile_Time_Warning (True, "probably incorrect record layout"); type T_UINT16_READ is record v : aliased sys_ustdint_h.uint16_t; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:90 end record with Convention => C_Pass_By_Copy; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:90 pragma Compile_Time_Warning (True, "probably incorrect record layout"); type T_UINT32_WRITE is record v : aliased sys_ustdint_h.uint32_t; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:98 end record with Convention => C_Pass_By_Copy; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:98 pragma Compile_Time_Warning (True, "probably incorrect record layout"); type T_UINT32_READ is record v : aliased sys_ustdint_h.uint32_t; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:106 end record with Convention => C_Pass_By_Copy; -- ../CMSIS_5/CMSIS/Core/Include/cmsis_gcc.h:106 -- skipped func __cmsis_start -- skipped func _start -- skipped func __ISB -- skipped func __DSB -- skipped func __DMB -- skipped func __REV -- skipped func __REV16 -- skipped func __REVSH -- skipped func __ROR -- skipped func __RBIT -- skipped func __CLZ -- skipped func __SSAT -- skipped func __USAT -- skipped func __enable_irq -- skipped func __disable_irq -- skipped func __get_CONTROL -- skipped func __set_CONTROL -- skipped func __get_IPSR -- skipped func __get_APSR -- skipped func __get_xPSR -- skipped func __get_PSP -- skipped func __set_PSP -- skipped func __get_MSP -- skipped func __set_MSP -- skipped func __get_PRIMASK -- skipped func __set_PRIMASK -- skipped func __get_FPSCR -- skipped func __set_FPSCR end cmsis_gcc_h;
------------------------------------------------------------------------------ -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with HAL.GPIO; private with System; package SAM.Port is type GPIO_Pin_Index is range 0 .. 31; type Peripheral_Function is (A, B, C, D, E, F, G, H, I, J, K, L, M, N, Disabled); type Port_Internal is private; type Port_Controller (Periph : not null access Port_Internal) is private; type Any_GPIO_Controller is access all Port_Controller; type GPIO_Point (Controller : not null Any_GPIO_Controller; Pin : GPIO_Pin_Index) is new HAL.GPIO.GPIO_Point with private; procedure Set_Function (This : in out GPIO_Point; Func : Peripheral_Function); -- Set the peripheral function for the given pin. The function is disabled -- by default. -- -- See Multiplexed Peripheral Signals table of your device reference manual -- for more information about the available functions. --------------- -- HAL.GPIO -- --------------- overriding function Support (This : GPIO_Point; Unused : HAL.GPIO.Capability) return Boolean is (True); overriding function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode; overriding procedure Set_Mode (This : in out GPIO_Point; Mode : HAL.GPIO.GPIO_Config_Mode); overriding function Pull_Resistor (This : GPIO_Point) return HAL.GPIO.GPIO_Pull_Resistor; overriding procedure Set_Pull_Resistor (This : in out GPIO_Point; Pull : HAL.GPIO.GPIO_Pull_Resistor); overriding function Set (This : GPIO_Point) return Boolean; overriding procedure Set (This : in out GPIO_Point); overriding procedure Clear (This : in out GPIO_Point); overriding procedure Toggle (This : in out GPIO_Point); private for Peripheral_Function use (A => 0, B => 1, C => 2, D => 3, E => 4, F => 5, G => 6, H => 7, I => 8, J => 9, K => 10, L => 11, M => 12, N => 13, Disabled => 17); type Port_Controller (Periph : not null access Port_Internal) is null record; type GPIO_Point (Controller : not null Any_GPIO_Controller; Pin : GPIO_Pin_Index) is new HAL.GPIO.GPIO_Point with null record; --------------- -- Registers -- --------------- subtype WRCONFIG_PINMASK_Field is HAL.UInt16; subtype WRCONFIG_PMUX_Field is HAL.UInt4; -- Write Configuration type WRCONFIG_Register is record -- Write-only. Pin Mask for Multiple Pin Configuration PINMASK : WRCONFIG_PINMASK_Field := 16#0#; -- Write-only. Peripheral Multiplexer Enable PMUXEN : Boolean := False; -- Write-only. Input Enable INEN : Boolean := False; -- Write-only. Pull Enable PULLEN : Boolean := False; -- unspecified Reserved_19_21 : HAL.UInt3 := 16#0#; -- Write-only. Output Driver Strength Selection DRVSTR : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Write-only. Peripheral Multiplexing PMUX : WRCONFIG_PMUX_Field := 16#0#; -- Write-only. Write PMUX WRPMUX : Boolean := False; -- unspecified Reserved_29_29 : HAL.Bit := 16#0#; -- Write-only. Write PINCFG WRPINCFG : Boolean := False; -- Write-only. Half-Word Select HWSEL : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WRCONFIG_Register use record PINMASK at 0 range 0 .. 15; PMUXEN at 0 range 16 .. 16; INEN at 0 range 17 .. 17; PULLEN at 0 range 18 .. 18; Reserved_19_21 at 0 range 19 .. 21; DRVSTR at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; PMUX at 0 range 24 .. 27; WRPMUX at 0 range 28 .. 28; Reserved_29_29 at 0 range 29 .. 29; WRPINCFG at 0 range 30 .. 30; HWSEL at 0 range 31 .. 31; end record; subtype EVCTRL_PID0_Field is HAL.UInt5; -- PORT Event Action 0 type EVCTRL0_EVACT0Select is ( -- Event output to pin Out_k, -- Set output register of pin on event Set, -- Clear output register of pin on event Clr, -- Toggle output register of pin on event Tgl) with Size => 2; for EVCTRL0_EVACT0Select use (Out_k => 0, Set => 1, Clr => 2, Tgl => 3); subtype EVCTRL_PID1_Field is HAL.UInt5; subtype EVCTRL_EVACT1_Field is HAL.UInt2; subtype EVCTRL_PID2_Field is HAL.UInt5; subtype EVCTRL_EVACT2_Field is HAL.UInt2; subtype EVCTRL_PID3_Field is HAL.UInt5; subtype EVCTRL_EVACT3_Field is HAL.UInt2; -- Event Input Control type EVCTRL_Register is record -- PORT Event Pin Identifier 0 PID0 : EVCTRL_PID0_Field := 16#0#; -- PORT Event Action 0 EVACT0 : EVCTRL0_EVACT0Select := Out_k; -- PORT Event Input Enable 0 PORTEI0 : Boolean := False; -- PORT Event Pin Identifier 1 PID1 : EVCTRL_PID1_Field := 16#0#; -- PORT Event Action 1 EVACT1 : EVCTRL_EVACT1_Field := 16#0#; -- PORT Event Input Enable 1 PORTEI1 : Boolean := False; -- PORT Event Pin Identifier 2 PID2 : EVCTRL_PID2_Field := 16#0#; -- PORT Event Action 2 EVACT2 : EVCTRL_EVACT2_Field := 16#0#; -- PORT Event Input Enable 2 PORTEI2 : Boolean := False; -- PORT Event Pin Identifier 3 PID3 : EVCTRL_PID3_Field := 16#0#; -- PORT Event Action 3 EVACT3 : EVCTRL_EVACT3_Field := 16#0#; -- PORT Event Input Enable 3 PORTEI3 : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EVCTRL_Register use record PID0 at 0 range 0 .. 4; EVACT0 at 0 range 5 .. 6; PORTEI0 at 0 range 7 .. 7; PID1 at 0 range 8 .. 12; EVACT1 at 0 range 13 .. 14; PORTEI1 at 0 range 15 .. 15; PID2 at 0 range 16 .. 20; EVACT2 at 0 range 21 .. 22; PORTEI2 at 0 range 23 .. 23; PID3 at 0 range 24 .. 28; EVACT3 at 0 range 29 .. 30; PORTEI3 at 0 range 31 .. 31; end record; subtype PMUX_PMUXE_Field is HAL.UInt4; subtype PMUX_PMUXO_Field is HAL.UInt4; -- Peripheral Multiplexing - Group 0 type PMUX_Register is record -- Peripheral Multiplexing for Even-Numbered Pin PMUXE : PMUX_PMUXE_Field := 16#0#; -- Peripheral Multiplexing for Odd-Numbered Pin PMUXO : PMUX_PMUXO_Field := 16#0#; end record with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First; for PMUX_Register use record PMUXE at 0 range 0 .. 3; PMUXO at 0 range 4 .. 7; end record; -- Peripheral Multiplexing - Group 0 type PMUX_Registers is array (0 .. 15) of PMUX_Register; -- Pin Configuration - Group 0 type PINCFG_Register is record -- Peripheral Multiplexer Enable PMUXEN : Boolean := False; -- Input Enable INEN : Boolean := False; -- Pull Enable PULLEN : Boolean := False; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Output Driver Strength Selection DRVSTR : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First; for PINCFG_Register use record PMUXEN at 0 range 0 .. 0; INEN at 0 range 1 .. 1; PULLEN at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; DRVSTR at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; end record; -- Pin Configuration - Group 0 type PINCFG_Registers is array (GPIO_Pin_Index) of PINCFG_Register; ----------------- -- Peripherals -- ----------------- -- Port Module type PORT_Internal is record -- Data Direction DIR : aliased HAL.UInt32; -- Data Direction Clear DIRCLR : aliased HAL.UInt32; -- Data Direction Set DIRSET : aliased HAL.UInt32; -- Data Direction Toggle DIRTGL : aliased HAL.UInt32; -- Data Output Value DATA_OUT : aliased HAL.UInt32; -- Data Output Value Clear OUTCLR : aliased HAL.UInt32; -- Data Output Value Set OUTSET : aliased HAL.UInt32; -- Data Output Value Toggle OUTTGL : aliased HAL.UInt32; -- Data Input Value DATA_IN : aliased HAL.UInt32; -- Control CTRL : aliased HAL.UInt32; -- Write Configuration WRCONFIG : aliased WRCONFIG_Register; -- Event Input Control EVCTRL : aliased EVCTRL_Register; -- Peripheral Multiplexing - Group 0 PMUX : aliased PMUX_Registers; -- Pin Configuration - Group 0 PINCFG : aliased PINCFG_Registers; end record with Volatile; for PORT_Internal use record DIR at 16#0# range 0 .. 31; DIRCLR at 16#4# range 0 .. 31; DIRSET at 16#8# range 0 .. 31; DIRTGL at 16#C# range 0 .. 31; DATA_OUT at 16#10# range 0 .. 31; OUTCLR at 16#14# range 0 .. 31; OUTSET at 16#18# range 0 .. 31; OUTTGL at 16#1C# range 0 .. 31; DATA_IN at 16#20# range 0 .. 31; CTRL at 16#24# range 0 .. 31; WRCONFIG at 16#28# range 0 .. 31; EVCTRL at 16#2C# range 0 .. 31; PMUX at 16#30# range 0 .. 127; PINCFG at 16#40# range 0 .. 255; end record; end SAM.Port;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Characters.Handling; use Ada.Characters.Handling; procedure Soundex is type UStrings is array(Natural range <>) of Unbounded_String; function "+"(S:String) return Unbounded_String renames To_Unbounded_String; function toSoundex (instr : String) return String is str : String := To_Upper(instr); output : String := "0000"; spos : Integer := str'First+1; opos : Positive := 2; map : array(0..255) of Character := (others => ' '); last : Integer := str'First; begin map(65..90) := " 123 12- 22455 12623 1-2 2"; for i in str'Range loop str(i) := map(Character'Pos(str(i))); end loop; output(1) := str(str'First); while (opos <= 4 and spos <= str'Last) loop if str(spos) /= '-' and str(spos) /= ' ' then if (str(spos-1) = '-' and last = spos-2) and then (str(spos) = str(spos-2)) then null; elsif (str(spos) = output(opos-1) and last = spos-1) then last := spos; else output(opos) := str(spos); opos := opos + 1; last := spos; end if; end if; spos := spos + 1; end loop; output(1) := To_Upper(instr(instr'First)); return output; end toSoundex; cases : constant UStrings := (+"Soundex", +"Example", +"Sownteks", +"Ekzampul", +"Euler", +"Gauss", +"Hilbert", +"Knuth", +"Lloyd", +"Lukasiewicz", +"Ellery", +"Ghosh", +"Heilbronn", +"Kant", +"Ladd", +"Lissajous", +"Wheaton", +"Burroughs", +"Burrows", +"O'Hara", +"Washington", +"Lee", +"Gutierrez", +"Pfister", +"Jackson", +"Tymczak", +"VanDeusen", +"Ashcraft"); begin for i in cases'Range loop Put_Line(To_String(cases(i))&" = "&toSoundex(To_String(cases(i)))); end loop; end Soundex;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, 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. -- -- -- ------------------------------------------------------------------------------ with HAL; use HAL; with HAL.I2C; use HAL.I2C; package body BBQ10KBD is ---------- -- Read -- ---------- procedure Read (This : in out BBQ10KBD_Device; Reg : HAL.UInt8; Data : out HAL.I2C.I2C_Data) is Status : I2C_Status; begin This.Port.Mem_Read (Device_Addr, UInt16 (Reg), Memory_Size_8b, Data, Status); if Status /= Ok then raise Program_Error; end if; end Read; ----------- -- Write -- ----------- procedure Write (This : in out BBQ10KBD_Device; Reg : HAL.UInt8; Data : HAL.I2C.I2C_Data) is Status : I2C_Status; begin This.Port.Mem_Write (Device_Addr, UInt16 (Reg), Memory_Size_8b, Data, Status); if Status /= Ok then raise Program_Error; end if; end Write; ------------- -- Version -- ------------- function Version (This : in out BBQ10KBD_Device) return HAL.UInt8 is Data : I2C_Data (0 .. 0); begin This.Read (REG_VER, Data); return Data (Data'First); end Version; ------------------ -- Key_FIFO_Pop -- ------------------ function Key_FIFO_Pop (This : in out BBQ10KBD_Device) return Key_State is Data : I2C_Data (0 .. 1); begin This.Read (REG_FIF, Data); return State : Key_State do case Data (Data'First) is when 1 => State.Kind := Pressed; when 2 => State.Kind := Held_Pressed; when 3 => State.Kind := Released; when others => State.Kind := Error; end case; State.Code := Data (Data'Last); end return; end Key_FIFO_Pop; ------------ -- Status -- ------------ function Status (This : in out BBQ10KBD_Device) return KBD_Status is Data : I2C_Data (0 .. 0); D : UInt8 renames Data (Data'First); begin This.Read (REG_KEY, Data); return Stat : KBD_Status do Stat.Numlock := (D and 1) /= 0; Stat.Capslock := (D and 1) /= 0; Stat.Key_Count := UInt5 (D and 16#1F#); end return; end Status; ------------------- -- Set_Backlight -- ------------------- procedure Set_Backlight (This : in out BBQ10KBD_Device; Lvl : HAL.UInt8) is begin This.Write (REG_BKL, (0 => Lvl)); end Set_Backlight; end BBQ10KBD;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, 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. -- -- -- ------------------------------------------------------------------------------ -- This program demonstrates use of the CRC processor on STM32F4x MCUs. (The -- STM32F3 MCUs, among others, have additional CRC capabilities.) -- The checksum for a given block of 32-bit words is calculated two ways and -- then compared. -- The checksum is first computed on the data block by calling a routine that -- transfers the block content to the CRC processor in a loop, which is to say -- that the CPU does the transfer. In the second approach, a different routine -- is called. This second routine uses DMA to transfer the data block to -- the CRC processor. Obviously for a large data block, this second approach -- is far quicker. -- The first routine includes a parameter that provides the checksum. The -- second routine does not have this output parameter since the caller will -- return before the transfer completes (in practice) and the checksum is -- computed. Hence after calling the second routine the caller blocks, -- waiting for the DMA transfer completion interrupt. -- If the two checksums are equal then the green LED is turned on, otherwise -- the red LED is turned on. Both checksum values are displayed. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with STM32.Device; use STM32.Device; with STM32.Board; use STM32.Board; with STM32.CRC; use STM32.CRC; with STM32.CRC.DMA; use STM32.CRC.DMA; with LCD_Std_Out; use LCD_Std_Out; with HAL; use HAL; with STM32.DMA; use STM32.DMA; with Ada.Real_Time; use Ada.Real_Time; with Memory_Transfer; use Memory_Transfer; with Ada.Unchecked_Conversion; with System; procedure Demo_CRC is Checksum_CPU : UInt32 := 0; -- the checksum obtained by calling a routine that uses the CPU to transfer -- the memory block to the CRC processor Checksum_DMA : UInt32 := 0; -- the checksum obtained by calling a routine that uses DMA to transfer the -- memory block to the CRC processor -- see the STM32Cube_FW_F4_V1.6.0\Projects\ CRC example for data and -- expected CRC checksum value Section1 : constant Block_32 := (16#00001021#, 16#20423063#, 16#408450A5#, 16#60C670E7#, 16#9129A14A#, 16#B16BC18C#, 16#D1ADE1CE#, 16#F1EF1231#, 16#32732252#, 16#52B54294#, 16#72F762D6#, 16#93398318#, 16#A35AD3BD#, 16#C39CF3FF#, 16#E3DE2462#, 16#34430420#, 16#64E674C7#, 16#44A45485#, 16#A56AB54B#, 16#85289509#, 16#F5CFC5AC#, 16#D58D3653#, 16#26721611#, 16#063076D7#, 16#569546B4#, 16#B75BA77A#, 16#97198738#, 16#F7DFE7FE#, 16#C7BC48C4#, 16#58E56886#, 16#78A70840#, 16#18612802#, 16#C9CCD9ED#, 16#E98EF9AF#, 16#89489969#, 16#A90AB92B#, 16#4AD47AB7#, 16#6A961A71#, 16#0A503A33#, 16#2A12DBFD#, 16#FBBFEB9E#, 16#9B798B58#, 16#BB3BAB1A#, 16#6CA67C87#, 16#5CC52C22#, 16#3C030C60#, 16#1C41EDAE#, 16#FD8FCDEC#, 16#AD2ABD0B#, 16#8D689D49#, 16#7E976EB6#, 16#5ED54EF4#, 16#2E321E51#, 16#0E70FF9F#); Section2 : constant Block_32 := (16#EFBEDFDD#, 16#CFFCBF1B#, 16#9F598F78#, 16#918881A9#, 16#B1CAA1EB#, 16#D10CC12D#, 16#E16F1080#, 16#00A130C2#, 16#20E35004#, 16#40257046#, 16#83B99398#, 16#A3FBB3DA#, 16#C33DD31C#, 16#E37FF35E#, 16#129022F3#, 16#32D24235#, 16#52146277#, 16#7256B5EA#, 16#95A88589#, 16#F56EE54F#, 16#D52CC50D#, 16#34E224C3#, 16#04817466#, 16#64475424#, 16#4405A7DB#, 16#B7FA8799#, 16#E75FF77E#, 16#C71DD73C#, 16#26D336F2#, 16#069116B0#, 16#76764615#, 16#5634D94C#, 16#C96DF90E#, 16#E92F99C8#, 16#B98AA9AB#, 16#58444865#, 16#78066827#, 16#18C008E1#, 16#28A3CB7D#, 16#DB5CEB3F#, 16#FB1E8BF9#, 16#9BD8ABBB#, 16#4A755A54#, 16#6A377A16#, 16#0AF11AD0#, 16#2AB33A92#, 16#ED0FDD6C#, 16#CD4DBDAA#, 16#AD8B9DE8#, 16#8DC97C26#, 16#5C644C45#, 16#3CA22C83#, 16#1CE00CC1#, 16#EF1FFF3E#, 16#DF7CAF9B#, 16#BFBA8FD9#, 16#9FF86E17#, 16#7E364E55#, 16#2E933EB2#, 16#0ED11EF0#); -- expected CRC value for the data above is 379E9F06 hex, or 933142278 dec Expected_Checksum : constant UInt32 := 933142278; Next_DMA_Interrupt : DMA_Interrupt; procedure Panic with No_Return; -- flash the on-board LEDs, indefinitely, to indicate a failure procedure Panic is begin loop Toggle_LEDs (All_LEDs); delay until Clock + Milliseconds (100); end loop; end Panic; begin Clear_Screen; Initialize_LEDs; Enable_Clock (CRC_Unit); -- get the checksum using the CPU to transfer memory to the CRC processor; -- verify it is the expected value Update_CRC (CRC_Unit, Input => Section1, Output => Checksum_CPU); Update_CRC (CRC_Unit, Input => Section2, Output => Checksum_CPU); Put_Line ("CRC:" & Checksum_CPU'Img); if Checksum_CPU /= Expected_Checksum then Panic; end if; -- get the checksum using DMA to transfer memory to the CRC processor Enable_Clock (Controller); Reset (Controller); Reset_Calculator (CRC_Unit); Update_CRC (CRC_Unit, Controller'Access, Stream, Input => Section1); DMA_IRQ_Handler.Await_Event (Next_DMA_Interrupt); if Next_DMA_Interrupt /= Transfer_Complete_Interrupt then Panic; end if; -- In this code fragment we use the approach suited for the case in which -- we are calculating the CRC for a section of system memory rather than a -- block of application data. We pretend that Section2 is a memory section. -- All we need is a known starting address and a known length. Given that, -- we can create a view of it as if it is an object of type Block_32 (or -- whichever block type is appropriate). declare subtype Memory_Section is Block_32 (1 .. Section2'Length); type Section_Pointer is access all Memory_Section with Storage_Size => 0; function As_Memory_Section_Reference is new Ada.Unchecked_Conversion (Source => System.Address, Target => Section_Pointer); begin Update_CRC (CRC_Unit, Controller'Access, Stream, Input => As_Memory_Section_Reference (Section2'Address).all); end; DMA_IRQ_Handler.Await_Event (Next_DMA_Interrupt); if Next_DMA_Interrupt /= Transfer_Complete_Interrupt then Panic; end if; Checksum_DMA := Value (CRC_Unit); Put_Line ("CRC:" & Checksum_DMA'Img); -- verify the two checksums are identical (one of which is already verified -- as the expected value) if Checksum_CPU = Checksum_DMA then Turn_On (Green_LED); else Turn_On (Red_LED); end if; loop delay until Time_Last; end loop; end Demo_CRC;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with GL.API; with GL.Enums.Textures; package body GL.Objects.Textures.Targets is function Buffer_Offset (Object : Texture_Buffer_Target; Level : Mipmap_Level) return Size is Ret : Size; begin API.Get_Tex_Level_Parameter_Size (Object.Kind, Level, Enums.Textures.Buffer_Offset, Ret); Raise_Exception_On_OpenGL_Error; return Ret; end Buffer_Offset; function Buffer_Size (Object : Texture_Buffer_Target; Level : Mipmap_Level) return Size is Ret : Size; begin API.Get_Tex_Level_Parameter_Size (Object.Kind, Level, Enums.Textures.Buffer_Size, Ret); Raise_Exception_On_OpenGL_Error; return Ret; end Buffer_Size; function Target_From_Kind (Kind : Low_Level.Enums.Texture_Kind) return not null access constant Texture_Proxy'Class is begin case Kind is when GL.Low_Level.Enums.Texture_1D => return Texture_1D'Access; when GL.Low_Level.Enums.Texture_2D => return Texture_2D'Access; when GL.Low_Level.Enums.Texture_3D => return Texture_3D'Access; when GL.Low_Level.Enums.Proxy_Texture_1D => return Texture_1D_Proxy'Access; when GL.Low_Level.Enums.Proxy_Texture_2D => return Texture_2D_Proxy'Access; when GL.Low_Level.Enums.Proxy_Texture_3D => return Texture_3D_Proxy'Access; when GL.Low_Level.Enums.Proxy_Texture_Cube_Map => return Texture_Cube_Map_Proxy'Access; when GL.Low_Level.Enums.Texture_Cube_Map => return Texture_Cube_Map'Access; when GL.Low_Level.Enums.Texture_Cube_Map_Positive_X => return Texture_Cube_Map_Positive_X'Access; when GL.Low_Level.Enums.Texture_Cube_Map_Negative_X => return Texture_Cube_Map_Negative_X'Access; when GL.Low_Level.Enums.Texture_Cube_Map_Positive_Y => return Texture_Cube_Map_Positive_Y'Access; when GL.Low_Level.Enums.Texture_Cube_Map_Negative_Y => return Texture_Cube_Map_Negative_Y'Access; when GL.Low_Level.Enums.Texture_Cube_Map_Positive_Z => return Texture_Cube_Map_Positive_Z'Access; when GL.Low_Level.Enums.Texture_Cube_Map_Negative_Z => return Texture_Cube_Map_Negative_Z'Access; when GL.Low_Level.Enums.Texture_1D_Array | GL.Low_Level.Enums.Texture_2D_Array | GL.Low_Level.Enums.Proxy_Texture_1D_Array | GL.Low_Level.Enums.Proxy_Texture_2D_Array => raise Not_Implemented_Exception with Kind'Img; when GL.Low_Level.Enums.Texture_Buffer => return Texture_Buffer'Access; end case; end Target_From_Kind; end GL.Objects.Textures.Targets;
with Interfaces; use Interfaces; with PX4IO.Driver; use PX4IO; with NVRAM; with Types; with Logger; package body Servo with SPARK_Mode is ------------ -- Types ------------ type Servo_Setting_Type is record left : Servo_Angle_Type := Servo_Angle_Type (0.0); right : Servo_Angle_Type := Servo_Angle_Type (0.0); end record; ------------- -- States ------------- Last_Critical : Servo_Setting_Type; ---------------- -- Initialize ---------------- procedure initialize is nleft, nright : Integer_8; function Sat_Cast_ServoAngle is new Units.Saturated_Cast (Servo_Angle_Type); begin -- load most recent critical angles NVRAM.Load (NVRAM.VAR_SERVO_LEFT, nleft); NVRAM.Load (NVRAM.VAR_SERVO_RIGHT, nright); -- init and move servos to given angle Last_Critical.left := Sat_Cast_ServoAngle (Float (Unit_Type (nleft) * Degree)); Last_Critical.right := Sat_Cast_ServoAngle (Float (Unit_Type (nright) * Degree)); Logger.log_console (Logger.DEBUG, "Servo restore: " & AImage (Last_Critical.left) & " / " & AImage (Last_Critical.right)); Driver.initialize (init_left => Last_Critical.left, init_right => Last_Critical.right); end initialize; ------------------------ -- Set_Angle ------------------------ procedure Set_Angle (which : Servo_Type; angle : Servo_Angle_Type) is begin case which is when LEFT_ELEVON => Driver.Set_Servo_Angle (Driver.LEFT_ELEVON, angle); when RIGHT_ELEVON => Driver.Set_Servo_Angle (Driver.RIGHT_ELEVON, angle); end case; end Set_Angle; ------------------------ -- Set_Critical_Angle ------------------------ procedure Set_Critical_Angle (which : Servo_Type; angle : Servo_Angle_Type) is begin Set_Angle (which, angle); -- backup to NVRAM, if it has changed case which is when LEFT_ELEVON => if angle /= Last_Critical.left then declare pos : constant Integer_8 := Types.Sat_Cast_Int8 (To_Degree (angle)); begin NVRAM.Store (NVRAM.VAR_SERVO_LEFT, pos); Last_Critical.left := angle; end; end if; when RIGHT_ELEVON => if angle /= Last_Critical.right then declare pos : constant Integer_8 := Types.Sat_Cast_Int8 (To_Degree (angle)); begin NVRAM.Store (NVRAM.VAR_SERVO_RIGHT, pos); Last_Critical.right := angle; end; end if; end case; end Set_Critical_Angle; -------------- -- activate -------------- procedure activate is begin -- arm PX4IO Driver.arm; end activate; ---------------- -- deactivate ---------------- procedure deactivate is begin -- arm PX4IO Driver.disarm; end deactivate; ----------- -- sync ----------- procedure sync is begin Driver.sync_Outputs; end sync; end Servo;
----------------------------------------------------------------------- -- util-serialize-tools -- Tools to Serialize objects in various formats -- Copyright (C) 2012, 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Beans.Objects.Maps; with Util.Serialize.IO.JSON; package Util.Serialize.Tools is -- Serialize the objects defined in the object map <b>Map</b> into the <b>Output</b> -- JSON stream. Use the <b>Name</b> as the name of the JSON object. procedure To_JSON (Output : in out Util.Serialize.IO.JSON.Output_Stream'Class; Name : in String; Map : in Util.Beans.Objects.Maps.Map); -- Deserializes the JSON content passed in <b>Content</b> and restore the object map -- with their values. The object map passed in <b>Map</b> can contain existing values. -- They will be overriden by the JSON values. procedure From_JSON (Content : in String; Map : in out Util.Beans.Objects.Maps.Map); -- Serialize the objects defined in the object map <b>Map</b> into an JSON stream. -- Returns the JSON string that contains a serialization of the object maps. function To_JSON (Map : in Util.Beans.Objects.Maps.Map) return String; -- Deserializes the XML content passed in <b>Content</b> and restore the object map -- with their values. -- Returns the object map that was restored. function From_JSON (Content : in String) return Util.Beans.Objects.Maps.Map; end Util.Serialize.Tools;
-- Generated from glut.h -- Date: Sun Apr 6 14:32:02 1997 -- -- Command line definitions: -- -D__ANSI_C__ -D_LANGUAGE_C -DGENERATING_ADA_BINDING -D__unix -D__sgi -- -D__mips -D__host_mips -D__EXTENSIONS__ -D__EDG -D__DSO__ -D__STDC__ -- -D_SYSTYPE_SVR4 -D_MODERN_C -D_MIPS_SZPTR=32 -D_MIPS_SZLONG=32 -- -D_MIPS_SZINT=32 -D_MIPS_SIM=_MIPS_SIM_ABI32 -- -D_MIPS_ISA=_MIPS_ISA_MIPS1 -D_MIPS_FPSET=16 -D_MIPSEB -- with Interfaces.C; with Interfaces.C.Extensions; with Interfaces.C.Strings; with GL; package Glut is -- Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. -- This program is freely distributable without licensing fees and is -- provided without guarantee or warrantee expressed or implied. This -- program is -not- in the public domain. * -- ** -- GLUT API revision history: -- -- GLUT_API_VERSION is updated to reflect incompatible GLUT -- API changes (interface changes, semantic changes, deletions, -- or additions). -- -- GLUT_API_VERSION=1 First public release of GLUT. 11/29/94 -- -- GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling, -- extension. Supports new input devices like tablet, dial and button -- box, and Spaceball. Easy to query OpenGL extensions. -- -- GLUT_API_VERSION=3 glutMenuStatus added. -- -- * GLUT_API_VERSION : constant := 4; -- VERSION 4 API NOT FINALIZED -- ** -- GLUT implementation revision history: -- -- GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT -- API revisions and implementation revisions (ie, bug fixes). -- -- GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of -- GLUT Xlib-based implementation. 11/29/94 -- -- GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of -- GLUT Xlib-based implementation providing GLUT version 2 -- interfaces. -- -- GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95 -- -- GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95 -- -- GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95 -- -- GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96 -- -- GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner -- and video resize. 1/3/97 -- * GLUT_XLIB_IMPLEMENTATION : constant := 7; -- Display mode bit masks. GLUT_RGB : constant := 0; GLUT_RGBA : constant := 0; GLUT_INDEX : constant := 1; GLUT_SINGLE : constant := 0; GLUT_DOUBLE : constant := 2; GLUT_ACCUM : constant := 4; GLUT_ALPHA : constant := 8; GLUT_DEPTH : constant := 16; GLUT_STENCIL : constant := 32; GLUT_MULTISAMPLE : constant := 128; GLUT_STEREO : constant := 256; GLUT_LUMINANCE : constant := 512; -- Mouse buttons. GLUT_LEFT_BUTTON : constant := 0; GLUT_MIDDLE_BUTTON : constant := 1; GLUT_RIGHT_BUTTON : constant := 2; -- Mouse button callback state. GLUT_DOWN : constant := 0; GLUT_UP : constant := 1; -- function keys GLUT_KEY_F1 : constant := 1; GLUT_KEY_F2 : constant := 2; GLUT_KEY_F3 : constant := 3; GLUT_KEY_F4 : constant := 4; GLUT_KEY_F5 : constant := 5; GLUT_KEY_F6 : constant := 6; GLUT_KEY_F7 : constant := 7; GLUT_KEY_F8 : constant := 8; GLUT_KEY_F9 : constant := 9; GLUT_KEY_F10 : constant := 10; GLUT_KEY_F11 : constant := 11; GLUT_KEY_F12 : constant := 12; -- directional keys GLUT_KEY_LEFT : constant := 100; GLUT_KEY_UP : constant := 101; GLUT_KEY_RIGHT : constant := 102; GLUT_KEY_DOWN : constant := 103; GLUT_KEY_PAGE_UP : constant := 104; GLUT_KEY_PAGE_DOWN : constant := 105; GLUT_KEY_HOME : constant := 106; GLUT_KEY_END : constant := 107; GLUT_KEY_INSERT : constant := 108; -- Entry/exit callback state. GLUT_LEFT : constant := 0; GLUT_ENTERED : constant := 1; -- Menu usage callback state. GLUT_MENU_NOT_IN_USE : constant := 0; GLUT_MENU_IN_USE : constant := 1; -- Visibility callback state. GLUT_NOT_VISIBLE : constant := 0; GLUT_VISIBLE : constant := 1; -- Window status callback state. GLUT_HIDDEN : constant := 0; GLUT_FULLY_RETAINED : constant := 1; GLUT_PARTIALLY_RETAINED : constant := 2; GLUT_FULLY_COVERED : constant := 3; -- Color index component selection values. GLUT_RED : constant := 0; GLUT_GREEN : constant := 1; GLUT_BLUE : constant := 2; -- Layers for use. GLUT_NORMAL : constant := 0; GLUT_OVERLAY : constant := 1; -- Stroke font opaque addresses (use constants instead in source code). glutStrokeRoman : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutStrokeRoman, "glutStrokeRoman", "glutStrokeRoman"); glutStrokeMonoRoman : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutStrokeMonoRoman, "glutStrokeMonoRoman", "glutStrokeMonoRoman"); -- Stroke font constants (use these in GLUT program). -- Bitmap font opaque addresses (use constants instead in source code). glutBitmap9By15 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmap9By15, "glutBitmap9By15", "glutBitmap9By15"); glutBitmap8By13 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmap8By13, "glutBitmap8By13", "glutBitmap8By13"); glutBitmapTimesRoman10 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmapTimesRoman10, "glutBitmapTimesRoman10", "glutBitmapTimesRoman10"); glutBitmapTimesRoman24 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmapTimesRoman24, "glutBitmapTimesRoman24", "glutBitmapTimesRoman24"); glutBitmapHelvetica10 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmapHelvetica10, "glutBitmapHelvetica10", "glutBitmapHelvetica10"); glutBitmapHelvetica12 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmapHelvetica12, "glutBitmapHelvetica12", "glutBitmapHelvetica12"); glutBitmapHelvetica18 : aliased Interfaces.C.Extensions.Void_Ptr; pragma Import (C, glutBitmapHelvetica18, "glutBitmapHelvetica18", "glutBitmapHelvetica18"); -- Bitmap font constants (use these in GLUT program). -- glutGet parameters. GLUT_WINDOW_X : constant := 100; GLUT_WINDOW_Y : constant := 101; GLUT_WINDOW_WIDTH : constant := 102; GLUT_WINDOW_HEIGHT : constant := 103; GLUT_WINDOW_BUFFER_SIZE : constant := 104; GLUT_WINDOW_STENCIL_SIZE : constant := 105; GLUT_WINDOW_DEPTH_SIZE : constant := 106; GLUT_WINDOW_RED_SIZE : constant := 107; GLUT_WINDOW_GREEN_SIZE : constant := 108; GLUT_WINDOW_BLUE_SIZE : constant := 109; GLUT_WINDOW_ALPHA_SIZE : constant := 110; GLUT_WINDOW_ACCUM_RED_SIZE : constant := 111; GLUT_WINDOW_ACCUM_GREEN_SIZE : constant := 112; GLUT_WINDOW_ACCUM_BLUE_SIZE : constant := 113; GLUT_WINDOW_ACCUM_ALPHA_SIZE : constant := 114; GLUT_WINDOW_DOUBLEBUFFER : constant := 115; GLUT_WINDOW_RGBA : constant := 116; GLUT_WINDOW_PARENT : constant := 117; GLUT_WINDOW_NUM_CHILDREN : constant := 118; GLUT_WINDOW_COLORMAP_SIZE : constant := 119; GLUT_WINDOW_NUM_SAMPLES : constant := 120; GLUT_WINDOW_STEREO : constant := 121; GLUT_WINDOW_CURSOR : constant := 122; GLUT_SCREEN_WIDTH : constant := 200; GLUT_SCREEN_HEIGHT : constant := 201; GLUT_SCREEN_WIDTH_MM : constant := 202; GLUT_SCREEN_HEIGHT_MM : constant := 203; GLUT_MENU_NUM_ITEMS : constant := 300; GLUT_DISPLAY_MODE_POSSIBLE : constant := 400; GLUT_INIT_WINDOW_X : constant := 500; GLUT_INIT_WINDOW_Y : constant := 501; GLUT_INIT_WINDOW_WIDTH : constant := 502; GLUT_INIT_WINDOW_HEIGHT : constant := 503; GLUT_INIT_DISPLAY_MODE : constant := 504; GLUT_ELAPSED_TIME : constant := 700; -- glutDeviceGet parameters. GLUT_HAS_KEYBOARD : constant := 600; GLUT_HAS_MOUSE : constant := 601; GLUT_HAS_SPACEBALL : constant := 602; GLUT_HAS_DIAL_AND_BUTTON_BOX : constant := 603; GLUT_HAS_TABLET : constant := 604; GLUT_NUM_MOUSE_BUTTONS : constant := 605; GLUT_NUM_SPACEBALL_BUTTONS : constant := 606; GLUT_NUM_BUTTON_BOX_BUTTONS : constant := 607; GLUT_NUM_DIALS : constant := 608; GLUT_NUM_TABLET_BUTTONS : constant := 609; -- glutLayerGet parameters. GLUT_OVERLAY_POSSIBLE : constant := 800; GLUT_LAYER_IN_USE : constant := 801; GLUT_HAS_OVERLAY : constant := 802; GLUT_TRANSPARENT_INDEX : constant := 803; GLUT_NORMAL_DAMAGED : constant := 804; GLUT_OVERLAY_DAMAGED : constant := 805; -- glutVideoResizeGet parameters. GLUT_VIDEO_RESIZE_POSSIBLE : constant := 900; GLUT_VIDEO_RESIZE_IN_USE : constant := 901; GLUT_VIDEO_RESIZE_X_DELTA : constant := 902; GLUT_VIDEO_RESIZE_Y_DELTA : constant := 903; GLUT_VIDEO_RESIZE_WIDTH_DELTA : constant := 904; GLUT_VIDEO_RESIZE_HEIGHT_DELTA : constant := 905; GLUT_VIDEO_RESIZE_X : constant := 906; GLUT_VIDEO_RESIZE_Y : constant := 907; GLUT_VIDEO_RESIZE_WIDTH : constant := 908; GLUT_VIDEO_RESIZE_HEIGHT : constant := 909; -- glutUseLayer parameters. -- glutGetModifiers return mask. GLUT_ACTIVE_SHIFT : constant := 1; GLUT_ACTIVE_CTRL : constant := 2; GLUT_ACTIVE_ALT : constant := 4; -- glutSetCursor parameters. -- Basic arrows. GLUT_CURSOR_RIGHT_ARROW : constant := 0; GLUT_CURSOR_LEFT_ARROW : constant := 1; -- Symbolic cursor shapes. GLUT_CURSOR_INFO : constant := 2; GLUT_CURSOR_DESTROY : constant := 3; GLUT_CURSOR_HELP : constant := 4; GLUT_CURSOR_CYCLE : constant := 5; GLUT_CURSOR_SPRAY : constant := 6; GLUT_CURSOR_WAIT : constant := 7; GLUT_CURSOR_TEXT : constant := 8; GLUT_CURSOR_CROSSHAIR : constant := 9; -- Directional cursors. GLUT_CURSOR_UP_DOWN : constant := 10; GLUT_CURSOR_LEFT_RIGHT : constant := 11; -- Sizing cursors. GLUT_CURSOR_TOP_SIDE : constant := 12; GLUT_CURSOR_BOTTOM_SIDE : constant := 13; GLUT_CURSOR_LEFT_SIDE : constant := 14; GLUT_CURSOR_RIGHT_SIDE : constant := 15; GLUT_CURSOR_TOP_LEFT_CORNER : constant := 16; GLUT_CURSOR_TOP_RIGHT_CORNER : constant := 17; GLUT_CURSOR_BOTTOM_RIGHT_CORNER : constant := 18; GLUT_CURSOR_BOTTOM_LEFT_CORNER : constant := 19; -- Inherit from parent window. GLUT_CURSOR_INHERIT : constant := 100; -- Blank cursor. GLUT_CURSOR_NONE : constant := 101; -- Fullscreen crosshair (if available). GLUT_CURSOR_FULL_CROSSHAIR : constant := 102; -- GLUT initialization sub-API. procedure glutInit (argcp : access Integer; argv : access Interfaces.C.Strings.Chars_Ptr); pragma Import (C, glutInit, "glutInit", "glutInit"); procedure glutInitDisplayMode (mode : Interfaces.C.unsigned); pragma Import (C, glutInitDisplayMode, "glutInitDisplayMode", "glutInitDisplayMode"); procedure glutInitDisplayString (string : Interfaces.C.Strings.Chars_Ptr); pragma Import (C, glutInitDisplayString, "glutInitDisplayString", "glutInitDisplayString"); procedure glutInitWindowPosition (x : Integer; y : Integer); pragma Import (C, glutInitWindowPosition, "glutInitWindowPosition", "glutInitWindowPosition"); procedure glutInitWindowSize (width : Integer; height : Integer); pragma Import (C, glutInitWindowSize, "glutInitWindowSize", "glutInitWindowSize"); procedure glutMainLoop; pragma Import (C, glutMainLoop, "glutMainLoop", "glutMainLoop"); -- GLUT window sub-API. function glutCreateWindow (title : Interfaces.C.Strings.Chars_Ptr) return Integer; pragma Import (C, glutCreateWindow, "glutCreateWindow", "glutCreateWindow"); function glutCreateWindow (title : String) return Integer; function glutCreateSubWindow (win : Integer; x : Integer; y : Integer; width : Integer; height : Integer) return Integer; pragma Import (C, glutCreateSubWindow, "glutCreateSubWindow", "glutCreateSubWindow"); procedure glutDestroyWindow (win : Integer); pragma Import (C, glutDestroyWindow, "glutDestroyWindow", "glutDestroyWindow"); procedure glutPostRedisplay; pragma Import (C, glutPostRedisplay, "glutPostRedisplay", "glutPostRedisplay"); procedure glutPostWindowRedisplay (win : Integer); pragma Import (C, glutPostWindowRedisplay, "glutPostWindowRedisplay", "glutPostWindowRedisplay"); procedure glutSwapBuffers; pragma Import (C, glutSwapBuffers, "glutSwapBuffers", "glutSwapBuffers"); function glutGetWindow return Integer; pragma Import (C, glutGetWindow, "glutGetWindow", "glutGetWindow"); procedure glutSetWindow (win : Integer); pragma Import (C, glutSetWindow, "glutSetWindow", "glutSetWindow"); procedure glutSetWindowTitle (title : Interfaces.C.Strings.Chars_Ptr); pragma Import (C, glutSetWindowTitle, "glutSetWindowTitle", "glutSetWindowTitle"); procedure glutSetWindowTitle (title : String); procedure glutSetIconTitle (title : Interfaces.C.Strings.Chars_Ptr); pragma Import (C, glutSetIconTitle, "glutSetIconTitle", "glutSetIconTitle"); procedure glutSetIconTitle (title : String); procedure glutPositionWindow (x : Integer; y : Integer); pragma Import (C, glutPositionWindow, "glutPositionWindow", "glutPositionWindow"); procedure glutReshapeWindow (width : Integer; height : Integer); pragma Import (C, glutReshapeWindow, "glutReshapeWindow", "glutReshapeWindow"); procedure glutPopWindow; pragma Import (C, glutPopWindow, "glutPopWindow", "glutPopWindow"); procedure glutPushWindow; pragma Import (C, glutPushWindow, "glutPushWindow", "glutPushWindow"); procedure glutIconifyWindow; pragma Import (C, glutIconifyWindow, "glutIconifyWindow", "glutIconifyWindow"); procedure glutShowWindow; pragma Import (C, glutShowWindow, "glutShowWindow", "glutShowWindow"); procedure glutHideWindow; pragma Import (C, glutHideWindow, "glutHideWindow", "glutHideWindow"); procedure glutFullScreen; pragma Import (C, glutFullScreen, "glutFullScreen", "glutFullScreen"); procedure glutSetCursor (cursor : Integer); pragma Import (C, glutSetCursor, "glutSetCursor", "glutSetCursor"); procedure glutWarpPointer (x : Integer; y : Integer); pragma Import (C, glutWarpPointer, "glutWarpPointer", "glutWarpPointer"); -- GLUT overlay sub-API. procedure glutEstablishOverlay; pragma Import (C, glutEstablishOverlay, "glutEstablishOverlay", "glutEstablishOverlay"); procedure glutRemoveOverlay; pragma Import (C, glutRemoveOverlay, "glutRemoveOverlay", "glutRemoveOverlay"); procedure glutUseLayer (layer : GL.GLenum); pragma Import (C, glutUseLayer, "glutUseLayer", "glutUseLayer"); procedure glutPostOverlayRedisplay; pragma Import (C, glutPostOverlayRedisplay, "glutPostOverlayRedisplay", "glutPostOverlayRedisplay"); procedure glutPostWindowOverlayRedisplay (win : Integer); pragma Import (C, glutPostWindowOverlayRedisplay, "glutPostWindowOverlayRedisplay", "glutPostWindowOverlayRedisplay"); procedure glutShowOverlay; pragma Import (C, glutShowOverlay, "glutShowOverlay", "glutShowOverlay"); procedure glutHideOverlay; pragma Import (C, glutHideOverlay, "glutHideOverlay", "glutHideOverlay"); -- GLUT menu sub-API. type Glut_proc_1 is access procedure (P1 : Integer); function glutCreateMenu (P1 : Glut_proc_1) return Integer; pragma Import (C, glutCreateMenu, "glutCreateMenu", "glutCreateMenu"); procedure glutDestroyMenu (menu : Integer); pragma Import (C, glutDestroyMenu, "glutDestroyMenu", "glutDestroyMenu"); function glutGetMenu return Integer; pragma Import (C, glutGetMenu, "glutGetMenu", "glutGetMenu"); procedure glutSetMenu (menu : Integer); pragma Import (C, glutSetMenu, "glutSetMenu", "glutSetMenu"); procedure glutAddMenuEntry (label : Interfaces.C.Strings.Chars_Ptr; value : Integer); pragma Import (C, glutAddMenuEntry, "glutAddMenuEntry", "glutAddMenuEntry"); procedure glutAddMenuEntry (label : String; value : Integer); procedure glutAddSubMenu (label : Interfaces.C.Strings.Chars_Ptr; submenu : Integer); pragma Import (C, glutAddSubMenu, "glutAddSubMenu", "glutAddSubMenu"); procedure glutAddSubMenu (label : String; submenu : Integer); procedure glutChangeToMenuEntry (item : Integer; label : Interfaces.C.Strings.Chars_Ptr; value : Integer); pragma Import (C, glutChangeToMenuEntry, "glutChangeToMenuEntry", "glutChangeToMenuEntry"); procedure glutChangeToMenuEntry (item : Integer; label : String; value : Integer); procedure glutChangeToSubMenu (item : Integer; label : Interfaces.C.Strings.Chars_Ptr; submenu : Integer); pragma Import (C, glutChangeToSubMenu, "glutChangeToSubMenu", "glutChangeToSubMenu"); procedure glutChangeToSubMenu (item : Integer; label : String; submenu : Integer); procedure glutRemoveMenuItem (item : Integer); pragma Import (C, glutRemoveMenuItem, "glutRemoveMenuItem", "glutRemoveMenuItem"); procedure glutAttachMenu (button : Integer); pragma Import (C, glutAttachMenu, "glutAttachMenu", "glutAttachMenu"); procedure glutDetachMenu (button : Integer); pragma Import (C, glutDetachMenu, "glutDetachMenu", "glutDetachMenu"); -- GLUT callback sub-API. type Glut_proc_2 is access procedure; procedure glutDisplayFunc (P1 : Glut_proc_2); pragma Import (C, glutDisplayFunc, "glutDisplayFunc", "glutDisplayFunc"); type Glut_proc_3 is access procedure (width : Integer; height : Integer); procedure glutReshapeFunc (P1 : Glut_proc_3); pragma Import (C, glutReshapeFunc, "glutReshapeFunc", "glutReshapeFunc"); type Glut_proc_4 is access procedure (key : Interfaces.C.unsigned_char; x : Integer; y : Integer); procedure glutKeyboardFunc (P1 : Glut_proc_4); pragma Import (C, glutKeyboardFunc, "glutKeyboardFunc", "glutKeyboardFunc"); type Glut_proc_5 is access procedure (button : Integer; state : Integer; x : Integer; y : Integer); procedure glutMouseFunc (P1 : Glut_proc_5); pragma Import (C, glutMouseFunc, "glutMouseFunc", "glutMouseFunc"); type Glut_proc_6 is access procedure (x : Integer; y : Integer); procedure glutMotionFunc (P1 : Glut_proc_6); pragma Import (C, glutMotionFunc, "glutMotionFunc", "glutMotionFunc"); type Glut_proc_7 is access procedure (x : Integer; y : Integer); procedure glutPassiveMotionFunc (P1 : Glut_proc_7); pragma Import (C, glutPassiveMotionFunc, "glutPassiveMotionFunc", "glutPassiveMotionFunc"); type Glut_proc_8 is access procedure (state : Integer); procedure glutEntryFunc (P1 : Glut_proc_8); pragma Import (C, glutEntryFunc, "glutEntryFunc", "glutEntryFunc"); type Glut_proc_9 is access procedure (state : Integer); procedure glutVisibilityFunc (P1 : Glut_proc_9); pragma Import (C, glutVisibilityFunc, "glutVisibilityFunc", "glutVisibilityFunc"); type Glut_proc_10 is access procedure; procedure glutIdleFunc (P1 : Glut_proc_10); pragma Import (C, glutIdleFunc, "glutIdleFunc", "glutIdleFunc"); type Glut_proc_11 is access procedure (value : Integer); procedure glutTimerFunc (millis : Interfaces.C.unsigned; P2 : Glut_proc_11; value : Integer); pragma Import (C, glutTimerFunc, "glutTimerFunc", "glutTimerFunc"); type Glut_proc_12 is access procedure (state : Integer); procedure glutMenuStateFunc (P1 : Glut_proc_12); pragma Import (C, glutMenuStateFunc, "glutMenuStateFunc", "glutMenuStateFunc"); type Glut_proc_13 is access procedure (key : Integer; x : Integer; y : Integer); procedure glutSpecialFunc (P1 : Glut_proc_13); pragma Import (C, glutSpecialFunc, "glutSpecialFunc", "glutSpecialFunc"); type Glut_proc_14 is access procedure (x : Integer; y : Integer; z : Integer); procedure glutSpaceballMotionFunc (P1 : Glut_proc_14); pragma Import (C, glutSpaceballMotionFunc, "glutSpaceballMotionFunc", "glutSpaceballMotionFunc"); type Glut_proc_15 is access procedure (x : Integer; y : Integer; z : Integer); procedure glutSpaceballRotateFunc (P1 : Glut_proc_15); pragma Import (C, glutSpaceballRotateFunc, "glutSpaceballRotateFunc", "glutSpaceballRotateFunc"); type Glut_proc_16 is access procedure (button : Integer; state : Integer); procedure glutSpaceballButtonFunc (P1 : Glut_proc_16); pragma Import (C, glutSpaceballButtonFunc, "glutSpaceballButtonFunc", "glutSpaceballButtonFunc"); type Glut_proc_17 is access procedure (button : Integer; state : Integer); procedure glutButtonBoxFunc (P1 : Glut_proc_17); pragma Import (C, glutButtonBoxFunc, "glutButtonBoxFunc", "glutButtonBoxFunc"); type Glut_proc_18 is access procedure (dial : Integer; value : Integer); procedure glutDialsFunc (P1 : Glut_proc_18); pragma Import (C, glutDialsFunc, "glutDialsFunc", "glutDialsFunc"); type Glut_proc_19 is access procedure (x : Integer; y : Integer); procedure glutTabletMotionFunc (P1 : Glut_proc_19); pragma Import (C, glutTabletMotionFunc, "glutTabletMotionFunc", "glutTabletMotionFunc"); type Glut_proc_20 is access procedure (button : Integer; state : Integer; x : Integer; y : Integer); procedure glutTabletButtonFunc (P1 : Glut_proc_20); pragma Import (C, glutTabletButtonFunc, "glutTabletButtonFunc", "glutTabletButtonFunc"); type Glut_proc_21 is access procedure (status : Integer; x : Integer; y : Integer); procedure glutMenuStatusFunc (P1 : Glut_proc_21); pragma Import (C, glutMenuStatusFunc, "glutMenuStatusFunc", "glutMenuStatusFunc"); type Glut_proc_22 is access procedure; procedure glutOverlayDisplayFunc (P1 : Glut_proc_22); pragma Import (C, glutOverlayDisplayFunc, "glutOverlayDisplayFunc", "glutOverlayDisplayFunc"); type Glut_proc_23 is access procedure (state : Integer); procedure glutWindowStatusFunc (P1 : Glut_proc_23); pragma Import (C, glutWindowStatusFunc, "glutWindowStatusFunc", "glutWindowStatusFunc"); -- GLUT color index sub-API. procedure glutSetColor (P1 : Integer; red : GL.GLfloat; green : GL.GLfloat; blue : GL.GLfloat); pragma Import (C, glutSetColor, "glutSetColor", "glutSetColor"); function glutGetColor (ndx : Integer; component : Integer) return GL.GLfloat; pragma Import (C, glutGetColor, "glutGetColor", "glutGetColor"); procedure glutCopyColormap (win : Integer); pragma Import (C, glutCopyColormap, "glutCopyColormap", "glutCopyColormap"); -- GLUT state retrieval sub-API. function glutGet (type_Id : GL.GLenum) return Integer; pragma Import (C, glutGet, "glutGet", "glutGet"); function glutDeviceGet (type_Id : GL.GLenum) return Integer; pragma Import (C, glutDeviceGet, "glutDeviceGet", "glutDeviceGet"); -- GLUT extension support sub-API function glutExtensionSupported (name : Interfaces.C.Strings.Chars_Ptr) return Integer; pragma Import (C, glutExtensionSupported, "glutExtensionSupported", "glutExtensionSupported"); function glutExtensionSupported (name : String) return Integer; function glutGetModifiers return Integer; pragma Import (C, glutGetModifiers, "glutGetModifiers", "glutGetModifiers"); function glutLayerGet (type_Id : GL.GLenum) return Integer; pragma Import (C, glutLayerGet, "glutLayerGet", "glutLayerGet"); -- GLUT font sub-API procedure glutBitmapCharacter (font : access Interfaces.C.Extensions.Void_Ptr; character : Integer); pragma Import (C, glutBitmapCharacter, "glutBitmapCharacter", "glutBitmapCharacter"); function glutBitmapWidth (font : access Interfaces.C.Extensions.Void_Ptr; character : Integer) return Integer; pragma Import (C, glutBitmapWidth, "glutBitmapWidth", "glutBitmapWidth"); procedure glutStrokeCharacter (font : access Interfaces.C.Extensions.Void_Ptr; character : Integer); pragma Import (C, glutStrokeCharacter, "glutStrokeCharacter", "glutStrokeCharacter"); function glutStrokeWidth (font : access Interfaces.C.Extensions.Void_Ptr; character : Integer) return Integer; pragma Import (C, glutStrokeWidth, "glutStrokeWidth", "glutStrokeWidth"); function glutStrokeLength (font : access Interfaces.C.Extensions.Void_Ptr; string : Interfaces.C.Strings.Chars_Ptr) return Integer; pragma Import (C, glutStrokeLength, "glutStrokeLength", "glutStrokeLength"); function glutBitmapLength (font : access Interfaces.C.Extensions.Void_Ptr; string : Interfaces.C.Strings.Chars_Ptr) return Integer; pragma Import (C, glutBitmapLength, "glutBitmapLength", "glutBitmapLength"); -- GLUT pre-built models sub-API procedure glutWireSphere (radius : GL.GLdouble; slices : GL.GLint; stacks : GL.GLint); pragma Import (C, glutWireSphere, "glutWireSphere", "glutWireSphere"); procedure glutSolidSphere (radius : GL.GLdouble; slices : GL.GLint; stacks : GL.GLint); pragma Import (C, glutSolidSphere, "glutSolidSphere", "glutSolidSphere"); procedure glutWireCone (base : GL.GLdouble; height : GL.GLdouble; slices : GL.GLint; stacks : GL.GLint); pragma Import (C, glutWireCone, "glutWireCone", "glutWireCone"); procedure glutSolidCone (base : GL.GLdouble; height : GL.GLdouble; slices : GL.GLint; stacks : GL.GLint); pragma Import (C, glutSolidCone, "glutSolidCone", "glutSolidCone"); procedure glutWireCube (size : GL.GLdouble); pragma Import (C, glutWireCube, "glutWireCube", "glutWireCube"); procedure glutSolidCube (size : GL.GLdouble); pragma Import (C, glutSolidCube, "glutSolidCube", "glutSolidCube"); procedure glutWireTorus (innerRadius : GL.GLdouble; outerRadius : GL.GLdouble; sides : GL.GLint; rings : GL.GLint); pragma Import (C, glutWireTorus, "glutWireTorus", "glutWireTorus"); procedure glutSolidTorus (innerRadius : GL.GLdouble; outerRadius : GL.GLdouble; sides : GL.GLint; rings : GL.GLint); pragma Import (C, glutSolidTorus, "glutSolidTorus", "glutSolidTorus"); procedure glutWireDodecahedron; pragma Import (C, glutWireDodecahedron, "glutWireDodecahedron", "glutWireDodecahedron"); procedure glutSolidDodecahedron; pragma Import (C, glutSolidDodecahedron, "glutSolidDodecahedron", "glutSolidDodecahedron"); procedure glutWireTeapot (size : GL.GLdouble); pragma Import (C, glutWireTeapot, "glutWireTeapot", "glutWireTeapot"); procedure glutSolidTeapot (size : GL.GLdouble); pragma Import (C, glutSolidTeapot, "glutSolidTeapot", "glutSolidTeapot"); procedure glutWireOctahedron; pragma Import (C, glutWireOctahedron, "glutWireOctahedron", "glutWireOctahedron"); procedure glutSolidOctahedron; pragma Import (C, glutSolidOctahedron, "glutSolidOctahedron", "glutSolidOctahedron"); procedure glutWireTetrahedron; pragma Import (C, glutWireTetrahedron, "glutWireTetrahedron", "glutWireTetrahedron"); procedure glutSolidTetrahedron; pragma Import (C, glutSolidTetrahedron, "glutSolidTetrahedron", "glutSolidTetrahedron"); procedure glutWireIcosahedron; pragma Import (C, glutWireIcosahedron, "glutWireIcosahedron", "glutWireIcosahedron"); procedure glutSolidIcosahedron; pragma Import (C, glutSolidIcosahedron, "glutSolidIcosahedron", "glutSolidIcosahedron"); function glutVideoResizeGet (param : GL.GLenum) return Integer; pragma Import (C, glutVideoResizeGet, "glutVideoResizeGet", "glutVideoResizeGet"); procedure glutSetupVideoResizing; pragma Import (C, glutSetupVideoResizing, "glutSetupVideoResizing", "glutSetupVideoResizing"); procedure glutStopVideoResizing; pragma Import (C, glutStopVideoResizing, "glutStopVideoResizing", "glutStopVideoResizing"); procedure glutVideoResize (x : Integer; y : Integer; width : Integer; height : Integer); pragma Import (C, glutVideoResize, "glutVideoResize", "glutVideoResize"); procedure glutVideoPan (x : Integer; y : Integer; width : Integer; height : Integer); pragma Import (C, glutVideoPan, "glutVideoPan", "glutVideoPan"); end Glut;
generic type Number is digits <>; function Multiply (A, B : Number) return Number;
-- -- Copyright (C) 2016 secunet Security Networks AG -- -- 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 2 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. -- package body HW.MMIO_Regs is generic type Word_T is mod <>; procedure Read_G (Value : out Word_T; Idx : Subs_P.Index_T); procedure Read_G (Value : out Word_T; Idx : Subs_P.Index_T) is Off : constant Range_P.Index_T := Range_P.Index_T ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)); pragma Warnings (GNAT, Off, """Mask"" is not modified, could be declared constant", Reason => "Ada RM forbids making it constant."); Mask : Word64 := Shift_Left (1, Regs (Idx).MSB + 1 - Regs (Idx).LSB) - 1; pragma Warnings (GNAT, On, """Mask"" is not modified, could be declared constant"); Temp : Range_P.Element_T; begin Range_P.Read (Temp, Off); Value := Word_T (Shift_Right (Word64 (Temp), Regs (Idx).LSB) and Mask); end Read_G; procedure Read_I is new Read_G (Word8); procedure Read (Value : out Word8; Idx : Subs_P.Index_T) renames Read_I; procedure Read_I is new Read_G (Word16); procedure Read (Value : out Word16; Idx : Subs_P.Index_T) renames Read_I; procedure Read_I is new Read_G (Word32); procedure Read (Value : out Word32; Idx : Subs_P.Index_T) renames Read_I; procedure Read_I is new Read_G (Word64); procedure Read (Value : out Word64; Idx : Subs_P.Index_T) renames Read_I; ---------------------------------------------------------------------------- generic type Word_T is mod <>; procedure Write_G (Idx : Subs_P.Index_T; Value : Word_T); procedure Write_G (Idx : Subs_P.Index_T; Value : Word_T) is Off : constant Range_P.Index_T := Range_P.Index_T ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)); pragma Warnings (GNAT, Off, """Mask"" is not modified, could be declared constant", Reason => "Ada RM forbids making it constant."); Mask : Word64 := Shift_Left (1, Regs (Idx).MSB + 1) - Shift_Left (1, Regs (Idx).LSB); pragma Warnings (GNAT, On, """Mask"" is not modified, could be declared constant"); Temp : Range_P.Element_T; begin if Regs (Idx).MSB - Regs (Idx).LSB + 1 = Range_P.Element_T'Size then Range_P.Write (Off, Range_P.Element_T (Value)); else -- read/modify/write Range_P.Read (Temp, Off); Temp := Range_P.Element_T ((Word64 (Temp) and not Mask) or (Shift_Left (Word64 (Value), Regs (Idx).LSB))); Range_P.Write (Off, Temp); end if; end Write_G; procedure Write_I is new Write_G (Word8); procedure Write (Idx : Subs_P.Index_T; Value : Word8) renames Write_I; procedure Write_I is new Write_G (Word16); procedure Write (Idx : Subs_P.Index_T; Value : Word16) renames Write_I; procedure Write_I is new Write_G (Word32); procedure Write (Idx : Subs_P.Index_T; Value : Word32) renames Write_I; procedure Write_I is new Write_G (Word64); procedure Write (Idx : Subs_P.Index_T; Value : Word64) renames Write_I; end HW.MMIO_Regs;
-- This package will provide declarations for devices -- and configuration routines on the Flip32cc3df4revo board with System; with STM32; use STM32; with STM32.Device; use STM32.Device; with STM32.GPIO; use STM32.GPIO; -- with STM32.USARTs; use STM32.USARTs; -- with STM32.Timers; use STM32.Timers; -- with STM32.PWM; use STM32.PWM; with Interfaces; use Interfaces; with Interfaces.C; with Ada.Strings.Bounded; -- with Ravenscar_Time; package cc3df4revo.Board is package ASB32 is new Ada.Strings.Bounded.Generic_Bounded_Length (Max => 32); -- -- Devices -- -- mpu -- usart (for s.bus) -- type SBUS_RXTX (USART_Ptr : not null access USART) is limited null record; -- SBUS1 : SBUS_RXTX (USART_Ptr => USART_1'Access); -- SBUS1 : USART renames USART_1; -- SBUS_TX : GPIO_Point renames PA9; -- SBUS_RX : GPIO_Point renames PA10; -- SBUS_AF : GPIO_Alternate_Function renames GPIO_AF_USART1_7; -- M1 : PWM_Modulator; -- -- Board initialization -- procedure Initialize; -- Doing receive procedure usb_receive (message : out ASB32.Bounded_String); -- Doing transmission procedure usb_transmit (message : String); private function ada_usbapi_rx (buffer : out Interfaces.C.char_array) return Interfaces.C.unsigned_short with Import => True, Convention => C, External_Name => "usbapi_rx"; procedure ada_usbapi_tx (buffer : System.Address; len : Interfaces.C.unsigned_short) with Import => True, Convention => C, External_Name => "usbapi_tx"; -- -- USB util -- function ada_usbapi_setup return Interfaces.C.int with Import => True, Convention => C, External_Name => "usbapi_setup"; -- -- Motor pins -- -- MOTOR_123_Timer : Timer renames Timer_2; -- MOTOR_4_Timer : Timer renames Timer_4; -- MOTOR_1 : GPIO_Point renames PB0; -- MOTOR_1_AF : GPIO_Alternate_Function renames GPIO_AF_TIM2_1; -- MOTOR_1_Channel : Timer_Channel renames Channel_2; -- MOTOR_2 : GPIO_Point renames PB1; -- MOTOR_2_AF : GPIO_Alternate_Function renames GPIO_AF_TIM2_1; -- MOTOR_2_Channel : Timer_Channel renames Channel_4; -- MOTOR_3 : GPIO_Point renames PA3; -- MOTOR_3_AF : GPIO_Alternate_Function renames GPIO_AF_TIM2_1; -- MOTOR_3_Channel : Timer_Channel renames Channel_1; -- MOTOR_4 : GPIO_Point renames PA2; -- MOTOR_4_AF : GPIO_Alternate_Function renames GPIO_AF_TIM4_2; -- MOTOR_4_Channel : Timer_Channel renames Channel_4; end cc3df4revo.Board;
-- { dg-do compile } package Pack2 is type Rec is record Ptr: access Character; Int :Integer; end record; type Table is array (1..2) of rec; pragma Pack (Table); end Pack2;
package body math_Pkg is procedure is_prime (to_check : IN integer; prime : out boolean) is begin Prime := True; if To_Check = 0 then Prime := False; elsif To_Check > 3 then for i in 2..ABS(to_check)/2 loop if abs(to_check) MOD i = 0 then Prime := false; exit; -- number to check is not prime, no further check end if; end loop; end if; end is_prime; end Math_Pkg;
----------------------------------------------------------------------- -- mat-memory-probes - Definition and Analysis of memory events -- Copyright (C) 2014, 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Log.Loggers; with MAT.Types; with MAT.Readers.Marshaller; with MAT.Memory; package body MAT.Memory.Probes is -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Memory.Probes"); M_SIZE : constant MAT.Events.Internal_Reference := 1; M_FRAME : constant MAT.Events.Internal_Reference := 2; M_ADDR : constant MAT.Events.Internal_Reference := 3; M_OLD_ADDR : constant MAT.Events.Internal_Reference := 4; M_THREAD : constant MAT.Events.Internal_Reference := 5; M_UNKNOWN : constant MAT.Events.Internal_Reference := 6; M_TIME : constant MAT.Events.Internal_Reference := 7; -- Defines the possible data kinds which are recognized by -- the memory unmarshaller. All others are ignored. SIZE_NAME : aliased constant String := "size"; FRAME_NAME : aliased constant String := "frame"; ADDR_NAME : aliased constant String := "pointer"; OLD_NAME : aliased constant String := "old-pointer"; THREAD_NAME : aliased constant String := "thread"; TIME_NAME : aliased constant String := "time"; Memory_Attributes : aliased constant MAT.Events.Attribute_Table := (1 => (Name => SIZE_NAME'Access, Size => 0, Kind => MAT.Events.T_SIZE_T, Ref => M_SIZE), 2 => (Name => FRAME_NAME'Access, Size => 0, Kind => MAT.Events.T_FRAME, Ref => M_FRAME), 3 => (Name => ADDR_NAME'Access, Size => 0, Kind => MAT.Events.T_POINTER, Ref => M_ADDR), 4 => (Name => OLD_NAME'Access, Size => 0, Kind => MAT.Events.T_POINTER, Ref => M_OLD_ADDR), 5 => (Name => THREAD_NAME'Access, Size => 0, Kind => MAT.Events.T_THREAD, Ref => M_THREAD), 6 => (Name => TIME_NAME'Access, Size => 0, Kind => MAT.Events.T_TIME, Ref => M_TIME)); procedure Unmarshall_Allocation (Msg : in out MAT.Readers.Message; Size : in out MAT.Types.Target_Size; Addr : in out MAT.Types.Target_Addr; Old_Addr : in out MAT.Types.Target_Addr; Defs : in MAT.Events.Attribute_Table); ---------------------- -- Register the reader to extract and analyze memory events. ---------------------- procedure Register (Into : in out MAT.Events.Probes.Probe_Manager_Type'Class; Probe : in Memory_Probe_Type_Access) is begin Into.Register_Probe (Probe.all'Access, "malloc", MAT.Events.MSG_MALLOC, Memory_Attributes'Access); Into.Register_Probe (Probe.all'Access, "free", MAT.Events.MSG_FREE, Memory_Attributes'Access); Into.Register_Probe (Probe.all'Access, "realloc", MAT.Events.MSG_REALLOC, Memory_Attributes'Access); end Register; ---------------------- -- Unmarshall from the message the memory slot information. -- The data is described by the Defs table. ---------------------- procedure Unmarshall_Allocation (Msg : in out MAT.Readers.Message_Type; Size : in out MAT.Types.Target_Size; Addr : in out MAT.Types.Target_Addr; Old_Addr : in out MAT.Types.Target_Addr; Defs : in MAT.Events.Attribute_Table) is begin for I in Defs'Range loop declare Def : MAT.Events.Attribute renames Defs (I); begin case Def.Ref is when M_SIZE => Size := MAT.Readers.Marshaller.Get_Target_Size (Msg, Def.Kind); when M_ADDR => Addr := MAT.Readers.Marshaller.Get_Target_Addr (Msg, Def.Kind); when M_OLD_ADDR => Old_Addr := MAT.Readers.Marshaller.Get_Target_Addr (Msg, Def.Kind); when M_UNKNOWN => MAT.Readers.Marshaller.Skip (Msg, Def.Size); when others => MAT.Readers.Marshaller.Skip (Msg, Def.Size); end case; end; end loop; end Unmarshall_Allocation; ---------------------- -- Extract the probe information from the message. ---------------------- overriding procedure Extract (Probe : in Memory_Probe_Type; Params : in MAT.Events.Const_Attribute_Table_Access; Msg : in out MAT.Readers.Message_Type; Event : in out MAT.Events.Target_Event_Type) is pragma Unreferenced (Probe); begin case Event.Index is when MAT.Events.MSG_MALLOC => Unmarshall_Allocation (Msg, Event.Size, Event.Addr, Event.Old_Addr, Params.all); when MAT.Events.MSG_FREE => Unmarshall_Allocation (Msg, Event.Size, Event.Addr, Event.Old_Addr, Params.all); when MAT.Events.MSG_REALLOC => Unmarshall_Allocation (Msg, Event.Size, Event.Addr, Event.Old_Addr, Params.all); when others => Log.Error ("Invalid event {0} for memory extract probe", MAT.Events.Probe_Index_Type'Image (Event.Index)); raise Program_Error; end case; end Extract; procedure Execute (Probe : in Memory_Probe_Type; Event : in out MAT.Events.Target_Event_Type) is Slot : Allocation; begin Slot.Size := Event.Size; Slot.Thread := Event.Thread; Slot.Time := Event.Time; Slot.Frame := Event.Frame; Slot.Event := Event.Id; case Event.Index is when MAT.Events.MSG_MALLOC => Probe.Data.Probe_Malloc (Event.Addr, Slot); when MAT.Events.MSG_FREE => Probe.Data.Probe_Free (Event.Addr, Slot, Event.Size, Event.Prev_Id); Probe.Update_Event (Event.Id, Event.Size, Event.Prev_Id); when MAT.Events.MSG_REALLOC => Probe.Data.Probe_Realloc (Event.Addr, Event.Old_Addr, Slot, Event.Old_Size, Event.Prev_Id); Probe.Update_Event (Event.Id, Event.Old_Size, Event.Prev_Id); when others => Log.Error ("Invalid event {0} for memory execute probe", MAT.Events.Probe_Index_Type'Image (Event.Index)); raise Program_Error; end case; end Execute; end MAT.Memory.Probes;
-- { dg-do run } with System; procedure Protected_Self_Ref1 is protected type P is procedure Foo; end P; protected body P is procedure Foo is Ptr : access P; -- here P denotes the type P T : Integer; A : System.Address; begin Ptr := P'Access; -- here P denotes the "this" instance of P T := P'Size; A := P'Address; end; end P; O : P; begin O.Foo; end Protected_Self_Ref1;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <contact@flyx.org> -- -- 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.API; with GL.Enums.Getter; package body GL.Blending is procedure Set_Blend_Func (Factors : Blend_Factors) is begin API.Blend_Func_Separate.Ref (Factors.Src_RGB, Factors.Dst_RGB, Factors.Src_Alpha, Factors.Dst_Alpha); end Set_Blend_Func; procedure Set_Blend_Func (Draw_Buffer : Buffers.Draw_Buffer_Index; Factors : Blend_Factors) is begin API.Blend_Func_Separate_I.Ref (Draw_Buffer, Factors.Src_RGB, Factors.Dst_RGB, Factors.Src_Alpha, Factors.Dst_Alpha); end Set_Blend_Func; function Blend_Func return Blend_Factors is Src_RGB, Src_Alpha : Blend_Factor := One; Dst_RGB, Dst_Alpha : Blend_Factor := Zero; begin API.Get_Blend_Factor.Ref (Enums.Getter.Blend_Src_RGB, Src_RGB); API.Get_Blend_Factor.Ref (Enums.Getter.Blend_Src_Alpha, Src_Alpha); API.Get_Blend_Factor.Ref (Enums.Getter.Blend_Dst_RGB, Dst_RGB); API.Get_Blend_Factor.Ref (Enums.Getter.Blend_Dst_Alpha, Dst_Alpha); return (Src_RGB, Dst_RGB, Src_Alpha, Dst_Alpha); end Blend_Func; procedure Set_Blend_Color (Value : Types.Colors.Color) is use Types.Colors; begin API.Blend_Color.Ref (Value (R), Value (G), Value (B), Value (A)); end Set_Blend_Color; function Blend_Color return Types.Colors.Color is Ret : Types.Colors.Color; begin API.Get_Color.Ref (Enums.Getter.Blend_Color, Ret); return Ret; end Blend_Color; procedure Set_Blend_Equation (Equations : Blend_Equations) is begin API.Blend_Equation_Separate.Ref (Equations.RGB, Equations.Alpha); end Set_Blend_Equation; procedure Set_Blend_Equation (Draw_Buffer : Buffers.Draw_Buffer_Index; Equations : Blend_Equations) is begin API.Blend_Equation_Separate_I.Ref (Draw_Buffer, Equations.RGB, Equations.Alpha); end Set_Blend_Equation; function Blend_Equation return Blend_Equations is RGB, Alpha : Equation := Equation'First; begin API.Get_Blend_Equation.Ref (Enums.Getter.Blend_Equation_RGB, RGB); API.Get_Blend_Equation.Ref (Enums.Getter.Blend_Equation_Alpha, Alpha); return (RGB, Alpha); end Blend_Equation; ----------------------------------------------------------------------------- procedure Set_Logic_Op_Mode (Value : Logic_Op) is begin API.Logic_Op.Ref (Value); end Set_Logic_Op_Mode; function Logic_Op_Mode return Logic_Op is Ret : Logic_Op := Logic_Op'First; begin API.Get_Logic_Op.Ref (Enums.Getter.Logic_Op_Mode, Ret); return Ret; end Logic_Op_Mode; end GL.Blending;
----------------------------------------------------------------------- -- hestia-network -- Hestia Network Manager -- Copyright (C) 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 System; with Interfaces; with Ada.Real_Time; with Net.Buffers; with Net.Interfaces.STM32; with Net.DHCP; with Net.NTP; with Net.DNS; package Hestia.Network is use type Interfaces.Unsigned_32; -- Reserve 32 network buffers. NET_BUFFER_SIZE : constant Interfaces.Unsigned_32 := Net.Buffers.NET_ALLOC_SIZE * 32; -- The Ethernet interface driver. Ifnet : aliased Net.Interfaces.STM32.STM32_Ifnet; -- Initialize and start the network stack. procedure Initialize; -- Do the network housekeeping and return the next deadline. procedure Process (Deadline : out Ada.Real_Time.Time); -- Get the NTP time reference. function Get_Time return Net.NTP.NTP_Reference; private -- The task that waits for packets. task Controller with Storage_Size => (16 * 1024), Priority => System.Default_Priority; type NTP_Client_Type is limited new Net.DNS.Query with record -- The TTL deadline for the resolved DNS entry. Ttl_Deadline : Ada.Real_Time.Time; -- The NTP client connection and port. Server : aliased Net.NTP.Client; Port : Net.Uint16 := Net.NTP.NTP_PORT; end record; -- Save the answer received from the DNS server. This operation is called for each answer -- found in the DNS response packet. The Index is incremented at each answer. For example -- a DNS server can return a CNAME_RR answer followed by an A_RR: the operation is called -- two times. -- -- This operation can be overriden to implement specific actions when an answer is received. overriding procedure Answer (Request : in out NTP_Client_Type; Status : in Net.DNS.Status_Type; Response : in Net.DNS.Response_Type; Index : in Natural); -- The DHCP client used by Hestia. Dhcp : aliased Net.DHCP.Client; -- NTP client based on the NTP server provided by DHCP option (or static). Time_Ntp : aliased NTP_Client_Type; end Hestia.Network;
with AUnit.Run; -- with AUnit.Reporter.Text; with AUnit.Reporter.XML; with Dl.Test_All_Suit; ----------------- -- Dl.Test_All -- ----------------- procedure Dl.Test_All is procedure Run is new AUnit.Run.Test_Runner (Dl.Test_All_Suit.Suite); -- Reporter : AUnit.Reporter.Text.Text_Reporter; Reporter : AUnit.Reporter.XML.XML_Reporter; begin Run (Reporter); end Dl.Test_All;
with AdaM.Factory; package body AdaM.component_Definition is -- Storage Pool -- record_Version : constant := 1; pool_Size : constant := 5_000; package Pool is new AdaM.Factory.Pools (".adam-store", "component_Definitions", pool_Size, record_Version, component_Definition.item, component_Definition.view); -- Forge -- procedure define (Self : in out Item; is_subtype_Indication : in Boolean) is begin if is_subtype_Indication then Self.subtype_Indication := AdaM.subtype_Indication.new_Indication; else Self.access_Definition := AdaM.access_Definition.new_Definition; end if; end define; procedure destruct (Self : in out Item) is begin null; end destruct; function new_Definition (is_subtype_Indication : in Boolean) return component_Definition.view is new_View : constant component_Definition.view := Pool.new_Item; begin define (component_Definition.item (new_View.all), is_subtype_Indication); return new_View; end new_Definition; procedure free (Self : in out component_Definition.view) is begin destruct (component_Definition.item (Self.all)); Pool.free (Self); end free; -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id is begin return Pool.to_Id (Self); end Id; overriding function Name (Self : in Item) return Identifier is begin return ""; end Name; procedure is_Aliased (Self : in out Item; Now : in Boolean := True) is begin Self.is_Aliased := Now; end is_Aliased; function is_Aliased (Self : in Item) return Boolean is begin return Self.is_Aliased; end is_Aliased; -- procedure subtype_Indication_is (Self : out Item; Now : in AdaM.subtype_Indication.view) -- is -- use type AdaM.access_Definition.view; -- begin -- if Self.access_Definition /= null -- then -- raise program_Error with "access_Definition is already set"; -- end if; -- -- Self.subtype_Indication := Now; -- end subtype_Indication_is; -- -- procedure access_Definition_is (Self : out Item; Now : in AdaM.access_Definition.view) -- is -- use type AdaM.subtype_Indication.view; -- begin -- if Self.subtype_Indication /= null -- then -- raise program_Error with "subtype_Indication is already set"; -- end if; -- -- Self.access_Definition := Now; -- end access_Definition_is; function is_subtype_Indication (Self : in Item) return Boolean is use type AdaM.subtype_Indication.view; begin return Self.subtype_Indication /= null; end is_subtype_Indication; function is_access_Definition (Self : in Item) return Boolean is use type AdaM.access_Definition.view; begin return Self.access_Definition /= null; end is_access_Definition; function subtype_Indication (Self : in Item) return AdaM.subtype_Indication.view is begin return Self.subtype_Indication; end subtype_Indication; function access_Definition (Self : in Item) return AdaM.access_Definition.view is begin return Self.access_Definition; end access_Definition; -- procedure Type_is (Self : in out Item; Now : in AdaM.a_Type.view) -- is -- begin -- Self.my_Type := Now; -- end Type_is; -- -- -- function my_Type (Self : in Item) return AdaM.a_Type.view -- is -- begin -- return Self.my_Type; -- end my_Type; -- -- -- function my_Type (Self : access Item) return access AdaM.a_Type.view -- is -- begin -- return Self.my_Type'Access; -- end my_Type; -- -- -- -- procedure Initialiser_is (Self : in out Item; Now : in String) -- is -- begin -- Self.Initialiser := +Now; -- end Initialiser_is; -- -- -- function Initialiser (Self : in Item) return String -- is -- begin -- return +Self.Initialiser; -- end Initialiser; -- overriding function to_Source (Self : in Item) return text_Vectors.Vector is the_Source : text_Vectors.Vector; begin return the_Source; end to_Source; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View) renames Pool.View_write; procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View) renames Pool.View_read; end AdaM.component_Definition;
with Ada.Text_IO; procedure Vignere_Cipher is subtype Letter is Character range 'A' .. 'Z'; subtype Lowercase is Character range 'a' .. 'z'; function "+"(X, Y: Letter) return Letter is begin return Character'Val( ( (Character'Pos(X)-Character'Pos('A')) + (Character'Pos(Y)-Character'Pos('A')) ) mod 26 + Character'Pos('A')); end; function Normalize(S: String) return String is -- removes all characters except for uppercase and lowercase letters -- replaces lowercase by uppercase letters Offset: Integer := Character'Pos('A') - Character'Pos('a'); begin if S="" then return ""; elsif S(S'First) in Letter then return S(S'First) & Normalize(S(S'First+1 .. S'Last)); elsif S(S'First) in Lowercase then return (Character'Val(Character'Pos(S(S'First)) + Offset) & Normalize(S(S'First+1 .. S'Last))); else return Normalize(S(S'First+1 .. S'Last)); end if; end Normalize; function Encrypt(Key: String; Text: String) return String is Ciphertext: String(Text'Range); begin for I in Text'Range loop Ciphertext(I) := Text(I) + Key(Key'First + ((I-Text'First) mod Key'Length)); end loop; return Ciphertext; end Encrypt; function Invert(Key: String) return String is Result: String(Key'Range); begin for I in Key'Range loop Result(I) := Character'Val( 26 - (Character'Pos(Key(I))-Character'Pos('A')) + Character'Pos('A') ); end loop; return Result; end Invert; use Ada.Text_IO; Input: String := Get_Line; Key: String := Normalize(Get_Line); Ciph: String := Encrypt(Key => Key, Text => Normalize(Input)); begin Put_Line("Input =" & Input); Put_Line("Key =" & Key); Put_Line("Ciphertext =" & Ciph); Put_Line("Decryption =" & Encrypt(Key => Invert(Key), Text => Ciph)); end Vignere_Cipher;
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- G N A T . B U B B L E _ S O R T _ A -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1994 NYU, All Rights Reserved -- -- -- -- The GNAT library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU Library General Public License as published by -- -- the Free Software Foundation; either version 2, or (at your option) any -- -- later version. The GNAT 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 -- -- Library General Public License for more details. You should have -- -- received a copy of the GNU Library General Public License along with -- -- the GNAT library; see the file COPYING.LIB. If not, write to the Free -- -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package provides a bubblesort routine that works with access to -- subprogram parameters, so that it can be used with different types with -- shared sorting code (see also Gnat.Bubble_Sort_G, the generic version) package Gnat.Bubble_Sort_A is pragma Preelaborate (Bubble_Sort_A); -- The data to be sorted is assumed to be indexed by integer values from -- 1 to N, where N is the number of items to be sorted. In addition, the -- index value zero is used for a temporary location used during the sort. type Move_Procedure is access procedure (From : Natural; To : Natural); -- A pointer to a procedure that moves the data item with index From to -- the data item with index To. An index value of zero is used for moves -- from and to the single temporary location used by the sort. type Lt_Function is access function (Op1, Op2 : Natural) return Boolean; -- A pointer to a function that compares two items and returns True if -- the item with index Op1 is less than the item with index Op2, and False -- if the Op2 item is greater than or equal to the Op1 item. procedure Sort (N : Positive; Move : Move_Procedure; Lt : Lt_Function); -- This procedures sorts items indexed from 1 to N into ascending order -- making calls to Lt to do required comparisons, and Move to move items -- around. Note that, as described above, both Move and Lt use a single -- temporary location with index value zero. This sort is not stable, -- i.e. the order of equal elements in the input is not preserved. end Gnat.Bubble_Sort_A;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . V A L _ L L U -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, 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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Unsigned_Types; use System.Unsigned_Types; with System.Val_Util; use System.Val_Util; package body System.Val_LLU is --------------------------------- -- Scan_Raw_Long_Long_Unsigned -- --------------------------------- function Scan_Raw_Long_Long_Unsigned (Str : String; Ptr : access Integer; Max : Integer) return Long_Long_Unsigned is P : Integer; -- Local copy of the pointer Uval : Long_Long_Unsigned; -- Accumulated unsigned integer result Expon : Integer; -- Exponent value Overflow : Boolean := False; -- Set True if overflow is detected at any point Base_Char : Character; -- Base character (# or :) in based case Base : Long_Long_Unsigned := 10; -- Base value (reset in based case) Digit : Long_Long_Unsigned; -- Digit value begin P := Ptr.all; Uval := Character'Pos (Str (P)) - Character'Pos ('0'); P := P + 1; -- Scan out digits of what is either the number or the base. -- In either case, we are definitely scanning out in base 10. declare Umax : constant := (Long_Long_Unsigned'Last - 9) / 10; -- Max value which cannot overflow on accumulating next digit Umax10 : constant := Long_Long_Unsigned'Last / 10; -- Numbers bigger than Umax10 overflow if multiplied by 10 begin -- Loop through decimal digits loop exit when P > Max; Digit := Character'Pos (Str (P)) - Character'Pos ('0'); -- Non-digit encountered if Digit > 9 then if Str (P) = '_' then Scan_Underscore (Str, P, Ptr, Max, False); else exit; end if; -- Accumulate result, checking for overflow else if Uval <= Umax then Uval := 10 * Uval + Digit; elsif Uval > Umax10 then Overflow := True; else Uval := 10 * Uval + Digit; if Uval < Umax10 then Overflow := True; end if; end if; P := P + 1; end if; end loop; end; Ptr.all := P; -- Deal with based case if P < Max and then (Str (P) = ':' or else Str (P) = '#') then Base_Char := Str (P); P := P + 1; Base := Uval; Uval := 0; -- Check base value. Overflow is set True if we find a bad base, or -- a digit that is out of range of the base. That way, we scan out -- the numeral that is still syntactically correct, though illegal. -- We use a safe base of 16 for this scan, to avoid zero divide. if Base not in 2 .. 16 then Overflow := True; Base := 16; end if; -- Scan out based integer declare Umax : constant Long_Long_Unsigned := (Long_Long_Unsigned'Last - Base + 1) / Base; -- Max value which cannot overflow on accumulating next digit UmaxB : constant Long_Long_Unsigned := Long_Long_Unsigned'Last / Base; -- Numbers bigger than UmaxB overflow if multiplied by base begin -- Loop to scan out based integer value loop -- We require a digit at this stage if Str (P) in '0' .. '9' then Digit := Character'Pos (Str (P)) - Character'Pos ('0'); elsif Str (P) in 'A' .. 'F' then Digit := Character'Pos (Str (P)) - (Character'Pos ('A') - 10); elsif Str (P) in 'a' .. 'f' then Digit := Character'Pos (Str (P)) - (Character'Pos ('a') - 10); -- If we don't have a digit, then this is not a based number -- after all, so we use the value we scanned out as the base -- (now in Base), and the pointer to the base character was -- already stored in Ptr.all. else Uval := Base; exit; end if; -- If digit is too large, just signal overflow and continue. -- The idea here is to keep scanning as long as the input is -- syntactically valid, even if we have detected overflow if Digit >= Base then Overflow := True; -- Here we accumulate the value, checking overflow elsif Uval <= Umax then Uval := Base * Uval + Digit; elsif Uval > UmaxB then Overflow := True; else Uval := Base * Uval + Digit; if Uval < UmaxB then Overflow := True; end if; end if; -- If at end of string with no base char, not a based number -- but we signal Constraint_Error and set the pointer past -- the end of the field, since this is what the ACVC tests -- seem to require, see CE3704N, line 204. P := P + 1; if P > Max then Ptr.all := P; raise Constraint_Error; end if; -- If terminating base character, we are done with loop if Str (P) = Base_Char then Ptr.all := P + 1; exit; -- Deal with underscore elsif Str (P) = '_' then Scan_Underscore (Str, P, Ptr, Max, True); end if; end loop; end; end if; -- Come here with scanned unsigned value in Uval. The only remaining -- required step is to deal with exponent if one is present. Expon := Scan_Exponent (Str, Ptr, Max); if Expon /= 0 and then Uval /= 0 then -- For non-zero value, scale by exponent value. No need to do this -- efficiently, since use of exponent in integer literals is rare, -- and in any case the exponent cannot be very large. declare UmaxB : constant Long_Long_Unsigned := Long_Long_Unsigned'Last / Base; -- Numbers bigger than UmaxB overflow if multiplied by base begin for J in 1 .. Expon loop if Uval > UmaxB then Overflow := True; exit; end if; Uval := Uval * Base; end loop; end; end if; -- Return result, dealing with sign and overflow if Overflow then raise Constraint_Error; else return Uval; end if; end Scan_Raw_Long_Long_Unsigned; ----------------------------- -- Scan_Long_Long_Unsigned -- ----------------------------- function Scan_Long_Long_Unsigned (Str : String; Ptr : access Integer; Max : Integer) return Long_Long_Unsigned is Start : Positive; -- Save location of first non-blank character begin Scan_Plus_Sign (Str, Ptr, Max, Start); if Str (Ptr.all) not in '0' .. '9' then Ptr.all := Start; raise Constraint_Error; end if; return Scan_Raw_Long_Long_Unsigned (Str, Ptr, Max); end Scan_Long_Long_Unsigned; ------------------------------ -- Value_Long_Long_Unsigned -- ------------------------------ function Value_Long_Long_Unsigned (Str : String) return Long_Long_Unsigned is V : Long_Long_Unsigned; P : aliased Integer := Str'First; begin V := Scan_Long_Long_Unsigned (Str, P'Access, Str'Last); Scan_Trailing_Blanks (Str, P); return V; end Value_Long_Long_Unsigned; end System.Val_LLU;
pragma Ada_2012; package body Tokenize.Private_Token_Lists with SPARK_Mode => On is ------------ -- Append -- ------------ procedure Append (List : in out Token_List; What : String) is begin if List.First_Free > List.Tokens'Last then raise Constraint_Error; end if; List.Tokens (List.First_Free) := To_Unbounded_String (What); List.First_Free := List.First_Free + 1; end Append; end Tokenize.Private_Token_Lists;
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with bits_types_h; package bits_types_clockid_t_h is -- Clock ID used in clock and timer functions. subtype clockid_t is bits_types_h.uu_clockid_t; -- /usr/include/bits/types/clockid_t.h:7 end bits_types_clockid_t_h;
generic type Character_Type is (<>); type String_Type is array(Positive range <>) of Character_Type; Max_Length: Positive; package Encodings.Utility.Generic_Sequence_Buffers is function Remaining_Length( Data: String_Type; Last: Natural ) return Natural is ( if Last >= Data'Last then 0 else Data'Last - Last ) with Pre => Last >= Data'First - 1, Post => Remaining_Length'Result in 0 .. Data'Length; type Sequence_Buffer is record Data: String_Type(1 .. Max_Length); First: Positive := 1; -- first position of buffered sequence Last: Natural := 0; -- last position of buffered sequence end record; function Is_Empty( Buffer: in Sequence_Buffer ) return Boolean is ( Buffer.Last < Buffer.First ); function Length( Buffer: in Sequence_Buffer ) return Natural is ( if Is_Empty(Buffer) then 0 else Buffer.Last - Buffer.First + 1 ) with Post => Length'Result in 0 .. Max_Length; procedure Write_Buffered( Buffer: in out Sequence_Buffer; Target: in out String_Type; Target_Last: in out Natural ); procedure Set_Buffer( Buffer: in out Sequence_Buffer; Source: in String_Type ) with Pre => Is_Empty(Buffer), Post => Length(Buffer) = Source'Length; procedure Write( Buffer: in out Sequence_Buffer; Source: in String_Type; Target: in out String_Type; Target_Last: in out Natural ) with Pre => Is_Empty(Buffer); end Encodings.Utility.Generic_Sequence_Buffers;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2014, Vadim Godunko <vgodunko@gmail.com> -- -- 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.Internals.Strings.Configuration; with Matreshka.Internals.Strings.Operations; with Matreshka.Internals.Unicode.Characters.Latin; with XML.SAX.Simple_Readers.Callbacks; with XML.SAX.Simple_Readers.Scanner.Tables; package body XML.SAX.Simple_Readers.Scanner.Actions is use Matreshka.Internals.Strings.Configuration; use Matreshka.Internals.Unicode; use Matreshka.Internals.Unicode.Characters.Latin; use Matreshka.Internals.Utf16; use Matreshka.Internals.XML; use Matreshka.Internals.XML.Entity_Tables; use Matreshka.Internals.XML.Symbol_Tables; procedure Resolve_Symbol (Self : in out Simple_Reader'Class; Trim_Left : Natural; Trim_Right : Natural; Trim_Whitespace : Boolean; Can_Be_Qname : Boolean; Not_Qname : Boolean; Error : out Boolean; Symbol : out Matreshka.Internals.XML.Symbol_Identifier); -- Converts name to symbol. Trim_Left, Trim_Right, Trim_Whitespace can be -- used to trim several characters from head of tail of matched substring, -- and to trim leading whitespaces. Not_Qname specify that resolved name -- is not a qualified name at all (it is enumeration element of attribute -- of non-NOTATION type). Can_Be_Qname specify that resolved name is -- qualified name when namespace processing is enabled. Subprogram sets -- Error when error is detected and Symbol when symbol is resolved. procedure Character_Reference_To_Code_Point (Self : in out Simple_Reader'Class; Hex : Boolean; Code : out Code_Point; Valid : out Boolean); -- Converts scanned character reference to code point. Reports errors to -- application is any and sets Valid to False. Otherwise sets Code to -- referenced code point and sets Valid to True. --------------------------------------- -- Character_Reference_To_Code_Point -- --------------------------------------- procedure Character_Reference_To_Code_Point (Self : in out Simple_Reader'Class; Hex : Boolean; Code : out Code_Point; Valid : out Boolean) is Zero_Fixup : constant := Digit_Zero; Upper_Fixup : constant := Latin_Capital_Letter_A - 16#0A#; Lower_Fixup : constant := Latin_Small_Letter_A - 16#0A#; FP : Utf16_String_Index := Self.Scanner_State.YY_Base_Position; LP : Utf16_String_Index := Self.Scanner_State.YY_Current_Position; Aux : Code_Unit_32 := 0; D : Code_Point; begin -- NOTE: Sequences of leading and trailing character always fixed: -- "&#" for decimal representation and "&#x" for hexadecimal -- representation for the leading sequence of characters and ";" for -- trailing; thus we can just add/subtract required number of code point -- positions instead of doing more expensive iteration with analysis of -- UTF-16 code units. -- -- Actual value has limited character set ([0-9] or [0-9a-fA-F]), all -- of characters is on BMP also, thus expensive decoding can be omitted -- also. if Hex then -- Trim three leading characters and trailing character. FP := FP + 3; LP := LP - 1; while FP < LP loop D := Code_Point (Self.Scanner_State.Data.Value (FP)); FP := FP + 1; if D in Latin_Capital_Letter_A .. Latin_Capital_Letter_F then Aux := (Aux * 16) + D - Upper_Fixup; elsif D in Latin_Small_Letter_A .. Latin_Small_Letter_F then Aux := (Aux * 16) + D - Lower_Fixup; else Aux := (Aux * 16) + D - Zero_Fixup; end if; -- Check whether collected code is inside range of Unicode code -- points. Then it is outside reset to maximum value and exit -- the loop. Error will be reported later in this subprogram. if Aux not in Code_Point then Aux := Code_Unit_32'Last; exit; end if; end loop; else -- Trim two leading characters and trailing character. FP := FP + 2; LP := LP - 1; while FP < LP loop D := Code_Point (Self.Scanner_State.Data.Value (FP)); FP := FP + 1; Aux := (Aux * 10) + D - Zero_Fixup; -- Check whether collected code is inside range of Unicode code -- points. Then it is outside reset to maximum value and exit -- the loop. Error will be reported later in this subprogram. if Aux not in Code_Point then Aux := Code_Unit_32'Last; exit; end if; end loop; end if; -- [XML1.0/1.1 4.1 WFC: Legal Character] -- -- "Characters referred to using character references MUST match the -- production for Char." -- -- Check whether character reference is resolved into valid character. case Self.Version is when XML_1_0 => -- [XML1.0 2.2 Characters] -- -- [2] Char ::= -- #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] -- | [#x10000-#x10FFFF] Valid := Aux = 16#0009# or Aux = 16#000A# or Aux = 16#000D# or Aux in 16#0020# .. 16#D7FF# or Aux in 16#E000# .. 16#FFFD# or Aux in 16#1_0000# .. 16#10_FFFF#; when XML_1_1 => -- [XML1.1 2.2 Characters] -- -- [2] Char ::= -- [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] Valid := Aux in 16#0001# .. 16#D7FF# or Aux in 16#E000# .. 16#FFFD# or Aux in 16#1_0000# .. 16#10_FFFF#; end case; if not Valid then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML 4.1 WFC: Legal Character] character reference refers to" & " invalid character")); Self.Error_Reported := True; else Code := Aux; end if; end Character_Reference_To_Code_Point; ---------------------------------------- -- On_Asterisk_In_Content_Declaration -- ---------------------------------------- function On_Asterisk_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token is begin if Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [47], [48], [51]] illegal whitespace before asterisk")); return Error; else return Token_Asterisk; end if; end On_Asterisk_In_Content_Declaration; ----------------------------------------------------- -- On_Attribute_Name_In_Attribute_List_Declaration -- ----------------------------------------------------- function On_Attribute_Name_In_Attribute_List_Declaration (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- [53] AttDef ::= S Name S AttType S DefaultDecl -- -- Checks whitespace before the attribute name is present. if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [53] AttDef]" & " no whitespace before attribute name")); return Error; end if; Self.Whitespace_Matched := False; Resolve_Symbol (Self, 0, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.ATTLIST_TYPE); return Token_Name; end if; end On_Attribute_Name_In_Attribute_List_Declaration; ----------------------- -- On_Attribute_Type -- ----------------------- function On_Attribute_Type (Self : in out Simple_Reader'Class; Type_Token : Token) return Token is begin -- Checks ithat whitespace before attribute type keyword is detected -- and report error when check fail. if not Self.Whitespace_Matched then -- XXX This is recoverable error. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("whitespace required before attribute type")); return Error; end if; Self.Whitespace_Matched := False; return Type_Token; end On_Attribute_Type; --------------------------------------- -- On_Attribute_Value_Character_Data -- --------------------------------------- procedure On_Attribute_Value_Character_Data (Self : in out Simple_Reader'Class) is Next : Utf16_String_Index := Self.Scanner_State.YY_Base_Position; Code : Code_Point; begin -- Allocates buffer of necessary size to avoid memory reallocation. It -- can be larger when needed if attribute value normalization is -- activated, but usually not too large. Matreshka.Internals.Strings.Mutate (Self.Character_Data, Self.Character_Data.Unused + Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position + 1); -- Two mostly equivalent paths are separated, because they are on the -- performance critical path. if Self.Normalize_Value then -- Normalization is required for attribute's value. while Next /= Self.Scanner_State.YY_Current_Position loop Unchecked_Next (Self.Scanner_State.Data.Value, Next, Code); -- It can be reasonable to implement this step of normalization -- on SIMD. if Code = Character_Tabulation or Code = Line_Feed or Code = Carriage_Return then Code := Space; end if; if Code = Space then if not Self.Space_Before then Unchecked_Store (Self.Character_Data.Value, Self.Character_Data.Unused, Code); Self.Character_Data.Length := Self.Character_Data.Length + 1; Self.Space_Before := True; end if; else Unchecked_Store (Self.Character_Data.Value, Self.Character_Data.Unused, Code); Self.Character_Data.Length := Self.Character_Data.Length + 1; Self.Space_Before := False; end if; end loop; else -- XXX Can be optimized by adding special operation Append_Slice. while Next /= Self.Scanner_State.YY_Current_Position loop Unchecked_Next (Self.Scanner_State.Data.Value, Next, Code); -- It can be reasonable to implement this step of normalization -- on SIMD. if Code = Character_Tabulation or Code = Line_Feed or Code = Carriage_Return then Code := Space; end if; Unchecked_Store (Self.Character_Data.Value, Self.Character_Data.Unused, Code); Self.Character_Data.Length := Self.Character_Data.Length + 1; end loop; end if; end On_Attribute_Value_Character_Data; ---------------------------------------- -- On_Attribute_Value_Close_Delimiter -- ---------------------------------------- function On_Attribute_Value_Close_Delimiter (Self : in out Simple_Reader'Class) return Boolean is -- NOTE: Attribute value delimiter can be ' or " and both are -- represented as single UTF-16 code unit, thus expensive UTF-16 -- decoding can be avoided. Delimiter : constant Matreshka.Internals.Unicode.Code_Point := Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Base_Position)); begin if Self.Scanner_State.Delimiter /= Delimiter then Matreshka.Internals.Strings.Operations.Unterminated_Append (Self.Character_Data, Delimiter); return False; else if Self.Normalize_Value and then Self.Space_Before then -- One space character is at the end of the prepared string, it -- must be removed from the result. Self.Character_Data.Length := Self.Character_Data.Length - 1; Self.Character_Data.Unused := Self.Character_Data.Unused - 1; end if; String_Handler.Fill_Null_Terminator (Self.Character_Data); Matreshka.Internals.Strings.Reference (Self.Character_Data); Set_String_Internal (Item => Self.YYLVal, String => Self.Character_Data, Is_Whitespace => False); Reset_Whitespace_Matched (Self); Pop_Start_Condition (Self); return True; end if; end On_Attribute_Value_Close_Delimiter; ------------------------------------------- -- On_Attribute_Value_In_XML_Declaration -- ------------------------------------------- function On_Attribute_Value_In_XML_Declaration (Self : in out Simple_Reader'Class) return Token is begin Set_String_Internal (Item => Self.YYLVal, String => YY_Text (Self, 1, 1), Is_Whitespace => False); Reset_Whitespace_Matched (Self); return Token_String_Segment; end On_Attribute_Value_In_XML_Declaration; --------------------------------------- -- On_Attribute_Value_Open_Delimiter -- --------------------------------------- function On_Attribute_Value_Open_Delimiter (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32) return Boolean is begin if not Self.Whitespace_Matched then -- XXX This is recoverable error. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("whitespace required before default value")); return False; end if; On_Attribute_Value_Open_Delimiter (Self, State); return True; end On_Attribute_Value_Open_Delimiter; --------------------------------------- -- On_Attribute_Value_Open_Delimiter -- --------------------------------------- procedure On_Attribute_Value_Open_Delimiter (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32) is begin -- NOTE: Attribute value delimiter can be ' or " and both are -- represented as single UTF-16 code unit, thus expensive UTF-16 -- decoding can be avoided. Self.Scanner_State.Delimiter := Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Base_Position)); Matreshka.Internals.Strings.Operations.Reset (Self.Character_Data); case Self.Version is when XML_1_0 => Push_And_Enter_Start_Condition (Self, State, Tables.ATTRIBUTE_VALUE_10); when XML_1_1 => Push_And_Enter_Start_Condition (Self, State, Tables.ATTRIBUTE_VALUE_11); end case; end On_Attribute_Value_Open_Delimiter; -------------- -- On_CDATA -- -------------- function On_CDATA (Self : in out Simple_Reader'Class) return Token is begin -- Segment of CDATA section (production [20]) optionally terminated by -- end of CDATA section mark (production [21]). if Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position >= 3 and then (Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 1)) = Greater_Than_Sign and Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 2)) = Right_Square_Bracket and Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 3)) = Right_Square_Bracket) then -- Character data ends with ']]>', move backward before end of CDATA -- section literal. End of CDATA section literal will be processed -- on next cycle. YY_Move_Backward (Self); YY_Move_Backward (Self); YY_Move_Backward (Self); end if; Matreshka.Internals.Strings.Operations.Copy_Slice (Self.Character_Data, Self.Scanner_State.Data, Self.Scanner_State.YY_Base_Position, Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position, Self.Scanner_State.YY_Current_Index - Self.Scanner_State.YY_Base_Index); Matreshka.Internals.Strings.Reference (Self.Character_Data); Set_String_Internal (Item => Self.YYLVal, String => Self.Character_Data, Is_Whitespace => False); return Token_String_Segment; end On_CDATA; ----------------------- -- On_Character_Data -- ----------------------- function On_Character_Data (Self : in out Simple_Reader'Class) return Token is C : constant Code_Point := Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 1)); begin if Self.Element_Names.Is_Empty then -- Document content not entered. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("Text may not appear after the root element")); Self.Error_Reported := True; return Error; end if; if C = Less_Than_Sign or C = Ampersand then -- Matched string end with '<' or '&' which is start character of -- tag or reference accordingly. YY_Move_Backward (Self); elsif C = Greater_Than_Sign and then Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position >= 3 and then (Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 2)) = Right_Square_Bracket and Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 3)) = Right_Square_Bracket) then -- Matched string ends with literal ']]>' which is invalid in -- character data. if Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position = 3 then -- Exactly ']]>' found. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[[14] CharData]" & " Text may not contain a literal ']]>' sequence")); Self.Error_Reported := True; return Error; else -- String ends with ']]>', move backward to report character data -- in this cycle and report error in next cycle. YY_Move_Backward (Self); YY_Move_Backward (Self); YY_Move_Backward (Self); end if; end if; Matreshka.Internals.Strings.Operations.Copy_Slice (Self.Character_Data, Self.Scanner_State.Data, Self.Scanner_State.YY_Base_Position, Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position, Self.Scanner_State.YY_Current_Index - Self.Scanner_State.YY_Base_Index); Matreshka.Internals.Strings.Reference (Self.Character_Data); Set_String_Internal (Item => Self.YYLVal, String => Self.Character_Data, Is_Whitespace => False); return Token_String_Segment; end On_Character_Data; ---------------------------- -- On_Character_Reference -- ---------------------------- function On_Character_Reference (Self : in out Simple_Reader'Class; Hex : Boolean) return Token is Code : Code_Point; Valid : Boolean; begin Character_Reference_To_Code_Point (Self, Hex, Code, Valid); if not Valid then return Error; end if; -- XXX Whitespace must be detected and reported in token. if not Matreshka.Internals.Strings.Can_Be_Reused (Self.Character_Buffer, 2) then -- Preallocated buffer can't be reused for some reason (most -- probably because application made copy of the previous character -- reference), so new buffer need to be preallocated. Requested -- size of the buffer is maximum number of UTF-16 code unit to -- store one Unicode code point. Matreshka.Internals.Strings.Dereference (Self.Character_Buffer); Self.Character_Buffer := Matreshka.Internals.Strings.Allocate (2); end if; Self.Character_Buffer.Unused := 0; Self.Character_Buffer.Length := 1; Matreshka.Internals.Utf16.Unchecked_Store (Self.Character_Buffer.Value, Self.Character_Buffer.Unused, Code); Matreshka.Internals.Strings.Reference (Self.Character_Buffer); Set_String_Internal (Item => Self.YYLVal, String => Self.Character_Buffer, Is_Whitespace => False); return Token_String_Segment; end On_Character_Reference; ----------------------------------------------- -- On_Character_Reference_In_Attribute_Value -- ----------------------------------------------- function On_Character_Reference_In_Attribute_Value (Self : in out Simple_Reader'Class; Hex : Boolean) return Boolean is Code : Code_Point; Valid : Boolean; begin Character_Reference_To_Code_Point (Self, Hex, Code, Valid); if not Valid then return False; end if; if Self.Normalize_Value then if Code = Space then if not Self.Space_Before then Matreshka.Internals.Strings.Operations.Unterminated_Append (Self.Character_Data, Code); Self.Space_Before := True; end if; else Matreshka.Internals.Strings.Operations.Unterminated_Append (Self.Character_Data, Code); Self.Space_Before := False; end if; else Matreshka.Internals.Strings.Operations.Unterminated_Append (Self.Character_Data, Code); end if; return True; end On_Character_Reference_In_Attribute_Value; ----------------------- -- On_Close_Of_CDATA -- ----------------------- function On_Close_Of_CDATA (Self : in out Simple_Reader'Class) return Token is begin Pop_Start_Condition (Self); return Token_CData_Close; end On_Close_Of_CDATA; ------------------------------------- -- On_Close_Of_Conditional_Section -- ------------------------------------- function On_Close_Of_Conditional_Section (Self : in out Simple_Reader'Class) return Token is begin if Self.Conditional_Depth = 0 then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("']]>' doesn't close conditional section")); return Error; end if; Self.Conditional_Depth := Self.Conditional_Depth - 1; if Self.Ignore_Depth /= 0 then Self.Ignore_Depth := Self.Ignore_Depth - 1; end if; if Self.Ignore_Depth /= 0 then case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.CONDITIONAL_IGNORE_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.CONDITIONAL_IGNORE_11); end case; else case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_11); end case; end if; return Token_Conditional_Close; end On_Close_Of_Conditional_Section; ----------------------------- -- On_Close_Of_Declaration -- ----------------------------- function On_Close_Of_Declaration (Self : in out Simple_Reader'Class) return Token is begin case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_11); end case; return Token_Close; end On_Close_Of_Declaration; ------------------------------------------- -- On_Close_Of_Document_Type_Declaration -- ------------------------------------------- function On_Close_Of_Document_Type_Declaration (Self : in out Simple_Reader'Class) return Boolean is Success : Boolean; pragma Unreferenced (Success); begin if Self.External_Subset_Entity /= No_Entity and Self.Validation.Load_DTD and not Self.External_Subset_Done then -- External subset is declared, need to be loaded and not processed, -- push it into the scanner stack to process before reporting of -- close of document type declaration. Self.External_Subset_Done := True; YY_Move_Backward (Self); Success := Scanner.Push_Entity (Self => Self, Entity => Self.External_Subset_Entity, In_Document_Type => True, In_Literal => False); -- XXX Error processing is not implemented. return False; else case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCUMENT_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.DOCUMENT_11); end case; return True; end if; end On_Close_Of_Document_Type_Declaration; ----------------------------------- -- On_Close_Of_Empty_Element_Tag -- ----------------------------------- function On_Close_Of_Empty_Element_Tag (Self : in out Simple_Reader'Class) return Token is begin case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCUMENT_10); when XML_1_1 => if Is_Internal_General_Entity (Self.Entities, Self.Scanner_State.Entity) then -- Character references are resolved when replacement text of -- internal general entity is constructed. In XML 1.1 character -- references can refer to restricted characters which is not -- valid in text, but valid in replacement text. Enter_Start_Condition (Self, Tables.DOCUMENT_U11); else Enter_Start_Condition (Self, Tables.DOCUMENT_11); end if; end case; return Token_Empty_Close; end On_Close_Of_Empty_Element_Tag; ---------------------------------------- -- On_Close_Of_Processing_Instruction -- ---------------------------------------- function On_Close_Of_Processing_Instruction (Self : in out Simple_Reader'Class; Is_Empty : Boolean) return Token is begin if Is_Empty then Set_String_Internal (Item => Self.YYLVal, String => Matreshka.Internals.Strings.Shared_Empty'Access, Is_Whitespace => False); else if not Self.Whitespace_Matched then raise Program_Error with "no whitespace before processing instruction data"; -- XXX This is recoverable error. end if; Set_String_Internal (Item => Self.YYLVal, String => YY_Text (Self, 0, 2), Is_Whitespace => False); end if; Pop_Start_Condition (Self); return Token_Pi_Close; end On_Close_Of_Processing_Instruction; --------------------- -- On_Close_Of_Tag -- --------------------- function On_Close_Of_Tag (Self : in out Simple_Reader'Class) return Token is begin case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCUMENT_10); when XML_1_1 => if Is_Internal_General_Entity (Self.Entities, Self.Scanner_State.Entity) then -- Character references are resolved when replacement text of -- internal general entity is constructed. In XML 1.1 character -- references can refer to restricted characters which is not -- valid in text, but valid in replacement text. Enter_Start_Condition (Self, Tables.DOCUMENT_U11); else Enter_Start_Condition (Self, Tables.DOCUMENT_11); end if; end case; return Token_Close; end On_Close_Of_Tag; ----------------------------------------- -- On_Close_Of_XML_Or_Text_Declaration -- ----------------------------------------- function On_Close_Of_XML_Or_Text_Declaration (Self : in out Simple_Reader'Class) return Token is begin Set_String_Internal (Item => Self.YYLVal, String => Matreshka.Internals.Strings.Shared_Empty'Access, Is_Whitespace => False); if Self.Scanner_State.Entity /= No_Entity then -- End of text declaration of the external entity is reached, -- save current position to start from it next time entity is -- referenced. Set_First_Position (Self.Entities, Self.Scanner_State.Entity, Self.Scanner_State.YY_Current_Position); end if; Pop_Start_Condition (Self); return Token_Pi_Close; end On_Close_Of_XML_Or_Text_Declaration; ------------------------------------------------- -- On_Close_Parenthesis_In_Content_Declaration -- ------------------------------------------------- function On_Close_Parenthesis_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token is begin -- Whitespace can't be present between close parenthesis and -- multiplicity indicator if any, so reset whitespace matching flag. Self.Whitespace_Matched := False; return Token_Close_Parenthesis; end On_Close_Parenthesis_In_Content_Declaration; ------------------------------------------------ -- On_Close_Parenthesis_In_Notation_Attribute -- ------------------------------------------------ function On_Close_Parenthesis_In_Notation_Attribute (Self : in out Simple_Reader'Class) return Token is begin -- Resets whitespace matching flag. Self.Whitespace_Matched := False; return Token_Close_Parenthesis; end On_Close_Parenthesis_In_Notation_Attribute; -------------------------------------- -- On_Conditional_Section_Directive -- -------------------------------------- procedure On_Conditional_Section_Directive (Self : in out Simple_Reader'Class; Include : Boolean) is begin -- XXX Syntax check must be added! Self.Conditional_Directive := True; Self.Conditional_Depth := Self.Conditional_Depth + 1; if Self.Ignore_Depth /= 0 or not Include then Self.Ignore_Depth := Self.Ignore_Depth + 1; end if; end On_Conditional_Section_Directive; ---------------------------------------------- -- On_Content_Of_Ignore_Conditional_Section -- ---------------------------------------------- procedure On_Content_Of_Ignore_Conditional_Section (Self : in out Simple_Reader'Class) is begin YY_Move_Backward (Self); YY_Move_Backward (Self); YY_Move_Backward (Self); end On_Content_Of_Ignore_Conditional_Section; ---------------------------- -- On_Default_Declaration -- ---------------------------- function On_Default_Declaration (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32; Default_Token : Token) return Token is begin -- Checks ithat whitespace before attribute type keyword is detected -- and report error when check fail. if not Self.Whitespace_Matched then -- XXX This is recoverable error. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("whitespace required before default declaration")); return Error; end if; Self.Whitespace_Matched := False; Enter_Start_Condition (Self, State); return Default_Token; end On_Default_Declaration; --------------------------------------------------- -- On_Element_Name_In_Attribute_List_Declaration -- --------------------------------------------------- function On_Element_Name_In_Attribute_List_Declaration (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- [XML [52]] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>' -- -- Checks whitespace before the element name is present. if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [52] AttlistDecl]" & " no whitespace before element's name")); return Error; end if; Self.Whitespace_Matched := False; Resolve_Symbol (Self, 0, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.ATTLIST_DECL); return Token_Name; end if; end On_Element_Name_In_Attribute_List_Declaration; ------------------------- -- On_Encoding_Keyword -- ------------------------- function On_Encoding_Keyword (Self : in out Simple_Reader'Class) return Token is begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("no whitespace before 'encoding'")); Self.Error_Reported := True; -- XXX This is recoverable error. return Error; else return Token_Encoding; end if; end On_Encoding_Keyword; ------------------------------------- -- On_Entity_Value_Close_Delimiter -- ------------------------------------- function On_Entity_Value_Close_Delimiter (Self : in out Simple_Reader'Class) return Token is -- NOTE: Entity value delimiter can be ' or " and both are -- represented as single UTF-16 code unit, thus expensive UTF-16 -- decoding can be avoided. Delimiter : constant Matreshka.Internals.Unicode.Code_Point := Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Base_Position)); begin if Self.Scanner_State.In_Literal or else Self.Scanner_State.Delimiter /= Delimiter then Set_String_Internal (Item => Self.YYLVal, String => YY_Text (Self), Is_Whitespace => False); return Token_String_Segment; else Enter_Start_Condition (Self, Tables.ENTITY_DEF); return Token_Value_Close; end if; end On_Entity_Value_Close_Delimiter; ------------------------------------ -- On_Entity_Value_Open_Delimiter -- ------------------------------------ function On_Entity_Value_Open_Delimiter (Self : in out Simple_Reader'Class) return Token is begin -- NOTE: Entity value delimiter can be ' or " and both are -- represented as single UTF-16 code unit, thus expensive UTF-16 -- decoding can be avoided. Self.Scanner_State.Delimiter := Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Base_Position)); if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[[71] GEDecl, [72] PEDecl]" & " no whitespace before entity value")); return Error; end if; Self.Whitespace_Matched := False; case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.ENTITY_VALUE_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.ENTITY_VALUE_11); end case; return Token_Value_Open; end On_Entity_Value_Open_Delimiter; ---------------------------------------------------- -- On_General_Entity_Reference_In_Attribute_Value -- ---------------------------------------------------- function On_General_Entity_Reference_In_Attribute_Value (Self : in out Simple_Reader'Class) return Boolean is Qualified_Name : Symbol_Identifier; Qname_Error : Boolean; Entity : Entity_Identifier; State : Scanner_State_Information; begin Resolve_Symbol (Self, 1, 1, False, False, False, Qname_Error, Qualified_Name); if Qname_Error then return False; end if; Entity := General_Entity (Self.Symbols, Qualified_Name); -- [XML1.1 4.1 WFC: Entity Declared] -- -- "In a document without any DTD, a document with only an internal -- DTD subset which contains no parameter entity references, or a -- document with "standalone='yes'", for an entity reference that -- does not occur within the external subset or a parameter entity, -- the Name given in the entity reference MUST match that in an -- entity declaration that does not occur within the external subset -- or a parameter entity, except that well-formed documents need not -- declare any of the following entities: amp, lt, gt, apos, quot. -- The declaration of a general entity MUST precede any reference -- to it which appears in a default value in an attribute-list -- declaration. -- -- Note that non-validating processors are not obligated to to read -- and process entity declarations occurring in parameter entities -- or in the external subset; for such documents, the rule that an -- entity must be declared is a well-formedness constraint only if -- standalone='yes'." -- -- Check whether entity is declared. -- -- XXX This is probably too strong check, need to be arranged with -- standalone documents and validation. if Entity = No_Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: Entity Declared]" & " general entity must be declared")); return False; elsif Enclosing_Entity (Self.Entities, Entity) = No_Entity then -- All predefined entities doesn't have enclosing entity. null; elsif Self.Is_Standalone and not Is_Parameter_Entity (Self.Entities, Self.Scanner_State.Entity) and not Is_External_Subset (Self.Entities, Self.Scanner_State.Entity) and not Is_Document_Entity (Self.Entities, Enclosing_Entity (Self.Entities, Entity)) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: Entity Declared]" & " general entity must not be declared externally")); return False; end if; -- [XML1.1 4.1 WFC: Parsed Entity] -- -- "An entity reference MUST NOT contain the name of an unparsed -- entity. Unparsed entities may be referred to only in attribute -- values declared to be of type ENTITY or ENTITIES." -- -- Check whether referenced entity is not unparsed external general -- entity. XXX Attribute's value type must be checked also. if Is_External_Unparsed_General_Entity (Self.Entities, Entity) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: Parsed Entity]" & " an entity reference must not contain the name of an" & " unparsed entity")); return False; end if; -- [XML1.1 3.1 WFC: No External Entity References] -- -- "Attribute values MUST NOT contain direct or indirect entity -- references to external entities." -- -- Check whether referenced entity is not parsed external general -- entity. if Is_External_Parsed_General_Entity (Self.Entities, Entity) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 3.1 WFC: No External Entity References]" & " attribute value must not contain entity reference to" & " external entity")); return False; end if; -- [XML1.1 4.1 WFC: No Recursion] -- -- "A parsed entity MUST NOT contain a recursive reference to itself, -- either directly or indirectly." -- -- Check whether there is no replacement text of the same entity in the -- scanner stack. if Self.Scanner_State.Entity = Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: No Recursion]" & " parsed entity must not containt a direct recursive" & " reference to itself")); return False; end if; for J in 1 .. Integer (Self.Scanner_Stack.Length) loop State := Self.Scanner_Stack.Element (J); if State.Entity = Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: No Recursion]" & " parsed entity must not containt a indirect recursive" & " reference to itself")); return False; end if; end loop; return Push_Entity (Self => Self, Entity => Entity, In_Document_Type => False, In_Literal => True); end On_General_Entity_Reference_In_Attribute_Value; ----------------------------------------------------- -- On_General_Entity_Reference_In_Document_Content -- ----------------------------------------------------- function On_General_Entity_Reference_In_Document_Content (Self : in out Simple_Reader'Class) return Token is Qualified_Name : Symbol_Identifier; Qname_Error : Boolean; Entity : Entity_Identifier; State : Scanner_State_Information; Deep : Natural; begin Resolve_Symbol (Self, 1, 1, False, False, False, Qname_Error, Qualified_Name); if Qname_Error then return Error; end if; -- [1] document ::= -- ( prolog element Misc* ) - ( Char* RestrictedChar Char* ) -- -- [39] element ::= EmptyElemTag | STag content ETag -- -- [43] content ::= -- CharData? -- ((element | Reference | CDSect | PI | Comment) CharData?)* -- -- Check that entity is referenced inside element content. if Self.Element_Names.Is_Empty then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("entity reference must be in content of element")); return Error; end if; Entity := General_Entity (Self.Symbols, Qualified_Name); -- [XML1.1 4.1 WFC: Entity Declared] -- -- "In a document without any DTD, a document with only an internal -- DTD subset which contains no parameter entity references, or a -- document with "standalone='yes'", for an entity reference that -- does not occur within the external subset or a parameter entity, -- the Name given in the entity reference MUST match that in an -- entity declaration that does not occur within the external subset -- or a parameter entity, except that well-formed documents need not -- declare any of the following entities: amp, lt, gt, apos, quot. -- The declaration of a general entity MUST precede any reference -- to it which appears in a default value in an attribute-list -- declaration. -- -- Note that non-validating processors are not obligated to to read -- and process entity declarations occurring in parameter entities -- or in the external subset; for such documents, the rule that an -- entity must be declared is a well-formedness constraint only if -- standalone='yes'." -- -- Check whether entity is declared. -- -- XXX This is probably too strong check, need to be arranged with -- standalone documents and validation. if Entity = No_Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: Entity Declared]" & " general entity must be declared")); return Error; elsif Enclosing_Entity (Self.Entities, Entity) = No_Entity then -- All predefined entities doesn't have enclosing entity. null; elsif Self.Is_Standalone and not Is_Parameter_Entity (Self.Entities, Self.Scanner_State.Entity) and not Is_External_Subset (Self.Entities, Self.Scanner_State.Entity) and not Is_Document_Entity (Self.Entities, Enclosing_Entity (Self.Entities, Entity)) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: Entity Declared]" & " general entity must not be declared externally")); return Error; end if; -- [XML1.1 4.1 WFC: Parsed Entity] -- -- "An entity reference MUST NOT contain the name of an unparsed -- entity. Unparsed entities may be referred to only in attribute -- values declared to be of type ENTITY or ENTITIES." -- -- Check whether referenced entity is not unparsed external general -- entity. if Is_External_Unparsed_General_Entity (Self.Entities, Entity) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: Parsed Entity]" & " an entity reference must not contain the name of an" & " unparsed entity")); return Error; end if; -- [XML1.1 4.1 WFC: No Recursion] -- -- "A parsed entity MUST NOT contain a recursive reference to itself, -- either directly or indirectly." -- -- Check whether there is no replacement text of the same entity in the -- scanner stack. if Self.Scanner_State.Entity = Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: No Recursion]" & " parsed entity must not containt a direct recursive" & " reference to itself")); return Error; end if; for J in 1 .. Integer (Self.Scanner_Stack.Length) loop State := Self.Scanner_Stack.Element (J); if State.Entity = Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.1 WFC: No Recursion]" & " parsed entity must not containt a indirect recursive" & " reference to itself")); return Error; end if; end loop; Deep := Integer (Self.Scanner_Stack.Length); if not Push_Entity (Self => Self, Entity => Entity, In_Document_Type => False, In_Literal => False) then return Error; elsif Deep = Integer (Self.Scanner_Stack.Length) then -- Entity doesn't pushed in stack because its replacement text -- is empty. return End_Of_Input; else Self.Scanner_State.Start_Issued := True; return Token_Entity_Start; end if; end On_General_Entity_Reference_In_Document_Content; ------------------------------------------------- -- On_General_Entity_Reference_In_Entity_Value -- ------------------------------------------------- function On_General_Entity_Reference_In_Entity_Value (Self : in out Simple_Reader'Class) return Token is Qualified_Name : Symbol_Identifier; Qname_Error : Boolean; begin Resolve_Symbol (Self, 1, 1, False, False, False, Qname_Error, Qualified_Name); if Qname_Error then return Error; else Set_String_Internal (Item => Self.YYLVal, String => YY_Text (Self), Is_Whitespace => False); return Token_String_Segment; end if; end On_General_Entity_Reference_In_Entity_Value; ------------------------------------------ -- On_Less_Than_Sign_In_Attribute_Value -- ------------------------------------------ function On_Less_Than_Sign_In_Attribute_Value (Self : in out Simple_Reader'Class) return Token is begin -- [3.1 WFC: No < in Attribute Values] -- -- "The replacement text of any entity referred to directly or -- indirectly in an attribute value MUST NOT contain a <." Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[3.1 WFC: No < in Attribute Values]" & " '<' can't be used in attribute value")); Self.Error_Reported := True; return Error; end On_Less_Than_Sign_In_Attribute_Value; ---------------------------------------------------- -- On_Name_In_Attribute_List_Declaration_Notation -- ---------------------------------------------------- function On_Name_In_Attribute_List_Declaration_Notation (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- [XMLNS 7] -- -- "It follows that in a namespace-well-formed document: -- -- - All element and attribute names contain either zero or one colon; -- -- - No entity names, processing instruction targets, or notation -- names contain any colons." -- -- This code is used to handle names in both NOTATION and enumeration -- attribute declarations, thus it must distinguish colon handling. Resolve_Symbol (Self, 0, 0, False, True, not Self.Notation_Attribute, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else return Token_Name; end if; end On_Name_In_Attribute_List_Declaration_Notation; ------------------------------------ -- On_Name_In_Element_Declaration -- ------------------------------------ function On_Name_In_Element_Declaration (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- Production [45] requires whitespace after name and before content -- specification, so whitespace indicator is reset here. Self.Whitespace_Matched := False; Resolve_Symbol (Self, 0, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.ELEMENT_DECL); return Token_Name; end if; end On_Name_In_Element_Declaration; --------------------------------------------- -- On_Name_In_Element_Declaration_Children -- --------------------------------------------- function On_Name_In_Element_Declaration_Children (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- Production [48] checks that no whitespace separates Name from -- following multiplicity indicator, so whitespace indicator must be -- reset here. Self.Whitespace_Matched := False; Resolve_Symbol (Self, 0, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else return Token_Name; end if; end On_Name_In_Element_Declaration_Children; ---------------------------------- -- On_Name_In_Element_Start_Tag -- ---------------------------------- function On_Name_In_Element_Start_Tag (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("whitespace is missing before attribute name")); -- XXX It is recoverable error. return Error; end if; Resolve_Symbol (Self, 0, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else return Token_Name; end if; end On_Name_In_Element_Start_Tag; ----------------------------------- -- On_Name_In_Entity_Declaration -- ----------------------------------- function On_Name_In_Entity_Declaration (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- [XML1.1 4.2] -- -- [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>' -- [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>' -- -- Check whether whitespace is present before the name. if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.2 productions [71], [72]]" & " whitespace must be present before the name")); -- XXX This is recoverable error. return Error; end if; Resolve_Symbol (Self, 0, 0, False, False, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Self.Whitespace_Matched := False; Enter_Start_Condition (Self, Tables.ENTITY_DEF); return Token_Name; end if; end On_Name_In_Entity_Declaration; -------------------------------------------- -- On_Name_In_Entity_Declaration_Notation -- -------------------------------------------- function On_Name_In_Entity_Declaration_Notation (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin -- [XML1.1 4.2.2] -- -- [76] NDataDecl ::= S 'NDATA' S Name -- -- Check whether whitespace is present before the name. if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML1.1 4.2 production [76]]" & " whitespace must be present before the name of notation")); -- XXX This is recoverable error. return Error; end if; Resolve_Symbol (Self, 0, 0, False, False, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.ENTITY_DEF); return Token_Name; end if; end On_Name_In_Entity_Declaration_Notation; -------------- -- On_NDATA -- -------------- function On_NDATA (Self : in out Simple_Reader'Class) return Token is begin if not Self.Whitespace_Matched then -- XXX This is recoverable error. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("whitespace required before NDATA")); Self.Error_Reported := True; return Error; else Self.Whitespace_Matched := False; Enter_Start_Condition (Self, Tables.ENTITY_NDATA); return Token_Ndata; end if; end On_NDATA; --------------------------- -- On_No_XML_Declaration -- --------------------------- procedure On_No_XML_Declaration (Self : in out Simple_Reader'Class) is begin -- Move scanner's position back to the start of the document or external -- parsed entity. Entity's XML version and encoding are set up -- automatically. YY_Move_Backward (Self); Pop_Start_Condition (Self); end On_No_XML_Declaration; ------------------------------------------- -- On_Open_Of_Attribute_List_Declaration -- ------------------------------------------- function On_Open_Of_Attribute_List_Declaration (Self : in out Simple_Reader'Class) return Token is begin Enter_Start_Condition (Self, Tables.ATTLIST_NAME); Self.Whitespace_Matched := False; return Token_Attlist_Decl_Open; end On_Open_Of_Attribute_List_Declaration; ---------------------- -- On_Open_Of_CDATA -- ---------------------- function On_Open_Of_CDATA (Self : in out Simple_Reader'Class) return Token is Condition : Interfaces.Unsigned_32; begin case Start_Condition (Self) is when Tables.DOCUMENT_10 => Condition := Tables.CDATA_10; when Tables.DOCUMENT_11 => Condition := Tables.CDATA_11; when Tables.DOCUMENT_U11 => Condition := Tables.CDATA_U11; when others => raise Program_Error; end case; Push_Current_And_Enter_Start_Condition (Self, Condition); return Token_CData_Open; end On_Open_Of_CDATA; ------------------------------------ -- On_Open_Of_Conditional_Section -- ------------------------------------ function On_Open_Of_Conditional_Section (Self : in out Simple_Reader'Class) return Token is begin -- [XML [28b], [31]] Conditional section can be present only in external -- subset of DTD. if Is_Document_Entity (Self.Entities, Self.Scanner_State.Entity) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [28b], [31]]" & " conditional sections may only appear in the external" & " DTD subset")); return Error; end if; if Self.Ignore_Depth = 0 then Enter_Start_Condition (Self, Tables.CONDITIONAL_DIRECTIVE); Self.Conditional_Directive := False; else Self.Conditional_Depth := Self.Conditional_Depth + 1; Self.Ignore_Depth := Self.Ignore_Depth + 1; Self.Conditional_Directive := True; end if; return Token_Conditional_Open; end On_Open_Of_Conditional_Section; -------------------------------------------- -- On_Open_Of_Conditional_Section_Content -- -------------------------------------------- function On_Open_Of_Conditional_Section_Content (Self : in out Simple_Reader'Class) return Boolean is begin -- XXX Syntax rules must be checked! if not Self.Conditional_Directive then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("conditional directive is missing")); return False; end if; if Self.Ignore_Depth /= 0 then case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.CONDITIONAL_IGNORE_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.CONDITIONAL_IGNORE_11); end case; else case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_11); end case; end if; return True; end On_Open_Of_Conditional_Section_Content; ------------------------------------------ -- On_Open_Of_Document_Type_Declaration -- ------------------------------------------ function On_Open_Of_Document_Type_Declaration (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin Resolve_Symbol (Self, 10, 0, True, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.DOCTYPE_EXTINT); return Token_Doctype_Decl_Open; end if; end On_Open_Of_Document_Type_Declaration; ------------------------------------ -- On_Open_Of_Element_Declaration -- ------------------------------------ function On_Open_Of_Element_Declaration (Self : in out Simple_Reader'Class) return Token is begin Enter_Start_Condition (Self, Tables.ELEMENT_NAME); return Token_Element_Decl_Open; end On_Open_Of_Element_Declaration; ------------------------ -- On_Open_Of_End_Tag -- ------------------------ function On_Open_Of_End_Tag (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin Resolve_Symbol (Self, 2, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.ELEMENT_START); return Token_End_Open; end if; end On_Open_Of_End_Tag; -------------------------------- -- On_Open_Of_Internal_Subset -- -------------------------------- function On_Open_Of_Internal_Subset (Self : in out Simple_Reader'Class) return Token is begin case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.DOCTYPE_INTSUBSET_11); end case; return Token_Internal_Subset_Open; end On_Open_Of_Internal_Subset; ------------------------------------- -- On_Open_Of_Notation_Declaration -- ------------------------------------- function On_Open_Of_Notation_Declaration (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin Resolve_Symbol (Self, 10, 0, True, False, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Push_Current_And_Enter_Start_Condition (Self, Tables.NOTATION_DECL); return Token_Notation_Decl_Open; end if; end On_Open_Of_Notation_Declaration; --------------------------------------- -- On_Open_Of_Processing_Instruction -- --------------------------------------- function On_Open_Of_Processing_Instruction (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin Resolve_Symbol (Self, 2, 0, False, False, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Push_And_Enter_Start_Condition (Self, Start_Condition (Self), Tables.PI); Reset_Whitespace_Matched (Self); return Token_Pi_Open; end if; end On_Open_Of_Processing_Instruction; -------------------------- -- On_Open_Of_Start_Tag -- -------------------------- function On_Open_Of_Start_Tag (Self : in out Simple_Reader'Class) return Token is Qname_Error : Boolean; begin Resolve_Symbol (Self, 1, 0, False, True, False, Qname_Error, Self.YYLVal.Symbol); if Qname_Error then return Error; else Enter_Start_Condition (Self, Tables.ELEMENT_START); return Token_Element_Open; end if; end On_Open_Of_Start_Tag; ---------------------------------------- -- On_Open_Of_XML_Or_Text_Declaration -- ---------------------------------------- function On_Open_Of_XML_Or_Text_Declaration (Self : in out Simple_Reader'Class) return Token is begin Self.Whitespace_Matched := False; Push_And_Enter_Start_Condition (Self, Start_Condition (Self), Tables.XML_DECL); return Token_Xml_Decl_Open; end On_Open_Of_XML_Or_Text_Declaration; ------------------------------------------------ -- On_Open_Parenthesis_In_Content_Declaration -- ------------------------------------------------ function On_Open_Parenthesis_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token is use type Interfaces.Unsigned_32; begin if Start_Condition (Self) = Tables.ELEMENT_DECL then -- Check whitespace from rule [45] elementdecl. This subprogram -- changes scanner's start condition, so handing of nested -- declarations skip check below. if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [45]] no whitespace after name")); return Error; end if; Enter_Start_Condition (Self, Tables.ELEMENT_CHILDREN); end if; return Token_Open_Parenthesis; end On_Open_Parenthesis_In_Content_Declaration; ----------------------------------------------- -- On_Open_Parenthesis_In_Notation_Attribute -- ----------------------------------------------- function On_Open_Parenthesis_In_Notation_Attribute (Self : in out Simple_Reader'Class) return Token is begin -- Checks ithat whitespace before open parenthesis is detected -- and report error when check fail. if not Self.Whitespace_Matched then -- XXX This is recoverable error. Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("whitespace required before open parenthesis")); return Error; end if; return Token_Open_Parenthesis; end On_Open_Parenthesis_In_Notation_Attribute; ----------------------------------------------------------- -- On_Parameter_Entity_Reference_In_Document_Declaration -- ----------------------------------------------------------- function On_Parameter_Entity_Reference_In_Document_Declaration (Self : in out Simple_Reader'Class) return Token is Qualified_Name : Symbol_Identifier; Qname_Error : Boolean; Entity : Entity_Identifier; Deep : Natural; begin Resolve_Symbol (Self, 1, 1, False, False, False, Qname_Error, Qualified_Name); if Qname_Error then return Error; end if; Entity := Parameter_Entity (Self.Symbols, Qualified_Name); if Entity = No_Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("parameter entity must be declared")); return Error; end if; Deep := Integer (Self.Scanner_Stack.Length); if not Push_Entity (Self => Self, Entity => Entity, In_Document_Type => False, In_Literal => False) then return Error; elsif Deep = Integer (Self.Scanner_Stack.Length) then -- Entity doesn't pushed in stack because its replacement text -- is empty. return End_Of_Input; else Self.Scanner_State.Start_Issued := True; return Token_Entity_Start; end if; end On_Parameter_Entity_Reference_In_Document_Declaration; --------------------------------------------------- -- On_Parameter_Entity_Reference_In_Entity_Value -- --------------------------------------------------- function On_Parameter_Entity_Reference_In_Entity_Value (Self : in out Simple_Reader'Class) return Boolean is Qualified_Name : Symbol_Identifier; Qname_Error : Boolean; Entity : Entity_Identifier; begin Resolve_Symbol (Self, 1, 1, False, False, False, Qname_Error, Qualified_Name); if Qname_Error then return False; else Entity := Parameter_Entity (Self.Symbols, Qualified_Name); -- XML WFC: PEs in Internal Subset -- -- "In the internal DTD subset, parameter-entity references MUST NOT -- occur within markup declarations; they may occur where markup -- declarations can occur. (This does not apply to references that -- occur in external parameter entities or to the external subset.)" -- -- Check whether parameter entity reference doesn't occure in the -- entity value of the entity declared in internal subset. if Is_Document_Entity (Self.Entities, Self.Scanner_State.Entity) then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML 2.8 WFC: PEs in Internal Subset]" & " parameter-entity reference in internal subset must not" & " occur within markup declaration")); return False; end if; -- XML VC: Entity Declared -- -- "In a document with an external subset or parameter entity -- references with "standalone='no'", the Name given in the entity -- reference MUST match that in an entity declaration. For -- interoperability, valid documents SHOULD declare the entities amp, -- lt, gt, apos, quot, in the form specified in 4.6 Predefined -- Entities. The declaration of a parameter entity MUST precede any -- reference to it. Similarly, the declaration of a general entity -- MUST precede any attribute-list declaration containing a default -- value with a direct or indirect reference to that general entity." -- -- XXX Parameter entity must not be declared at the point of -- reference, except in some conditions in validating mode; so, -- check below must be improved, as well as behavior in -- non-validating mode must be checked. if Entity = No_Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("parameter entity must be declared")); return False; end if; return Push_Entity (Self => Self, Entity => Entity, In_Document_Type => False, In_Literal => True); end if; end On_Parameter_Entity_Reference_In_Entity_Value; --------------------------------------------------------- -- On_Parameter_Entity_Reference_In_Markup_Declaration -- --------------------------------------------------------- function On_Parameter_Entity_Reference_In_Markup_Declaration (Self : in out Simple_Reader'Class) return Boolean is Qualified_Name : Symbol_Identifier; Qname_Error : Boolean; Entity : Entity_Identifier; begin Resolve_Symbol (Self, 1, 1, False, False, False, Qname_Error, Qualified_Name); if Qname_Error then return False; else -- [XML 2.8] WFC: PEs in Internal Subset -- -- "In the internal DTD subset, parameter-entity references MUST NOT -- occur within markup declarations; they may occur where markup -- declarations can occur. (This does not apply to references that -- occur in external parameter entities or to the external subset.)" -- -- Check whether external subset is processed. if not Self.External_Subset_Done then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML 2.8 WFC: PEs in Internal Subset]" & " parameter-entity reference in internal subset must not" & " occur within markup declaration")); return False; end if; Entity := Parameter_Entity (Self.Symbols, Qualified_Name); if Entity = No_Entity then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("parameter entity must be declared")); return False; end if; return Push_Entity (Self => Self, Entity => Entity, In_Document_Type => False, In_Literal => True); end if; end On_Parameter_Entity_Reference_In_Markup_Declaration; --------------------- -- On_Percent_Sign -- --------------------- function On_Percent_Sign (Self : in out Simple_Reader'Class) return Token is begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("no whitespace before percent")); Self.Error_Reported := True; -- XXX This is recoverable error. return Error; else Self.Whitespace_Matched := False; return Token_Percent; end if; end On_Percent_Sign; ------------------------------------ -- On_Plus_In_Content_Declaration -- ------------------------------------ function On_Plus_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token is begin if Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [47], [48]] illegal whitespace before plus")); return Error; else return Token_Plus; end if; end On_Plus_In_Content_Declaration; ----------------------- -- On_Public_Literal -- ----------------------- function On_Public_Literal (Self : in out Simple_Reader'Class) return Token is Next : Utf16_String_Index := Self.Scanner_State.YY_Base_Position + 1; -- Skip literal open delimiter. Code : Code_Point; Space_Before : Boolean := True; begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[[75] ExternalID, [83] PublicID]" & " whitespace is required before pubid literal")); return Error; end if; Self.Whitespace_Matched := False; Enter_Start_Condition (Self, Tables.EXTERNAL_ID_SYS); -- [XML 4.2.2] External Entities -- -- "[Definition: In addition to a system identifier, an external -- identifier may include a public identifier.] An XML processor -- attempting to retrieve the entity's content may use any combination -- of the public and system identifiers as well as additional -- information outside the scope of this specification to try to -- generate an alternative URI reference. If the processor is unable to -- do so, it MUST use the URI reference specified in the system literal. -- Before a match is attempted, all strings of white space in the public -- identifier MUST be normalized to single space characters (#x20), and -- leading and trailing white space MUST be removed." -- -- Normalize public identifier. Matreshka.Internals.Strings.Operations.Reset (Self.Character_Data); while Next /= Self.Scanner_State.YY_Current_Position - 1 loop -- Exclude literal close delimiter. Unchecked_Next (Self.Scanner_State.Data.Value, Next, Code); -- It can be reasonable to implement this step of normalization on -- SIMD. if Code = Character_Tabulation or Code = Line_Feed or Code = Carriage_Return then Code := Space; end if; if Code = Space then if not Space_Before then Matreshka.Internals.Strings.Operations.Unterminated_Append (Self.Character_Data, Code); Space_Before := True; end if; else Matreshka.Internals.Strings.Operations.Unterminated_Append (Self.Character_Data, Code); Space_Before := False; end if; end loop; if Space_Before and Self.Character_Data.Unused /= 0 then -- Remove traling space. Self.Character_Data.Length := Self.Character_Data.Length - 1; Self.Character_Data.Unused := Self.Character_Data.Unused - 1; end if; String_Handler.Fill_Null_Terminator (Self.Character_Data); Matreshka.Internals.Strings.Reference (Self.Character_Data); Set_String_Internal (Item => Self.YYLVal, String => Self.Character_Data, Is_Whitespace => False); return Token_Public_Literal; end On_Public_Literal; --------------------------------------------- -- On_Question_Mark_In_Content_Declaration -- --------------------------------------------- function On_Question_Mark_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token is begin if Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[XML [47], [48]] illegal whitespace before question mark")); return Error; else return Token_Question; end if; end On_Question_Mark_In_Content_Declaration; --------------------------- -- On_Standalone_Keyword -- --------------------------- function On_Standalone_Keyword (Self : in out Simple_Reader'Class) return Token is begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("no whitespace before 'standalone'")); Self.Error_Reported := True; -- XXX This is recoverable error. return Error; else return Token_Standalone; end if; end On_Standalone_Keyword; ---------------------------------------- -- On_System_Keyword_In_Document_Type -- ---------------------------------------- function On_System_Keyword_In_Document_Type (Self : in out Simple_Reader'Class) return Token is begin Reset_Whitespace_Matched (Self); Push_And_Enter_Start_Condition (Self, Tables.DOCTYPE_INT, Tables.EXTERNAL_ID_SYS); return Token_System; end On_System_Keyword_In_Document_Type; --------------------------------------------- -- On_System_Keyword_In_Entity_Or_Notation -- --------------------------------------------- function On_System_Keyword_In_Entity_Or_Notation (Self : in out Simple_Reader'Class) return Token is begin Reset_Whitespace_Matched (Self); Push_Current_And_Enter_Start_Condition (Self, Tables.EXTERNAL_ID_SYS); return Token_System; end On_System_Keyword_In_Entity_Or_Notation; ----------------------- -- On_System_Literal -- ----------------------- function On_System_Literal (Self : in out Simple_Reader'Class) return Token is begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[[75] ExternalID]" & " whitespace is required before system literal")); return Error; end if; Self.Whitespace_Matched := False; Pop_Start_Condition (Self); Set_String_Internal (Item => Self.YYLVal, String => YY_Text (Self, 1, 1), Is_Whitespace => False); return Token_System_Literal; end On_System_Literal; ----------------------------- -- On_Unexpected_Character -- ----------------------------- function On_Unexpected_Character (Self : in out Simple_Reader'Class) return Token is begin Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("unexpected character")); return Error; end On_Unexpected_Character; ------------------------ -- On_Version_Keyword -- ------------------------ function On_Version_Keyword (Self : in out Simple_Reader'Class) return Token is begin if not Self.Whitespace_Matched then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("no whitespace before 'version'")); Self.Error_Reported := True; -- XXX This is recoverable error. return Error; else return Token_Version; end if; end On_Version_Keyword; ------------------------------- -- On_Whitespace_In_Document -- ------------------------------- function On_Whitespace_In_Document (Self : in out Simple_Reader'Class) return Boolean is C : constant Code_Point := Code_Point (Self.Scanner_State.Data.Value (Self.Scanner_State.YY_Current_Position - 1)); begin if C = Less_Than_Sign or C = Ampersand then -- Move back when trailing context is available. YY_Move_Backward (Self); end if; if Self.Element_Names.Is_Empty then -- Document content not entered. return False; else Matreshka.Internals.Strings.Operations.Copy_Slice (Self.Character_Data, Self.Scanner_State.Data, Self.Scanner_State.YY_Base_Position, Self.Scanner_State.YY_Current_Position - Self.Scanner_State.YY_Base_Position, Self.Scanner_State.YY_Current_Index - Self.Scanner_State.YY_Base_Index); Matreshka.Internals.Strings.Reference (Self.Character_Data); Set_String_Internal (Item => Self.YYLVal, String => Self.Character_Data, Is_Whitespace => True); return True; end if; end On_Whitespace_In_Document; --------------------------------------------- -- On_Whitespace_In_Processing_Instruction -- --------------------------------------------- procedure On_Whitespace_In_Processing_Instruction (Self : in out Simple_Reader'Class) is begin -- Whitespace between processing instruction's target and data are -- required, so set flag which indicates their presence. Self.Whitespace_Matched := True; case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.PI_DATA_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.PI_DATA_11); end case; end On_Whitespace_In_Processing_Instruction; -------------------- -- Resolve_Symbol -- -------------------- procedure Resolve_Symbol (Self : in out Simple_Reader'Class; Trim_Left : Natural; Trim_Right : Natural; Trim_Whitespace : Boolean; Can_Be_Qname : Boolean; Not_Qname : Boolean; Error : out Boolean; Symbol : out Matreshka.Internals.XML.Symbol_Identifier) is -- Trailing and leading character as well as whitespace characters -- belongs to BMP and don't require expensive UTF-16 decoding. FP : Utf16_String_Index := Self.Scanner_State.YY_Base_Position + Utf16_String_Index (Trim_Left); FI : Positive := Self.Scanner_State.YY_Base_Index + Trim_Left; LP : constant Utf16_String_Index := Self.Scanner_State.YY_Current_Position - Utf16_String_Index (Trim_Right); LI : constant Positive := Self.Scanner_State.YY_Current_Index - Trim_Right; C : Code_Point; E : Matreshka.Internals.XML.Symbol_Tables.Qualified_Name_Errors; begin if Trim_Whitespace then loop C := Code_Point (Self.Scanner_State.Data.Value (FP)); exit when C /= Space and then C /= Character_Tabulation and then C /= Carriage_Return and then C /= Line_Feed; FP := FP + 1; FI := FI + 1; end loop; end if; Matreshka.Internals.XML.Symbol_Tables.Insert (Self.Symbols, Self.Scanner_State.Data, FP, LP - FP, LI - FI, Self.Namespaces.Enabled, E, Symbol); Error := False; if Self.Namespaces.Enabled and not Not_Qname then case E is when Valid => if not Can_Be_Qname and Local_Name (Self.Symbols, Symbol) /= Symbol then Error := True; Symbol := No_Symbol; Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[NSXML1.1] qualified name must not be used here")); end if; when Colon_At_Start => Error := True; Symbol := No_Symbol; Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[NSXML1.1]" & " qualified name must not start with colon character")); when Colon_At_End => Error := True; Symbol := No_Symbol; Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[NSXML1.1]" & " qualified name must not end with colon character")); when Multiple_Colons => Error := True; Symbol := No_Symbol; Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[NSXML1.1]" & " qualified name must not contain more than one colon" & " character")); when First_Character_Is_Not_NS_Name_Start_Char => Error := True; Symbol := No_Symbol; Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("[NSXML1.1] first character of local name is invalid")); end case; end if; end Resolve_Symbol; end XML.SAX.Simple_Readers.Scanner.Actions;
with Ada.Text_IO; with System; procedure Macrodef is begin Ada.Text_IO.Put_Line ("Integer'First = " & Integer'Image (Integer'First)); Ada.Text_IO.Put_Line ("Integer'Last = " & Integer'Image (Integer'Last)); Ada.Text_IO.Put_Line ("System.Min_Int = " & Long_Long_Integer'Image (System.Min_Int)); Ada.Text_IO.Put_Line ("System.Max_Int = " & Long_Long_Integer'Image (System.Max_Int)); Ada.Text_IO.Put_Line ("Ada.Text_IO.Count'Last = " & Ada.Text_IO.Count'Image (Ada.Text_IO.Count'Last)); Ada.Text_IO.Put_Line ("Ada.Text_IO.Field'Last = " & Ada.Text_IO.Field'Image (Ada.Text_IO.Field'Last)); end Macrodef;
with Interfaces; use Interfaces; package body Hardware.Beacon is procedure Init (Tick_Size : Interfaces.Unsigned_8) is begin Resolution := Tick_Size; MCU.DDRH_Bits (LED1_Bit) := DD_Output; MCU.DDRH_Bits (LED2_Bit) := DD_Output; LED1 := Low; LED2 := Low; Tick := 0; Counter := 0; end Init; procedure Trigger is begin if Tick >= Resolution then if Counter = 0 then LED1 := High; LED2 := High; Counter := Counter + 1; elsif Counter = 1 then LED1 := Low; LED2 := Low; Counter := Counter + 1; elsif Counter = 10 then Counter := 0; else Counter := Counter + 1; end if; Tick := 0; else Tick := Tick + 1; end if; end Trigger; end Hardware.Beacon;
pragma License (Unrestricted); -- runtime unit required by compiler with System.Unwind; package System.Standard_Library is pragma Preelaborate; -- required for controlled type by compiler (s-stalib.ads) procedure Abort_Undefer_Direct with Import, Convention => Ada, External_Name => "system__standard_library__abort_undefer_direct"; -- required by compiler (s-stalib.ads) subtype Exception_Data_Ptr is Unwind.Exception_Data_Access; end System.Standard_Library;
-- -- Copyright (C) 2021 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- with HAL.Real_Time_Clock; use HAL.Real_Time_Clock; with HAL; package Text_Format is subtype Number_Base is Positive range 2 .. 16; function From_Natural (N : Natural; Base : Number_Base := 10) return String; function From_Integer (N : Integer; Base : Number_Base := 10) return String; procedure From_Natural (N : Natural; Str : out String); function ISO_Date (Date : RTC_Date; Year_Offset : Integer := 2000) return String; subtype ISO_Time_String is String (1 .. 8); function ISO_Time (Time : RTC_Time) return ISO_Time_String; function From_ISO_Time (Time : ISO_Time_String) return RTC_Time; function ISO_Date_Time (Date : RTC_Date; Time : RTC_Time; Year_Offset : Integer := 2000) return String; function From_Float (F : Float; Fore : Positive := 1; Aft : Positive := 3) return String; subtype Hex_String is String (1 .. 2); function Hex (Data : HAL.UInt8) return Hex_String; procedure Hex (Data : HAL.UInt8_Array; Str : out String); function Hex (Data : HAL.UInt8_Array) return String; function From_UInt8_Array (Data : HAL.UInt8_Array) return String; function To_UInt8_Array (S : String) return HAL.UInt8_Array; end Text_Format;
----------------------------------------------------------------------- -- wiki-render-wiki -- Wiki to Wiki renderer -- Copyright (C) 2015, 2016, 2018, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Wiki.Helpers; package body Wiki.Render.Wiki is use Helpers; HEADER_CREOLE : aliased constant Strings.WString := "="; BOLD_CREOLE : aliased constant Strings.WString := "**"; ITALIC_CREOLE : aliased constant Strings.WString := "//"; SUPERSCRIPT_CREOLE : aliased constant Strings.WString := "^^"; SUBSCRIPT_CREOLE : aliased constant Strings.WString := ",,"; UNDERLINE_CREOLE : aliased constant Strings.WString := "__"; LINE_BREAK_CREOLE : aliased constant Strings.WString := "%%%" & LF; IMG_START_CREOLE : aliased constant Strings.WString := "{{"; IMG_END_CREOLE : aliased constant Strings.WString := "}}"; LINK_START_CREOLE : aliased constant Strings.WString := "[["; LINK_END_CREOLE : aliased constant Strings.WString := "]]"; PREFORMAT_START_CREOLE : aliased constant Strings.WString := "{{{"; PREFORMAT_END_CREOLE : aliased constant Strings.WString := "}}}" & LF; HORIZONTAL_RULE_CREOLE : aliased constant Strings.WString := "----" & LF & LF; LINK_SEPARATOR_CREOLE : aliased constant Strings.WString := "|"; LIST_ITEM_CREOLE : aliased constant Strings.WString := "*"; LIST_ORDERED_ITEM_CREOLE : aliased constant Strings.WString := "#"; ESCAPE_CREOLE : aliased constant Strings.WString := "~"; HEADER_DOTCLEAR : aliased constant Strings.WString := "!"; BOLD_DOTCLEAR : aliased constant Strings.WString := "__"; ITALIC_DOTCLEAR : aliased constant Strings.WString := "''"; DELETE_DOTCLEAR : aliased constant Strings.WString := "--"; CODE_DOTCLEAR : aliased constant Strings.WString := "@@"; IMG_START_DOTCLEAR : aliased constant Strings.WString := "(("; IMG_END_DOTCLEAR : aliased constant Strings.WString := "))"; LINK_START_DOTCLEAR : aliased constant Strings.WString := "["; LINK_END_DOTCLEAR : aliased constant Strings.WString := "]"; QUOTE_START_DOTCLEAR : aliased constant Strings.WString := "{{"; QUOTE_END_DOTCLEAR : aliased constant Strings.WString := "}}"; QUOTE_SEPARATOR_DOTCLEAR : aliased constant Strings.WString := "|"; PREFORMAT_START_DOTCLEAR : aliased constant Strings.WString := "///"; PREFORMAT_END_DOTCLEAR : aliased constant Strings.WString := "///" & LF; ESCAPE_DOTCLEAR : aliased constant Strings.WString := "\"; QUOTE_DOTCLEAR : aliased constant Strings.WString := ">"; BOLD_MARKDOWN : aliased constant Strings.WString := "**"; ITALIC_MARKDOWN : aliased constant Strings.WString := "__"; CODE_MARKDOWN : aliased constant Strings.WString := "`"; HEADER_MARKDOWN : aliased constant Strings.WString := "#"; ESCAPE_MARKDOWN : aliased constant Strings.WString := "\"; QUOTE_MARKDOWN : aliased constant Strings.WString := ">"; PREFORMAT_START_MARKDOWN : aliased constant Strings.WString := "```"; PREFORMAT_END_MARKDOWN : aliased constant Strings.WString := "```" & LF; HORIZONTAL_RULE_MARKDOWN : aliased constant Strings.WString := "----" & LF & LF; IMG_START_MARKDOWN : aliased constant Strings.WString := "!["; IMG_END_MARKDOWN : aliased constant Strings.WString := ")"; LINK_START_MARKDOWN : aliased constant Strings.WString := "["; LINK_SEPARATOR_MARKDOWN : aliased constant Strings.WString := "]("; LINK_END_MARKDOWN : aliased constant Strings.WString := ")"; LIST_ITEM_MARKDOWN : aliased constant Strings.WString := "*"; LIST_ORDERED_ITEM_MARKDOWN : aliased constant Strings.WString := "*"; LINE_BREAK_MARKDOWN : aliased constant Strings.WString := "\" & LF; LINE_BREAK_MEDIAWIKI : aliased constant Strings.WString := "<br />" & LF; BOLD_MEDIAWIKI : aliased constant Strings.WString := "'''"; ITALIC_MEDIAWIKI : aliased constant Strings.WString := "''"; PREFORMAT_START_MEDIAWIKI : aliased constant Strings.WString := "<pre>"; PREFORMAT_END_MEDIAWIKI : aliased constant Strings.WString := "</pre>"; IMG_START_MEDIAWIKI : aliased constant Strings.WString := "[[File:"; IMG_END_MEDIAWIKI : aliased constant Strings.WString := "]]"; Empty_Formats : constant Format_Map := (others => False); -- Set the output writer. procedure Set_Output_Stream (Engine : in out Wiki_Renderer; Stream : in Streams.Output_Stream_Access; Format : in Wiki_Syntax) is begin Engine.Output := Stream; Engine.Syntax := Format; case Format is when SYNTAX_DOTCLEAR => Engine.Style_Start_Tags (BOLD) := BOLD_DOTCLEAR'Access; Engine.Style_End_Tags (BOLD) := BOLD_DOTCLEAR'Access; Engine.Style_Start_Tags (ITALIC) := ITALIC_DOTCLEAR'Access; Engine.Style_End_Tags (ITALIC) := ITALIC_DOTCLEAR'Access; Engine.Style_Start_Tags (STRIKEOUT) := DELETE_DOTCLEAR'Access; Engine.Style_End_Tags (STRIKEOUT) := DELETE_DOTCLEAR'Access; Engine.Style_Start_Tags (CODE) := CODE_DOTCLEAR'Access; Engine.Style_End_Tags (CODE) := CODE_DOTCLEAR'Access; Engine.Tags (Header_Start) := HEADER_DOTCLEAR'Access; Engine.Tags (Line_Break) := LINE_BREAK_CREOLE'Access; Engine.Tags (Img_Start) := IMG_START_DOTCLEAR'Access; Engine.Tags (Img_End) := IMG_END_DOTCLEAR'Access; Engine.Tags (Link_Start) := LINK_START_DOTCLEAR'Access; Engine.Tags (Link_End) := LINK_END_DOTCLEAR'Access; Engine.Tags (Link_Separator) := LINK_SEPARATOR_CREOLE'Access; Engine.Tags (Quote_Start) := QUOTE_START_DOTCLEAR'Access; Engine.Tags (Quote_End) := QUOTE_END_DOTCLEAR'Access; Engine.Tags (Quote_Separator) := QUOTE_SEPARATOR_DOTCLEAR'Access; Engine.Tags (Preformat_Start) := PREFORMAT_START_DOTCLEAR'Access; Engine.Tags (Preformat_End) := PREFORMAT_END_DOTCLEAR'Access; Engine.Tags (Horizontal_Rule) := HORIZONTAL_RULE_CREOLE'Access; Engine.Tags (List_Item) := LIST_ITEM_CREOLE'Access; Engine.Tags (List_Ordered_Item) := LIST_ORDERED_ITEM_CREOLE'Access; Engine.Tags (Escape_Rule) := ESCAPE_DOTCLEAR'Access; Engine.Tags (Blockquote_Start) := QUOTE_DOTCLEAR'Access; Engine.Invert_Header_Level := True; Engine.Allow_Link_Language := True; Engine.Link_First := True; Engine.Escape_Set := Ada.Strings.Wide_Wide_Maps.To_Set ("-+_*{}][/=\"); when SYNTAX_MEDIA_WIKI => Engine.Style_Start_Tags (BOLD) := BOLD_MEDIAWIKI'Access; Engine.Style_End_Tags (BOLD) := BOLD_MEDIAWIKI'Access; Engine.Style_Start_Tags (ITALIC) := ITALIC_MEDIAWIKI'Access; Engine.Style_End_Tags (ITALIC) := ITALIC_MEDIAWIKI'Access; Engine.Tags (Header_Start) := HEADER_CREOLE'Access; Engine.Tags (Header_End) := HEADER_CREOLE'Access; Engine.Tags (Line_Break) := LINE_BREAK_MEDIAWIKI'Access; Engine.Tags (Img_Start) := IMG_START_MEDIAWIKI'Access; Engine.Tags (Img_End) := IMG_END_MEDIAWIKI'Access; Engine.Tags (Link_Start) := LINK_START_CREOLE'Access; Engine.Tags (Link_End) := LINK_END_CREOLE'Access; Engine.Tags (Link_Separator) := LINK_SEPARATOR_CREOLE'Access; Engine.Tags (List_Item) := LIST_ITEM_CREOLE'Access; Engine.Tags (List_Ordered_Item) := LIST_ORDERED_ITEM_CREOLE'Access; Engine.Tags (Preformat_Start) := PREFORMAT_START_MEDIAWIKI'Access; Engine.Tags (Preformat_End) := PREFORMAT_END_MEDIAWIKI'Access; Engine.Tags (Horizontal_Rule) := HORIZONTAL_RULE_CREOLE'Access; Engine.Tags (Escape_Rule) := ESCAPE_CREOLE'Access; Engine.Link_First := True; Engine.Html_Blockquote := True; Engine.Escape_Set := Ada.Strings.Wide_Wide_Maps.To_Set ("'+_-*(){}][!"); when SYNTAX_MARKDOWN => Engine.Style_Start_Tags (BOLD) := BOLD_MARKDOWN'Access; Engine.Style_End_Tags (BOLD) := BOLD_MARKDOWN'Access; Engine.Style_Start_Tags (ITALIC) := ITALIC_MARKDOWN'Access; Engine.Style_End_Tags (ITALIC) := ITALIC_MARKDOWN'Access; Engine.Style_Start_Tags (CODE) := CODE_MARKDOWN'Access; Engine.Style_End_Tags (CODE) := CODE_MARKDOWN'Access; Engine.Tags (Header_Start) := HEADER_MARKDOWN'Access; Engine.Tags (Line_Break) := LINE_BREAK_MARKDOWN'Access; Engine.Tags (Img_Start) := IMG_START_MARKDOWN'Access; Engine.Tags (Img_End) := IMG_END_MARKDOWN'Access; -- Engine.Tags (Img_Separator) := LINK_SEPARATOR_MARKDOWN'Access; Engine.Tags (Link_Start) := LINK_START_MARKDOWN'Access; Engine.Tags (Link_End) := LINK_END_MARKDOWN'Access; Engine.Tags (Link_Separator) := LINK_SEPARATOR_MARKDOWN'Access; Engine.Tags (List_Item) := LIST_ITEM_MARKDOWN'Access; Engine.Tags (List_Ordered_Item) := LIST_ORDERED_ITEM_MARKDOWN'Access; Engine.Tags (Preformat_Start) := PREFORMAT_START_MARKDOWN'Access; Engine.Tags (Preformat_End) := PREFORMAT_END_MARKDOWN'Access; Engine.Tags (Horizontal_Rule) := HORIZONTAL_RULE_MARKDOWN'Access; Engine.Tags (Escape_Rule) := ESCAPE_MARKDOWN'Access; Engine.Tags (Blockquote_Start) := QUOTE_MARKDOWN'Access; Engine.Link_First := False; Engine.Html_Blockquote := False; Engine.Escape_Set := Ada.Strings.Wide_Wide_Maps.To_Set ("\`*_{}[]()#+-!"); when others => Engine.Style_Start_Tags (BOLD) := BOLD_CREOLE'Access; Engine.Style_End_Tags (BOLD) := BOLD_CREOLE'Access; Engine.Style_Start_Tags (ITALIC) := ITALIC_CREOLE'Access; Engine.Style_End_Tags (ITALIC) := ITALIC_CREOLE'Access; Engine.Style_Start_Tags (SUPERSCRIPT) := SUPERSCRIPT_CREOLE'Access; Engine.Style_End_Tags (SUPERSCRIPT) := SUPERSCRIPT_CREOLE'Access; Engine.Style_Start_Tags (SUBSCRIPT) := SUBSCRIPT_CREOLE'Access; Engine.Style_End_Tags (SUBSCRIPT) := SUBSCRIPT_CREOLE'Access; Engine.Style_Start_Tags (CODE) := UNDERLINE_CREOLE'Access; Engine.Style_End_Tags (CODE) := UNDERLINE_CREOLE'Access; Engine.Tags (Header_Start) := HEADER_CREOLE'Access; Engine.Tags (Header_End) := HEADER_CREOLE'Access; Engine.Tags (Line_Break) := LINE_BREAK_CREOLE'Access; Engine.Tags (Img_Start) := IMG_START_CREOLE'Access; Engine.Tags (Img_End) := IMG_END_CREOLE'Access; Engine.Tags (Link_Start) := LINK_START_CREOLE'Access; Engine.Tags (Link_End) := LINK_END_CREOLE'Access; Engine.Tags (Link_Separator) := LINK_SEPARATOR_CREOLE'Access; Engine.Tags (Quote_Start) := LINK_START_CREOLE'Access; Engine.Tags (Quote_End) := LINK_END_CREOLE'Access; Engine.Tags (Quote_Separator) := LINK_SEPARATOR_CREOLE'Access; Engine.Tags (List_Item) := LIST_ITEM_CREOLE'Access; Engine.Tags (List_Ordered_Item) := LIST_ORDERED_ITEM_CREOLE'Access; Engine.Tags (Preformat_Start) := PREFORMAT_START_CREOLE'Access; Engine.Tags (Preformat_End) := PREFORMAT_END_CREOLE'Access; Engine.Tags (Horizontal_Rule) := HORIZONTAL_RULE_CREOLE'Access; Engine.Tags (Escape_Rule) := ESCAPE_CREOLE'Access; Engine.Escape_Set := Ada.Strings.Wide_Wide_Maps.To_Set ("'+_-*(){}][!"); Engine.Link_First := True; end case; end Set_Output_Stream; -- ------------------------------ -- Emit a new line. -- ------------------------------ procedure New_Line (Engine : in out Wiki_Renderer; Optional : in Boolean := False) is begin if Optional and then (Engine.Line_Count = 0 or else Engine.Empty_Line) then return; end if; Engine.Output.Write (LF); Engine.Empty_Previous_Line := Engine.Empty_Line; Engine.Empty_Line := True; Engine.Need_Newline := False; Engine.Need_Space := False; Engine.Line_Count := Engine.Line_Count + 1; end New_Line; procedure Write_Optional_Space (Engine : in out Wiki_Renderer) is begin if Engine.Need_Space then Engine.Need_Space := False; Engine.Output.Write (' '); end if; end Write_Optional_Space; procedure Need_Separator_Line (Engine : in out Wiki_Renderer) is begin if not Engine.Empty_Line then Engine.Empty_Previous_Line := False; Engine.Output.Write (LF); Engine.Empty_Line := True; Engine.Line_Count := Engine.Line_Count + 1; end if; Engine.Need_Newline := True; end Need_Separator_Line; -- ------------------------------ -- Render the node instance from the document. -- ------------------------------ overriding procedure Render (Engine : in out Wiki_Renderer; Doc : in Documents.Document; Node : in Nodes.Node_Type) is begin case Node.Kind is when Nodes.N_HEADER => Engine.Render_Header (Node.Header, Node.Level); when Nodes.N_LINE_BREAK => Engine.Output.Write (Engine.Tags (Line_Break).all); Engine.Empty_Line := False; Engine.Need_Space := False; when Nodes.N_HORIZONTAL_RULE => Engine.Close_Paragraph; Engine.Output.Write (Engine.Tags (Horizontal_Rule).all); when Nodes.N_PARAGRAPH => Engine.Add_Paragraph; when Nodes.N_PREFORMAT => Engine.Render_Preformatted (Node.Preformatted, Strings.To_WString (Node.Language)); when Nodes.N_LIST => Engine.Add_List_Item (Node.Level, False); when Nodes.N_NUM_LIST => Engine.Add_List_Item (Node.Level, True); when Nodes.N_TEXT => declare F : Format_Map := Node.Format; begin for I in F'Range loop F (I) := F (I) or Engine.Current_Style (I); end loop; Engine.Render_Text (Node.Text, F); end; when Nodes.N_LINK => Engine.Render_Link (Node.Title, Node.Link_Attr); when Nodes.N_IMAGE => Engine.Render_Image (Node.Title, Node.Link_Attr); when Nodes.N_QUOTE => Engine.Render_Quote (Node.Title, Node.Link_Attr); when Nodes.N_TAG_START => Engine.Render_Tag (Doc, Node); when others => null; end case; end Render; -- ------------------------------ -- Add a section header in the document. -- ------------------------------ procedure Render_Header (Engine : in out Wiki_Renderer; Header : in Strings.WString; Level : in Positive) is Count : Natural := Level; begin Engine.Set_Format (Empty_Formats); if not Engine.Empty_Line then Engine.Output.Write (LF); end if; Engine.Close_Paragraph; Engine.Output.Write (LF); if Engine.Invert_Header_Level then if Count > 5 then Count := 5; end if; Count := 6 - Count; elsif Count > 6 then Count := 6; end if; for I in 1 .. Count loop Engine.Output.Write (Engine.Tags (Header_Start).all); end loop; Engine.Output.Write (' '); Engine.Output.Write (Header); if Engine.Tags (Header_End)'Length > 0 then Engine.Output.Write (' '); for I in 1 .. Level loop Engine.Output.Write (Engine.Tags (Header_End).all); end loop; end if; Engine.New_Line; end Render_Header; -- ------------------------------ -- Add a paragraph (<p>). Close the previous paragraph if any. -- The paragraph must be closed at the next paragraph or next header. -- ------------------------------ procedure Add_Paragraph (Engine : in out Wiki_Renderer) is begin Engine.Close_Paragraph; if Engine.Line_Count > 0 then if not Engine.Empty_Line then Engine.New_Line; end if; Engine.New_Line; end if; end Add_Paragraph; -- Add a blockquote (<blockquote>). The level indicates the blockquote nested level. -- The blockquote must be closed at the next header. procedure Add_Blockquote (Engine : in out Wiki_Renderer; Level : in Natural) is begin null; end Add_Blockquote; -- ------------------------------ -- Add a list item (<li>). Close the previous paragraph and list item if any. -- The list item will be closed at the next list item, next paragraph or next header. -- ------------------------------ procedure Add_List_Item (Engine : in out Wiki_Renderer; Level : in Positive; Ordered : in Boolean) is begin Engine.Need_Space := False; Engine.Close_Paragraph; Engine.Output.Write (Engine.Tags (List_Start).all); for I in 1 .. Level loop if Ordered then Engine.Output.Write (Engine.Tags (List_Ordered_Item).all); else Engine.Output.Write (Engine.Tags (List_Item).all); end if; end loop; Engine.Output.Write (' '); end Add_List_Item; -- ------------------------------ -- Render a link. -- ------------------------------ procedure Render_Link (Engine : in out Wiki_Renderer; Name : in Strings.WString; Attrs : in Attributes.Attribute_List) is Link : constant Strings.WString := Attributes.Get_Attribute (Attrs, "href"); Lang : constant Strings.WString := Attributes.Get_Attribute (Attrs, "lang"); begin if Engine.Empty_Line and Engine.In_List then if Engine.UL_List_Level + Engine.OL_List_Level > 0 then if Engine.UL_List_Level > Engine.OL_List_Level then Engine.Add_List_Item (Engine.UL_List_Level, False); else Engine.Add_List_Item (Engine.OL_List_Level, True); end if; end if; Engine.In_List := False; end if; Engine.Write_Optional_Space; Engine.Output.Write (Engine.Tags (Link_Start).all); if Engine.Link_First then Engine.Output.Write (Link); if Name'Length > 0 then Engine.Output.Write (Engine.Tags (Link_Separator).all); Engine.Output.Write (Name); end if; if Engine.Allow_Link_Language and Lang'Length > 0 then Engine.Output.Write (Engine.Tags (Link_Separator).all); Engine.Output.Write (Lang); end if; else Engine.Output.Write (Name); Engine.Output.Write (Engine.Tags (Link_Separator).all); Engine.Output.Write (Link); end if; Engine.Output.Write (Engine.Tags (Link_End).all); Engine.Empty_Line := False; end Render_Link; -- Render an image. procedure Render_Image (Engine : in out Wiki_Renderer; Title : in Strings.WString; Attrs : in Attributes.Attribute_List) is Src : constant Strings.WString := Attributes.Get_Attribute (Attrs, "src"); begin Engine.Write_Optional_Space; Engine.Output.Write (Engine.Tags (Img_Start).all); if Engine.Link_First then Engine.Output.Write (Src); if Title'Length > 0 then Engine.Output.Write (Engine.Tags (Link_Separator).all); Engine.Output.Write (Title); end if; else Engine.Output.Write (Title); Engine.Output.Write (Engine.Tags (Link_Separator).all); Engine.Output.Write (Src); end if; Engine.Output.Write (Engine.Tags (Img_End).all); Engine.Empty_Line := False; end Render_Image; -- Render a quote. procedure Render_Quote (Engine : in out Wiki_Renderer; Title : in Strings.WString; Attrs : in Attributes.Attribute_List) is Link : constant Strings.WString := Attributes.Get_Attribute (Attrs, "cite"); Lang : constant Strings.WString := Attributes.Get_Attribute (Attrs, "lang"); begin Engine.Output.Write (Engine.Tags (Quote_Start).all); Engine.Output.Write (Title); if Engine.Allow_Link_Language and Lang'Length > 0 then Engine.Output.Write (Engine.Tags (Quote_Separator).all); Engine.Output.Write (Lang); end if; if Link'Length > 0 then if Lang'Length = 0 then Engine.Output.Write (Engine.Tags (Quote_Separator).all); end if; Engine.Output.Write (Engine.Tags (Quote_Separator).all); Engine.Output.Write (Link); end if; Engine.Output.Write (Engine.Tags (Quote_End).all); Engine.Empty_Line := False; end Render_Quote; -- Set the text style format. procedure Set_Format (Engine : in out Wiki_Renderer; Format : in Format_Map) is begin if Engine.Format /= Format then for I in Format'Range loop if Format (I) xor Engine.Format (I) then if Format (I) then Engine.Output.Write (Engine.Style_Start_Tags (I).all); Engine.Format (I) := True; else Engine.Output.Write (Engine.Style_End_Tags (I).all); Engine.Format (I) := False; end if; end if; end loop; Engine.Need_Space := False; end if; end Set_Format; -- Add a text block with the given format. procedure Render_Text (Engine : in out Wiki_Renderer; Text : in Strings.WString; Format : in Format_Map) is Start : Natural := Text'First; Last : Natural := Text'Last; Apply_Format : Boolean := True; Last_Char : Strings.WChar; begin if Engine.Keep_Content > 0 or Engine.Empty_Line then while Start <= Text'Last and then Helpers.Is_Space_Or_Newline (Text (Start)) loop Start := Start + 1; end loop; end if; if Engine.Keep_Content > 0 then while Last >= Start and then Helpers.Is_Space_Or_Newline (Text (Last)) loop Last := Last - 1; end loop; if Engine.Need_Space then Append (Engine.Content, ' '); Engine.Need_Space := False; end if; Append (Engine.Content, Text (Start .. Last)); Engine.Need_Space := True; else -- Some rules: -- o avoid several consecutive LF -- o drop spaces at beginning of a text (because it can be interpreted) -- o emit the blockquote if we are at beginning of a new line -- o emit the list item if we are at beginning of a new line Last_Char := ' '; for I in Start .. Last loop Last_Char := Text (I); if Helpers.Is_Newline (Last_Char) then if Engine.Empty_Line = False then if Apply_Format and then Engine.Format /= Empty_Formats then Engine.Set_Format (Empty_Formats); end if; Engine.Write_Optional_Space; Engine.New_Line; end if; elsif not Engine.Empty_Line or else not Helpers.Is_Space (Last_Char) then if Engine.Empty_Line and Engine.Quote_Level > 0 then for Level in 1 .. Engine.Quote_Level loop Engine.Output.Write (Engine.Tags (Blockquote_Start).all); end loop; end if; if Engine.In_List and Engine.UL_List_Level + Engine.OL_List_Level > 0 then if Engine.UL_List_Level > Engine.OL_List_Level then Engine.Add_List_Item (Engine.UL_List_Level, False); else Engine.Add_List_Item (Engine.OL_List_Level, True); end if; Engine.In_List := False; end if; if Apply_Format then Engine.Set_Format (Format); Apply_Format := False; Engine.Write_Optional_Space; end if; if Ada.Strings.Wide_Wide_Maps.Is_In (Last_Char, Engine.Escape_Set) then Engine.Output.Write (Engine.Tags (Escape_Rule).all); end if; if Last_Char = NBSP then Last_Char := ' '; end if; Engine.Output.Write (Last_Char); Engine.Empty_Line := False; end if; end loop; if not Helpers.Is_Space_Or_Newline (Last_Char) and not Engine.Empty_Line then Engine.Need_Space := True; end if; end if; end Render_Text; -- ------------------------------ -- Render a text block that is pre-formatted. -- ------------------------------ procedure Render_Preformatted (Engine : in out Wiki_Renderer; Text : in Strings.WString; Format : in Strings.WString) is pragma Unreferenced (Format); Col : Natural := 2; begin Engine.New_Line; Engine.Output.Write (Engine.Tags (Preformat_Start).all); for I in Text'Range loop if Helpers.Is_Newline (Text (I)) then Col := 0; else Col := Col + 1; end if; if I = Text'First and then Col > 0 then Engine.Output.Write (LF); Col := 0; end if; Engine.Output.Write (Text (I)); end loop; if Col /= 0 then Engine.New_Line; end if; Engine.Output.Write (Engine.Tags (Preformat_End).all); Engine.New_Line; end Render_Preformatted; procedure Start_Keep_Content (Engine : in out Wiki_Renderer) is begin Engine.Keep_Content := Engine.Keep_Content + 1; if Engine.Keep_Content = 1 then Engine.Content := Strings.To_UString (""); Engine.Need_Space := False; end if; end Start_Keep_Content; procedure Render_Tag (Engine : in out Wiki_Renderer; Doc : in Documents.Document; Node : in Nodes.Node_Type) is begin case Node.Tag_Start is when BR_TAG => Engine.Output.Write (Engine.Tags (Line_Break).all); Engine.Empty_Line := False; Engine.Need_Space := False; return; when HR_TAG => Engine.Close_Paragraph; Engine.Output.Write (Engine.Tags (Horizontal_Rule).all); return; when H1_TAG | H2_TAG | H3_TAG | H4_TAG | H5_TAG | H6_TAG => Engine.Start_Keep_Content; when IMG_TAG => Engine.Render_Image (Title => Get_Attribute (Node.Attributes, "alt"), Attrs => Node.Attributes); when A_TAG | Q_TAG => Engine.Start_Keep_Content; when B_TAG | EM_TAG | STRONG_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (BOLD) := True; end if; when I_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (ITALIC) := True; end if; when U_TAG | TT_TAG | CODE_TAG | KBD_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (CODE) := True; end if; when SUP_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (SUPERSCRIPT) := True; end if; when SUB_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (SUBSCRIPT) := True; end if; when P_TAG => Engine.Set_Format (Empty_Formats); Engine.Close_Paragraph; Engine.Need_Separator_Line; when PRE_TAG => Engine.Start_Keep_Content; when UL_TAG => if Engine.UL_List_Level = 0 then Engine.Need_Separator_Line; end if; Engine.Close_Paragraph; Engine.UL_List_Level := Engine.UL_List_Level + 1; when OL_TAG => if Engine.OL_List_Level = 0 then Engine.Need_Separator_Line; end if; Engine.Close_Paragraph; Engine.OL_List_Level := Engine.OL_List_Level + 1; when LI_TAG => Engine.In_List := True; if Engine.UL_List_Level + Engine.OL_List_Level = 0 then Engine.Need_Separator_Line; Engine.Close_Paragraph; end if; when BLOCKQUOTE_TAG => Engine.Set_Format (Empty_Formats); Engine.Need_Separator_Line; Engine.Close_Paragraph; Engine.Quote_Level := Engine.Quote_Level + 1; if Engine.Html_Blockquote then -- Make sure there is en empty line before the HTML <blockquote>. Engine.Output.Write (LF & "<blockquote>" & LF); end if; when others => null; end case; Engine.Render (Doc, Node.Children); case Node.Tag_Start is when H1_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Header (Strings.To_WString (Engine.Content), 1); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when H2_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Header (Strings.To_WString (Engine.Content), 2); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when H3_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Header (Strings.To_WString (Engine.Content), 3); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when H4_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Header (Strings.To_WString (Engine.Content), 4); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when H5_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Header (Strings.To_WString (Engine.Content), 5); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when H6_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Header (Strings.To_WString (Engine.Content), 6); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when A_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Link (Name => Strings.To_WString (Engine.Content), Attrs => Node.Attributes); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when Q_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Quote (Title => Strings.To_WString (Engine.Content), Attrs => Node.Attributes); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when P_TAG => Engine.Set_Format (Empty_Formats); Engine.New_Line; when B_TAG | EM_TAG | STRONG_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (BOLD) := False; end if; when I_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (ITALIC) := False; end if; when U_TAG | TT_TAG | CODE_TAG | KBD_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (CODE) := False; end if; when SUP_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (SUPERSCRIPT) := False; end if; when SUB_TAG => if Engine.Keep_Content = 0 then Engine.Current_Style (SUBSCRIPT) := False; end if; when PRE_TAG => if Engine.Keep_Content = 1 then Engine.Need_Space := False; Engine.Render_Preformatted (Strings.To_WString (Engine.Content), ""); end if; Engine.Keep_Content := Engine.Keep_Content - 1; when UL_TAG => Engine.UL_List_Level := Engine.UL_List_Level - 1; if Engine.UL_List_Level = 0 then Engine.Need_Separator_Line; end if; when OL_TAG => Engine.OL_List_Level := Engine.OL_List_Level - 1; if Engine.UL_List_Level = 0 then Engine.Need_Separator_Line; end if; when LI_TAG => Engine.In_List := False; if not Engine.Empty_Line then Engine.New_Line; end if; when BLOCKQUOTE_TAG => Engine.Set_Format (Empty_Formats); Engine.Need_Separator_Line; Engine.Quote_Level := Engine.Quote_Level - 1; Engine.Need_Space := False; if Engine.Html_Blockquote then -- Make sure there is an empty line after the HTML </blockquote>. Engine.Output.Write ("</blockquote>" & LF & LF); end if; when others => null; end case; end Render_Tag; -- ------------------------------ -- Finish the document after complete wiki text has been parsed. -- ------------------------------ overriding procedure Finish (Engine : in out Wiki_Renderer; Doc : in Documents.Document) is pragma Unreferenced (Doc); begin Engine.Set_Format (Empty_Formats); end Finish; procedure Close_Paragraph (Engine : in out Wiki_Renderer) is Need_Newline : constant Boolean := Engine.Need_Newline; begin if not Engine.Empty_Line then Engine.New_Line; end if; Engine.Need_Space := False; Engine.Has_Item := False; if Need_Newline and not Engine.Empty_Previous_Line then Engine.New_Line; end if; end Close_Paragraph; end Wiki.Render.Wiki;
procedure procedure_instantiation is begin begin declare generic procedure proc(pfp:in integer); procedure proc(pfp:in integer) is begin null; end proc; begin declare procedure p is new proc; begin null; end; end; end; end procedure_instantiation;
-- cerner_2^5_2018 with Ada.Command_line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; procedure EvenOrOddInputs is begin for A in 1..Argument_Count loop declare N : Integer := Integer'Value(Argument(A)); begin if N rem 2 = 0 then Put_Line ("Even"); elsif N rem 2 /= 0 then Put_Line ("Odd"); else Put_Line ("This is very odd!"); end if; end; end loop; New_Line; end EvenOrOddInputs;
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ package body Natools.S_Expressions.Atom_Buffers is procedure Preallocate (Buffer : in out Atom_Buffer; Length : in Count) is Old_Size, New_Size : Count := 0; begin if Buffer.Used + Length <= Buffer.Available then return; end if; Old_Size := Buffer.Available; New_Size := Buffer.Used + Length; if Buffer.Ref.Is_Empty then declare function Create return Atom; function Create return Atom is begin return Atom'(1 .. New_Size => <>); end Create; begin Buffer.Ref.Replace (Create'Access); end; else declare function Create return Atom; Old_Accessor : constant Atom_Refs.Accessor := Buffer.Ref.Query; function Create return Atom is begin return Result : Atom (1 .. New_Size) do Result (1 .. Old_Size) := Old_Accessor.Data.all; end return; end Create; begin Buffer.Ref.Replace (Create'Access); end; end if; Buffer.Available := New_Size; end Preallocate; procedure Append (Buffer : in out Atom_Buffer; Data : in Atom) is begin if Data'Length > 0 then Preallocate (Buffer, Data'Length); Buffer.Ref.Update.Data.all (Buffer.Used + 1 .. Buffer.Used + Data'Length) := Data; Buffer.Used := Buffer.Used + Data'Length; end if; end Append; procedure Append (Buffer : in out Atom_Buffer; Data : in Octet) is begin Preallocate (Buffer, 1); Buffer.Ref.Update.Data.all (Buffer.Used + 1) := Data; Buffer.Used := Buffer.Used + 1; end Append; procedure Append_Reverse (Buffer : in out Atom_Buffer; Data : in Atom) is procedure Process (Target : in out Atom); procedure Process (Target : in out Atom) is begin for I in reverse Data'Range loop Buffer.Used := Buffer.Used + 1; Target (Buffer.Used) := Data (I); end loop; end Process; begin Preallocate (Buffer, Data'Length); Buffer.Ref.Update (Process'Access); end Append_Reverse; procedure Invert (Buffer : in out Atom_Buffer) is procedure Process (Data : in out Atom); procedure Process (Data : in out Atom) is Low : Count := Data'First; High : Count := Buffer.Used; Tmp : Octet; begin while Low < High loop Tmp := Data (Low); Data (Low) := Data (High); Data (High) := Tmp; Low := Low + 1; High := High - 1; end loop; end Process; begin if not Buffer.Ref.Is_Empty then Buffer.Ref.Update (Process'Access); end if; end Invert; function Length (Buffer : Atom_Buffer) return Count is begin return Buffer.Used; end Length; function Capacity (Buffer : Atom_Buffer) return Count is begin return Buffer.Available; end Capacity; function Data (Buffer : Atom_Buffer) return Atom is begin if Buffer.Ref.Is_Empty then pragma Assert (Buffer.Available = 0 and Buffer.Used = 0); return Null_Atom; else return Buffer.Ref.Query.Data.all (1 .. Buffer.Used); end if; end Data; function Raw_Query (Buffer : Atom_Buffer) return Atom_Refs.Accessor is function Create return Atom; function Create return Atom is begin return Null_Atom; end Create; begin if Buffer.Ref.Is_Empty then declare Tmp_Ref : constant Atom_Refs.Reference := Atom_Refs.Create (Create'Access); begin return Tmp_Ref.Query; end; else return Buffer.Ref.Query; end if; end Raw_Query; procedure Query (Buffer : in Atom_Buffer; Process : not null access procedure (Data : in Atom)) is begin if Buffer.Ref.Is_Empty then Process.all (Null_Atom); else Process.all (Buffer.Ref.Query.Data.all (1 .. Buffer.Used)); end if; end Query; procedure Peek (Buffer : in Atom_Buffer; Data : out Atom; Length : out Count) is Transmit : constant Count := Count'Min (Data'Length, Buffer.Used); begin Length := Buffer.Used; if Buffer.Ref.Is_Empty then pragma Assert (Length = 0); null; else Data (Data'First .. Data'First + Transmit - 1) := Buffer.Ref.Query.Data.all (1 .. Transmit); end if; end Peek; function Element (Buffer : Atom_Buffer; Position : Count) return Octet is begin return Buffer.Ref.Query.Data.all (Position); end Element; procedure Pop (Buffer : in out Atom_Buffer; Data : out Octet) is begin Data := Buffer.Ref.Query.Data.all (Buffer.Used); Buffer.Used := Buffer.Used - 1; end Pop; procedure Hard_Reset (Buffer : in out Atom_Buffer) is begin Buffer.Ref.Reset; Buffer.Available := 0; Buffer.Used := 0; end Hard_Reset; procedure Soft_Reset (Buffer : in out Atom_Buffer) is begin Buffer.Used := 0; end Soft_Reset; overriding procedure Write (Buffer : in out Atom_Buffer; Item : in Ada.Streams.Stream_Element_Array) renames Append; overriding procedure Read (Buffer : in out Atom_Buffer; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is begin if Item'Length < Buffer.Used then declare Mutator : constant Atom_Refs.Mutator := Buffer.Ref.Update; begin Last := Item'Last; Item := Mutator.Data.all (1 .. Item'Length); Buffer.Used := Buffer.Used - Item'Length; Mutator.Data.all (1 .. Buffer.Used) := Mutator.Data.all (Item'Length + 1 .. Item'Length + Buffer.Used); end; else Last := Item'First + Buffer.Used - 1; Item (Item'First .. Last) := Buffer.Ref.Query.Data.all (1 .. Buffer.Used); Buffer.Used := 0; end if; end Read; end Natools.S_Expressions.Atom_Buffers;
generic MAX_TEXT_LENGTH: POSITIVE; package GEN_TEXT_HANDLER is subtype TEXT_LENGTH is NATURAL range 0..MAX_TEXT_LENGTH; type TEXT(LENGTH: TEXT_LENGTH := 0) is private; private type TEXT(LENGTH: TEXT_LENGTH := 0) is record IMAGE: STRING(1..LENGTH); end record; end GEN_TEXT_HANDLER; package body GEN_TEXT_HANDLER is end GEN_TEXT_HANDLER; with GEN_TEXT_HANDLER; package TOKEN_TEXT is MAX_TOKEN_LENGTH: constant := 512; package TEXT_HANDLER is new GEN_TEXT_HANDLER(MAX_TOKEN_LENGTH); end TOKEN_TEXT; with TOKEN_TEXT; use TOKEN_TEXT; procedure MAIN is use TEXT_HANDLER; TOKEN : TEXT; begin -- MAIN null; end MAIN;
---------------------------------------------------------------------------- -- Generic Command Line Parser (gclp) -- -- Copyright (C) 2012, Riccardo Bernardini -- -- This file is part of gclp. -- -- gclp 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. -- -- gclp 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 gclp. If not, see <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- -- -- <summary> -- <p>This is a package implementing a simple-to-use command line -- parser. Yes, I know, everyone makes his/her own command line parser... -- so, I wrote mine. As they say, every open source project starts -- with a programmer that schratches its own itch. So I did... If -- you find this useful, you are welcome to use it.</p> -- -- <p>The ideas behind this package are the following -- -- <itemize> -- <item> <p>Parameters are nominal, non positional. The syntax is of -- "named parameter" type, that is, each command line parameter is -- expected to have thefollowing format</p> -- -- <center>label ['=' value]</center> -- -- <p>where "label" is any string without '='.</p></item> -- -- <item><p> Parsed value are processed by "parameter handlers." A -- parameter handler is a descendant of Abstract_Parameter_Handler. The -- operations required to a parameter handler are -- -- [Receive] Used to give name, value and position of the parameter -- to the handler that can do whatever it wants with them. Usually -- it will convert the value to an internal format and store the -- result. -- -- [Is_Set] Return true if Receive has been called at least once. I could -- not find a way to implement this in the root class, so it is the -- duty of the concrete handler to define this. I do not like this -- very much, but it is the "least bad" solution. -- -- [Reusable] Return true if Receive can be called more than once. -- Usually only one instance of a parameter is ammitted on a -- command line, but every now and then we can meet exceptions. -- -- </p></item> -- </itemize> -- </p> -- The names of the accepted parameters are given to the parser by means -- of the Add_Parameter procedure by specifying -- -- + The parameter name -- -- + A default value (if needed) -- -- + What to do if the parameter is missing -- -- + The handler to be used when the parameter is found -- -- In order to parse the command line it suffices to call Parse_Command_Line -- giving as argument the Line_Parser initialized with the parameter -- description as said above. For every parameter found, the Receive -- procedure of the corresponding handler is called. If at the end -- of the parsing there are some optional parameters that were missing -- from the command line, the corresponding handlers are called with -- the default parameter. -- </summary> with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Containers.Vectors; with Ada.Containers.Indefinite_Vectors; with Ada.Containers.Indefinite_Ordered_Maps; package Line_Parsers is use Ada.Strings.Unbounded; type Abstract_Parameter_Handler is interface; type Handler_Access is access all Abstract_Parameter_Handler'Class; -- Return True if the handler already received at least a value function Is_Set (Handler : Abstract_Parameter_Handler) return Boolean is abstract; -- Return True if the handler can handle more than one value. -- Often it does not make sense to give twice the same parameter, -- but in few cases it can be useful function Reusable (Handler : Abstract_Parameter_Handler) return Boolean is abstract; -- Called to give to the handler a parameter read from command line -- Name is the name of the parameter (the part before '='), Value -- is the part after '=' and Position is the position of the -- parameter on the command line, with the same convention of -- Command_Line.Argument procedure Receive (Handler : in out Abstract_Parameter_Handler; Name : String; Value : String; Position : Natural) is abstract with Pre'Class => not Handler.Is_Set or Handler.Reusable, Post'Class => Handler.Is_Set; No_Position : constant Natural := 0; type Line_Parser (<>) is private; -- Use case_sensitive = False if you want case insensitive option matching. -- For example, if you set this to False, "input", "Input", "INPUT" -- and "InPuT" will be equivalent names for the option "input" function Create (Case_Sensitive : Boolean := True; Normalize_Name : Boolean := True; Help_Line : String := "") return Line_Parser; type Missing_Action is (Die, Use_Default, Ignore); -- Possibile alternatives about what to do if a parameter is missing -- -- [Die] The parameter is mandatory. If it is missing, an -- exception with explicative message is raised -- -- [Use_Default] The parameter is optional. If it is missing, the -- corresponding callback function is called with the -- specified default value (see record -- Parameter_Descriptor in the following) -- -- [Ignore] The parameter is optional. If it is missing, nothing -- is done -- <description>Record holding the description of a parameter. The fields -- should be self-explenatory (I hope). The only field that needs some -- explanation is Name since it allows to specify more than one -- name for each parameter. The syntax is very simple: just separate -- the names with commas. For example, if Name is "f,filename,input" -- one can use on the command line, with the same effect f=/tmp/a.txt or -- filename=/tmp/a.txt or input=/tmp/a.txt. Spaces at both ends of -- the label name are trimmed, so that, for example, "f,filename,input" -- is equivalent to "f , filename ,input " -- </description> procedure Add_Parameter (Parser : in out Line_Parser; Name : String; If_Missing : Missing_Action := Ignore; Default : String; Handler : Handler_Access); package String_Vectors is new Ada.Containers.Indefinite_Vectors (Index_Type => Positive, Element_Type => String); procedure Parse_Command_Line (Parser : Line_Parser; Extend_By : String_Vectors.Vector := String_Vectors.Empty_Vector; Help_Output : Ada.Text_IO.File_Type := Ada.Text_IO.Standard_Error); -- Main exported method. It parses the command line and it writes -- the result in Result. If some error is encountered, Bad_Command -- is raised with an explicative exception message. If Help_Line is -- not empty, it is written to Help_Output in case of error. function Slurp (Filename : String; Skip_Comments : Boolean := True; Comment_Char : Character := '#'; Comment_Strict : Boolean := False) return String_Vectors.Vector; -- Read the specified filename and returns a vector with the file -- lines. If Skip_Comments is True, lines beginning with Comment_Char -- are ignored. If Comment_Strict is True Comment_Char must be at -- the beginning of the line, otherwise initial spaces are allowed. Bad_Command : exception; -- function Normalized_Form (X : String) return String; private type Parameter_Index is range 1 .. Integer'Last; type Parameter_Descriptor is record Name : Unbounded_String; Handler : Handler_Access; If_Missing : Missing_Action := Ignore; Standard_Name : Unbounded_String; Default : Unbounded_String; end record; package Parameter_Vectors is new Ada.Containers.Vectors (Index_Type => Parameter_Index, Element_Type => Parameter_Descriptor); -- In order to handle parameter aliases (see comments in the specs) -- we keep a table that maps parameter names to parameter "index" package Name_To_Index_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String, Element_Type => Parameter_Index); type Line_Parser is record Case_Sensitive : Boolean; Normalize_Name : Boolean; Help_Line : Unbounded_String; Parameters : Parameter_Vectors.Vector; Name_Table : Name_To_Index_Maps.Map; end record; end Line_Parsers;
with Ada.Text_IO; package body my_lib is procedure Do_Stuff is begin Ada.Text_IO.Put_Line("Hello DLL land!"); end Do_Stuff; -- procedure Initialize_API is -- procedure Adainit; -- pragma Import(C, Adainit); -- begin -- Adainit; -- end Initialize_API; -- procedure Finalize_API is -- procedure Adafinal; -- pragma Import(C, Adafinal); -- begin -- Adafinal; -- end Finalize_API; end my_lib;
with System; with STM32.Device; use STM32.Device; with STM32_SVD; use STM32_SVD; with STM32_SVD.PKA; use STM32_SVD.PKA; generic Curve_Name : String; Num_Bits : UInt32; Hash_Size : UInt32 := 256; package STM32.PKA is N_By_8 : constant UInt32 := (Num_Bits / 8) + (if (Num_Bits mod 8) > 0 then 1 else 0); N_By_32 : constant UInt32 := (Num_Bits / 32) + (if (Num_Bits mod 32) > 0 then 1 else 0); Rem_By_32 : constant UInt32 := (Num_Bits mod 32); Hash_N_By_8 : UInt32 := Hash_Size / 8; subtype ECDSA_Array is UInt8_Array (0 .. Integer (N_By_8 - 1)); subtype ECDSA_Key is ECDSA_Array; subtype ECDSA_Hash is UInt8_Array (0 .. Integer (Hash_N_By_8 - 1)); subtype ECDSA_Rand is ECDSA_Array; type ECDSA_Signature is record R : ECDSA_Array; S : ECDSA_Array; end record; type ECDSA_PublicKey is record X : ECDSA_Array; Y : ECDSA_Array; end record; subtype ECDSA_String is String (1 .. Integer ((2 * N_By_8))); subtype ECDSA_KeyStr is ECDSA_String; subtype ECDSA_HashStr is String (1 .. Integer ((2 * Hash_N_By_8))); subtype ECDSA_RandStr is ECDSA_String; type ECDSA_SignatureStr is record R : ECDSA_String; S : ECDSA_String; end record; type ECDSA_PointStr is record X : ECDSA_String; Y : ECDSA_String; end record; subtype ECDSA_PublicKeyStr is ECDSA_PointStr; subtype Digest_Buffer is UInt8_Array (0 .. Integer (N_By_8 - 1)); subtype Digest_BufferStr is String (1 .. Integer ((2 * N_By_8))); PKA : aliased PKA_Peripheral with Import, Volatile, Address => S_NS_Periph (PKA_Base); -- PKA RAM -- The PKA RAM is mapped at the offset address of 0x0400 compared to the PKA base -- vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -- address. Only 32-bit word single accesses are supported, through PKA.AHB interface. -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- RAM size is 3576 bytes (max word offset: 0x11F4) type ECDSA_Sign_Ram is record Order_Num_Bits : UInt32; Mod_Num_Bits : UInt32; A_Coeff_Sign : UInt32; A_Coeff : UInt32_Array (0 .. 20); Mod_GF : UInt32_Array (0 .. 41); K : UInt32_Array (0 .. 20); X : UInt32_Array (0 .. 20); Y : UInt32_Array (0 .. 20); R : UInt32_Array (0 .. 20); S : UInt32_Array (0 .. 20); B_Coeff : UInt32_Array (0 .. 20); Hash : UInt32_Array (0 .. 20); PrivateKey : UInt32_Array (0 .. 21); Order_N : UInt32_Array (0 .. 20); Error : UInt32; Final_Pt_X : UInt32_Array (0 .. 20); Final_Pt_Y : UInt32_Array (0 .. 20); end record; for ECDSA_Sign_Ram use record Order_Num_Bits at 16#0400# range 0 .. 31; Mod_Num_Bits at 16#0404# range 0 .. 31; A_Coeff_Sign at 16#0408# range 0 .. 31; A_Coeff at 16#040c# range 0 .. 671; Mod_GF at 16#0460# range 0 .. 1343; K at 16#0508# range 0 .. 671; X at 16#055c# range 0 .. 671; Y at 16#05b0# range 0 .. 671; R at 16#0700# range 0 .. 671; S at 16#0754# range 0 .. 671; B_Coeff at 16#07fc# range 0 .. 671; Hash at 16#0de8# range 0 .. 671; PrivateKey at 16#0e3c# range 0 .. 703; Order_N at 16#0e94# range 0 .. 671; Error at 16#0ee8# range 0 .. 31; Final_Pt_X at 16#103c# range 0 .. 671; Final_Pt_Y at 16#1090# range 0 .. 671; end record; type ECDSA_Verify_Ram is record Order_Num_Bits : UInt32; A_Coeff_Sign : UInt32; A_Coeff : UInt32_Array (0 .. 20); Mod_Num_Bits : UInt32; Mod_GF : UInt32_Array (0 .. 61); Result : UInt32; IP_X : UInt32_Array (0 .. 20); IP_Y : UInt32_Array (0 .. 20); S : UInt32_Array (0 .. 20); Order_N : UInt32_Array (0 .. 20); PK_X : UInt32_Array (0 .. 20); PK_Y : UInt32_Array (0 .. 20); Hash : UInt32_Array (0 .. 20); R : UInt32_Array (0 .. 20); end record; for ECDSA_Verify_Ram use record Order_Num_Bits at 16#0404# range 0 .. 31; A_Coeff_Sign at 16#045c# range 0 .. 31; A_Coeff at 16#0460# range 0 .. 671; Mod_Num_Bits at 16#04b4# range 0 .. 31; Mod_GF at 16#04b8# range 0 .. 1983; Result at 16#05b0# range 0 .. 31; IP_X at 16#05e8# range 0 .. 671; IP_Y at 16#063c# range 0 .. 671; S at 16#0a44# range 0 .. 671; Order_N at 16#0d5c# range 0 .. 671; PK_X at 16#0f40# range 0 .. 671; PK_Y at 16#0f94# range 0 .. 671; Hash at 16#0fe8# range 0 .. 671; R at 16#1098# range 0 .. 671; end record; type ECDSA_Ram is record Op_Len : UInt32; N_Bits : UInt32; M_Param : UInt32_Array (0 .. 20); A : UInt32_Array (0 .. 20); T1 : UInt32_Array (0 .. 20); T2 : UInt32_Array (0 .. 20); T3 : UInt32_Array (0 .. 20); B : UInt32_Array (0 .. 20); Result : UInt32_Array (0 .. 20); Mod_GF : UInt32_Array (0 .. 20); end record; for ECDSA_Ram use record Op_Len at 16#0400# range 0 .. 31; N_Bits at 16#0404# range 0 .. 31; M_Param at 16#0594# range 0 .. 671; A at 16#08b4# range 0 .. 671; T1 at 16#0908# range 0 .. 671; T2 at 16#095c# range 0 .. 671; T3 at 16#09b0# range 0 .. 671; B at 16#0a44# range 0 .. 671; Result at 16#0bd0# range 0 .. 671; Mod_GF at 16#0d5c# range 0 .. 671; end record; type ECDSA_Point_Ram is record Scalar_Len : UInt32; N_Bits : UInt32; A_Sign : UInt32; A_Coeff : UInt32_Array (0 .. 20); Curve_Mod : UInt32_Array (0 .. 20); Scalar : UInt32_Array (0 .. 20); X : UInt32_Array (0 .. 20); Y : UInt32_Array (0 .. 20); end record; for ECDSA_Point_Ram use record Scalar_Len at 16#0400# range 0 .. 31; N_Bits at 16#0404# range 0 .. 31; A_Sign at 16#0408# range 0 .. 31; A_Coeff at 16#040c# range 0 .. 671; Curve_Mod at 16#0460# range 0 .. 671; Scalar at 16#0508# range 0 .. 671; X at 16#055c# range 0 .. 671; Y at 16#05b0# range 0 .. 671; end record; type ECDSA_Point_Check_Ram is record Result : UInt32; N_Bits : UInt32; A_Sign : UInt32; A_Coeff : UInt32_Array (0 .. 20); Curve_Mod : UInt32_Array (0 .. 20); X : UInt32_Array (0 .. 20); Y : UInt32_Array (0 .. 20); B_Coeff : UInt32_Array (0 .. 20); end record; for ECDSA_Point_Check_Ram use record Result at 16#0400# range 0 .. 31; N_Bits at 16#0404# range 0 .. 31; A_Sign at 16#0408# range 0 .. 31; A_Coeff at 16#040c# range 0 .. 671; Curve_Mod at 16#0460# range 0 .. 671; X at 16#055c# range 0 .. 671; Y at 16#05b0# range 0 .. 671; B_Coeff at 16#07fc# range 0 .. 671; end record; type All_PKA_Ram is record RAM : UInt32_Array (0 .. 893); end record; for All_PKA_Ram use record RAM at 16#400# range 0 .. 28607; end record; type PKA_Parameters is ( Montgomery_Parameter_Computation_With_Modular_Exponentiation, Montgomery_Parameter_Computation_Only, Modular_Exponentiation_Only, RSA_CRT_Exponentiation, Modular_Inversion, Arithmetic_Addition, Arithmetic_Subtraction, Arithmetic_Multiplication, Arithmetic_Comparison, Modular_Reduction, Modular_Addition, Modular_Subtraction, Montgomery_Multiplication, FP_Scalar_Multiplication, FP_Scalar_Multiplication_Fast, ECDSA_Sign, ECDSA_Verification, Point_On_Elliptic_Curve_Fp_Check) with Size => 6; for PKA_Parameters use ( Montgomery_Parameter_Computation_With_Modular_Exponentiation => 2#000000#, Montgomery_Parameter_Computation_Only => 2#000001#, Modular_Exponentiation_Only => 2#000010#, RSA_CRT_Exponentiation => 2#000111#, Modular_Inversion => 2#001000#, Arithmetic_Addition => 2#001001#, Arithmetic_Subtraction => 2#001010#, Arithmetic_Multiplication => 2#001011#, Arithmetic_Comparison => 2#001100#, Modular_Reduction => 2#001101#, Modular_Addition => 2#001110#, Modular_Subtraction => 2#001111#, Montgomery_Multiplication => 2#010000#, FP_Scalar_Multiplication => 2#100000#, FP_Scalar_Multiplication_Fast => 2#100010#, ECDSA_Sign => 2#100100#, ECDSA_Verification => 2#100110#, Point_On_Elliptic_Curve_Fp_Check => 2#101000#); type CurveData is record P : String (1 .. Integer (N_By_8 * 2)); X : String (1 .. Integer (N_By_8 * 2)); Y : String (1 .. Integer (N_By_8 * 2)); A : String (1 .. Integer (N_By_8 * 2)); B : String (1 .. Integer (N_By_8 * 2)); N : String (1 .. Integer (N_By_8 * 2)); end record; type Init_Mode is (Signing, Validation, Point_Check, Arithmetic, Field_Arithmetic); procedure Copy_S_To_U32 (S : String; To : out UInt32_Array); procedure Copy_U8_To_U32 (From : UInt8_Array; To : out UInt32_Array); procedure Copy_U32_To_U8 (From : UInt32_Array; To : out UInt8_Array); procedure Copy_U8_To_S (From : UInt8; To : out ECDSA_String; Offset : UInt32); procedure Copy_U32_To_S (From : UInt32_Array; To : out ECDSA_String); procedure Enable_Pka; procedure Disable_Pka; procedure StartPKA (Mode : PKA_Parameters); function Check_Errors return Boolean; procedure Clear_Flags; procedure Clear_Ram; function Common_Init (Mode : Init_Mode) return CurveData; function Normalize (Digest : ECDSA_Hash) return Digest_Buffer; function Normalize (Digest : ECDSA_HashStr) return Digest_BufferStr; function ECDSA_Sign (Private_Key : ECDSA_Key; H : ECDSA_Hash; K : ECDSA_Rand; Signature : out ECDSA_Signature) return Boolean; function ECDSA_Sign (Private_Key : ECDSA_KeyStr; H : ECDSA_HashStr; K : ECDSA_RandStr; Signature : out ECDSA_SignatureStr) return Boolean; function ECDSA_Valid (Public_Key : ECDSA_PublicKey; Digest : ECDSA_Hash; Signature : ECDSA_Signature) return Boolean; function ECDSA_Valid (Public_Key : ECDSA_PublicKeyStr; Digest : ECDSA_HashStr; Signature : ECDSA_SignatureStr) return Boolean; procedure ECDSA_Math (Work : String; A : ECDSA_String; B : ECDSA_String := (1 => '0', others => '0'); C : ECDSA_String := (1 => '0', others => '0'); O1 : out ECDSA_String; O2 : out ECDSA_String); procedure ECDSA_Point_Mult (X : ECDSA_String; Y : ECDSA_String; Scalar : ECDSA_String; X_Res : out ECDSA_String; Y_Res : out ECDSA_String); procedure ECDSA_Point_Mult (Scalar : ECDSA_String; X_Res : out ECDSA_String; Y_Res : out ECDSA_String); function ECDSA_Point_On_Curve (Point : ECDSA_PointStr) return Boolean; function Make_Random_Group_String (NClamp : Boolean := False) return ECDSA_String; function Make_Public_Key_String (PrivateKey : ECDSA_String) return ECDSA_PublicKeyStr; end STM32.PKA;
----------------------------------------------------------------------- -- are-generator-go-tests -- Tests for Go generator -- Copyright (C) 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Directories; with Util.Files; with Util.Test_Caller; package body Are.Generator.Go.Tests is Expect_Dir : constant String := "regtests/expect/go/"; function Tool return String; package Caller is new Util.Test_Caller (Test, "Are.Generator.Go"); function Tool return String is begin return "bin/are" & Are.Testsuite.EXE; end Tool; procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Are.Generate_Go1", Test_Generate_Go1'Access); Caller.Add_Test (Suite, "Test Are.Generate_Go2", Test_Generate_Go2'Access); Caller.Add_Test (Suite, "Test Are.Generate_Go3", Test_Generate_Go3'Access); end Add_Tests; procedure Test_Generate_Go1 (T : in out Test) is Dir : constant String := Util.Tests.Get_Test_Path (""); Target : constant String := Util.Files.Compose (Dir, "resources1/resources1.go"); Web : constant String := "regtests/files/test-c-1/web"; Result : Ada.Strings.Unbounded.Unbounded_String; begin -- Generate the resources1.go file T.Execute (Tool & " --lang=go -o " & Dir & " --name-access --resource=Resources1 --fileset '**/*' " & Web, Result); T.Assert (Ada.Directories.Exists (Target), "Resource file 'resources1/resources1.go' not generated"); Are.Testsuite.Assert_Equal_Files (T => T, Expect => Util.Tests.Get_Path (Expect_Dir & "resources1.go"), Test => Target, Message => "Invalid Go generation"); end Test_Generate_Go1; procedure Test_Generate_Go2 (T : in out Test) is Dir : constant String := Util.Tests.Get_Test_Path (""); Target : constant String := Util.Files.Compose (Dir, "resources2/resources2.go"); Web : constant String := "regtests/files/test-ada-2"; Rule : constant String := "regtests/files/test-ada-2/package.xml"; Result : Ada.Strings.Unbounded.Unbounded_String; begin -- Generate the resources1.go file T.Execute (Tool & " --lang=go -o " & Dir & " --name-access --rule=" & Rule & " " & Web, Result); T.Assert (Ada.Directories.Exists (Target), "Resource file 'resources2/resources2.go' not generated"); Are.Testsuite.Assert_Equal_Files (T => T, Expect => Util.Tests.Get_Path (Expect_Dir & "resources2.go"), Test => Target, Message => "Invalid Go generation"); end Test_Generate_Go2; procedure Test_Generate_Go3 (T : in out Test) is Dir : constant String := Util.Tests.Get_Test_Path (""); Target : constant String := Util.Files.Compose (Dir, "resource4/resource4.go"); Web : constant String := "regtests/files/test-ada-4"; Rule : constant String := "regtests/files/test-ada-4/package.xml"; Result : Ada.Strings.Unbounded.Unbounded_String; begin -- Generate the resources1.go file T.Execute (Tool & " --lang=go -o " & Dir & " --name-access --rule=" & Rule & " " & Web, Result); T.Assert (Ada.Directories.Exists (Target), "Resource file 'resource4/resource4.go' not generated"); Are.Testsuite.Assert_Equal_Files (T => T, Expect => Util.Tests.Get_Path (Expect_Dir & "resource4.go"), Test => Target, Message => "Invalid Go generation"); end Test_Generate_Go3; end Are.Generator.Go.Tests;
with Ada.Strings.Unbounded; private with Ada.Containers.Indefinite_Vectors; generic with procedure Print_Line(Indention: Natural; Line: String); package S_Expr is function "-"(S: String) return Ada.Strings.Unbounded.Unbounded_String renames Ada.Strings.Unbounded.To_Unbounded_String; function "+"(U: Ada.Strings.Unbounded.Unbounded_String) return String renames Ada.Strings.Unbounded.To_String; type Empty_Data is tagged null record; subtype Data is Empty_Data'Class; procedure Print(This: Empty_Data; Indention: Natural); -- any object form class Data knows how to print itself -- objects of class data are either List of Data or Atomic -- atomic objects hold either an integer or a float or a string type List_Of_Data is new Empty_Data with private; overriding procedure Print(This: List_Of_Data; Indention: Natural); function First(This: List_Of_Data) return Data; function Rest(This: List_Of_Data) return List_Of_Data; function Empty(This: List_Of_Data) return Boolean; type Atomic is new Empty_Data with null record; type Str_Data is new Atomic with record Value: Ada.Strings.Unbounded.Unbounded_String; Quoted: Boolean := False; end record; overriding procedure Print(This: Str_Data; Indention: Natural); type Int_Data is new Atomic with record Value: Integer; end record; overriding procedure Print(This: Int_Data; Indention: Natural); type Flt_Data is new Atomic with record Value: Float; end record; overriding procedure Print(This: Flt_Data; Indention: Natural); private package Vectors is new Ada.Containers.Indefinite_Vectors (Index_Type => Positive, Element_Type => Data); type List_Of_Data is new Empty_Data with record Values: Vectors.Vector; end record; end S_Expr;
private with Ada.Strings.Unbounded; private with Ada.Text_IO; package Test is type Test_t is range 1 .. 1_000_000; type Context_t is limited private; type Result_t is (Not_Executed, Pass, Fail, Unsupported); subtype Valid_Result_t is Result_t range Pass .. Unsupported; procedure Initialize (Test_Context : out Context_t; Program : in String; Test_DB : in String; Test_Results : in String); procedure Satisfy (Test_Context : in Context_t; Test : in Test_t; Result : in Valid_Result_t; Statement : in String := ""); procedure Check (Test_Context : in Context_t; Test : in Test_t; Condition : in Boolean; Statement : in String := ""); private package UB_Strings renames Ada.Strings.Unbounded; type Context_t is record Test_DB : UB_Strings.Unbounded_String; Test_Results : UB_Strings.Unbounded_String; Program : UB_Strings.Unbounded_String; Output_File : Ada.Text_IO.File_Type; Error_File : Ada.Text_IO.File_Type; end record; end Test;