content
stringlengths
23
1.05M
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2018 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.Video.Palettes -- -- Palettes, colours and various conversions. -------------------------------------------------------------------------------------------------------------------- with Ada.Finalization; with Ada.Iterator_Interfaces; with Interfaces.C.Pointers; package SDL.Video.Palettes is package C renames Interfaces.C; type Colour_Component is range 0 .. 255 with Size => 8, Convention => C; type Colour is record Red : Colour_Component; Green : Colour_Component; Blue : Colour_Component; Alpha : Colour_Component; end record with Convention => C_Pass_by_Copy, Size => Colour_Component'Size * 4; Null_Colour : constant Colour := Colour'(others => Colour_Component'First); type RGB_Colour is record Red : Colour_Component; Green : Colour_Component; Blue : Colour_Component; end record with Convention => C_Pass_by_Copy, Size => Colour_Component'Size * 4; Null_RGB_Colour : constant RGB_Colour := RGB_Colour'(others => Colour_Component'First); -- Cursor type for our iterator. type Cursor is private; No_Element : constant Cursor; function Element (Position : in Cursor) return Colour; function Has_Element (Position : Cursor) return Boolean; -- Create the iterator interface package. package Palette_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); type Palette is tagged limited private with Default_Iterator => Iterate, Iterator_Element => Colour, Constant_Indexing => Constant_Reference; type Palette_Access is access Palette; function Constant_Reference (Container : aliased Palette; Position : Cursor) return Colour; function Iterate (Container : Palette) return Palette_Iterator_Interfaces.Forward_Iterator'Class; function Create (Total_Colours : in Positive) return Palette; procedure Free (Container : in out Palette); Empty_Palette : constant Palette; private type Colour_Array is array (C.size_t range <>) of aliased Colour with Convention => C; package Colour_Array_Pointer is new Interfaces.C.Pointers (Index => C.size_t, Element => Colour, Element_Array => Colour_Array, Default_Terminator => Null_Colour); type Internal_Palette is record Total : C.int; Colours : Colour_Array_Pointer.Pointer; Version : Interfaces.Unsigned_32; Ref_Count : C.int; end record with Convention => C; type Internal_Palette_Access is access Internal_Palette with Convention => C; type Palette is tagged limited record Data : Internal_Palette_Access; end record; type Palette_Constant_Access is access constant Palette; type Cursor is record Container : Palette_Constant_Access; Index : Natural; Current : Colour_Array_Pointer.Pointer; end record; No_Element : constant Cursor := Cursor'(Container => null, Index => Natural'First, Current => null); Empty_Palette : constant Palette := Palette'(Data => null); end SDL.Video.Palettes;
package body problem_15 is function Solution_1 return Int128 is Solutions : array( Natural range 0 .. 20, Natural range 0 .. 20 ) of Int128; begin for I in Solutions'Range(1) loop Solutions(I, 0) := 1; end loop; for I in Solutions'Range(2) loop Solutions(0, I) := 1; end loop; for I in 1 .. Solutions'Last(1) loop for J in 1 .. Solutions'Last(2) loop Solutions(I, J) := Solutions( I-1, J) + Solutions( I, J-1); end loop; end loop; return Solutions(20, 20); end Solution_1; procedure Test_Solution_1 is Solution : constant Int128 := 137846528820; begin Assert( Solution_1 = Solution ); end Test_Solution_1; function Get_Solutions return Solution_Case is Ret : Solution_Case; begin Set_Name( Ret, "Problem 15" ); Add_Test( Ret, Test_Solution_1'Access ); return Ret; end Get_Solutions; end problem_15;
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; with Ada.Text_IO; with Ada.Streams.Stream_IO; with Ada.Assertions; with Ada.Directories; with Ada.Environment_Variables; with Platform_Info; with Registrar.Queries; with Registrar.Registration; with Registrar.Subsystems; with Registrar.Library_Units; with Workers, Workers.Reporting; with Child_Processes.Path_Searching; package body Build.Linking is New_Line: Character renames Workers.Reporting.New_Line; procedure Assert (Check: Boolean; Message: in String) renames Ada.Assertions.Assert; package Program_Paths renames Child_Processes.Path_Searching; Binder_Program: aliased constant String := (Platform_Info.Toolchain_Prefix & "gnatbind"); Binder: constant Program_Paths.Elaboration_Path_Search := Program_Paths.Initialize (Binder_Program); Linker_Program: aliased constant String := Platform_Info.Toolchain_Prefix & "gcc"; Linker: constant Program_Paths.Elaboration_Path_Search := Program_Paths.Initialize (Linker_Program); Archiver_Program: aliased constant String := Platform_Info.Toolchain_Prefix & "ar"; Archiver: constant Program_Paths.Elaboration_Path_Search := Program_Paths.Initialize (Archiver_Program); -- -- Scan_ALI_Order -- type Scan_ALI_Order is new Workers.Work_Order with record Target: Registrar.Library_Units.Library_Unit; end record; overriding function Image (Order: Scan_ALI_Order) return String; overriding procedure Execute (Order: in out Scan_ALI_Order); ----------- -- Image -- ----------- function Image (Order: Scan_ALI_Order) return String is ("[Scan_ALI_Order] (Build.Scan_Linker_Options)" & New_Line & "Target: " & Order.Target.Name.To_UTF8_String); ------------- -- Execute -- ------------- procedure Execute (Order: in out Scan_ALI_Order) is use Ada.Text_IO; use Registrar.Library_Units; -- Avoid using the secondary stack, for efficincy Buffer: String (1 .. 1920); Last : Natural; ALI_File: File_Type; begin pragma Assert (Order.Target.State = Compiled); -- Skip units that are not Ada Library Units if Order.Target.Kind not in Package_Unit | Subprogram_Unit then return; end if; Open (File => ALI_File, Mode => In_File, Name => ALI_File_Name (Order.Target)); -- Fairly simple operation. We'll keep going until we hit the end of the -- file, scanning each line. Linker option lines start with 'L', and then -- a space, and then a quote-enclosed string. We simply take those strings, -- strip the quotes, and slap them onto the queue while not End_Of_File (ALI_File) loop Get_Line (File => ALI_File, Item => Buffer, Last => Last); if Last > Buffer'First -- if Last = Item'First, we definately don't want it anyways and then Buffer(1) = 'L' then pragma Assert (Buffer(3) = '"'); pragma Assert (Buffer(Last) = '"'); Linker_Options.Enqueue (UBS.To_Unbounded_String (Buffer(4 .. Last - 1))); -- L "option" -- ^....^ -- 1234.....Last end if; end loop; Close (ALI_File); exception when others => if Is_Open (ALI_File) then Close (ALI_File); end if; raise; end Execute; ------------------------- -- Scan_Linker_Options -- ------------------------- procedure Scan_Linker_Options (Unit_Set: in Registrar.Library_Units.Library_Unit_Sets.Set) is use Registrar.Library_Units; New_Order: Scan_ALI_Order := (Tracker => Scan_Progress'Access, others => <>); begin Scan_Progress.Increase_Total_Items_By (Natural (Unit_Set.Length)); for Unit of Unit_Set loop New_Order.Target := Unit; Workers.Enqueue_Order (New_Order); end loop; end Scan_Linker_Options; ---------- -- Bind -- ---------- procedure Bind (Unit_Set : in Registrar.Library_Units.Library_Unit_Sets.Set; Configuration: in Build_Configuration; Errors : out UBS.Unbounded_String) is use UBS; use Registrar.Library_Units; use type Ada.Containers.Count_Type; Need_GNARL: Boolean := False; -- GNAT-specific. GNARL is the tasting part of the Ada runtime. Not -- all programs need this, and those that do also need pthreads Args: Unbounded_String; Bind_Output: Unbounded_String; begin pragma Assert (Configuration.Mode in Library | Image); pragma Assert (if Unit_Set.Length = 1 then Configuration.Mode = Image and then Unit_Set(Unit_Set.First).Kind = Subprogram_Unit); pragma Assert (for all Unit of Unit_Set => Unit.Kind in Package_Unit | Subprogram_Unit); -- Verify that we have a binder if not Program_Paths.Found (Binder) then raise Program_Error with "Bind failed: Could not find the binder program (" & Binder_Program & ")."; end if; -- Generate the binder file -- Switches first Set_Unbounded_String (Args, "-x -o ada_main.adb"); if Configuration.Mode = Library then Append (Args, " -n"); elsif Unit_Set.Length > 1 then Append (Args, " -z"); end if; if Configuration.Linking in Static | Static_RT then Append (Args, " -static"); else Append (Args, " -shared"); end if; -- Now add the unit ALI file names for Unit of Unit_Set loop Append (Args, ' ' & ALI_File_Name (Unit)); end loop; -- Keep a record of our command declare use Ada.Text_IO; Path: constant String := Build_Output_Root & "/ada_main.binder.cmd"; CMD_OUT: File_Type; begin if Ada.Directories.Exists (Path) then Open (File => CMD_OUT, Mode => Out_File, Name => Path); else Create (File => CMD_OUT, Name => Path); end if; Put_Line (CMD_OUT, "Binder used:"); Put_Line (CMD_OUT, Program_Paths.Image_Path (Binder)); Put_Line (CMD_OUT, "Arguments used:"); Put_Line (CMD_OUT, To_String (Args)); Close (CMD_OUT); end; -- Execute declare use Child_Processes; Bind_Process: Child_Process'Class := Spawn_Process (Image_Path => Program_Paths.Image_Path (Binder), Arguments => To_String (Args), Working_Directory => Build_Root); Timed_Out: Boolean; Status : Exit_Status; Output : Unbounded_String; begin Output := Null_Unbounded_String; Wait_And_Buffer (Process => Bind_Process, Poll_Rate => 0.1, Timeout => 300.0, Output => Output, Error => Errors, Timed_Out => Timed_Out, Status => Status); if Timed_Out then Bind_Process.Kill; Append (Errors, " [TIMED OUT]"); elsif Status = Failure or else Length (Errors) > 0 then if Length (Errors) = 0 then Append (Errors, "[No error output]"); end if; return; end if; end; -- Successful. Errors is empty. -- Complete by entering the outputed binder unit declare use Ada.Directories; Search : Search_Type; Unit_Source: Directory_Entry_Type; begin Start_Search (Search => Search, Directory => Build_Root, Pattern => "ada_main.ad*"); -- We are expecting exactly two entries for I in 1 .. 2 loop if not More_Entries (Search) then Set_Unbounded_String (Errors, "Could not find the expected binder output."); return; end if; Get_Next_Entry (Search => Search, Directory_Entry => Unit_Source); Registrar.Registration.Enter_Unit (Unit_Source); end loop; if More_Entries (Search) then Set_Unbounded_String (Errors, "Unexpected binder artifacts."); return; end if; End_Search (Search); end; end Bind; -- -- Link Operations -- ------------------ -- Find_Ada_RTS -- ------------------ -- Path to the Ada RTS function Find_Ada_RTS return String is -- This function is very GCC-specific. We want to find the directory -- that contains the actual Ada Run-Time libraries (libgnat and libgnarl) -- These always reside in the location of libgcc, within the directory -- adalib. use UBS; use Ada.Directories; use Child_Processes; GCC_Info: Child_Process'Class := Spawn_Process (Image_Path => Program_Paths.Image_Path (Linker), Arguments => "-print-libgcc-file-name", Working_Directory => Current_Directory); Output, Error: Unbounded_String; Timed_Out : Boolean; Status : Exit_Status; begin Wait_And_Buffer (Process => GCC_Info, Poll_Rate => 0.01, -- Expected to be quick Timeout => 1.0, -- Generous Output => Output, Error => Error, Timed_Out => Timed_Out, Status => Status); Assert (Check => not Timed_Out, Message => "gcc timed out unexpectedly."); Assert (Check => Status = Success and then Length (Error) = 0, Message => "gcc failed unexpectedly."); -- Output now consists of a "full name" to 'libgcc.a'. The containing -- directory of that file contains a directory "adalib", which is what -- we need to return return Containing_Directory (To_String (Output)) & "/adalib"; end Find_Ada_RTS; ----------------- -- Needs_GNARL -- ----------------- -- GNAT-specific. Scans the binder body file looking for the presence of -- "-lgnarl" function Needs_GNARL return Boolean is use Ada.Text_IO; File: File_Type; Test: Character; In_Section : Boolean := False; Section_Test : constant String := "-- BEGIN Object file/option list"; Section_Test_Depth: Positive := Section_Test'First; GNARL_Test : constant String := "-lgnarl"; GNARL_Test_Depth: Positive := GNARL_Test'First; begin Open (File => File, Mode => In_File, Name => Build_Root & "/ada_main.adb"); while not End_Of_File (File) loop Get (File, Test); if not In_Section then if Test = Section_Test(Section_Test_Depth) then if Section_Test_Depth = Section_Test'Last then In_Section := True; else Section_Test_Depth := Section_Test_Depth + 1; end if; else Section_Test_Depth := Section_Test'First; end if; else if Test = GNARL_Test(GNARL_Test_Depth) then if GNARL_Test_Depth = GNARL_Test'Last then Close (File); return True; else GNARL_Test_Depth := GNARL_Test_Depth + 1; end if; else GNARL_Test_Depth := GNARL_Test'First; end if; end if; end loop; -- End of file and we didn't find any -lgnarl Close (File); Assert (In_Section, "Could not find option list in binder source."); return False; exception when Name_Error => raise Name_Error with "Binder source was not found"; end Needs_GNARL; ------------------------ -- Add_Linker_Options -- ------------------------ -- A generalized procedure for adding all the various linker options that -- would be shared between image and library linking procedure Add_Linker_Options (Configuration: in Build_Configuration; Args : in out UBS.Unbounded_String) is use UBS; begin -- Debug options if Configuration.Debug_Enabled then Append (Args, " -g"); end if; -- User-defined linker options declare Option: UBS.Unbounded_String; begin loop select Linker_Options.Dequeue (Option); else exit; end select; Append (Args, ' ' & UBS.To_String (Option)); end loop; end; -- The following options really only apply when we are linking some kind -- of final elf "image" - either an executable or a shared library. -- -- For archives (static libraries), we don't want to include these -- options in "linker options" output provided along-side the archive if Configuration.Mode in Image | Systemize or else (Configuration.Mode = Library and then Configuration.Linking = Static) then -- Initial set-up depending on the linking mode case Configuration.Linking is when Shared => Append (Args, " -shared-libgcc -shared"); -- Only if we are actually creating an executable (image), -- should we add the pie/no-pie flags if Configuration.Mode = Image then if Configuration.Position_Independent then Append (Args, " -pie"); else Append (Args, " -no-pie"); end if; end if; when Static_RT => Append (Args, " -static-libgcc"); when Static => Append (Args, " -static-libgcc"); if Configuration.Position_Independent then Append (Args, " -static-pie"); else Append (Args, " -static"); end if; end case; -- If we are building a shared library, we will add in the -- initialization and finalization symbols to cause elaboration of the -- Ada code via the binder program. if Configuration.Mode = Library and then Configuration.Linking = Shared then Append (Args, " -Wl,-init=adainit,-fini=adafinal"); end if; end if; -- Now all the user libraries for Subsys of Registrar.Queries.Available_Subsystems loop for Lib_Pair of Subsys.Configuration.External_Libraries loop Append (Args, " -l" & To_String (Lib_Pair.Value)); end loop; end loop; end Add_Linker_Options; ----------------- -- Add_Runtime -- ----------------- -- Adds the appropriate libraries or archives for the Ada runtime. This -- must come after the object list in the case of a static rt -- -- For_Archive is set true when building the linker option outbut for -- static archive library builds. This causes only the libgnat and -- libgnarl objects to be rolled into the archive procedure Add_Static_Runtime_Archives (Configuration: in Build_Configuration; Args : in out UBS.Unbounded_String; GNARL : in Boolean := Needs_GNARL; RTS_Dir : in String := Find_Ada_RTS) is -- Add_Static_Runtime_Archives specifically adds the actual archives -- for the static version of the Ada runtime. This subprogram is used -- both by Add_Runtime and Archive. -- -- Add_Runtime uses it to pass to the linker, while Archive uses it -- to include the static runtime archives in the final archive object begin if GNARL then UBS.Append (Args, ' ' & RTS_Dir & (if Configuration.Position_Independent then "/libgnarl_pic.a" else "/libgnarl.a")); end if; UBS.Append (Args, ' ' & RTS_DIR & (if Configuration.Position_Independent then "/libgnat_pic.a" else "/libgnat.a")); end; ---------------------------------------------------------------------- procedure Add_Runtime (Configuration: in Build_Configuration; Args : in out UBS.Unbounded_String) is use UBS; RTS_Dir: constant String := Find_Ada_RTS; GNARL : constant Boolean := Needs_GNARL; -- Note in theory, there should be only one link per run of AURA, so it -- is perfectly fine to elaborate these locally, since it will only -- happen once anyways. begin if GNARL and then Platform_Info.Platform_Family = "unix" then Append (Args, " -pthread"); end if; case Configuration.Linking is when Shared => Append (Args, " -L" & RTS_Dir); Append (Args, " -lgnat"); if GNARL then Append (Args, " -lgnarl"); end if; when Static_RT | Static => Add_Static_Runtime_Archives (Configuration, Args, GNARL, RTS_Dir); end case; end Add_Runtime; ---------------- -- Link_Image -- ---------------- procedure Link_Image (Image_Path : in String; Unit_Set : in Registrar.Library_Units.Library_Unit_Sets.Set; Configuration: in Build_Configuration; Errors : out UBS.Unbounded_String) is use UBS; use Child_Processes; Args: Unbounded_String; begin -- Verify that we can find the Linker if not Program_Paths.Found (Binder) then raise Program_Error with "Link failed: Could not find the linker program (" & Linker_Program & ")."; end if; if Image_Path'Length = 0 then raise Constraint_Error with "Attempt to link without an image path"; end if; Set_Unbounded_String (Args, "-o " & Image_Path); Add_Linker_Options (Configuration, Args); -- Add linker options -- Then the objects declare use Ada.Directories; use Registrar.Library_Units; begin for Unit of Unit_Set loop if Unit.Kind not in Unknown | Subunit then Append (Args, ' ' & Simple_Name (Object_File_Name (Unit))); -- We use Simple_Name and then execute the linker from the -- aura-build subdirectory to avoid any problems with -- overwhelming the arguments of the linker with long path-names -- for each object. It's also a bit nicer to look at when -- debugging end if; end loop; end; -- Finally the Ada Runtime Add_Runtime (Configuration, Args); -- Record the command declare use Ada.Text_IO; Path: constant String := Build_Output_Root & "/ada_main.linker.cmd"; CMD_OUT: File_Type; begin if Ada.Directories.Exists (Path) then Open (File => CMD_OUT, Mode => Out_File, Name => Path); else Create (File => CMD_OUT, Name => Path); end if; Put_Line (CMD_OUT, "Linker used:"); Put_Line (CMD_OUT, Program_Paths.Image_Path (Linker)); Put_Line (CMD_OUT, "Arguments used:"); Put_Line (CMD_OUT, To_String (Args)); Close (CMD_OUT); end; -- Execute declare use Child_Processes; Link_Process: Child_Process'Class := Spawn_Process (Image_Path => Program_Paths.Image_Path (Linker), Arguments => To_String (Args), Working_Directory => Build_Root); Discard : Unbounded_String; Timed_Out: Boolean; Status : Exit_Status; begin Wait_And_Buffer (Process => Link_Process, Poll_Rate => 0.1, Timeout => 300.0, Output => Discard, Error => Errors, Timed_Out => Timed_Out, Status => Status); if Timed_Out then Link_Process.Kill; Append (Errors, " [TIMED OUT]"); elsif Status = Failure and then Length (Errors) = 0 then Set_Unbounded_String (Errors, "[No error output]"); end if; end; end Link_Image; ------------- -- Archive -- ------------- procedure Archive (Archive_Path : in String; Unit_Set : in Registrar.Library_Units.Library_Unit_Sets.Set; Configuration: in Build_Configuration; Errors : out UBS.Unbounded_String) is Args: UBS.Unbounded_String := UBS.To_Unbounded_String ("-rc " & Archive_Path & ' '); GNARL : constant Boolean := Needs_GNARL; RTS_Dir: constant String := Find_Ada_RTS; procedure Output_Linker_Options is use Ada.Strings.Fixed; use Ada.Text_IO; use all type Ada.Strings.Direction; Linker_Options: UBS.Unbounded_String; LO_File: File_Type; Extension_Start: constant Natural := Index (Source => Archive_Path, Pattern => ".", Going => Backward); Path: constant String := Archive_Path (Archive_Path'First .. Extension_Start) & "linkopt"; begin if Extension_Start < Archive_Path'First then -- This will likely be checked by the command processor, -- but this is such a cheap check to make, why not raise Constraint_Error with "Library archive path shall have an extension."; end if; if GNARL and then Platform_Info.Platform_Family = "unix" then UBS.Append (Linker_Options, " -pthread"); end if; Add_Linker_Options (Configuration, Linker_Options); if Ada.Directories.Exists (Path) then Open (File => LO_File, Mode => Out_File, Name => Path); else Create (File => LO_File, Mode => Out_File, Name => Path); end if; Put_Line (File => LO_File, Item => UBS.To_String (Linker_Options)); Close (LO_File); end; begin pragma Assert (Configuration.Mode = Library); -- Verify that we can find the Archiver if not Program_Paths.Found (Archiver) then raise Program_Error with "Archive failed: Could not find the archiver program (" & Archiver_Program & ")."; end if; declare use Ada.Directories; use Registrar.Library_Units; begin for Unit of Unit_Set loop if Unit.Kind not in Unknown | Subunit then UBS.Append (Args, ' ' & Simple_Name (Object_File_Name (Unit))); -- We use Simple_Name and then execute the linker from the -- aura-build subdirectory to avoid any problems with -- overwhelming the arguments of the linker with long path-names -- for each object. It's also a bit nicer to look at when -- debugging end if; end loop; end; -- Add the Ada runtime archives Add_Static_Runtime_Archives (Configuration, Args, GNARL, RTS_Dir); -- Record the command declare use Ada.Text_IO; Path: constant String := Build_Output_Root & "/ada_main.archiver.cmd"; CMD_OUT: File_Type; begin if Ada.Directories.Exists (Path) then Open (File => CMD_OUT, Mode => Out_File, Name => Path); else Create (File => CMD_OUT, Name => Path); end if; Put_Line (CMD_OUT, "Archiver used:"); Put_Line (CMD_OUT, Program_Paths.Image_Path (Archiver)); Put_Line (CMD_OUT, "Arguments used:"); Put_Line (CMD_OUT, UBS.To_String (Args)); Close (CMD_OUT); end; -- Execute declare use Child_Processes; Archive_Process: Child_Process'Class := Spawn_Process (Image_Path => Program_Paths.Image_Path (Archiver), Arguments => UBS.To_String (Args), Working_Directory => Build_Root); Discard : UBS.Unbounded_String; Timed_Out: Boolean; Status : Exit_Status; begin Wait_And_Buffer (Process => Archive_Process, Poll_Rate => 0.1, Timeout => 60.0, Output => Discard, Error => Errors, Timed_Out => Timed_Out, Status => Status); if Timed_Out then Archive_Process.Kill; UBS.Append (Errors, " [TIMED OUT]"); elsif Status = Success then Output_Linker_Options; elsif Status = Failure and then UBS.Length (Errors) = 0 then UBS.Set_Unbounded_String (Errors, "[No error output]"); end if; end; end Archive; --------------------- -- Link_Subsystems -- --------------------- procedure Link_Subsystems is begin -- TODO raise Program_Error with "Not implemented"; end Link_Subsystems; end Build.Linking;
-- Abstract : -- -- Implement [McKenzie] error recovery, extended to parallel parsers. -- -- References: -- -- [McKenzie] McKenzie, Bruce J., Yeatman, Corey, and De Vere, -- Lorraine. Error repair in shift reduce parsers. ACM Trans. Prog. -- Lang. Syst., 17(4):672-689, July 1995. Described in [Grune 2008] ref 321. -- -- [Grune 2008] Parsing Techniques, A Practical Guide, Second -- Edition. Dick Grune, Ceriel J.H. Jacobs. -- -- Copyright (C) 2017 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada.Task_Attributes; with WisiToken.Parse.LR.Parser; with WisiToken.Lexer; package WisiToken.Parse.LR.McKenzie_Recover is Bad_Config : exception; -- Raised when a config is determined to violate some programming -- convention; abandon it. type Recover_Status is (Fail_Check_Delta, Fail_Enqueue_Limit, Fail_No_Configs_Left, Fail_Programmer_Error, Success); function Recover (Shared_Parser : in out WisiToken.Parse.LR.Parser.Parser) return Recover_Status; -- Attempt to modify Parser.Parsers state and Parser.Lookahead to -- allow recovering from an error state. Force_Full_Explore : Boolean := False; -- Sometimes recover throws an exception in a race condition case -- that is hard to reproduce. Setting this True ignores all Success, -- so all configs are checked. Force_High_Cost_Solutions : Boolean := False; -- Similarly, setting this true keeps all solutions that are found, -- and forces at least three. private use all type WisiToken.Syntax_Trees.Node_Index; ---------- -- Visible for language-specific child packages. Alphabetical. procedure Check (ID : Token_ID; Expected_ID : in Token_ID) with Inline => True; -- Check that ID = Expected_ID; raise Assertion_Error if not. -- Implemented using 'pragma Assert'. function Current_Token (Terminals : in Base_Token_Arrays.Vector; Terminals_Current : in out Base_Token_Index; Restore_Terminals_Current : out WisiToken.Base_Token_Index; Insert_Delete : aliased in out Sorted_Insert_Delete_Arrays.Vector; Current_Insert_Delete : in out SAL.Base_Peek_Type; Prev_Deleted : in Recover_Token_Index_Arrays.Vector) return Base_Token; -- Return the current token, from either Terminals or Insert_Delete; -- set up for Next_Token. -- -- See Next_Token for more info. function Current_Token_ID_Peek (Terminals : in Base_Token_Arrays.Vector; Terminals_Current : in Base_Token_Index; Insert_Delete : aliased in Sorted_Insert_Delete_Arrays.Vector; Current_Insert_Delete : in SAL.Base_Peek_Type) return Token_ID; -- Return the current token from either Terminals or -- Insert_Delete, without setting up for Next_Token. procedure Current_Token_ID_Peek_3 (Terminals : in Base_Token_Arrays.Vector; Terminals_Current : in Base_Token_Index; Insert_Delete : aliased in Sorted_Insert_Delete_Arrays.Vector; Current_Insert_Delete : in SAL.Base_Peek_Type; Prev_Deleted : in Recover_Token_Index_Arrays.Vector; Tokens : out Token_ID_Array_1_3); -- Return the current token (in Tokens (1)) from either Terminals or -- Insert_Delete, without setting up for Next_Token. Return the two -- following tokens in Tokens (2 .. 3). procedure Delete_Check (Terminals : in Base_Token_Arrays.Vector; Config : in out Configuration; ID : in Token_ID); -- Check that Terminals (Config.Current_Shared_Token) = ID. Append a -- Delete op to Config.Ops, and insert it in Config.Insert_Delete in -- token_index order. -- -- This or the next routine must be used instead of Config.Ops.Append -- (Delete...) unless the code also takes care of changing -- Config.Current_Shared_Token. Note that this routine does _not_ -- increment Config.Current_Shared_Token, so it can only be used to -- delete one token. procedure Delete_Check (Terminals : in Base_Token_Arrays.Vector; Config : in out Configuration; Index : in out WisiToken.Token_Index; ID : in Token_ID); -- Check that Terminals (Index) = ID. Append a Delete op to -- Config.Ops, and insert it in Config.Insert_Delete in token_index -- order. Increments Index, for convenience when deleting several -- tokens. procedure Find_ID (Config : in Configuration; ID : in Token_ID; Matching_Index : in out SAL.Peek_Type); -- Search Config.Stack for a token with ID, starting at -- Matching_Index. If found, Matching_Index points to it. -- If not found, Matching_Index = Config.Stack.Depth. procedure Find_ID (Config : in Configuration; IDs : in Token_ID_Set; Matching_Index : in out SAL.Peek_Type); -- Search Config.Stack for a token with ID in IDs, starting at -- Matching_Index. If found, Matching_Index points to it. -- If not found, Matching_Index = Config.Stack.Depth. procedure Find_Descendant_ID (Tree : in Syntax_Trees.Tree; Config : in Configuration; ID : in Token_ID; ID_Set : in Token_ID_Set; Matching_Index : in out SAL.Peek_Type); -- Search Config.Stack for a token with id in ID_Set, with a -- descendant with id = ID, starting at Matching_Index. If found, -- Matching_Index points to it. If not found, Matching_Index = -- Config.Stack.Depth. procedure Find_Matching_Name (Config : in Configuration; Lexer : access constant WisiToken.Lexer.Instance'Class; Name : in String; Matching_Name_Index : in out SAL.Peek_Type; Case_Insensitive : in Boolean); -- Search Config.Stack for a token matching Name, starting at -- Matching_Name_Index. If found, Matching_Name_Index points to it. -- If not found, Matching_Name_Index = Config.Stack.Depth. procedure Find_Matching_Name (Config : in Configuration; Lexer : access constant WisiToken.Lexer.Instance'Class; Name : in String; Matching_Name_Index : in out SAL.Peek_Type; Other_ID : in Token_ID; Other_Count : out Integer; Case_Insensitive : in Boolean); -- Search Config.Stack for a token matching Name, starting at -- Matching_Name_Index. If found, Matching_Name_Index points to it. -- If not found, Matching_Name_Index = Config.Stack.Depth. -- -- Also count tokens with ID = Other_ID. procedure Insert (Config : in out Configuration; ID : in Token_ID); -- Append an Insert op to Config.Ops, and insert it in -- Config.Insert_Deleted in token_index order. procedure Insert (Config : in out Configuration; IDs : in Token_ID_Array); -- Call Insert for each item in IDs. function Next_Token (Terminals : in Base_Token_Arrays.Vector; Terminals_Current : in out Base_Token_Index; Restore_Terminals_Current : in out WisiToken.Base_Token_Index; Insert_Delete : aliased in out Sorted_Insert_Delete_Arrays.Vector; Current_Insert_Delete : in out SAL.Base_Peek_Type; Prev_Deleted : in Recover_Token_Index_Arrays.Vector) return Base_Token; -- Return the next token, from either Terminals or Insert_Delete; -- update Terminals_Current or Current_Insert_Delete. -- -- If result is Insert_Delete.Last_Index, Current_Insert_Delete = -- Last_Index; Insert_Delete is cleared and Current_Insert_Delete -- reset on next call. -- -- When done parsing, caller must reset actual Terminals_Current to -- Restore_Terminals_Current. -- -- Insert_Delete contains only Insert and Delete ops, in token_index -- order. Those ops are applied when Terminals_Current = -- op.token_index. -- -- Prev_Deleted contains tokens deleted in previous recover -- operations; those are skipped. procedure Push_Back (Config : in out Configuration); -- Pop the top Config.Stack item, set Config.Current_Shared_Token to -- the first terminal in that item. If the item is empty, -- Config.Current_Shared_Token is unchanged. -- -- If any earlier Insert or Delete items in Config.Ops are for a -- token_index after that first terminal, they are added to -- Config.Insert_Delete in token_index order. procedure Push_Back_Check (Config : in out Configuration; Expected_ID : in Token_ID); -- In effect, call Check and Push_Back. procedure Push_Back_Check (Config : in out Configuration; Expected : in Token_ID_Array); -- Call Push_Back_Check for each item in Expected. procedure Put (Message : in String; Trace : in out WisiToken.Trace'Class; Parser_Label : in Natural; Terminals : in Base_Token_Arrays.Vector; Config : in Configuration; Task_ID : in Boolean := True; Strategy : in Boolean := False); -- Put Message and an image of Config to Trace. procedure Put_Line (Trace : in out WisiToken.Trace'Class; Parser_Label : in Natural; Message : in String; Task_ID : in Boolean := True); -- Put message to Trace, with parser and task info. function Undo_Reduce_Valid (Stack : in Recover_Stacks.Stack; Tree : in Syntax_Trees.Tree) return Boolean is (Stack.Depth > 1 and then ((Stack.Peek.Tree_Index /= WisiToken.Syntax_Trees.Invalid_Node_Index and then Tree.Is_Nonterm (Stack.Peek.Tree_Index)) or (Stack.Peek.Tree_Index = WisiToken.Syntax_Trees.Invalid_Node_Index and (not Stack.Peek.Token.Virtual and Stack.Peek.Token.Byte_Region = Null_Buffer_Region)))); -- Undo_Reduce needs to know what tokens the nonterm contains, to -- push them on the stack. Thus we need either a valid Tree index, or -- an empty nonterm. If Token.Virtual, we can't trust -- Token.Byte_Region to determine empty. function Undo_Reduce (Stack : in out Recover_Stacks.Stack; Tree : in Syntax_Trees.Tree) return Ada.Containers.Count_Type with Pre => Undo_Reduce_Valid (Stack, Tree); -- Undo the reduction that produced the top stack item, return the -- token count for that reduction. procedure Undo_Reduce_Check (Config : in out Configuration; Tree : in Syntax_Trees.Tree; Expected : in Token_ID) with Inline => True; -- Call Check, Undo_Reduce. procedure Undo_Reduce_Check (Config : in out Configuration; Tree : in Syntax_Trees.Tree; Expected : in Token_ID_Array); -- Call Undo_Reduce_Check for each item in Expected. package Task_Attributes is new Ada.Task_Attributes (Integer, 0); end WisiToken.Parse.LR.McKenzie_Recover;
package body Ada.Containers.Binary_Trees.Simple is procedure Insert ( Container : in out Node_Access; Length : in out Count_Type; Before : Node_Access; New_Item : not null Node_Access) is begin Length := Length + 1; if Container = null then New_Item.Parent := null; New_Item.Left := null; New_Item.Right := null; Container := New_Item; elsif Before = null then New_Item.Parent := Last (Container); New_Item.Left := null; New_Item.Right := null; New_Item.Parent.Right := New_Item; elsif Before.Left = null then New_Item.Parent := Before; New_Item.Left := null; New_Item.Right := null; New_Item.Parent.Left := New_Item; else New_Item.Parent := Last (Before.Left); New_Item.Left := null; New_Item.Right := null; New_Item.Parent.Right := New_Item; end if; end Insert; procedure Remove ( Container : in out Node_Access; Length : in out Count_Type; Position : not null Node_Access) is Alt : Node_Access; begin Length := Length - 1; if Position.Left = null then Alt := Position.Right; elsif Position.Right = null then Alt := Position.Left; else Alt := Position.Right; declare Left_Of_Alt : constant not null Node_Access := First (Alt); begin Left_Of_Alt.Left := Position.Left; Position.Left.Parent := Left_Of_Alt; end; end if; if Alt /= null then Alt.Parent := Position.Parent; end if; if Position.Parent /= null then if Position.Parent.Left = Position then Position.Parent.Left := Alt; else pragma Assert (Position.Parent.Right = Position); Position.Parent.Right := Alt; end if; else pragma Assert (Container = Position); Container := Alt; end if; end Remove; procedure Copy ( Target : out Node_Access; Length : out Count_Type; Source : Node_Access; Copy : not null access procedure ( Target : out Node_Access; Source : not null Node_Access)) is begin Length := 0; if Source /= null then Length := Length + 1; Copy (Target, Source); Target.Parent := null; declare Source_Item : Node_Access := Source; Target_Item : Node_Access := Target; begin loop declare Source_Parent_Item : Node_Access; Target_Parent_Item : Node_Access; Index : Index_Type; begin Root_To_Leaf_Next ( Previous_Source_Item => Source_Item, Source_Parent_Item => Source_Parent_Item, Previous_Target_Item => Target_Item, Target_Parent_Item => Target_Parent_Item, Index => Index); exit when Source_Parent_Item = null; case Index is when Left => Source_Item := Source_Parent_Item.Left; when Right => Source_Item := Source_Parent_Item.Right; end case; Length := Length + 1; Copy (Target_Item, Source_Item); Target_Item.Parent := Target_Parent_Item; case Index is when Left => Target_Parent_Item.Left := Target_Item; when Right => Target_Parent_Item.Right := Target_Item; end case; end; end loop; end; end if; end Copy; end Ada.Containers.Binary_Trees.Simple;
-- This spec has been automatically generated from STM32WB55x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.AES is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_DATATYPE_Field is HAL.UInt2; subtype CR_MODE_Field is HAL.UInt2; subtype CR_CHMOD_Field is HAL.UInt2; subtype CR_GCMPH_Field is HAL.UInt2; subtype CR_NPBLB_Field is HAL.UInt4; type CR_Register is record EN : Boolean := False; DATATYPE : CR_DATATYPE_Field := 16#0#; MODE : CR_MODE_Field := 16#0#; CHMOD : CR_CHMOD_Field := 16#0#; CCFC : Boolean := False; ERRC : Boolean := False; CCFIE : Boolean := False; ERRIE : Boolean := False; DMAINEN : Boolean := False; DMAOUTEN : Boolean := False; GCMPH : CR_GCMPH_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; CHMOD_1 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; KEYSIZE : Boolean := False; -- unspecified Reserved_19_19 : HAL.Bit := 16#0#; NPBLB : CR_NPBLB_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record EN at 0 range 0 .. 0; DATATYPE at 0 range 1 .. 2; MODE at 0 range 3 .. 4; CHMOD at 0 range 5 .. 6; CCFC at 0 range 7 .. 7; ERRC at 0 range 8 .. 8; CCFIE at 0 range 9 .. 9; ERRIE at 0 range 10 .. 10; DMAINEN at 0 range 11 .. 11; DMAOUTEN at 0 range 12 .. 12; GCMPH at 0 range 13 .. 14; Reserved_15_15 at 0 range 15 .. 15; CHMOD_1 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; KEYSIZE at 0 range 18 .. 18; Reserved_19_19 at 0 range 19 .. 19; NPBLB at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; type SR_Register is record CCF : Boolean := False; RDERR : Boolean := False; WRERR : Boolean := False; BUSY : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record CCF at 0 range 0 .. 0; RDERR at 0 range 1 .. 1; WRERR at 0 range 2 .. 2; BUSY at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; ----------------- -- Peripherals -- ----------------- type AES_Peripheral is record CR : aliased CR_Register; SR : aliased SR_Register; DINR : aliased HAL.UInt32; DOUTR : aliased HAL.UInt32; KEYR0 : aliased HAL.UInt32; KEYR1 : aliased HAL.UInt32; KEYR2 : aliased HAL.UInt32; KEYR3 : aliased HAL.UInt32; IVR0 : aliased HAL.UInt32; IVR1 : aliased HAL.UInt32; IVR2 : aliased HAL.UInt32; IVR3 : aliased HAL.UInt32; KEYR4 : aliased HAL.UInt32; KEYR5 : aliased HAL.UInt32; KEYR6 : aliased HAL.UInt32; KEYR7 : aliased HAL.UInt32; SUSP0R : aliased HAL.UInt32; SUSP1R : aliased HAL.UInt32; SUSP2R : aliased HAL.UInt32; SUSP3R : aliased HAL.UInt32; SUSP4R : aliased HAL.UInt32; SUSP5R : aliased HAL.UInt32; SUSP6R : aliased HAL.UInt32; SUSP7R : aliased HAL.UInt32; end record with Volatile; for AES_Peripheral use record CR at 16#0# range 0 .. 31; SR at 16#4# range 0 .. 31; DINR at 16#8# range 0 .. 31; DOUTR at 16#C# range 0 .. 31; KEYR0 at 16#10# range 0 .. 31; KEYR1 at 16#14# range 0 .. 31; KEYR2 at 16#18# range 0 .. 31; KEYR3 at 16#1C# range 0 .. 31; IVR0 at 16#20# range 0 .. 31; IVR1 at 16#24# range 0 .. 31; IVR2 at 16#28# range 0 .. 31; IVR3 at 16#2C# range 0 .. 31; KEYR4 at 16#30# range 0 .. 31; KEYR5 at 16#34# range 0 .. 31; KEYR6 at 16#38# range 0 .. 31; KEYR7 at 16#3C# range 0 .. 31; SUSP0R at 16#40# range 0 .. 31; SUSP1R at 16#44# range 0 .. 31; SUSP2R at 16#48# range 0 .. 31; SUSP3R at 16#4C# range 0 .. 31; SUSP4R at 16#50# range 0 .. 31; SUSP5R at 16#54# range 0 .. 31; SUSP6R at 16#58# range 0 .. 31; SUSP7R at 16#5C# range 0 .. 31; end record; AES1_Periph : aliased AES_Peripheral with Import, Address => System'To_Address (16#50050400#); AES2_Periph : aliased AES_Peripheral with Import, Address => System'To_Address (16#58001800#); end STM32_SVD.AES;
with System;use System; package Blinker is -- type Cmd_Type is (START, STOP, QUIT); type Cmd_Type is (STOP, START); type Id_Type is ( R, L, E); type Command_To_Type is record Cmd : Cmd_Type; Receiver : Id_Type; end record; Id : Id_Type; -- type Cmd_Ptr_Type is access all Cmd_Type; -- Cmd_Ptr : constant Cmd_Ptr_Type := Command'Access; protected type Cmd_Type_Access is procedure Send( Cmd : Command_To_Type ); entry Receive( Cmd : out COmmand_To_Type); private Command_To : Command_To_Type; Command_Is_New : Boolean := False; end Cmd_Type_Access; task type Blinker_Type is --pragma Priority (System.Priority'Last); end Blinker_Type; Protected_Command : Cmd_Type_Access; end Blinker;
-- { dg-do compile } -- { dg-options "-gnatp -O1" } procedure Fatp_Sra is function X return String is begin return "X"; end; function Letter return String is begin return X; end; begin null; end;
with Ada.Text_IO; use Ada.Text_IO; with GESTE_Config; with GESTE; generic Width : Natural; Height : Natural; Buffer_Size : Positive; Init_Char : Character; package Console_Char_Screen is Screen_Rect : constant GESTE.Pix_Rect := ((0, 0), (Width - 1, Height - 1)); Buffer : GESTE.Output_Buffer (1 .. Buffer_Size); procedure Push_Pixels (Buffer : GESTE.Output_Buffer); procedure Set_Drawing_Area (Area : GESTE.Pix_Rect); procedure Print; procedure Verbose; procedure Set_Output (Output : File_Type); procedure Test_Collision (X, Y : Integer; Expected : Boolean); end Console_Char_Screen;
----------------------------------------------------------------------- -- awa-tags-components -- Tags component -- Copyright (C) 2013, 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 Ada.Strings.Unbounded; with Ada.Exceptions; with Ada.Unchecked_Deallocation; with Util.Strings; with Util.Log.Loggers; with ASF.Utils; with ASF.Converters; with ASF.Views.Nodes; with ASF.Components; with ASF.Components.Utils; with ASF.Components.Base; with ASF.Requests; with ASF.Events.Faces.Actions; with ASF.Applications.Main; with AWA.Tags.Beans; package body AWA.Tags.Components is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Tags.Components"); READONLY_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; function Create_Tag return ASF.Components.Base.UIComponent_Access; function Create_Cloud return ASF.Components.Base.UIComponent_Access; procedure Swap (Item1 : in out AWA.Tags.Models.Tag_Info; Item2 : in out AWA.Tags.Models.Tag_Info); procedure Dispatch (List : in out Tag_Info_Array); -- ------------------------------ -- Create an Tag_UIInput component -- ------------------------------ function Create_Tag return ASF.Components.Base.UIComponent_Access is begin return new Tag_UIInput; end Create_Tag; -- ------------------------------ -- Create an Tag_UICloud component -- ------------------------------ function Create_Cloud return ASF.Components.Base.UIComponent_Access is begin return new Tag_UICloud; end Create_Cloud; URI : aliased constant String := "http://code.google.com/p/ada-awa/jsf"; TAG_LIST_TAG : aliased constant String := "tagList"; TAG_CLOUD_TAG : aliased constant String := "tagCloud"; AWA_Bindings : aliased constant ASF.Factory.Binding_Array := (1 => (Name => TAG_CLOUD_TAG'Access, Component => Create_Cloud'Access, Tag => ASF.Views.Nodes.Create_Component_Node'Access), 2 => (Name => TAG_LIST_TAG'Access, Component => Create_Tag'Access, Tag => ASF.Views.Nodes.Create_Component_Node'Access) ); AWA_Factory : aliased constant ASF.Factory.Factory_Bindings := (URI => URI'Access, Bindings => AWA_Bindings'Access); -- ------------------------------ -- Get the Tags component factory. -- ------------------------------ function Definition return ASF.Factory.Factory_Bindings_Access is begin return AWA_Factory'Access; end Definition; -- ------------------------------ -- Returns True if the tag component must be rendered as readonly. -- ------------------------------ function Is_Readonly (UI : in Tag_UIInput; Context : in ASF.Contexts.Faces.Faces_Context'Class) return Boolean is pragma Unreferenced (Context); use type ASF.Components.Html.Forms.UIForm_Access; begin return UI.Get_Form = null; end Is_Readonly; -- ------------------------------ -- Render the javascript to enable the tag edition. -- ------------------------------ procedure Render_Script (UI : in Tag_UIInput; Id : in String; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Auto_Complete : constant String := UI.Get_Attribute ("autoCompleteUrl", Context); Allow_Edit : constant Boolean := UI.Get_Attribute ("allowEdit", Context); begin Writer.Queue_Script ("$('#"); Writer.Queue_Script (Id); Writer.Queue_Script (" input').tagedit({"); Writer.Queue_Script ("allowEdit: "); if Allow_Edit then Writer.Queue_Script ("true"); else Writer.Queue_Script ("false"); end if; if Auto_Complete'Length > 0 then Writer.Queue_Script (", autocompleteURL: '"); Writer.Queue_Script (Auto_Complete); Writer.Queue_Script ("'"); end if; Writer.Queue_Script ("});"); end Render_Script; -- ------------------------------ -- Get the tag after convertion with the optional converter. -- ------------------------------ function Get_Tag (UI : in Tag_UIInput; Tag : in Util.Beans.Objects.Object; Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is begin if not Util.Beans.Objects.Is_Null (Tag) then declare Convert : constant access ASF.Converters.Converter'Class := Tag_UIInput'Class (UI).Get_Converter; begin if Convert /= null then return Convert.To_String (Value => Tag, Component => UI, Context => Context); else return Util.Beans.Objects.To_String (Value => Tag); end if; end; else return ""; end if; end Get_Tag; -- ------------------------------ -- Render the tag as a readonly item. -- ------------------------------ procedure Render_Readonly_Tag (UI : in Tag_UIInput; Tag : in Util.Beans.Objects.Object; Class : in Util.Beans.Objects.Object; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Value : constant String := UI.Get_Tag (Tag, Context); begin Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Class) then Writer.Write_Attribute ("class", Class); end if; Writer.Start_Element ("span"); Writer.Write_Text (Value); Writer.End_Element ("span"); Writer.End_Element ("li"); end Render_Readonly_Tag; -- ------------------------------ -- Render the tag as a link. -- ------------------------------ procedure Render_Link_Tag (UI : in Tag_UIInput; Name : in String; Tag : in Util.Beans.Objects.Object; Link : in EL.Expressions.Expression; Class : in Util.Beans.Objects.Object; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Value : constant String := UI.Get_Tag (Tag, Context); begin Context.Set_Attribute (Name, Util.Beans.Objects.To_Object (Value)); Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Class) then Writer.Write_Attribute ("class", Class); end if; Writer.Start_Element ("a"); Writer.Write_Attribute ("href", Link.Get_Value (Context.Get_ELContext.all)); Writer.Write_Text (Value); Writer.End_Element ("a"); Writer.End_Element ("li"); end Render_Link_Tag; -- ------------------------------ -- Render the tag for an input form. -- ------------------------------ procedure Render_Form_Tag (UI : in Tag_UIInput; Id : in String; Tag : in Util.Beans.Objects.Object; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin Writer.Start_Element ("input"); Writer.Write_Attribute (Name => "type", Value => "text"); Writer.Write_Attribute (Name => "name", Value => Id); if not Util.Beans.Objects.Is_Null (Tag) then declare Convert : constant access ASF.Converters.Converter'Class := Tag_UIInput'Class (UI).Get_Converter; begin if Convert /= null then Writer.Write_Attribute (Name => "value", Value => Convert.To_String (Value => Tag, Component => UI, Context => Context)); else Writer.Write_Attribute (Name => "value", Value => Tag); end if; end; end if; Writer.End_Element ("input"); end Render_Form_Tag; -- ------------------------------ -- Render the list of tags as readonly list. If a <tt>tagLink</tt> attribute is defined, -- a link is rendered for each tag. Otherwise, each tag is rendered as a <tt>span</tt>. -- ------------------------------ procedure Render_Readonly (UI : in Tag_UIInput; List : in Util.Beans.Basic.List_Bean_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Class : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "tagClass"); Count : constant Natural := List.Get_Count; Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Link : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("tagLink"); begin if Count > 0 then Writer.Start_Element ("ul"); UI.Render_Attributes (Context, Writer); if Link /= null then declare Link : constant EL.Expressions.Expression := UI.Get_Expression ("tagLink"); Name : constant String := UI.Get_Attribute (Name => "var", Context => Context, Default => "tag"); begin for I in 1 .. Count loop List.Set_Row_Index (I); Tag_UIInput'Class (UI).Render_Link_Tag (Name => Name, Tag => List.Get_Row, Link => Link, Class => Class, Writer => Writer, Context => Context); end loop; end; else for I in 1 .. Count loop List.Set_Row_Index (I); Tag_UIInput'Class (UI).Render_Readonly_Tag (Tag => List.Get_Row, Class => Class, Writer => Writer, Context => Context); end loop; end if; Writer.End_Element ("ul"); end if; end Render_Readonly; -- ------------------------------ -- Render the list of tags for a form. -- ------------------------------ procedure Render_Form (UI : in Tag_UIInput; List : in Util.Beans.Basic.List_Bean_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Id : constant String := Ada.Strings.Unbounded.To_String (UI.Get_Client_Id); Count : constant Natural := List.Get_Count; Writer : constant Response_Writer_Access := Context.Get_Response_Writer; begin Writer.Start_Element ("div"); if Count > 0 then UI.Render_Attributes (Context, Writer); for I in 1 .. Count loop List.Set_Row_Index (I); Tag_UIInput'Class (UI).Render_Form_Tag (Id & "[" & Util.Strings.Image (I) & "]", List.Get_Row, Writer, Context); end loop; else Writer.Write_Attribute ("id", Id); end if; Tag_UIInput'Class (UI).Render_Form_Tag (Id & "[]", Util.Beans.Objects.Null_Object, Writer, Context); Writer.End_Element ("div"); Tag_UIInput'Class (UI).Render_Script (Id, Writer, Context); end Render_Form; -- ------------------------------ -- Render the input component. Starts the DL/DD list and write the input -- component with the possible associated error message. -- ------------------------------ overriding procedure Encode_Begin (UI : in Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare use AWA.Tags.Beans; Value : constant Util.Beans.Objects.Object := Tag_UIInput'Class (UI).Get_Value; Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); Readonly : constant Boolean := UI.Is_Readonly (Context); List : Util.Beans.Basic.List_Bean_Access; begin if Bean = null then if not Readonly then ASF.Components.Base.Log_Error (UI, "There is no tagList bean value"); end if; return; elsif not (Bean.all in Util.Beans.Basic.List_Bean'Class) then ASF.Components.Base.Log_Error (UI, "There bean value is not a List_Bean"); return; end if; List := Util.Beans.Basic.List_Bean'Class (Bean.all)'Unchecked_Access; if Readonly then UI.Render_Readonly (List, Context); else UI.Render_Form (List, Context); end if; end; end Encode_Begin; -- ------------------------------ -- Render the end of the input component. Closes the DL/DD list. -- ------------------------------ overriding procedure Encode_End (UI : in Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin null; end Encode_End; -- ------------------------------ -- Get the action method expression to invoke if the command is pressed. -- ------------------------------ function Get_Action_Expression (UI : in Tag_UIInput; Context : in ASF.Contexts.Faces.Faces_Context'Class) return EL.Expressions.Method_Expression is pragma Unreferenced (Context); begin return UI.Get_Method_Expression (Name => ASF.Components.ACTION_NAME); end Get_Action_Expression; -- ------------------------------ -- Decode any new state of the specified component from the request contained -- in the specified context and store that state on the component. -- -- During decoding, events may be enqueued for later processing -- (by event listeners that have registered an interest), by calling -- the <b>Queue_Event</b> on the associated component. -- ------------------------------ overriding procedure Process_Decodes (UI : in out Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare Req : constant ASF.Requests.Request_Access := Context.Get_Request; Id : constant String := Ada.Strings.Unbounded.To_String (UI.Get_Client_Id); procedure Process_Parameter (Name, Value : in String); procedure Process_Parameter (Name, Value : in String) is begin if Name'Length <= Id'Length or Name (Name'Last) /= ']' then return; end if; if Name (Name'First .. Name'First + Id'Length - 1) /= Id then return; end if; if Name (Name'First + Id'Length) /= '[' then return; end if; if Name (Name'Last - 1) = 'd' then UI.Deleted.Append (Value); elsif Name (Name'Last - 1) = 'a' or else Name (Name'Last - 1) = '[' then UI.Added.Append (Value); end if; end Process_Parameter; Val : constant String := Context.Get_Parameter (Id); begin Req.Iterate_Parameters (Process_Parameter'Access); UI.Is_Valid := True; if not UI.Added.Is_Empty or else not UI.Deleted.Is_Empty then ASF.Events.Faces.Actions.Post_Event (UI => UI, Method => UI.Get_Action_Expression (Context)); end if; exception when E : others => UI.Is_Valid := False; Log.Info (ASF.Components.Utils.Get_Line_Info (UI) & ": Exception raised when converting value {0} for component {1}: {2}", Val, Id, Ada.Exceptions.Exception_Name (E)); end; end Process_Decodes; -- ------------------------------ -- Perform the component tree processing required by the <b>Update Model Values</b> -- phase of the request processing lifecycle for all facets of this component, -- all children of this component, and this component itself, as follows. -- <ul> -- <li>If this component <b>rendered</b> property is false, skip further processing. -- <li>Call the <b>Process_Updates/b> of all facets and children. -- <ul> -- ------------------------------ overriding procedure Process_Updates (UI : in out Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if UI.Is_Valid and then not UI.Is_Rendered (Context) then return; end if; declare use AWA.Tags.Beans; Value : constant Util.Beans.Objects.Object := Tag_UIInput'Class (UI).Get_Value; Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); List : access Tag_List_Bean'Class; begin if Bean = null then ASF.Components.Base.Log_Error (UI, "There is no tagList bean value"); return; elsif not (Bean.all in Tag_List_Bean'Class) then ASF.Components.Base.Log_Error (UI, "There is not taglist bean"); return; end if; List := Tag_List_Bean'Class (Bean.all)'Access; List.Set_Added (UI.Added); List.Set_Deleted (UI.Deleted); end; end Process_Updates; -- ------------------------------ -- Broadcast the event to the event listeners installed on this component. -- Listeners are called in the order in which they were added. -- ------------------------------ overriding procedure Broadcast (UI : in out Tag_UIInput; Event : not null access ASF.Events.Faces.Faces_Event'Class; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is pragma Unreferenced (UI); use ASF.Events.Faces.Actions; App : constant access ASF.Applications.Main.Application'Class := Context.Get_Application; Disp : constant Action_Listener_Access := App.Get_Action_Listener; begin if Disp /= null and Event.all in Action_Event'Class then Disp.Process_Action (Event => Action_Event (Event.all), Context => Context); end if; end Broadcast; -- ------------------------------ -- Render the list of tags. If the <tt>tagLink</tt> attribute is defined, a link -- is rendered for each tag. -- ------------------------------ procedure Render_Cloud (UI : in Tag_UICloud; List : in Tag_Info_Array; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Link : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("tagLink"); Style : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "tagClass"); Font_Size : constant Boolean := True; begin Writer.Start_Element ("ul"); UI.Render_Attributes (Context, Writer); if Link /= null then declare Link : constant EL.Expressions.Expression := UI.Get_Expression ("tagLink"); Name : constant String := UI.Get_Attribute ("var", Context, ""); begin for I in List'Range loop Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Style) then Writer.Write_Attribute ("class", Style); end if; Writer.Start_Element ("a"); Context.Set_Attribute (Name, Util.Beans.Objects.To_Object (List (I).Tag)); Writer.Write_Attribute ("href", Link.Get_Value (Context.Get_ELContext.all)); if Font_Size then Writer.Write_Attribute ("style", "font-size:" & Util.Strings.Image (List (I).Count / 100) & "." & Util.Strings.Image (List (I).Count mod 100) & "px;"); else Writer.Write_Attribute ("class", "tag" & Util.Strings.Image (List (I).Count / 100)); end if; Writer.Write_Text (List (I).Tag); Writer.End_Element ("a"); Writer.End_Element ("li"); end loop; end; else for I in List'Range loop Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Style) then Writer.Write_Attribute ("class", Style); end if; Writer.Write_Text (List (I).Tag); Writer.End_Element ("li"); end loop; end if; Writer.End_Element ("ul"); end Render_Cloud; -- ------------------------------ -- Compute the weight for each tag in the list according to the <tt>minWeight</tt> and -- <tt>maxWeight</tt> attributes. The computed weight is an integer multiplied by 100 -- and will range from 100x<i>minWeight</i> and 100x<i>maxWeight</i>. -- ------------------------------ procedure Compute_Cloud_Weight (UI : in Tag_UICloud; List : in out Tag_Info_Array; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Min : constant Integer := UI.Get_Attribute ("minWeight", Context, 0); Max : constant Integer := UI.Get_Attribute ("maxWeight", Context, 100) - Min; Min_Count : constant Natural := List (List'Last).Count; Max_Count : Natural := List (List'First).Count; begin if Max_Count = Min_Count then Max_Count := Min_Count + 1; end if; for I in List'Range loop if List (I).Count = Min_Count then List (I).Count := 100 * Min; else List (I).Count := (100 * Max * (List (I).Count - Min_Count)) / (Max_Count - Min_Count) + 100 * Min; end if; end loop; end Compute_Cloud_Weight; procedure Swap (Item1 : in out AWA.Tags.Models.Tag_Info; Item2 : in out AWA.Tags.Models.Tag_Info) is Tmp : constant AWA.Tags.Models.Tag_Info := Item2; begin Item2 := Item1; Item1 := Tmp; end Swap; -- ------------------------------ -- A basic algorithm to dispatch the tags in the list. -- The original list is sorted on the tag count (due to the Tag_Ordered_Sets). -- We try to dispatch the first tags somewhere in the first or second halves of the list. -- ------------------------------ procedure Dispatch (List : in out Tag_Info_Array) is Middle : constant Natural := List'First + List'Length / 2; Quarter : Natural := List'Length / 4; Target : Natural := Middle; Pos : Natural := 0; begin while Target <= List'Last and List'First + Pos < Middle and Quarter /= 0 loop Swap (List (List'First + Pos), List (Target)); Pos := Pos + 1; if Target <= Middle then Target := List'Last - Quarter; else Target := List'First + Quarter; Quarter := Quarter / 2; end if; end loop; end Dispatch; -- ------------------------------ -- Render the tag cloud component. -- ------------------------------ overriding procedure Encode_Children (UI : in Tag_UICloud; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is procedure Free is new Ada.Unchecked_Deallocation (Object => Tag_Info_Array, Name => Tag_Info_Array_Access); Table : Tag_Info_Array_Access := null; begin if not UI.Is_Rendered (Context) then return; end if; declare use type Util.Beans.Basic.List_Bean_Access; Max : constant Integer := UI.Get_Attribute ("rows", Context, 1000); Layout : constant String := UI.Get_Attribute ("layout", Context); Bean : constant Util.Beans.Basic.List_Bean_Access := ASF.Components.Utils.Get_List_Bean (UI, "value", Context); Count : Natural; Tags : AWA.Tags.Beans.Tag_Ordered_Sets.Set; List : AWA.Tags.Beans.Tag_Info_List_Bean_Access; begin -- Check that we have a List_Bean but do not complain if we have a null value. if Bean = null or Max <= 0 then return; end if; if not (Bean.all in AWA.Tags.Beans.Tag_Info_List_Bean'Class) then ASF.Components.Base.Log_Error (UI, "Invalid tag list bean: it does not " & "implement 'Tag_Info_List_Bean' interface"); return; end if; List := AWA.Tags.Beans.Tag_Info_List_Bean'Class (Bean.all)'Unchecked_Access; Count := List.Get_Count; if Count = 0 then return; end if; -- Pass 1: Collect the tags and keep the most used. for I in 1 .. Count loop Tags.Insert (List.List.Element (I - 1)); if Integer (Tags.Length) > Max then Tags.Delete_Last; end if; end loop; Count := Natural (Tags.Length); Table := new Tag_Info_Array (1 .. Count); for I in 1 .. Count loop Table (I) := Tags.First_Element; Tags.Delete_First; end loop; -- Pass 2: Assign weight to each tag. UI.Compute_Cloud_Weight (Table.all, Context); -- Pass 3: Dispatch the tags using some layout algorithm. if Layout = "dispatch" then Dispatch (Table.all); end if; -- Pass 4: Render each tag. UI.Render_Cloud (Table.all, Context); Free (Table); exception when others => Free (Table); raise; end; end Encode_Children; begin ASF.Utils.Set_Text_Attributes (READONLY_ATTRIBUTE_NAMES); end AWA.Tags.Components;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.FUNCTIONAL_SETS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2016-2019, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- 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/>. -- ------------------------------------------------------------------------------ pragma Ada_2012; package body Ada.Containers.Functional_Sets with SPARK_Mode => Off is use Containers; --------- -- "=" -- --------- function "=" (Left : Set; Right : Set) return Boolean is (Left.Content <= Right.Content and Right.Content <= Left.Content); ---------- -- "<=" -- ---------- function "<=" (Left : Set; Right : Set) return Boolean is (Left.Content <= Right.Content); --------- -- Add -- --------- function Add (Container : Set; Item : Element_Type) return Set is (Content => Add (Container.Content, Length (Container.Content) + 1, Item)); -------------- -- Contains -- -------------- function Contains (Container : Set; Item : Element_Type) return Boolean is (Find (Container.Content, Item) > 0); --------------------- -- Included_Except -- --------------------- function Included_Except (Left : Set; Right : Set; Item : Element_Type) return Boolean is (for all E of Left => Equivalent_Elements (E, Item) or Contains (Right, E)); ----------------------- -- Included_In_Union -- ----------------------- function Included_In_Union (Container : Set; Left : Set; Right : Set) return Boolean is (for all Item of Container => Contains (Left, Item) or Contains (Right, Item)); --------------------------- -- Includes_Intersection -- --------------------------- function Includes_Intersection (Container : Set; Left : Set; Right : Set) return Boolean is (for all Item of Left => (if Contains (Right, Item) then Contains (Container, Item))); ------------------ -- Intersection -- ------------------ function Intersection (Left : Set; Right : Set) return Set is (Content => Intersection (Left.Content, Right.Content)); -------------- -- Is_Empty -- -------------- function Is_Empty (Container : Set) return Boolean is (Length (Container.Content) = 0); ------------------ -- Is_Singleton -- ------------------ function Is_Singleton (Container : Set; New_Item : Element_Type) return Boolean is (Length (Container.Content) = 1 and New_Item = Get (Container.Content, 1)); ------------ -- Length -- ------------ function Length (Container : Set) return Count_Type is (Length (Container.Content)); ----------------- -- Not_In_Both -- ----------------- function Not_In_Both (Container : Set; Left : Set; Right : Set) return Boolean is (for all Item of Container => not Contains (Right, Item) or not Contains (Left, Item)); ---------------- -- No_Overlap -- ---------------- function No_Overlap (Left : Set; Right : Set) return Boolean is (Num_Overlaps (Left.Content, Right.Content) = 0); ------------------ -- Num_Overlaps -- ------------------ function Num_Overlaps (Left : Set; Right : Set) return Count_Type is (Num_Overlaps (Left.Content, Right.Content)); ------------ -- Remove -- ------------ function Remove (Container : Set; Item : Element_Type) return Set is (Content => Remove (Container.Content, Find (Container.Content, Item))); ----------- -- Union -- ----------- function Union (Left : Set; Right : Set) return Set is (Content => Union (Left.Content, Right.Content)); end Ada.Containers.Functional_Sets;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Characters.Conversions; with Ada.Command_Line; with Ada.Wide_Wide_Text_IO; with Program.Compilation_Unit_Vectors; with Program.Compilation_Units; with Program.Elements.Defining_Names; with Program.Plain_Contexts; with Program.Symbols; with Program.Visibility; with Program.Storage_Pools.Instance; pragma Unreferenced (Program.Storage_Pools.Instance); procedure Dump_Standard is procedure Print (View : Program.Visibility.View); procedure Print (View : Program.Visibility.View_Array); Ctx : aliased Program.Plain_Contexts.Context; Env : aliased Program.Visibility.Context; ----------- -- Print -- ----------- procedure Print (View : Program.Visibility.View_Array) is begin for J in View'Range loop Print (View (J)); end loop; end Print; ----------- -- Print -- ----------- procedure Print (View : Program.Visibility.View) is use Program.Visibility; Name : constant Program.Elements.Defining_Names.Defining_Name_Access := Program.Visibility.Name (View); begin if Name.Assigned then Ada.Wide_Wide_Text_IO.Put_Line (Name.Image & " [" & View_Kind'Wide_Wide_Image (View.Kind) & "]"); else Ada.Wide_Wide_Text_IO.Put_Line ("___ [" & View_Kind'Wide_Wide_Image (View.Kind) & "]"); end if; case View.Kind is when Enumeration_Type_View => Print (Enumeration_Literals (View)); when Signed_Integer_Type_View => null; when Modular_Type_View => null; when Float_Point_Type_View => null; when Array_Type_View => declare Indexes : constant Program.Visibility.View_Array := Program.Visibility.Indexes (View); begin for J in Indexes'Range loop Ada.Wide_Wide_Text_IO.Put (" "); Print (Indexes (J)); end loop; Ada.Wide_Wide_Text_IO.Put (" => "); Print (Program.Visibility.Component (View)); end; when Implicit_Type_View => null; when Enumeration_Literal_View => null; when Character_Literal_View => null; when Subtype_View => Ada.Wide_Wide_Text_IO.Put (" "); Print (Program.Visibility.Subtype_Mark (View)); when Exception_View => null; when Package_View => Print (Immediate_Visible (View, Program.Symbols.Boolean)); Print (Immediate_Visible (View, Program.Symbols.Integer)); Print (Immediate_Visible (View, Ctx.Find ("Natural"))); Print (Immediate_Visible (View, Ctx.Find ("Positive"))); Print (Immediate_Visible (View, Program.Symbols.Float)); Print (Immediate_Visible (View, Program.Symbols.Character)); Print (Immediate_Visible (View, Program.Symbols.String)); Print (Immediate_Visible (View, Ctx.Find ("Constraint_Error"))); end case; end Print; File : constant String := Ada.Command_Line.Argument (1); begin Ctx.Initialize; Ctx.Parse_File (Ada.Characters.Conversions.To_Wide_Wide_String (File), Env); Print (Env.Immediate_Visible (Program.Visibility.Standard)); end Dump_Standard;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.STRINGS.TEXT_OUTPUT.BUFFERS -- -- -- -- S p e c -- -- -- -- Copyright (C) 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 Ada.Strings.Text_Output.Buffers is type Buffer (<>) is new Sink with private; function New_Buffer (Indent_Amount : Natural := Default_Indent_Amount; Chunk_Length : Positive := Default_Chunk_Length) return Buffer; procedure Destroy (S : in out Buffer); -- Reclaim any heap-allocated data, and render the Buffer unusable. -- It would make sense to do this via finalization, but we wish to -- avoid controlled types in the generated code for 'Image. function Get_UTF_8 (S : Buffer'Class) return UTF_8_Lines; -- Get the characters in S, encoded as UTF-8. function UTF_8_Length (S : Buffer'Class) return Natural; procedure Get_UTF_8 (S : Buffer'Class; Result : out UTF_8_Lines) with Pre => Result'First = 1 and Result'Last = UTF_8_Length (S); -- This is a procedure version of the Get_UTF_8 function, for -- efficiency. The Result String must be the exact right length. function Get (S : Buffer'Class) return String; function Wide_Get (S : Buffer'Class) return Wide_String; function Wide_Wide_Get (S : Buffer'Class) return Wide_Wide_String; -- Get the characters in S, decoded as [[Wide_]Wide_]String. -- There is no need for procedure versions of these, because -- they are intended primarily to implement the [[Wide_]Wide_]Image -- attribute, which is already a function. private type Chunk_Count is new Natural; type Buffer is new Sink with record Num_Extra_Chunks : Natural := 0; -- Number of chunks in the linked list, not including Initial_Chunk. end record; overriding procedure Full_Method (S : in out Buffer); overriding procedure Flush_Method (S : in out Buffer) is null; end Ada.Strings.Text_Output.Buffers;
with Ada.Text_IO; procedure Narcissistic is function Is_Narcissistic(N: Natural) return Boolean is Decimals: Natural := 1; M: Natural := N; Sum: Natural := 0; begin while M >= 10 loop M := M / 10; Decimals := Decimals + 1; end loop; M := N; while M >= 1 loop Sum := Sum + (M mod 10) ** Decimals; M := M/10; end loop; return Sum=N; end Is_Narcissistic; Count, Current: Natural := 0; begin while Count < 25 loop if Is_Narcissistic(Current) then Ada.Text_IO.Put(Integer'Image(Current)); Count := Count + 1; end if; Current := Current + 1; end loop; end Narcissistic;
with gel.Window.sdl, gel.Applet.gui_world, gel.Forge, gel.Sprite, gel.hinge_Joint, physics.Model, openGL.Model.box.colored, openGL.Palette, float_math.Algebra.linear.d3, ada.Text_IO, ada.Exceptions; pragma unreferenced (gel.Window.sdl); procedure launch_hinged_Box -- -- Shows variously hinged boxes. -- is package Math renames float_Math; use openGL, openGL.Model.box, opengl.Palette, ada.Text_IO; the_Applet : constant gel.Applet.gui_World.view := gel.Forge.new_gui_Applet ("hinged Box", 1536, 864); X : float_math.Real := 0.0; begin the_Applet.gui_Camera.Site_is ((0.0, 4.0, 30.0)); -- Position the camera. the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboard. the_Applet.Renderer.Background_is (Blue); -- Add sprites and joints. -- declare use float_Math; box_Size : constant gel.Math.Vector_3 := (1.0, 1.0, 1.0); -- Box -- the_box_Model : constant openGL.Model.box.colored.view := openGL.Model.box.colored.new_Box (Size => box_Size, Faces => (Front => (colors => (others => (Red, Opaque))), Rear => (colors => (others => (Blue, Opaque))), Upper => (colors => (others => (Violet, Opaque))), Lower => (colors => (others => (Yellow, Opaque))), Left => (colors => (others => (Cyan, Opaque))), Right => (colors => (others => (Magenta, Opaque))))); the_static_box_physics_Model : constant physics.Model.view := physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube, half_Extents => box_Size)); the_dynamic_box_physics_Model : constant physics.Model.view := physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube, half_Extents => box_Size / 2.0), Mass => 1.0); the_Box_1 : constant gel.Sprite.view := gel.Sprite.forge.new_Sprite ("demo.Box.static.1", the_Applet.gui_World.all'Access, math.Origin_3d, the_box_Model.all'Access, the_static_box_physics_Model, owns_Graphics => False, owns_Physics => True); the_Box_2 : constant gel.Sprite.view := gel.Sprite.forge.new_Sprite ("demo.Box.dynamic.2", the_Applet.gui_World.all'Access, math.Origin_3d, the_box_Model.all'Access, the_dynamic_box_physics_Model, owns_Graphics => False, owns_Physics => False); the_Box_3 : constant gel.Sprite.view := gel.Sprite.forge.new_Sprite ("demo.Box.dynamic.3", the_Applet.gui_World.all'Access, math.Origin_3d, the_box_Model.all'Access, the_dynamic_box_physics_Model, owns_Graphics => True, owns_Physics => True); the_Joint_1 : constant gel.hinge_Joint.view := new gel.hinge_Joint.item; the_Joint_2 : constant gel.hinge_Joint.view := new gel.hinge_Joint.item; begin the_Applet.gui_World.Gravity_is ((0.0, -10.0, 0.0)); the_Applet.gui_World.add (the_Box_1); the_Applet.gui_World.add (the_Box_2); the_Applet.gui_World.add (the_Box_3); the_Box_1.Site_is (( 0.0, 0.0, 0.0)); the_Box_2.Site_is (( -1.0, 2.0, 0.0)); the_Box_3.Site_is (( 10.0, 10.0, 0.0)); -- the_Box_3.Site_is (( 10.0, 10.0, 0.0)); declare use math.Algebra.linear.d3; Frame_1 : constant math.Matrix_4x4 := math.Identity_4x4; Frame_2 : math.Matrix_4x4 := math.Identity_4x4; Frame_3 : math.Matrix_4x4 := math.Identity_4x4; y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (180.0)); begin set_Translation (Frame_2, (2.0, 2.0, 0.0)); set_Translation (Frame_3, (8.0, 8.0, 0.0)); -- set_Translation (Frame_3, (8.0, 8.0, 0.0)); -- set_Translation (Frame_B, y_Rot * math.Vector_3'( -2.0, 0.0, 0.0)); -- -- set_Rotation (Frame_A, x_Rotation_from (to_Radians (0.0))); -- set_Rotation (Frame_B, y_Rot); the_Joint_1.define (the_Applet.gui_World.Space, the_Box_3, Frame_3); the_Joint_2.define (the_Applet.gui_World.Space, the_Box_1, the_Box_2, Frame_1, Frame_2, low_Limit => to_Radians (-360.0), high_Limit => to_Radians ( 360.0), collide_Conected => False); -- TODO: -- the_Joint_2.define (the_Applet.gui_World.Space, -- the_Box_1, the_Box_2, -- pivot_Axis => (0.0, 0.0, 0.0)); -- the_Joint.low_Bound_is (Pitch, 0.0); -- the_Joint.low_Bound_is (Yaw, 0.0); -- the_Joint.low_Bound_is (Roll, 0.0); -- -- the_Joint.high_Bound_is (Pitch, 0.0); -- the_Joint.high_Bound_is (Yaw, 0.0); -- the_Joint.high_Bound_is (Roll, 0.0); end; the_Applet.gui_World.add (the_Joint_1.all'Access); -- Add joint to the world. the_Applet.gui_World.add (the_Joint_2.all'Access); -- Add joint to the world. end; while the_Applet.is_open loop the_Applet.freshen; -- Handle any new events and update the screen. end loop; the_Applet.destroy; exception when E : others => new_Line; put_Line ("Unhandled exception in main thread !"); put_Line (ada.Exceptions.exception_Information (E)); new_Line; end launch_hinged_Box;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with League.Strings; with League.String_Vectors; package Processes is type Environment is record Names : League.String_Vectors.Universal_String_Vector; Values : League.String_Vectors.Universal_String_Vector; end record; No_Env : constant Environment := (others => <>); procedure Run (Program : League.Strings.Universal_String; Arguments : League.String_Vectors.Universal_String_Vector; Directory : League.Strings.Universal_String; Env : Environment := No_Env; Output : out League.Strings.Universal_String; Errors : out League.Strings.Universal_String; Status : out Integer); end Processes;
package STM32GD.Startup is pragma Preelaborate; procedure Reset_Handler with Export => True, External_Name => "_start_rom"; pragma Machine_Attribute (Reset_Handler, "naked"); pragma Weak_External (Reset_Handler); end STM32GD.Startup;
-- AoC 2020, Day 10 with Ada.Text_IO; with Ada.Containers.Ordered_Maps; package body Day is package TIO renames Ada.Text_IO; function load_file(filename : in String) return Adaptors.Vector is package Natural_Text_IO is new Ada.Text_IO.Integer_IO(Natural); package Adaptor_Sorter is new Adaptors.Generic_Sorting; file : TIO.File_Type; v : Adaptors.Vector := Empty_Vector; n : Natural := 0; begin TIO.open(File => file, Mode => TIO.In_File, Name => filename); while not TIO.end_of_file(file) loop Natural_Text_IO.get(file, n); v.append(n); end loop; TIO.close(file); Adaptor_Sorter.sort(Container => v); return v; end load_file; function mult_diffs(v : in Adaptors.Vector) return Natural is diff_1 : Natural := 0; diff_3 : Natural := 0; curr : Natural; last : Natural := v.first_element; begin for idx in v.first_index+1 .. v.last_index loop curr := v(idx); case curr - last is when 3 => diff_3 := diff_3 + 1; when 1 => diff_1 := diff_1 + 1; when others => null; end case; last := curr; end loop; return diff_1 * diff_3; end mult_diffs; function mult_1_3_differences(v : in Adaptors.Vector) return Natural is remaining : Adaptors.Vector := v; begin remaining.prepend(0); remaining.append(remaining.last_element + 3); return mult_diffs(remaining); end mult_1_3_differences; package Reachable_Map is new Ada.Containers.Ordered_Maps (Element_Type => Long_Integer, Key_Type => Natural); use Reachable_Map; reach_map : Reachable_Map.Map := Empty_Map; function count(curr_idx : in Natural; v : in Adaptors.Vector) return Long_Integer is curr_value : constant Natural := v(curr_idx); total : Long_Integer := 0; last_idx : constant Natural := Natural'Min(curr_idx+3, v.last_index); begin if contains(reach_map, curr_value) then return reach_map(curr_value); end if; for next_idx in curr_idx+1..last_idx loop if v(next_idx) + 3 >= curr_value then total := total + count(next_idx, v); end if; end loop; reach_map.insert(curr_value, total); return total; end count; function total_arrangments(v : in Adaptors.Vector) return Long_Integer is v_first_last : Adaptors.Vector := v; begin v_first_last.prepend(0); v_first_last.append(v_first_last.last_element + 3); reverse_elements(v_first_last); clear(reach_map); reach_map.insert(0, 1); return count(v_first_last.first_index, v_first_last); end total_arrangments; end Day;
package display is --IMPORTANT: This function must be called before any other functions --This Initializes the package for use procedure Initialize(width, height : Integer); --The color type consists of 4 ANSI codes in series [ 0 ; 27 ; 37 ; 40 m --A code or string of codes must always begin with the ESC character (ASCII.ESC or Character'Val(27)) --The Codes are usually 2 digits long and usually start with '[' and end with 'm', but not always --Codes in series are separated by ';' --References for ANSI codes : http://ascii-table.com/ansi-escape-sequences-vt-100.php -- http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html --Below subtype colorType is String(1..13); --colors colorDefault: constant colorType := ASCII.ESC & "[0;27;37;40m"; --red colorRed : constant colorType := ASCII.ESC & "[0;27;31;40m"; colorRedL : constant colorType := ASCII.ESC & "[1;27;31;40m"; colorRedI : constant colorType := ASCII.ESC & "[0;07;31;40m"; --green colorGreen : constant colorType := ASCII.ESC & "[0;27;32;40m"; colorGreenL : constant colorType := ASCII.ESC & "[1;27;32;40m"; colorGreenI : constant colorType := ASCII.ESC & "[0;07;32;40m"; --yellow colorYellow : constant colorType := ASCII.ESC & "[0;27;33;40m"; colorYellowL: constant colorType := ASCII.ESC & "[1;27;33;40m"; colorYellowI: constant colorType := ASCII.ESC & "[0;07;33;40m"; --blue colorBlue : constant colorType := ASCII.ESC & "[0;27;34;40m"; colorBlueL : constant colorType := ASCII.ESC & "[1;27;34;40m"; colorBlueI : constant colorType := ASCII.ESC & "[0;07;34;40m"; --magenta colorMag : constant colorType := ASCII.ESC & "[0;27;35;40m"; colorMagL : constant colorType := ASCII.ESC & "[1;27;35;40m"; colorMagI : constant colorType := ASCII.ESC & "[0;07;35;40m"; --cyan colorCyan : constant colorType := ASCII.ESC & "[0;27;36;40m"; colorCyanL : constant colorType := ASCII.ESC & "[1;27;36;40m"; colorCyanI : constant colorType := ASCII.ESC & "[0;07;36;40m"; --black colorBlack : constant colorType := ASCII.ESC & "[0;27;30;40m"; colorBlackL : constant colorType := ASCII.ESC & "[1;27;30;40m"; colorBlackI : constant colorType := ASCII.ESC & "[0;07;30;40m"; --white colorWhite : constant colorType := ASCII.ESC & "[0;27;37;40m"; colorWhiteL : constant colorType := ASCII.ESC & "[1;27;37;40m"; colorWhiteI : constant colorType := ASCII.ESC & "[0;07;37;40m"; --A PixelType contains a character and a colorType Type PixelType is record char : Character; color : colorType; end record; --tests if 2 pixels are the same function "=" (L, R : pixelType) return Boolean; --an imageBox is a 2-dimensional array of pixelType Type ImageBox is array(0..127,0..63) of PixelType; --a sprite is an image that can be placed and moved around on the screen Type SpriteType is record Width : Integer; Height : Integer; Image : ImageBox; color : colorType;--deprecated end record; --Character constants --These Constants contain symbols that look best when using the Terminal font --NOTE: these characters must be entered with Character'Val(charID). The compiler will not accept these in strings --Refernece for Extended ASCII: http://www.asciitable.com/index/extend.gif Char_Block : constant Character := character'val(219);-- Û Char_BorderV : constant Character := character'val(186);-- º Vertical Border Char_BorderH : constant Character := character'val(205);-- Í Horizontal Border Char_BorderTL : constant Character := character'val(201);-- É Top Left Corner Char_BorderTR : constant Character := character'val(187);-- » Top Right Corner Char_BorderBL : constant Character := character'val(200);-- È Bottom Left Corner Char_BorderBR : constant Character := character'val(188);-- ¼ Bottom Right Corner --screen width and height. These start at 0, so a width of 149 is actually 150 pixels wide Screen_Width : Integer := 149; Screen_Height : Integer := 39; --this defines the screen; Screen : array(0..Screen_Width,0..Screen_Height) of PixelType; --sets a pixel on the screen with the piven character and color(optional) procedure setPixel(X,Y : Integer; char : character; color : colorType := colorDefault); procedure setPixel(X,Y : Integer; pixel : PixelType); --returns the pixel at the position X,Y function getPixel(X,Y : Integer) return PixelType; --loads a formatted sprite file --To format a sprite file, you must use the spritemaker executable and convert an unformatted sprite --an unformatted sprite is a text file that contains: (width height) new line (ASCII image) function LoadSprite(FileName : String) return SpriteType; procedure SetSprite(posX, posY : Integer; sprite : SpriteType); --text functions --these set Text on the screen starting at position X,Y; Left Aligned procedure setText(posX,posY : Integer; Item : String; color : colorType := colorDefault); procedure setText(posX,posY : Integer; Item : Character; color : colorType := colorDefault); --Refresh Screen --This must be called to draw the screen to the console --take care not to call this too often, it can be slow procedure Refresh; --ClearDisplay resets the display array to blank spaces -- This does NOT clear the screen procedure ClearDisplay; --WipeScreen physically clears the console --This does not reset the display array --it is recommended not to use this often, but it is useful procedure WipeScreen; Private end display;
with OpenGL.Thin; with OpenGL.Types; package OpenGL.Buffer is type Buffer_Mask_t is new Thin.Bitfield_t; Color_Buffer : constant Buffer_Mask_t := Thin.GL_COLOR_BUFFER_BIT; Depth_Buffer : constant Buffer_Mask_t := Thin.GL_DEPTH_BUFFER_BIT; Accumulation_Buffer : constant Buffer_Mask_t := Thin.GL_ACCUM_BUFFER_BIT; Stencil_Buffer : constant Buffer_Mask_t := Thin.GL_STENCIL_BUFFER_BIT; -- proc_map : glClear procedure Clear (Mask : in Buffer_Mask_t); pragma Inline (Clear); -- proc_map : glClearColor procedure Clear_Color (Red : in OpenGL.Types.Clamped_Float_t; Green : in OpenGL.Types.Clamped_Float_t; Blue : in OpenGL.Types.Clamped_Float_t; Alpha : in OpenGL.Types.Clamped_Float_t); pragma Inline (Clear_Color); end OpenGL.Buffer;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Containers.Vectors; package Plugins is type Dummy_Type is null record; type No_Parameters is access Dummy_Type; -- This type is handy for those plugins that require no parameters. package Parameter_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String, Element_Type => String); subtype Parameter_Map is Parameter_Maps.Map; type Parameter_Map_Access is access Parameter_Maps.Map; -- Another very common case of plugin parameters: a map -- parameter name --> parameter value. The parameters have no special -- order and every name has at most one value Empty_Map : constant Parameter_Map_Access := new Parameter_Maps.Map'(Parameter_Maps.Empty_Map); type Parameter_Pair is record Name : Unbounded_String; Value : Unbounded_String; end record; function "<" (L, R : Parameter_Pair) return Boolean is (L.Name < R.Name or else (L.Name = R.Name and L.Value < R.Value)); package Parameter_Lists is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Parameter_Pair); package Parameter_List_Sorting is new Parameter_Lists.Generic_Sorting; type Parameter_List is access Parameter_Lists.Vector; -- A third common case: a sequence of pairs (name, value). Note -- that in this case there is an ordering and that every name can have -- more than one value. A Parameter_List can be sorted according to -- the parameter name by using the subroutines in Parameter_List_Sorting. end Plugins;
-- Internal package -- A placeholder is a hole / wild card for AST matching. -- A placeholder can also act as backreference: -- * when a placeholder occurs multiple times within a single find pattern, -- these parts should be identical to match -- * when a placeholder occurs within a replace pattern, -- it refer to the part that matches that placeholder in the find pattern. -- There are two types of placeholders: -- $S_ : denotes exactly one node -- $M_ : denotes zero or more nodes with String_Sets; use String_Sets; package Rejuvenation.Placeholders is function Is_Placeholder_Name (Name : String) return Boolean; -- Is the provided name a placeholder name? -- A placeholder name is an identifier that starts with '$M_' or '$S_' function Is_Single_Placeholder_Name (Name : String) return Boolean; function Is_Multiple_Placeholder_Name (Name : String) return Boolean; function Is_Placeholder (Node : Ada_Node'Class) return Boolean; -- Is the provide node a placeholder? function Is_Single_Placeholder (Node : Ada_Node'Class) return Boolean; function Is_Multiple_Placeholder (Node : Ada_Node'Class) return Boolean; function Get_Placeholder_Name (Node : Ada_Node'Class) return String with Pre => Is_Placeholder (Node), Post => Is_Placeholder_Name (Get_Placeholder_Name'Result); -- Get the name of placeholder. function Get_Placeholders (Node : Ada_Node'Class) return Node_List.Vector with Post => (for all Element of Get_Placeholders'Result => Is_Placeholder (Element)); -- Provide a list with all placeholder nodes within the given node. -- The list might contain multiple placeholder nodes that share the -- same placeholder name. These nodes, of course, differ in their -- position within the text / AST tree. -- TODO: should we promiss the nodes appear in their textual order? function Get_Placeholder_Names (Node : Ada_Node'Class) return Set; -- Provide a set with all placeholder names within the given node. end Rejuvenation.Placeholders;
------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2019, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Discrete_Random; with Ada.Real_Time; use Ada.Real_Time; with Interfaces.SAM; use Interfaces.SAM; with Interfaces.SAM.PMC; use Interfaces.SAM.PMC; with Interfaces.SAM.PIO; use Interfaces.SAM.PIO; with System.SAMV71; use System.SAMV71; procedure Leds is LED0 : constant := 2 ** 23; -- PA23 LED1 : constant := 2 ** 9; -- PC09 procedure Wait (Period : Time_Span) is begin delay until (Period + Clock); end Wait; procedure Flip_Coin is type Coin is (Heads, Tails); package Random_Coin is new Ada.Numerics.Discrete_Random (Coin); use Random_Coin; G : Generator; begin Reset (G); loop -- simulate flipping for I in 1 .. 10 loop PIOA_Periph.PIO_SODR.Val := LED0; PIOC_Periph.PIO_CODR.Val := LED1; Wait (Period => Milliseconds (50)); PIOA_Periph.PIO_CODR.Val := LED0; PIOC_Periph.PIO_SODR.Val := LED1; Wait (Period => Milliseconds (50)); end loop; -- Clear LEDS and delay PIOA_Periph.PIO_SODR.Val := LED0; PIOC_Periph.PIO_SODR.Val := LED1; Wait (Period => Milliseconds (300)); -- check result case Random (G) is when Heads => PIOA_Periph.PIO_SODR.Val := LED0; PIOC_Periph.PIO_CODR.Val := LED1; when Tails => PIOA_Periph.PIO_CODR.Val := LED0; PIOC_Periph.PIO_SODR.Val := LED1; end case; -- delay and repeat Wait (Period => Milliseconds (2000)); end loop; end Flip_Coin; begin -- Enable clock for GPIO-A and GPIO-C PMC_Periph.PMC_PCER0.PID.Val := 2 ** PIOA_ID + 2 ** PIOC_ID; -- PIO Enable PIOA_Periph.PIO_PER.Val := LED0; PIOC_Periph.PIO_PER.Val := LED1; PIOA_Periph.PIO_OER.Val := LED0; PIOC_Periph.PIO_OER.Val := LED1; PIOA_Periph.PIO_CODR.Val := LED0; PIOC_Periph.PIO_CODR.Val := LED1; PIOA_Periph.PIO_MDDR.Val := LED0; PIOC_Periph.PIO_MDDR.Val := LED1; Flip_Coin; end Leds;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Finalization; package Yaml.Transformator is type Instance is abstract tagged limited private; type Pointer is access Instance'Class; procedure Put (Object : in out Instance; E : Event) is abstract; function Has_Next (Object : Instance) return Boolean is abstract; function Next (Object : in out Instance) return Event is abstract; private type Instance is abstract limited new Ada.Finalization.Limited_Controlled with null record; end Yaml.Transformator;
-- ============================================================================= -- Package body AVR.IMAGE -- ============================================================================= package body IMAGE is procedure U8_Img_Right (Data : Unsigned_8; Target : out AVR.USART.String_U8) is D : Unsigned_8 := Data; begin for Index in Target'Range loop Target (Index) := ' '; end loop; if D >= 100 then Target (Target'First) := Character'Val (48 + (D / 100)); D := D rem 100; else Target (Target'First) := ' '; end if; if D >= 10 or else Data >= 100 then Target (Target'First + 1) := Character'Val (48 + (D / 10)); else Target (Target'First + 1) := ' '; end if; Target (Target'First + 2) := Character'Val (48 + (D rem 10)); exception when others => null; end U8_Img_Right; function Unsigned_8_To_String_Simon (Input : Unsigned_8) return String_3 is Result : String_3 := (others => ' '); Digit : Unsigned_8; Rest_Of_Number : Unsigned_8; begin Digit := Input mod 10; Rest_Of_Number := Input / 10; for J in reverse Result'Range loop if Digit /= 0 or else Rest_Of_Number /= 0 or else J = Result'Last then Result (J) := Character'Val (Character'Pos ('0') + Integer (Digit)); end if; Digit := Rest_Of_Number mod 10; Rest_Of_Number := Rest_Of_Number / 10; -- could exit when Rest_Of_Number = 0 end loop; return Result; exception when others => return " "; end Unsigned_8_To_String_Simon; function Unsigned_8_To_String_Shark8 (Input : Unsigned_8) return String_3 is -- A temporary variable for manipulation, initialized to input. Working : Unsigned_8 := Input; begin -- Extended return, we do not have to initialize any characters -- because they will be in range '0'..'9' with leading zeros. return Result : String_3 do -- We assign the digit it's proper value, based on its -- position within the string. for Digit in reverse Result'Range loop Result (Digit) := Character'Val ( -- We add the mod 10 value of working -- to the value of '0' to get the proper -- digit-character. Natural (Working mod 10) + Character'Pos('0') ); -- We adjust our working-variable, by dividing it by 10. Working := Working / 10; end loop; end return; exception when others => return " "; end Unsigned_8_To_String_Shark8; function String_To_Unsigned_8 (Input : AVR.USART.String_U8) return Unsigned_8 is Result : Unsigned_8 := 0; begin for Digit in Input'Range loop Result := 10 * Result + (Character'Pos (Input (Digit)) - Character'Pos ('0')); end loop; return Result; end String_To_Unsigned_8; function String_To_Unsigned_32 (Input : AVR.USART.String_U8) return Unsigned_32 is Result : Unsigned_32 := 0; begin for Digit in Input'Range loop Result := 10 * Result + (Character'Pos (Input (Digit)) - Character'Pos ('0')); end loop; return Result; end String_To_Unsigned_32; function String_To_Unsigned_8_Shark8 (Input : String_3) return Unsigned_8 is Working : String_3 := Input; Index : Unsigned_8 := 1; begin -- Preprocessing string: spaces are treated as 0. for C of Working loop C := (if C = ' ' then '0' else C); -- throw error if invalid characters exist. if C not in Digit then raise Numeric_Error; end if; -- Note a case statement might habe been -- nore appropriate for this block. end loop; return Result : Unsigned_8 := 0 do for C of reverse Working loop -- We add the current character's value, multiplied -- by its position, to modify result. Result:= Result + Index * (Character'Pos(C) - Character'Pos('0')); -- The following works because wrap-around isn't an error. -- If we weren't using Unsigned_8 we would need a cast. Index:= Index * 10; end loop; end return; exception when others => return 0; end String_To_Unsigned_8_Shark8; function Compare_String_U8 (Left, Right : in AVR.USART.String_U8) return Boolean is Return_Test : Boolean := True; begin if Left'Length /= Right'Length then raise Constraint_Error; end if; for Index in Left'Range loop if Left (Index) /= Right (Index) then Return_Test := False; exit; end if; end loop; return Return_Test; exception when others => return False; end Compare_String_U8; end IMAGE;
function IsDivisible(x, y: IN Integer) return Integer is Result : Integer; begin Result := 0; if y = 0 or else x = 0 then Result := 0; else Result := x / y; end if; if y = 0 and then x = 0 then Result := 0; else Result := x * (x / y ); end if; return Result; end IsDivisible;
with Ada.Text_IO; use Ada.Text_IO; procedure P is type t; begin put('a'); end;
with Widgets; with Aof.Core.Properties; package Labels is type Label is new Widgets.Widget with record -- Properties: Label_Text : Aof.Core.Properties.Unbounded_Strings.Property; end record; type Label_Ptr is access all Label'Class; -- Slots: procedure Paint_Event (This : in out Label'Class); end Labels;
-- Copyright 2016-2019 NXP -- All rights reserved.SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from LPC55S6x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NXP_SVD.GINT is pragma Preelaborate; --------------- -- Registers -- --------------- -- Group interrupt status. This bit is cleared by writing a one to it. -- Writing zero has no effect. type CTRL_INT_Field is ( -- No request. No interrupt request is pending. No_Request, -- Request active. Interrupt request is active. Request_Active) with Size => 1; for CTRL_INT_Field use (No_Request => 0, Request_Active => 1); -- Combine enabled inputs for group interrupt type CTRL_COMB_Field is ( -- Or. OR functionality: A grouped interrupt is generated when any one -- of the enabled inputs is active (based on its programmed polarity). Or_k, -- And. AND functionality: An interrupt is generated when all enabled -- bits are active (based on their programmed polarity). And_k) with Size => 1; for CTRL_COMB_Field use (Or_k => 0, And_k => 1); -- Group interrupt trigger type CTRL_TRIG_Field is ( -- Edge-triggered. Edge_Triggered, -- Level-triggered. Level_Triggered) with Size => 1; for CTRL_TRIG_Field use (Edge_Triggered => 0, Level_Triggered => 1); -- GPIO grouped interrupt control register type CTRL_Register is record -- Group interrupt status. This bit is cleared by writing a one to it. -- Writing zero has no effect. INT : CTRL_INT_Field := NXP_SVD.GINT.No_Request; -- Combine enabled inputs for group interrupt COMB : CTRL_COMB_Field := NXP_SVD.GINT.Or_k; -- Group interrupt trigger TRIG : CTRL_TRIG_Field := NXP_SVD.GINT.Edge_Triggered; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CTRL_Register use record INT at 0 range 0 .. 0; COMB at 0 range 1 .. 1; TRIG at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- GPIO grouped interrupt port 0 polarity register -- GPIO grouped interrupt port 0 polarity register type PORT_POL_Registers is array (0 .. 1) of HAL.UInt32 with Volatile; -- GPIO grouped interrupt port 0 enable register -- GPIO grouped interrupt port 0 enable register type PORT_ENA_Registers is array (0 .. 1) of HAL.UInt32 with Volatile; ----------------- -- Peripherals -- ----------------- -- Group GPIO input interrupt (GINT0/1) type GINT_Peripheral is record -- GPIO grouped interrupt control register CTRL : aliased CTRL_Register; -- GPIO grouped interrupt port 0 polarity register PORT_POL : aliased PORT_POL_Registers; -- GPIO grouped interrupt port 0 enable register PORT_ENA : aliased PORT_ENA_Registers; end record with Volatile; for GINT_Peripheral use record CTRL at 16#0# range 0 .. 31; PORT_POL at 16#20# range 0 .. 63; PORT_ENA at 16#40# range 0 .. 63; end record; -- Group GPIO input interrupt (GINT0/1) GINT0_Periph : aliased GINT_Peripheral with Import, Address => System'To_Address (16#40002000#); -- Group GPIO input interrupt (GINT0/1) GINT1_Periph : aliased GINT_Peripheral with Import, Address => System'To_Address (16#40003000#); end NXP_SVD.GINT;
----------------------------------------------------------------------- -- util-streams-aes -- AES encoding and decoding streams -- Copyright (C) 2019 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.Encoders.AES; with Util.Streams.Buffered.Encoders; -- == AES Encoding Streams == -- The `Util.Streams.AES` package define the `Encoding_Stream` and `Decoding_Stream` types to -- encrypt and decrypt using the AES cipher. Before using these streams, you must use -- the `Set_Key` procedure to setup the encryption or decryption key and define the AES -- encryption mode to be used. The following encryption modes are supported: -- -- * AES-ECB -- * AES-CBC -- * AES-PCBC -- * AES-CFB -- * AES-OFB -- * AES-CTR -- -- The encryption and decryption keys are represented by the `Util.Encoders.Secret_Key` limited -- type. The key cannot be copied, has its content protected and will erase the memory once -- the instance is deleted. The size of the encryption key defines the AES encryption level -- to be used: -- -- * Use 16 bytes, or `Util.Encoders.AES.AES_128_Length` for AES-128, -- * Use 24 bytes, or `Util.Encoders.AES.AES_192_Length` for AES-192, -- * Use 32 bytes, or `Util.Encoders.AES.AES_256_Length` for AES-256. -- -- Other key sizes will raise a pre-condition or constraint error exception. -- The recommended key size is 32 bytes to use AES-256. The key could be declared as follows: -- -- Key : Util.Encoders.Secret_Key -- (Length => Util.Encoders.AES.AES_256_Length); -- -- The encryption and decryption key are initialized by using the `Util.Encoders.Create` -- operations or by using one of the key derivative functions provided by the -- `Util.Encoders.KDF` package. A simple string password is created by using: -- -- Password_Key : constant Util.Encoders.Secret_Key -- := Util.Encoders.Create ("mysecret"); -- -- Using a password key like this is not the good practice and it may be useful to generate -- a stronger key by using one of the key derivative function. We will use the -- PBKDF2 HMAC-SHA256 with 20000 loops (see RFC 8018): -- -- Util.Encoders.KDF.PBKDF2_HMAC_SHA256 (Password => Password_Key, -- Salt => Password_Key, -- Counter => 20000, -- Result => Key); -- -- To write a text, encrypt the content and save the file, we can chain several stream objects -- together. Because they are chained, the last stream object in the chain must be declared -- first and the first element of the chain will be declared last. The following declaration -- is used: -- -- Out_Stream : aliased Util.Streams.Files.File_Stream; -- Cipher : aliased Util.Streams.AES.Encoding_Stream; -- Printer : Util.Streams.Texts.Print_Stream; -- -- The stream objects are chained together by using their `Initialize` procedure. -- The `Out_Stream` is configured to write on the `encrypted.aes` file. -- The `Cipher` is configured to write in the `Out_Stream` with a 32Kb buffer. -- The `Printer` is configured to write in the `Cipher` with a 4Kb buffer. -- -- Out_Stream.Initialize (Mode => Ada.Streams.Stream_IO.In_File, -- Name => "encrypted.aes"); -- Cipher.Initialize (Output => Out_Stream'Access, -- Size => 32768); -- Printer.Initialize (Output => Cipher'Access, -- Size => 4096); -- -- The last step before using the cipher is to configure the encryption key and modes: -- -- Cipher.Set_Key (Secret => Key, Mode => Util.Encoders.AES.ECB); -- -- It is now possible to write the text by using the `Printer` object: -- -- Printer.Write ("Hello world!"); -- -- package Util.Streams.AES is package Encoding is new Util.Streams.Buffered.Encoders (Encoder => Util.Encoders.AES.Encoder); package Decoding is new Util.Streams.Buffered.Encoders (Encoder => Util.Encoders.AES.Decoder); type Encoding_Stream is new Encoding.Encoder_Stream with null record; -- Set the encryption key and mode to be used. procedure Set_Key (Stream : in out Encoding_Stream; Secret : in Util.Encoders.Secret_Key; Mode : in Util.Encoders.AES.AES_Mode := Util.Encoders.AES.CBC); -- Set the encryption initialization vector before starting the encryption. procedure Set_IV (Stream : in out Encoding_Stream; IV : in Util.Encoders.AES.Word_Block_Type); type Decoding_Stream is new Decoding.Encoder_Stream with null record; -- Set the encryption key and mode to be used. procedure Set_Key (Stream : in out Decoding_Stream; Secret : in Util.Encoders.Secret_Key; Mode : in Util.Encoders.AES.AES_Mode := Util.Encoders.AES.CBC); -- Set the encryption initialization vector before starting the encryption. procedure Set_IV (Stream : in out Decoding_Stream; IV : in Util.Encoders.AES.Word_Block_Type); end Util.Streams.AES;
package body agar.gui.widget.hbox is package cbinds is procedure set_homogenous (box : hbox_access_t; homogenous : c.int); pragma import (c, set_homogenous, "agar_gui_widget_hbox_set_homogenous"); procedure set_padding (box : hbox_access_t; padding : c.int); pragma import (c, set_padding, "agar_gui_widget_hbox_set_padding"); procedure set_spacing (box : hbox_access_t; spacing : c.int); pragma import (c, set_spacing, "agar_gui_widget_hbox_set_spacing"); end cbinds; procedure set_homogenous (box : hbox_access_t; homogenous : boolean := true) is begin if homogenous then cbinds.set_homogenous (box, 1); else cbinds.set_homogenous (box, 0); end if; end set_homogenous; procedure set_padding (box : hbox_access_t; padding : natural) is begin cbinds.set_padding (box => box, padding => c.int (padding)); end set_padding; procedure set_spacing (box : hbox_access_t; spacing : natural) is begin cbinds.set_spacing (box => box, spacing => c.int (spacing)); end set_spacing; function widget (box : hbox_access_t) return widget_access_t is begin return agar.gui.widget.box.widget (box.box'access); end widget; end agar.gui.widget.hbox;
with Extraction.Node_Edge_Types; with Extraction.Utilities; package body Extraction.Decls is use type LALCO.Ada_Node_Kind_Type; function Is_Standard_Package_Decl(Node : LAL.Ada_Node'Class) return Boolean is Standard_Unit : constant LAL.Compilation_Unit := Node.P_Standard_Unit.Root.As_Compilation_Unit; Standard_Pkg_Decl : constant LAL.Basic_Decl := Standard_Unit.F_Body.As_Library_Item.F_Item; begin return Node.Kind = LALCO.Ada_Package_Decl and then Node = Standard_Pkg_Decl; end Is_Standard_Package_Decl; procedure Extract_Nodes (Node : LAL.Ada_Node'Class; Graph : Graph_Operations.Graph_Context) is begin if Utilities.Is_Relevant_Basic_Decl(Node) then declare Basic_Decl : constant LAL.Basic_Decl := Node.As_Basic_Decl; begin for Defining_Name of Basic_Decl.P_Defining_Names loop Graph.Write_Node(Defining_Name, Basic_Decl); end loop; end; end if; end Extract_Nodes; procedure Extract_Edges (Node : LAL.Ada_Node'Class; Graph : Graph_Operations.Graph_Context) is begin if Utilities.Is_Relevant_Basic_Decl(Node) and then not Is_Standard_Package_Decl(Node) then declare Basic_Decl : constant LAL.Basic_Decl := Node.As_Basic_Decl; Parent : constant LAL.Basic_Decl := Utilities.Get_Parent_Basic_Decl(Basic_Decl); begin for Defining_Name of Basic_Decl.P_Defining_Names loop Graph.Write_Edge(Defining_Name, Basic_Decl, Basic_Decl.Unit, Node_Edge_Types.Edge_Type_Source); if not Basic_Decl.P_Is_Compilation_Unit_Root or else Basic_Decl.Parent.Kind = LALCO.Ada_Subunit then Graph.Write_Edge(Parent, Defining_Name, Basic_Decl, Node_Edge_Types.Edge_Type_Contains); elsif Parent.P_Body_Part_For_Decl /= Basic_Decl and then not Is_Standard_Package_Decl(Parent) then Graph.Write_Edge(Parent, Defining_Name, Basic_Decl, Node_Edge_Types.Edge_Type_Is_Parent_Of); end if; end loop; end; end if; end Extract_Edges; end Extraction.Decls;
------------------------------------------------------------ -- -- ADA REAL-TIME TIME-TRIGGERED SCHEDULING SUPPORT -- -- @file time_triggered_scheduling.ads -- -- @package Time_Triggered_Scheduling (SPEC) -- -- @brief -- Ada Real-Time Time Triggered Scheduling support: Time Triggered Scheduling -- -- Ravenscar version ------------------------------------------------------------ pragma Profile (Ravenscar); private with Ada.Real_Time.Timing_Events, System; with Ada.Real_Time; use Ada.Real_Time; generic Number_Of_Work_IDs : Positive; package Time_Triggered_Scheduling is -- Work identifier types type Any_Work_Id is new Integer range Integer'First .. Number_Of_Work_IDs; subtype Special_Work_Id is Any_Work_Id range Any_Work_Id'First .. 0; subtype Regular_Work_Id is Any_Work_Id range 1 .. Any_Work_Id'Last; -- Special IDs Empty_Slot : constant Special_Work_Id; Mode_Change_Slot : constant Special_Work_Id; -- A time slot in the TT plan type Time_Slot is record Slot_Duration : Time_Span; Work_Id : Any_Work_Id; Next_Slot_Separation : Time_Span := Time_Span_Zero; -- User_Defined_Info: Any_User_Defined_Info; end record; -- Types representing/accessing TT plans type Time_Triggered_Plan is array (Natural range <>) of Time_Slot; type Time_Triggered_Plan_Access is access all Time_Triggered_Plan; -- Set new TT plan to start at the end of the next mode change slot procedure Set_Plan (TTP : in Time_Triggered_Plan_Access); -- TT works use this procedure to wait for their next assigned slot -- The When_Was_Released result informs caller of slot starting time procedure Wait_For_Activation (Work_Id : Regular_Work_Id; When_Was_Released : out Time); private use Ada.Real_Time.Timing_Events; Empty_Slot : constant Special_Work_Id := 0; Mode_Change_Slot : constant Special_Work_Id := -1; protected Time_Triggered_Scheduler with Priority => System.Interrupt_Priority'Last is -- Setting a new TT plan procedure Set_Plan (TTP : in Time_Triggered_Plan_Access); private -- New slot timing event NS_Event : Timing_Event; -- New slot handler procedure procedure NS_Handler (Event : in out Timing_Event); -- This access object is the reason why the scheduler is declared -- in this private part, given that this is a generioc package. -- It should be a constant, but a PO can't have constant components. NS_Handler_Access : Timing_Event_Handler := NS_Handler'Access; -- Procedure to enforce plan change procedure Change_Plan (At_Time : Time); -- Currently running plan and next plan to switch to, if any Current_Plan : Time_Triggered_Plan_Access := null; Next_Plan : Time_Triggered_Plan_Access := null; -- Index numbers of current and next slots in the plan Current_Slot_Index : Natural := 0; Next_Slot_Index : Natural := 0; -- Start time of next slot Next_Slot_Release : Time := Time_Last; end Time_Triggered_Scheduler; end Time_Triggered_Scheduling;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <denkpadje@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. private with Wayland.Cursor_API; with Wayland.Protocols.Client; package Wayland.Cursor is pragma Preelaborate; subtype Image_Index is Positive; ----------------------------------------------------------------------------- type Cursor_Image is tagged limited private; type Image_State is record Width, Height, Hotspot_X, Hotspot_Y : Natural; Interval : Duration; end record; function State (Object : Cursor_Image) return Image_State; function Get_Buffer (Object : in out Cursor_Image) return Wayland.Protocols.Client.Buffer'Class with Post => Get_Buffer'Result.Has_Proxy; -- Return the buffer of the image -- -- The buffer can be attached to a separate surface. After the surface -- has been committed, it can be set via the procedure Set_Cursor of a -- Pointer object. -- -- The buffer must not be destroyed. ----------------------------------------------------------------------------- type Cursor is tagged limited private; function Index_At_Elapsed_Time (Object : Cursor; Time : Duration) return Image_Index; function Index_At_Elapsed_Time (Object : Cursor; Time : Duration; Next : out Duration) return Image_Index; function Length (Object : Cursor) return Positive; function Image (Object : Cursor; Index : Image_Index) return Cursor_Image'Class; ----------------------------------------------------------------------------- type Cursor_Theme is tagged limited private; function Is_Initialized (Object : Cursor_Theme) return Boolean; procedure Load_Theme (Object : in out Cursor_Theme; Name : String; Size : Positive; Shm : Wayland.Protocols.Client.Shm) with Pre => not Object.Is_Initialized and Shm.Has_Proxy, Post => Object.Is_Initialized; procedure Destroy (Object : in out Cursor_Theme) with Pre => Object.Is_Initialized, Post => not Object.Is_Initialized; function Get_Cursor (Object : in out Cursor_Theme; Name : String) return Cursor'Class with Pre => Object.Is_Initialized; private type Cursor_Image is tagged limited record Handle : not null Cursor_API.Cursor_Image_Ptr; end record; type Cursor is tagged limited record Handle : not null Cursor_API.Cursor_Ptr; end record; type Cursor_Theme is tagged limited record Handle : Cursor_API.Cursor_Theme_Ptr; end record; end Wayland.Cursor;
-- { dg-do run } -- { dg-options "-O -fstack-check" } procedure Opt49 is function Ident (I : Integer) return Integer; pragma No_Inline (Ident); function Ident (I : Integer) return Integer is begin return I; end; Int_0 : Integer := Ident (0); Int_4 : Integer := Ident (4); A : array (-4 .. Int_4) of Integer; begin A := (-4 , -3 , -2 , -1 , 100 , 1 , 2 , 3 , 4); A (-4 .. Int_0) := A (Int_0 .. 4); if A /= (100 , 1 , 2 , 3 , 4 , 1 , 2 , 3 , 4) then raise Program_Error; end if; A := (-4 , -3 , -2 , -1 , 100 , 1 , 2 , 3 , 4); A (Int_0 .. 4) := A (-4 .. Int_0); if A /= (-4 , -3 , -2 , -1 , -4 , -3 , -2 , -1 , 100) then raise Program_Error; end if; end;
----------------------------------------------------------------------- -- wi2wic -- Wiki 2 Wiki Converter server startup -- Copyright (C) 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 Ada.IO_Exceptions; with AWS.Config.Set; with Servlet.Server.Web; with Util.Strings; with Util.Log.Loggers; with Util.Properties; with Util.Properties.Basic; with Wi2wic.Rest; with Wi2wic.Applications; procedure Wi2wic.Server is procedure Configure (Config : in out AWS.Config.Object); use Util.Properties.Basic; CONFIG_PATH : constant String := "wi2wic.properties"; Port : Natural := 8080; procedure Configure (Config : in out AWS.Config.Object) is begin AWS.Config.Set.Server_Port (Config, Port); AWS.Config.Set.Max_Connection (Config, 8); AWS.Config.Set.Accept_Queue_Size (Config, 512); end Configure; App : aliased Wi2wic.Applications.Application_Type; WS : Servlet.Server.Web.AWS_Container; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Wi2wic.Server"); Props : Util.Properties.Manager; begin Props.Load_Properties (CONFIG_PATH); Util.Log.Loggers.Initialize (Props); Port := Integer_Property.Get (Props, "wi2wic.port", Port); App.Configure (Props); Wi2wic.Rest.Register (App); WS.Configure (Configure'Access); WS.Register_Application ("/wi2wic", App'Unchecked_Access); App.Dump_Routes (Util.Log.INFO_LEVEL); Log.Info ("Connect you browser to: http://localhost:{0}/wi2wic/index.html", Util.Strings.Image (Port)); WS.Start; loop delay 6000.0; end loop; exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Cannot read application configuration file {0}", CONFIG_PATH); end Wi2wic.Server;
pragma Assertion_Policy (Check); with Atomic; with Atomic.Unsigned; with Atomic.Signed; with Ada.Text_IO; with Interfaces; procedure Main is generic type T is mod <>; procedure Test_Unsigned; generic type T is range <>; procedure Test_Signed; ------------------- -- Test_Unsigned -- ------------------- procedure Test_Unsigned is package UAtomic is new Atomic.Unsigned (T); use UAtomic; V : aliased Instance := Init (T'Last); Old : T := T'Last; Result : T; Success : Boolean; begin pragma Assert (Load (V) = T'Last); Store (V, T'First); pragma Assert (Load (V) = T'First); Exchange (V, T'Last, Old); pragma Assert (Load (V) = T'Last); pragma Assert (Old = T'First); Compare_Exchange (V, Expected => T'First, Desired => T'Last / 2, Weak => True, Success => Success); pragma Assert (not Success); Compare_Exchange (V, Expected => T'Last, Desired => T'Last / 2, Weak => True, Success => Success); pragma Assert (Success); pragma Assert (Load (V) = T'Last / 2); -- <OP> Store (V, T'First); Add (V, 1); pragma Assert (Load (V) = T'First + 1); Store (V, T'Last); Sub (V, 1); pragma Assert (Load (V) = T'Last - 1); Store (V, T'First); Op_And (V, 2#1010#); pragma Assert (Load (V) = (T'First and 2#1010#)); Store (V, T'First); Op_XOR (V, 2#1010#); pragma Assert (Load (V) = (T'First xor 2#1010#)); Store (V, T'First); Op_OR (V, 2#1010#); pragma Assert (Load (V) = (T'First or 2#1010#)); Store (V, T'First); NAND (V, 2#1010#); pragma Assert (Load (V) = (not (T'First and 2#1010#))); -- <OP>_Fetch Store (V, T'First); Add_Fetch (V, 1, Result); pragma Assert (Load (V) = T'First + 1); pragma Assert (Result = T'First + 1); Store (V, T'Last); Sub_Fetch (V, 1, Result); pragma Assert (Load (V) = T'Last - 1); pragma Assert (Result = T'Last - 1); Store (V, T'First); And_Fetch (V, 2#1010#, Result); pragma Assert (Load (V) = (T'First and 2#1010#)); pragma Assert (Result = (T'First and 2#1010#)); Store (V, T'First); XOR_Fetch (V, 2#1010#, Result); pragma Assert (Load (V) = (T'First xor 2#1010#)); pragma Assert (Result = (T'First xor 2#1010#)); Store (V, T'First); OR_Fetch (V, 2#1010#, Result); pragma Assert (Load (V) = (T'First or 2#1010#)); pragma Assert (Result = (T'First or 2#1010#)); Store (V, T'First); NAND_Fetch (V, 2#1010#, Result); pragma Assert (Load (V) = (not (T'First and 2#1010#))); pragma Assert (Result = (not (T'First and 2#1010#))); -- Fetch_<OP> Store (V, T'First); Fetch_Add (V, 1, Result); pragma Assert (Load (V) = T'First + 1); pragma Assert (Result = T'First); Store (V, T'Last); Fetch_Sub (V, 1, Result); pragma Assert (Load (V) = T'Last - 1); pragma Assert (Result = T'Last); Store (V, T'First); Fetch_And (V, 2#1010#, Result); pragma Assert (Load (V) = (T'First and 2#1010#)); pragma Assert (Result = T'First); Store (V, T'First); Fetch_XOR (V, 2#1010#, Result); pragma Assert (Load (V) = (T'First xor 2#1010#)); pragma Assert (Result = T'First); Store (V, T'First); Fetch_OR (V, 2#1010#, Result); pragma Assert (Load (V) = (T'First or 2#1010#)); pragma Assert (Result = T'First); Store (V, T'First); Fetch_NAND (V, 2#1010#, Result); pragma Assert (Load (V) = (not (T'First and 2#1010#))); pragma Assert (Result = T'First); -- Exchange Store (V, T'First); pragma Assert (Exchange (V, T'First + 1) = T'First); pragma Assert (Load (V) = T'First + 1); Store (V, T'First); pragma Assert (not Compare_Exchange (V, T'First + 1, T'First + 1, Weak => True)); pragma Assert (Compare_Exchange (V, T'First, T'First + 1, Weak => True)); pragma Assert (Load (V) = T'First + 1); -- func <OP>_Fetch Store (V, T'First); pragma Assert (Add_Fetch (V, 1) = T'First + 1); pragma Assert (Load (V) = T'First + 1); Store (V, T'Last); pragma Assert (Sub_Fetch (V, 1) = T'Last - 1); pragma Assert (Load (V) = T'Last - 1); Store (V, T'First); pragma Assert (And_Fetch (V, 2#1010#) = (T'First and 2#1010#)); pragma Assert (Load (V) = (T'First and 2#1010#)); Store (V, T'First); pragma Assert (XOR_Fetch (V, 2#1010#) = (T'First xor 2#1010#)); pragma Assert (Load (V) = (T'First xor 2#1010#)); Store (V, T'First); pragma Assert (OR_Fetch (V, 2#1010#) = (T'First or 2#1010#)); pragma Assert (Load (V) = (T'First or 2#1010#)); Store (V, T'First); pragma Assert (NAND_Fetch (V, 2#1010#) = (not (T'First and 2#1010#))); pragma Assert (Load (V) = (not (T'First and 2#1010#))); -- func Fetch_<OP> Store (V, T'First); pragma Assert (Fetch_Add (V, 1) = T'First); pragma Assert (Load (V) = T'First + 1); Store (V, T'Last); pragma Assert (Fetch_Sub (V, 1) = T'Last); pragma Assert (Load (V) = T'Last - 1); Store (V, T'First); pragma Assert (Fetch_And (V, 2#1010#) = T'First); pragma Assert (Load (V) = (T'First and 2#1010#)); Store (V, T'First); pragma Assert (Fetch_XOR (V, 2#1010#) = T'First); pragma Assert (Load (V) = (T'First xor 2#1010#)); Store (V, T'First); pragma Assert (Fetch_OR (V, 2#1010#) = T'First); pragma Assert (Load (V) = (T'First or 2#1010#)); Store (V, T'First); pragma Assert (Fetch_NAND (V, 2#1010#) = T'First); pragma Assert (Load (V) = (not (T'First and 2#1010#))); Ada.Text_IO.Put_Line ("SUCCESS Unsigned" & T'Object_Size'Img); end Test_Unsigned; ----------------- -- Test_Signed -- ----------------- procedure Test_Signed is package UAtomic is new Atomic.Signed (T); use UAtomic; V : aliased Instance := Init (T'Last); Old : T := T'Last; Result : T; Success : Boolean; begin pragma Assert (Load (V) = T'Last); Store (V, T'First); pragma Assert (Load (V) = T'First); Exchange (V, T'Last, Old); pragma Assert (Load (V) = T'Last); pragma Assert (Old = T'First); Compare_Exchange (V, Expected => T'First, Desired => T'Last / 2, Weak => True, Success => Success); pragma Assert (not Success); Compare_Exchange (V, Expected => T'Last, Desired => T'Last / 2, Weak => True, Success => Success); pragma Assert (Success); pragma Assert (Load (V) = T'Last / 2); -- <OP> Store (V, T'First); Add (V, 1); pragma Assert (Load (V) = T'First + 1); Store (V, T'Last); Sub (V, 1); pragma Assert (Load (V) = T'Last - 1); -- <OP>_Fetch Store (V, T'First); Add_Fetch (V, 1, Result); pragma Assert (Load (V) = T'First + 1); pragma Assert (Result = T'First + 1); Store (V, T'Last); Sub_Fetch (V, 1, Result); pragma Assert (Load (V) = T'Last - 1); pragma Assert (Result = T'Last - 1); -- Fetch_<OP> Store (V, T'First); Fetch_Add (V, 1, Result); pragma Assert (Load (V) = T'First + 1); pragma Assert (Result = T'First); Store (V, T'Last); Fetch_Sub (V, 1, Result); pragma Assert (Load (V) = T'Last - 1); pragma Assert (Result = T'Last); -- Exchange Store (V, T'First); pragma Assert (Exchange (V, T'First + 1) = T'First); pragma Assert (Load (V) = T'First + 1); Store (V, T'First); pragma Assert (not Compare_Exchange (V, T'First + 1, T'First + 1, Weak => True)); pragma Assert (Compare_Exchange (V, T'First, T'First + 1, Weak => True)); pragma Assert (Load (V) = T'First + 1); -- func <OP>_Fetch Store (V, T'First); pragma Assert (Add_Fetch (V, 1) = T'First + 1); pragma Assert (Load (V) = T'First + 1); Store (V, T'Last); pragma Assert (Sub_Fetch (V, 1) = T'Last - 1); pragma Assert (Load (V) = T'Last - 1); -- func Fetch_<OP> Store (V, T'First); pragma Assert (Fetch_Add (V, 1) = T'First); pragma Assert (Load (V) = T'First + 1); Store (V, T'Last); pragma Assert (Fetch_Sub (V, 1) = T'Last); pragma Assert (Load (V) = T'Last - 1); Ada.Text_IO.Put_Line ("SUCCESS Signed" & T'Object_Size'Img); end Test_Signed; procedure Test_U8 is new Test_Unsigned (Interfaces.Unsigned_8); procedure Test_U16 is new Test_Unsigned (Interfaces.Unsigned_16); procedure Test_U32 is new Test_Unsigned (Interfaces.Unsigned_32); procedure Test_U64 is new Test_Unsigned (Interfaces.Unsigned_64); procedure Test_S8 is new Test_Signed (Interfaces.Integer_8); procedure Test_S16 is new Test_Signed (Interfaces.Integer_16); procedure Test_S32 is new Test_Signed (Interfaces.Integer_32); procedure Test_S64 is new Test_Signed (Interfaces.Integer_64); begin Test_U8; Test_U16; Test_U32; Test_U64; Test_S8; Test_S16; Test_S32; Test_S64; end Main;
-- FILE: oedipus.adb -- LICENSE: MIT © 2021 Mae Morella package body Oedipus is function Create_Complex (A, B : in Float) return Complex is C : Complex; begin C.Real := A; C.Imaginary := B; return C; end Create_Complex; function Get_Real (C : in Complex) return Float is begin return C.Real; end Get_Real; function Get_Imaginary (C : in Complex) return Float is begin return C.Imaginary; end Get_Imaginary; end Oedipus;
with OpenAL.Types; package OpenAL.Global is -- -- Distance_Model -- type Distance_Model_t is (None, Inverse_Distance, Inverse_Distance_Clamped, Linear_Distance, Linear_Distance_Clamped, Exponent_Distance, Exponent_Distance_Clamped, Unknown_Distance_Model); subtype Valid_Distance_Model_t is Distance_Model_t range None .. Exponent_Distance_Clamped; -- proc_map : alDistanceModel procedure Set_Distance_Model (Model : in Valid_Distance_Model_t); -- proc_map : alGetInteger function Get_Distance_Model return Distance_Model_t; -- -- Doppler_Factor -- -- proc_map : alDopplerFactor procedure Set_Doppler_Factor (Factor : in Types.Natural_Float_t); -- proc_map : alGetFloat function Get_Doppler_Factor return Types.Natural_Float_t; -- -- Speed_Of_Sound -- -- proc_map : alSpeedOfSound procedure Set_Speed_Of_Sound (Factor : in Types.Positive_Float_t); -- proc_map : alGetFloat function Get_Speed_Of_Sound return Types.Positive_Float_t; -- -- String queries -- -- proc_map : alGetString function Version return String; -- proc_map : alGetString function Renderer return String; -- proc_map : alGetString function Vendor return String; -- proc_map : alGetString function Extensions return String; -- -- Is_Extension_Present -- -- proc_map : alIsExtensionPresent function Is_Extension_Present (Name : in String) return Boolean; end OpenAL.Global;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . B O U N D E D _ V E C T O R S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2019, 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/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Containers.Generic_Array_Sort; with System; use type System.Address; package body Ada.Containers.Bounded_Vectors is pragma Warnings (Off, "variable ""Busy*"" is not referenced"); pragma Warnings (Off, "variable ""Lock*"" is not referenced"); -- See comment in Ada.Containers.Helpers ----------------------- -- Local Subprograms -- ----------------------- function To_Array_Index (Index : Index_Type'Base) return Count_Type'Base; --------- -- "&" -- --------- function "&" (Left, Right : Vector) return Vector is LN : constant Count_Type := Length (Left); RN : constant Count_Type := Length (Right); N : Count_Type'Base; -- length of result J : Count_Type'Base; -- for computing intermediate index values Last : Index_Type'Base; -- Last index of result begin -- We decide that the capacity of the result is the sum of the lengths -- of the vector parameters. We could decide to make it larger, but we -- have no basis for knowing how much larger, so we just allocate the -- minimum amount of storage. -- Here we handle the easy cases first, when one of the vector -- parameters is empty. (We say "easy" because there's nothing to -- compute, that can potentially overflow.) if LN = 0 then if RN = 0 then return Empty_Vector; end if; return Vector'(Capacity => RN, Elements => Right.Elements (1 .. RN), Last => Right.Last, others => <>); end if; if RN = 0 then return Vector'(Capacity => LN, Elements => Left.Elements (1 .. LN), Last => Left.Last, others => <>); end if; -- Neither of the vector parameters is empty, so must compute the length -- of the result vector and its last index. (This is the harder case, -- because our computations must avoid overflow.) -- There are two constraints we need to satisfy. The first constraint is -- that a container cannot have more than Count_Type'Last elements, so -- we must check the sum of the combined lengths. Note that we cannot -- simply add the lengths, because of the possibility of overflow. if Checks and then LN > Count_Type'Last - RN then raise Constraint_Error with "new length is out of range"; end if; -- It is now safe to compute the length of the new vector, without fear -- of overflow. N := LN + RN; -- The second constraint is that the new Last index value cannot -- exceed Index_Type'Last. We use the wider of Index_Type'Base and -- Count_Type'Base as the type for intermediate values. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then -- We perform a two-part test. First we determine whether the -- computed Last value lies in the base range of the type, and then -- determine whether it lies in the range of the index (sub)type. -- Last must satisfy this relation: -- First + Length - 1 <= Last -- We regroup terms: -- First - 1 <= Last - Length -- Which can rewrite as: -- No_Index <= Last - Length if Checks and then Index_Type'Base'Last - Index_Type'Base (N) < No_Index then raise Constraint_Error with "new length is out of range"; end if; -- We now know that the computed value of Last is within the base -- range of the type, so it is safe to compute its value: Last := No_Index + Index_Type'Base (N); -- Finally we test whether the value is within the range of the -- generic actual index subtype: if Checks and then Last > Index_Type'Last then raise Constraint_Error with "new length is out of range"; end if; elsif Index_Type'First <= 0 then -- Here we can compute Last directly, in the normal way. We know that -- No_Index is less than 0, so there is no danger of overflow when -- adding the (positive) value of length. J := Count_Type'Base (No_Index) + N; -- Last if Checks and then J > Count_Type'Base (Index_Type'Last) then raise Constraint_Error with "new length is out of range"; end if; -- We know that the computed value (having type Count_Type) of Last -- is within the range of the generic actual index subtype, so it is -- safe to convert to Index_Type: Last := Index_Type'Base (J); else -- Here Index_Type'First (and Index_Type'Last) is positive, so we -- must test the length indirectly (by working backwards from the -- largest possible value of Last), in order to prevent overflow. J := Count_Type'Base (Index_Type'Last) - N; -- No_Index if Checks and then J < Count_Type'Base (No_Index) then raise Constraint_Error with "new length is out of range"; end if; -- We have determined that the result length would not create a Last -- index value outside of the range of Index_Type, so we can now -- safely compute its value. Last := Index_Type'Base (Count_Type'Base (No_Index) + N); end if; declare LE : Elements_Array renames Left.Elements (1 .. LN); RE : Elements_Array renames Right.Elements (1 .. RN); begin return Vector'(Capacity => N, Elements => LE & RE, Last => Last, others => <>); end; end "&"; function "&" (Left : Vector; Right : Element_Type) return Vector is LN : constant Count_Type := Length (Left); begin -- We decide that the capacity of the result is the sum of the lengths -- of the parameters. We could decide to make it larger, but we have no -- basis for knowing how much larger, so we just allocate the minimum -- amount of storage. -- We must compute the length of the result vector and its last index, -- but in such a way that overflow is avoided. We must satisfy two -- constraints: the new length cannot exceed Count_Type'Last, and the -- new Last index cannot exceed Index_Type'Last. if Checks and then LN = Count_Type'Last then raise Constraint_Error with "new length is out of range"; end if; if Checks and then Left.Last >= Index_Type'Last then raise Constraint_Error with "new length is out of range"; end if; return Vector'(Capacity => LN + 1, Elements => Left.Elements (1 .. LN) & Right, Last => Left.Last + 1, others => <>); end "&"; function "&" (Left : Element_Type; Right : Vector) return Vector is RN : constant Count_Type := Length (Right); begin -- We decide that the capacity of the result is the sum of the lengths -- of the parameters. We could decide to make it larger, but we have no -- basis for knowing how much larger, so we just allocate the minimum -- amount of storage. -- We compute the length of the result vector and its last index, but in -- such a way that overflow is avoided. We must satisfy two constraints: -- the new length cannot exceed Count_Type'Last, and the new Last index -- cannot exceed Index_Type'Last. if Checks and then RN = Count_Type'Last then raise Constraint_Error with "new length is out of range"; end if; if Checks and then Right.Last >= Index_Type'Last then raise Constraint_Error with "new length is out of range"; end if; return Vector'(Capacity => 1 + RN, Elements => Left & Right.Elements (1 .. RN), Last => Right.Last + 1, others => <>); end "&"; function "&" (Left, Right : Element_Type) return Vector is begin -- We decide that the capacity of the result is the sum of the lengths -- of the parameters. We could decide to make it larger, but we have no -- basis for knowing how much larger, so we just allocate the minimum -- amount of storage. -- We must compute the length of the result vector and its last index, -- but in such a way that overflow is avoided. We must satisfy two -- constraints: the new length cannot exceed Count_Type'Last (here, we -- know that that condition is satisfied), and the new Last index cannot -- exceed Index_Type'Last. if Checks and then Index_Type'First >= Index_Type'Last then raise Constraint_Error with "new length is out of range"; end if; return Vector'(Capacity => 2, Elements => (Left, Right), Last => Index_Type'First + 1, others => <>); end "&"; --------- -- "=" -- --------- overriding function "=" (Left, Right : Vector) return Boolean is begin if Left.Last /= Right.Last then return False; end if; if Left.Length = 0 then return True; end if; declare -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. Lock_Left : With_Lock (Left.TC'Unrestricted_Access); Lock_Right : With_Lock (Right.TC'Unrestricted_Access); begin for J in Count_Type range 1 .. Left.Length loop if Left.Elements (J) /= Right.Elements (J) then return False; end if; end loop; end; return True; end "="; ------------ -- Assign -- ------------ procedure Assign (Target : in out Vector; Source : Vector) is begin if Target'Address = Source'Address then return; end if; if Checks and then Target.Capacity < Source.Length then raise Capacity_Error -- ??? with "Target capacity is less than Source length"; end if; Target.Clear; Target.Elements (1 .. Source.Length) := Source.Elements (1 .. Source.Length); Target.Last := Source.Last; end Assign; ------------ -- Append -- ------------ procedure Append (Container : in out Vector; New_Item : Vector) is begin if New_Item.Is_Empty then return; end if; if Checks and then Container.Last >= Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Container.Insert (Container.Last + 1, New_Item); end Append; procedure Append (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1) is begin if Count = 0 then return; end if; if Checks and then Container.Last >= Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Container.Insert (Container.Last + 1, New_Item, Count); end Append; -------------- -- Capacity -- -------------- function Capacity (Container : Vector) return Count_Type is begin return Container.Elements'Length; end Capacity; ----------- -- Clear -- ----------- procedure Clear (Container : in out Vector) is begin TC_Check (Container.TC); Container.Last := No_Index; end Clear; ------------------------ -- Constant_Reference -- ------------------------ function Constant_Reference (Container : aliased Vector; Position : Cursor) return Constant_Reference_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; if Checks and then Position.Index > Position.Container.Last then raise Constraint_Error with "Position cursor is out of range"; end if; declare A : Elements_Array renames Container.Elements; J : constant Count_Type := To_Array_Index (Position.Index); TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Constant_Reference_Type := (Element => A (J)'Access, Control => (Controlled with TC)) do Lock (TC.all); end return; end; end Constant_Reference; function Constant_Reference (Container : aliased Vector; Index : Index_Type) return Constant_Reference_Type is begin if Checks and then Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; declare A : Elements_Array renames Container.Elements; J : constant Count_Type := To_Array_Index (Index); TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Constant_Reference_Type := (Element => A (J)'Access, Control => (Controlled with TC)) do Lock (TC.all); end return; end; end Constant_Reference; -------------- -- Contains -- -------------- function Contains (Container : Vector; Item : Element_Type) return Boolean is begin return Find_Index (Container, Item) /= No_Index; end Contains; ---------- -- Copy -- ---------- function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector is C : Count_Type; begin if Capacity = 0 then C := Source.Length; elsif Capacity >= Source.Length then C := Capacity; elsif Checks then raise Capacity_Error with "Requested capacity is less than Source length"; end if; return Target : Vector (C) do Target.Elements (1 .. Source.Length) := Source.Elements (1 .. Source.Length); Target.Last := Source.Last; end return; end Copy; ------------ -- Delete -- ------------ procedure Delete (Container : in out Vector; Index : Extended_Index; Count : Count_Type := 1) is Old_Last : constant Index_Type'Base := Container.Last; Old_Len : constant Count_Type := Container.Length; New_Last : Index_Type'Base; Count2 : Count_Type'Base; -- count of items from Index to Old_Last Off : Count_Type'Base; -- Index expressed as offset from IT'First begin -- Delete removes items from the vector, the number of which is the -- minimum of the specified Count and the items (if any) that exist from -- Index to Container.Last. There are no constraints on the specified -- value of Count (it can be larger than what's available at this -- position in the vector, for example), but there are constraints on -- the allowed values of the Index. -- As a precondition on the generic actual Index_Type, the base type -- must include Index_Type'Pred (Index_Type'First); this is the value -- that Container.Last assumes when the vector is empty. However, we do -- not allow that as the value for Index when specifying which items -- should be deleted, so we must manually check. (That the user is -- allowed to specify the value at all here is a consequence of the -- declaration of the Extended_Index subtype, which includes the values -- in the base range that immediately precede and immediately follow the -- values in the Index_Type.) if Checks and then Index < Index_Type'First then raise Constraint_Error with "Index is out of range (too small)"; end if; -- We do allow a value greater than Container.Last to be specified as -- the Index, but only if it's immediately greater. This allows the -- corner case of deleting no items from the back end of the vector to -- be treated as a no-op. (It is assumed that specifying an index value -- greater than Last + 1 indicates some deeper flaw in the caller's -- algorithm, so that case is treated as a proper error.) if Index > Old_Last then if Checks and then Index > Old_Last + 1 then raise Constraint_Error with "Index is out of range (too large)"; end if; return; end if; -- Here and elsewhere we treat deleting 0 items from the container as a -- no-op, even when the container is busy, so we simply return. if Count = 0 then return; end if; -- The tampering bits exist to prevent an item from being deleted (or -- otherwise harmfully manipulated) while it is being visited. Query, -- Update, and Iterate increment the busy count on entry, and decrement -- the count on exit. Delete checks the count to determine whether it is -- being called while the associated callback procedure is executing. TC_Check (Container.TC); -- We first calculate what's available for deletion starting at -- Index. Here and elsewhere we use the wider of Index_Type'Base and -- Count_Type'Base as the type for intermediate values. (See function -- Length for more information.) if Count_Type'Base'Last >= Index_Type'Pos (Index_Type'Base'Last) then Count2 := Count_Type'Base (Old_Last) - Count_Type'Base (Index) + 1; else Count2 := Count_Type'Base (Old_Last - Index + 1); end if; -- If more elements are requested (Count) for deletion than are -- available (Count2) for deletion beginning at Index, then everything -- from Index is deleted. There are no elements to slide down, and so -- all we need to do is set the value of Container.Last. if Count >= Count2 then Container.Last := Index - 1; return; end if; -- There are some elements aren't being deleted (the requested count was -- less than the available count), so we must slide them down to -- Index. We first calculate the index values of the respective array -- slices, using the wider of Index_Type'Base and Count_Type'Base as the -- type for intermediate calculations. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Off := Count_Type'Base (Index - Index_Type'First); New_Last := Old_Last - Index_Type'Base (Count); else Off := Count_Type'Base (Index) - Count_Type'Base (Index_Type'First); New_Last := Index_Type'Base (Count_Type'Base (Old_Last) - Count); end if; -- The array index values for each slice have already been determined, -- so we just slide down to Index the elements that weren't deleted. declare EA : Elements_Array renames Container.Elements; Idx : constant Count_Type := EA'First + Off; begin EA (Idx .. Old_Len - Count) := EA (Idx + Count .. Old_Len); Container.Last := New_Last; end; end Delete; procedure Delete (Container : in out Vector; Position : in out Cursor; Count : Count_Type := 1) is pragma Warnings (Off, Position); begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; if Checks and then Position.Index > Container.Last then raise Program_Error with "Position index is out of range"; end if; Delete (Container, Position.Index, Count); Position := No_Element; end Delete; ------------------ -- Delete_First -- ------------------ procedure Delete_First (Container : in out Vector; Count : Count_Type := 1) is begin if Count = 0 then return; elsif Count >= Length (Container) then Clear (Container); return; else Delete (Container, Index_Type'First, Count); end if; end Delete_First; ----------------- -- Delete_Last -- ----------------- procedure Delete_Last (Container : in out Vector; Count : Count_Type := 1) is begin -- It is not permitted to delete items while the container is busy (for -- example, we're in the middle of a passive iteration). However, we -- always treat deleting 0 items as a no-op, even when we're busy, so we -- simply return without checking. if Count = 0 then return; end if; -- The tampering bits exist to prevent an item from being deleted (or -- otherwise harmfully manipulated) while it is being visited. Query, -- Update, and Iterate increment the busy count on entry, and decrement -- the count on exit. Delete_Last checks the count to determine whether -- it is being called while the associated callback procedure is -- executing. TC_Check (Container.TC); -- There is no restriction on how large Count can be when deleting -- items. If it is equal or greater than the current length, then this -- is equivalent to clearing the vector. (In particular, there's no need -- for us to actually calculate the new value for Last.) -- If the requested count is less than the current length, then we must -- calculate the new value for Last. For the type we use the widest of -- Index_Type'Base and Count_Type'Base for the intermediate values of -- our calculation. (See the comments in Length for more information.) if Count >= Container.Length then Container.Last := No_Index; elsif Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Container.Last := Container.Last - Index_Type'Base (Count); else Container.Last := Index_Type'Base (Count_Type'Base (Container.Last) - Count); end if; end Delete_Last; ------------- -- Element -- ------------- function Element (Container : Vector; Index : Index_Type) return Element_Type is begin if Checks and then Index > Container.Last then raise Constraint_Error with "Index is out of range"; else return Container.Elements (To_Array_Index (Index)); end if; end Element; function Element (Position : Cursor) return Element_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; else return Position.Container.Element (Position.Index); end if; end Element; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Iterator) is begin Unbusy (Object.Container.TC); end Finalize; ---------- -- Find -- ---------- function Find (Container : Vector; Item : Element_Type; Position : Cursor := No_Element) return Cursor is begin if Position.Container /= null then if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; if Checks and then Position.Index > Container.Last then raise Program_Error with "Position index is out of range"; end if; end if; -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unrestricted_Access); begin for J in Position.Index .. Container.Last loop if Container.Elements (To_Array_Index (J)) = Item then return Cursor'(Container'Unrestricted_Access, J); end if; end loop; return No_Element; end; end Find; ---------------- -- Find_Index -- ---------------- function Find_Index (Container : Vector; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index is -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. Lock : With_Lock (Container.TC'Unrestricted_Access); begin for Indx in Index .. Container.Last loop if Container.Elements (To_Array_Index (Indx)) = Item then return Indx; end if; end loop; return No_Index; end Find_Index; ----------- -- First -- ----------- function First (Container : Vector) return Cursor is begin if Is_Empty (Container) then return No_Element; else return (Container'Unrestricted_Access, Index_Type'First); end if; end First; function First (Object : Iterator) return Cursor is begin -- The value of the iterator object's Index component influences the -- behavior of the First (and Last) selector function. -- When the Index component is No_Index, this means the iterator -- object was constructed without a start expression, in which case the -- (forward) iteration starts from the (logical) beginning of the entire -- sequence of items (corresponding to Container.First, for a forward -- iterator). -- Otherwise, this is iteration over a partial sequence of items. -- When the Index component isn't No_Index, the iterator object was -- constructed with a start expression, that specifies the position -- from which the (forward) partial iteration begins. if Object.Index = No_Index then return First (Object.Container.all); else return Cursor'(Object.Container, Object.Index); end if; end First; ------------------- -- First_Element -- ------------------- function First_Element (Container : Vector) return Element_Type is begin if Checks and then Container.Last = No_Index then raise Constraint_Error with "Container is empty"; end if; return Container.Elements (To_Array_Index (Index_Type'First)); end First_Element; ----------------- -- First_Index -- ----------------- function First_Index (Container : Vector) return Index_Type is pragma Unreferenced (Container); begin return Index_Type'First; end First_Index; --------------------- -- Generic_Sorting -- --------------------- package body Generic_Sorting is --------------- -- Is_Sorted -- --------------- function Is_Sorted (Container : Vector) return Boolean is begin if Container.Last <= Index_Type'First then return True; end if; -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unrestricted_Access); EA : Elements_Array renames Container.Elements; begin for J in 1 .. Container.Length - 1 loop if EA (J + 1) < EA (J) then return False; end if; end loop; return True; end; end Is_Sorted; ----------- -- Merge -- ----------- procedure Merge (Target, Source : in out Vector) is I, J : Count_Type; begin -- The semantics of Merge changed slightly per AI05-0021. It was -- originally the case that if Target and Source denoted the same -- container object, then the GNAT implementation of Merge did -- nothing. However, it was argued that RM05 did not precisely -- specify the semantics for this corner case. The decision of the -- ARG was that if Target and Source denote the same non-empty -- container object, then Program_Error is raised. if Source.Is_Empty then return; end if; if Checks and then Target'Address = Source'Address then raise Program_Error with "Target and Source denote same non-empty container"; end if; if Target.Is_Empty then Move (Target => Target, Source => Source); return; end if; TC_Check (Source.TC); I := Target.Length; Target.Set_Length (I + Source.Length); -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare TA : Elements_Array renames Target.Elements; SA : Elements_Array renames Source.Elements; Lock_Target : With_Lock (Target.TC'Unchecked_Access); Lock_Source : With_Lock (Source.TC'Unchecked_Access); begin J := Target.Length; while not Source.Is_Empty loop pragma Assert (Source.Length <= 1 or else not (SA (Source.Length) < SA (Source.Length - 1))); if I = 0 then TA (1 .. J) := SA (1 .. Source.Length); Source.Last := No_Index; exit; end if; pragma Assert (I <= 1 or else not (TA (I) < TA (I - 1))); if SA (Source.Length) < TA (I) then TA (J) := TA (I); I := I - 1; else TA (J) := SA (Source.Length); Source.Last := Source.Last - 1; end if; J := J - 1; end loop; end; end Merge; ---------- -- Sort -- ---------- procedure Sort (Container : in out Vector) is procedure Sort is new Generic_Array_Sort (Index_Type => Count_Type, Element_Type => Element_Type, Array_Type => Elements_Array, "<" => "<"); begin if Container.Last <= Index_Type'First then return; end if; -- The exception behavior for the vector container must match that -- for the list container, so we check for cursor tampering here -- (which will catch more things) instead of for element tampering -- (which will catch fewer things). It's true that the elements of -- this vector container could be safely moved around while (say) an -- iteration is taking place (iteration only increments the busy -- counter), and so technically all we would need here is a test for -- element tampering (indicated by the lock counter), that's simply -- an artifact of our array-based implementation. Logically Sort -- requires a check for cursor tampering. TC_Check (Container.TC); -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unchecked_Access); begin Sort (Container.Elements (1 .. Container.Length)); end; end Sort; end Generic_Sorting; ------------------------ -- Get_Element_Access -- ------------------------ function Get_Element_Access (Position : Cursor) return not null Element_Access is begin return Position.Container.Elements (To_Array_Index (Position.Index))'Access; end Get_Element_Access; ----------------- -- Has_Element -- ----------------- function Has_Element (Position : Cursor) return Boolean is begin if Position.Container = null then return False; end if; return Position.Index <= Position.Container.Last; end Has_Element; ------------ -- Insert -- ------------ procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Element_Type; Count : Count_Type := 1) is EA : Elements_Array renames Container.Elements; Old_Length : constant Count_Type := Container.Length; Max_Length : Count_Type'Base; -- determined from range of Index_Type New_Length : Count_Type'Base; -- sum of current length and Count Index : Index_Type'Base; -- scratch for intermediate values J : Count_Type'Base; -- scratch begin -- As a precondition on the generic actual Index_Type, the base type -- must include Index_Type'Pred (Index_Type'First); this is the value -- that Container.Last assumes when the vector is empty. However, we do -- not allow that as the value for Index when specifying where the new -- items should be inserted, so we must manually check. (That the user -- is allowed to specify the value at all here is a consequence of the -- declaration of the Extended_Index subtype, which includes the values -- in the base range that immediately precede and immediately follow the -- values in the Index_Type.) if Checks and then Before < Index_Type'First then raise Constraint_Error with "Before index is out of range (too small)"; end if; -- We do allow a value greater than Container.Last to be specified as -- the Index, but only if it's immediately greater. This allows for the -- case of appending items to the back end of the vector. (It is assumed -- that specifying an index value greater than Last + 1 indicates some -- deeper flaw in the caller's algorithm, so that case is treated as a -- proper error.) if Checks and then Before > Container.Last and then Before > Container.Last + 1 then raise Constraint_Error with "Before index is out of range (too large)"; end if; -- We treat inserting 0 items into the container as a no-op, even when -- the container is busy, so we simply return. if Count = 0 then return; end if; -- There are two constraints we need to satisfy. The first constraint is -- that a container cannot have more than Count_Type'Last elements, so -- we must check the sum of the current length and the insertion -- count. Note that we cannot simply add these values, because of the -- possibility of overflow. if Checks and then Old_Length > Count_Type'Last - Count then raise Constraint_Error with "Count is out of range"; end if; -- It is now safe compute the length of the new vector, without fear of -- overflow. New_Length := Old_Length + Count; -- The second constraint is that the new Last index value cannot exceed -- Index_Type'Last. In each branch below, we calculate the maximum -- length (computed from the range of values in Index_Type), and then -- compare the new length to the maximum length. If the new length is -- acceptable, then we compute the new last index from that. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then -- We have to handle the case when there might be more values in the -- range of Index_Type than in the range of Count_Type. if Index_Type'First <= 0 then -- We know that No_Index (the same as Index_Type'First - 1) is -- less than 0, so it is safe to compute the following sum without -- fear of overflow. Index := No_Index + Index_Type'Base (Count_Type'Last); if Index <= Index_Type'Last then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the -- maximum number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than in Count_Type, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last - No_Index); end if; else -- No_Index is equal or greater than 0, so we can safely compute -- the difference without fear of overflow (which we would have to -- worry about if No_Index were less than 0, but that case is -- handled above). if Index_Type'Last - No_Index >= Count_Type'Pos (Count_Type'Last) then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the -- maximum number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than in Count_Type, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last - No_Index); end if; end if; elsif Index_Type'First <= 0 then -- We know that No_Index (the same as Index_Type'First - 1) is less -- than 0, so it is safe to compute the following sum without fear of -- overflow. J := Count_Type'Base (No_Index) + Count_Type'Last; if J <= Count_Type'Base (Index_Type'Last) then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the maximum -- number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than Count_Type does, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index); end if; else -- No_Index is equal or greater than 0, so we can safely compute the -- difference without fear of overflow (which we would have to worry -- about if No_Index were less than 0, but that case is handled -- above). Max_Length := Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index); end if; -- We have just computed the maximum length (number of items). We must -- now compare the requested length to the maximum length, as we do not -- allow a vector expand beyond the maximum (because that would create -- an internal array with a last index value greater than -- Index_Type'Last, with no way to index those elements). if Checks and then New_Length > Max_Length then raise Constraint_Error with "Count is out of range"; end if; -- The tampering bits exist to prevent an item from being harmfully -- manipulated while it is being visited. Query, Update, and Iterate -- increment the busy count on entry, and decrement the count on -- exit. Insert checks the count to determine whether it is being called -- while the associated callback procedure is executing. TC_Check (Container.TC); if Checks and then New_Length > Container.Capacity then raise Capacity_Error with "New length is larger than capacity"; end if; J := To_Array_Index (Before); if Before > Container.Last then -- The new items are being appended to the vector, so no -- sliding of existing elements is required. EA (J .. New_Length) := (others => New_Item); else -- The new items are being inserted before some existing -- elements, so we must slide the existing elements up to their -- new home. EA (J + Count .. New_Length) := EA (J .. Old_Length); EA (J .. J + Count - 1) := (others => New_Item); end if; if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Container.Last := No_Index + Index_Type'Base (New_Length); else Container.Last := Index_Type'Base (Count_Type'Base (No_Index) + New_Length); end if; end Insert; procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Vector) is N : constant Count_Type := Length (New_Item); B : Count_Type; -- index Before converted to Count_Type begin -- Use Insert_Space to create the "hole" (the destination slice) into -- which we copy the source items. Insert_Space (Container, Before, Count => N); if N = 0 then -- There's nothing else to do here (vetting of parameters was -- performed already in Insert_Space), so we simply return. return; end if; B := To_Array_Index (Before); if Container'Address /= New_Item'Address then -- This is the simple case. New_Item denotes an object different -- from Container, so there's nothing special we need to do to copy -- the source items to their destination, because all of the source -- items are contiguous. Container.Elements (B .. B + N - 1) := New_Item.Elements (1 .. N); return; end if; -- We refer to array index value Before + N - 1 as J. This is the last -- index value of the destination slice. -- New_Item denotes the same object as Container, so an insertion has -- potentially split the source items. The destination is always the -- range [Before, J], but the source is [Index_Type'First, Before) and -- (J, Container.Last]. We perform the copy in two steps, using each of -- the two slices of the source items. declare subtype Src_Index_Subtype is Count_Type'Base range 1 .. B - 1; Src : Elements_Array renames Container.Elements (Src_Index_Subtype); begin -- We first copy the source items that precede the space we -- inserted. (If Before equals Index_Type'First, then this first -- source slice will be empty, which is harmless.) Container.Elements (B .. B + Src'Length - 1) := Src; end; declare subtype Src_Index_Subtype is Count_Type'Base range B + N .. Container.Length; Src : Elements_Array renames Container.Elements (Src_Index_Subtype); begin -- We next copy the source items that follow the space we inserted. Container.Elements (B + N - Src'Length .. B + N - 1) := Src; end; end Insert; procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Vector) is Index : Index_Type'Base; begin if Checks and then Before.Container /= null and then Before.Container /= Container'Unchecked_Access then raise Program_Error with "Before cursor denotes wrong container"; end if; if Is_Empty (New_Item) then return; end if; if Before.Container = null or else Before.Index > Container.Last then if Checks and then Container.Last = Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Index := Container.Last + 1; else Index := Before.Index; end if; Insert (Container, Index, New_Item); end Insert; procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Vector; Position : out Cursor) is Index : Index_Type'Base; begin if Checks and then Before.Container /= null and then Before.Container /= Container'Unchecked_Access then raise Program_Error with "Before cursor denotes wrong container"; end if; if Is_Empty (New_Item) then if Before.Container = null or else Before.Index > Container.Last then Position := No_Element; else Position := (Container'Unchecked_Access, Before.Index); end if; return; end if; if Before.Container = null or else Before.Index > Container.Last then if Checks and then Container.Last = Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Index := Container.Last + 1; else Index := Before.Index; end if; Insert (Container, Index, New_Item); Position := Cursor'(Container'Unchecked_Access, Index); end Insert; procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Element_Type; Count : Count_Type := 1) is Index : Index_Type'Base; begin if Checks and then Before.Container /= null and then Before.Container /= Container'Unchecked_Access then raise Program_Error with "Before cursor denotes wrong container"; end if; if Count = 0 then return; end if; if Before.Container = null or else Before.Index > Container.Last then if Checks and then Container.Last = Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Index := Container.Last + 1; else Index := Before.Index; end if; Insert (Container, Index, New_Item, Count); end Insert; procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Element_Type; Position : out Cursor; Count : Count_Type := 1) is Index : Index_Type'Base; begin if Checks and then Before.Container /= null and then Before.Container /= Container'Unchecked_Access then raise Program_Error with "Before cursor denotes wrong container"; end if; if Count = 0 then if Before.Container = null or else Before.Index > Container.Last then Position := No_Element; else Position := (Container'Unchecked_Access, Before.Index); end if; return; end if; if Before.Container = null or else Before.Index > Container.Last then if Checks and then Container.Last = Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Index := Container.Last + 1; else Index := Before.Index; end if; Insert (Container, Index, New_Item, Count); Position := Cursor'(Container'Unchecked_Access, Index); end Insert; procedure Insert (Container : in out Vector; Before : Extended_Index; Count : Count_Type := 1) is New_Item : Element_Type; -- Default-initialized value pragma Warnings (Off, New_Item); begin Insert (Container, Before, New_Item, Count); end Insert; procedure Insert (Container : in out Vector; Before : Cursor; Position : out Cursor; Count : Count_Type := 1) is New_Item : Element_Type; -- Default-initialized value pragma Warnings (Off, New_Item); begin Insert (Container, Before, New_Item, Position, Count); end Insert; ------------------ -- Insert_Space -- ------------------ procedure Insert_Space (Container : in out Vector; Before : Extended_Index; Count : Count_Type := 1) is EA : Elements_Array renames Container.Elements; Old_Length : constant Count_Type := Container.Length; Max_Length : Count_Type'Base; -- determined from range of Index_Type New_Length : Count_Type'Base; -- sum of current length and Count Index : Index_Type'Base; -- scratch for intermediate values J : Count_Type'Base; -- scratch begin -- As a precondition on the generic actual Index_Type, the base type -- must include Index_Type'Pred (Index_Type'First); this is the value -- that Container.Last assumes when the vector is empty. However, we do -- not allow that as the value for Index when specifying where the new -- items should be inserted, so we must manually check. (That the user -- is allowed to specify the value at all here is a consequence of the -- declaration of the Extended_Index subtype, which includes the values -- in the base range that immediately precede and immediately follow the -- values in the Index_Type.) if Checks and then Before < Index_Type'First then raise Constraint_Error with "Before index is out of range (too small)"; end if; -- We do allow a value greater than Container.Last to be specified as -- the Index, but only if it's immediately greater. This allows for the -- case of appending items to the back end of the vector. (It is assumed -- that specifying an index value greater than Last + 1 indicates some -- deeper flaw in the caller's algorithm, so that case is treated as a -- proper error.) if Checks and then Before > Container.Last and then Before > Container.Last + 1 then raise Constraint_Error with "Before index is out of range (too large)"; end if; -- We treat inserting 0 items into the container as a no-op, even when -- the container is busy, so we simply return. if Count = 0 then return; end if; -- There are two constraints we need to satisfy. The first constraint is -- that a container cannot have more than Count_Type'Last elements, so -- we must check the sum of the current length and the insertion count. -- Note that we cannot simply add these values, because of the -- possibility of overflow. if Checks and then Old_Length > Count_Type'Last - Count then raise Constraint_Error with "Count is out of range"; end if; -- It is now safe compute the length of the new vector, without fear of -- overflow. New_Length := Old_Length + Count; -- The second constraint is that the new Last index value cannot exceed -- Index_Type'Last. In each branch below, we calculate the maximum -- length (computed from the range of values in Index_Type), and then -- compare the new length to the maximum length. If the new length is -- acceptable, then we compute the new last index from that. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then -- We have to handle the case when there might be more values in the -- range of Index_Type than in the range of Count_Type. if Index_Type'First <= 0 then -- We know that No_Index (the same as Index_Type'First - 1) is -- less than 0, so it is safe to compute the following sum without -- fear of overflow. Index := No_Index + Index_Type'Base (Count_Type'Last); if Index <= Index_Type'Last then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the -- maximum number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than in Count_Type, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last - No_Index); end if; else -- No_Index is equal or greater than 0, so we can safely compute -- the difference without fear of overflow (which we would have to -- worry about if No_Index were less than 0, but that case is -- handled above). if Index_Type'Last - No_Index >= Count_Type'Pos (Count_Type'Last) then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the -- maximum number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than in Count_Type, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last - No_Index); end if; end if; elsif Index_Type'First <= 0 then -- We know that No_Index (the same as Index_Type'First - 1) is less -- than 0, so it is safe to compute the following sum without fear of -- overflow. J := Count_Type'Base (No_Index) + Count_Type'Last; if J <= Count_Type'Base (Index_Type'Last) then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the maximum -- number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than Count_Type does, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index); end if; else -- No_Index is equal or greater than 0, so we can safely compute the -- difference without fear of overflow (which we would have to worry -- about if No_Index were less than 0, but that case is handled -- above). Max_Length := Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index); end if; -- We have just computed the maximum length (number of items). We must -- now compare the requested length to the maximum length, as we do not -- allow a vector expand beyond the maximum (because that would create -- an internal array with a last index value greater than -- Index_Type'Last, with no way to index those elements). if Checks and then New_Length > Max_Length then raise Constraint_Error with "Count is out of range"; end if; -- The tampering bits exist to prevent an item from being harmfully -- manipulated while it is being visited. Query, Update, and Iterate -- increment the busy count on entry, and decrement the count on -- exit. Insert checks the count to determine whether it is being called -- while the associated callback procedure is executing. TC_Check (Container.TC); -- An internal array has already been allocated, so we need to check -- whether there is enough unused storage for the new items. if Checks and then New_Length > Container.Capacity then raise Capacity_Error with "New length is larger than capacity"; end if; -- In this case, we're inserting space into a vector that has already -- allocated an internal array, and the existing array has enough -- unused storage for the new items. if Before <= Container.Last then -- The space is being inserted before some existing elements, -- so we must slide the existing elements up to their new home. J := To_Array_Index (Before); EA (J + Count .. New_Length) := EA (J .. Old_Length); end if; -- New_Last is the last index value of the items in the container after -- insertion. Use the wider of Index_Type'Base and Count_Type'Base to -- compute its value from the New_Length. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Container.Last := No_Index + Index_Type'Base (New_Length); else Container.Last := Index_Type'Base (Count_Type'Base (No_Index) + New_Length); end if; end Insert_Space; procedure Insert_Space (Container : in out Vector; Before : Cursor; Position : out Cursor; Count : Count_Type := 1) is Index : Index_Type'Base; begin if Checks and then Before.Container /= null and then Before.Container /= Container'Unchecked_Access then raise Program_Error with "Before cursor denotes wrong container"; end if; if Count = 0 then if Before.Container = null or else Before.Index > Container.Last then Position := No_Element; else Position := (Container'Unchecked_Access, Before.Index); end if; return; end if; if Before.Container = null or else Before.Index > Container.Last then if Checks and then Container.Last = Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Index := Container.Last + 1; else Index := Before.Index; end if; Insert_Space (Container, Index, Count => Count); Position := Cursor'(Container'Unchecked_Access, Index); end Insert_Space; -------------- -- Is_Empty -- -------------- function Is_Empty (Container : Vector) return Boolean is begin return Container.Last < Index_Type'First; end Is_Empty; ------------- -- Iterate -- ------------- procedure Iterate (Container : Vector; Process : not null access procedure (Position : Cursor)) is Busy : With_Busy (Container.TC'Unrestricted_Access); begin for Indx in Index_Type'First .. Container.Last loop Process (Cursor'(Container'Unrestricted_Access, Indx)); end loop; end Iterate; function Iterate (Container : Vector) return Vector_Iterator_Interfaces.Reversible_Iterator'Class is V : constant Vector_Access := Container'Unrestricted_Access; begin -- The value of its Index component influences the behavior of the First -- and Last selector functions of the iterator object. When the Index -- component is No_Index (as is the case here), this means the iterator -- object was constructed without a start expression. This is a complete -- iterator, meaning that the iteration starts from the (logical) -- beginning of the sequence of items. -- Note: For a forward iterator, Container.First is the beginning, and -- for a reverse iterator, Container.Last is the beginning. return It : constant Iterator := (Limited_Controlled with Container => V, Index => No_Index) do Busy (Container.TC'Unrestricted_Access.all); end return; end Iterate; function Iterate (Container : Vector; Start : Cursor) return Vector_Iterator_Interfaces.Reversible_Iterator'Class is V : constant Vector_Access := Container'Unrestricted_Access; begin -- It was formerly the case that when Start = No_Element, the partial -- iterator was defined to behave the same as for a complete iterator, -- and iterate over the entire sequence of items. However, those -- semantics were unintuitive and arguably error-prone (it is too easy -- to accidentally create an endless loop), and so they were changed, -- per the ARG meeting in Denver on 2011/11. However, there was no -- consensus about what positive meaning this corner case should have, -- and so it was decided to simply raise an exception. This does imply, -- however, that it is not possible to use a partial iterator to specify -- an empty sequence of items. if Checks and then Start.Container = null then raise Constraint_Error with "Start position for iterator equals No_Element"; end if; if Checks and then Start.Container /= V then raise Program_Error with "Start cursor of Iterate designates wrong vector"; end if; if Checks and then Start.Index > V.Last then raise Constraint_Error with "Start position for iterator equals No_Element"; end if; -- The value of its Index component influences the behavior of the First -- and Last selector functions of the iterator object. When the Index -- component is not No_Index (as is the case here), it means that this -- is a partial iteration, over a subset of the complete sequence of -- items. The iterator object was constructed with a start expression, -- indicating the position from which the iteration begins. Note that -- the start position has the same value irrespective of whether this is -- a forward or reverse iteration. return It : constant Iterator := (Limited_Controlled with Container => V, Index => Start.Index) do Busy (Container.TC'Unrestricted_Access.all); end return; end Iterate; ---------- -- Last -- ---------- function Last (Container : Vector) return Cursor is begin if Is_Empty (Container) then return No_Element; else return (Container'Unrestricted_Access, Container.Last); end if; end Last; function Last (Object : Iterator) return Cursor is begin -- The value of the iterator object's Index component influences the -- behavior of the Last (and First) selector function. -- When the Index component is No_Index, this means the iterator object -- was constructed without a start expression, in which case the -- (reverse) iteration starts from the (logical) beginning of the entire -- sequence (corresponding to Container.Last, for a reverse iterator). -- Otherwise, this is iteration over a partial sequence of items. When -- the Index component is not No_Index, the iterator object was -- constructed with a start expression, that specifies the position from -- which the (reverse) partial iteration begins. if Object.Index = No_Index then return Last (Object.Container.all); else return Cursor'(Object.Container, Object.Index); end if; end Last; ------------------ -- Last_Element -- ------------------ function Last_Element (Container : Vector) return Element_Type is begin if Checks and then Container.Last = No_Index then raise Constraint_Error with "Container is empty"; end if; return Container.Elements (Container.Length); end Last_Element; ---------------- -- Last_Index -- ---------------- function Last_Index (Container : Vector) return Extended_Index is begin return Container.Last; end Last_Index; ------------ -- Length -- ------------ function Length (Container : Vector) return Count_Type is L : constant Index_Type'Base := Container.Last; F : constant Index_Type := Index_Type'First; begin -- The base range of the index type (Index_Type'Base) might not include -- all values for length (Count_Type). Contrariwise, the index type -- might include values outside the range of length. Hence we use -- whatever type is wider for intermediate values when calculating -- length. Note that no matter what the index type is, the maximum -- length to which a vector is allowed to grow is always the minimum -- of Count_Type'Last and (IT'Last - IT'First + 1). -- For example, an Index_Type with range -127 .. 127 is only guaranteed -- to have a base range of -128 .. 127, but the corresponding vector -- would have lengths in the range 0 .. 255. In this case we would need -- to use Count_Type'Base for intermediate values. -- Another case would be the index range -2**63 + 1 .. -2**63 + 10. The -- vector would have a maximum length of 10, but the index values lie -- outside the range of Count_Type (which is only 32 bits). In this -- case we would need to use Index_Type'Base for intermediate values. if Count_Type'Base'Last >= Index_Type'Pos (Index_Type'Base'Last) then return Count_Type'Base (L) - Count_Type'Base (F) + 1; else return Count_Type (L - F + 1); end if; end Length; ---------- -- Move -- ---------- procedure Move (Target : in out Vector; Source : in out Vector) is begin if Target'Address = Source'Address then return; end if; if Checks and then Target.Capacity < Source.Length then raise Capacity_Error -- ??? with "Target capacity is less than Source length"; end if; TC_Check (Target.TC); TC_Check (Source.TC); -- Clear Target now, in case element assignment fails Target.Last := No_Index; Target.Elements (1 .. Source.Length) := Source.Elements (1 .. Source.Length); Target.Last := Source.Last; Source.Last := No_Index; end Move; ---------- -- Next -- ---------- function Next (Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; elsif Position.Index < Position.Container.Last then return (Position.Container, Position.Index + 1); else return No_Element; end if; end Next; function Next (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; end if; if Checks and then Position.Container /= Object.Container then raise Program_Error with "Position cursor of Next designates wrong vector"; end if; return Next (Position); end Next; procedure Next (Position : in out Cursor) is begin if Position.Container = null then return; elsif Position.Index < Position.Container.Last then Position.Index := Position.Index + 1; else Position := No_Element; end if; end Next; ------------- -- Prepend -- ------------- procedure Prepend (Container : in out Vector; New_Item : Vector) is begin Insert (Container, Index_Type'First, New_Item); end Prepend; procedure Prepend (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1) is begin Insert (Container, Index_Type'First, New_Item, Count); end Prepend; -------------- -- Previous -- -------------- procedure Previous (Position : in out Cursor) is begin if Position.Container = null then return; elsif Position.Index > Index_Type'First then Position.Index := Position.Index - 1; else Position := No_Element; end if; end Previous; function Previous (Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; elsif Position.Index > Index_Type'First then return (Position.Container, Position.Index - 1); else return No_Element; end if; end Previous; function Previous (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; end if; if Checks and then Position.Container /= Object.Container then raise Program_Error with "Position cursor of Previous designates wrong vector"; end if; return Previous (Position); end Previous; ---------------------- -- Pseudo_Reference -- ---------------------- function Pseudo_Reference (Container : aliased Vector'Class) return Reference_Control_Type is TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Reference_Control_Type := (Controlled with TC) do Lock (TC.all); end return; end Pseudo_Reference; ------------------- -- Query_Element -- ------------------- procedure Query_Element (Container : Vector; Index : Index_Type; Process : not null access procedure (Element : Element_Type)) is Lock : With_Lock (Container.TC'Unrestricted_Access); V : Vector renames Container'Unrestricted_Access.all; begin if Checks and then Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; Process (V.Elements (To_Array_Index (Index))); end Query_Element; procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)) is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; Query_Element (Position.Container.all, Position.Index, Process); end Query_Element; ---------- -- Read -- ---------- procedure Read (Stream : not null access Root_Stream_Type'Class; Container : out Vector) is Length : Count_Type'Base; Last : Index_Type'Base := No_Index; begin Clear (Container); Count_Type'Base'Read (Stream, Length); Reserve_Capacity (Container, Capacity => Length); for Idx in Count_Type range 1 .. Length loop Last := Last + 1; Element_Type'Read (Stream, Container.Elements (Idx)); Container.Last := Last; end loop; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Position : out Cursor) is begin raise Program_Error with "attempt to stream vector cursor"; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Read; --------------- -- Reference -- --------------- function Reference (Container : aliased in out Vector; Position : Cursor) return Reference_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; if Checks and then Position.Index > Position.Container.Last then raise Constraint_Error with "Position cursor is out of range"; end if; declare A : Elements_Array renames Container.Elements; J : constant Count_Type := To_Array_Index (Position.Index); TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Reference_Type := (Element => A (J)'Access, Control => (Controlled with TC)) do Lock (TC.all); end return; end; end Reference; function Reference (Container : aliased in out Vector; Index : Index_Type) return Reference_Type is begin if Checks and then Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; declare A : Elements_Array renames Container.Elements; J : constant Count_Type := To_Array_Index (Index); TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Reference_Type := (Element => A (J)'Access, Control => (Controlled with TC)) do Lock (TC.all); end return; end; end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Container : in out Vector; Index : Index_Type; New_Item : Element_Type) is begin if Checks and then Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; TE_Check (Container.TC); Container.Elements (To_Array_Index (Index)) := New_Item; end Replace_Element; procedure Replace_Element (Container : in out Vector; Position : Cursor; New_Item : Element_Type) is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; if Checks and then Position.Index > Container.Last then raise Constraint_Error with "Position cursor is out of range"; end if; TE_Check (Container.TC); Container.Elements (To_Array_Index (Position.Index)) := New_Item; end Replace_Element; ---------------------- -- Reserve_Capacity -- ---------------------- procedure Reserve_Capacity (Container : in out Vector; Capacity : Count_Type) is begin if Checks and then Capacity > Container.Capacity then raise Capacity_Error with "Capacity is out of range"; end if; end Reserve_Capacity; ---------------------- -- Reverse_Elements -- ---------------------- procedure Reverse_Elements (Container : in out Vector) is E : Elements_Array renames Container.Elements; Idx : Count_Type; Jdx : Count_Type; begin if Container.Length <= 1 then return; end if; -- The exception behavior for the vector container must match that for -- the list container, so we check for cursor tampering here (which will -- catch more things) instead of for element tampering (which will catch -- fewer things). It's true that the elements of this vector container -- could be safely moved around while (say) an iteration is taking place -- (iteration only increments the busy counter), and so technically -- all we would need here is a test for element tampering (indicated -- by the lock counter), that's simply an artifact of our array-based -- implementation. Logically Reverse_Elements requires a check for -- cursor tampering. TC_Check (Container.TC); Idx := 1; Jdx := Container.Length; while Idx < Jdx loop declare EI : constant Element_Type := E (Idx); begin E (Idx) := E (Jdx); E (Jdx) := EI; end; Idx := Idx + 1; Jdx := Jdx - 1; end loop; end Reverse_Elements; ------------------ -- Reverse_Find -- ------------------ function Reverse_Find (Container : Vector; Item : Element_Type; Position : Cursor := No_Element) return Cursor is Last : Index_Type'Base; begin if Checks and then Position.Container /= null and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; Last := (if Position.Container = null or else Position.Index > Container.Last then Container.Last else Position.Index); -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unrestricted_Access); begin for Indx in reverse Index_Type'First .. Last loop if Container.Elements (To_Array_Index (Indx)) = Item then return Cursor'(Container'Unrestricted_Access, Indx); end if; end loop; return No_Element; end; end Reverse_Find; ------------------------ -- Reverse_Find_Index -- ------------------------ function Reverse_Find_Index (Container : Vector; Item : Element_Type; Index : Index_Type := Index_Type'Last) return Extended_Index is -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. Lock : With_Lock (Container.TC'Unrestricted_Access); Last : constant Index_Type'Base := Index_Type'Min (Container.Last, Index); begin for Indx in reverse Index_Type'First .. Last loop if Container.Elements (To_Array_Index (Indx)) = Item then return Indx; end if; end loop; return No_Index; end Reverse_Find_Index; --------------------- -- Reverse_Iterate -- --------------------- procedure Reverse_Iterate (Container : Vector; Process : not null access procedure (Position : Cursor)) is Busy : With_Busy (Container.TC'Unrestricted_Access); begin for Indx in reverse Index_Type'First .. Container.Last loop Process (Cursor'(Container'Unrestricted_Access, Indx)); end loop; end Reverse_Iterate; ---------------- -- Set_Length -- ---------------- procedure Set_Length (Container : in out Vector; Length : Count_Type) is Count : constant Count_Type'Base := Container.Length - Length; begin -- Set_Length allows the user to set the length explicitly, instead of -- implicitly as a side-effect of deletion or insertion. If the -- requested length is less than the current length, this is equivalent -- to deleting items from the back end of the vector. If the requested -- length is greater than the current length, then this is equivalent to -- inserting "space" (nonce items) at the end. if Count >= 0 then Container.Delete_Last (Count); elsif Checks and then Container.Last >= Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; else Container.Insert_Space (Container.Last + 1, -Count); end if; end Set_Length; ---------- -- Swap -- ---------- procedure Swap (Container : in out Vector; I, J : Index_Type) is E : Elements_Array renames Container.Elements; begin if Checks and then I > Container.Last then raise Constraint_Error with "I index is out of range"; end if; if Checks and then J > Container.Last then raise Constraint_Error with "J index is out of range"; end if; if I = J then return; end if; TE_Check (Container.TC); declare EI_Copy : constant Element_Type := E (To_Array_Index (I)); begin E (To_Array_Index (I)) := E (To_Array_Index (J)); E (To_Array_Index (J)) := EI_Copy; end; end Swap; procedure Swap (Container : in out Vector; I, J : Cursor) is begin if Checks and then I.Container = null then raise Constraint_Error with "I cursor has no element"; end if; if Checks and then J.Container = null then raise Constraint_Error with "J cursor has no element"; end if; if Checks and then I.Container /= Container'Unrestricted_Access then raise Program_Error with "I cursor denotes wrong container"; end if; if Checks and then J.Container /= Container'Unrestricted_Access then raise Program_Error with "J cursor denotes wrong container"; end if; Swap (Container, I.Index, J.Index); end Swap; -------------------- -- To_Array_Index -- -------------------- function To_Array_Index (Index : Index_Type'Base) return Count_Type'Base is Offset : Count_Type'Base; begin -- We know that -- Index >= Index_Type'First -- hence we also know that -- Index - Index_Type'First >= 0 -- The issue is that even though 0 is guaranteed to be a value in -- the type Index_Type'Base, there's no guarantee that the difference -- is a value in that type. To prevent overflow we use the wider -- of Count_Type'Base and Index_Type'Base to perform intermediate -- calculations. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Offset := Count_Type'Base (Index - Index_Type'First); else Offset := Count_Type'Base (Index) - Count_Type'Base (Index_Type'First); end if; -- The array index subtype for all container element arrays -- always starts with 1. return 1 + Offset; end To_Array_Index; --------------- -- To_Cursor -- --------------- function To_Cursor (Container : Vector; Index : Extended_Index) return Cursor is begin if Index not in Index_Type'First .. Container.Last then return No_Element; end if; return Cursor'(Container'Unrestricted_Access, Index); end To_Cursor; -------------- -- To_Index -- -------------- function To_Index (Position : Cursor) return Extended_Index is begin if Position.Container = null then return No_Index; end if; if Position.Index <= Position.Container.Last then return Position.Index; end if; return No_Index; end To_Index; --------------- -- To_Vector -- --------------- function To_Vector (Length : Count_Type) return Vector is Index : Count_Type'Base; Last : Index_Type'Base; begin if Length = 0 then return Empty_Vector; end if; -- We create a vector object with a capacity that matches the specified -- Length, but we do not allow the vector capacity (the length of the -- internal array) to exceed the number of values in Index_Type'Range -- (otherwise, there would be no way to refer to those components via an -- index). We must therefore check whether the specified Length would -- create a Last index value greater than Index_Type'Last. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then -- We perform a two-part test. First we determine whether the -- computed Last value lies in the base range of the type, and then -- determine whether it lies in the range of the index (sub)type. -- Last must satisfy this relation: -- First + Length - 1 <= Last -- We regroup terms: -- First - 1 <= Last - Length -- Which can rewrite as: -- No_Index <= Last - Length if Checks and then Index_Type'Base'Last - Index_Type'Base (Length) < No_Index then raise Constraint_Error with "Length is out of range"; end if; -- We now know that the computed value of Last is within the base -- range of the type, so it is safe to compute its value: Last := No_Index + Index_Type'Base (Length); -- Finally we test whether the value is within the range of the -- generic actual index subtype: if Checks and then Last > Index_Type'Last then raise Constraint_Error with "Length is out of range"; end if; elsif Index_Type'First <= 0 then -- Here we can compute Last directly, in the normal way. We know that -- No_Index is less than 0, so there is no danger of overflow when -- adding the (positive) value of Length. Index := Count_Type'Base (No_Index) + Length; -- Last if Checks and then Index > Count_Type'Base (Index_Type'Last) then raise Constraint_Error with "Length is out of range"; end if; -- We know that the computed value (having type Count_Type) of Last -- is within the range of the generic actual index subtype, so it is -- safe to convert to Index_Type: Last := Index_Type'Base (Index); else -- Here Index_Type'First (and Index_Type'Last) is positive, so we -- must test the length indirectly (by working backwards from the -- largest possible value of Last), in order to prevent overflow. Index := Count_Type'Base (Index_Type'Last) - Length; -- No_Index if Checks and then Index < Count_Type'Base (No_Index) then raise Constraint_Error with "Length is out of range"; end if; -- We have determined that the value of Length would not create a -- Last index value outside of the range of Index_Type, so we can now -- safely compute its value. Last := Index_Type'Base (Count_Type'Base (No_Index) + Length); end if; return V : Vector (Capacity => Length) do V.Last := Last; end return; end To_Vector; function To_Vector (New_Item : Element_Type; Length : Count_Type) return Vector is Index : Count_Type'Base; Last : Index_Type'Base; begin if Length = 0 then return Empty_Vector; end if; -- We create a vector object with a capacity that matches the specified -- Length, but we do not allow the vector capacity (the length of the -- internal array) to exceed the number of values in Index_Type'Range -- (otherwise, there would be no way to refer to those components via an -- index). We must therefore check whether the specified Length would -- create a Last index value greater than Index_Type'Last. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then -- We perform a two-part test. First we determine whether the -- computed Last value lies in the base range of the type, and then -- determine whether it lies in the range of the index (sub)type. -- Last must satisfy this relation: -- First + Length - 1 <= Last -- We regroup terms: -- First - 1 <= Last - Length -- Which can rewrite as: -- No_Index <= Last - Length if Checks and then Index_Type'Base'Last - Index_Type'Base (Length) < No_Index then raise Constraint_Error with "Length is out of range"; end if; -- We now know that the computed value of Last is within the base -- range of the type, so it is safe to compute its value: Last := No_Index + Index_Type'Base (Length); -- Finally we test whether the value is within the range of the -- generic actual index subtype: if Checks and then Last > Index_Type'Last then raise Constraint_Error with "Length is out of range"; end if; elsif Index_Type'First <= 0 then -- Here we can compute Last directly, in the normal way. We know that -- No_Index is less than 0, so there is no danger of overflow when -- adding the (positive) value of Length. Index := Count_Type'Base (No_Index) + Length; -- same value as V.Last if Checks and then Index > Count_Type'Base (Index_Type'Last) then raise Constraint_Error with "Length is out of range"; end if; -- We know that the computed value (having type Count_Type) of Last -- is within the range of the generic actual index subtype, so it is -- safe to convert to Index_Type: Last := Index_Type'Base (Index); else -- Here Index_Type'First (and Index_Type'Last) is positive, so we -- must test the length indirectly (by working backwards from the -- largest possible value of Last), in order to prevent overflow. Index := Count_Type'Base (Index_Type'Last) - Length; -- No_Index if Checks and then Index < Count_Type'Base (No_Index) then raise Constraint_Error with "Length is out of range"; end if; -- We have determined that the value of Length would not create a -- Last index value outside of the range of Index_Type, so we can now -- safely compute its value. Last := Index_Type'Base (Count_Type'Base (No_Index) + Length); end if; return V : Vector (Capacity => Length) do V.Elements := (others => New_Item); V.Last := Last; end return; end To_Vector; -------------------- -- Update_Element -- -------------------- procedure Update_Element (Container : in out Vector; Index : Index_Type; Process : not null access procedure (Element : in out Element_Type)) is Lock : With_Lock (Container.TC'Unchecked_Access); begin if Checks and then Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; Process (Container.Elements (To_Array_Index (Index))); end Update_Element; procedure Update_Element (Container : in out Vector; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)) is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor denotes wrong container"; end if; Update_Element (Container, Position.Index, Process); end Update_Element; ----------- -- Write -- ----------- procedure Write (Stream : not null access Root_Stream_Type'Class; Container : Vector) is N : Count_Type; begin N := Container.Length; Count_Type'Base'Write (Stream, N); for J in 1 .. N loop Element_Type'Write (Stream, Container.Elements (J)); end loop; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Position : Cursor) is begin raise Program_Error with "attempt to stream vector cursor"; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Write; end Ada.Containers.Bounded_Vectors;
-- Shoot'n'loot -- Copyright (c) 2020 Fabien Chouteau package Sound is procedure Tick; procedure Play_Coin; procedure Play_Monster_Dead; procedure Play_Gun; procedure Play_Jump; procedure Play_Exit_Open; procedure Play_Exit_Taken; procedure Play_Gameover; procedure Play_Victory; procedure Play_Main_Theme; procedure Play_Gameplay; end Sound;
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Registrar.Dependency_Maps; separate (Scheduling) procedure Report_Unavailable_Subsystems (Unavailable_Subsystems: in Registrar.Subsystems.Subsystem_Sets.Set) is Verbose_Output: constant Boolean := Parameters.Output_Style = Verbose; use type Unit_Names.Unit_Name; package UBS renames Registrar.Subsystems.UBS; procedure Dump_Dependency_Trace (Target: Registrar.Subsystems.Subsystem) is begin -- First collect a map of all units -- Iterate over Target's reverse dependencies, and scan the -- dependencies of each unit of each dependent subsystem, -- dumping the specfic unit withs of units in the target subsystem Dependent_Subsystems_Iteration: for Dep_Subsys_Name of Registrar.Queries.Dependent_Subsystems (Target.Name) loop UI.Put_Empty_Tag; Put_Line (" Subsystem " & Dep_Subsys_Name.To_UTF8_String & " has dependent units:"); declare -- First collect a map with a key for each unit name that is a -- member of the dependent subsystem, and then inserting all -- reverse dependencies of each of those units that is a member -- of the Target subsystem use Registrar.Subsystems; use Registrar.Library_Units; Subsys_Units: constant Library_Unit_Sets.Set := Registrar.Queries.Subsystem_Library_Units (Subsystem'(Name => Dep_Subsys_Name, others => <>)); Target_Rev_Deps: Registrar.Dependency_Maps.Map; begin -- For each unit of this subsystem, check for any reverse -- dependencies that are members of Target. If we find that, -- we output that information for Unit of Subsys_Units loop declare Unit_Deps: constant Unit_Names.Sets.Set := Registrar.Queries.Unit_Dependencies (Unit.Name); Target_Deps: Unit_Names.Sets.Set; begin for Name of Unit_Deps loop if Name.Subsystem_Name = Target.Name then Target_Deps.Insert (Name); end if; end loop; if not Target_Deps.Is_Empty then UI.Put_Empty_Tag; Put_Line (" - " & Unit.Name.To_UTF8_String & " withs:"); for Target_Unit_Name of Target_Deps loop UI.Put_Empty_Tag; Put_Line (" -> " & Target_Unit_Name.To_UTF8_String); end loop; end if; end; end loop; end; New_Line; end loop Dependent_Subsystems_Iteration; end Dump_Dependency_Trace; begin -- Note that this is always called following a failed Checkout_Cycle, -- which has already alerted the user that subsystems could not be -- checked-out for Subsys of Unavailable_Subsystems loop UI.Put_Fail_Tag; Put_Line (' ' & Subsys.Name.To_UTF8_String & ": " & UBS.To_String (Subsys.Aquisition_Failure)); if Verbose_Output then Dump_Dependency_Trace (Subsys); end if; end loop; if not Verbose_Output then UI.Put_Info_Tag; Put_Line (" Use -v to see dependency details of missing subsystems."); end if; end Report_Unavailable_Subsystems;
with Aof.Core.Objects; with Widgets; with Labels; package My_Objects is Top : aliased Widgets.Widget; Form : aliased Widgets.Widget; Label : aliased Labels.Label; Row_Column_Layout : aliased Widgets.Widget; Ok : aliased Widgets.Widget; Cancel : aliased Widgets.Widget; Top_Ptr : Aof.Core.Objects.Access_Object := Top'Access; Form_Ptr : Aof.Core.Objects.Access_Object := Form'Access; Label_Ptr : Aof.Core.Objects.Access_Object := Label'Access; Row_Column_Layout_Ptr : Aof.Core.Objects.Access_Object := Row_Column_Layout'Access; Ok_Ptr : Aof.Core.Objects.Access_Object := Ok'Access; Cancel_Ptr : Aof.Core.Objects.Access_Object := Cancel'Access; end My_Objects;
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2004 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- -- $Id: buffer_demo.adb,v 1.1 2005/09/23 22:39:01 beng Exp $ -- This demo program provided by Dr Steve Sangwine <sjs@essex.ac.uk> -- -- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer -- of exactly the correct size is used for decompressed data, and the last -- few bytes passed in to Zlib are checksum bytes. -- This program compresses a string of text, and then decompresses the -- compressed text into a buffer of the same size as the original text. with Ada.Streams; use Ada.Streams; with Ada.Text_IO; with ZLib; use ZLib; procedure Buffer_Demo is EOL : Character renames ASCII.LF; Text : constant String := "Four score and seven years ago our fathers brought forth," & EOL & "upon this continent, a new nation, conceived in liberty," & EOL & "and dedicated to the proposition that `all men are created equal'."; Source : Stream_Element_Array (1 .. Text'Length); for Source'Address use Text'Address; begin Ada.Text_IO.Put (Text); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Uncompressed size : " & Positive'Image (Text'Length) & " bytes"); declare Compressed_Data : Stream_Element_Array (1 .. Text'Length); L : Stream_Element_Offset; begin Compress : declare Compressor : Filter_Type; I : Stream_Element_Offset; begin Deflate_Init (Compressor); -- Compress the whole of T at once. Translate (Compressor, Source, I, Compressed_Data, L, Finish); pragma Assert (I = Source'Last); Close (Compressor); Ada.Text_IO.Put_Line ("Compressed size : " & Stream_Element_Offset'Image (L) & " bytes"); end Compress; -- Now we decompress the data, passing short blocks of data to Zlib -- (because this demonstrates the problem - the last block passed will -- contain checksum information and there will be no output, only a -- check inside Zlib that the checksum is correct). Decompress : declare Decompressor : Filter_Type; Uncompressed_Data : Stream_Element_Array (1 .. Text'Length); Block_Size : constant := 4; -- This makes sure that the last block contains -- only Adler checksum data. P : Stream_Element_Offset := Compressed_Data'First - 1; O : Stream_Element_Offset; begin Inflate_Init (Decompressor); loop Translate (Decompressor, Compressed_Data (P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)), P, Uncompressed_Data (Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last), O, No_Flush); Ada.Text_IO.Put_Line ("Total in : " & Count'Image (Total_In (Decompressor)) & ", out : " & Count'Image (Total_Out (Decompressor))); exit when P = L; end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Decompressed text matches original text : " & Boolean'Image (Uncompressed_Data = Source)); end Decompress; end; end Buffer_Demo;
with Ada.Text_IO; use Ada.Text_IO; procedure Steps_6 is task Step_By_Step is entry Step_One; entry Step_Two; end Step_By_Step; task body Step_By_Step is Waiting_Count : Natural := 1; begin loop select accept Step_One do Put_Line ("1"); Waiting_Count := 1; end Step_One; or accept Step_Two do Put_Line ("2"); Waiting_Count := 1; end Step_Two; or delay 3.0; if Waiting_Count mod 4 = 0 then Put_Line ("Hurry Up, call me!"); else Put_Line ("No calls. Waiting for another 3 secs"); end if; Waiting_Count := Waiting_Count + 1; end select; end loop; end Step_By_Step; begin Put_Line ("I do my business for 5.5 secs"); delay 5.5; Put_Line ("Stepping into 1"); Step_By_Step.Step_One; Put_Line ("Again... I do my business in 3.5 secs"); delay 3.5; Step_By_Step.Step_Two; Put_Line ("Rest for 2 secs..."); delay 2.0; Put_Line ("Wait..."); delay 1.5; Put_Line ("Work hard 5 times!"); for I in Integer range 1 .. 5 loop Put_Line ("** round " & Integer'Image (I)); Step_By_Step.Step_One; delay 1.0; Step_By_Step.Step_Two; delay 1.0; end loop; Put_Line ("Tired... Bye!"); end;
package body Mult with SPARK_Mode is function Mult (A: Natural; B: Natural) return Natural is AB: Natural := 0; AA: Natural := A; B1: Natural := B; begin while B1 > 0 loop if B1 mod 2 = 1 then AB := AB + AA; end if; AA := 2 * AA; B1 := B1 / 2; pragma Loop_Invariant (A * B = AA * B1 + AB); end loop; return AB; end Mult; end Mult;
with STM32.Device; use STM32.Device; with HAL; use HAL; with STM32.ADC; use STM32.ADC; with STM32.GPIO; use STM32.GPIO; package analog is Converter : Analog_To_Digital_Converter renames ADC_1; Successful : Boolean; procedure Configure_Analog_Input (Input : GPIO_Point); procedure ADC_Init (Input : GPIO_Point; Channel : UInt5); function Analog_Read return uint16; flt : Short_Float := 0.0; end analog;
package Bootloader is pragma Preelaborate; procedure Erase; procedure Start; pragma Machine_Attribute (Start, "naked"); end Bootloader;
-- 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 Tk.Image.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.Environment_Variables; use Ada.Environment_Variables; with Tcl.Lists; use Tcl.Lists; with Tcl.Strings; use Tcl.Strings; -- begin read only -- end read only package body Tk.Image.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 procedure Wrap_Test_Delete_18cc03_4162dd (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) is begin begin pragma Assert (Image_Name'Length in 1 .. Integer'Last - 13 and Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Delete test requirement violated"); end; GNATtest_Generated.GNATtest_Standard.Tk.Image.Delete (Image_Name, Interpreter); begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Delete test commitment violated"); end; end Wrap_Test_Delete_18cc03_4162dd; -- end read only -- begin read only procedure Test_1_Delete_test_image_delete(Gnattest_T: in out Test); procedure Test_Delete_18cc03_4162dd(Gnattest_T: in out Test) renames Test_1_Delete_test_image_delete; -- id:2.2/18cc033703c4a107/Delete/1/0/test_image_delete/ procedure Test_1_Delete_test_image_delete(Gnattest_T: in out Test) is procedure Delete (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) renames Wrap_Test_Delete_18cc03_4162dd; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Tcl_Eval("image create bitmap mybitmap -background red"); Delete("mybitmap"); Assert(True, "This test can only crash."); -- begin read only end Test_1_Delete_test_image_delete; -- end read only -- begin read only procedure Wrap_Test_Delete_c4bccc_e7853a (Images: Array_List; Interpreter: Tcl_Interpreter := Get_Interpreter) is begin begin pragma Assert ((Images'Length > 0 and then Merge_List(List => Images)'Length < Integer'Last - 13) and Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Delete2 test requirement violated"); end; GNATtest_Generated.GNATtest_Standard.Tk.Image.Delete (Images, Interpreter); begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Delete2 test commitment violated"); end; end Wrap_Test_Delete_c4bccc_e7853a; -- end read only -- begin read only procedure Test_2_Delete_test_image_delete2(Gnattest_T: in out Test); procedure Test_Delete_c4bccc_e7853a(Gnattest_T: in out Test) renames Test_2_Delete_test_image_delete2; -- id:2.2/c4bccce0d4280cf5/Delete/0/0/test_image_delete2/ procedure Test_2_Delete_test_image_delete2(Gnattest_T: in out Test) is procedure Delete (Images: Array_List; Interpreter: Tcl_Interpreter := Get_Interpreter) renames Wrap_Test_Delete_c4bccc_e7853a; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Tcl_Eval("image create bitmap mybitmap -background red"); Tcl_Eval("image create bitmap mybitmap2 -background red"); Delete (Array_List'(To_Tcl_String("mybitmap"), To_Tcl_String("mybitmap2"))); Assert(True, "This test can only crash."); -- begin read only end Test_2_Delete_test_image_delete2; -- end read only -- begin read only function Wrap_Test_Height_80fc6b_a13f55 (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return Natural is begin begin pragma Assert (Image_Name'Length in 1 .. Integer'Last - 13 and Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Height test requirement violated"); end; declare Test_Height_80fc6b_a13f55_Result: constant Natural := GNATtest_Generated.GNATtest_Standard.Tk.Image.Height (Image_Name, Interpreter); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Height test commitment violated"); end; return Test_Height_80fc6b_a13f55_Result; end; end Wrap_Test_Height_80fc6b_a13f55; -- end read only -- begin read only procedure Test_Height_test_image_height(Gnattest_T: in out Test); procedure Test_Height_80fc6b_a13f55(Gnattest_T: in out Test) renames Test_Height_test_image_height; -- id:2.2/80fc6bcf066b498a/Height/1/0/test_image_height/ procedure Test_Height_test_image_height(Gnattest_T: in out Test) is function Height (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return Natural renames Wrap_Test_Height_80fc6b_a13f55; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Tcl_Eval("image create bitmap mybitmap -background red"); Assert(Height("mybitmap") = 0, "Failed to get height of the image."); Delete("mybitmap"); -- begin read only end Test_Height_test_image_height; -- end read only -- begin read only function Wrap_Test_In_Use_d3d7f4_57ef8d (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_Boolean_Result is begin begin pragma Assert (Image_Name'Length in 1 .. Integer'Last - 12 and Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_In_Use test requirement violated"); end; declare Test_In_Use_d3d7f4_57ef8d_Result: constant Tcl_Boolean_Result := GNATtest_Generated.GNATtest_Standard.Tk.Image.In_Use (Image_Name, Interpreter); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_In_Use test commitment violated"); end; return Test_In_Use_d3d7f4_57ef8d_Result; end; end Wrap_Test_In_Use_d3d7f4_57ef8d; -- end read only -- begin read only procedure Test_In_Use_test_image_in_use(Gnattest_T: in out Test); procedure Test_In_Use_d3d7f4_57ef8d(Gnattest_T: in out Test) renames Test_In_Use_test_image_in_use; -- id:2.2/d3d7f45dad637676/In_Use/1/0/test_image_in_use/ procedure Test_In_Use_test_image_in_use(Gnattest_T: in out Test) is function In_Use (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_Boolean_Result renames Wrap_Test_In_Use_d3d7f4_57ef8d; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Tcl_Eval("image create bitmap mybitmap -background red"); Assert (not In_Use("mybitmap").Result, "Failed to get image in use state."); Delete("mybitmap"); -- begin read only end Test_In_Use_test_image_in_use; -- end read only -- begin read only function Wrap_Test_Names_eadae1_91e953 (Interpreter: Tcl_Interpreter := Get_Interpreter) return Array_List is begin begin pragma Assert(Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Names test requirement violated"); end; declare Test_Names_eadae1_91e953_Result: constant Array_List := GNATtest_Generated.GNATtest_Standard.Tk.Image.Names(Interpreter); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Names test commitment violated"); end; return Test_Names_eadae1_91e953_Result; end; end Wrap_Test_Names_eadae1_91e953; -- end read only -- begin read only procedure Test_Names_test_image_names(Gnattest_T: in out Test); procedure Test_Names_eadae1_91e953(Gnattest_T: in out Test) renames Test_Names_test_image_names; -- id:2.2/eadae19ee57308fa/Names/1/0/test_image_names/ procedure Test_Names_test_image_names(Gnattest_T: in out Test) is function Names (Interpreter: Tcl_Interpreter := Get_Interpreter) return Array_List renames Wrap_Test_Names_eadae1_91e953; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Assert(Names'Length = 0, "Failed to get images names."); -- begin read only end Test_Names_test_image_names; -- end read only -- begin read only function Wrap_Test_Image_Type_2e187d_3f2cd3 (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return String is begin begin pragma Assert (Image_Name'Length in 1 .. Integer'Last - 11 and Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Type test requirement violated"); end; declare Test_Image_Type_2e187d_3f2cd3_Result: constant String := GNATtest_Generated.GNATtest_Standard.Tk.Image.Image_Type (Image_Name, Interpreter); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Type test commitment violated"); end; return Test_Image_Type_2e187d_3f2cd3_Result; end; end Wrap_Test_Image_Type_2e187d_3f2cd3; -- end read only -- begin read only procedure Test_Image_Type_test_image_type(Gnattest_T: in out Test); procedure Test_Image_Type_2e187d_3f2cd3(Gnattest_T: in out Test) renames Test_Image_Type_test_image_type; -- id:2.2/2e187dd659bbd28b/Image_Type/1/0/test_image_type/ procedure Test_Image_Type_test_image_type(Gnattest_T: in out Test) is function Image_Type (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return String renames Wrap_Test_Image_Type_2e187d_3f2cd3; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Tcl_Eval("image create bitmap mybitmap -background red"); Assert(Image_Type("mybitmap") = "bitmap", "Failed to get image type."); Delete("mybitmap"); -- begin read only end Test_Image_Type_test_image_type; -- end read only -- begin read only function Wrap_Test_Types_efe030_7e3369 (Interpreter: Tcl_Interpreter := Get_Interpreter) return Array_List is begin begin pragma Assert(Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Types test requirement violated"); end; declare Test_Types_efe030_7e3369_Result: constant Array_List := GNATtest_Generated.GNATtest_Standard.Tk.Image.Types(Interpreter); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Types test commitment violated"); end; return Test_Types_efe030_7e3369_Result; end; end Wrap_Test_Types_efe030_7e3369; -- end read only -- begin read only procedure Test_Types_test_image_types(Gnattest_T: in out Test); procedure Test_Types_efe030_7e3369(Gnattest_T: in out Test) renames Test_Types_test_image_types; -- id:2.2/efe03054d1e26056/Types/1/0/test_image_types/ procedure Test_Types_test_image_types(Gnattest_T: in out Test) is function Types (Interpreter: Tcl_Interpreter := Get_Interpreter) return Array_List renames Wrap_Test_Types_efe030_7e3369; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Assert(Types'Length >= 2, "Failed to get images types."); -- begin read only end Test_Types_test_image_types; -- end read only -- begin read only function Wrap_Test_Width_f67773_d8adc9 (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return Natural is begin begin pragma Assert (Image_Name'Length in 1 .. Integer'Last - 12 and Interpreter /= Null_Interpreter); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-image.ads:0):Test_Image_Width test requirement violated"); end; declare Test_Width_f67773_d8adc9_Result: constant Natural := GNATtest_Generated.GNATtest_Standard.Tk.Image.Width (Image_Name, Interpreter); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-image.ads:0:):Test_Image_Width test commitment violated"); end; return Test_Width_f67773_d8adc9_Result; end; end Wrap_Test_Width_f67773_d8adc9; -- end read only -- begin read only procedure Test_Width_test_image_width(Gnattest_T: in out Test); procedure Test_Width_f67773_d8adc9(Gnattest_T: in out Test) renames Test_Width_test_image_width; -- id:2.2/f6777397a6522bab/Width/1/0/test_image_width/ procedure Test_Width_test_image_width(Gnattest_T: in out Test) is function Width (Image_Name: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter) return Natural renames Wrap_Test_Width_f67773_d8adc9; -- end read only pragma Unreferenced(Gnattest_T); begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Tcl_Eval("image create bitmap mybitmap -background red"); Assert(Width("mybitmap") = 0, "Failed to get width of the image."); Delete("mybitmap"); -- begin read only end Test_Width_test_image_width; -- 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 Tk.Image.Test_Data.Tests;
package body UxAS.Common.Sentinel_Serial_Buffers is ----------------------------- -- Get_Next_Payload_String -- ----------------------------- procedure Get_Next_Payload_String (This : in out Sentinel_Serial_Buffer; New_Data_Chunk : String; Result : out String) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Next_Payload_String unimplemented"); raise Program_Error with "Unimplemented procedure Get_Next_Payload_String"; end Get_Next_Payload_String; -------------------------------- -- Create_Sentinelized_String -- -------------------------------- function Create_Sentinelized_String (Data : String) return String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Create_Sentinelized_String unimplemented"); return raise Program_Error with "Unimplemented function Create_Sentinelized_String"; end Create_Sentinelized_String; ------------------------- -- Calculated_Checksum -- ------------------------- function Calculated_Checksum (Str : String) return UInt32 is Result : UInt32 := 0; begin for C of Str loop Result := Result + Character'Pos (C); end loop; return Result; end Calculated_Checksum; ---------------------------------------------- -- Get_Detect_Sentinel_Base_Strings_Message -- ---------------------------------------------- function Get_Detect_Sentinel_Base_Strings_Message (Data : String) return String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Detect_Sentinel_Base_Strings_Message unimplemented"); return raise Program_Error with "Unimplemented function Get_Detect_Sentinel_Base_Strings_Message"; end Get_Detect_Sentinel_Base_Strings_Message; end UxAS.Common.Sentinel_Serial_Buffers;
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- package System.Machine_Code is -- The contents of the library package System.Machine_Code (if provided) -- are implementation defined. end System.Machine_Code;
with AdaCar.Parametros; package body AdaCar.Entrada_Salida is ----------------------- -- Entrada_Salida_PO -- ----------------------- protected Entrada_Salida_PO with Priority => Parametros.Techo_Entrada_Salida_PO is procedure Init_System; function Lectura_Digital(Canal: Canal_DI) return Estado_Digital; procedure Salida_Digital(Canal: Canal_DO; Valor: Estado_Digital); procedure Comienza_Analogico (Canal : Canal_AI); function Lectura_Analogico (Canal : Canal_AI) return Unidades_AI; end Entrada_Salida_PO; ----------------- -- Init_System -- ----------------- procedure Init_System is begin Entrada_Salida_PO.Init_System; end Init_System; --------------------- -- Lectura_Digital -- --------------------- function Lectura_Digital (Canal : Canal_DI) return Estado_Digital is begin return Entrada_Salida_PO.Lectura_Digital(Canal); end Lectura_Digital; -------------------- -- Salida_Digital -- -------------------- procedure Salida_Digital (Canal : Canal_DO; Valor : Estado_Digital) is begin Entrada_Salida_PO.Salida_Digital(Canal,Valor); end Salida_Digital; ------------------------- -- Configura_Analogico -- ------------------------- procedure Comienza_Analogico (Canal : Canal_AI) is begin Entrada_Salida_PO.Comienza_Analogico(Canal); end Comienza_Analogico; ----------------------- -- Lectura_Analogico -- ----------------------- function Lectura_Analogico (Canal : Canal_AI) return Unidades_AI is begin return Entrada_Salida_PO.Lectura_Analogico(Canal); end Lectura_Analogico; ----------------------- -- Entrada_Salida_PO -- ----------------------- protected body Entrada_Salida_PO is procedure Init_System is begin Digital.Configure_Pin(Pin_D2,Input); Digital.Configure_Pin(Pin_D3,Input); Digital.Configure_Pin(Pin_D4,Input); Digital.Configure_Pin(Pin_D5,Input); Digital.Configure_Pin(Pin_D6,Input); Digital.Configure_Pin(Pin_D7,Input); Digital.Configure_Pin(Pin_D8,Output); Digital.Configure_Pin(Pin_D9,Output); Digital.Configure_Pin(Pin_D10,Output); Digital.Configure_Pin(Pin_D11,Output); Digital.Configure_Pin(Pin_D12,Output); Digital.Configure_Pin(Pin_D13,Output); Digital.Set_Signal(Pin_D8,LOW); Digital.Set_Signal(Pin_D9,LOW); Digital.Set_Signal(Pin_D10,LOW); Digital.Set_Signal(Pin_D11,LOW); Digital.Set_Signal(Pin_D12,LOW); Digital.Set_Signal(Pin_D13,LOW); Analog.Configure_Pin(Pin_A0); Analog.Configure_Pin(Pin_A1); Analog.Configure_Pin(Pin_A2); end Init_System; function Lectura_Digital(Canal: Canal_DI) return Estado_Digital is Valor: Signal_Mode; begin Valor:= Digital.Read_Signal(Canal); case Valor is when LOW => return Estado_Digital'(0); when HIGH => return Estado_Digital'(1); end case; end Lectura_Digital; procedure Salida_Digital(Canal: Canal_DO; Valor: Estado_Digital) is begin case Valor is when 0 => Digital.Set_Signal(Canal,LOW); when 1 => Digital.Set_Signal(Canal,HIGH); end case; end Salida_Digital; procedure Comienza_Analogico (Canal : Canal_AI) is begin Analog.Start_Adquisition(Canal); end Comienza_Analogico; function Lectura_Analogico (Canal : Canal_AI) return Unidades_AI is begin return Unidades_AI(Analog.Get_Value(Canal)); end Lectura_Analogico; end Entrada_Salida_PO; end AdaCar.Entrada_Salida;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ P R A G -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-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. 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. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for pragmas with Types; use Types; package Exp_Prag is procedure Expand_N_Pragma (N : Node_Id); procedure Expand_Pragma_Contract_Cases (CCs : Node_Id; Subp_Id : Entity_Id; Decls : List_Id; Stmts : in out List_Id); -- Given pragma Contract_Cases CCs, create the circuitry needed to evaluate -- case guards and trigger consequence expressions. Subp_Id is the related -- subprogram for which the pragma applies. Decls are the declarations of -- Subp_Id's body. All generated code is added to list Stmts. If Stmts is -- No_List on entry, a new list is created. procedure Expand_Pragma_Initial_Condition (Pack_Id : Entity_Id; N : Node_Id); -- Verify the run-time semantics of pragma Initial_Condition when it -- applies to package Pack_Id. N denotes the related package spec or -- body. procedure Expand_Pragma_Subprogram_Variant (Prag : Node_Id; Subp_Id : Entity_Id; Body_Decls : List_Id); -- Given pragma Subprogram_Variant Prag, create the circuitry needed -- to evaluate variant expressions at the subprogram entry and at the -- recursive call. Subp_Id is the related subprogram for which the pragma -- applies and Body_Decls are its body declarations. On exit, the argument -- of Prag is replaced with a reference to procedure with checks for the -- variant expressions. end Exp_Prag;
Counter: Natural; begin -- initialize array Prime; Prime(I) must be true if and only if I is a prime ... Counter := 0; -- count p. numbers below 2**32 for Y in Num(2) .. 2**32 loop if Prime(Pop_Count(Y)) then Counter := Counter + 1; end if; end loop; Ada.Text_IO.Put_Line(Natural'Image(Counter)); end Count_Pernicious;
package Keyboard is type Key_Kind is (Up, Down, Left, Right, Forward, Backward, Esc); procedure Update; function Pressed (Key : Key_Kind) return Boolean; end Keyboard;
-- { dg-do run } with Ada.Text_IO; use Ada.Text_IO; procedure test_fixed_io is type FX is delta 0.0001 range -3.0 .. 250.0; for FX'Small use 0.0001; package FXIO is new Fixed_IO (FX); use FXIO; ST : String (1 .. 11) := (others => ' '); ST2 : String (1 .. 12) := (others => ' '); N : constant FX := -2.345; begin begin Put (ST, N, 6, 2); Put_Line ("*ERROR* Test1: Exception Layout_Error was not raised"); Put_Line ("ST = """ & ST & '"'); exception when Layout_Error => null; when others => Put_Line ("Test1: Unexpected exception"); end; begin Put (ST2, N, 6, 2); exception when Layout_Error => Put_Line ("*ERROR* Test2: Exception Layout_Error was raised"); when others => Put_Line ("Test2: Unexpected exception"); end; end;
with Ada.Text_IO; with Ada.Exceptions; package body SoE is -- slow down factor for the activity of process Odd Slow_Down_Factor : constant Duration := 1.0; -- each process instance gets an own Id Assigned_Id : Natural := 0; -- function specification ---------------------------------------- function Get_Id return Positive; function New_Sieve (Val : Positive) return Sieve_Ref; -- this is the procedure that will be called upon the finalization -- of any scope that contains objects of type Last_Wishes ---------------------------------------- procedure Finalize (Last_Wishes : in out Last_Wishes_T) is use Ada.Text_IO; begin Put_Line ("Process " & Natural'Image (Last_Wishes.Id) & " has completed and can terminate"); end Finalize; --+------------------------------------- task body Odd is -- process Odd has a child process Sieve (instance of Sieve_T) -- with which it will rendezvous for passing down the numbers -- to search for primes in Sieve : Sieve_Ref; Num : Positive := 3; Limit : Positive; -- Odd gets the first Id Last_Wishes : Last_Wishes_T := Last_Wishes_T'(Ada.Finalization.Limited_Controlled with Id => Get_Id); begin accept Set_Limit (User_Limit : Positive) do Limit := User_Limit; end Set_Limit; -- Odd creates its successor and sends it the prime to guard Sieve := New_Sieve (Num); Num := Num + 2; while Num < Limit loop -- process Odd passes down to Sieve by rendez-vous -- all odd numbers subsequent to 3 in the range to Limit -- (the 1st number passed down the line -- is known to be a prime) Sieve.Relay (Num); Num := Num + 2; delay Slow_Down_Factor; end loop; Ada.Text_IO.Put_Line ("Odd ready to finalize ..."); -- process Odd completes ... end Odd; ---------------------------------------- task body Sieve_T is use Ada.Text_IO; Sieve : Sieve_Ref; Prime, Num : Positive; -- any process instance of Sieve_T will possess a finalizable object, -- initialized to the process id of that particular instance, so that -- its termination will be trapped by the finalization of the object Last_Wishes : Last_Wishes_T := Last_Wishes_T'(Ada.Finalization.Limited_Controlled with Id); begin -- any instance of Sieve_T accepts the 1st rendezvous -- with its master, knowing that the 1st incoming value -- will be a prime accept Relay (Int : Positive) do Prime := Int; end Relay; Put_Line ("Sieve instance " & Natural'Image (Id) & " found prime number" & Natural'Image (Prime)); loop -- the instace of Sieve_T continues to accept rendezvous -- with its master to receive all other odd numbers -- in the designated range -- -- as we cannot be sure that there will always -- be callers on this entry (the corresponding master -- or parent may have completed in the meanwhile) -- we should protect this process from infinite wait -- and allow it to terminate in case no partner -- was alive anymore select accept Relay (Int : Positive) do Num := Int; end Relay; or -- this alternative will allow the process instance -- to abandon the select statement in case -- no partner there were no partner left to synchronise with terminate; end select; exit when Num rem Prime /= 0; end loop; -- any number which is not divisible by Prime -- is itself a new prime, and we must pass it on -- by rendezvous to a new child process, instance -- of Sieve, so that it can continue the search Sieve := New_Sieve (Num); loop -- at this point Sieve can accept from its master -- all the remaining odd numbers in the range and -- pass down to its child Sieve those that are -- candidate primes because they are not divisible -- by Prime -- -- we must do the same as before of course select accept Relay (Int : Positive) do Num := Int; end Relay; or -- again, we need to place a terminate alternative -- to allow the accepter to leave the select terminate; end select; if Num rem Prime /= 0 then Sieve.Relay (Num); end if; end loop; -- process Sieve will complete when all select constructs -- will be terminated for the lack of partners exception when E : others => Put_Line ("Exception " & Ada.Exceptions.Exception_Name (E) & " propagated to Sieve instance " & Positive'Image (Id)); Flush; end Sieve_T; --------------------------------------------------------------------------- -- function body ---------------------------------------- function Get_Id return Positive is begin Assigned_Id := Assigned_Id + 1; return Assigned_Id; end Get_Id; function New_Sieve (Val : Positive) return Sieve_Ref is begin -- we want to create a new instance of Sieve -- that is immediately sent the prime to guard -- to this end we use the "extended return" construct return Result : Sieve_Ref := new Sieve_T (Get_Id) do Result.Relay (Val); end return; end New_Sieve; end SoE;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Wide_Text_IO; use Ada.Wide_Text_IO; with Interfaces; use Interfaces; with System; with Ada.Unchecked_Conversion; use Ada; -- Play with UTF8 pragma Wide_Character_Encoding (UTF8); procedure represent2 is type Action_Type is (Load, Store, Copy, Add, Clear, Jump, Ret) with Size => 4; for Action_Type use (Load => 2#1000#, Store => 2#1001#, Copy => 2#1010#, Add => 2#1011#, Clear => 2#1100#, Jump => 2#1101#, Ret => 2#1110#); type Register_Type is mod 2**4 with Size => 4; type Ref_Register_Type is mod 2**2 with Size => 2; type Mode_Type is (Direct, Register, Indirect) with Size => 2; for Mode_Type use (Direct => 2#01#, Register => 2#10#, Indirect => 2#11#); type Mult_Factor_Type is mod 2**2 with Size => 2; type Long_Reg (Mode : Mode_Type := Direct) is record Action : Action_Type; -- 4 case Mode is when Direct => Bit_Fill : Mult_Factor_Type; -- 2 Address : Unsigned_8; -- 8 when Register => Mult_Factor : Mult_Factor_Type; -- 2 Reg1 : Register_Type; -- 4 Reg2 : Register_Type; -- 4 when Indirect => Ref_Reg : Ref_Register_Type; -- 2 Offset : Unsigned_8; -- 8 end case; end record with Size => 16, -- Pack, Bit_Order => System.Low_Order_First; -- This works. for Long_Reg use record Action at 0 range 12 .. 15; Mode at 0 range 10 .. 11; Bit_Fill at 0 range 8 .. 9; Address at 0 range 0 .. 7; Mult_Factor at 0 range 8 .. 9; Reg1 at 0 range 4 .. 7; Reg2 at 0 range 0 .. 3; Ref_Reg at 0 range 8 .. 9; Offset at 0 range 0 .. 7; end record; type Word is new Interfaces.Unsigned_16; function To_Word is new Unchecked_Conversion (Long_Reg, Word); procedure Put_Word (S : Long_Reg) is begin Put_Line (Word'Image (To_Word (S))); end; E : Long_Reg; begin Put_Line (Integer'Image (Long_Reg'Size)); Put (Wide_Character'Val (16#03BC#)); Text_IO.New_Line; E := (Action => Load, Mode => Direct, Bit_Fill => 0, Address => 0); Put_Word (E); E := (Action => Load, Mode => Register, Mult_Factor => 3, Reg1 => 15, Reg2 => 0); Put_Word (E); end;
-- -- Copyright (C) 2019, AdaCore -- -- This spec has been automatically generated from PolarFire.svd pragma Ada_2012; pragma Style_Checks (Off); with System; -- serial communication controller with a flexible serial data -- interface -- package Interfaces.Microsemi.CoreUARTapb is pragma Preelaborate; pragma No_Elaboration_Code_All; --------------- -- Registers -- --------------- subtype Tx_Data_Value_Field is Interfaces.Microsemi.Byte; -- Transmit Data register type Tx_Data_Register is record Value : Tx_Data_Value_Field := 16#0#; -- unspecified Reserved_8_31 : Interfaces.Microsemi.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for Tx_Data_Register use record Value at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype Rx_Data_Value_Field is Interfaces.Microsemi.Byte; -- Receive Data register type Rx_Data_Register is record Value : Rx_Data_Value_Field := 16#0#; -- unspecified Reserved_8_31 : Interfaces.Microsemi.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for Rx_Data_Register use record Value at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype Control_1_Baud_Value_Field is Interfaces.Microsemi.Byte; -- Control register 1 type Control_1_Register is record Baud_Value : Control_1_Baud_Value_Field := 16#0#; -- unspecified Reserved_8_31 : Interfaces.Microsemi.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for Control_1_Register use record Baud_Value at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; type Control_2_Odd_N_Even_Field is (Even, Odd) with Size => 1; for Control_2_Odd_N_Even_Field use (Even => 0, Odd => 1); subtype Control_2_Baud_Value_Field is Interfaces.Microsemi.UInt5; -- Control register 1 type Control_2_Register is record Bit8 : Boolean := False; Parity_En : Boolean := False; Odd_N_Even : Control_2_Odd_N_Even_Field := Interfaces.Microsemi.CoreUARTapb.Even; Baud_Value : Control_2_Baud_Value_Field := 16#0#; -- unspecified Reserved_8_31 : Interfaces.Microsemi.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for Control_2_Register use record Bit8 at 0 range 0 .. 0; Parity_En at 0 range 1 .. 1; Odd_N_Even at 0 range 2 .. 2; Baud_Value at 0 range 3 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Control register 1 type Status_Register is record TX_Rdy : Boolean := False; RX_Rdy : Boolean := False; Parity_Err : Boolean := False; Overflow : Boolean := False; Framing_Err : Boolean := False; -- unspecified Reserved_5_31 : Interfaces.Microsemi.UInt27 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for Status_Register use record TX_Rdy at 0 range 0 .. 0; RX_Rdy at 0 range 1 .. 1; Parity_Err at 0 range 2 .. 2; Overflow at 0 range 3 .. 3; Framing_Err at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype Control_3_Baud_Val_Fraction_Field is Interfaces.Microsemi.UInt3; -- Control register 1 type Control_3_Register is record Baud_Val_Fraction : Control_3_Baud_Val_Fraction_Field := 16#0#; -- unspecified Reserved_3_31 : Interfaces.Microsemi.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for Control_3_Register use record Baud_Val_Fraction at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- serial communication controller with a flexible serial data interface type CoreUARTapb_Peripheral is record -- Transmit Data register Tx_Data : aliased Tx_Data_Register; -- Receive Data register Rx_Data : aliased Rx_Data_Register; -- Control register 1 Control_1 : aliased Control_1_Register; -- Control register 1 Control_2 : aliased Control_2_Register; -- Control register 1 Status : aliased Status_Register; -- Control register 1 Control_3 : aliased Control_3_Register; end record with Volatile; for CoreUARTapb_Peripheral use record Tx_Data at 16#0# range 0 .. 31; Rx_Data at 16#4# range 0 .. 31; Control_1 at 16#8# range 0 .. 31; Control_2 at 16#C# range 0 .. 31; Status at 16#10# range 0 .. 31; Control_3 at 16#14# range 0 .. 31; end record; -- serial communication controller with a flexible serial data interface CoreUARTapb_Periph : aliased CoreUARTapb_Peripheral with Import, Address => CoreUARTapb_Base; end Interfaces.Microsemi.CoreUARTapb;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 5 -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; with Errout; use Errout; with Expander; use Expander; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Lib.Xref; use Lib.Xref; with Nlists; use Nlists; with Opt; use Opt; with Sem; use Sem; with Sem_Case; use Sem_Case; with Sem_Ch3; use Sem_Ch3; with Sem_Ch8; use Sem_Ch8; with Sem_Disp; use Sem_Disp; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; with Sem_Warn; use Sem_Warn; with Stand; use Stand; with Sinfo; use Sinfo; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Sem_Ch5 is Unblocked_Exit_Count : Nat := 0; -- This variable is used when processing if statements or case -- statements, it counts the number of branches of the conditional -- that are not blocked by unconditional transfer instructions. At -- the end of processing, if the count is zero, it means that control -- cannot fall through the conditional statement. This is used for -- the generation of warning messages. This variable is recursively -- saved on entry to processing an if or case, and restored on exit. ----------------------- -- Local Subprograms -- ----------------------- procedure Analyze_Iteration_Scheme (N : Node_Id); ------------------------ -- Analyze_Assignment -- ------------------------ procedure Analyze_Assignment (N : Node_Id) is Lhs : constant Node_Id := Name (N); Rhs : constant Node_Id := Expression (N); T1, T2 : Entity_Id; Decl : Node_Id; procedure Diagnose_Non_Variable_Lhs (N : Node_Id); -- N is the node for the left hand side of an assignment, and it -- is not a variable. This routine issues an appropriate diagnostic. procedure Set_Assignment_Type (Opnd : Node_Id; Opnd_Type : in out Entity_Id); -- Opnd is either the Lhs or Rhs of the assignment, and Opnd_Type -- is the nominal subtype. This procedure is used to deal with cases -- where the nominal subtype must be replaced by the actual subtype. ------------------------------- -- Diagnose_Non_Variable_Lhs -- ------------------------------- procedure Diagnose_Non_Variable_Lhs (N : Node_Id) is begin -- Not worth posting another error if left hand side already -- flagged as being illegal in some respect if Error_Posted (N) then return; -- Some special bad cases of entity names elsif Is_Entity_Name (N) then if Ekind (Entity (N)) = E_In_Parameter then Error_Msg_N ("assignment to IN mode parameter not allowed", N); return; -- Private declarations in a protected object are turned into -- constants when compiling a protected function. elsif Present (Scope (Entity (N))) and then Is_Protected_Type (Scope (Entity (N))) and then (Ekind (Current_Scope) = E_Function or else Ekind (Enclosing_Dynamic_Scope (Current_Scope)) = E_Function) then Error_Msg_N ("protected function cannot modify protected object", N); return; elsif Ekind (Entity (N)) = E_Loop_Parameter then Error_Msg_N ("assignment to loop parameter not allowed", N); return; end if; -- For indexed components, or selected components, test prefix elsif Nkind (N) = N_Indexed_Component or else Nkind (N) = N_Selected_Component then Diagnose_Non_Variable_Lhs (Prefix (N)); return; end if; -- If we fall through, we have no special message to issue! Error_Msg_N ("left hand side of assignment must be a variable", N); end Diagnose_Non_Variable_Lhs; ------------------------- -- Set_Assignment_Type -- ------------------------- procedure Set_Assignment_Type (Opnd : Node_Id; Opnd_Type : in out Entity_Id) is begin -- If the assignment operand is an in-out or out parameter, then we -- get the actual subtype (needed for the unconstrained case). if Is_Entity_Name (Opnd) and then (Ekind (Entity (Opnd)) = E_Out_Parameter or else Ekind (Entity (Opnd)) = E_In_Out_Parameter or else Ekind (Entity (Opnd)) = E_Generic_In_Out_Parameter) then Opnd_Type := Get_Actual_Subtype (Opnd); -- If assignment operand is a component reference, then we get the -- actual subtype of the component for the unconstrained case. elsif Nkind (Opnd) = N_Selected_Component or else Nkind (Opnd) = N_Explicit_Dereference then Decl := Build_Actual_Subtype_Of_Component (Opnd_Type, Opnd); if Present (Decl) then Insert_Action (N, Decl); Mark_Rewrite_Insertion (Decl); Analyze (Decl); Opnd_Type := Defining_Identifier (Decl); Set_Etype (Opnd, Opnd_Type); Freeze_Itype (Opnd_Type, N); elsif Is_Constrained (Etype (Opnd)) then Opnd_Type := Etype (Opnd); end if; -- For slice, use the constrained subtype created for the slice elsif Nkind (Opnd) = N_Slice then Opnd_Type := Etype (Opnd); end if; end Set_Assignment_Type; -- Start of processing for Analyze_Assignment begin Analyze (Rhs); Analyze (Lhs); T1 := Etype (Lhs); -- In the most general case, both Lhs and Rhs can be overloaded, and we -- must compute the intersection of the possible types on each side. if Is_Overloaded (Lhs) then declare I : Interp_Index; It : Interp; begin T1 := Any_Type; Get_First_Interp (Lhs, I, It); while Present (It.Typ) loop if Has_Compatible_Type (Rhs, It.Typ) then if T1 /= Any_Type then -- An explicit dereference is overloaded if the prefix -- is. Try to remove the ambiguity on the prefix, the -- error will be posted there if the ambiguity is real. if Nkind (Lhs) = N_Explicit_Dereference then declare PI : Interp_Index; PI1 : Interp_Index := 0; PIt : Interp; Found : Boolean; begin Found := False; Get_First_Interp (Prefix (Lhs), PI, PIt); while Present (PIt.Typ) loop if Has_Compatible_Type (Rhs, Designated_Type (PIt.Typ)) then if Found then PIt := Disambiguate (Prefix (Lhs), PI1, PI, Any_Type); if PIt = No_Interp then return; else Resolve (Prefix (Lhs), PIt.Typ); end if; exit; else Found := True; PI1 := PI; end if; end if; Get_Next_Interp (PI, PIt); end loop; end; else Error_Msg_N ("ambiguous left-hand side in assignment", Lhs); exit; end if; else T1 := It.Typ; end if; end if; Get_Next_Interp (I, It); end loop; end; if T1 = Any_Type then Error_Msg_N ("no valid types for left-hand side for assignment", Lhs); return; end if; end if; Resolve (Lhs, T1); if not Is_Variable (Lhs) then Diagnose_Non_Variable_Lhs (Lhs); return; elsif Is_Limited_Type (T1) and then not Assignment_OK (Lhs) and then not Assignment_OK (Original_Node (Lhs)) then Error_Msg_N ("left hand of assignment must not be limited type", Lhs); return; end if; -- Resolution may have updated the subtype, in case the left-hand -- side is a private protected component. Use the correct subtype -- to avoid scoping issues in the back-end. T1 := Etype (Lhs); Set_Assignment_Type (Lhs, T1); Resolve (Rhs, T1); -- Remaining steps are skipped if Rhs was synatactically in error if Rhs = Error then return; end if; T2 := Etype (Rhs); Check_Unset_Reference (Rhs); Note_Possible_Modification (Lhs); if Covers (T1, T2) then null; else Wrong_Type (Rhs, Etype (Lhs)); return; end if; Set_Assignment_Type (Rhs, T2); if T1 = Any_Type or else T2 = Any_Type then return; end if; if (Is_Class_Wide_Type (T2) or else Is_Dynamically_Tagged (Rhs)) and then not Is_Class_Wide_Type (T1) then Error_Msg_N ("dynamically tagged expression not allowed!", Rhs); elsif Is_Class_Wide_Type (T1) and then not Is_Class_Wide_Type (T2) and then not Is_Tag_Indeterminate (Rhs) and then not Is_Dynamically_Tagged (Rhs) then Error_Msg_N ("dynamically tagged expression required!", Rhs); end if; -- Tag propagation is done only in semantics mode only. If expansion -- is on, the rhs tag indeterminate function call has been expanded -- and tag propagation would have happened too late, so the -- propagation take place in expand_call instead. if not Expander_Active and then Is_Class_Wide_Type (T1) and then Is_Tag_Indeterminate (Rhs) then Propagate_Tag (Lhs, Rhs); end if; if Is_Scalar_Type (T1) then Apply_Scalar_Range_Check (Rhs, Etype (Lhs)); elsif Is_Array_Type (T1) then -- Assignment verifies that the length of the Lsh and Rhs are equal, -- but of course the indices do not have to match. Apply_Length_Check (Rhs, Etype (Lhs)); else -- Discriminant checks are applied in the course of expansion. null; end if; -- ??? a real accessibility check is needed when ??? -- Post warning for useless assignment if Warn_On_Redundant_Constructs -- We only warn for source constructs and then Comes_From_Source (N) -- Where the entity is the same on both sides and then Is_Entity_Name (Lhs) and then Is_Entity_Name (Rhs) and then Entity (Lhs) = Entity (Rhs) -- But exclude the case where the right side was an operation -- that got rewritten (e.g. JUNK + K, where K was known to be -- zero). We don't want to warn in such a case, since it is -- reasonable to write such expressions especially when K is -- defined symbolically in some other package. and then Nkind (Original_Node (Rhs)) not in N_Op then Error_Msg_NE ("?useless assignment of & to itself", N, Entity (Lhs)); end if; end Analyze_Assignment; ----------------------------- -- Analyze_Block_Statement -- ----------------------------- procedure Analyze_Block_Statement (N : Node_Id) is Decls : constant List_Id := Declarations (N); Id : constant Node_Id := Identifier (N); Ent : Entity_Id; begin -- If a label is present analyze it and mark it as referenced if Present (Id) then Analyze (Id); Ent := Entity (Id); Set_Ekind (Ent, E_Block); Generate_Reference (Ent, N, ' '); Generate_Definition (Ent); if Nkind (Parent (Ent)) = N_Implicit_Label_Declaration then Set_Label_Construct (Parent (Ent), N); end if; -- Otherwise create a label entity else Ent := New_Internal_Entity (E_Block, Current_Scope, Sloc (N), 'B'); Set_Identifier (N, New_Occurrence_Of (Ent, Sloc (N))); end if; Set_Etype (Ent, Standard_Void_Type); Set_Block_Node (Ent, Identifier (N)); New_Scope (Ent); if Present (Decls) then Analyze_Declarations (Decls); Check_Completion; end if; Analyze (Handled_Statement_Sequence (N)); Process_End_Label (Handled_Statement_Sequence (N), 'e'); -- Analyze exception handlers if present. Note that the test for -- HSS being present is an error defence against previous errors. if Present (Handled_Statement_Sequence (N)) and then Present (Exception_Handlers (Handled_Statement_Sequence (N))) then declare S : Entity_Id := Scope (Ent); begin -- Indicate that enclosing scopes contain a block with handlers. -- Only non-generic scopes need to be marked. loop Set_Has_Nested_Block_With_Handler (S); exit when Is_Overloadable (S) or else Ekind (S) = E_Package or else Ekind (S) = E_Generic_Function or else Ekind (S) = E_Generic_Package or else Ekind (S) = E_Generic_Procedure; S := Scope (S); end loop; end; end if; Check_References (Ent); End_Scope; end Analyze_Block_Statement; ---------------------------- -- Analyze_Case_Statement -- ---------------------------- procedure Analyze_Case_Statement (N : Node_Id) is Statements_Analyzed : Boolean := False; -- Set True if at least some statement sequences get analyzed. -- If False on exit, means we had a serious error that prevented -- full analysis of the case statement, and as a result it is not -- a good idea to output warning messages about unreachable code. Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; -- Recursively save value of this global, will be restored on exit procedure Non_Static_Choice_Error (Choice : Node_Id); -- Error routine invoked by the generic instantiation below when -- the case statement has a non static choice. procedure Process_Statements (Alternative : Node_Id); -- Analyzes all the statements associated to a case alternative. -- Needed by the generic instantiation below. package Case_Choices_Processing is new Generic_Choices_Processing (Get_Alternatives => Alternatives, Get_Choices => Discrete_Choices, Process_Empty_Choice => No_OP, Process_Non_Static_Choice => Non_Static_Choice_Error, Process_Associated_Node => Process_Statements); use Case_Choices_Processing; -- Instantiation of the generic choice processing package. ----------------------------- -- Non_Static_Choice_Error -- ----------------------------- procedure Non_Static_Choice_Error (Choice : Node_Id) is begin Error_Msg_N ("choice given in case statement is not static", Choice); end Non_Static_Choice_Error; ------------------------ -- Process_Statements -- ------------------------ procedure Process_Statements (Alternative : Node_Id) is begin Unblocked_Exit_Count := Unblocked_Exit_Count + 1; Statements_Analyzed := True; Analyze_Statements (Statements (Alternative)); end Process_Statements; -- Variables local to Analyze_Case_Statement. Exp : Node_Id; Exp_Type : Entity_Id; Exp_Btype : Entity_Id; Case_Table : Choice_Table_Type (1 .. Number_Of_Choices (N)); Last_Choice : Nat; Dont_Care : Boolean; Others_Present : Boolean; -- Start of processing for Analyze_Case_Statement begin Unblocked_Exit_Count := 0; Exp := Expression (N); Analyze_And_Resolve (Exp, Any_Discrete); Check_Unset_Reference (Exp); Exp_Type := Etype (Exp); Exp_Btype := Base_Type (Exp_Type); -- The expression must be of a discrete type which must be determinable -- independently of the context in which the expression occurs, but -- using the fact that the expression must be of a discrete type. -- Moreover, the type this expression must not be a character literal -- (which is always ambiguous) or, for Ada-83, a generic formal type. -- If error already reported by Resolve, nothing more to do if Exp_Btype = Any_Discrete or else Exp_Btype = Any_Type then return; elsif Exp_Btype = Any_Character then Error_Msg_N ("character literal as case expression is ambiguous", Exp); return; elsif Ada_83 and then (Is_Generic_Type (Exp_Btype) or else Is_Generic_Type (Root_Type (Exp_Btype))) then Error_Msg_N ("(Ada 83) case expression cannot be of a generic type", Exp); return; end if; -- If the case expression is a formal object of mode in out, -- then treat it as having a nonstatic subtype by forcing -- use of the base type (which has to get passed to -- Check_Case_Choices below). Also use base type when -- the case expression is parenthesized. if Paren_Count (Exp) > 0 or else (Is_Entity_Name (Exp) and then Ekind (Entity (Exp)) = E_Generic_In_Out_Parameter) then Exp_Type := Exp_Btype; end if; -- Call the instantiated Analyze_Choices which does the rest of the work Analyze_Choices (N, Exp_Type, Case_Table, Last_Choice, Dont_Care, Others_Present); if Exp_Type = Universal_Integer and then not Others_Present then Error_Msg_N ("case on universal integer requires OTHERS choice", Exp); end if; -- If all our exits were blocked by unconditional transfers of control, -- then the entire CASE statement acts as an unconditional transfer of -- control, so treat it like one, and check unreachable code. Skip this -- test if we had serious errors preventing any statement analysis. if Unblocked_Exit_Count = 0 and then Statements_Analyzed then Unblocked_Exit_Count := Save_Unblocked_Exit_Count; Check_Unreachable_Code (N); else Unblocked_Exit_Count := Save_Unblocked_Exit_Count; end if; end Analyze_Case_Statement; ---------------------------- -- Analyze_Exit_Statement -- ---------------------------- -- If the exit includes a name, it must be the name of a currently open -- loop. Otherwise there must be an innermost open loop on the stack, -- to which the statement implicitly refers. procedure Analyze_Exit_Statement (N : Node_Id) is Target : constant Node_Id := Name (N); Cond : constant Node_Id := Condition (N); Scope_Id : Entity_Id; U_Name : Entity_Id; Kind : Entity_Kind; begin if No (Cond) then Check_Unreachable_Code (N); end if; if Present (Target) then Analyze (Target); U_Name := Entity (Target); if not In_Open_Scopes (U_Name) or else Ekind (U_Name) /= E_Loop then Error_Msg_N ("invalid loop name in exit statement", N); return; else Set_Has_Exit (U_Name); end if; else U_Name := Empty; end if; for J in reverse 0 .. Scope_Stack.Last loop Scope_Id := Scope_Stack.Table (J).Entity; Kind := Ekind (Scope_Id); if Kind = E_Loop and then (No (Target) or else Scope_Id = U_Name) then Set_Has_Exit (Scope_Id); exit; elsif Kind = E_Block or else Kind = E_Loop then null; else Error_Msg_N ("cannot exit from program unit or accept statement", N); exit; end if; end loop; -- Verify that if present the condition is a Boolean expression. if Present (Cond) then Analyze_And_Resolve (Cond, Any_Boolean); Check_Unset_Reference (Cond); end if; end Analyze_Exit_Statement; ---------------------------- -- Analyze_Goto_Statement -- ---------------------------- procedure Analyze_Goto_Statement (N : Node_Id) is Label : constant Node_Id := Name (N); Scope_Id : Entity_Id; Label_Scope : Entity_Id; begin Check_Unreachable_Code (N); Analyze (Label); if Entity (Label) = Any_Id then return; elsif Ekind (Entity (Label)) /= E_Label then Error_Msg_N ("target of goto statement must be a label", Label); return; elsif not Reachable (Entity (Label)) then Error_Msg_N ("target of goto statement is not reachable", Label); return; end if; Label_Scope := Enclosing_Scope (Entity (Label)); for J in reverse 0 .. Scope_Stack.Last loop Scope_Id := Scope_Stack.Table (J).Entity; if Label_Scope = Scope_Id or else (Ekind (Scope_Id) /= E_Block and then Ekind (Scope_Id) /= E_Loop) then if Scope_Id /= Label_Scope then Error_Msg_N ("cannot exit from program unit or accept statement", N); end if; return; end if; end loop; raise Program_Error; end Analyze_Goto_Statement; -------------------------- -- Analyze_If_Statement -- -------------------------- -- A special complication arises in the analysis of if statements. -- The expander has circuitry to completely deleted code that it -- can tell will not be executed (as a result of compile time known -- conditions). In the analyzer, we ensure that code that will be -- deleted in this manner is analyzed but not expanded. This is -- obviously more efficient, but more significantly, difficulties -- arise if code is expanded and then eliminated (e.g. exception -- table entries disappear). procedure Analyze_If_Statement (N : Node_Id) is E : Node_Id; Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; -- Recursively save value of this global, will be restored on exit Del : Boolean := False; -- This flag gets set True if a True condition has been found, -- which means that remaining ELSE/ELSIF parts are deleted. procedure Analyze_Cond_Then (Cnode : Node_Id); -- This is applied to either the N_If_Statement node itself or -- to an N_Elsif_Part node. It deals with analyzing the condition -- and the THEN statements associated with it. procedure Analyze_Cond_Then (Cnode : Node_Id) is Cond : constant Node_Id := Condition (Cnode); Tstm : constant List_Id := Then_Statements (Cnode); begin Unblocked_Exit_Count := Unblocked_Exit_Count + 1; Analyze_And_Resolve (Cond, Any_Boolean); Check_Unset_Reference (Cond); -- If already deleting, then just analyze then statements if Del then Analyze_Statements (Tstm); -- Compile time known value, not deleting yet elsif Compile_Time_Known_Value (Cond) then -- If condition is True, then analyze the THEN statements -- and set no expansion for ELSE and ELSIF parts. if Is_True (Expr_Value (Cond)) then Analyze_Statements (Tstm); Del := True; Expander_Mode_Save_And_Set (False); -- If condition is False, analyze THEN with expansion off else -- Is_False (Expr_Value (Cond)) Expander_Mode_Save_And_Set (False); Analyze_Statements (Tstm); Expander_Mode_Restore; end if; -- Not known at compile time, not deleting, normal analysis else Analyze_Statements (Tstm); end if; end Analyze_Cond_Then; -- Start of Analyze_If_Statement begin -- Initialize exit count for else statements. If there is no else -- part, this count will stay non-zero reflecting the fact that the -- uncovered else case is an unblocked exit. Unblocked_Exit_Count := 1; Analyze_Cond_Then (N); -- Now to analyze the elsif parts if any are present if Present (Elsif_Parts (N)) then E := First (Elsif_Parts (N)); while Present (E) loop Analyze_Cond_Then (E); Next (E); end loop; end if; if Present (Else_Statements (N)) then Analyze_Statements (Else_Statements (N)); end if; -- If all our exits were blocked by unconditional transfers of control, -- then the entire IF statement acts as an unconditional transfer of -- control, so treat it like one, and check unreachable code. if Unblocked_Exit_Count = 0 then Unblocked_Exit_Count := Save_Unblocked_Exit_Count; Check_Unreachable_Code (N); else Unblocked_Exit_Count := Save_Unblocked_Exit_Count; end if; if Del then Expander_Mode_Restore; end if; end Analyze_If_Statement; ---------------------------------------- -- Analyze_Implicit_Label_Declaration -- ---------------------------------------- -- An implicit label declaration is generated in the innermost -- enclosing declarative part. This is done for labels as well as -- block and loop names. -- Note: any changes in this routine may need to be reflected in -- Analyze_Label_Entity. procedure Analyze_Implicit_Label_Declaration (N : Node_Id) is Id : Node_Id := Defining_Identifier (N); begin Enter_Name (Id); Set_Ekind (Id, E_Label); Set_Etype (Id, Standard_Void_Type); Set_Enclosing_Scope (Id, Current_Scope); end Analyze_Implicit_Label_Declaration; ------------------------------ -- Analyze_Iteration_Scheme -- ------------------------------ procedure Analyze_Iteration_Scheme (N : Node_Id) is begin -- For an infinite loop, there is no iteration scheme if No (N) then return; else declare Cond : constant Node_Id := Condition (N); begin -- For WHILE loop, verify that the condition is a Boolean -- expression and resolve and check it. if Present (Cond) then Analyze_And_Resolve (Cond, Any_Boolean); Check_Unset_Reference (Cond); -- Else we have a FOR loop else declare LP : constant Node_Id := Loop_Parameter_Specification (N); Id : constant Entity_Id := Defining_Identifier (LP); DS : constant Node_Id := Discrete_Subtype_Definition (LP); F : List_Id; begin Enter_Name (Id); -- We always consider the loop variable to be referenced, -- since the loop may be used just for counting purposes. Generate_Reference (Id, N, ' '); -- Check for case of loop variable hiding a local -- variable (used later on to give a nice warning -- if the hidden variable is never assigned). declare H : constant Entity_Id := Homonym (Id); begin if Present (H) and then Enclosing_Dynamic_Scope (H) = Enclosing_Dynamic_Scope (Id) and then Ekind (H) = E_Variable and then Is_Discrete_Type (Etype (H)) then Set_Hiding_Loop_Variable (H, Id); end if; end; -- Now analyze the subtype definition Analyze (DS); if DS = Error then return; end if; -- The subtype indication may denote the completion -- of an incomplete type declaration. if Is_Entity_Name (DS) and then Present (Entity (DS)) and then Is_Type (Entity (DS)) and then Ekind (Entity (DS)) = E_Incomplete_Type then Set_Entity (DS, Get_Full_View (Entity (DS))); Set_Etype (DS, Entity (DS)); end if; if not Is_Discrete_Type (Etype (DS)) then Wrong_Type (DS, Any_Discrete); Set_Etype (DS, Any_Type); end if; Make_Index (DS, LP); Set_Ekind (Id, E_Loop_Parameter); Set_Etype (Id, Etype (DS)); Set_Is_Known_Valid (Id, True); -- The loop is not a declarative part, so the only entity -- declared "within" must be frozen explicitly. Since the -- type of this entity has already been frozen, this cannot -- generate any freezing actions. F := Freeze_Entity (Id, Sloc (LP)); pragma Assert (F = No_List); -- Check for null or possibly null range and issue warning. -- We suppress such messages in generic templates and -- instances, because in practice they tend to be dubious -- in these cases. if Nkind (DS) = N_Range and then Comes_From_Source (N) and then not Inside_A_Generic and then not In_Instance then declare L : constant Node_Id := Low_Bound (DS); H : constant Node_Id := High_Bound (DS); Llo : Uint; Lhi : Uint; LOK : Boolean; Hlo : Uint; Hhi : Uint; HOK : Boolean; begin Determine_Range (L, LOK, Llo, Lhi); Determine_Range (H, HOK, Hlo, Hhi); -- If range of loop is null, issue warning if (LOK and HOK) and then Llo > Hhi then Error_Msg_N ("?loop range is null, loop will not execute", DS); -- The other case for a warning is a reverse loop -- where the upper bound is the integer literal -- zero or one, and the lower bound can be positive. elsif Reverse_Present (LP) and then Nkind (H) = N_Integer_Literal and then (Intval (H) = Uint_0 or else Intval (H) = Uint_1) and then Lhi > Hhi then Warn_On_Instance := True; Error_Msg_N ("?loop range may be null", DS); Warn_On_Instance := False; end if; end; end if; end; end if; end; end if; end Analyze_Iteration_Scheme; ------------------- -- Analyze_Label -- ------------------- -- Important note: normally this routine is called from Analyze_Statements -- which does a prescan, to make sure that the Reachable flags are set on -- all labels before encountering a possible goto to one of these labels. -- If expanded code analyzes labels via the normal Sem path, then it must -- ensure that Reachable is set early enough to avoid problems in the case -- of a forward goto. procedure Analyze_Label (N : Node_Id) is Lab : Entity_Id; begin Analyze (Identifier (N)); Lab := Entity (Identifier (N)); -- If we found a label mark it as reachable. if Ekind (Lab) = E_Label then Generate_Definition (Lab); Set_Reachable (Lab); if Nkind (Parent (Lab)) = N_Implicit_Label_Declaration then Set_Label_Construct (Parent (Lab), N); end if; -- If we failed to find a label, it means the implicit declaration -- of the label was hidden. A for-loop parameter can do this to a -- label with the same name inside the loop, since the implicit label -- declaration is in the innermost enclosing body or block statement. else Error_Msg_Sloc := Sloc (Lab); Error_Msg_N ("implicit label declaration for & is hidden#", Identifier (N)); end if; end Analyze_Label; -------------------------- -- Analyze_Label_Entity -- -------------------------- procedure Analyze_Label_Entity (E : Entity_Id) is begin Set_Ekind (E, E_Label); Set_Etype (E, Standard_Void_Type); Set_Enclosing_Scope (E, Current_Scope); Set_Reachable (E, True); end Analyze_Label_Entity; ---------------------------- -- Analyze_Loop_Statement -- ---------------------------- procedure Analyze_Loop_Statement (N : Node_Id) is Id : constant Node_Id := Identifier (N); Ent : Entity_Id; begin if Present (Id) then -- Make name visible, e.g. for use in exit statements. Loop -- labels are always considered to be referenced. Analyze (Id); Ent := Entity (Id); Generate_Reference (Ent, N, ' '); Generate_Definition (Ent); -- If we found a label, mark its type. If not, ignore it, since it -- means we have a conflicting declaration, which would already have -- been diagnosed at declaration time. Set Label_Construct of the -- implicit label declaration, which is not created by the parser -- for generic units. if Ekind (Ent) = E_Label then Set_Ekind (Ent, E_Loop); if Nkind (Parent (Ent)) = N_Implicit_Label_Declaration then Set_Label_Construct (Parent (Ent), N); end if; end if; -- Case of no identifier present else Ent := New_Internal_Entity (E_Loop, Current_Scope, Sloc (N), 'L'); Set_Etype (Ent, Standard_Void_Type); Set_Parent (Ent, N); end if; New_Scope (Ent); Analyze_Iteration_Scheme (Iteration_Scheme (N)); Analyze_Statements (Statements (N)); Process_End_Label (N, 'e'); End_Scope; end Analyze_Loop_Statement; ---------------------------- -- Analyze_Null_Statement -- ---------------------------- -- Note: the semantics of the null statement is implemented by a single -- null statement, too bad everything isn't as simple as this! procedure Analyze_Null_Statement (N : Node_Id) is begin null; end Analyze_Null_Statement; ------------------------ -- Analyze_Statements -- ------------------------ procedure Analyze_Statements (L : List_Id) is S : Node_Id; begin -- The labels declared in the statement list are reachable from -- statements in the list. We do this as a prepass so that any -- goto statement will be properly flagged if its target is not -- reachable. This is not required, but is nice behavior! S := First (L); while Present (S) loop if Nkind (S) = N_Label then Analyze_Label (S); end if; Next (S); end loop; -- Perform semantic analysis on all statements S := First (L); while Present (S) loop if Nkind (S) /= N_Label then Analyze (S); end if; Next (S); end loop; -- Make labels unreachable. Visibility is not sufficient, because -- labels in one if-branch for example are not reachable from the -- other branch, even though their declarations are in the enclosing -- declarative part. S := First (L); while Present (S) loop if Nkind (S) = N_Label then Set_Reachable (Entity (Identifier (S)), False); end if; Next (S); end loop; end Analyze_Statements; ---------------------------- -- Check_Unreachable_Code -- ---------------------------- procedure Check_Unreachable_Code (N : Node_Id) is Error_Loc : Source_Ptr; P : Node_Id; begin if Is_List_Member (N) and then Comes_From_Source (N) then declare Nxt : Node_Id; begin Nxt := Original_Node (Next (N)); if Present (Nxt) and then Comes_From_Source (Nxt) and then Is_Statement (Nxt) then -- Special very annoying exception. If we have a return that -- follows a raise, then we allow it without a warning, since -- the Ada RM annoyingly requires a useless return here! if Nkind (Original_Node (N)) /= N_Raise_Statement or else Nkind (Nxt) /= N_Return_Statement then -- The rather strange shenanigans with the warning message -- here reflects the fact that Kill_Dead_Code is very good -- at removing warnings in deleted code, and this is one -- warning we would prefer NOT to have removed :-) Error_Loc := Sloc (Nxt); -- If we have unreachable code, analyze and remove the -- unreachable code, since it is useless and we don't -- want to generate junk warnings. -- We skip this step if we are not in code generation mode. -- This is the one case where we remove dead code in the -- semantics as opposed to the expander, and we do not want -- to remove code if we are not in code generation mode, -- since this messes up the ASIS trees. -- Note that one might react by moving the whole circuit to -- exp_ch5, but then we lose the warning in -gnatc mode. if Operating_Mode = Generate_Code then loop Nxt := Next (N); exit when No (Nxt) or else not Is_Statement (Nxt); Analyze (Nxt); Remove (Nxt); Kill_Dead_Code (Nxt); end loop; end if; -- Now issue the warning Error_Msg ("?unreachable code", Error_Loc); end if; -- If the unconditional transfer of control instruction is -- the last statement of a sequence, then see if our parent -- is an IF statement, and if so adjust the unblocked exit -- count of the if statement to reflect the fact that this -- branch of the if is indeed blocked by a transfer of control. else P := Parent (N); if Nkind (P) = N_If_Statement then null; elsif Nkind (P) = N_Elsif_Part then P := Parent (P); pragma Assert (Nkind (P) = N_If_Statement); elsif Nkind (P) = N_Case_Statement_Alternative then P := Parent (P); pragma Assert (Nkind (P) = N_Case_Statement); else return; end if; Unblocked_Exit_Count := Unblocked_Exit_Count - 1; end if; end; end if; end Check_Unreachable_Code; end Sem_Ch5;
-- { dg-do compile } -- { dg-options "-O -Wall" } function uninit_func (A, B : Boolean) return Boolean is C : Boolean; begin if A then C := False; elsif B then C := True; end if; return C; -- { dg-warning "may be used uninitialized" } end;
with Ada.Containers.Multiway_Trees; package Improved_Trie is type Element_Type is record A : Character; B : Integer; end record; function "=" (Left, Right : Element_Type) return Boolean is (Left.A = Right.A); --the Ada Multiway tree package backend to be used package Trie is new Ada.Containers.Multiway_Trees (Element_Type=>Element_Type, "="=>"="); use Trie; --searches the Trie for the input string. --returns the associated integer, returns -1 if not found function Find_String (T : Tree; Input : String) return Integer; --adds the input string into the Trie --returns whether it is successful or not function Add_String (T : in out Tree; Input : String; Address : Integer) return Boolean; private --finds the child of a node --returns the found child node, No_Element if not found function Find_Immediate_Child (Parent : Cursor; Element : Element_Type) return Cursor; --moves the input node to the found child node --returns if found or not. --if not found, Parent is not changed function Find_Move_Immediate_Child (Parent : in out Cursor; Element : Element_Type) return Boolean; end Improved_Trie;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with CUPS.bits_types_h; with CUPS.wchar_h; private package CUPS.uG_config_h is -- This file is needed by libio to define various configuration parameters. -- These are always the same in the GNU C library. -- Define types for libio in terms of the standard internal type names. type u_G_fpos_t is record uu_pos : aliased CUPS.bits_types_h.uu_off_t; -- _G_config.h:23 uu_state : aliased CUPS.wchar_h.uu_mbstate_t; -- _G_config.h:24 end record; pragma Convention (C_Pass_By_Copy, u_G_fpos_t); -- _G_config.h:25 -- skipped anonymous struct anon_3 type u_G_fpos64_t is record uu_pos : aliased CUPS.bits_types_h.uu_off64_t; -- _G_config.h:28 uu_state : aliased CUPS.wchar_h.uu_mbstate_t; -- _G_config.h:29 end record; pragma Convention (C_Pass_By_Copy, u_G_fpos64_t); -- _G_config.h:30 -- skipped anonymous struct anon_4 -- These library features are always available in the GNU C library. -- This is defined by <bits/stat.h> if `st_blksize' exists. end CUPS.uG_config_h;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S P R I N T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-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. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package (source print) contains routines for printing the source -- program corresponding to a specified syntax tree. These routines are -- intended for debugging use in the compiler (not as a user level pretty -- print tool). Only information present in the tree is output (e.g. no -- comments are present in the output), and as far as possible we avoid -- making any assumptions about the correctness of the tree, so a bad -- tree may either blow up on a debugging check, or list incorrect source. with Types; use Types; package Sprint is ----------------------- -- Syntax Extensions -- ----------------------- -- When the generated tree is printed, it contains constructs that are not -- pure Ada. For convenience, syntactic extensions to Ada have been defined -- purely for the purposes of this printout (they are not recognized by the -- parser). -- Could use more documentation for all of these ??? -- Allocator new xxx [storage_pool = xxx] -- Cleanup action at end procedure name; -- Convert wi Conversion_OK target?(source) -- Convert wi Float_Truncate target^(source) -- Convert wi Rounded_Result target@(source) -- Divide wi Rounded_Result x @/ y -- Expression with actions do action; .. action; in expr end -- Expression with range check {expression} -- Free statement free expr [storage_pool = xxx] -- Freeze entity with freeze actions freeze entityname [ actions ] -- Freeze generic entity freeze_generic entityname -- Implicit call to run time routine $routine-name -- Implicit exportation $pragma import (...) -- Implicit importation $pragma export (...) -- Interpretation interpretation type [, entity] -- Intrinsic calls function-name!(arg, arg, arg) -- Itype declaration [(sub)type declaration without ;] -- Itype reference reference itype -- Label declaration labelname : label -- Multiple concatenation expr && expr && expr ... && expr -- Multiply wi Rounded_Result x @* y -- Operator with overflow check {operator} (e.g. {+}) -- Others choice for cleanup when all others -- Pop exception label %pop_xxx_exception_label -- Push exception label %push_xxx_exception_label (label) -- Raise xxx error [xxx_error [when cond]] -- Raise xxx error with msg [xxx_error [when cond], "msg"] -- Rational literal [expression] -- Reference expression'reference -- Shift nodes shift_name!(expr, count) -- Static declaration name : static xxx -- Unchecked conversion target_type!(source_expression) -- Unchecked expression `(expression) -- Validate_Unchecked_Conversion validate unchecked_conversion -- (src-type, target-typ); -- Note: the storage_pool parameters for allocators and the free node are -- omitted if the Storage_Pool field is Empty, indicating use of the -- standard default pool. ----------------- -- Subprograms -- ----------------- procedure Source_Dump; -- This routine is called from the GNAT main program to dump source as -- requested by debug options. The relevant debug options are: -- -ds print source from tree, both original and generated code -- -dg print source from tree, including only the generated code -- -do print source from tree, including only the original code -- -df modify the above to include all units, not just the main unit -- -sz print source from tree for package Standard procedure Sprint_Comma_List (List : List_Id); -- Prints the nodes in a list, with separating commas. If the list is empty -- then no output is generated. procedure Sprint_Paren_Comma_List (List : List_Id); -- Prints the nodes in a list, surrounded by parentheses, and separated by -- commas. If the list is empty, then no output is generated. A blank is -- output before the initial left parenthesis. procedure Sprint_Opt_Paren_Comma_List (List : List_Id); -- Same as normal Sprint_Paren_Comma_List procedure, except that an extra -- blank is output if List is non-empty, and nothing at all is printed it -- the argument is No_List. procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False); -- Prints the nodes in a list with no separating characters. This is used -- in the case of lists of items which are printed on separate lines using -- the current indentation amount. New_Lines controls the generation of -- New_Line calls. If False, no New_Line calls are generated. If True, -- then New_Line calls are generated as needed to ensure that each list -- item starts at the beginning of a line. procedure Sprint_Opt_Node_List (List : List_Id); -- Like Sprint_Node_List, but prints nothing if List = No_List procedure Sprint_Indented_List (List : List_Id); -- Like Sprint_Line_List, except that the indentation level is increased -- before outputting the list of items, and then decremented (back to its -- original level) before returning to the caller. procedure Sprint_Node (Node : Node_Id); -- Prints a single node. No new lines are output, except as required for -- splitting lines that are too long to fit on a single physical line. -- No output is generated at all if Node is Empty. No trailing or leading -- blank characters are generated. procedure Sprint_Opt_Node (Node : Node_Id); -- Same as normal Sprint_Node procedure, except that one leading blank is -- output before the node if it is non-empty. procedure pg (Arg : Union_Id); pragma Export (Ada, pg); -- Print generated source for argument N (like -gnatdg output). Intended -- only for use from gdb for debugging purposes. Currently, Arg may be a -- List_Id or a Node_Id (anything else outputs a blank line). procedure po (Arg : Union_Id); pragma Export (Ada, po); -- Like pg, but prints original source for the argument (like -gnatdo -- output). Intended only for use from gdb for debugging purposes. In -- the list case, an end of line is output to separate list elements. procedure ps (Arg : Union_Id); pragma Export (Ada, ps); -- Like pg, but prints generated and original source for the argument (like -- -gnatds output). Intended only for use from gdb for debugging purposes. -- In the list case, an end of line is output to separate list elements. end Sprint;
------------------------------------------------------------------------------ -- -- -- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ C L O C K -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved -- -- -- -- GNARL 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. GNARL is distributed in the hope that it will be use- -- -- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- -- -- eral Library Public License for more details. You should have received -- -- a copy of the GNU Library General Public License along with GNARL; see -- -- file COPYING.LIB. If not, write to the Free Software Foundation, 675 -- -- Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package interfaces with the Ada RTS and defines the low-level -- timer operations. package System.Task_Clock is type Stimespec is private; Stimespec_First : constant Stimespec; Stimespec_Last : constant Stimespec; Stimespec_Zero : constant Stimespec; Stimespec_Unit : constant Stimespec; Stimespec_Sec_Unit : constant Stimespec; function Stimespec_Seconds (TV : Stimespec) return Integer; function Stimespec_NSeconds (TV : Stimespec) return Integer; function Time_Of (S, NS : Integer) return Stimespec; function Stimespec_To_Duration (TV : Stimespec) return Duration; function Duration_To_Stimespec (Time : Duration) return Stimespec; function "-" (TV : Stimespec) return Stimespec; function "+" (LTV, RTV : Stimespec) return Stimespec; function "-" (LTV, RTV : Stimespec) return Stimespec; function "*" (TV : Stimespec; N : Integer) return Stimespec; function "/" (TV : Stimespec; N : integer) return Stimespec; function "/" (LTV, RTV : Stimespec) return Integer; function "<" (LTV, RTV : Stimespec) return Boolean; function "<=" (LTV, RTV : Stimespec) return Boolean; function ">" (LTV, RTV : Stimespec) return Boolean; function ">=" (LTV, RTV : Stimespec) return Boolean; private -- Stimespec is represented in 64-bit Integer. It represents seconds and -- nanoseconds together and is symmetric around Zero. -- For example, 1 second and 1 nanosecond is represented as "100000001" subtype Time_Base is Long_Long_Integer range -Long_Long_Integer'Last .. Long_Long_Integer'Last; type Stimespec is record Val : Time_Base; end record; Stimespec_First : constant Stimespec := Stimespec' (Val => -Long_Long_Integer'Last); Stimespec_Last : constant Stimespec := Stimespec' (Val => Long_Long_Integer'Last); Stimespec_Zero : constant Stimespec := Stimespec' (Val => 0); Stimespec_Unit : constant Stimespec := Stimespec' (Val => 1); Stimespec_Sec_Unit : constant Stimespec := Stimespec' (Val => 10#1#E9); end System.Task_Clock;
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Numerics.Generic_Complex_Types; generic with package Complex_Types is new Ada.Numerics.Generic_Complex_Types (<>); package Ada.Text_IO.Complex_IO is use Complex_Types; Default_Fore : Field := 2; Default_Aft : Field := Real'Digits - 1; Default_Exp : Field := 3; procedure Get (File : in File_Type; Item : out Complex; Width : in Field := 0); procedure Get (Item : out Complex; Width : in Field := 0); procedure Put (File : in File_Type; Item : in Complex; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); procedure Put (Item : in Complex; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); procedure Get (From : in String; Item : out Complex; Last : out Positive); procedure Put (To : out String; Item : in Complex; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); end Ada.Text_IO.Complex_IO;
with Ada.Text_IO; use Ada.Text_IO; with AVTAS.LMCP.Types; use AVTAS.LMCP.Types; with UxAS.Comms.Data; use UxAS.Comms.Data; with UxAS.Comms.Transport.Receiver; use UxAS.Comms.Transport.Receiver; with UxAS.Comms.LMCP_Object_Message_Receiver_Pipes; use UxAS.Comms.LMCP_Object_Message_Receiver_Pipes; with UxAS.Comms.Data.LMCP_Messages; use UxAS.Comms.Data.LMCP_Messages; with Avtas.Lmcp.Object; procedure Test_Receiver_Pipes is Receiver : LMCP_Object_Message_Receiver_Pipe; Msg : Any_Lmcp_Message; Success : Boolean; begin Receiver.Initialize_External_Subscription (Entity_Id => 200, Service_Id => 0, External_Socket_Address => "tcp://127.0.0.1:5560", Is_Server => False); Receiver.Add_Lmcp_Object_Subscription_Address (Any_Address_Accepted, Success); if not Success then Put_Line ("Could not add subscription address to Receiver"); return; end if; loop Receiver.Get_Next_Message_Object (Msg); if Msg = null then Put_Line ("Receiver got null msg pointer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); else Put_Line ("LMCP Type Name : " & Msg.Payload.getLmcpTypeName); Put_Line ("Full LMCP Type Name : " & Msg.Payload.getFullLmcpTypeName); Put_Line ("LMCP Type :" & Msg.Payload.getLmcpType'Image); Put_Line ("Series Name : " & Msg.Payload.getSeriesName); Put_Line ("Series Version :" & Msg.Payload.getSeriesVersion'Image); Put_Line ("Payload_Content_Type : " & Msg.Attributes.Payload_Content_Type); Put_Line ("Payload_Descriptor : " & Msg.Attributes.Payload_Descriptor); Put_Line ("Source_Group : " & Msg.Attributes.Source_Group); Put_Line ("Source_Entity_Id : " & Msg.Attributes.Source_Entity_Id); Put_Line ("Source_Service_Id : " & Msg.Attributes.Source_Service_Id); New_Line; end if; end loop; end Test_Receiver_Pipes;
package body agar.gui.widget.combo is package cbinds is function allocate (parent : widget_access_t; flags : flags_t; label : cs.chars_ptr) return combo_access_t; pragma import (c, allocate, "AG_ComboNewS"); procedure size_hint (combo : combo_access_t; text : cs.chars_ptr; items : c.int); pragma import (c, size_hint, "AG_ComboSizeHint"); procedure size_hint_pixels (combo : combo_access_t; width : c.int; height : c.int); pragma import (c, size_hint_pixels, "AG_ComboSizeHintPixels"); procedure select_text (combo : combo_access_t; text : cs.chars_ptr); pragma import (c, select_text, "AG_ComboSelectText"); end cbinds; -- function allocate (parent : widget_access_t; flags : flags_t; label : string) return combo_access_t is ca_text : aliased c.char_array := c.to_c (label); begin return cbinds.allocate (parent => parent, flags => flags, label => cs.to_chars_ptr (ca_text'unchecked_access)); end allocate; procedure size_hint (combo : combo_access_t; text : string; items : integer) is ca_text : aliased c.char_array := c.to_c (text); begin cbinds.size_hint (combo => combo, text => cs.to_chars_ptr (ca_text'unchecked_access), items => c.int (items)); end size_hint; procedure size_hint_pixels (combo : combo_access_t; width : positive; height : positive) is begin cbinds.size_hint_pixels (combo => combo, width => c.int (width), height => c.int (height)); end size_hint_pixels; procedure select_text (combo : combo_access_t; text : string) is ca_text : aliased c.char_array := c.to_c (text); begin cbinds.select_text (combo => combo, text => cs.to_chars_ptr (ca_text'unchecked_access)); end select_text; end agar.gui.widget.combo;
-- { dg-do compile } package body Discr46 is function F (Id : Enum) return Integer is Node : Integer := 0; begin if A (Id).R.D = True then Node := A (Id).R.T; end if; return Node; end; end Discr46;
package FLTK.Widgets.Valuators.Sliders is type Slider is new Valuator with private; type Slider_Reference (Data : not null access Slider'Class) is limited null record with Implicit_Dereference => Data; type Slider_Kind is (Vertical_Kind, Horizontal_Kind, Vert_Fill_Kind, Hor_Fill_Kind, Vert_Nice_Kind, Hor_Nice_Kind); package Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Slider; end Forge; function Get_Slider_Type (This : in Slider) return Slider_Kind; procedure Set_Bounds (This : in out Slider; Min, Max : in Long_Float); function Get_Box (This : in Slider) return Box_Kind; procedure Set_Box (This : in out Slider; To : in Box_Kind); function Get_Slide_Size (This : in Slider) return Float; procedure Set_Slide_Size (This : in out Slider; To : in Float); procedure Set_Scrollvalue (This : in out Slider; Pos_First_Line : in Natural; Lines_In_Window : in Natural; First_Line_Num : in Natural; Total_Lines : in Natural); procedure Draw (This : in out Slider); function Handle (This : in out Slider; Event : in Event_Kind) return Event_Outcome; package Extra is procedure Set_Slider_Type (This : in out Slider; To : in Slider_Kind); end Extra; private type Slider is new Valuator with null record; overriding procedure Finalize (This : in out Slider); pragma Inline (Get_Slider_Type); pragma Inline (Set_Bounds); pragma Inline (Get_Box); pragma Inline (Set_Box); pragma Inline (Get_Slide_Size); pragma Inline (Set_Slide_Size); pragma Inline (Set_Scrollvalue); pragma Inline (Draw); pragma Inline (Handle); end FLTK.Widgets.Valuators.Sliders;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- O S I N T - B -- -- -- -- S p e c -- -- -- -- Copyright (C) 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, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the low level, operating system routines used only -- in the GNAT binder for command line processing and file input output. package Osint.B is procedure Record_Time_From_Last_Bind; -- Trigger the computing of the time from the last bind of the same -- program. function More_Lib_Files return Boolean; -- Indicates whether more library information files remain to be processed. -- Returns False right away if no source files, or if all source files -- have been processed. function Next_Main_Lib_File return File_Name_Type; -- This function returns the name of the next library info file specified -- on the command line. It is an error to call Next_Main_Lib_File if no -- more library information files exist (i.e. Next_Main_Lib_File may be -- called only if a previous call to More_Lib_Files returned True). This -- name is the simple name, excluding any directory information. function Time_From_Last_Bind return Nat; -- This function give an approximate number of minute from the last bind. -- It bases its computation on file stamp and therefore does gibe not -- any meaningful result before the new output binder file is written. -- So it returns Nat'last if: -- -- - it is the first bind of this specific program -- - Record_Time_From_Last_Bind was not Called first -- - Close_Binder_Output was not called first -- -- otherwise it returns the number of minutes from the last bind. The -- computation does not try to be completely accurate and in particular -- does not take leap years into account. ------------------- -- Binder Output -- ------------------- -- These routines are used by the binder to generate the C source file -- containing the binder output. The format of this file is described -- in the package Bindfmt. procedure Create_Binder_Output (Output_File_Name : String; Typ : Character; Bfile : out Name_Id); -- Creates the binder output file. Typ is one of -- -- 'c' create output file for case of generating C -- 'b' create body file for case of generating Ada -- 's' create spec file for case of generating Ada -- -- If Output_File_Name is null, then a default name is used based on -- the name of the most recently accessed main source file name. If -- Output_File_Name is non-null then it is the full path name of the -- file to be output (in the case of Ada, it must have an extension -- of adb, and the spec file is created by changing the last character -- from b to s. On return, Bfile also contains the Name_Id for the -- generated file name. procedure Write_Binder_Info (Info : String); -- Writes the contents of the referenced string to the binder output file -- created by a previous call to Create_Binder_Output. Info represents a -- single line in the file, but does not contain any line termination -- characters. The implementation of Write_Binder_Info is responsible -- for adding necessary end of line and end of file control characters -- as required by the operating system. procedure Close_Binder_Output; -- Closes the file created by Create_Binder_Output, flushing any -- buffers etc from writes by Write_Binder_Info. end Osint.B;
-------------------------------------------------------------------------------------- -- -- Copyright (c) 2016 Reinert Korsnes -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. -- -- NB: this is the MIT License, as found 2016-09-27 on the site -- http://www.opensource.org/licenses/mit-license.php -------------------------------------------------------------------------------------- -- Change log: -- -------------------------------------------------------------------------------------- with Ada.Characters.Latin_1; package split_string is command_white_space1 : constant String := " ,|" & Ada.Characters.Latin_1.HT; -- command_single1 : constant String := "&"; function number_of_words (fs : String; ws : String := command_white_space1) return Natural; function word (fs : in String; word_number : Natural; ws : String := command_white_space1) return String; function last_word (fs : String; ws : String := command_white_space1) return String; function first_word (fs : String; ws : String := command_white_space1) return String; function collect1 (fs : String; from_word_number : Natural; ws : String := command_white_space1) return String; function remove_comment1 (fs : String; cc : String := "#") return String; function expand1 (fs : String; singles : String) return String; end split_string;
-------------------------------------------------------------------------------- -- -- -- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU Lesser General Public -- -- License as published by the Free Software Foundation; either -- -- version 2.1 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Lesser General Public License for more details. -- -- -- -- You should have received a copy of the GNU Lesser General Public -- -- License along with this library; if not, write to the Free Software -- -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- -------------------------------------------------------------------------------- -- $Author$ -- $Date$ -- $Revision$ with Kernel; use Kernel; with Interfaces.C; use Interfaces.C; with Reporter; with RASCAL.Memory; use RASCAL.Memory; with RASCAL.Utility; use RASCAL.Utility; with RASCAL.OS; package body RASCAL.Mode is OS_ReadModeVariable : constant := 16#35#; -- function Get_X_Resolution (Unit : Mode_Unit_Type := Pixel) return Integer is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := -1; Register.R(1) := 11; Error := Kernel.SWI (OS_ReadModeVariable,register'Access,register'Access); if Error = null then if Unit = OSUnits then return (Integer(Register.R(2))+1) * (2**Get_X_Eig_Factor); else return Integer(Register.R(2))+1; end if; end if; raise No_Mode_Variable; end Get_X_Resolution; -- function Get_Y_Resolution (Unit : Mode_Unit_Type := Pixel) return Integer is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := -1; Register.R(1) := 12; Error := Kernel.SWI (OS_ReadModeVariable,register'Access,register'Access); if Error = null then if Unit = OSUnits then return (Integer(Register.R(2))+1) * (2**Get_Y_Eig_Factor); else return Integer(Register.R(2))+1; end if; end if; raise No_Mode_Variable; end Get_Y_Resolution; -- function Get_Y_Eig_Factor return Integer is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := -1; Register.R(1) := 5; Error := Kernel.SWI (OS_ReadModeVariable,register'Access,register'Access); if Error = null then return Integer(Register.R(2)); end if; raise No_Mode_Variable; end Get_Y_Eig_Factor; -- function Get_X_Eig_Factor return Integer is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := -1; Register.R(1) := 4; Error := Kernel.SWI (OS_ReadModeVariable,register'Access,register'Access); if Error = null then return Integer(Register.R(2)); end if; raise No_Mode_Variable; end Get_X_Eig_Factor; -- end RASCAL.Mode;
-- -- 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. -- with root.child; procedure run_gb_01 is package R is new Root(Real => Float); package RC is new R.child; begin null; end run_gb_01;
with openGL.surface_Profile; private with Glx; limited private with openGL.Context; package openGL.Surface -- -- Models an openGL surface. -- is type Item is tagged private; type Items is array (Positive range <>) of aliased Item; type View is access all Item'Class; type Views is array (Positive range <>) of View; procedure define (Self : in out Item; Profile : in surface_Profile.item'Class; Window_Id : in Natural); -- Operations -- procedure swap_Buffers (Self : in Item); private type Item is tagged record glx_Surface : glx.Drawable; Context : access openGL.Context.item'Class; end record; end openGL.Surface;
with Ada.Text_IO; with Ada.Strings; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body CSV is function open(path: in String; separator: in Character := ',') return Reader is begin return result: Reader do Ada.Text_IO.Open(File => result.handle, Mode => Ada.Text_IO.In_File, Name => path); if Ada.Text_IO.Is_Open(File => result.handle) then result.nextLine := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line(result.handle)); result.hasMore := Ada.Strings.Unbounded.Length(result.nextLine) > 0; else result.hasMore := False; end if; end return; end open; function hasNext(r: in Reader) return Boolean is begin return r.hasMore; end hasNext; function split(s: in Ada.Strings.Unbounded.Unbounded_String) return MathUtils.Vector is result: MathUtils.Vector; nextIndex: Natural := 1; startIndex: Natural := 1; begin while nextIndex < Ada.Strings.Unbounded.Length(s) loop nextIndex := Ada.Strings.Unbounded.Index(Source => s, Pattern => ",", From => nextIndex + 1); if nextIndex = 0 then declare subs: constant String := Ada.Strings.Unbounded.Slice(Source => s, Low => startIndex, High => Ada.Strings.Unbounded.Length(s)); begin result.Append(Float'Value(subs)); end; exit; end if; declare subs: constant String := Ada.Strings.Unbounded.Slice(Source => s, Low => startIndex, High => nextIndex - 1); begin result.Append(Float'Value(subs)); end; startIndex := nextIndex + 1; end loop; return result; end split; function next(r: in out Reader) return MathUtils.Vector is result: MathUtils.Vector; begin if r.hasMore then result := split(r.nextLine); if Ada.Text_IO.End_Of_Line(File => r.handle) = False then r.nextLine := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line(r.handle)); r.hasMore := Ada.Strings.Unbounded.Length(r.nextLine) > 0; else r.hasMore := False; end if; end if; return result; end next; end CSV;
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- sell copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. with Ada.Unchecked_Conversion; with System; package body DNSCatcher.DNS.Processor.RData.Utils is function Decode_DNS_IPv4_Address (Parsed_RR : Parsed_DNS_Resource_Record) return Unbounded_String is type Raw_IPv4_Components is record A : Unsigned_8; B : Unsigned_8; C : Unsigned_8; D : Unsigned_8; end record; pragma Pack (Raw_IPv4_Components); for Raw_IPv4_Components'Bit_Order use System.High_Order_First; for Raw_IPv4_Components'Scalar_Storage_Order use System.High_Order_First; IPv4_Components : Raw_IPv4_Components; ASCII_IPv4 : Unbounded_String; function To_IPv4_Components is new Ada.Unchecked_Conversion (Source => String, Target => Raw_IPv4_Components); begin IPv4_Components := To_IPv4_Components (To_String (Parsed_RR.RData) (1 .. 4)); ASCII_IPv4 := ASCII_IPv4 & IPv4_Components.A'Image & IPv4_Components.B'Image & IPv4_Components.C'Image & IPv4_Components.D'Image; return ASCII_IPv4; end Decode_DNS_IPv4_Address; end DNSCatcher.DNS.Processor.RData.Utils;
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with GNAT.Strings; package Options is Show_Conflict : aliased Boolean := False; Show_Version : aliased Boolean := False; RP_Flag : aliased Boolean := False; Basis_Flag : aliased Boolean := False; Compress : aliased Boolean := False; Be_Quiet : aliased Boolean := False; Statistics : aliased Boolean := False; Make_Headers : aliased Boolean := False; -- Output makeheaders compompatible No_Line_Nos : aliased Boolean := False; No_Resort : aliased Boolean := False; Show_Help : aliased Boolean := False; Generate_SQL : aliased Boolean := False; Debug_Level : aliased Integer := 0; use GNAT.Strings; Program_Name : aliased String_Access := new String'(""); Input_File : aliased String_Access := new String'("parse.y"); User_Template : aliased String_Access := new String'(""); Output_Dir : aliased String_Access := new String'("."); Placeholder_Dummy : aliased GNAT.Strings.String_Access := null; Language_String : aliased GNAT.Strings.String_Access := new String'("C"); -- C is the default language like in Lemon. -- High level options type Language_Type is (Language_Ada, Language_C); Language : Language_Type := Language_C; -- Not used by C parts. procedure Set_Language; end Options;
------------------------------------------------------------------------------ -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ P R I M I T I V E S .O P E R A T I O N S -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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. GNARL 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 GNARL; 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. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains all the GNULL primitives that interface directly -- with the underlying OS. with System.Parameters; -- used for Size_Type with System.Tasking; -- used for Task_ID with System.OS_Interface; -- used for Thread_Id package System.Task_Primitives.Operations is pragma Elaborate_Body; package ST renames System.Tasking; package OSI renames System.OS_Interface; procedure Initialize (Environment_Task : ST.Task_ID); pragma Inline (Initialize); -- This must be called once, before any other subprograms of this -- package are called. procedure Create_Task (T : ST.Task_ID; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; Succeeded : out Boolean); pragma Inline (Create_Task); -- Create a new low-level task with ST.Task_ID T and place other needed -- information in the ATCB. -- -- A new thread of control is created, with a stack of at least Stack_Size -- storage units, and the procedure Wrapper is called by this new thread -- of control. If Stack_Size = Unspecified_Storage_Size, choose a default -- stack size; this may be effectively "unbounded" on some systems. -- -- The newly created low-level task is associated with the ST.Task_ID T -- such that any subsequent call to Self from within the context of the -- low-level task returns T. -- -- The caller is responsible for ensuring that the storage of the Ada -- task control block object pointed to by T persists for the lifetime -- of the new task. -- -- Succeeded is set to true unless creation of the task failed, -- as it may if there are insufficient resources to create another task. procedure Enter_Task (Self_ID : ST.Task_ID); pragma Inline (Enter_Task); -- Initialize data structures specific to the calling task. -- Self must be the ID of the calling task. -- It must be called (once) by the task immediately after creation, -- while abortion is still deferred. -- The effects of other operations defined below are not defined -- unless the caller has previously called Initialize_Task. procedure Exit_Task; pragma Inline (Exit_Task); -- Destroy the thread of control. -- Self must be the ID of the calling task. -- The effects of further calls to operations defined below -- on the task are undefined thereafter. function New_ATCB (Entry_Num : ST.Task_Entry_Index) return ST.Task_ID; pragma Inline (New_ATCB); -- Allocate a new ATCB with the specified number of entries. procedure Initialize_TCB (Self_ID : ST.Task_ID; Succeeded : out Boolean); pragma Inline (Initialize_TCB); -- Initialize all fields of the TCB procedure Finalize_TCB (T : ST.Task_ID); pragma Inline (Finalize_TCB); -- Finalizes Private_Data of ATCB, and then deallocates it. -- This is also responsible for recovering any storage or other resources -- that were allocated by Create_Task (the one in this package). -- This should only be called from Free_Task. -- After it is called there should be no further -- reference to the ATCB that corresponds to T. procedure Abort_Task (T : ST.Task_ID); pragma Inline (Abort_Task); -- Abort the task specified by T (the target task). This causes -- the target task to asynchronously raise Abort_Signal if -- abort is not deferred, or if it is blocked on an interruptible -- system call. -- -- precondition: -- the calling task is holding T's lock and has abort deferred -- -- postcondition: -- the calling task is holding T's lock and has abort deferred. -- ??? modify GNARL to skip wakeup and always call Abort_Task function Self return ST.Task_ID; pragma Inline (Self); -- Return a pointer to the Ada Task Control Block of the calling task. type Lock_Level is (PO_Level, Global_Task_Level, All_Attrs_Level, All_Tasks_Level, Interrupts_Level, ATCB_Level); -- Type used to describe kind of lock for second form of Initialize_Lock -- call specified below. -- See locking rules in System.Tasking (spec) for more details. procedure Initialize_Lock (Prio : System.Any_Priority; L : access Lock); procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level); pragma Inline (Initialize_Lock); -- Initialize a lock object. -- -- For Lock, Prio is the ceiling priority associated with the lock. -- For RTS_Lock, the ceiling is implicitly Priority'Last. -- -- If the underlying system does not support priority ceiling -- locking, the Prio parameter is ignored. -- -- The effect of either initialize operation is undefined unless L -- is a lock object that has not been initialized, or which has been -- finalized since it was last initialized. -- -- The effects of the other operations on lock objects -- are undefined unless the lock object has been initialized -- and has not since been finalized. -- -- Initialization of the per-task lock is implicit in Create_Task. -- -- These operations raise Storage_Error if a lack of storage is detected. procedure Finalize_Lock (L : access Lock); procedure Finalize_Lock (L : access RTS_Lock); pragma Inline (Finalize_Lock); -- Finalize a lock object, freeing any resources allocated by the -- corresponding Initialize_Lock operation. procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean); procedure Write_Lock (L : access RTS_Lock); procedure Write_Lock (T : ST.Task_ID); pragma Inline (Write_Lock); -- Lock a lock object for write access. After this operation returns, -- the calling task holds write permission for the lock object. No other -- Write_Lock or Read_Lock operation on the same lock object will return -- until this task executes an Unlock operation on the same object. The -- effect is undefined if the calling task already holds read or write -- permission for the lock object L. -- -- For the operation on Lock, Ceiling_Violation is set to true iff the -- operation failed, which will happen if there is a priority ceiling -- violation. -- -- For the operation on ST.Task_ID, the lock is the special lock object -- associated with that task's ATCB. This lock has effective ceiling -- priority high enough that it is safe to call by a task with any -- priority in the range System.Priority. It is implicitly initialized -- by task creation. The effect is undefined if the calling task already -- holds T's lock, or has interrupt-level priority. Finalization of the -- per-task lock is implicit in Exit_Task. procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean); pragma Inline (Read_Lock); -- Lock a lock object for read access. After this operation returns, -- the calling task has non-exclusive read permission for the logical -- resources that are protected by the lock. No other Write_Lock operation -- on the same object will return until this task and any other tasks with -- read permission for this lock have executed Unlock operation(s) on the -- lock object. A Read_Lock for a lock object may return immediately while -- there are tasks holding read permission, provided there are no tasks -- holding write permission for the object. The effect is undefined if -- the calling task already holds read or write permission for L. -- -- Alternatively: An implementation may treat Read_Lock identically to -- Write_Lock. This simplifies the implementation, but reduces the level -- of concurrency that can be achieved. -- -- Note that Read_Lock is not defined for RT_Lock and ST.Task_ID. -- That is because (1) so far Read_Lock has always been implemented -- the same as Write_Lock, (2) most lock usage inside the RTS involves -- potential write access, and (3) implementations of priority ceiling -- locking that make a reader-writer distinction have higher overhead. procedure Unlock (L : access Lock); procedure Unlock (L : access RTS_Lock); procedure Unlock (T : ST.Task_ID); pragma Inline (Unlock); -- Unlock a locked lock object. -- -- The effect is undefined unless the calling task holds read or write -- permission for the lock L, and L is the lock object most recently -- locked by the calling task for which the calling task still holds -- read or write permission. (That is, matching pairs of Lock and Unlock -- operations on each lock object must be properly nested.) -- Note that Write_Lock for RTS_Lock does not have an out-parameter. -- RTS_Locks are used in situations where we have not made provision -- for recovery from ceiling violations. We do not expect them to -- occur inside the runtime system, because all RTS locks have ceiling -- Priority'Last. -- There is one way there can be a ceiling violation. -- That is if the runtime system is called from a task that is -- executing in the Interrupt_Priority range. -- It is not clear what to do about ceiling violations due -- to RTS calls done at interrupt priority. In general, it -- is not acceptable to give all RTS locks interrupt priority, -- since that whould give terrible performance on systems where -- this has the effect of masking hardware interrupts, though we -- could get away with allowing Interrupt_Priority'last where we -- are layered on an OS that does not allow us to mask interrupts. -- Ideally, we would like to raise Program_Error back at the -- original point of the RTS call, but this would require a lot of -- detailed analysis and recoding, with almost certain performance -- penalties. -- For POSIX systems, we considered just skipping setting a -- priority ceiling on RTS locks. This would mean there is no -- ceiling violation, but we would end up with priority inversions -- inside the runtime system, resulting in failure to satisfy the -- Ada priority rules, and possible missed validation tests. -- This could be compensated-for by explicit priority-change calls -- to raise the caller to Priority'Last whenever it first enters -- the runtime system, but the expected overhead seems high, though -- it might be lower than using locks with ceilings if the underlying -- implementation of ceiling locks is an inefficient one. -- This issue should be reconsidered whenever we get around to -- checking for calls to potentially blocking operations from -- within protected operations. If we check for such calls and -- catch them on entry to the OS, it may be that we can eliminate -- the possibility of ceiling violations inside the RTS. For this -- to work, we would have to forbid explicitly setting the priority -- of a task to anything in the Interrupt_Priority range, at least. -- We would also have to check that there are no RTS-lock operations -- done inside any operations that are not treated as potentially -- blocking. -- The latter approach seems to be the best, i.e. to check on entry -- to RTS calls that may need to use locks that the priority is not -- in the interrupt range. If there are RTS operations that NEED to -- be called from interrupt handlers, those few RTS locks should then -- be converted to PO-type locks, with ceiling Interrupt_Priority'Last. -- For now, we will just shut down the system if there is a -- ceiling violation. procedure Yield (Do_Yield : Boolean := True); pragma Inline (Yield); -- Yield the processor. Add the calling task to the tail of the -- ready queue for its active_priority. -- The Do_Yield argument is only used in some very rare cases very -- a yield should have an effect on a specific target and not on regular -- ones. procedure Set_Priority (T : ST.Task_ID; Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False); pragma Inline (Set_Priority); -- Set the priority of the task specified by T to T.Current_Priority. -- The priority set is what would correspond to the Ada concept of -- "base priority" in the terms of the lower layer system, but -- the operation may be used by the upper layer to implement -- changes in "active priority" that are not due to lock effects. -- The effect should be consistent with the Ada Reference Manual. -- In particular, when a task lowers its priority due to the loss of -- inherited priority, it goes at the head of the queue for its new -- priority (RM D.2.2 par 9). -- Loss_Of_Inheritance helps the underlying implementation to do it -- right when the OS doesn't. function Get_Priority (T : ST.Task_ID) return System.Any_Priority; pragma Inline (Get_Priority); -- Returns the priority last set by Set_Priority for this task. function Monotonic_Clock return Duration; pragma Inline (Monotonic_Clock); -- Returns "absolute" time, represented as an offset -- relative to "the Epoch", which is Jan 1, 1970. -- This clock implementation is immune to the system's clock changes. function RT_Resolution return Duration; pragma Inline (RT_Resolution); -- Returns the resolution of the underlying clock used to implement -- RT_Clock. ------------------ -- Extensions -- ------------------ -- Whoever calls either of the Sleep routines is responsible -- for checking for pending aborts before the call. -- Pending priority changes are handled internally. procedure Sleep (Self_ID : ST.Task_ID; Reason : System.Tasking.Task_States); pragma Inline (Sleep); -- Wait until the current task, T, is signaled to wake up. -- -- precondition: -- The calling task is holding its own ATCB lock -- and has abort deferred -- -- postcondition: -- The calling task is holding its own ATCB lock -- and has abort deferred. -- The effect is to atomically unlock T's lock and wait, so that another -- task that is able to lock T's lock can be assured that the wait has -- actually commenced, and that a Wakeup operation will cause the waiting -- task to become ready for execution once again. When Sleep returns, -- the waiting task will again hold its own ATCB lock. The waiting task -- may become ready for execution at any time (that is, spurious wakeups -- are permitted), but it will definitely become ready for execution when -- a Wakeup operation is performed for the same task. procedure Timed_Sleep (Self_ID : ST.Task_ID; Time : Duration; Mode : ST.Delay_Modes; Reason : System.Tasking.Task_States; Timedout : out Boolean; Yielded : out Boolean); -- Combination of Sleep (above) and Timed_Delay procedure Timed_Delay (Self_ID : ST.Task_ID; Time : Duration; Mode : ST.Delay_Modes); -- Implements the semantics of the delay statement. It is assumed that -- the caller is not abort-deferred and does not hold any locks. procedure Wakeup (T : ST.Task_ID; Reason : System.Tasking.Task_States); pragma Inline (Wakeup); -- Wake up task T if it is waiting on a Sleep call (of ordinary -- or timed variety), making it ready for execution once again. -- If the task T is not waiting on a Sleep, the operation has no effect. function Environment_Task return ST.Task_ID; pragma Inline (Environment_Task); -- returns the task ID of the environment task -- Consider putting this into a variable visible directly -- by the rest of the runtime system. ??? function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id; -- returns the thread id of the specified task. -------------------- -- Stack Checking -- -------------------- -- Stack checking in GNAT is done using the concept of stack probes. A -- stack probe is an operation that will generate a storage error if -- an insufficient amount of stack space remains in the current task. -- The exact mechanism for a stack probe is target dependent. Typical -- possibilities are to use a load from a non-existent page, a store -- to a read-only page, or a comparison with some stack limit constant. -- Where possible we prefer to use a trap on a bad page access, since -- this has less overhead. The generation of stack probes is either -- automatic if the ABI requires it (as on for example DEC Unix), or -- is controlled by the gcc parameter -fstack-check. -- When we are using bad-page accesses, we need a bad page, called a -- guard page, at the end of each task stack. On some systems, this -- is provided automatically, but on other systems, we need to create -- the guard page ourselves, and the procedure Stack_Guard is provided -- for this purpose. procedure Stack_Guard (T : ST.Task_ID; On : Boolean); -- Ensure guard page is set if one is needed and the underlying thread -- system does not provide it. The procedure is as follows: -- -- 1. When we create a task adjust its size so a guard page can -- safely be set at the bottom of the stack -- -- 2. When the thread is created (and its stack allocated by the -- underlying thread system), get the stack base (and size, depending -- how the stack is growing), and create the guard page taking care of -- page boundaries issues. -- -- 3. When the task is destroyed, remove the guard page. -- -- If On is true then protect the stack bottom (i.e make it read only) -- else unprotect it (i.e. On is True for the call when creating a task, -- and False when a task is destroyed). -- -- The call to Stack_Guard has no effect if guard pages are not used on -- the target, or if guard pages are automatically provided by the system. ----------------------------------------- -- Runtime System Debugging Interfaces -- ----------------------------------------- -- These interfaces have been added to assist in debugging the -- tasking runtime system. function Check_Exit (Self_ID : ST.Task_ID) return Boolean; pragma Inline (Check_Exit); -- Check that the current task is holding only Global_Task_Lock. function Check_No_Locks (Self_ID : ST.Task_ID) return Boolean; pragma Inline (Check_No_Locks); -- Check that current task is holding no locks. function Suspend_Task (T : ST.Task_ID; Thread_Self : OSI.Thread_Id) return Boolean; -- Suspend a specific task when the underlying thread library provides -- such functionality, unless the thread associated with T is Thread_Self. -- Such functionality is needed by gdb on some targets (e.g VxWorks) -- Return True is the operation is successful function Resume_Task (T : ST.Task_ID; Thread_Self : OSI.Thread_Id) return Boolean; -- Resume a specific task when the underlying thread library provides -- such functionality, unless the thread associated with T is Thread_Self. -- Such functionality is needed by gdb on some targets (e.g VxWorks) -- Return True is the operation is successful procedure Lock_All_Tasks_List; procedure Unlock_All_Tasks_List; -- Lock/Unlock the All_Tasks_L lock which protects -- System.Initialization.All_Tasks_List and Known_Tasks -- ??? These routines were previousely in System.Tasking.Initialization -- but were moved here to avoid dependency problems. That would be -- nice to look at it some day and put it back in Initialization. end System.Task_Primitives.Operations;
-- -- ABench2020 Benchmark Suite -- -- Softmax Program -- -- Licensed under the MIT License. See LICENSE file in the ABench root -- directory for license information. -- -- Uncomment the lines below to print the result. -- with Ada.Text_IO; use Ada.Text_IO; procedure Softmax is type Vector is array (1..15) of Integer; Result : array (1..15) of Float; Exp : constant := 2.71828; procedure Calculate_Softmax (Sample: Vector) is Denonminator : Float := 0.0; begin for I in Sample'Range loop Denonminator := Denonminator + (Exp ** Sample (I)); end loop; for I in Sample'Range loop Result (I) := (Exp ** Sample (I)) / Denonminator; end loop; end; Sample : Vector := (1, 5, 3, 7, 4, 10, 4, 9, 4, 1, 9, 12, 3, 8, 5); begin loop Calculate_Softmax (Sample); Sample := (1, 5, 3, 7, 4, 10, 4, 9, 4, 1, 9, 12, 3, 8, 5); end loop; -- Uncomment the lines below to print the result. -- for I in Sample'Range loop -- Put (Float'Image (Result (I)) & " "); -- end loop; end;
----------------------------------------------------------------------- -- util-executors -- Execute work that is queued -- Copyright (C) 2019 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; private with Util.Concurrent.Fifos; -- == Executors == -- The `Util.Executors` generic package defines a queue of work that will be executed -- by one or several tasks. The `Work_Type` describes the type of the work and the -- `Execute` procedure will be called by the task to execute the work. After instantiation -- of the package, an instance of the `Executor_Manager` is created with a number of desired -- tasks. The tasks are then started by calling the `Start` procedure. -- -- A work object is added to the executor's queue by using the `Execute` procedure. -- The work object is added in a concurrent fifo queue. One of the task managed by the -- executor manager will pick the work object and run it. -- generic type Work_Type is private; with procedure Execute (Work : in out Work_Type); with procedure Error (Work : in out Work_Type; Err : in Ada.Exceptions.Exception_Occurrence) is null; Default_Queue_Size : Positive := 32; package Util.Executors is use Ada.Finalization; type Executor_Manager (Count : Positive) is limited new Limited_Controlled with private; type Executor_Manager_Access is access all Executor_Manager'Class; overriding procedure Initialize (Manager : in out Executor_Manager); -- Execute the work through the executor. procedure Execute (Manager : in out Executor_Manager; Work : in Work_Type); -- Start the executor tasks. procedure Start (Manager : in out Executor_Manager; Autostop : in Boolean := False); -- Stop the tasks and wait for their completion. procedure Stop (Manager : in out Executor_Manager); -- Set the work queue size. procedure Set_Queue_Size (Manager : in out Executor_Manager; Capacity : in Positive); -- Wait for the pending work to be executed by the executor tasks. procedure Wait (Manager : in out Executor_Manager); -- Get the number of elements in the queue. function Get_Count (Manager : in Executor_Manager) return Natural; -- Stop and release the executor. overriding procedure Finalize (Manager : in out Executor_Manager); private type Work_Info is record Work : Work_Type; Done : Boolean := False; end record; package Work_Queue is new Util.Concurrent.Fifos (Element_Type => Work_Info, Default_Size => Default_Queue_Size, Clear_On_Dequeue => True); task type Worker_Task is entry Start (Manager : in Executor_Manager_Access); end Worker_Task; type Worker_Task_Array is array (Positive range <>) of Worker_Task; type Executor_Manager (Count : Positive) is limited new Limited_Controlled with record Self : Executor_Manager_Access; Autostop : Boolean := False; Queue : Work_Queue.Fifo; Workers : Worker_Task_Array (1 .. Count); end record; end Util.Executors;
-- Ada_GUI implementation based on Gnoga. Adapted 2021 -- -- -- GNOGA - The GNU Omnificent GUI for Ada -- -- -- -- G N O G A . G U I . E L E M E N T . F O R M -- -- -- -- S p e c -- -- -- -- -- -- Copyright (C) 2014 David Botton -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- 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/>. -- -- -- -- 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. -- -- -- -- For more information please go to http://www.gnoga.com -- ------------------------------------------------------------------------------ with Ada_GUI.Gnoga.Gui.View; package Ada_GUI.Gnoga.Gui.Element.Form is ------------------------------------------------------------------------- -- Form_Types ------------------------------------------------------------------------- type Form_Type is new Gnoga.Gui.View.View_Base_Type with private; type Form_Access is access all Form_Type; type Pointer_To_Form_Class is access all Form_Type'Class; ------------------------------------------------------------------------- -- Form_Type - Creation Methods ------------------------------------------------------------------------- type Form_Method_Type is (Get, Post); procedure Create (Form : in out Form_Type; Parent : in out Gnoga.Gui.Base_Type'Class; Action : in String := ""; Method : in Form_Method_Type := Get; Target : in String := "_self"; ID : in String := ""); -- Create a Form element. This is used to group and set the action -- taken on a submit of the form. -- -- In Gnoga forms in general should be processed by handling the -- On_Submit event and accessing each element's value directly. -- However it is possible to set an action (URL for form to submit to) -- and that page can process the results. For submitted forms access -- using Gnoga.Gui.Window.Window_Type.Form_Parameters. ------------------------------------------------------------------------- -- From_Type - Properties ------------------------------------------------------------------------- procedure Action (Form : in out Form_Type; Value : in String); function Action (Form : Form_Type) return String; -- URL to submit form to using Method procedure Method (Form : in out Form_Type; Value : in Form_Method_Type); function Method (Form : Form_Type) return Form_Method_Type; type Encoding_Type is (URL_Encode, Multi_Part, Text); -- application/x-www-form-urlencoded / multipart/form-data / text/plain -- The default for forms is URL_Encode procedure Encoding (Form : in out Form_Type; Value : in Encoding_Type); function Encoding (Form : Form_Type) return Encoding_Type; -- Encoding affects how the form is send via the POST method only. procedure Autocomplete (Form : in out Form_Type; Value : in Boolean := True); function Autocomplete (Form : Form_Type) return Boolean; procedure Validate_On_Submit (Form : in out Form_Type; Value : in Boolean := True); function Validate_On_Submit (Form : Form_Type) return Boolean; function Number_Of_Elements_In_Form (Form : Form_Type) return Integer; procedure Target (Form : in out Form_Type; Value : in String); function Target (Form : Form_Type) return String; -- Target of link, name (set as attribute on a frame or windows) of -- a frame or: -- _blank = new window -- _top = top most frame (full browser window) -- _parent = parent frame or window -- _self = current frame or window ------------------------------------------------------------------------- -- Form_Type - Methods ------------------------------------------------------------------------- procedure Submit (Form : in out Form_Type); -- Submit form procedure Reset (Form : in out Form_Type); -- Reset form to original defaults ------------------------------------------------------------------------- -- Form_Element_Types ------------------------------------------------------------------------- -- Parent type for all form elements type Form_Element_Type is new Gnoga.Gui.Element.Element_Type with private; type Form_Element_Access is access all Form_Element_Type; type Pointer_To_Form_Element_Class is access all Form_Element_Type'Class; type Data_List_Type is new Gnoga.Gui.View.View_Base_Type with private; -- Forward declaration of Data_List_Type used for drop down / -- autocomplete. ------------------------------------------------------------------------- -- Form_Element_Type - Creation Methods ------------------------------------------------------------------------- procedure Create_Element (Element : in out Form_Element_Type; Form : in out Form_Type'Class; Input_Type : in String; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Create a form element of Input_Type. Setting Name on form element -- is only important if the form will be submitted via a GET or POST. -- Value is the initial value for the element. -- -- Valid HTML5 Input_Types are: -- button, checkbox, color, date, datetime, datetime-local, email -- file, hidden, image, month, number, password, radio, range -- reset, search, submit, tel, text, time, url, week ------------------------------------------------------------------------- -- Form_Element_Type - Properties ------------------------------------------------------------------------- procedure Autocomplete (Element : in out Form_Element_Type; Value : in Boolean := True); function Autocomplete (Element : Form_Element_Type) return Boolean; procedure Autofocus (Element : in out Form_Element_Type; Value : in Boolean := True); function Autofocus (Element : Form_Element_Type) return Boolean; procedure Data_List (Element : in out Form_Element_Type; Data_List : in out Data_List_Type'Class); -- Set the data list for Autocomplete procedure Disabled (Element : in out Form_Element_Type; Value : in Boolean := True); function Disabled (Element : Form_Element_Type) return Boolean; procedure Read_Only (Element : in out Form_Element_Type; Value : in Boolean := True); function Read_Only (Element : Form_Element_Type) return Boolean; procedure Validate_On_Submit (Element : in out Form_Element_Type; Value : in Boolean := True); function Validate_On_Submit (Element : Form_Element_Type) return Boolean; procedure Name (Element : in out Form_Element_Type; Value : in String); function Name (Element : Form_Element_Type) return String; -- Form element name, name is not the id of the element but rather how -- the data returned from the element will be named in the submit to the -- server. For example if Name is My_Field a GET request could look like -- http://localhost:8080?My_Field=xxxx procedure Default_Value (Element : in out Form_Element_Type; Value : in String); procedure Default_Value (Element : in out Form_Element_Type; Value : in Integer); function Default_Value (Element : Form_Element_Type) return String; function Default_Value (Element : Form_Element_Type) return Integer; -- If the form is reset the value will be set to default value -- If Value is set at time of creation it also sets it as the Default_Value procedure Value (Element : in out Form_Element_Type; Value : in String); procedure Value (Element : in out Form_Element_Type; Value : in Integer); function Value (Element : Form_Element_Type) return String; function Value (Element : Form_Element_Type) return Integer; -- Form element values are not accessible through the Text property but -- instead through the value property. -- Text oriented properties procedure Place_Holder (Element : in out Form_Element_Type; Value : in String); function Place_Holder (Element : Form_Element_Type) return String; procedure Pattern (Element : in out Form_Element_Type; Value : in String); function Pattern (Element : Form_Element_Type) return String; -- Form validation pattern. Validate_On_Submit fields with input -- will validate against their Pattern if set on submit. -- Pattern is included in Form_Element_Type since in cases where a specific -- input type is not supported like (date, week, etc.) Pattern can be set -- to ensure the expected results. This works since Input type will fall -- back to a text input. procedure Required (Element : in out Form_Element_Type; Value : in Boolean := True); function Required (Element : Form_Element_Type) return Boolean; -- If Required is true on submit Element must be set/contain a value -- Range oriented inputs procedure Minimum (Element : in out Form_Element_Type; Value : in String); procedure Minimum (Element : in out Form_Element_Type; Value : in Integer); function Minimum (Element : Form_Element_Type) return String; function Minimum (Element : Form_Element_Type) return Integer; procedure Maximum (Element : in out Form_Element_Type; Value : in String); procedure Maximum (Element : in out Form_Element_Type; Value : in Integer); function Maximum (Element : Form_Element_Type) return String; function Maximum (Element : Form_Element_Type) return Integer; procedure Step (Element : in out Form_Element_Type; Value : in String); procedure Step (Element : in out Form_Element_Type; Value : in Integer); function Step (Element : Form_Element_Type) return String; function Step (Element : Form_Element_Type) return Integer; ------------------------------------------------------------------------- -- Form_Element_Type - Methods ------------------------------------------------------------------------- procedure Select_Text (Element : in out Form_Element_Type); -- Selects and highlights the context of Element ------------------------------------------------------------------------- -- Data_List_Types ------------------------------------------------------------------------- type Data_List_Access is access all Data_List_Type; type Pointer_To_Data_List_Class is access all Data_List_Type'Class; ------------------------------------------------------------------------- -- Data_List_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (List : in out Data_List_Type; Parent : in out Gnoga.Gui.Base_Type'Class; ID : in String := ""); ------------------------------------------------------------------------- -- Data_List_Type - Methods ------------------------------------------------------------------------- procedure Add_Option (List : in out Data_List_Type; Value : in String); -- Add option to Data_List ------------------------------------------------------------------------- -- Text_Area_Types ------------------------------------------------------------------------- type Text_Area_Type is new Form_Element_Type with private; type Text_Area_Access is access all Text_Area_Type; type Pointer_To_Text_Area_Class is access all Text_Area_Type'Class; ------------------------------------------------------------------------- -- Text_Area_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Text_Area_Type; Form : in out Form_Type'Class; Columns : in Natural := 20; Rows : in Natural := 2; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Text_Area_Type - Properties ------------------------------------------------------------------------- procedure Word_Wrap (Element : in out Text_Area_Type; Value : in Boolean := True); function Word_Wrap (Element : Text_Area_Type) return Boolean; procedure Columns (Element : in out Text_Area_Type; Value : in Integer); function Columns (Element : Text_Area_Type) return Integer; procedure Rows (Element : in out Text_Area_Type; Value : in Integer); function Rows (Element : Text_Area_Type) return Integer; ------------------------------------------------------------------------- -- Hidden_Types ------------------------------------------------------------------------- type Hidden_Type is new Form_Element_Type with private; type Hidden_Access is access all Hidden_Type; type Pointer_To_Hidden_Class is access all Hidden_Type'Class; ------------------------------------------------------------------------- -- Hidden_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Hidden_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Input_Button_Types ------------------------------------------------------------------------- type Input_Button_Type is new Form_Element_Type with private; type Input_Button_Access is access all Input_Button_Type; type Pointer_To_Input_Button_Class is access all Input_Button_Type'Class; ------------------------------------------------------------------------- -- Input_Button_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Input_Button_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Submit_Button_Types ------------------------------------------------------------------------- -- An Input Button that On_Click will fire On_Submit type Submit_Button_Type is new Input_Button_Type with private; type Submit_Button_Access is access all Submit_Button_Type; type Pointer_To_Submit_Button_Class is access all Submit_Button_Type'Class; ------------------------------------------------------------------------- -- Submit_Button_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out Submit_Button_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Reset_Button_Types ------------------------------------------------------------------------- -- An Input Button that On_Click will fire On_Reset type Reset_Button_Type is new Input_Button_Type with private; type Reset_Button_Access is access all Reset_Button_Type; type Pointer_To_Reset_Button_Class is access all Reset_Button_Type'Class; ------------------------------------------------------------------------- -- Reset_Button_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out Reset_Button_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Check_Box_Types ------------------------------------------------------------------------- type Check_Box_Type is new Form_Element_Type with private; type Check_Box_Access is access all Check_Box_Type; type Pointer_To_Check_Box_Class is access all Check_Box_Type'Class; ------------------------------------------------------------------------- -- Check_Box_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Check_Box_Type; Form : in out Form_Type'Class; Checked : in Boolean := False; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value will be what is submitted if Checked is true for Name. ------------------------------------------------------------------------- -- Check_Box_Type - Properties ------------------------------------------------------------------------- procedure Checked (Element : in out Check_Box_Type; Value : in Boolean := True); function Checked (Element : Check_Box_Type) return Boolean; procedure Indeterminate (Element : in out Check_Box_Type; Value : in Boolean := True); function Indeterminate (Element : Check_Box_Type) return Boolean; ------------------------------------------------------------------------- -- Radio_Button_Types ------------------------------------------------------------------------- type Radio_Button_Type is new Form_Element_Type with private; type Radio_Button_Access is access all Radio_Button_Type; type Pointer_To_Radio_Button_Class is access all Radio_Button_Type'Class; -- These radio buttons will operate as groups based on having a common -- Name attribute. ------------------------------------------------------------------------- -- Radio_Button_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Radio_Button_Type; Form : in out Form_Type'Class; Checked : in Boolean := False; Value : in String := ""; Name : in String := ""; ID : in String := ""); ---------------------------------------------------------- -- Radio_Button_Type - Properties ------------------------------------------------------------------------- procedure Checked (Element : in out Radio_Button_Type; Value : in Boolean := True); function Checked (Element : Radio_Button_Type) return Boolean; ------------------------------------------------------------------------- -- Input_Image_Types ------------------------------------------------------------------------- type Input_Image_Type is new Form_Element_Type with private; type Input_Image_Access is access all Input_Image_Type; type Pointer_To_Input_Image_Class is access all Input_Image_Type'Class; ------------------------------------------------------------------------- -- Input_Image_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Input_Image_Type; Form : in out Form_Type'Class; Source : in String := ""; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Input_Image_Type - Properties ------------------------------------------------------------------------- procedure Source (Element : in out Input_Image_Type; Value : String); function Source (Element : Input_Image_Type) return String; -- URL source for image ------------------------------------------------------------------------- -- Text_Types ------------------------------------------------------------------------- type Text_Type is new Form_Element_Type with private; type Text_Access is access all Text_Type; type Pointer_To_Text_Class is access all Text_Type'Class; ------------------------------------------------------------------------- -- Text_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Text_Type; Form : in out Form_Type'Class; Size : in Integer := 20; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Text_Type - Properties ------------------------------------------------------------------------- procedure Size (Element : in out Text_Type; Value : Integer); function Size (Element : Text_Type) return Integer; -- Length of visible field in characters procedure Max_Length (Element : in out Text_Type; Value : Integer); function Max_Length (Element : Text_Type) return Integer; -- Maximum length of Value ------------------------------------------------------------------------- -- Email_Types ------------------------------------------------------------------------- type Email_Type is new Text_Type with private; type Email_Access is access all Email_Type; type Pointer_To_Email_Class is access all Email_Type'Class; ------------------------------------------------------------------------- -- Email_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out Email_Type; Form : in out Form_Type'Class; Size : in Integer := 20; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Email_Type - Properties ------------------------------------------------------------------------- procedure Multiple_Emails (Element : in out Email_Type; Value : in Boolean := True); function Multiple_Emails (Element : Email_Type) return Boolean; ------------------------------------------------------------------------- -- Password_Types ------------------------------------------------------------------------- type Password_Type is new Text_Type with private; type Password_Access is access all Password_Type; type Pointer_To_Password_Class is access all Password_Type'Class; ------------------------------------------------------------------------- -- Password_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out Password_Type; Form : in out Form_Type'Class; Size : in Integer := 20; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- URL_Types ------------------------------------------------------------------------- type URL_Type is new Text_Type with private; type URL_Access is access all URL_Type; type Pointer_To_URL_Class is access all URL_Type'Class; ------------------------------------------------------------------------- -- URL_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out URL_Type; Form : in out Form_Type'Class; Size : in Integer := 20; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Search_Types ------------------------------------------------------------------------- type Search_Type is new Text_Type with private; type Search_Access is access all Search_Type; type Pointer_To_Search_Class is access all Search_Type'Class; ------------------------------------------------------------------------- -- Search_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out Search_Type; Form : in out Form_Type'Class; Size : in Integer := 20; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Color_Picker_Types ------------------------------------------------------------------------- type Color_Picker_Type is new Form_Element_Type with private; type Color_Picker_Access is access all Color_Picker_Type; type Pointer_To_Color_Picker_Class is access all Color_Picker_Type'Class; ------------------------------------------------------------------------- -- Color_Picker_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Color_Picker_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); procedure Create (Element : in out Color_Picker_Type; Form : in out Form_Type'Class; Value : in Gnoga.RGBA_Type; Name : in String := ""; ID : in String := ""); procedure Create (Element : in out Color_Picker_Type; Form : in out Form_Type'Class; Value : in Gnoga.Colors.Color_Enumeration; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Color_Picker_Type - Properties ------------------------------------------------------------------------- overriding procedure Color (Element : in out Color_Picker_Type; Value : in String); overriding procedure Color (Element : in out Color_Picker_Type; RGBA : in Gnoga.RGBA_Type); overriding procedure Color (Element : in out Color_Picker_Type; Enum : in Gnoga.Colors.Color_Enumeration); overriding function Color (Element : Color_Picker_Type) return Gnoga.RGBA_Type; ------------------------------------------------------------------------- -- Date_Types ------------------------------------------------------------------------- type Date_Type is new Form_Element_Type with private; type Date_Access is access all Date_Type; type Pointer_To_Date_Class is access all Date_Type'Class; ------------------------------------------------------------------------- -- Date_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Date_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value format yyyy-mm-dd for Date_Type ------------------------------------------------------------------------- -- Time_Types ------------------------------------------------------------------------- type Time_Type is new Form_Element_Type with private; type Time_Access is access all Time_Type; type Pointer_To_Time_Class is access all Time_Type'Class; ------------------------------------------------------------------------- -- Time_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Time_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value format HH:MM no time zone 24hour format ------------------------------------------------------------------------- -- Month_Types ------------------------------------------------------------------------- type Month_Type is new Form_Element_Type with private; type Month_Access is access all Month_Type; type Pointer_To_Month_Class is access all Month_Type'Class; ------------------------------------------------------------------------- -- Month_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Month_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value format yyyy-mm for Month_Type -- Months are 1-12 ------------------------------------------------------------------------- -- Week_Types ------------------------------------------------------------------------- type Week_Type is new Form_Element_Type with private; type Week_Access is access all Week_Type; type Pointer_To_Week_Class is access all Week_Type'Class; ------------------------------------------------------------------------- -- Week_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Week_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value format yyyy-Www for Week_Type -- Date with the year and a W followed by the week number, with no time -- zone. A "week" goes from Monday to Sunday, with week 1 being the week -- containing the first Wednesday of the year, so could start on December -- 30 or even January 2. ------------------------------------------------------------------------- -- Date_Time_Types ------------------------------------------------------------------------- type Date_Time_Type is new Form_Element_Type with private; type Date_Time_Access is access all Date_Time_Type; type Pointer_To_Date_Time_Class is access all Date_Time_Type'Class; ------------------------------------------------------------------------- -- Date_Time_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Date_Time_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value format yyyy-mm-ddTHH:MMZ -- Hour, minute, second, and fraction of a second based on UTC time zone ------------------------------------------------------------------------- -- Date_Time_Local_Types ------------------------------------------------------------------------- type Date_Time_Local_Type is new Form_Element_Type with private; type Date_Time_Local_Access is access all Date_Time_Local_Type; type Pointer_To_Date_Time_Local_Class is access all Date_Time_Local_Type'Class; ------------------------------------------------------------------------- -- Date_Time_Local_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Date_Time_Local_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); -- Value format yyyy-mm-ddTHH:MMZ -- Hour, minute, second, and fraction of a second based on UTC time zone ------------------------------------------------------------------------- -- Number_Types ------------------------------------------------------------------------- type Number_Type is new Form_Element_Type with private; type Number_Access is access all Number_Type; type Pointer_To_Number_Class is access all Number_Type'Class; ------------------------------------------------------------------------- -- Number_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Number_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Range_Types ------------------------------------------------------------------------- type Range_Type is new Number_Type with private; type Range_Access is access all Range_Type; type Pointer_To_Range_Class is access all Range_Type'Class; ------------------------------------------------------------------------- -- Range_Type - Creation Methods ------------------------------------------------------------------------- overriding procedure Create (Element : in out Range_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- Label_Types ------------------------------------------------------------------------- type Label_Type is new Gnoga.Gui.Element.Element_Type with private; type Label_Access is access all Label_Type; type Pointer_To_Label_Class is access all Label_Type'Class; ------------------------------------------------------------------------- -- Label_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Label_Type; Form : in out Form_Type'Class; Label_For : in out Element_Type'Class; Content : in String := ""; Auto_Place : in Boolean := True; ID : in String := ""); -- Creates a Label_For a form element in Form with Content as label. -- If Auto_Place is true, the label element will be moved in the DOM -- to just before Label_For. ------------------------------------------------------------------------- -- Selection_Types ------------------------------------------------------------------------- -- As an alternative to using the Add_Option method you can add -- as children Option_Type and Option_Group_Types. Option_Type -- and Option_Group_Type are added with Item.Create, they can -- be removed using Item.Remove and their order can be changed using -- the standard Element_Type.Place_* methods. type Selection_Type is new Form_Element_Type with private; type Selection_Access is access all Selection_Type; type Pointer_To_Selection_Class is access all Selection_Type'Class; ------------------------------------------------------------------------- -- Selection_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Selection_Type; Form : in out Form_Type'Class; Multiple_Select : in Boolean := False; Visible_Lines : in Positive := 1; Name : in String := ""; ID : in String := ""); -- If Parent is a Window_Type'Class will automatically set itself -- as the View on Parent if Attach is True ------------------------------------------------------------------------- -- Selection_Type - Properties ------------------------------------------------------------------------- procedure Multiple_Select (Element : in out Selection_Type; Value : in Boolean := True); function Multiple_Select (Element : Selection_Type) return Boolean; procedure Visible_Lines (Element : in out Selection_Type; Value : in Positive); function Visible_Lines (Element : Selection_Type) return Positive; function Selected_Index (Element : Selection_Type) return Natural; -- If no item currently selected returns 0, in multiple select boxes -- traverse the options using Selected. overriding function Value (Element : Selection_Type) return String; -- Returns the value of the currently selected item. For multiple select -- boxes get the value based on Index. The Value is the non-displayed -- value of the currently selected item. function Length (Element : Selection_Type) return Natural; -- Number of options in Selection_Type procedure Selected (Element : in out Selection_Type; Index : in Positive; Value : in Boolean := True); function Selected (Element : Selection_Type; Index : Positive) return Boolean; procedure Disabled (Element : in out Selection_Type; Index : in Positive; Value : in Boolean := True); function Disabled (Element : Selection_Type; Index : Positive) return Boolean; procedure Value (Element : in out Selection_Type; Index : in Positive; Value : in String); function Value (Element : Selection_Type; Index : Positive) return String; -- Value is the non-displayed value of the the item at Index. If the form -- is submitted, the value not the "Text" is sent to the form's action -- URL. procedure Text (Element : in out Selection_Type; Index : in Positive; Value : in String); function Text (Element : Selection_Type; Index : Positive) return String; -- The displayed text of the item at Index. The text is not submitted by -- the form only its value if the form is submitted to its action URL. ------------------------------------------------------------------------- -- Selection_Type - Methods ------------------------------------------------------------------------- procedure Add_Option (Element : in out Selection_Type; Value : in String; Text : in String; Index : in Natural := 0; Selected : in Boolean := False; Disabled : in Boolean := False; ID : in String := ""); -- Call to add options to the Selection_Type Element. If Index is 0 -- adds to end of list. Otherwise inserts at Index. procedure Remove_Option (Element : in out Selection_Type; Index : in Positive); procedure Empty_Options (Element : in out Selection_Type); ------------------------------------------------------------------------- -- Option_Type ------------------------------------------------------------------------- type Option_Type is new Gnoga.Gui.Element.Element_Type with private; type Option_Access is access all Option_Type; type Pointer_To_Option_Class is access all Option_Type'Class; ------------------------------------------------------------------------- -- Option_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Option_Type; Form : in out Form_Type'Class; Selection : in out Gnoga.Gui.Element.Element_Type'Class; Value : in String; Text : in String; Selected : in Boolean := False; Disabled : in Boolean := False; ID : in String := ""); -- Creates an Option for Selection, this is an alternative to using -- Selection_Type.Add_Option that allows attaching events to the option. -- Depending on browser, some styling may be possible also. -- Will be added to end of Selection, the placement can be changed using -- standard Element_Type.Place_* methods and can also be removed using -- Element.Remove -- Selection can be an element of Selection_Type or Option_Group_Type -- NOTE: A few browsers allow limited styling of Element such as color -- some do not allow any. Test across your expected delivery -- platforms to insure the styling you use works as expected. ------------------------------------------------------------------------- -- Option_Type - Properties ------------------------------------------------------------------------- procedure Selected (Element : in out Option_Type; Value : in Boolean := True); function Selected (Element : Option_Type) return Boolean; procedure Disabled (Element : in out Option_Type; Value : in Boolean := True); function Disabled (Element : Option_Type) return Boolean; procedure Value (Element : in out Option_Type; Value : in String); function Value (Element : Option_Type) return String; overriding procedure Text (Element : in out Option_Type; Value : in String); overriding function Text (Element : Option_Type) return String; ------------------------------------------------------------------------- -- Option_Group_Type ------------------------------------------------------------------------- type Option_Group_Type is new Gnoga.Gui.Element.Element_Type with private; type Option_Group_Access is access all Option_Group_Type; type Pointer_To_Option_Group_Class is access all Option_Group_Type'Class; ------------------------------------------------------------------------- -- Option_Group_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Option_Group_Type; Form : in out Form_Type'Class; Selection : in out Selection_Type'Class; Label : in String; Disabled : in Boolean := False; ID : in String := ""); -- Option Groups create a tree like selection hierarchy in the Select. -- once added ------------------------------------------------------------------------- -- Option_Group_Type - Properties ------------------------------------------------------------------------- procedure Disabled (Element : in out Option_Group_Type; Value : in Boolean := True); function Disabled (Element : Option_Group_Type) return Boolean; procedure Label (Element : in out Option_Group_Type; Value : in String); function Label (Element : Option_Group_Type) return String; ------------------------------------------------------------------------- -- File_Types ------------------------------------------------------------------------- type File_Type is new Form_Element_Type with private; type File_Access is access all File_Type; type Pointer_To_File_Class is access all File_Type'Class; ------------------------------------------------------------------------- -- File_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out File_Type; Form : in out Form_Type'Class; Multiple : in Boolean := False; Name : in String := ""; ID : in String := ""); ------------------------------------------------------------------------- -- File_Type - Properties ------------------------------------------------------------------------- procedure Accept_List (Element : in out File_Type; Value : in String); function Accept_List (Element : File_Type) return String; -- One or more unique file type specifiers describing file types to allow procedure Capture (Element : in out File_Type; Value : in String); function Capture (Element : File_Type) return String; -- What source to use for capturing image or video data procedure Multiple (Element : in out File_Type; Value : in Boolean := True); function Multiple (Element : File_Type) return Boolean; -- A Boolean which, if present, indicates that the user may choose more than one file procedure WebkitDirectory (Element : in out File_Type; Value : in Boolean := True); function WebkitDirectory (Element : File_Type) return Boolean; -- A Boolean indicating whether or not to only allow the user to choose a directory -- (or directories, if multiple is also present) function File_Count (Element : File_Type) return Natural; -- Return the number of selected files function File_Name (Element : File_Type; Index : Positive := 1) return String; -- Return the name of the specified file by its index function File_Size (Element : File_Type; Index : Positive := 1) return Natural; -- Return the size of the specified file by its index function File_MIME_Type (Element : File_Type; Index : Positive := 1) return String; -- Return the MIME type of the specified file by its index function File_Last_Modified (Element : File_Type; Index : Positive := 1) return Natural; -- Return the last modification time in millisecond of the specified file by its index function File_WebkitRelativePath (Element : File_Type; Index : Positive := 1) return String; -- Return the path of the file is relative to. ------------------------------------------------------------------------- -- Tel_Types ------------------------------------------------------------------------- type Tel_Type is new Form_Element_Type with private; type Tel_Access is access all Tel_Type; type Pointer_To_Tel_Class is access all Tel_Type'Class; ------------------------------------------------------------------------- -- Tel_Type - Creation Methods ------------------------------------------------------------------------- procedure Create (Element : in out Tel_Type; Form : in out Form_Type'Class; Value : in String := ""; Name : in String := ""; ID : in String := ""); private type Form_Type is new Gnoga.Gui.View.View_Base_Type with null record; type Form_Element_Type is new Gnoga.Gui.Element.Element_Type with null record; type Text_Area_Type is new Form_Element_Type with null record; type Hidden_Type is new Form_Element_Type with null record; type Input_Image_Type is new Form_Element_Type with null record; type Input_Button_Type is new Form_Element_Type with null record; type Submit_Button_Type is new Input_Button_Type with null record; type Reset_Button_Type is new Input_Button_Type with null record; type Text_Type is new Form_Element_Type with null record; type Email_Type is new Text_Type with null record; type Password_Type is new Text_Type with null record; type Search_Type is new Text_Type with null record; type URL_Type is new Text_Type with null record; type Check_Box_Type is new Form_Element_Type with null record; type Radio_Button_Type is new Form_Element_Type with null record; type Color_Picker_Type is new Form_Element_Type with null record; type Date_Type is new Form_Element_Type with null record; type Time_Type is new Form_Element_Type with null record; type Month_Type is new Form_Element_Type with null record; type Week_Type is new Form_Element_Type with null record; type Date_Time_Type is new Form_Element_Type with null record; type Date_Time_Local_Type is new Form_Element_Type with null record; type Number_Type is new Form_Element_Type with null record; type Range_Type is new Number_Type with null record; type Label_Type is new Gnoga.Gui.Element.Element_Type with null record; type Data_List_Type is new Gnoga.Gui.View.View_Base_Type with null record; type Selection_Type is new Form_Element_Type with null record; type Option_Type is new Gnoga.Gui.Element.Element_Type with null record; type Option_Group_Type is new Gnoga.Gui.Element.Element_Type with null record; type File_Type is new Form_Element_Type with null record; type Tel_Type is new Form_Element_Type with null record; end Ada_GUI.Gnoga.Gui.Element.Form;
-- CE3806C.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 PUT FOR FLOAT_IO RAISES CONSTRAINT_ERROR WHEN THE -- VALUES SUPPLIED BY FORE, AFT, OR EXP ARE NEGATIVE OR GREATER -- THAN FIELD'LAST WHEN FIELD'LAST < FIELD'BASE'LAST. ALSO CHECK -- THAT PUT FOR FLOAT_IO RAISES CONSTRAINT_ERROR WHEN THE VALUE OF -- ITEM IS OUTSIDE THE RANGE OF THE TYPE USED TO INSTANTIATE -- FLOAT_IO. -- HISTORY: -- SPS 09/10/82 -- JBG 08/30/83 -- JLH 09/14/87 ADDED CASES FOR COMPLETE OBJECTIVE. -- KAS 11/24/95 DELETED DIGITS CONSTRAINT FROM SUBTYPE -- CHANGED STATIC EXPRESSIONS INVOLVING 'LAST WITH REPORT; USE REPORT; WITH TEXT_IO; USE TEXT_IO; PROCEDURE CE3806C IS FIELD_LAST : TEXT_IO.FIELD := TEXT_IO.FIELD'LAST; BEGIN TEST ("CE3806C", "CHECK THAT PUT FOR FLOAT_IO RAISES " & "CONSTRAINT_ERROR APPROPRIATELY"); DECLARE TYPE FLOAT IS DIGITS 5 RANGE 0.0 .. 2.0; SUBTYPE MY_FLOAT IS FLOAT RANGE 0.0 .. 1.0; PACKAGE NFL_IO IS NEW FLOAT_IO (MY_FLOAT); USE NFL_IO; FT : FILE_TYPE; Y : FLOAT := 1.8; X : MY_FLOAT := 26.3 / 26.792; BEGIN BEGIN PUT (FT, X, FORE => IDENT_INT(-6)); FAILED ("CONSTRAINT_ERROR NOT RAISED - NEGATIVE FORE " & "FLOAT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 1"); WHEN USE_ERROR => FAILED ("USE_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 1"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - NEGATIVE FORE " & "FLOAT"); END; BEGIN PUT (FT, X, AFT => IDENT_INT(-2)); FAILED ("CONSTRAINT_ERROR NOT RAISED - NEGATIVE AFT " & "FLOAT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 2"); WHEN USE_ERROR => FAILED ("USE_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 2"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - NEGATIVE AFT " & "FLOAT"); END; BEGIN PUT (FT, X, EXP => IDENT_INT(-1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - NEGATIVE EXP " & "FLOAT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 3"); WHEN USE_ERROR => FAILED ("USE_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 3"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - NEGATIVE EXP " & "FLOAT"); END; IF FIELD_LAST < FIELD'BASE'LAST THEN BEGIN PUT (FT, X, FORE => IDENT_INT(FIELD_LAST+1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - FORE FLOAT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 4"); WHEN USE_ERROR => FAILED ("USE_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 4"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FORE FLOAT"); END; BEGIN PUT (FT, X, AFT => IDENT_INT(FIELD_LAST+1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - AFT FLOAT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 5"); WHEN USE_ERROR => FAILED ("USE_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 5"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - AFT FLOAT"); END; BEGIN PUT (FT, X, EXP => IDENT_INT(FIELD_LAST+1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - EXP FLOAT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 6"); WHEN USE_ERROR => FAILED ("USE_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR - 6"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - EXP FLOAT"); END; END IF; BEGIN PUT (FT, Y); FAILED ("CONSTRAINT_ERROR NOT RAISED FOR ITEM OUTSIDE " & "RANGE - FILE"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED FOR ITEM OUTSIDE " & "RANGE - FILE"); END; BEGIN PUT (Y); FAILED ("CONSTRAINT_ERROR NOT RAISED FOR ITEM OUTSIDE " & "RANGE - DEFAULT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED FOR ITEM OUTSIDE " & "RANGE - DEFAULT"); END; END; RESULT; END CE3806C;
with Decls.Dgenerals, Semantica, Decls.Dtdesc, Ada.Sequential_Io, Ada.Text_Io, Decls.D_Taula_De_Noms, Semantica.Ctipus, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps; use Decls.Dgenerals, Semantica, Decls.Dtdesc, Decls.D_Taula_De_Noms, Semantica.Ctipus, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps; package Semantica.Declsc3a is --taula procediments procedure Nouproc (Tp : in out T_Procs; Idp : out num_proc); function Consulta (Tp : in T_Procs; Idp : in num_proc) return Info_Proc; function Consulta (Tv : in T_Vars; Idv : in num_var) return Info_Var; procedure Modif_Descripcio (Tv : in out T_Vars; Idv : in num_var; Iv : in Info_Var); procedure Novavar (Tv : in out T_Vars; Idpr : in num_proc; Idv : out num_var); procedure Novaconst (Tv : in out T_Vars; Vc : in Valor; Tsub : in tipussubjacent; Idpr : in num_proc; Idc : out num_var); --Taula d'etiquetes function Nova_Etiq return num_Etiq; function Etiqueta (Ipr : in Info_Proc) return String; --Fitxers procedure Crea_Fitxer (Nom_Fitxer : in String); procedure Obrir_Fitxer (Nom_Fitxer : in String); procedure Tanca_Fitxer; procedure Llegir_Fitxer (Instruccio : out c3a); procedure Escriure_Fitxer (Instruccio : in c3a); function Fi_Fitxer return Boolean; private package Fitxer_Seq is new Ada.Sequential_Io(c3a); use Fitxer_Seq; F3as : Fitxer_Seq.File_Type; F3at : Ada.Text_Io.File_Type; end Semantica.Declsc3a;
package body MPFR.Generic_FR is function To_MP_Float (X : Long_Long_Float) return MP_Float is begin return To_MP_Float (X, Precision, Rounding); end To_MP_Float; function To_Long_Long_Float (X : MP_Float) return Long_Long_Float is begin return To_Long_Long_Float (X, Rounding); end To_Long_Long_Float; function Image (Value : MP_Float; Base : Number_Base := 10) return String is begin return Image (Value, Base, Rounding); end Image; function Value (Image : String; Base : Number_Base := 10) return MP_Float is begin return Value (Image, Base, Precision, Rounding); end Value; function "+" (Right : MP_Float) return MP_Float is begin return Copy (Right, Precision, Rounding); end "+"; function "-" (Right : MP_Float) return MP_Float is begin return Negative (Right, Precision, Rounding); end "-"; function "+" (Left, Right : MP_Float) return MP_Float is begin return Add (Left, Right, Precision, Rounding); end "+"; function "+" (Left : MP_Float; Right : Long_Long_Float) return MP_Float is begin return Add (Left, Right, Precision, Rounding); end "+"; function "+" (Left : Long_Long_Float; Right : MP_Float) return MP_Float is begin return Add (Left, Right, Precision, Rounding); end "+"; function "-" (Left, Right : MP_Float) return MP_Float is begin return Subtract (Left, Right, Precision, Rounding); end "-"; function "-" (Left : MP_Float; Right : Long_Long_Float) return MP_Float is begin return Subtract (Left, Right, Precision, Rounding); end "-"; function "-" (Left : Long_Long_Float; Right : MP_Float) return MP_Float is begin return Subtract (Left, Right, Precision, Rounding); end "-"; function "*" (Left, Right : MP_Float) return MP_Float is begin return Multiply (Left, Right, Precision, Rounding); end "*"; function "*" (Left : MP_Float; Right : Long_Long_Float) return MP_Float is begin return Multiply (Left, Right, Precision, Rounding); end "*"; function "*" (Left : Long_Long_Float; Right : MP_Float) return MP_Float is begin return Multiply (Left, Right, Precision, Rounding); end "*"; function "/" (Left, Right : MP_Float) return MP_Float is begin return Divide (Left, Right, Precision, Rounding); end "/"; function "/" (Left : MP_Float; Right : Long_Long_Float) return MP_Float is begin return Divide (Left, Right, Precision, Rounding); end "/"; function "/" (Left : Long_Long_Float; Right : MP_Float) return MP_Float is begin return Divide (Left, Right, Precision, Rounding); end "/"; function "**" (Left : MP_Float; Right : Integer) return MP_Float is begin return Power (Left, Right, Precision, Rounding); end "**"; function Sqrt (X : MP_Float) return MP_Float is begin return Sqrt (X, Precision, Rounding); end Sqrt; function NaN return MP_Float is begin return NaN (Precision); end NaN; function Infinity return MP_Float is begin return Infinity (Precision); end Infinity; end MPFR.Generic_FR;
package body LogQueue with SPARK_Mode is protected body queue is procedure Put (msg : mylog.logmsg) is buf_int : mylog.logmsg; begin buf := msg; buf_int := msg; Not_Empty := True; end Put; entry Get (msg : out mylog.logmsg) when Not_Empty is msg_ucon : mylog.logmsg (TEXT); begin msg := buf; msg_ucon := buf; Not_Empty := False; end Get; end queue; procedure mytest is msg_ucon : mylog.logmsg (GPS); begin myqueue.Get (msg_ucon); -- this call is not analyzed, because there is no -- precondition. But we would need one to tell -- that the parameter must be unconstrained end mytest; end LogQueue;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $: with Ada.Wide_Text_IO; with Asis.Elements; with Asis.Iterator; with Asis.Statements; with Asis.Gela.Lists; with Asis.Gela.Errors; with Asis.Expressions; with Asis.Declarations; with Asis.Gela.Debug; with Asis.Gela.Utils; with Asis.Gela.Element_Utils; with Asis.Gela.Visibility.Utils; with Asis.Gela.Visibility.Create; with XASIS.Utils; with Gela.Containers.Stacks; use Gela; package body Asis.Gela.Visibility is type Stack_Item is record Element : Asis.Element; Point : Visibility.Point; end record; package Region_Stacks is new Containers.Stacks (Stack_Item); use Region_Stacks; Region_Stack : Stack; procedure Enter_Each_Construction (Element : in Asis.Element; Point : in out Visibility.Point); procedure Resolve_Profile (Construct : in Asis.Element; Point : in out Visibility.Point); procedure Resolve_RR_Name (Construct : in Asis.Element; Point : in out Visibility.Point); procedure Pre_Op (Element : in Asis.Element; Control : in out Asis.Traverse_Control; State : in out Visibility.Point); procedure Post_Op (Element : in Asis.Element; Control : in out Asis.Traverse_Control; State : in out Visibility.Point); procedure Resolve_Names is new Asis.Iterator.Traverse_Element (State_Information => Visibility.Point, Pre_Operation => Pre_Op, Post_Operation => Post_Op); function Get_Name (Element : Asis.Element) return Asis.Program_Text; function Lookup_Operators (Item : Asis.Element; Tipe : Asis.Declaration) return Asis.Defining_Name_List; function Print_Region (Point : Visibility.Point) return Boolean; procedure Print_Region (Point : Visibility.Point; Prefix : Wide_String := ""; Mark : Visibility.Point); -------------------- -- End_Of_Package -- -------------------- function End_Of_Package (The_Package : Asis.Declaration) return Asis.Element is use Asis.Elements; begin case Declaration_Kind (The_Package) is when A_Package_Declaration | A_Package_Body_Declaration | A_Generic_Package_Declaration => return Declarations.Names (The_Package) (1); when others => raise Internal_Error; end case; end End_Of_Package; ------------------------ -- Enter_Construction -- ------------------------ procedure Enter_Construction (Element : in Asis.Element; Point : in out Visibility.Point) is begin if not Utils.Is_Top_Declaration (Element) then Enter_Each_Construction (Element, Point); end if; end Enter_Construction; ----------------------------- -- Enter_Each_Construction -- ----------------------------- procedure Enter_Each_Construction (Element : in Asis.Element; Point : in out Visibility.Point) is use Asis.Elements; procedure Try_Unhide_Parent is Decl : constant Asis.Declaration := XASIS.Utils.Parent_Declaration (Element); begin if not Is_Nil (Decl) then case Declaration_Kind (Decl) is when A_Package_Declaration | A_Generic_Package_Declaration | A_Procedure_Body_Declaration | A_Function_Body_Declaration => Utils.Unhide_Declaration (Decl, Point); when others => null; end case; end if; end Try_Unhide_Parent; Kind : constant Asis.Element_Kinds := Element_Kind (Element); Stmt : Asis.Statement_Kinds; Needed : Boolean := False; Is_Compl : Boolean := False; Is_Instance : Boolean := False; Skip_Formal : Boolean := False; RR_Clause : Boolean := False; Overridden : Boolean := False; begin Utils.Set_Place (Element, Point); case Kind is when Asis.A_Declaration => Try_Unhide_Parent; Resolve_Profile (Element, Point); Needed := True; if XASIS.Utils.Can_Be_Completion (Element) then Utils.Check_Completion (Element, Point); Is_Compl := XASIS.Utils.Is_Completion (Element) or Asis.Declarations.Is_Subunit (Element); end if; if Utils.Is_Template (Element) then Is_Instance := True; end if; if Declaration_Kind (Element) in A_Formal_Declaration and then Is_Part_Of_Instance (Element) then declare Expr : constant Asis.Expression := Element_Utils.Generic_Actual (Element); begin if Assigned (Expr) and Expression_Kind (Expr) /= A_Box_Expression then Skip_Formal := True; end if; end; end if; when Asis.An_Exception_Handler => Needed := True; when Asis.A_Statement => Try_Unhide_Parent; Resolve_Profile (Element, Point); Stmt := Asis.Elements.Statement_Kind (Element); if Stmt in Asis.A_Loop_Statement .. Asis.A_Block_Statement or Stmt = Asis.An_Accept_Statement or Stmt = Asis.An_Extended_Return_Statement then Needed := True; end if; when A_Definition => case Definition_Kind (Element) is when A_Record_Definition | A_Null_Record_Definition | A_Task_Definition | A_Protected_Definition => Utils.Unhide_Declaration (XASIS.Utils.Parent_Declaration (Element), Point); when others => null; end case; when A_Pragma => Try_Unhide_Parent; when A_Clause => case Representation_Clause_Kind (Element) is when A_Record_Representation_Clause => Resolve_RR_Name (Element, Point); RR_Clause := True; Needed := True; when others => null; end case; when others => null; end case; if not Skip_Formal then Create.Region_Items (Element, Point, Asis.Nil_Element, Overridden); end if; if Overridden then Errors.Report (Element, Errors.Error_Name_Redeclaration); end if; if not Needed then return; end if; if Utils.Need_New_Region (Element) or RR_Clause then if Is_Compl or Is_Instance or RR_Clause then Push (Region_Stack, (Element, Point)); Create.Completion_Region (Element, Point, Is_Instance, RR_Clause); else Push (Region_Stack, (Element, Point)); Create.Region (Element, Point); end if; end if; if Kind /= A_Defining_Name then Utils.Set_Place (Element, Point); -- set place to deeper region end if; end Enter_Each_Construction; ---------------- -- Enter_Unit -- ---------------- function Enter_Unit (Unit : Asis.Compilation_Unit) return Point is Point : Visibility.Point; Element : Asis.Element; begin Utils.Find_Parent_Region (Unit, Point); Element := Asis.Elements.Unit_Declaration (Unit); Enter_Each_Construction (Element, Point); return Point; end Enter_Unit; -------------- -- Get_Name -- -------------- function Get_Name (Element : Asis.Element) return Asis.Program_Text is begin if Asis.Elements.Element_Kind (Element) = An_Expression then return Asis.Expressions.Name_Image (Element); else return XASIS.Utils.Direct_Name (Element); end if; end Get_Name; ----------------- -- Is_Declared -- ----------------- function Is_Declared (Name : in Asis.Defining_Name) return Boolean renames Utils.Is_Declared; ------------------------ -- Leave_Construction -- ------------------------ procedure Leave_Construction (Element : in Asis.Element; Point : in out Visibility.Point) is use XASIS.Utils; use Asis.Elements; Kind : constant Asis.Element_Kinds := Element_Kind (Element); Item : Stack_Item; Part : Part_Access; begin case Kind is when Asis.A_Declaration => Utils.Unhide_Declaration (Element, Point); case Declaration_Kind (Element) is when A_Package_Declaration => if Point.Item.Part.Kind = A_Visible_Part and not Is_Part_Of_Implicit (Element) then Create.New_Part (Region => Point.Item.Part.Region, Kind => A_Private_Part, Parent_Item => Point.Item.Part.Parent_Item, Element => Declaration_Name (Element), Check_Private => True, Result => Part); end if; when others => null; end case; when Asis.A_Clause => Create.Use_Clause (Element, Point); when others => null; end case; if not Is_Empty (Region_Stack) and then Is_Equal (Top (Region_Stack).Element, Element) then Pop (Region_Stack, Item); Point := Item.Point; elsif Utils.Need_New_Region (Element) then raise Internal_Error; end if; end Leave_Construction; ------------ -- Lookup -- ------------ function Lookup (Item : Asis.Element; Point : Visibility.Point) return Asis.Defining_Name_List is pragma Assert (Debug.Run (Item, Debug.Lookup) or else Print_Region (Point)); Direct : constant Asis.Defining_Name_List := Lookup_Direct (Item, Point); begin return Direct & Lookup_Use (Item, Direct, Point); end Lookup; ------------------- -- Lookup_Direct -- ------------------- function Lookup_Direct (Item : Asis.Element; Point : Visibility.Point) return Asis.Defining_Name_List is use Asis.Elements; Name : constant Asis.Program_Text := Get_Name (Item); First : constant Region_Item_Access := Utils.Find_Name (Name, Point); Unit : constant Asis.Compilation_Unit := Enclosing_Compilation_Unit (Item); begin if First = null then return Asis.Nil_Element_List; end if; declare Result : Asis.Defining_Name_List (1 .. First.Count); Index : Asis.ASIS_Natural := 0; begin Utils.Find_All (First, Index, Result, Unit, Point); if Index /= 0 then Utils.Strip_Homograph (Index, Result, Item); end if; return Result (1 .. Index); end; end Lookup_Direct; ----------------------------- -- Lookup_In_Parent_Region -- ----------------------------- function Lookup_In_Parent_Region (Item : Asis.Element; Element : Asis.Element) return Asis.Defining_Name_List is Point : Visibility.Point := Utils.Find_Region (Element); begin Point := (Item => Point.Item.Part.Parent_Item.Part.Region.Last_Part.Last_Item); return Lookup_In_Region (Item, Point, Point); end Lookup_In_Parent_Region; ---------------------- -- Lookup_In_Region -- ---------------------- function Lookup_In_Region (Item : Asis.Element; Reg : Visibility.Point; Point : Visibility.Point) return Asis.Defining_Name_List is use Asis.Elements; Name : constant Asis.Program_Text := Get_Name (Item); Unit : constant Asis.Compilation_Unit := Enclosing_Compilation_Unit (Item); First : constant Region_Item_Access := Utils.Find_Name (Name, Reg, No_Parent_Region => True); begin if First = null or else First.Part.Region /= Reg.Item.Part.Region then return Asis.Nil_Element_List; end if; declare Result : Asis.Defining_Name_List (1 .. First.Count); Index : Asis.ASIS_Natural := 0; begin Utils.Find_All (First, Index, Result, Unit, Point, No_Parent_Region => True); return Result (1 .. Index); end; end Lookup_In_Region; ---------------------- -- Lookup_In_Region -- ---------------------- function Lookup_In_Region (Item : Asis.Element; Element : Asis.Element; Point : Visibility.Point) return Asis.Defining_Name_List is Reg : constant Visibility.Point := Utils.Find_Region (Element); begin return Lookup_In_Region (Item, Reg, Point); end Lookup_In_Region; ---------------------- -- Lookup_Operators -- ---------------------- function Lookup_Operators (Item : Asis.Element; Tipe : Asis.Declaration) return Asis.Defining_Name_List is Name : constant Asis.Program_Text := Get_Name (Item); Def : constant Asis.Definition := Asis.Declarations.Type_Declaration_View (Tipe); List : constant Asis.Declaration_List := Corresponding_Type_Operators (Def.all); -- Asis.Definitions.Corresponding_Type_Operators (Def); -- because we want Private_Type_Definition, etc Result : Asis.Defining_Name_List (List'Range); Index : Asis.List_Index := 1; begin for I in List'Range loop Result (Index) := XASIS.Utils.Get_Defining_Name (List (I), Name); if Assigned (Result (Index)) and then Visible_From (Result (Index), Item) then Index := Index + 1; end if; end loop; return Result (1 .. Index - 1); end Lookup_Operators; ---------------- -- Lookup_Use -- ---------------- function Lookup_Use (Item : Asis.Element; Direct : Asis.Defining_Name_List; Point : Visibility.Point) return Asis.Defining_Name_List is use Asis.Gela.Utils; use Asis.Gela.Lists.Secondary_Definition_Lists; procedure Check_And_Add (Local : in Asis.Defining_Name_List; List : in out List_Node; Item : in Asis.Defining_Name; Fail : out Boolean) is begin for I in Local'Range loop if Are_Homographs (Local (I), Item, Lookup_Use.Item) then Fail := False; return; end if; end loop; for I in 1 .. Length (List) loop if Are_Homographs (Get (List, I), Item, Lookup_Use.Item) then Fail := False; return; end if; end loop; if Length (List) = 1 then if not XASIS.Utils.Overloadable (Get (List, 1)) then Fail := True; return; end if; end if; if not XASIS.Utils.Overloadable (Item) and Length (List) > 0 then Fail := True; return; end if; Add (List, Item); Fail := False; end Check_And_Add; List : List_Node; Next : Region_Item_Access := Point.Item; Part : Part_Access := Next.Part; Region : Region_Access := Part.Region; Stored_Item : Region_Item_Access; With_Private : Boolean := True; From_Visible : Boolean; Fail : Boolean; begin -- loop over regions (Region) while Region /= null loop Stored_Item := Next; From_Visible := Is_Visible (Next.Part.Kind); -- loop over region items (Item) while Next /= null loop if not With_Private and Region.Library_Unit and not Is_Visible (Next.Part.Kind) then null; elsif Next.Kind = Use_Package then declare Names : constant Asis.Defining_Name_List := Lookup_In_Region (Item, Next.Declaration, Point); begin for I in Names'Range loop Check_And_Add (Direct, List, Names (I), Fail); if Fail then return Asis.Nil_Element_List; end if; end loop; end; elsif Next.Kind = Use_Type then declare Names : constant Asis.Defining_Name_List := Lookup_Operators (Item, Classes.Get_Declaration (Next.Tipe)); begin for I in reverse Names'Range loop Check_And_Add (Direct, List, Names (I), Fail); if Fail then return Asis.Nil_Element_List; end if; end loop; end; end if; Next := Next.Next; if Next = null then Part := Part.Next; if Part /= null then Next := Part.Last_Item; end if; end if; end loop; if Region.Library_Unit and Region.Public_Child and From_Visible then With_Private := False; else With_Private := True; end if; Next := Stored_Item.Part.Parent_Item; if Next /= null then Part := Next.Part; Region := Part.Region; else Part := null; Region := null; end if; end loop; return To_Element_List (List); end Lookup_Use; ------------------------------ -- New_Implicit_Declaration -- ------------------------------ procedure New_Implicit_Declaration (Element : in Asis.Declaration; Point : in out Visibility.Point; Tipe : in Asis.Declaration; Overridden : out Boolean) is begin Utils.Set_Place (Element, Point); Create.Region_Items (Element, Point, Tipe, Overridden); if not Overridden then Utils.Unhide_Declaration (Element, Point); end if; end New_Implicit_Declaration; ------------- -- Post_Op -- ------------- procedure Post_Op (Element : in Asis.Element; Control : in out Asis.Traverse_Control; State : in out Visibility.Point) is begin null; end Post_Op; ------------ -- Pre_Op -- ------------ procedure Pre_Op (Element : in Asis.Element; Control : in out Asis.Traverse_Control; State : in out Visibility.Point) is Expr : constant Expression_Kinds := Asis.Elements.Expression_Kind (Element); begin if (Expr = An_Identifier or Expr = An_Operator_Symbol or Expr = A_Character_Literal) and not Elements.Is_Part_Of_Implicit (Element) and not Elements.Is_Part_Of_Instance (Element) then Try_To_Resolve (Element, State); end if; end Pre_Op; ------------------ -- Print_Region -- ------------------ function Print_Region (Point : Visibility.Point) return Boolean is begin Print_Region ((Item => Utils.Top_Region.First_Part.Last_Item), Mark => Point); return True; end Print_Region; ------------------ -- Print_Region -- ------------------ procedure Print_Region (Point : Visibility.Point; Prefix : Wide_String := ""; Mark : Visibility.Point) is use Asis.Elements; use Ada.Wide_Text_IO; Item : Region_Item_Access := Point.Item; Part : constant Part_Access := Item.Part; Region : Region_Access := Part.Region; Part_I : Part_Access := Region.Last_Part; Lib_Unit : Wide_Character := ' '; Public : Wide_Character := ' '; Current : Wide_Character := ' '; Visible : Wide_Character := ' '; Depth : constant Wide_String := Integer'Wide_Image (Region.Depth); begin if Point.Item = null then return; end if; if Region.Library_Unit then Lib_Unit := 'L'; end if; if Region.Public_Child then Public := 'P'; end if; Put_Line (Prefix & "<region lib='" & Lib_Unit & "' pub='" & Public & "' depth='" & Depth & "'>"); while Part_I /= null loop Put_Line (Prefix & "<part kind='" & Part_Kinds'Wide_Image (Part_I.Kind) & "'>"); Put_Line (Prefix & " <element img='" & Debug_Image (Part_I.Element) & "'/>"); if Part_I.Parent_Item /= null then Put_Line (Prefix & "<parent name='" & Debug_Image (Part_I.Parent_Item.Defining_Name) & "'/>"); end if; Item := Part_I.Last_Item; while Item /= null loop if Item = Mark.Item then Current := 'C'; else Current := ' '; end if; case Item.Kind is when Definition | Char | Wide_Char | Wide_Wide_Char => if Item.Kind = Definition and then Item.Still_Hidden then Visible := 'H'; else Visible := ' '; end if; if Item.Kind = Definition and then Item.Library_Unit then Lib_Unit := 'L'; else Lib_Unit := ' '; end if; Put_Line (Prefix & "<item cur='" & Current & "' vis='" & Visible & "' lib='" & Lib_Unit & "' name='" & Debug_Image (Item.Defining_Name) & "' cnt='" & ASIS_Natural'Wide_Image (Item.Count) & "'/>"); when Use_Package => Put_Line (Prefix & "<use_pkg cur='" & Current & "' decl='" & Debug_Image (Item.Declaration) & "'/>"); when Use_Type => Put_Line (Prefix & "<use_type cur='" & Current & "' tipe='" & Classes.Debug_Image (Item.Tipe) & "'/>"); when Dummy => Put_Line (Prefix & "<dummy cur='" & Current & "'/>"); end case; Item := Item.Next; end loop; Put_Line (Prefix & "</part>"); Part_I := Part_I.Next; end loop; Region := Region.First_Child; while Region /= null loop Print_Region ((Item => Region.First_Part.Last_Item), Prefix & " ", Mark); Region := Region.Next; end loop; Put_Line (Prefix & "</region>"); end Print_Region; ------------------ -- Print_Region -- ------------------ procedure Print_Region (Point : Visibility.Point; Prefix : Wide_String := "") is begin Print_Region (Point, Prefix, (Item => null)); end Print_Region; --------------------------- -- Print_Standard_Region -- --------------------------- procedure Print_Standard_Region is begin Print_Region ((Item => Utils.Top_Region.First_Part.Last_Item)); end Print_Standard_Region; --------------------- -- Resolve_Profile -- --------------------- procedure Resolve_Profile (Construct : in Asis.Element; Point : in out Visibility.Point) is use Asis.Elements; use Asis.Statements; use Asis.Declarations; Control : Asis.Traverse_Control := Continue; procedure Resolve_Profile (List : Asis.Parameter_Specification_List) is Mark : Asis.Expression; begin for I in List'Range loop Mark := Object_Declaration_Subtype (List (I)); Resolve_Names (Mark, Control, Point); end loop; end Resolve_Profile; Kind : constant Asis.Declaration_Kinds := Declaration_Kind (Construct); begin if Kind = A_Function_Declaration or Kind = A_Function_Body_Declaration or Kind = A_Function_Renaming_Declaration or Kind = A_Function_Body_Stub or Kind = A_Generic_Function_Declaration or Kind = A_Formal_Function_Declaration then Resolve_Names (Result_Subtype (Construct), Control, Point); end if; if Kind = A_Function_Declaration or Kind = A_Function_Body_Declaration or Kind = A_Function_Renaming_Declaration or Kind = A_Function_Body_Stub or Kind = A_Generic_Function_Declaration or Kind = A_Formal_Function_Declaration or Kind = A_Procedure_Declaration or Kind = A_Procedure_Body_Declaration or Kind = A_Procedure_Renaming_Declaration or Kind = An_Entry_Declaration or Kind = An_Entry_Body_Declaration or Kind = A_Procedure_Body_Stub or Kind = A_Generic_Procedure_Declaration or Kind = A_Formal_Procedure_Declaration then Resolve_Profile (Parameter_Profile (Construct)); elsif Statement_Kind (Construct) = An_Accept_Statement then Resolve_Profile (Accept_Parameters (Construct)); end if; end Resolve_Profile; --------------------- -- Resolve_RR_Name -- --------------------- procedure Resolve_RR_Name (Construct : in Asis.Element; Point : in out Visibility.Point) is Name : constant Asis.Expression := Representation_Clause_Name (Construct.all); Control : Asis.Traverse_Control := Continue; begin Resolve_Names (Name, Control, Point); end Resolve_RR_Name; ---------------------- -- Set_Not_Declared -- ---------------------- procedure Set_Not_Declared (Name : in Asis.Defining_Name) is begin Utils.Set_Name_Place (Name, (Item => null)); end Set_Not_Declared; -------------------- -- Try_To_Resolve -- -------------------- procedure Try_To_Resolve (Element : Asis.Expression; Point : Visibility.Point) is use Asis.Elements; use Asis.Expressions; type Resolution is record Allowed : Boolean; In_Region : Boolean; Construct : Asis.Element; end record; procedure Check (Result : out Resolution); procedure Set_Region (Result : in out Resolution; Parent : in Asis.Expression); function Is_Enclosing_Named_Construct (Parent : Asis.Element; Name : Asis.Defining_Name) return Boolean; procedure Check (Result : out Resolution) is Parent : constant Asis.Element := Enclosing_Element (Element); begin Result.Allowed := True; Result.In_Region := False; case Element_Kind (Parent) is when A_Pragma => Result.Allowed := False; when An_Association => case Association_Kind (Parent) is when A_Record_Component_Association | An_Array_Component_Association => -- if not Is_Equal (Element, Component_Expression (Parent)) -- then -- Result.Allowed := False; -- end if; null; when others => if not Is_Equal (Element, Actual_Parameter (Parent)) then Result.Allowed := False; end if; end case; when An_Expression => case Expression_Kind (Parent) is when A_Selected_Component => if Is_Equal (Element, Selector (Parent)) then Set_Region (Result, Prefix (Parent)); end if; when An_Attribute_Reference => if Is_Equal (Element, Attribute_Designator_Identifier (Parent)) then Result.Allowed := False; end if; when others => null; end case; when others => null; end case; end Check; function Is_Enclosing_Named_Construct (Parent : Asis.Element; Name : Asis.Defining_Name) return Boolean is use Asis.Statements; use Asis.Declarations; Declaration : Asis.Declaration := Nil_Element; Parent_Name : Asis.Defining_Name := Nil_Element; begin if Is_Nil (Parent) then return False; end if; case Element_Kind (Parent) is when A_Declaration => case Declaration_Kind (Parent) is when A_Task_Type_Declaration | A_Protected_Type_Declaration | A_Single_Task_Declaration | A_Single_Protected_Declaration | A_Procedure_Declaration | A_Function_Declaration | A_Procedure_Body_Declaration | A_Function_Body_Declaration | A_Task_Body_Declaration | A_Protected_Body_Declaration | An_Entry_Declaration | An_Entry_Body_Declaration | A_Generic_Procedure_Declaration | A_Generic_Function_Declaration | An_Ordinary_Type_Declaration => Parent_Name := Names (Parent) (1); when others => null; end case; when A_Statement => case Statement_Kind (Parent) is when A_Loop_Statement .. A_Block_Statement => Parent_Name := Statement_Identifier (Parent); when An_Accept_Statement => Declaration := Corresponding_Name_Declaration ( Accept_Entry_Direct_Name (Parent)); Parent_Name := Names (Declaration) (1); when others => null; end case; when others => null; end case; if Is_Equal (Parent_Name, Name) then return True; else return Is_Enclosing_Named_Construct (Enclosing_Element (Parent), Name); end if; end Is_Enclosing_Named_Construct; procedure Set_Region (Result : in out Resolution; Parent : in Asis.Expression) is Identifier : Asis.Expression; begin Result.Allowed := False; case Expression_Kind (Parent) is when An_Identifier => Identifier := Parent; when A_Selected_Component => Identifier := Selector (Parent); when others => return; end case; declare use Asis.Declarations; Target : constant Asis.Declaration := Corresponding_Name_Declaration (Identifier); begin if Declaration_Kind (Target) in A_Renaming_Declaration then Set_Region (Result, Corresponding_Base_Entity (Target)); return; end if; end; declare Names : constant Asis.Defining_Name_List := Corresponding_Name_Definition_List (Identifier); Found : Boolean := False; begin for I in Names'Range loop if XASIS.Utils.Is_Package_Name (Names (I)) or else XASIS.Utils.Is_Enclosing_Named_Construct (Parent, Names (I)) then if not Found then Found := True; Result.Construct := Enclosing_Element (Names (I)); Result.In_Region := True; Result.Allowed := True; else Result.Allowed := False; -- Put_Line ("Ambigous prefix"); end if; end if; end loop; end; end Set_Region; Res : Resolution; Expr : constant Expression_Kinds := Asis.Elements.Expression_Kind (Element); begin pragma Assert (Expr = An_Identifier or Expr = An_Operator_Symbol or Expr = A_Character_Literal, "Unexpected element in Try_To_Resolve"); Check (Res); if not Res.Allowed then return; end if; if Res.In_Region then Element_Utils.Set_Resolved (Element, Lookup_In_Region (Element, Res.Construct, Point)); else Element_Utils.Set_Resolved (Element, Lookup (Element, Point)); end if; end Try_To_Resolve; ------------------------- -- Try_To_Resolve_Goto -- ------------------------- procedure Try_To_Resolve_Goto (Element : Asis.Expression; Stmt : Asis.Statement) is Point : constant Visibility.Point := Utils.Goto_Enclosing_Region (Stmt); begin Try_To_Resolve (Element, Point); end Try_To_Resolve_Goto; ------------------ -- Visible_From -- ------------------ function Visible_From (Name : in Asis.Defining_Name; Point : in Asis.Identifier) return Boolean renames Utils.Visible_From; ----------------- -- Unique_Name -- ----------------- function Unique_Name (Name : in Asis.Defining_Name) return Wide_String is use Asis.Elements; function Get_Parent (Reg : Region_Access) return Region_Access is begin if Reg = Utils.Top_Region'Access then return null; else return Reg.Last_Part.Parent_Item.Part.Region; end if; end Get_Parent; function Count_Siblings (Reg : Region_Access) return Positive is Parent : constant Region_Access := Get_Parent (Reg); Current : Region_Access := Parent.First_Child; Result : Positive := 1; begin while Current /= Reg loop Result := Result + 1; Current := Current.Next; end loop; return Result; end Count_Siblings; function Region_Name (Reg : Region_Access) return Wide_String is use XASIS.Utils; Parent : constant Region_Access := Get_Parent (Reg); begin if Parent = null or Parent = Utils.Top_Region'Access then return ""; elsif Element_Kind (Reg.First_Part.Element) = A_Declaration then return Unique_Name (Declaration_Name (Reg.First_Part.Element)) & "."; else declare Img : Wide_String := Positive'Wide_Image (Count_Siblings (Reg)); begin Img (1) := '_'; return Region_Name (Parent) & Img & '.'; end; end if; end Region_Name; -- Go from completion to declaration function Declaration_Name return Asis.Defining_Name is use XASIS.Utils; Comp : Asis.Declaration := Enclosing_Element (Name); Decl : Asis.Declaration; begin if Is_Completion (Comp) then Decl := Declaration_For_Completion (Comp); return Get_Defining_Name (Decl, Direct_Name (Name)); else return Name; end if; end Declaration_Name; Target : constant Asis.Defining_Name := Declaration_Name; Item : constant Region_Item_Access := Utils.Get_Place (Target); Point : constant Visibility.Point := (Item => Item); Reg : constant Region_Access := Item.Part.Region; Reg_Name : constant Wide_String := Region_Name (Reg); Result : constant Asis.Defining_Name_List := Lookup_In_Region (Target, Point, Point); begin if Result'Length = 1 then return Reg_Name & XASIS.Utils.Direct_Name (Target); else declare Img : Wide_String := Positive'Wide_Image (Result'Length); begin Img (1) := '$'; return Reg_Name & XASIS.Utils.Direct_Name (Target) & Img; end; end if; end Unique_Name; end Asis.Gela.Visibility; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- 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 Maxim Reznik, 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 OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
with Ada.Text_IO; procedure Hello is begin Ada.Text_IO.Put_Line ("Hello, World!"); end Hello;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . E X E C U T I O N _ T I M E . G R O U P _ B U D G E T S -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- This unit is not implemented in typical GNAT implementations that lie on -- top of operating systems, because it is infeasible to implement in such -- environments. -- If a target environment provides appropriate support for this package, -- then the Unimplemented_Unit pragma should be removed from this spec and -- an appropriate body provided. with System; package Ada.Execution_Time.Group_Budgets is pragma Preelaborate; pragma Unimplemented_Unit; type Group_Budget is tagged limited private; type Group_Budget_Handler is access protected procedure (GB : in out Group_Budget); type Task_Array is array (Positive range <>) of Ada.Task_Identification.Task_Id; Min_Handler_Ceiling : constant System.Any_Priority := System.Any_Priority'First; -- Initial value is an arbitrary choice ??? procedure Add_Task (GB : in out Group_Budget; T : Ada.Task_Identification.Task_Id); procedure Remove_Task (GB : in out Group_Budget; T : Ada.Task_Identification.Task_Id); function Is_Member (GB : Group_Budget; T : Ada.Task_Identification.Task_Id) return Boolean; function Is_A_Group_Member (T : Ada.Task_Identification.Task_Id) return Boolean; function Members (GB : Group_Budget) return Task_Array; procedure Replenish (GB : in out Group_Budget; To : Ada.Real_Time.Time_Span); procedure Add (GB : in out Group_Budget; Interval : Ada.Real_Time.Time_Span); function Budget_Has_Expired (GB : Group_Budget) return Boolean; function Budget_Remaining (GB : Group_Budget) return Ada.Real_Time.Time_Span; procedure Set_Handler (GB : in out Group_Budget; Handler : Group_Budget_Handler); function Current_Handler (GB : Group_Budget) return Group_Budget_Handler; procedure Cancel_Handler (GB : in out Group_Budget; Cancelled : out Boolean); Group_Budget_Error : exception; private type Group_Budget is tagged limited null record; end Ada.Execution_Time.Group_Budgets;
----------------------------------------------------------------------- -- awa-workspaces-module -- Module workspaces -- Copyright (C) 2011, 2012, 2013, 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 Ada.Calendar; with AWA.Modules.Beans; with AWA.Modules.Get; with ADO.SQL; with ADO.Sessions.Entities; with ADO.Queries; with ADO.Statements; with Security.Policies.Roles; with Util.Log.Loggers; with AWA.Users.Modules; with AWA.Workspaces.Beans; package body AWA.Workspaces.Modules is use type ADO.Identifier; package ASC renames AWA.Services.Contexts; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Awa.Workspaces.Module"); package Register is new AWA.Modules.Beans (Module => Workspace_Module, Module_Access => Workspace_Module_Access); -- ------------------------------ -- Initialize the workspaces module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Workspace_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is Sec_Manager : constant Security.Policies.Policy_Manager_Access := Plugin.Get_Application.Get_Security_Manager; begin Log.Info ("Initializing the workspaces module"); -- Register here any bean class, servlet, filter. Register.Register (Plugin => Plugin, Name => "AWA.Workspaces.Beans.Workspaces_Bean", Handler => AWA.Workspaces.Beans.Create_Workspaces_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Workspaces.Beans.Member_List_Bean", Handler => AWA.Workspaces.Beans.Create_Member_List_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Workspaces.Beans.Invitation_Bean", Handler => AWA.Workspaces.Beans.Create_Invitation_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Workspaces.Beans.Member_Bean", Handler => AWA.Workspaces.Beans.Create_Member_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); Plugin.User_Manager := AWA.Users.Modules.Get_User_Manager; Plugin.Perm_Manager := Permissions.Services.Permission_Manager'Class (Sec_Manager.all)'Access; Plugin.Add_Listener (AWA.Users.Modules.NAME, Plugin'Unchecked_Access); end Initialize; -- ------------------------------ -- Configures the module after its initialization and after having read its XML configuration. -- ------------------------------ overriding procedure Configure (Plugin : in out Workspace_Module; Props : in ASF.Applications.Config) is pragma Unreferenced (Props); List : constant String := Plugin.Get_Config (PARAM_PERMISSIONS_LIST); begin Plugin.Owner_Permissions := Ada.Strings.Unbounded.To_Unbounded_String (List); Plugin.Allow_WS_Create := Plugin.Get_Config (PARAM_ALLOW_WORKSPACE_CREATE); end Configure; -- ------------------------------ -- Get the list of permissions for the workspace owner. -- ------------------------------ function Get_Owner_Permissions (Manager : in Workspace_Module) return Permission_Index_Array is use Ada.Strings.Unbounded; begin return Security.Permissions.Get_Permission_Array (To_String (Manager.Owner_Permissions)); end Get_Owner_Permissions; -- Get the workspace module. function Get_Workspace_Module return Workspace_Module_Access is function Get is new AWA.Modules.Get (Workspace_Module, Workspace_Module_Access, NAME); begin return Get; end Get_Workspace_Module; -- ------------------------------ -- Get the current workspace associated with the current user. -- If the user has not workspace, create one. -- ------------------------------ procedure Get_Workspace (Session : in out ADO.Sessions.Master_Session; Context : in AWA.Services.Contexts.Service_Context_Access; Workspace : out AWA.Workspaces.Models.Workspace_Ref) is User : constant AWA.Users.Models.User_Ref := Context.Get_User; WS : AWA.Workspaces.Models.Workspace_Ref; Member : AWA.Workspaces.Models.Workspace_Member_Ref; Query : ADO.SQL.Query; Found : Boolean; Plugin : constant Workspace_Module_Access := Get_Workspace_Module; begin if User.Is_Null then Log.Error ("There is no current user. The workspace cannot be identified"); Workspace := AWA.Workspaces.Models.Null_Workspace; return; end if; -- Find the workspace associated with the current user. Query.Add_Param (User.Get_Id); Query.Set_Filter ("o.owner_id = ?"); WS.Find (Session, Query, Found); if Found then Workspace := WS; return; end if; -- Check that the user has the permission to create a new workspace. AWA.Permissions.Check (Permission => ACL_Create_Workspace.Permission, Entity => User); -- Create a workspace for this user. WS.Set_Owner (User); WS.Set_Create_Date (Ada.Calendar.Clock); WS.Save (Session); -- Create the member instance for this user. Member.Set_Workspace (WS); Member.Set_Member (User); Member.Set_Role ("Owner"); Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False, Value => WS.Get_Create_Date)); Member.Save (Session); -- And give full control of the workspace for this user Add_Permission (Session => Session, User => User.Get_Id, Entity => WS, Workspace => WS.Get_Id, List => Plugin.Get_Owner_Permissions); Workspace := WS; end Get_Workspace; -- ------------------------------ -- Create a workspace for the user. -- ------------------------------ procedure Create_Workspace (Module : in Workspace_Module; Workspace : out AWA.Workspaces.Models.Workspace_Ref) is Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); WS : AWA.Workspaces.Models.Workspace_Ref; Member : AWA.Workspaces.Models.Workspace_Member_Ref; begin if User.Is_Null then Log.Error ("There is no current user. The workspace cannot be identified"); Workspace := AWA.Workspaces.Models.Null_Workspace; return; end if; -- Check that the user has the permission to create a new workspace. AWA.Permissions.Check (Permission => ACL_Create_Workspace.Permission, Entity => User); DB.Begin_Transaction; -- Create a workspace for this user. WS.Set_Owner (User); WS.Set_Create_Date (Ada.Calendar.Clock); WS.Save (DB); -- Create the member instance for this user. Member.Set_Workspace (WS); Member.Set_Member (User); Member.Set_Role ("Owner"); Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False, Value => WS.Get_Create_Date)); Member.Save (DB); -- And give full control of the workspace for this user Add_Permission (Session => DB, User => User.Get_Id, Entity => WS, Workspace => WS.Get_Id, List => Module.Get_Owner_Permissions); Workspace := WS; DB.Commit; end Create_Workspace; -- ------------------------------ -- Load the invitation from the access key and verify that the key is still valid. -- ------------------------------ procedure Load_Invitation (Module : in Workspace_Module; Key : in String; Invitation : in out AWA.Workspaces.Models.Invitation_Ref'Class; Inviter : in out AWA.Users.Models.User_Ref) is pragma Unreferenced (Module); use type Ada.Calendar.Time; Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); Query : ADO.SQL.Query; DB_Key : AWA.Users.Models.Access_Key_Ref; Found : Boolean; begin Log.Debug ("Loading invitation from key {0}", Key); Query.Set_Filter ("o.access_key = :key"); Query.Bind_Param ("key", Key); DB_Key.Find (DB, Query, Found); if not Found then Log.Info ("Invitation key {0} does not exist"); raise Not_Found; end if; if DB_Key.Get_Expire_Date < Ada.Calendar.Clock then Log.Info ("Invitation key {0} has expired"); raise Not_Found; end if; Query.Set_Filter ("o.invitee_id = :user"); Query.Bind_Param ("user", DB_Key.Get_User.Get_Id); Invitation.Find (DB, Query, Found); if not Found then Log.Warn ("Invitation key {0} has been withdawn"); raise Not_Found; end if; Inviter := AWA.Users.Models.User_Ref (Invitation.Get_Inviter); end Load_Invitation; -- ------------------------------ -- Accept the invitation identified by the access key. -- ------------------------------ procedure Accept_Invitation (Module : in Workspace_Module; Key : in String) is use type Ada.Calendar.Time; Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); Query : ADO.SQL.Query; DB_Key : AWA.Users.Models.Access_Key_Ref; Found : Boolean; Invitation : AWA.Workspaces.Models.Invitation_Ref; Invitee_Id : ADO.Identifier; Workspace_Id : ADO.Identifier; Member : AWA.Workspaces.Models.Workspace_Member_Ref; User_Member : AWA.Workspaces.Models.Workspace_Member_Ref; Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; begin Log.Debug ("Accept invitation with key {0}", Key); Ctx.Start; -- Get the access key and verify its validity. Query.Set_Filter ("o.access_key = :key"); Query.Bind_Param ("key", Key); DB_Key.Find (DB, Query, Found); if not Found then Log.Info ("Invitation key {0} does not exist", Key); raise Not_Found; end if; if DB_Key.Get_Expire_Date < Now then Log.Info ("Invitation key {0} has expired", Key); raise Not_Found; end if; -- Find the invitation associated with the access key. Invitee_Id := DB_Key.Get_User.Get_Id; Query.Set_Filter ("o.invitee_id = :user"); Query.Bind_Param ("user", Invitee_Id); Invitation.Find (DB, Query, Found); if not Found then Log.Warn ("Invitation key {0} has been withdawn", Key); raise Not_Found; end if; Member := AWA.Workspaces.Models.Workspace_Member_Ref (Invitation.Get_Member); Workspace_Id := Invitation.Get_Workspace.Get_Id; -- Update the workspace member relation. Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False, Value => Now)); Invitation.Set_Acceptance_Date (ADO.Nullable_Time '(Is_Null => False, Value => Now)); -- The user who received the invitation is different from the user who is -- logged and accepted the validation. Since the key is verified, this is -- the same user but the user who accepted the invitation registered using -- another email address. if Invitee_Id /= User.Get_Id then -- Check whether the user is not already part of the workspace. Query.Clear; Query.Set_Filter ("o.member_id = ? AND o.workspace_id = ?"); Query.Add_Param (User.Get_Id); Query.Add_Param (Workspace_Id); User_Member.Find (DB, Query, Found); if Found then Member.Delete (DB); Invitation.Delete (DB); Log.Info ("Invitation accepted by user who is already a member"); else Member.Set_Member (User); Log.Info ("Invitation accepted by user with another email address"); Invitation.Set_Invitee (User); end if; end if; if not Member.Is_Null then Member.Save (DB); end if; DB_Key.Delete (DB); if not Invitation.Is_Null then Invitation.Save (DB); -- Send the accepted invitation event. declare Event : AWA.Events.Module_Event; begin Event.Set_Parameter ("invitee_email", User.Get_Email.Get_Email); Event.Set_Parameter ("invitee_name", User.Get_Name); Event.Set_Parameter ("message", Invitation.Get_Message); Event.Set_Parameter ("inviter_email", Invitation.Get_Inviter.Get_Email.Get_Email); Event.Set_Parameter ("inviter_name", Invitation.Get_Inviter.Get_Name); Event.Set_Event_Kind (Accept_Invitation_Event.Kind); Module.Send_Event (Event); end; end if; Ctx.Commit; end Accept_Invitation; -- ------------------------------ -- Send the invitation to the user. -- ------------------------------ procedure Send_Invitation (Module : in Workspace_Module; Invitation : in out AWA.Workspaces.Models.Invitation_Ref'Class) is Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; WS : AWA.Workspaces.Models.Workspace_Ref; Query : ADO.SQL.Query; Found : Boolean; Key : AWA.Users.Models.Access_Key_Ref; Email : AWA.Users.Models.Email_Ref; Invitee : AWA.Users.Models.User_Ref; Invit : AWA.Workspaces.Models.Invitation_Ref; Member : AWA.Workspaces.Models.Workspace_Member_Ref; Email_Address : constant String := Invitation.Get_Email; begin Log.Info ("Sending invitation to {0}", Email_Address); if User.Is_Null then Log.Error ("There is no current user. The workspace cannot be identified"); return; end if; -- Find the workspace associated with the current user. Query.Set_Join ("INNER JOIN awa_workspace_member AS m ON m.workspace_id = o.id"); Query.Set_Filter ("m.member_id = ?"); Query.Add_Param (User.Get_Id); WS.Find (DB, Query, Found); if not Found then Log.Error ("The current user has no associated workspace"); return; end if; -- Check that the user has the permission to invite users in the workspace. AWA.Permissions.Check (Permission => ACL_Invite_User.Permission, Entity => WS); Ctx.Start; Query.Clear; Query.Set_Filter ("o.email = ?"); Query.Add_Param (Email_Address); Email.Find (DB, Query, Found); if not Found then Email.Set_User_Id (0); Email.Set_Email (Email_Address); Email.Save (DB); Invitee.Set_Email (Email); Invitee.Set_Name (Email_Address); Invitee.Save (DB); Email.Set_User_Id (Invitee.Get_Id); Email.Save (DB); else Invitee.Load (DB, Email.Get_User_Id); end if; -- Create the workspace member relation. Query.Clear; Query.Set_Filter ("o.member_id = ? AND o.workspace_id = ?"); Query.Add_Param (Invitee.Get_Id); Query.Add_Param (WS.Get_Id); Member.Find (DB, Query, Found); if not Found then Member.Set_Member (Invitee); Member.Set_Workspace (WS); Member.Set_Role ("Invited"); Member.Save (DB); end if; -- Check for a previous invitation for the user and delete it. Query.Set_Filter ("o.invitee_id = ? AND o.workspace_id = ?"); Invit.Find (DB, Query, Found); if Found then Key := AWA.Users.Models.Access_Key_Ref (Invit.Get_Access_Key); Key.Delete (DB); if not Invitation.Is_Inserted or else Invit.Get_Id /= Invitation.Get_Id then Invit.Delete (DB); end if; end if; Key := AWA.Users.Models.Access_Key_Ref (Invitation.Get_Access_Key); Module.User_Manager.Create_Access_Key (Invitee, Key, AWA.Users.Models.INVITATION_KEY, 365 * 86400.0, DB); Key.Save (DB); Invitation.Set_Access_Key (Key); Invitation.Set_Inviter (User); Invitation.Set_Invitee (Invitee); Invitation.Set_Workspace (WS); Invitation.Set_Create_Date (Ada.Calendar.Clock); Invitation.Set_Member (Member); Invitation.Save (DB); -- Send the email with the reset password key declare Event : AWA.Events.Module_Event; begin Event.Set_Parameter ("key", Key.Get_Access_Key); Event.Set_Parameter ("email", Email_Address); Event.Set_Parameter ("name", Invitee.Get_Name); Event.Set_Parameter ("message", Invitation.Get_Message); Event.Set_Parameter ("inviter", User.Get_Name); Event.Set_Event_Kind (Invite_User_Event.Kind); Module.Send_Event (Event); end; Ctx.Commit; end Send_Invitation; -- ------------------------------ -- Delete the member from the workspace. Remove the invitation if there is one. -- ------------------------------ procedure Delete_Member (Module : in Workspace_Module; Member_Id : in ADO.Identifier) is pragma Unreferenced (Module); Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; Query : ADO.SQL.Query; Found : Boolean; Key : AWA.Users.Models.Access_Key_Ref; Member : AWA.Workspaces.Models.Workspace_Member_Ref; Invitation : AWA.Workspaces.Models.Invitation_Ref; User_Id : ADO.Identifier; Workspace_Id : ADO.Identifier; User_Image : constant String := ADO.Identifier'Image (Member_Id); begin Log.Info ("Delete user member {0}", User_Image); -- Get the workspace member instance for the user and remove it. Member.Load (DB, Member_Id, Found); if not Found then Log.Error ("User member {0} does not exist", User_Image); return; end if; User_Id := Member.Get_Member.Get_Id; Workspace_Id := Member.Get_Workspace.Get_Id; if User.Get_Id = User_Id then Log.Warn ("Refusing to delete the current user {0}", User_Image); return; end if; -- Check that the user has the permission to delete users from the workspace. AWA.Permissions.Check (Permission => ACL_Delete_User.Permission, Entity => Workspace_Id); Ctx.Start; Member.Delete (DB); -- Get the invitation and remove it. Query.Set_Filter ("o.member_id = ?"); Query.Add_Param (Member_Id); Invitation.Find (DB, Query, Found); if Found then Key := AWA.Users.Models.Access_Key_Ref (Invitation.Get_Access_Key); Key.Delete (DB); Invitation.Delete (DB); end if; -- Remove all permissions assigned to the user in the workspace. AWA.Permissions.Services.Delete_Permissions (DB, User_Id, Workspace_Id); Ctx.Commit; end Delete_Member; -- ------------------------------ -- Add a list of permissions for all the users of the workspace that have the appropriate -- role. Workspace members will be able to access the given database entity for the -- specified list of permissions. -- ------------------------------ procedure Add_Permission (Session : in out ADO.Sessions.Master_Session; User : in ADO.Identifier; Entity : in ADO.Objects.Object_Ref'Class; Workspace : in ADO.Identifier; List : in Security.Permissions.Permission_Index_Array) is Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; Key : constant ADO.Objects.Object_Key := Entity.Get_Key; Id : constant ADO.Identifier := ADO.Objects.Get_Value (Key); Kind : constant ADO.Entity_Type := ADO.Sessions.Entities.Find_Entity_Type (Session => Session, Object => Key); Manager : constant AWA.Permissions.Services.Permission_Manager_Access := AWA.Permissions.Services.Get_Permission_Manager (Ctx); begin for Perm of List loop declare Member : ADO.Identifier; Query : ADO.Queries.Context; Names : constant Security.Policies.Roles.Role_Name_Array := Manager.Get_Role_Names (Perm); Need_Sep : Boolean := False; User_Added : Boolean := False; begin if Names'Length > 0 then Query.Set_Query (AWA.Workspaces.Models.Query_Member_In_Role); ADO.SQL.Append (Query.Filter, "user_member.workspace_id = :workspace_id"); ADO.SQL.Append (Query.Filter, " AND user_member.member_id IN ("); for Name of Names loop ADO.SQL.Append (Query.Filter, (if Need_Sep then ",?" else "?")); Query.Add_Param (Name.all); Need_Sep := True; end loop; Query.Bind_Param ("workspace_id", Workspace); ADO.SQL.Append (Query.Filter, ")"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query); begin Stmt.Execute; while Stmt.Has_Elements loop Member := Stmt.Get_Identifier (0); if Member = User then User_Added := True; end if; Manager.Add_Permission (Session => Session, User => Member, Entity => Id, Kind => Kind, Workspace => Workspace, Permission => Perm); Stmt.Next; end loop; end; end if; if not User_Added then Manager.Add_Permission (Session => Session, User => User, Entity => Id, Kind => Kind, Workspace => Workspace, Permission => Perm); end if; end; end loop; end Add_Permission; -- ------------------------------ -- The `On_Create` procedure is called by `Notify_Create` to notify the creation of the user. -- ------------------------------ overriding procedure On_Create (Module : in Workspace_Module; User : in AWA.Users.Models.User_Ref'Class) is Ctx : constant ASC.Service_Context_Access := ASC.Current; Kind : ADO.Entity_Type; begin if Module.Allow_WS_Create then declare DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); begin Ctx.Start; Kind := ADO.Sessions.Entities.Find_Entity_Type (DB, Models.WORKSPACE_TABLE); Module.Perm_Manager.Add_Permission (Session => DB, User => User.Get_Id, Entity => ADO.NO_IDENTIFIER, Kind => Kind, Workspace => ADO.NO_IDENTIFIER, Permission => ACL_Create_Workspace.Permission); Ctx.Commit; end; end if; end On_Create; end AWA.Workspaces.Modules;
package GESTE_Fonts.FreeSerifItalic6pt7b is Font : constant Bitmap_Font_Ref; private FreeSerifItalic6pt7bBitmaps : aliased constant Font_Bitmap := ( 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#08#, 16#01#, 16#00#, 16#20#, 16#08#, 16#01#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#50#, 16#0A#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#28#, 16#09#, 16#03#, 16#E0#, 16#48#, 16#1F#, 16#81#, 16#40#, 16#48#, 16#0A#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#80#, 16#58#, 16#15#, 16#01#, 16#80#, 16#30#, 16#05#, 16#00#, 16#A0#, 16#54#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#62#, 16#1B#, 16#82#, 16#60#, 16#55#, 16#8F#, 16#50#, 16#2A#, 16#09#, 16#41#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#02#, 16#80#, 16#60#, 16#1B#, 16#8D#, 16#21#, 16#18#, 16#23#, 16#03#, 16#B0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#0D#, 16#00#, 16#C0#, 16#3C#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#10#, 16#0F#, 16#C0#, 16#40#, 16#08#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#10#, 16#02#, 16#00#, 16#80#, 16#20#, 16#04#, 16#01#, 16#00#, 16#20#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#48#, 16#11#, 16#02#, 16#20#, 16#44#, 16#11#, 16#82#, 16#20#, 16#2C#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#, 16#02#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#12#, 16#00#, 16#40#, 16#08#, 16#02#, 16#00#, 16#80#, 16#20#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#58#, 16#03#, 16#00#, 16#80#, 16#38#, 16#01#, 16#00#, 16#20#, 16#08#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#02#, 16#01#, 16#C0#, 16#48#, 16#12#, 16#03#, 16#E0#, 16#08#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#08#, 16#01#, 16#80#, 16#08#, 16#01#, 16#00#, 16#20#, 16#08#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#30#, 16#08#, 16#02#, 16#C0#, 16#68#, 16#11#, 16#82#, 16#20#, 16#44#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#78#, 16#11#, 16#00#, 16#40#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#80#, 16#48#, 16#09#, 16#01#, 16#40#, 16#30#, 16#19#, 16#02#, 16#20#, 16#24#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#80#, 16#C8#, 16#11#, 16#02#, 16#20#, 16#4C#, 16#0F#, 16#00#, 16#60#, 16#18#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#, 16#18#, 16#0C#, 16#01#, 16#80#, 16#0C#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#18#, 16#00#, 16#C0#, 16#30#, 16#18#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#01#, 16#00#, 16#20#, 16#08#, 16#02#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#0B#, 16#62#, 16#54#, 16#52#, 16#8A#, 16#51#, 16#4A#, 16#17#, 16#81#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#10#, 16#03#, 16#00#, 16#A0#, 16#24#, 16#07#, 16#81#, 16#10#, 16#22#, 16#0C#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#04#, 16#81#, 16#10#, 16#3C#, 16#04#, 16#81#, 16#98#, 16#22#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#0C#, 16#43#, 16#08#, 16#40#, 16#08#, 16#01#, 16#00#, 16#22#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#04#, 16#C1#, 16#08#, 16#21#, 16#04#, 16#21#, 16#8C#, 16#23#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#04#, 16#01#, 16#20#, 16#3C#, 16#04#, 16#01#, 16#80#, 16#21#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#04#, 16#01#, 16#20#, 16#38#, 16#04#, 16#01#, 16#80#, 16#20#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#0C#, 16#43#, 16#00#, 16#40#, 16#08#, 16#F1#, 16#08#, 16#21#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#77#, 16#04#, 16#41#, 16#08#, 16#3F#, 16#04#, 16#41#, 16#88#, 16#21#, 16#0E#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#04#, 16#01#, 16#00#, 16#20#, 16#04#, 16#01#, 16#80#, 16#20#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#02#, 16#00#, 16#C0#, 16#10#, 16#02#, 16#00#, 16#40#, 16#10#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#77#, 16#04#, 16#81#, 16#20#, 16#38#, 16#05#, 16#01#, 16#A0#, 16#22#, 16#0E#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#04#, 16#01#, 16#00#, 16#20#, 16#04#, 16#01#, 16#80#, 16#21#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#61#, 16#C4#, 16#31#, 16#8C#, 16#52#, 16#8A#, 16#91#, 16#36#, 16#24#, 16#8D#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#63#, 16#04#, 16#41#, 16#C8#, 16#2A#, 16#09#, 16#41#, 16#18#, 16#22#, 16#0C#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#0C#, 16#43#, 16#08#, 16#41#, 16#18#, 16#63#, 16#08#, 16#22#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#04#, 16#81#, 16#10#, 16#22#, 16#07#, 16#81#, 16#80#, 16#20#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#0C#, 16#43#, 16#08#, 16#41#, 16#08#, 16#63#, 16#08#, 16#22#, 16#02#, 16#80#, 16#A2#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#0C#, 16#81#, 16#10#, 16#3C#, 16#05#, 16#01#, 16#B0#, 16#22#, 16#0E#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#78#, 16#19#, 16#03#, 16#00#, 16#30#, 16#03#, 16#02#, 16#20#, 16#44#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#12#, 16#40#, 16#40#, 16#18#, 16#02#, 16#00#, 16#40#, 16#08#, 16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#73#, 16#0C#, 16#41#, 16#08#, 16#21#, 16#04#, 16#41#, 16#88#, 16#31#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#63#, 16#0C#, 16#40#, 16#90#, 16#12#, 16#02#, 16#80#, 16#60#, 16#0C#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#6E#, 16#CC#, 16#88#, 16#92#, 16#16#, 16#43#, 16#50#, 16#64#, 16#08#, 16#81#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E6#, 16#0C#, 16#80#, 16#A0#, 16#18#, 16#03#, 16#00#, 16#B0#, 16#22#, 16#0E#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#66#, 16#04#, 16#80#, 16#A0#, 16#18#, 16#02#, 16#00#, 16#40#, 16#08#, 16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FC#, 16#11#, 16#00#, 16#40#, 16#08#, 16#02#, 16#00#, 16#80#, 16#22#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#08#, 16#01#, 16#00#, 16#20#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#08#, 16#01#, 16#00#, 16#10#, 16#02#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#14#, 16#02#, 16#80#, 16#88#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#34#, 16#09#, 16#03#, 16#20#, 16#4E#, 16#0E#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#58#, 16#0C#, 16#81#, 16#30#, 16#4C#, 16#0F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#08#, 16#02#, 16#00#, 16#40#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#01#, 16#00#, 16#20#, 16#38#, 16#09#, 16#03#, 16#20#, 16#4A#, 16#06#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#09#, 16#03#, 16#C0#, 16#40#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#20#, 16#04#, 16#01#, 16#00#, 16#78#, 16#04#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#09#, 16#01#, 16#60#, 16#18#, 16#04#, 16#01#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#58#, 16#0D#, 16#01#, 16#20#, 16#26#, 16#09#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#30#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#60#, 16#04#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#5C#, 16#0A#, 16#01#, 16#80#, 16#28#, 16#09#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#30#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#5B#, 16#0D#, 16#A1#, 16#24#, 16#25#, 16#09#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#58#, 16#0D#, 16#01#, 16#20#, 16#26#, 16#09#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#08#, 16#83#, 16#20#, 16#44#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#58#, 16#0C#, 16#81#, 16#20#, 16#2C#, 16#0F#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#0D#, 16#03#, 16#20#, 16#4C#, 16#0F#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#58#, 16#0C#, 16#01#, 16#00#, 16#20#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#0A#, 16#00#, 16#80#, 16#50#, 16#06#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#60#, 16#08#, 16#01#, 16#00#, 16#30#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#48#, 16#09#, 16#01#, 16#60#, 16#5A#, 16#0D#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#48#, 16#05#, 16#00#, 16#A0#, 16#18#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#49#, 16#07#, 16#20#, 16#E8#, 16#13#, 16#04#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#68#, 16#07#, 16#00#, 16#80#, 16#30#, 16#09#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#68#, 16#04#, 16#80#, 16#A0#, 16#14#, 16#01#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#04#, 16#01#, 16#00#, 16#20#, 16#0C#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#04#, 16#01#, 16#00#, 16#20#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#80#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#); Font_D : aliased constant Bitmap_Font := ( Bytes_Per_Glyph => 19, Glyph_Width => 11, Glyph_Height => 14, Data => FreeSerifItalic6pt7bBitmaps'Access); Font : constant Bitmap_Font_Ref := Font_D'Access; end GESTE_Fonts.FreeSerifItalic6pt7b;
-- The Cupcake GUI Toolkit -- (c) Kristian Klomsten Skordal 2012 <kristian.skordal@gmail.com> -- Report bugs and issues on <http://github.com/skordal/cupcake/issues> -- vim:ts=3:sw=3:et:si:sta with Ada.Text_IO; with Ada.Unchecked_Deallocation; package body Cupcake.Windows is -- Creates a new window: function New_Window (Width, Height : in Positive; Title : in String) return Window is Size : constant Primitives.Dimension := (Width, Height); begin return New_Window (Size, Title); end New_Window; -- Creates a new window: function New_Window (Size : in Primitives.Dimension; Title : in String) return Window is Retval : constant Window := new Window_Record; begin Retval.Backend_Data := Backends.Get_Backend.New_Window (Title, Size); Retval.ID := Backends.Get_Backend.Get_Window_ID (Retval.Backend_Data); Retval.Size := Size; return Retval; end New_Window; -- Destroys a window: procedure Destroy (Object : not null access Window_Record) is -- Deallocation procedure for window records: type Window_Access is access all Window_Record; procedure Free is new Ada.Unchecked_Deallocation ( Object => Window_Record, Name => Window_Access); Win : Window_Access := Window_Access (Object); begin Object.Set_Visible (False); Backends.Get_Backend.Destroy_Window (Object.Backend_Data); Free (Win); end Destroy; -- Sets the visibility of a window: procedure Set_Visible (This : access Window_Record'Class; Visible : in Boolean := True) is use Window_Lists; Window_Cursor : Cursor := Visible_Window_List.Find (Item => This); begin if Visible and not Has_Element (Window_Cursor) then Visible_Window_List.Append (This); Backends.Get_Backend.Set_Window_Visibility ( This.Backend_Data, Visible); elsif (not Visible and Has_Element (Window_Cursor)) and then Element (Window_Cursor).Close_Handler then Visible_Window_List.Delete (Window_Cursor); Backends.Get_Backend.Set_Window_Visibility (This.Backend_Data, Visible); if Visible_Window_List.Is_Empty then Backends.Get_Backend.Exit_Main_Loop; end if; end if; end Set_Visible; -- Gets the size of a window: function Get_Size (This : in Window_Record'Class) return Primitives.Dimension is begin return This.Size; end Get_Size; -- Sets the size of a window: procedure Set_Size (This : in out Window_Record'Class; Size : in Primitives.Dimension) is begin Backends.Get_Backend.Set_Window_Size (This.Backend_Data, Size); end Set_Size; -- Gets the background color of a window: function Get_Background_Color (This : in Window_Record'Class) return Colors.Color is begin return This.Background_Color; end Get_Background_Color; -- Sets the background color of a window: procedure Set_Background_Color (This : out Window_Record'Class; Color : in Colors.Color) is begin This.Background_Color := Color; end Set_Background_Color; -- Expose event handler: procedure Expose_Handler (This : in Window_Record'Class) is begin Backends.Get_Backend.Fill_Area (This.Backend_Data, ((0, 0), This.Size), This.Background_Color); end Expose_Handler; -- Resize event handler: procedure Resize_Handler (This : in out Window_Record'Class; New_Size : in Primitives.Dimension) is begin This.Size := New_Size; end Resize_Handler; -- Window close event handler: function Close_Handler (This : in Window_Record'Class) return Boolean is begin return True; end Close_Handler; -- Posts an expose event to a window: procedure Post_Expose (ID : in Backends.Window_ID_Type) is Target : constant Window := Get_Visible_Window (ID); begin if Target /= null then Target.Post_Expose; end if; end Post_Expose; -- Posts an expose event to a window: procedure Post_Expose (This : in Window_Record'Class) is begin if Debug_Mode then Ada.Text_IO.Put_Line ("[Cupcake.Windows.Post_Expose] " & "Expose received for window ID " & Backends.Window_ID_Type'Image (This.ID)); end if; This.Expose_Handler; end Post_Expose; -- Posts a resize event to a window: procedure Post_Resize (ID : in Backends.Window_ID_Type; Width, Height : in Natural) is begin Post_Resize (ID, (Width, Height)); end Post_Resize; -- Posts a resize event to a window: procedure Post_Resize (ID : in Backends.Window_ID_Type; New_Size : in Primitives.Dimension) is use Primitives; Target : constant Window := Get_Visible_Window (ID); begin if Target /= null and then Target.Size /= New_Size then if Debug_Mode then Ada.Text_IO.Put_Line ("[Cupcake.Windows.Post_Resize] " & "Resize event received for window ID " & Backends.Window_ID_Type'Image (ID)); end if; Target.Resize_Handler (New_Size); end if; end Post_Resize; -- Posts a close event to a window: procedure Post_Close_Event (ID : in Backends.Window_ID_Type) is Target : constant Window := Get_Visible_Window (ID); begin if Target /= null then if Debug_Mode then Ada.Text_IO.Put_Line ("[Cupcake.Windows.Post_Close_Event] " & "Close request received for window ID " & Backends.Window_ID_Type'Image (ID)); end if; Target.Set_Visible (False); end if; end Post_Close_Event; -- Gets a pointer to a visible window or null if no window was found: function Get_Visible_Window (ID : in Backends.Window_ID_Type) return Window is use Backends; begin for Win of Visible_Window_List loop if Win.ID = ID then return Win; end if; end loop; return null; end Get_Visible_Window; -- Gets the backend data for a visible window or null if no window was -- found: function Get_Visible_Window (ID : in Backends.Window_ID_Type) return Backends.Window_Data_Pointer is Target : constant Window := Get_Visible_Window (ID); begin if Target /= null then return Target.Backend_Data; else return Backends.Null_Window_Data_Pointer; end if; end Get_Visible_Window; end Cupcake.Windows;
with Irc.Bot; with Irc.Commands; with Irc.Message; with Ada.Strings.Unbounded; -- Some custom commands (commands.ads) with Commands; procedure Host_Bot is Bot : Irc.Bot.Connection; begin Bot := Irc.Bot.Create ("irc.tenthbit.net", 6667, Nick => "hostbot"); -- Set some bot administrators. The '!' is just to make sure the nick -- foosomeoneelse doesn't get admin rights. You could include host/cloak -- if you wanted. Bot.Add_Administrator ("foo!"); Bot.Add_Administrator ("bar!"); -- Add channels to join on connect Bot.Add_Default_Channel ("#bots"); -- Installs the default command set Irc.Commands.Install_Commands (Bot); -- Setup our hostname command callback Bot.On_Privmsg ("$host", Commands.Host'Access); -- Connect the socket and identify the bot (send NICK and USER) Bot.Connect; Bot.Identify; -- Loop until program is killed or an error occurs loop declare Line : Ada.Strings.Unbounded.Unbounded_String; Msg : Irc.Message.Message; begin Bot.Read_Line (Line); Msg := Irc.Message.Parse_Line (Line); Bot.Do_Message (Msg); exception when Irc.Message.Parse_Error => exit; end; end loop; -- Close the socket Bot.Disconnect; end Host_Bot;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <denkpadje@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. generic type Index_Type is mod <>; package Orka.Rendering.Buffers.Mapped.Persistent is pragma Preelaborate; type Persistent_Mapped_Buffer is new Mapped_Buffer with private; function Create_Buffer (Kind : Orka.Types.Element_Type; Length : Natural; Mode : IO_Mode) return Persistent_Mapped_Buffer with Post => Create_Buffer'Result.Length = Length; -- Create a persistent mapped buffer for only writes or only reads -- -- The actual size of the buffer is n * Length where n is the number -- of regions. Each region has an index (>= 0). -- -- After writing or reading, you must call Advance_Index (once per frame). -- -- If Mode = Write, then you must wait for a fence to complete before -- writing and then set the fence after the drawing or dispatch commands -- which uses the mapped buffer. -- -- If Mode = Read, then you must set a fence after the drawing or -- dispatch commands that write to the buffer and then wait for the -- fence to complete before reading the data. overriding function Length (Object : Persistent_Mapped_Buffer) return Natural; -- Number of elements in the buffer -- -- Will be less than the actual size of the buffer due to the n regions. procedure Advance_Index (Object : in out Persistent_Mapped_Buffer); private type Persistent_Mapped_Buffer is new Mapped_Buffer with record Index : Index_Type; end record; end Orka.Rendering.Buffers.Mapped.Persistent;
with Ada.Text_IO; use Ada.Text_IO; procedure Test is type t is record a, a: integer; end record; begin new_line; end;
-- ---------------------------------------------------------------------------- -- Note this is an implementation package and is subject to change att any time. -- ---------------------------------------------------------------------------- with DDS.ReadCondition; with DDS.Request_Reply.Impl; private package DDS.Request_Reply.Requester.Impl is type Ref is abstract limited new DDS.Request_Reply.Impl.Ref and DDS.Request_Reply.Requester.Ref with record null; end record; type Ref_Access is access all Ref'Class; function Touch_Samples (Self : not null access Ref; Max_Count : DDS.Integer; Read_Condition : DDS.ReadCondition.Ref_Access) return Integer; function Wait_For_Any_Sample (Self : not null access Ref; Max_Wait : DDS.Duration_T; Min_Sample_Count : DDS.Integer) return DDS.ReturnCode_T; end DDS.Request_Reply.Requester.Impl;
with PathPackage; use PathPackage; with StrategyPackage; use StrategyPackage; package PositionPackage is type Position is new Path with record omega : IntArrayPtr := null; end record; --type PositionPtr is access all Position; ROOT : access Position := null; ---------------------------------------------------------------------------- -- Path implementation ---------------------------------------------------------------------------- function add(p1, path: Position) return Position; function sub(p1, p2: Position) return Position; function inverse(p:Position) return Position; function length(p: Position) return Natural; function getHead(p: Position) return Integer; function getTail(p: Position) return Position; function conc(p: Position; i: Integer) return Position; function getCanonicalPath(p: Position) return Position; function toIntArray(p: Position) return IntArrayPtr; ---------------------------------------------------------------------------- function make return Position; function makeFromSubarray(src : not null IntArrayPtr ; srcIndex: Integer ; length: Natural) return Position; function makeFromArray(arr: IntArrayPtr) return Position; function makeFromPath(p : Position) return Position; function clone(pos: Position) return Position; function hashCode(p: Position) return Integer; function equals(p1, p2: Position) return Boolean; function compare(p1: Position; path: Position) return Integer; function toString(p: Position) return String; function up(pos: Position) return Position; function down(pos: Position; i: Integer) return Position; function hasPrefix(pos, pref: Position) return Boolean; function changePrefix(pos, oldprefix, prefix: Position) return Position; function getOmega(p: Position; v: Strategy'Class) return Strategy'Class; function getOmegaPath(pos: Position; v: Strategy'Class) return StrategyPtr; --function getReplace(pos: Position; t: ObjectPtr) return StrategyPtr; --function getSubterm return StrategyPtr; ---------------------------------------------------------------------------- end PositionPackage;
with Interfaces.C.Strings, Ada.Strings.Unbounded, Ada.Containers, System; use Ada.Strings.Unbounded; use type System.Address, Interfaces.C.int, Interfaces.C.Strings.chars_ptr, Ada.Containers.Count_Type; package body FLTK.Text_Buffers is function new_fl_text_buffer (RS, PGS : in Interfaces.C.int) return System.Address; pragma Import (C, new_fl_text_buffer, "new_fl_text_buffer"); pragma Inline (new_fl_text_buffer); procedure free_fl_text_buffer (TB : in System.Address); pragma Import (C, free_fl_text_buffer, "free_fl_text_buffer"); pragma Inline (free_fl_text_buffer); procedure fl_text_buffer_add_modify_callback (TB, CB, UD : in System.Address); pragma Import (C, fl_text_buffer_add_modify_callback, "fl_text_buffer_add_modify_callback"); pragma Inline (fl_text_buffer_add_modify_callback); procedure fl_text_buffer_add_predelete_callback (TB, CB, UD : in System.Address); pragma Import (C, fl_text_buffer_add_predelete_callback, "fl_text_buffer_add_predelete_callback"); pragma Inline (fl_text_buffer_add_predelete_callback); procedure fl_text_buffer_call_modify_callbacks (TB : in System.Address); pragma Import (C, fl_text_buffer_call_modify_callbacks, "fl_text_buffer_call_modify_callbacks"); pragma Inline (fl_text_buffer_call_modify_callbacks); procedure fl_text_buffer_call_predelete_callbacks (TB : in System.Address); pragma Import (C, fl_text_buffer_call_predelete_callbacks, "fl_text_buffer_call_predelete_callbacks"); pragma Inline (fl_text_buffer_call_predelete_callbacks); function fl_text_buffer_loadfile (TB : in System.Address; N : in Interfaces.C.char_array; B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_loadfile, "fl_text_buffer_loadfile"); pragma Inline (fl_text_buffer_loadfile); function fl_text_buffer_appendfile (TB : in System.Address; N : in Interfaces.C.char_array; B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_appendfile, "fl_text_buffer_appendfile"); pragma Inline (fl_text_buffer_appendfile); function fl_text_buffer_insertfile (TB : in System.Address; N : in Interfaces.C.char_array; P, B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_insertfile, "fl_text_buffer_insertfile"); pragma Inline (fl_text_buffer_insertfile); function fl_text_buffer_outputfile (TB : in System.Address; N : in Interfaces.C.char_array; F, T : in Interfaces.C.int; B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_outputfile, "fl_text_buffer_outputfile"); pragma Inline (fl_text_buffer_outputfile); function fl_text_buffer_savefile (TB : in System.Address; N : in Interfaces.C.char_array; B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_savefile, "fl_text_buffer_savefile"); pragma Inline (fl_text_buffer_savefile); procedure fl_text_buffer_insert (TB : in System.Address; P : in Interfaces.C.int; I : in Interfaces.C.char_array); pragma Import (C, fl_text_buffer_insert, "fl_text_buffer_insert"); pragma Inline (fl_text_buffer_insert); procedure fl_text_buffer_append (TB : in System.Address; I : in Interfaces.C.char_array); pragma Import (C, fl_text_buffer_append, "fl_text_buffer_append"); pragma Inline (fl_text_buffer_append); procedure fl_text_buffer_replace (TB : in System.Address; S, F : in Interfaces.C.int; T : in Interfaces.C.char_array); pragma Import (C, fl_text_buffer_replace, "fl_text_buffer_replace"); pragma Inline (fl_text_buffer_replace); procedure fl_text_buffer_remove (TB : in System.Address; S, F : in Interfaces.C.int); pragma Import (C, fl_text_buffer_remove, "fl_text_buffer_remove"); pragma Inline (fl_text_buffer_remove); function fl_text_buffer_get_text (TB : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_text_buffer_get_text, "fl_text_buffer_get_text"); pragma Inline (fl_text_buffer_get_text); procedure fl_text_buffer_set_text (TB : in System.Address; T : in Interfaces.C.char_array); pragma Import (C, fl_text_buffer_set_text, "fl_text_buffer_set_text"); pragma Inline (fl_text_buffer_set_text); function fl_text_buffer_byte_at (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.char; pragma Import (C, fl_text_buffer_byte_at, "fl_text_buffer_byte_at"); pragma Inline (fl_text_buffer_byte_at); function fl_text_buffer_char_at (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.unsigned; pragma Import (C, fl_text_buffer_char_at, "fl_text_buffer_char_at"); pragma Inline (fl_text_buffer_char_at); function fl_text_buffer_text_range (TB : in System.Address; S, F : in Interfaces.C.int) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_text_buffer_text_range, "fl_text_buffer_text_range"); pragma Inline (fl_text_buffer_text_range); function fl_text_buffer_next_char (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_next_char, "fl_text_buffer_next_char"); pragma Inline (fl_text_buffer_next_char); function fl_text_buffer_prev_char (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_prev_char, "fl_text_buffer_prev_char"); pragma Inline (fl_text_buffer_prev_char); function fl_text_buffer_count_displayed_characters (TB : in System.Address; S, F : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_count_displayed_characters, "fl_text_buffer_count_displayed_characters"); pragma Inline (fl_text_buffer_count_displayed_characters); function fl_text_buffer_count_lines (TB : in System.Address; S, F : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_count_lines, "fl_text_buffer_count_lines"); pragma Inline (fl_text_buffer_count_lines); function fl_text_buffer_length (TB : in System.Address) return Interfaces.C.int; pragma Import (C, fl_text_buffer_length, "fl_text_buffer_length"); pragma Inline (fl_text_buffer_length); function fl_text_buffer_get_tab_distance (TB : in System.Address) return Interfaces.C.int; pragma Import (C, fl_text_buffer_get_tab_distance, "fl_text_buffer_get_tab_distance"); pragma Inline (fl_text_buffer_get_tab_distance); procedure fl_text_buffer_set_tab_distance (TB : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_text_buffer_set_tab_distance, "fl_text_buffer_set_tab_distance"); pragma Inline (fl_text_buffer_set_tab_distance); function fl_text_buffer_selection_position (TB : in System.Address; S, E : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_selection_position, "fl_text_buffer_selection_position"); pragma Inline (fl_text_buffer_selection_position); function fl_text_buffer_secondary_selection_position (TB : in System.Address; S, E : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_secondary_selection_position, "fl_text_buffer_secondary_selection_position"); pragma Inline (fl_text_buffer_secondary_selection_position); procedure fl_text_buffer_select (TB : in System.Address; S, E : in Interfaces.C.int); pragma Import (C, fl_text_buffer_select, "fl_text_buffer_select"); pragma Inline (fl_text_buffer_select); procedure fl_text_buffer_secondary_select (TB : in System.Address; S, E : in Interfaces.C.int); pragma Import (C, fl_text_buffer_secondary_select, "fl_text_buffer_secondary_select"); pragma Inline (fl_text_buffer_secondary_select); function fl_text_buffer_selected (TB : in System.Address) return Interfaces.C.int; pragma Import (C, fl_text_buffer_selected, "fl_text_buffer_selected"); pragma Inline (fl_text_buffer_selected); function fl_text_buffer_secondary_selected (TB : in System.Address) return Interfaces.C.int; pragma Import (C, fl_text_buffer_secondary_selected, "fl_text_buffer_secondary_selected"); pragma Inline (fl_text_buffer_secondary_selected); function fl_text_buffer_selection_text (TB : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_text_buffer_selection_text, "fl_text_buffer_selection_text"); pragma Inline (fl_text_buffer_selection_text); function fl_text_buffer_secondary_selection_text (TB : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_text_buffer_secondary_selection_text, "fl_text_buffer_secondary_selection_text"); pragma Inline (fl_text_buffer_secondary_selection_text); procedure fl_text_buffer_replace_selection (TB : in System.Address; T : in Interfaces.C.char_array); pragma Import (C, fl_text_buffer_replace_selection, "fl_text_buffer_replace_selection"); pragma Inline (fl_text_buffer_replace_selection); procedure fl_text_buffer_replace_secondary_selection (TB : in System.Address; T : in Interfaces.C.char_array); pragma Import (C, fl_text_buffer_replace_secondary_selection, "fl_text_buffer_replace_secondary_selection"); pragma Inline (fl_text_buffer_replace_secondary_selection); procedure fl_text_buffer_remove_selection (TB : in System.Address); pragma Import (C, fl_text_buffer_remove_selection, "fl_text_buffer_remove_selection"); pragma Inline (fl_text_buffer_remove_selection); procedure fl_text_buffer_remove_secondary_selection (TB : in System.Address); pragma Import (C, fl_text_buffer_remove_secondary_selection, "fl_text_buffer_remove_secondary_selection"); pragma Inline (fl_text_buffer_remove_secondary_selection); procedure fl_text_buffer_unselect (TB : in System.Address); pragma Import (C, fl_text_buffer_unselect, "fl_text_buffer_unselect"); pragma Inline (fl_text_buffer_unselect); procedure fl_text_buffer_secondary_unselect (TB : in System.Address); pragma Import (C, fl_text_buffer_secondary_unselect, "fl_text_buffer_secondary_unselect"); pragma Inline (fl_text_buffer_secondary_unselect); procedure fl_text_buffer_highlight (TB : in System.Address; F, T : in Interfaces.C.int); pragma Import (C, fl_text_buffer_highlight, "fl_text_buffer_highlight"); pragma Inline (fl_text_buffer_highlight); function fl_text_buffer_highlight_text (TB : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_text_buffer_highlight_text, "fl_text_buffer_highlight_text"); pragma Inline (fl_text_buffer_highlight_text); procedure fl_text_buffer_unhighlight (TB : in System.Address); pragma Import (C, fl_text_buffer_unhighlight, "fl_text_buffer_unhighlight"); pragma Inline (fl_text_buffer_unhighlight); function fl_text_buffer_findchar_forward (TB : in System.Address; SP : in Interfaces.C.int; IT : in Interfaces.C.unsigned; FP : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_findchar_forward, "fl_text_buffer_findchar_forward"); pragma Inline (fl_text_buffer_findchar_forward); function fl_text_buffer_findchar_backward (TB : in System.Address; SP : in Interfaces.C.int; IT : in Interfaces.C.unsigned; FP : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_findchar_backward, "fl_text_buffer_findchar_backward"); pragma Inline (fl_text_buffer_findchar_backward); function fl_text_buffer_search_forward (TB : in System.Address; SP : in Interfaces.C.int; IT : in Interfaces.C.char_array; FP : out Interfaces.C.int; CA : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_search_forward, "fl_text_buffer_search_forward"); pragma Inline (fl_text_buffer_search_forward); function fl_text_buffer_search_backward (TB : in System.Address; SP : in Interfaces.C.int; IT : in Interfaces.C.char_array; FP : out Interfaces.C.int; CA : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_search_backward, "fl_text_buffer_search_backward"); pragma Inline (fl_text_buffer_search_backward); function fl_text_buffer_word_start (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_word_start, "fl_text_buffer_word_start"); pragma Inline (fl_text_buffer_word_start); function fl_text_buffer_word_end (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_word_end, "fl_text_buffer_word_end"); pragma Inline (fl_text_buffer_word_end); function fl_text_buffer_line_start (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_line_start, "fl_text_buffer_line_start"); pragma Inline (fl_text_buffer_line_start); function fl_text_buffer_line_end (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_line_end, "fl_text_buffer_line_end"); pragma Inline (fl_text_buffer_line_end); function fl_text_buffer_line_text (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_text_buffer_line_text, "fl_text_buffer_line_text"); pragma Inline (fl_text_buffer_line_text); function fl_text_buffer_skip_lines (TB : in System.Address; S, L : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_skip_lines, "fl_text_buffer_skip_lines"); pragma Inline (fl_text_buffer_skip_lines); function fl_text_buffer_rewind_lines (TB : in System.Address; S, L : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_rewind_lines, "fl_text_buffer_rewind_lines"); pragma Inline (fl_text_buffer_rewind_lines); function fl_text_buffer_skip_displayed_characters (TB : in System.Address; S, N : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_skip_displayed_characters, "fl_text_buffer_skip_displayed_characters"); pragma Inline (fl_text_buffer_skip_displayed_characters); procedure fl_text_buffer_canundo (TB : in System.Address; F : in Interfaces.C.char); pragma Import (C, fl_text_buffer_canundo, "fl_text_buffer_canundo"); pragma Inline (fl_text_buffer_canundo); procedure fl_text_buffer_copy (TB, TB2 : in System.Address; S, F, I : in Interfaces.C.int); pragma Import (C, fl_text_buffer_copy, "fl_text_buffer_copy"); pragma Inline (fl_text_buffer_copy); function fl_text_buffer_utf8_align (TB : in System.Address; P : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_buffer_utf8_align, "fl_text_buffer_utf8_align"); pragma Inline (fl_text_buffer_utf8_align); procedure Modify_Callback_Hook (Pos : in Interfaces.C.int; Inserted, Deleted, Restyled : in Interfaces.C.int; Text : in Interfaces.C.Strings.chars_ptr; UD : in System.Address) is Action : Modification; Place : Position := Position (Pos); Length : Natural; Deleted_Text : Unbounded_String := To_Unbounded_String (""); Ada_Text_Buffer : access Text_Buffer := Text_Buffer_Convert.To_Pointer (UD); begin if Ada_Text_Buffer.CB_Active then if Inserted > 0 then Length := Natural (Inserted); Action := Insert; elsif Deleted > 0 then Length := Natural (Deleted); Action := Delete; if Text /= Interfaces.C.Strings.Null_Ptr then Deleted_Text := To_Unbounded_String (Interfaces.C.Strings.Value (Text)); end if; elsif Restyled > 0 then Length := Natural (Restyled); Action := Restyle; else Length := 0; Action := None; end if; for CB of Ada_Text_Buffer.Modify_CBs loop CB.all (Action, Place, Length, To_String (Deleted_Text)); end loop; end if; end Modify_Callback_Hook; procedure Predelete_Callback_Hook (Pos, Deleted : in Interfaces.C.int; UD : in System.Address) is Place : Position := Position (Pos); Length : Natural := Natural (Deleted); Ada_Text_Buffer : access Text_Buffer := Text_Buffer_Convert.To_Pointer (UD); begin if Ada_Text_Buffer.CB_Active then for CB of Ada_Text_Buffer.Predelete_CBs loop CB.all (Place, Length); end loop; end if; end Predelete_Callback_Hook; procedure Finalize (This : in out Text_Buffer) is begin if This.Void_Ptr /= System.Null_Address and then This in Text_Buffer'Class then free_fl_text_buffer (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; end Finalize; package body Forge is function Create (Requested_Size : in Natural := 0; Preferred_Gap_Size : in Natural := 1024) return Text_Buffer is begin return This : Text_Buffer do This.Void_Ptr := new_fl_text_buffer (Interfaces.C.int (Requested_Size), Interfaces.C.int (Preferred_Gap_Size)); This.Modify_CBs := Modify_Vectors.Empty_Vector; This.Predelete_CBs := Predelete_Vectors.Empty_Vector; This.CB_Active := True; fl_text_buffer_add_modify_callback (This.Void_Ptr, Modify_Callback_Hook'Address, This'Address); fl_text_buffer_add_predelete_callback (This.Void_Ptr, Predelete_Callback_Hook'Address, This'Address); end return; end Create; end Forge; procedure Add_Modify_Callback (This : in out Text_Buffer; Func : in Modify_Callback) is begin This.Modify_CBs.Append (Func); end Add_Modify_Callback; procedure Add_Predelete_Callback (This : in out Text_Buffer; Func : in Predelete_Callback) is begin This.Predelete_CBs.Append (Func); end Add_Predelete_Callback; procedure Remove_Modify_Callback (This : in out Text_Buffer; Func : in Modify_Callback) is begin for I in reverse This.Modify_CBs.First_Index .. This.Modify_CBs.Last_Index loop if This.Modify_CBs.Element (I) = Func then This.Modify_CBs.Delete (I); return; end if; end loop; end Remove_Modify_Callback; procedure Remove_Predelete_Callback (This : in out Text_Buffer; Func : in Predelete_Callback) is begin for I in reverse This.Predelete_CBs.First_Index .. This.Predelete_CBs.Last_Index loop if This.Predelete_CBs.Element (I) = Func then This.Predelete_CBs.Delete (I); return; end if; end loop; end Remove_Predelete_Callback; procedure Call_Modify_Callbacks (This : in out Text_Buffer) is begin fl_text_buffer_call_modify_callbacks (This.Void_Ptr); end Call_Modify_Callbacks; procedure Call_Predelete_Callbacks (This : in out Text_Buffer) is begin fl_text_buffer_call_predelete_callbacks (This.Void_Ptr); end Call_Predelete_Callbacks; procedure Enable_Callbacks (This : in out Text_Buffer) is begin This.CB_Active := True; end Enable_Callbacks; procedure Disable_Callbacks (This : in out Text_Buffer) is begin This.CB_Active := False; end Disable_Callbacks; procedure Load_File (This : in out Text_Buffer; Name : in String; Buffer : in Natural := 128 * 1024) is Err_No : Interfaces.C.int := fl_text_buffer_loadfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error; end if; end Load_File; procedure Append_File (This : in out Text_Buffer; Name : in String; Buffer : in Natural := 128 * 1024) is Err_No : Interfaces.C.int := fl_text_buffer_appendfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error; end if; end Append_File; procedure Insert_File (This : in out Text_Buffer; Name : in String; Place : in Position; Buffer : in Natural := 128 * 1024) is Err_No : Interfaces.C.int := fl_text_buffer_insertfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Place), Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error; end if; end Insert_File; procedure Output_File (This : in Text_Buffer; Name : in String; Start, Finish : in Position; Buffer : in Natural := 128 * 1024) is Err_No : Interfaces.C.int := fl_text_buffer_outputfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Start), Interfaces.C.int (Finish), Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error; end if; end Output_File; procedure Save_File (This : in Text_Buffer; Name : in String; Buffer : in Natural := 128 * 1024) is Err_No : Interfaces.C.int := fl_text_buffer_savefile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error; end if; end Save_File; procedure Insert_Text (This : in out Text_Buffer; Place : in Position; Text : in String) is begin fl_text_buffer_insert (This.Void_Ptr, Interfaces.C.int (Place), Interfaces.C.To_C (Text)); end Insert_Text; procedure Append_Text (This : in out Text_Buffer; Text : in String) is begin fl_text_buffer_append (This.Void_Ptr, Interfaces.C.To_C (Text)); end Append_Text; procedure Replace_Text (This : in out Text_Buffer; Start, Finish : in Position; Text : in String) is begin fl_text_buffer_replace (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish), Interfaces.C.To_C (Text)); end Replace_Text; procedure Remove_Text (This : in out Text_Buffer; Start, Finish : in Position) is begin fl_text_buffer_remove (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); end Remove_Text; function Get_Entire_Text (This : in Text_Buffer) return String is Raw : Interfaces.C.Strings.chars_ptr := fl_text_buffer_get_text (This.Void_Ptr); begin if Raw = Interfaces.C.Strings.Null_Ptr then return ""; else declare Ada_String : String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; end; end if; end Get_Entire_Text; procedure Set_Entire_Text (This : in out Text_Buffer; Text : in String) is begin fl_text_buffer_set_text (This.Void_Ptr, Interfaces.C.To_C (Text)); end Set_Entire_Text; function Byte_At (This : in Text_Buffer; Place : in Position) return Character is begin return Character'Val (Interfaces.C.char'Pos (fl_text_buffer_byte_at (This.Void_Ptr, Interfaces.C.int (Place)))); end Byte_At; function Character_At (This : in Text_Buffer; Place : in Position) return Character is begin return Character'Val (fl_text_buffer_char_at (This.Void_Ptr, Interfaces.C.int (Place))); end Character_At; function Text_At (This : in Text_Buffer; Start, Finish : in Position) return String is C_Str : Interfaces.C.Strings.chars_ptr := fl_text_buffer_text_range (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); begin if C_Str = Interfaces.C.Strings.Null_Ptr then return ""; else declare The_Text : String := Interfaces.C.Strings.Value (C_Str); begin Interfaces.C.Strings.Free (C_Str); return The_Text; end; end if; end Text_At; function Next_Char (This : in Text_Buffer; Place : in Position) return Character is begin return Character'Val (fl_text_buffer_next_char (This.Void_Ptr, Interfaces.C.int (Place))); end Next_Char; function Prev_Char (This : in Text_Buffer; Place : in Position) return Character is begin return Character'Val (fl_text_buffer_prev_char (This.Void_Ptr, Interfaces.C.int (Place))); end Prev_Char; function Count_Displayed_Characters (This : in Text_Buffer; Start, Finish : in Position) return Integer is begin return Integer (fl_text_buffer_count_displayed_characters (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish))); end Count_Displayed_Characters; function Count_Lines (This : in Text_Buffer; Start, Finish : in Position) return Integer is begin return Integer (fl_text_buffer_count_lines (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish))); end Count_Lines; function Length (This : in Text_Buffer) return Natural is begin return Natural (fl_text_buffer_length (This.Void_Ptr)); end Length; function Get_Tab_Width (This : in Text_Buffer) return Natural is begin return Natural (fl_text_buffer_get_tab_distance (This.Void_Ptr)); end Get_Tab_Width; procedure Set_Tab_Width (This : in out Text_Buffer; To : in Natural) is begin fl_text_buffer_set_tab_distance (This.Void_Ptr, Interfaces.C.int (To)); end Set_Tab_Width; function Get_Selection (This : in Text_Buffer; Start, Finish : out Position) return Boolean is begin return fl_text_buffer_selection_position (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)) /= 0; end Get_Selection; function Get_Secondary_Selection (This : in Text_Buffer; Start, Finish : out Position) return Boolean is begin return fl_text_buffer_secondary_selection_position (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)) /= 0; end Get_Secondary_Selection; procedure Set_Selection (This : in out Text_Buffer; Start, Finish : in Position) is begin fl_text_buffer_select (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); end Set_Selection; procedure Set_Secondary_Selection (This : in out Text_Buffer; Start, Finish : in Position) is begin fl_text_buffer_secondary_select (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); end Set_Secondary_Selection; function Has_Selection (This : in Text_Buffer) return Boolean is begin return fl_text_buffer_selected (This.Void_Ptr) /= 0; end Has_Selection; function Has_Secondary_Selection (This : in Text_Buffer) return Boolean is begin return fl_text_buffer_secondary_selected (This.Void_Ptr) /= 0; end Has_Secondary_Selection; function Selection_Text (This : in Text_Buffer) return String is Raw : Interfaces.C.Strings.chars_ptr := fl_text_buffer_selection_text (This.Void_Ptr); begin if Raw = Interfaces.C.Strings.Null_Ptr then return ""; else declare Ada_String : String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; end; end if; end Selection_Text; function Secondary_Selection_Text (This : in Text_Buffer) return String is Raw : Interfaces.C.Strings.chars_ptr := fl_text_buffer_secondary_selection_text (This.Void_Ptr); begin if Raw = Interfaces.C.Strings.Null_Ptr then return ""; else declare Ada_String : String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; end; end if; end Secondary_Selection_Text; procedure Replace_Selection (This : in out Text_Buffer; Text : in String) is begin fl_text_buffer_replace_selection (This.Void_Ptr, Interfaces.C.To_C (Text)); end Replace_Selection; procedure Replace_Secondary_Selection (This : in out Text_Buffer; Text : in String) is begin fl_text_buffer_replace_secondary_selection (This.Void_Ptr, Interfaces.C.To_C (Text)); end Replace_Secondary_Selection; procedure Remove_Selection (This : in out Text_Buffer) is begin fl_text_buffer_remove_selection (This.Void_Ptr); end Remove_Selection; procedure Remove_Secondary_Selection (This : in out Text_Buffer) is begin fl_text_buffer_remove_secondary_selection (This.Void_Ptr); end Remove_Secondary_Selection; procedure Unselect (This : in out Text_Buffer) is begin fl_text_buffer_unselect (This.Void_Ptr); end Unselect; procedure Secondary_Unselect (This : in out Text_Buffer) is begin fl_text_buffer_secondary_unselect (This.Void_Ptr); end Secondary_Unselect; procedure Get_Highlight (This : in Text_Buffer; Start, Finish : out Position) is begin Start := This.High_From; Finish := This.High_To; end Get_Highlight; procedure Set_Highlight (This : in out Text_Buffer; Start, Finish : in Position) is begin This.High_From := Start; This.High_To := Finish; fl_text_buffer_highlight (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); end Set_Highlight; function Get_Highlighted_Text (This : in Text_Buffer) return String is Raw : Interfaces.C.Strings.chars_ptr := fl_text_buffer_highlight_text (This.Void_Ptr); begin if Raw = Interfaces.C.Strings.Null_Ptr then return ""; else declare Ada_String : String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; end; end if; end Get_Highlighted_Text; procedure Unhighlight (This : in out Text_Buffer) is begin fl_text_buffer_unhighlight (This.Void_Ptr); end Unhighlight; function Findchar_Forward (This : in Text_Buffer; Start_At : in Position; Item : in Character; Found_At : out Position) return Boolean is begin return fl_text_buffer_findchar_forward (This.Void_Ptr, Interfaces.C.int (Start_At), Character'Pos (Item), Interfaces.C.int (Found_At)) /= 0; end Findchar_Forward; function Findchar_Backward (This : in Text_Buffer; Start_At : in Position; Item : in Character; Found_At : out Position) return Boolean is begin return fl_text_buffer_findchar_backward (This.Void_Ptr, Interfaces.C.int (Start_At), Character'Pos (Item), Interfaces.C.int (Found_At)) /= 0; end Findchar_Backward; function Search_Forward (This : in Text_Buffer; Start_At : in Position; Item : in String; Found_At : out Position; Match_Case : in Boolean := False) return Boolean is begin return fl_text_buffer_search_forward (This.Void_Ptr, Interfaces.C.int (Start_At), Interfaces.C.To_C (Item), Interfaces.C.int (Found_At), Boolean'Pos (Match_Case)) /= 0; end Search_Forward; function Search_Backward (This : in Text_Buffer; Start_At : in Position; Item : in String; Found_At : out Position; Match_Case : in Boolean := False) return Boolean is begin return fl_text_buffer_search_backward (This.Void_Ptr, Interfaces.C.int (Start_At), Interfaces.C.To_C (Item), Interfaces.C.int (Found_At), Boolean'Pos (Match_Case)) /= 0; end Search_Backward; function Word_Start (This : in Text_Buffer; Place : in Position) return Position is begin return Position (fl_text_buffer_word_start (This.Void_Ptr, Interfaces.C.int (Place))); end Word_Start; function Word_End (This : in Text_Buffer; Place : in Position) return Position is begin return Position (fl_text_buffer_word_end (This.Void_Ptr, Interfaces.C.int (Place))); end Word_End; function Line_Start (This : in Text_Buffer; Place : in Position) return Position is begin return Position (fl_text_buffer_line_start (This.Void_Ptr, Interfaces.C.int (Place))); end Line_Start; function Line_End (This : in Text_Buffer; Place : in Position) return Position is begin return Position (fl_text_buffer_line_end (This.Void_Ptr, Interfaces.C.int (Place))); end Line_End; function Line_Text (This : in Text_Buffer; Place : in Position) return String is Raw : Interfaces.C.Strings.chars_ptr := fl_text_buffer_line_text (This.Void_Ptr, Interfaces.C.int (Place)); begin if Raw = Interfaces.C.Strings.Null_Ptr then return ""; else declare Ada_String : String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; end; end if; end Line_Text; function Skip_Lines (This : in out Text_Buffer; Start : in Position; Lines : in Natural) return Position is begin return Natural (fl_text_buffer_skip_lines (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Lines))); end Skip_Lines; function Rewind_Lines (This : in out Text_Buffer; Start : in Position; Lines : in Natural) return Position is begin return Natural (fl_text_buffer_rewind_lines (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Lines))); end Rewind_Lines; function Skip_Displayed_Characters (This : in Text_Buffer; Start : in Position; Chars : in Natural) return Position is begin return Natural (fl_text_buffer_skip_displayed_characters (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Chars))); end Skip_Displayed_Characters; procedure Can_Undo (This : in out Text_Buffer; Flag : in Boolean) is begin fl_text_buffer_canundo (This.Void_Ptr, Interfaces.C.char'Val (Boolean'Pos (Flag))); end Can_Undo; procedure Copy (This : in out Text_Buffer; From : in Text_Buffer; Start, Finish : in Position; Insert_Pos : in Position) is begin fl_text_buffer_copy (This.Void_Ptr, From.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish), Interfaces.C.int (Insert_Pos)); end Copy; function UTF8_Align (This : in Text_Buffer; Place : in Position) return Position is begin return Position (fl_text_buffer_utf8_align (This.Void_Ptr, Interfaces.C.int (Place))); end UTF8_Align; end FLTK.Text_Buffers;
with ada.Containers.Vectors, ada.Unchecked_Deallocation, interfaces.c.Pointers; -- for debug package body impact.d2.dynamic_Tree is use type int32; ------- -- Node -- procedure free is new ada.Unchecked_Deallocation (b2DynamicTreeNodes, b2DynamicTreeNodes_view); function isLeaf (Self : in b2DynamicTreeNode) return Boolean is begin return Self.child1 = b2_nullNode; end isLeaf; ------- -- Tree -- function to_b2DynamicTree return b2DynamicTree is Self : b2DynamicTree; begin Self.m_root := b2_nullNode; Self.m_nodeCapacity := 16; Self.m_nodeCount := 0; Self.m_nodes := new b2DynamicTreeNodes (0 .. Self.m_nodeCapacity - 1); -- Build a linked list for the free list. for i in 0 .. Self.m_nodeCapacity - 2 loop Self.m_nodes (i).next := i + 1; Self.m_nodes (i).height := -1; end loop; Self.m_nodes (Self.m_nodeCapacity - 1).next := b2_nullNode; Self.m_nodes (Self.m_nodeCapacity - 1).height := -1; Self.m_freeList := 0; Self.m_path := 0; Self.m_insertionCount := 0; return Self; end to_b2DynamicTree; procedure destruct (Self : in out b2DynamicTree) is begin free (Self.m_nodes); -- This frees the entire tree in one shot. end destruct; -- Create a proxy in the tree as a leaf node. We return the index -- of the node instead of a pointer so that we can grow -- the node pool. -- function createProxy (Self : access b2DynamicTree; aabb : in collision.b2AABB; userData : access Any'Class ) return int32 is proxyId : constant int32 := Self.AllocateNode; r : constant b2Vec2 := (b2_aabbExtension, b2_aabbExtension); begin -- Fatten the aabb. Self.m_nodes (proxyId).aabb.lowerBound := aabb.lowerBound - r; Self.m_nodes (proxyId).aabb.upperBound := aabb.upperBound + r; Self.m_nodes (proxyId).userData := userData; Self.m_nodes (proxyId).height := 0; Self.InsertLeaf (proxyId); return proxyId; end createProxy; -- int32 b2DynamicTree::CreateProxy(const b2AABB& aabb, void* userData) -- { -- int32 proxyId = AllocateNode(); -- -- // Fatten the aabb. -- b2Vec2 r(b2_aabbExtension, b2_aabbExtension); -- m_nodes[proxyId].aabb.lowerBound = aabb.lowerBound - r; -- m_nodes[proxyId].aabb.upperBound = aabb.upperBound + r; -- m_nodes[proxyId].userData = userData; -- m_nodes[proxyId].height = 0; -- -- InsertLeaf(proxyId); -- -- return proxyId; -- } procedure destroyProxy (Self : in out b2DynamicTree; proxyId : int32) is begin pragma Assert (0 <= proxyId and then proxyId < Self.m_nodeCapacity); pragma Assert (isLeaf (Self.m_nodes (proxyId))); Self.removeLeaf (proxyId); Self.freeNode (proxyId); end destroyProxy; -- void b2DynamicTree::DestroyProxy(int32 proxyId) -- { -- b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); -- b2Assert(m_nodes[proxyId].IsLeaf()); -- -- RemoveLeaf(proxyId); -- FreeNode(proxyId); -- } function MoveProxy (Self : access b2DynamicTree; proxyId : in int32; aabb : in collision.b2AABB; displacement : in b2Vec2) return Boolean is use impact.d2.Collision; b : collision.b2AABB; d, r : b2Vec2; begin pragma Assert (0 <= proxyId and then proxyId < Self.m_nodeCapacity); pragma Assert (isLeaf (Self.m_nodes (proxyId))); if Contains (Self.m_nodes (proxyId).aabb, aabb) then return False; end if; Self.RemoveLeaf (proxyId); -- Extend AABB. b := aabb; r := (b2_aabbExtension, b2_aabbExtension); b.lowerBound := b.lowerBound - r; b.upperBound := b.upperBound + r; -- Predict AABB displacement. d := b2_aabbMultiplier * displacement; if d.x < 0.0 then b.lowerBound.x := b.lowerBound.x + d.x; else b.upperBound.x := b.upperBound.x + d.x; end if; if d.y < 0.0 then b.lowerBound.y := b.lowerBound.y + d.y; else b.upperBound.y := b.upperBound.y + d.y; end if; Self.m_nodes (proxyId).aabb := b; Self.insertLeaf (proxyId); return True; end MoveProxy; -- bool b2DynamicTree::MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement) -- { -- b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); -- -- b2Assert(m_nodes[proxyId].IsLeaf()); -- -- if (m_nodes[proxyId].aabb.Contains(aabb)) -- { -- return false; -- } -- -- RemoveLeaf(proxyId); -- -- // Extend AABB. -- b2AABB b = aabb; -- b2Vec2 r(b2_aabbExtension, b2_aabbExtension); -- b.lowerBound = b.lowerBound - r; -- b.upperBound = b.upperBound + r; -- -- // Predict AABB displacement. -- b2Vec2 d = b2_aabbMultiplier * displacement; -- -- if (d.x < 0.0f) -- { -- b.lowerBound.x += d.x; -- } -- else -- { -- b.upperBound.x += d.x; -- } -- -- if (d.y < 0.0f) -- { -- b.lowerBound.y += d.y; -- } -- else -- { -- b.upperBound.y += d.y; -- } -- -- m_nodes[proxyId].aabb = b; -- -- InsertLeaf(proxyId); -- return true; -- } -- Perform a left or right rotation if node A is imbalanced. -- Returns the new root index. function Balance (Self : in out b2DynamicTree; iA : in int32) return int32 is pragma assert (iA /= b2_nullNode); A : b2DynamicTreeNode renames Self.m_nodes (iA); iB, iC : int32; begin if IsLeaf (A) or A.height < 2 then return iA; end if; iB := A.child1; pragma assert (0 <= iB and iB < Self.m_nodeCapacity); iC := A.child2; pragma assert (0 <= iC and iC < Self.m_nodeCapacity); declare B : b2DynamicTreeNode renames Self.m_nodes (iB); C : b2DynamicTreeNode renames Self.m_nodes (iC); balance : constant int32 := C.height - B.height; begin -- Rotate C up if balance > 1 then declare i_F : constant int32 := C.child1; pragma assert (0 <= i_F and i_F < Self.m_nodeCapacity); iG : constant int32 := C.child2; pragma assert (0 <= iG and iG < Self.m_nodeCapacity); F : b2DynamicTreeNode renames Self.m_nodes (i_F); G : b2DynamicTreeNode renames Self.m_nodes (iG); begin -- Swap A and C C.child1 := iA; C.parent := A.parent; A.parent := iC; -- A's old parent should point to C if C.parent /= b2_nullNode then if Self.m_nodes (C.parent).child1 = iA then Self.m_nodes (C.parent).child1 := iC; else pragma assert (Self.m_nodes (C.parent).child2 = iA); Self.m_nodes (C.parent).child2 := iC; end if; else Self.m_root := iC; end if; -- Rotate if F.height > G.height then C.child2 := i_F; A.child2 := iG; G.parent := iA; A.aabb.Combine (B.aabb, G.aabb); C.aabb.Combine (A.aabb, F.aabb); A.height := 1 + int32'Max (B.height, G.height); C.height := 1 + int32'Max (A.height, F.height); else C.child2 := iG; A.child2 := i_F; F.parent := iA; A.aabb.Combine(B.aabb, F.aabb); C.aabb.Combine(A.aabb, G.aabb); A.height := 1 + int32'Max (B.height, F.height); C.height := 1 + int32'Max (A.height, G.height); end if; return iC; end; end if; -- Rotate B up if balance < -1 then declare iD : constant int32 := B.child1; iE : constant int32 := B.child2; D : b2DynamicTreeNode renames Self.m_nodes (iD); E : b2DynamicTreeNode renames Self.m_nodes (iE); pragma assert (0 <= iD and iD < Self.m_nodeCapacity); pragma assert (0 <= iE and iE < Self.m_nodeCapacity); begin -- Swap A and B B.child1 := iA; B.parent := A.parent; A.parent := iB; -- A's old parent should point to B if B.parent /= b2_nullNode then if Self.m_nodes (B.parent).child1 = iA then Self.m_nodes (B.parent).child1 := iB; else pragma assert (Self.m_nodes (B.parent).child2 = iA); Self.m_nodes (B.parent).child2 := iB; end if; else Self.m_root := iB; end if; -- Rotate if D.height > E.height then B.child2 := iD; A.child1 := iE; E.parent := iA; A.aabb.Combine (C.aabb, E.aabb); B.aabb.Combine (A.aabb, D.aabb); A.height := 1 + int32'Max (C.height, E.height); B.height := 1 + int32'Max (A.height, D.height); else B.child2 := iE; A.child1 := iD; D.parent := iA; A.aabb.Combine (C.aabb, D.aabb); B.aabb.Combine (A.aabb, E.aabb); A.height := 1 + int32'Max (C.height, D.height); B.height := 1 + int32'Max (A.height, E.height); end if; return iB; end; end if; end; return iA; end Balance; -- // Perform a left or right rotation if node A is imbalanced. -- // Returns the new root index. -- int32 b2DynamicTree::Balance(int32 iA) -- { -- b2Assert(iA != b2_nullNode); -- -- b2TreeNode* A = m_nodes + iA; -- if (A->IsLeaf() || A->height < 2) -- { -- return iA; -- } -- -- int32 iB = A->child1; -- int32 iC = A->child2; -- b2Assert(0 <= iB && iB < m_nodeCapacity); -- b2Assert(0 <= iC && iC < m_nodeCapacity); -- -- b2TreeNode* B = m_nodes + iB; -- b2TreeNode* C = m_nodes + iC; -- -- int32 balance = C->height - B->height; -- -- // Rotate C up -- if (balance > 1) -- { -- int32 iF = C->child1; -- int32 iG = C->child2; -- b2TreeNode* F = m_nodes + iF; -- b2TreeNode* G = m_nodes + iG; -- b2Assert(0 <= iF && iF < m_nodeCapacity); -- b2Assert(0 <= iG && iG < m_nodeCapacity); -- -- // Swap A and C -- C->child1 = iA; -- C->parent = A->parent; -- A->parent = iC; -- -- // A's old parent should point to C -- if (C->parent != b2_nullNode) -- { -- if (m_nodes[C->parent].child1 == iA) -- { -- m_nodes[C->parent].child1 = iC; -- } -- else -- { -- b2Assert(m_nodes[C->parent].child2 == iA); -- m_nodes[C->parent].child2 = iC; -- } -- } -- else -- { -- m_root = iC; -- } -- -- // Rotate -- if (F->height > G->height) -- { -- C->child2 = iF; -- A->child2 = iG; -- G->parent = iA; -- A->aabb.Combine(B->aabb, G->aabb); -- C->aabb.Combine(A->aabb, F->aabb); -- -- A->height = 1 + b2Max(B->height, G->height); -- C->height = 1 + b2Max(A->height, F->height); -- } -- else -- { -- C->child2 = iG; -- A->child2 = iF; -- F->parent = iA; -- A->aabb.Combine(B->aabb, F->aabb); -- C->aabb.Combine(A->aabb, G->aabb); -- -- A->height = 1 + b2Max(B->height, F->height); -- C->height = 1 + b2Max(A->height, G->height); -- } -- -- return iC; -- } -- -- // Rotate B up -- if (balance < -1) -- { -- int32 iD = B->child1; -- int32 iE = B->child2; -- b2TreeNode* D = m_nodes + iD; -- b2TreeNode* E = m_nodes + iE; -- b2Assert(0 <= iD && iD < m_nodeCapacity); -- b2Assert(0 <= iE && iE < m_nodeCapacity); -- -- // Swap A and B -- B->child1 = iA; -- B->parent = A->parent; -- A->parent = iB; -- -- // A's old parent should point to B -- if (B->parent != b2_nullNode) -- { -- if (m_nodes[B->parent].child1 == iA) -- { -- m_nodes[B->parent].child1 = iB; -- } -- else -- { -- b2Assert(m_nodes[B->parent].child2 == iA); -- m_nodes[B->parent].child2 = iB; -- } -- } -- else -- { -- m_root = iB; -- } -- -- // Rotate -- if (D->height > E->height) -- { -- B->child2 = iD; -- A->child1 = iE; -- E->parent = iA; -- A->aabb.Combine(C->aabb, E->aabb); -- B->aabb.Combine(A->aabb, D->aabb); -- -- A->height = 1 + b2Max(C->height, E->height); -- B->height = 1 + b2Max(A->height, D->height); -- } -- else -- { -- B->child2 = iE; -- A->child1 = iD; -- D->parent = iA; -- A->aabb.Combine(C->aabb, D->aabb); -- B->aabb.Combine(A->aabb, E->aabb); -- -- A->height = 1 + b2Max(C->height, D->height); -- B->height = 1 + b2Max(A->height, E->height); -- } -- -- return iB; -- } -- -- return iA; -- } function getUserData (Self : in b2DynamicTree; proxyId : in int32) return access Any'Class is pragma Assert (0 <= proxyId and then proxyId < Self.m_nodeCapacity); begin return Self.m_nodes (proxyId).userData; end getUserData; function GetFatAABB (Self : in b2DynamicTree; proxyId : int32) return collision.b2AABB is pragma Assert (0 <= proxyId and then proxyId < Self.m_nodeCapacity); begin return Self.m_nodes (proxyId).aabb; end GetFatAABB; package int32_Vectors is new ada.Containers.Vectors (Positive, int32); subtype int32_Stack is int32_Vectors.Vector; procedure Query (Self : in b2DynamicTree; the_Callback : access callback_t; aabb : in collision.b2AABB) is use ada.Containers, int32_Vectors; Stack : int32_Stack; nodeId : int32; begin Stack.reserve_Capacity (256); Stack.append (Self.m_root); while Stack.Length > 0 loop nodeId := Stack.Last_Element; Stack.delete_Last; if nodeId /= b2_nullNode then declare node : b2DynamicTreeNode renames Self.m_nodes (nodeId); proceed : Boolean; begin if collision.b2TestOverlap (node.aabb, aabb) then if isLeaf (node) then proceed := QueryCallback (the_Callback, nodeId); if not proceed then return; end if; else Stack.append (node.child1); Stack.append (node.child2); end if; end if; end; end if; end loop; end Query; procedure Raycast (Self : in b2DynamicTree; the_Callback : access callback_t; input : in collision.b2RayCastInput) is use ada.Containers, int32_Vectors; p1 : constant b2Vec2 := input.p1; p2 : constant b2Vec2 := input.p2; r_pad : constant b2Vec2 := p2 - p1; pragma Assert (LengthSquared (r_pad) > 0.0); r : constant b2Vec2 := Normalize (r_pad); -- v is perpendicular to the segment. -- v : constant b2Vec2 := b2Cross (1.0, r); abs_v : constant b2Vec2 := b2Abs (v); -- Separating axis for segment (Gino, p80). -- |dot(v, p1 - c)| > dot(|v|, h) -- maxFraction : float32 := input.maxFraction; segmentAABB : collision.b2AABB; t : b2Vec2; Stack : int32_Stack; count : int32 := 0; nodeId : int32; begin -- Build a bounding box for the segment. -- t := p1 + maxFraction * (p2 - p1); segmentAABB.lowerBound := b2Min (p1, t); segmentAABB.upperBound := b2Max (p1, t); Stack.reserve_Capacity (256); Stack.append (Self.m_root); while Stack.Length > 0 loop nodeId := Stack.last_Element; Stack.delete_Last; if nodeId /= b2_nullNode then declare use impact.d2.Collision; node : b2DynamicTreeNode renames Self.m_nodes (nodeId); c, h : b2Vec2; separation : float32; subInput : collision.b2RayCastInput; value : float32; begin if collision.b2TestOverlap (node.aabb, segmentAABB) then -- Separating axis for segment (Gino, p80). -- |dot(v, p1 - c)| > dot(|v|, h) -- c := GetCenter (node.aabb); h := GetExtents (node.aabb); separation := abs (b2Dot (v, p1 - c)) - b2Dot (abs_v, h); if separation <= 0.0 then if isLeaf (node) then subInput.p1 := input.p1; subInput.p2 := input.p2; subInput.maxFraction := maxFraction; value := RayCastCallback (the_Callback, subInput, nodeId); if value = 0.0 then return; -- The client has terminated the ray cast. end if; if value > 0.0 then -- Update segment bounding box. -- maxFraction := value; t := p1 + maxFraction * (p2 - p1); segmentAABB.lowerBound := b2Min (p1, t); segmentAABB.upperBound := b2Max (p1, t); end if; else Stack.append (node.child1); Stack.append (node.child2); end if; end if; end if; end; end if; end loop; end Raycast; -- Allocate a node from the pool. Grow the pool if necessary. -- function AllocateNode (Self : access b2DynamicTree) return int32 is oldNodes : b2DynamicTreeNodes_view; nodeId : int32; begin -- Expand the node pool as needed. if Self.m_freeList = b2_nullNode then pragma Assert (Self.m_nodeCount = Self.m_nodeCapacity); -- The free list is empty. Rebuild a bigger pool. oldNodes := Self.m_nodes; Self.m_nodeCapacity := Self.m_nodeCapacity * 2; Self.m_nodes := new b2DynamicTreeNodes (0 .. Self.m_nodeCapacity - 1); Self.m_nodes (oldNodes'Range) := oldNodes.all; free (oldNodes); -- Build a linked list for the free list. The parent pointer becomes the "next" pointer. for i in Self.m_nodeCount .. Self.m_nodeCapacity - 2 loop Self.m_nodes (i).next := i + 1; Self.m_nodes (i).height := -1; end loop; Self.m_nodes (Self.m_nodeCapacity - 1).next := b2_nullNode; Self.m_nodes (Self.m_nodeCapacity - 1).height := -1; Self.m_freeList := Self.m_nodeCount; end if; -- Peel a node off the free list. nodeId := Self.m_freeList; Self.m_freeList := Self.m_nodes (nodeId).next; Self.m_nodes (nodeId).parent := b2_nullNode; Self.m_nodes (nodeId).child1 := b2_nullNode; Self.m_nodes (nodeId).child2 := b2_nullNode; Self.m_nodes (nodeId).height := 0; Self.m_nodes (nodeId).userData := null; Self.m_nodeCount := Self.m_nodeCount + 1; return nodeId; end AllocateNode; -- // Allocate a node from the pool. Grow the pool if necessary. -- int32 b2DynamicTree::AllocateNode() -- { -- // Expand the node pool as needed. -- if (m_freeList == b2_nullNode) -- { -- b2Assert(m_nodeCount == m_nodeCapacity); -- -- // The free list is empty. Rebuild a bigger pool. -- b2TreeNode* oldNodes = m_nodes; -- m_nodeCapacity *= 2; -- m_nodes = (b2TreeNode*)b2Alloc(m_nodeCapacity * sizeof(b2TreeNode)); -- memcpy(m_nodes, oldNodes, m_nodeCount * sizeof(b2TreeNode)); -- b2Free(oldNodes); -- -- // Build a linked list for the free list. The parent -- // pointer becomes the "next" pointer. -- for (int32 i = m_nodeCount; i < m_nodeCapacity - 1; ++i) -- { -- m_nodes[i].next = i + 1; -- m_nodes[i].height = -1; -- } -- m_nodes[m_nodeCapacity-1].next = b2_nullNode; -- m_nodes[m_nodeCapacity-1].height = -1; -- m_freeList = m_nodeCount; -- } -- -- // Peel a node off the free list. -- int32 nodeId = m_freeList; -- m_freeList = m_nodes[nodeId].next; -- m_nodes[nodeId].parent = b2_nullNode; -- m_nodes[nodeId].child1 = b2_nullNode; -- m_nodes[nodeId].child2 = b2_nullNode; -- m_nodes[nodeId].height = 0; -- m_nodes[nodeId].userData = NULL; -- ++m_nodeCount; -- return nodeId; -- } -- Return a node to the pool. -- procedure FreeNode (Self : in out b2DynamicTree; nodeId : in int32) is begin pragma Assert (0 <= nodeId and then nodeId < Self.m_nodeCapacity); pragma Assert (0 < Self.m_nodeCount); Self.m_nodes (nodeId).next := Self.m_freeList; Self.m_nodes (nodeId).height := -1; Self.m_freeList := nodeId; Self.m_nodeCount := Self.m_nodeCount - 1; end FreeNode; -- void b2DynamicTree::FreeNode(int32 nodeId) -- { -- b2Assert(0 <= nodeId && nodeId < m_nodeCapacity); -- b2Assert(0 < m_nodeCount); -- m_nodes[nodeId].next = m_freeList; -- m_nodes[nodeId].height = -1; -- m_freeList = nodeId; -- --m_nodeCount; -- } procedure InsertLeaf (Self : in out b2DynamicTree; leafId : in int32) is use impact.d2.Collision; center : b2Vec2; sibling : int32; node1, node2 : int32; leafAABB : b2AABB; index : int32; begin Self.m_insertionCount := Self.m_insertionCount + 1; if Self.m_root = b2_nullNode then Self.m_root := leafId; Self.m_nodes (Self.m_root).parent := b2_nullNode; return; end if; -- Find the best sibling for this node. leafAABB := Self.m_nodes (leafId).aabb; index := Self.m_root; while not IsLeaf (Self.m_nodes (index)) loop declare child1 : constant int32 := Self.m_nodes (index).child1; child2 : constant int32 := Self.m_nodes (index).child2; area : constant float32 := GetPerimeter (Self.m_nodes (index).aabb); combinedAABB : b2AABB; combinedArea : float32; cost, cost1, cost2, inheritanceCost : float32; begin Combine (combinedAABB, Self.m_nodes (index).aabb, leafAABB); combinedArea := GetPerimeter (combinedAABB); -- Cost of creating a new parent for this node and the new leaf cost := 2.0 * combinedArea; -- Minimum cost of pushing the leaf further down the tree inheritanceCost := 2.0 * (combinedArea - area); -- Cost of descending into child1 if IsLeaf (Self.m_nodes (child1)) then declare aabb : b2AABB; begin Combine (aabb, leafAABB, Self.m_nodes (child1).aabb); cost1 := GetPerimeter (aabb) + inheritanceCost; end; else declare aabb : b2AABB; oldArea, newArea : float32; begin aabb.Combine (leafAABB, Self.m_nodes (child1).aabb); oldArea := Self.m_nodes (child1).aabb.GetPerimeter; newArea := aabb.GetPerimeter; cost1 := (newArea - oldArea) + inheritanceCost; end; end if; -- Cost of descending into child2 if IsLeaf (Self.m_nodes (child2)) then declare aabb : b2AABB; begin aabb.Combine (leafAABB, Self.m_nodes (child2).aabb); cost2 := aabb.GetPerimeter + inheritanceCost; end; else declare aabb : b2AABB; oldArea, newArea : float32; begin aabb.Combine (leafAABB, Self.m_nodes (child2).aabb); oldArea := Self.m_nodes (child2).aabb.GetPerimeter; newArea := aabb.GetPerimeter; cost2 := newArea - oldArea + inheritanceCost; end; end if; -- Descend according to the minimum cost. if cost < cost1 and then cost < cost2 then exit; end if; -- Descend if cost1 < cost2 then index := child1; else index := child2; end if; end; end loop; sibling := index; -- Create a new parent. -- declare oldParent : constant int32 := Self.m_nodes (sibling).parent; newParent : constant int32 := Self.AllocateNode; begin Self.m_nodes (newParent).parent := oldParent; Self.m_nodes (newParent).userData := null; Self.m_nodes (newParent).aabb.Combine(leafAABB, Self.m_nodes (sibling).aabb); Self.m_nodes (newParent).height := Self.m_nodes (sibling).height + 1; if oldParent /= b2_nullNode then -- The sibling was not the root. if Self.m_nodes (oldParent).child1 = sibling then Self.m_nodes (oldParent).child1 := newParent; else Self.m_nodes (oldParent).child2 := newParent; end if; Self.m_nodes (newParent).child1 := sibling; Self.m_nodes (newParent).child2 := leafId; Self.m_nodes (sibling) .parent := newParent; Self.m_nodes (leafId) .parent := newParent; else -- The sibling was the root. Self.m_nodes (newParent).child1 := sibling; Self.m_nodes (newParent).child2 := leafId; Self.m_nodes (sibling) .parent := newParent; Self.m_nodes (leafId) .parent := newParent; Self.m_root := newParent; end if; end; -- Walk back up the tree fixing heights and AABBs index := Self.m_nodes (leafId).parent; while index /= b2_nullNode loop declare child1, child2 : int32; begin index := Self.Balance (index); child1 := Self.m_nodes (index).child1; child2 := Self.m_nodes (index).child2; pragma assert (child1 /= b2_nullNode); pragma assert (child2 /= b2_nullNode); Self.m_nodes (index).height := 1 + int32'Max (Self.m_nodes (child1).height, Self.m_nodes (child2).height); Self.m_nodes (index).aabb.Combine (Self.m_nodes (child1).aabb, Self.m_nodes (child2).aabb); index := Self.m_nodes (index).parent; end; end loop; end InsertLeaf; -- void b2DynamicTree::InsertLeaf(int32 leaf) -- { -- ++m_insertionCount; -- -- if (m_root == b2_nullNode) -- { -- m_root = leaf; -- m_nodes[m_root].parent = b2_nullNode; -- return; -- } -- -- // Find the best sibling for this node -- b2AABB leafAABB = m_nodes[leaf].aabb; -- int32 index = m_root; -- while (m_nodes[index].IsLeaf() == false) -- { -- int32 child1 = m_nodes[index].child1; -- int32 child2 = m_nodes[index].child2; -- -- float32 area = m_nodes[index].aabb.GetPerimeter(); -- -- b2AABB combinedAABB; -- combinedAABB.Combine(m_nodes[index].aabb, leafAABB); -- float32 combinedArea = combinedAABB.GetPerimeter(); -- -- // Cost of creating a new parent for this node and the new leaf -- float32 cost = 2.0f * combinedArea; -- -- // Minimum cost of pushing the leaf further down the tree -- float32 inheritanceCost = 2.0f * (combinedArea - area); -- -- // Cost of descending into child1 -- float32 cost1; -- if (m_nodes[child1].IsLeaf()) -- { -- b2AABB aabb; -- aabb.Combine(leafAABB, m_nodes[child1].aabb); -- cost1 = aabb.GetPerimeter() + inheritanceCost; -- } -- else -- { -- b2AABB aabb; -- aabb.Combine(leafAABB, m_nodes[child1].aabb); -- float32 oldArea = m_nodes[child1].aabb.GetPerimeter(); -- float32 newArea = aabb.GetPerimeter(); -- cost1 = (newArea - oldArea) + inheritanceCost; -- } -- -- // Cost of descending into child2 -- float32 cost2; -- if (m_nodes[child2].IsLeaf()) -- { -- b2AABB aabb; -- aabb.Combine(leafAABB, m_nodes[child2].aabb); -- cost2 = aabb.GetPerimeter() + inheritanceCost; -- } -- else -- { -- b2AABB aabb; -- aabb.Combine(leafAABB, m_nodes[child2].aabb); -- float32 oldArea = m_nodes[child2].aabb.GetPerimeter(); -- float32 newArea = aabb.GetPerimeter(); -- cost2 = newArea - oldArea + inheritanceCost; -- } -- -- // Descend according to the minimum cost. -- if (cost < cost1 && cost < cost2) -- { -- break; -- } -- -- // Descend -- if (cost1 < cost2) -- { -- index = child1; -- } -- else -- { -- index = child2; -- } -- } -- -- int32 sibling = index; -- -- // Create a new parent. -- int32 oldParent = m_nodes[sibling].parent; -- int32 newParent = AllocateNode(); -- m_nodes[newParent].parent = oldParent; -- m_nodes[newParent].userData = NULL; -- m_nodes[newParent].aabb.Combine(leafAABB, m_nodes[sibling].aabb); -- m_nodes[newParent].height = m_nodes[sibling].height + 1; -- -- if (oldParent != b2_nullNode) -- { -- // The sibling was not the root. -- if (m_nodes[oldParent].child1 == sibling) -- { -- m_nodes[oldParent].child1 = newParent; -- } -- else -- { -- m_nodes[oldParent].child2 = newParent; -- } -- -- m_nodes[newParent].child1 = sibling; -- m_nodes[newParent].child2 = leaf; -- m_nodes[sibling].parent = newParent; -- m_nodes[leaf].parent = newParent; -- } -- else -- { -- // The sibling was the root. -- m_nodes[newParent].child1 = sibling; -- m_nodes[newParent].child2 = leaf; -- m_nodes[sibling].parent = newParent; -- m_nodes[leaf].parent = newParent; -- m_root = newParent; -- } -- -- // Walk back up the tree fixing heights and AABBs -- index = m_nodes[leaf].parent; -- while (index != b2_nullNode) -- { -- index = Balance(index); -- -- int32 child1 = m_nodes[index].child1; -- int32 child2 = m_nodes[index].child2; -- -- b2Assert(child1 != b2_nullNode); -- b2Assert(child2 != b2_nullNode); -- -- m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height); -- m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb); -- -- index = m_nodes[index].parent; -- } -- -- //Validate(); -- } procedure RemoveLeaf (Self : in out b2DynamicTree; leafId : in int32) is use impact.d2.Collision; parent : int32; grandParent : int32; sibling : int32; oldAABB : b2AABB; begin if leafId = Self.m_root then Self.m_root := b2_nullNode; return; end if; parent := Self.m_nodes (leafId).parent; grandParent := Self.m_nodes (parent).parent; if Self.m_nodes (parent).child1 = leafId then sibling := Self.m_nodes (parent).child2; else sibling := Self.m_nodes (parent).child1; end if; if grandParent /= b2_nullNode then -- Destroy node2 and connect node1 to sibling. if Self.m_nodes (grandParent).child1 = parent then Self.m_nodes (grandParent).child1 := sibling; else Self.m_nodes (grandParent).child2 := sibling; end if; Self.m_nodes (sibling).parent := grandParent; Self.FreeNode (parent); -- Adjust ancestor bounds. declare index : int32 := grandParent; child1, child2 : int32; begin while index /= b2_nullNode loop index := Self.Balance (index); child1 := Self.m_nodes (index).child1; child2 := Self.m_nodes (index).child2; Self.m_nodes (index).aabb.combine (Self.m_nodes (child1).aabb, Self.m_nodes (child2).aabb); Self.m_nodes (index).height := 1 + int32'Max (Self.m_nodes (child1).height, Self.m_nodes (child2).height); index := Self.m_nodes (index).parent; end loop; end; else Self.m_root := sibling; Self.m_nodes (sibling).parent := b2_nullNode; Self.FreeNode (parent); end if; end RemoveLeaf; -- void b2DynamicTree::RemoveLeaf(int32 leaf) -- { -- if (leaf == m_root) -- { -- m_root = b2_nullNode; -- return; -- } -- -- int32 parent = m_nodes[leaf].parent; -- int32 grandParent = m_nodes[parent].parent; -- int32 sibling; -- if (m_nodes[parent].child1 == leaf) -- { -- sibling = m_nodes[parent].child2; -- } -- else -- { -- sibling = m_nodes[parent].child1; -- } -- -- if (grandParent != b2_nullNode) -- { -- // Destroy parent and connect sibling to grandParent. -- if (m_nodes[grandParent].child1 == parent) -- { -- m_nodes[grandParent].child1 = sibling; -- } -- else -- { -- m_nodes[grandParent].child2 = sibling; -- } -- m_nodes[sibling].parent = grandParent; -- FreeNode(parent); -- -- // Adjust ancestor bounds. -- int32 index = grandParent; -- while (index != b2_nullNode) -- { -- index = Balance(index); -- -- int32 child1 = m_nodes[index].child1; -- int32 child2 = m_nodes[index].child2; -- -- m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb); -- m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height); -- -- index = m_nodes[index].parent; -- } -- } -- else -- { -- m_root = sibling; -- m_nodes[sibling].parent = b2_nullNode; -- FreeNode(parent); -- } -- -- //Validate(); -- } function getHeight (Self : in b2DynamicTree) return int32 is begin if Self.m_root = b2_nullNode then return 0; end if; return Self.m_nodes (Self.m_root).height; end getHeight; function GetMaxBalance (Self : in b2DynamicTree) return int32 is maxBalance : int32 := 0; begin for i in 0 .. Self.m_nodeCapacity - 1 loop declare node : b2DynamicTreeNode renames Self.m_nodes (i); child1, child2, balance : int32; begin if node.height > 1 then pragma assert (not IsLeaf (node)); child1 := node.child1; child2 := node.child2; balance := abs ( Self.m_nodes (child2).height - Self.m_nodes (child1).height); maxBalance := int32'Max (maxBalance, balance); end if; end; end loop; return maxBalance; end GetMaxBalance; function GetAreaRatio (Self : in b2DynamicTree) return float32 is begin if Self.m_root = b2_nullNode then return 0.0; end if; declare root : b2DynamicTreeNode renames Self.m_nodes (Self.m_root); rootArea : float32 := root.aabb.GetPerimeter; totalArea : float32 := 0.0; begin for i in 0 .. Self.m_nodeCapacity - 1 loop declare node : b2DynamicTreeNode renames Self.m_nodes (i); begin if node.height < 0 then -- Free node in pool null; else totalArea := totalArea + node.aabb.GetPerimeter; end if; end; end loop; return totalArea / rootArea; end; end GetAreaRatio; function ComputeHeight (Self : in b2DynamicTree) return int32 is begin return Self.ComputeHeight (Self.m_root); end ComputeHeight; -- Compute the height of a sub-tree. -- function ComputeHeight (Self : in b2DynamicTree; nodeId : in int32) return int32 is pragma assert ( 0 <= nodeId and then nodeId < Self.m_nodeCapacity); node : b2DynamicTreeNode renames Self.m_nodes (nodeId); begin if isLeaf (node) then return 0; end if; declare height1 : constant int32 := Self.computeHeight (node.child1); height2 : constant int32 := Self.computeHeight (node.child2); begin return 1 + int32'Max (height1, height2); end; end ComputeHeight; -- int32 b2DynamicTree::ComputeHeight(int32 nodeId) const -- { -- b2Assert(0 <= nodeId && nodeId < m_nodeCapacity); -- b2TreeNode* node = m_nodes + nodeId; -- -- if (node->IsLeaf()) -- { -- return 0; -- } -- -- int32 height1 = ComputeHeight(node->child1); -- int32 height2 = ComputeHeight(node->child2); -- return 1 + b2Max(height1, height2); -- } end impact.d2.dynamic_Tree;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <denkpadje@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.Strings.Unbounded; with Strings; package Emojis is subtype String_List is Strings.String_List; subtype Completion_Mappings is String_List; ---------------------------------------------------------------------------- package SU renames Ada.Strings.Unbounded; function "+" (Value : String) return SU.Unbounded_String renames SU.To_Unbounded_String; function "+" (Value : SU.Unbounded_String) return String renames SU.To_String; type Text_Label_Pair is record Text, Label : SU.Unbounded_String; end record; type Label_Mappings is array (Positive range <>) of Text_Label_Pair; Text_Emojis : constant Label_Mappings := ((+":)", +"slightly_smiling_face"), (+";)", +"wink"), (+":D", +"grinning"), (+":'D", +"sweat_smile"), (+":')", +"sweat_smile"), (+":"")", +"joy"), (+"XD", +"laughing"), (+"X'D", +"rolling_on_the_floor_laughing"), (+":o", +"open_mouth"), (+":O", +"open_mouth"), (+">:(", +"angry"), (+":(", +"slightly_frowning_face"), (+"-_-", +"unamused"), (+":'(", +"cry"), (+":""(", +"sob"), (+":p", +"stuck_out_tongue"), (+":P", +"stuck_out_tongue"), (+";p", +"stuck_out_tongue_winking_eye"), (+";P", +"stuck_out_tongue_winking_eye"), (+"B)", +"sunglasses"), (+":+)", +"clown_face"), (+":(=", +"hot_face"), (+"o_O", +"face_with_raised_eyebrow"), (+"O_o", +"face_with_raised_eyebrow"), (+"XO=", +"face_vomiting"), (+"<3", +"orange_heart")); Lower_Case_Text_Emojis : constant Completion_Mappings := (+":o", +":p", +"XD"); ---------------------------------------------------------------------------- function Labels return String_List; function Replace (Text : String; Mappings : Label_Mappings := Text_Emojis; Completions : Completion_Mappings := (1 .. 0 => <>)) return String; private type Text_1_Points_Pair is record Text : SU.Unbounded_String; Point_1 : Long_Integer; end record; type Text_2_Points_Pair is record Text : SU.Unbounded_String; Point_1 : Long_Integer; Point_2 : Long_Integer; end record; type Text_3_Points_Pair is record Text : SU.Unbounded_String; Point_1 : Long_Integer; Point_2 : Long_Integer; Point_3 : Long_Integer; end record; Name_Emojis_3 : constant array (Positive range <>) of Text_3_Points_Pair := ((+"hash", 16#0023#, 16#FE0F#, 16#20E3#), (+"keycap_star", 16#002A#, 16#FE0F#, 16#20E3#), (+"zero", 16#0030#, 16#FE0F#, 16#20E3#), (+"one", 16#0031#, 16#FE0F#, 16#20E3#), (+"two", 16#0032#, 16#FE0F#, 16#20E3#), (+"three", 16#0033#, 16#FE0F#, 16#20E3#), (+"four", 16#0034#, 16#FE0F#, 16#20E3#), (+"five", 16#0035#, 16#FE0F#, 16#20E3#), (+"six", 16#0036#, 16#FE0F#, 16#20E3#), (+"seven", 16#0037#, 16#FE0F#, 16#20E3#), (+"eight", 16#0038#, 16#FE0F#, 16#20E3#), (+"nine", 16#0039#, 16#FE0F#, 16#20E3#), (+"black_cat", 16#1F408#, 16#200D#, 16#2B1B#), (+"service_dog", 16#1F415#, 16#200D#, 16#1F9BA#), (+"male-farmer", 16#1F468#, 16#200D#, 16#1F33E#), (+"male-cook", 16#1F468#, 16#200D#, 16#1F373#), (+"man_feeding_baby", 16#1F468#, 16#200D#, 16#1F37C#), (+"male-student", 16#1F468#, 16#200D#, 16#1F393#), (+"male-singer", 16#1F468#, 16#200D#, 16#1F3A4#), (+"male-artist", 16#1F468#, 16#200D#, 16#1F3A8#), (+"male-teacher", 16#1F468#, 16#200D#, 16#1F3EB#), (+"male-factory-worker", 16#1F468#, 16#200D#, 16#1F3ED#), (+"man-boy", 16#1F468#, 16#200D#, 16#1F466#), (+"man-girl", 16#1F468#, 16#200D#, 16#1F467#), (+"male-technologist", 16#1F468#, 16#200D#, 16#1F4BB#), (+"male-office-worker", 16#1F468#, 16#200D#, 16#1F4BC#), (+"male-mechanic", 16#1F468#, 16#200D#, 16#1F527#), (+"male-scientist", 16#1F468#, 16#200D#, 16#1F52C#), (+"male-astronaut", 16#1F468#, 16#200D#, 16#1F680#), (+"male-firefighter", 16#1F468#, 16#200D#, 16#1F692#), (+"man_with_probing_cane", 16#1F468#, 16#200D#, 16#1F9AF#), (+"red_haired_man", 16#1F468#, 16#200D#, 16#1F9B0#), (+"curly_haired_man", 16#1F468#, 16#200D#, 16#1F9B1#), (+"bald_man", 16#1F468#, 16#200D#, 16#1F9B2#), (+"white_haired_man", 16#1F468#, 16#200D#, 16#1F9B3#), (+"man_in_motorized_wheelchair", 16#1F468#, 16#200D#, 16#1F9BC#), (+"man_in_manual_wheelchair", 16#1F468#, 16#200D#, 16#1F9BD#), (+"female-farmer", 16#1F469#, 16#200D#, 16#1F33E#), (+"female-cook", 16#1F469#, 16#200D#, 16#1F373#), (+"woman_feeding_baby", 16#1F469#, 16#200D#, 16#1F37C#), (+"female-student", 16#1F469#, 16#200D#, 16#1F393#), (+"female-singer", 16#1F469#, 16#200D#, 16#1F3A4#), (+"female-artist", 16#1F469#, 16#200D#, 16#1F3A8#), (+"female-teacher", 16#1F469#, 16#200D#, 16#1F3EB#), (+"female-factory-worker", 16#1F469#, 16#200D#, 16#1F3ED#), (+"woman-boy", 16#1F469#, 16#200D#, 16#1F466#), (+"woman-girl", 16#1F469#, 16#200D#, 16#1F467#), (+"female-technologist", 16#1F469#, 16#200D#, 16#1F4BB#), (+"female-office-worker", 16#1F469#, 16#200D#, 16#1F4BC#), (+"female-mechanic", 16#1F469#, 16#200D#, 16#1F527#), (+"female-scientist", 16#1F469#, 16#200D#, 16#1F52C#), (+"female-astronaut", 16#1F469#, 16#200D#, 16#1F680#), (+"female-firefighter", 16#1F469#, 16#200D#, 16#1F692#), (+"woman_with_probing_cane", 16#1F469#, 16#200D#, 16#1F9AF#), (+"red_haired_woman", 16#1F469#, 16#200D#, 16#1F9B0#), (+"curly_haired_woman", 16#1F469#, 16#200D#, 16#1F9B1#), (+"bald_woman", 16#1F469#, 16#200D#, 16#1F9B2#), (+"white_haired_woman", 16#1F469#, 16#200D#, 16#1F9B3#), (+"woman_in_motorized_wheelchair", 16#1F469#, 16#200D#, 16#1F9BC#), (+"woman_in_manual_wheelchair", 16#1F469#, 16#200D#, 16#1F9BD#), (+"face_exhaling", 16#1F62E#, 16#200D#, 16#1F4A8#), (+"face_with_spiral_eyes", 16#1F635#, 16#200D#, 16#1F4AB#), (+"farmer", 16#1F9D1#, 16#200D#, 16#1F33E#), (+"cook", 16#1F9D1#, 16#200D#, 16#1F373#), (+"person_feeding_baby", 16#1F9D1#, 16#200D#, 16#1F37C#), (+"mx_claus", 16#1F9D1#, 16#200D#, 16#1F384#), (+"student", 16#1F9D1#, 16#200D#, 16#1F393#), (+"singer", 16#1F9D1#, 16#200D#, 16#1F3A4#), (+"artist", 16#1F9D1#, 16#200D#, 16#1F3A8#), (+"teacher", 16#1F9D1#, 16#200D#, 16#1F3EB#), (+"factory_worker", 16#1F9D1#, 16#200D#, 16#1F3ED#), (+"technologist", 16#1F9D1#, 16#200D#, 16#1F4BB#), (+"office_worker", 16#1F9D1#, 16#200D#, 16#1F4BC#), (+"mechanic", 16#1F9D1#, 16#200D#, 16#1F527#), (+"scientist", 16#1F9D1#, 16#200D#, 16#1F52C#), (+"astronaut", 16#1F9D1#, 16#200D#, 16#1F680#), (+"firefighter", 16#1F9D1#, 16#200D#, 16#1F692#), (+"person_with_probing_cane", 16#1F9D1#, 16#200D#, 16#1F9AF#), (+"red_haired_person", 16#1F9D1#, 16#200D#, 16#1F9B0#), (+"curly_haired_person", 16#1F9D1#, 16#200D#, 16#1F9B1#), (+"bald_person", 16#1F9D1#, 16#200D#, 16#1F9B2#), (+"white_haired_person", 16#1F9D1#, 16#200D#, 16#1F9B3#), (+"person_in_motorized_wheelchair", 16#1F9D1#, 16#200D#, 16#1F9BC#), (+"person_in_manual_wheelchair", 16#1F9D1#, 16#200D#, 16#1F9BD#)); Name_Emojis_2 : constant array (Positive range <>) of Text_2_Points_Pair := ((+"copyright", 16#00A9#, 16#FE0F#), (+"registered", 16#00AE#, 16#FE0F#), (+"a", 16#1F170#, 16#FE0F#), (+"b", 16#1F171#, 16#FE0F#), (+"o2", 16#1F17E#, 16#FE0F#), (+"parking", 16#1F17F#, 16#FE0F#), (+"flag-ac", 16#1F1E6#, 16#1F1E8#), (+"flag-ad", 16#1F1E6#, 16#1F1E9#), (+"flag-ae", 16#1F1E6#, 16#1F1EA#), (+"flag-af", 16#1F1E6#, 16#1F1EB#), (+"flag-ag", 16#1F1E6#, 16#1F1EC#), (+"flag-ai", 16#1F1E6#, 16#1F1EE#), (+"flag-al", 16#1F1E6#, 16#1F1F1#), (+"flag-am", 16#1F1E6#, 16#1F1F2#), (+"flag-ao", 16#1F1E6#, 16#1F1F4#), (+"flag-aq", 16#1F1E6#, 16#1F1F6#), (+"flag-ar", 16#1F1E6#, 16#1F1F7#), (+"flag-as", 16#1F1E6#, 16#1F1F8#), (+"flag-at", 16#1F1E6#, 16#1F1F9#), (+"flag-au", 16#1F1E6#, 16#1F1FA#), (+"flag-aw", 16#1F1E6#, 16#1F1FC#), (+"flag-ax", 16#1F1E6#, 16#1F1FD#), (+"flag-az", 16#1F1E6#, 16#1F1FF#), (+"flag-ba", 16#1F1E7#, 16#1F1E6#), (+"flag-bb", 16#1F1E7#, 16#1F1E7#), (+"flag-bd", 16#1F1E7#, 16#1F1E9#), (+"flag-be", 16#1F1E7#, 16#1F1EA#), (+"flag-bf", 16#1F1E7#, 16#1F1EB#), (+"flag-bg", 16#1F1E7#, 16#1F1EC#), (+"flag-bh", 16#1F1E7#, 16#1F1ED#), (+"flag-bi", 16#1F1E7#, 16#1F1EE#), (+"flag-bj", 16#1F1E7#, 16#1F1EF#), (+"flag-bl", 16#1F1E7#, 16#1F1F1#), (+"flag-bm", 16#1F1E7#, 16#1F1F2#), (+"flag-bn", 16#1F1E7#, 16#1F1F3#), (+"flag-bo", 16#1F1E7#, 16#1F1F4#), (+"flag-bq", 16#1F1E7#, 16#1F1F6#), (+"flag-br", 16#1F1E7#, 16#1F1F7#), (+"flag-bs", 16#1F1E7#, 16#1F1F8#), (+"flag-bt", 16#1F1E7#, 16#1F1F9#), (+"flag-bv", 16#1F1E7#, 16#1F1FB#), (+"flag-bw", 16#1F1E7#, 16#1F1FC#), (+"flag-by", 16#1F1E7#, 16#1F1FE#), (+"flag-bz", 16#1F1E7#, 16#1F1FF#), (+"flag-ca", 16#1F1E8#, 16#1F1E6#), (+"flag-cc", 16#1F1E8#, 16#1F1E8#), (+"flag-cd", 16#1F1E8#, 16#1F1E9#), (+"flag-cf", 16#1F1E8#, 16#1F1EB#), (+"flag-cg", 16#1F1E8#, 16#1F1EC#), (+"flag-ch", 16#1F1E8#, 16#1F1ED#), (+"flag-ci", 16#1F1E8#, 16#1F1EE#), (+"flag-ck", 16#1F1E8#, 16#1F1F0#), (+"flag-cl", 16#1F1E8#, 16#1F1F1#), (+"flag-cm", 16#1F1E8#, 16#1F1F2#), (+"flag-cn", 16#1F1E8#, 16#1F1F3#), (+"flag-co", 16#1F1E8#, 16#1F1F4#), (+"flag-cp", 16#1F1E8#, 16#1F1F5#), (+"flag-cr", 16#1F1E8#, 16#1F1F7#), (+"flag-cu", 16#1F1E8#, 16#1F1FA#), (+"flag-cv", 16#1F1E8#, 16#1F1FB#), (+"flag-cw", 16#1F1E8#, 16#1F1FC#), (+"flag-cx", 16#1F1E8#, 16#1F1FD#), (+"flag-cy", 16#1F1E8#, 16#1F1FE#), (+"flag-cz", 16#1F1E8#, 16#1F1FF#), (+"flag-de", 16#1F1E9#, 16#1F1EA#), (+"flag-dg", 16#1F1E9#, 16#1F1EC#), (+"flag-dj", 16#1F1E9#, 16#1F1EF#), (+"flag-dk", 16#1F1E9#, 16#1F1F0#), (+"flag-dm", 16#1F1E9#, 16#1F1F2#), (+"flag-do", 16#1F1E9#, 16#1F1F4#), (+"flag-dz", 16#1F1E9#, 16#1F1FF#), (+"flag-ea", 16#1F1EA#, 16#1F1E6#), (+"flag-ec", 16#1F1EA#, 16#1F1E8#), (+"flag-ee", 16#1F1EA#, 16#1F1EA#), (+"flag-eg", 16#1F1EA#, 16#1F1EC#), (+"flag-eh", 16#1F1EA#, 16#1F1ED#), (+"flag-er", 16#1F1EA#, 16#1F1F7#), (+"flag-es", 16#1F1EA#, 16#1F1F8#), (+"flag-et", 16#1F1EA#, 16#1F1F9#), (+"flag-eu", 16#1F1EA#, 16#1F1FA#), (+"flag-fi", 16#1F1EB#, 16#1F1EE#), (+"flag-fj", 16#1F1EB#, 16#1F1EF#), (+"flag-fk", 16#1F1EB#, 16#1F1F0#), (+"flag-fm", 16#1F1EB#, 16#1F1F2#), (+"flag-fo", 16#1F1EB#, 16#1F1F4#), (+"flag-fr", 16#1F1EB#, 16#1F1F7#), (+"flag-ga", 16#1F1EC#, 16#1F1E6#), (+"flag-gb", 16#1F1EC#, 16#1F1E7#), (+"flag-gd", 16#1F1EC#, 16#1F1E9#), (+"flag-ge", 16#1F1EC#, 16#1F1EA#), (+"flag-gf", 16#1F1EC#, 16#1F1EB#), (+"flag-gg", 16#1F1EC#, 16#1F1EC#), (+"flag-gh", 16#1F1EC#, 16#1F1ED#), (+"flag-gi", 16#1F1EC#, 16#1F1EE#), (+"flag-gl", 16#1F1EC#, 16#1F1F1#), (+"flag-gm", 16#1F1EC#, 16#1F1F2#), (+"flag-gn", 16#1F1EC#, 16#1F1F3#), (+"flag-gp", 16#1F1EC#, 16#1F1F5#), (+"flag-gq", 16#1F1EC#, 16#1F1F6#), (+"flag-gr", 16#1F1EC#, 16#1F1F7#), (+"flag-gs", 16#1F1EC#, 16#1F1F8#), (+"flag-gt", 16#1F1EC#, 16#1F1F9#), (+"flag-gu", 16#1F1EC#, 16#1F1FA#), (+"flag-gw", 16#1F1EC#, 16#1F1FC#), (+"flag-gy", 16#1F1EC#, 16#1F1FE#), (+"flag-hk", 16#1F1ED#, 16#1F1F0#), (+"flag-hm", 16#1F1ED#, 16#1F1F2#), (+"flag-hn", 16#1F1ED#, 16#1F1F3#), (+"flag-hr", 16#1F1ED#, 16#1F1F7#), (+"flag-ht", 16#1F1ED#, 16#1F1F9#), (+"flag-hu", 16#1F1ED#, 16#1F1FA#), (+"flag-ic", 16#1F1EE#, 16#1F1E8#), (+"flag-id", 16#1F1EE#, 16#1F1E9#), (+"flag-ie", 16#1F1EE#, 16#1F1EA#), (+"flag-il", 16#1F1EE#, 16#1F1F1#), (+"flag-im", 16#1F1EE#, 16#1F1F2#), (+"flag-in", 16#1F1EE#, 16#1F1F3#), (+"flag-io", 16#1F1EE#, 16#1F1F4#), (+"flag-iq", 16#1F1EE#, 16#1F1F6#), (+"flag-ir", 16#1F1EE#, 16#1F1F7#), (+"flag-is", 16#1F1EE#, 16#1F1F8#), (+"flag-it", 16#1F1EE#, 16#1F1F9#), (+"flag-je", 16#1F1EF#, 16#1F1EA#), (+"flag-jm", 16#1F1EF#, 16#1F1F2#), (+"flag-jo", 16#1F1EF#, 16#1F1F4#), (+"flag-jp", 16#1F1EF#, 16#1F1F5#), (+"flag-ke", 16#1F1F0#, 16#1F1EA#), (+"flag-kg", 16#1F1F0#, 16#1F1EC#), (+"flag-kh", 16#1F1F0#, 16#1F1ED#), (+"flag-ki", 16#1F1F0#, 16#1F1EE#), (+"flag-km", 16#1F1F0#, 16#1F1F2#), (+"flag-kn", 16#1F1F0#, 16#1F1F3#), (+"flag-kp", 16#1F1F0#, 16#1F1F5#), (+"flag-kr", 16#1F1F0#, 16#1F1F7#), (+"flag-kw", 16#1F1F0#, 16#1F1FC#), (+"flag-ky", 16#1F1F0#, 16#1F1FE#), (+"flag-kz", 16#1F1F0#, 16#1F1FF#), (+"flag-la", 16#1F1F1#, 16#1F1E6#), (+"flag-lb", 16#1F1F1#, 16#1F1E7#), (+"flag-lc", 16#1F1F1#, 16#1F1E8#), (+"flag-li", 16#1F1F1#, 16#1F1EE#), (+"flag-lk", 16#1F1F1#, 16#1F1F0#), (+"flag-lr", 16#1F1F1#, 16#1F1F7#), (+"flag-ls", 16#1F1F1#, 16#1F1F8#), (+"flag-lt", 16#1F1F1#, 16#1F1F9#), (+"flag-lu", 16#1F1F1#, 16#1F1FA#), (+"flag-lv", 16#1F1F1#, 16#1F1FB#), (+"flag-ly", 16#1F1F1#, 16#1F1FE#), (+"flag-ma", 16#1F1F2#, 16#1F1E6#), (+"flag-mc", 16#1F1F2#, 16#1F1E8#), (+"flag-md", 16#1F1F2#, 16#1F1E9#), (+"flag-me", 16#1F1F2#, 16#1F1EA#), (+"flag-mf", 16#1F1F2#, 16#1F1EB#), (+"flag-mg", 16#1F1F2#, 16#1F1EC#), (+"flag-mh", 16#1F1F2#, 16#1F1ED#), (+"flag-mk", 16#1F1F2#, 16#1F1F0#), (+"flag-ml", 16#1F1F2#, 16#1F1F1#), (+"flag-mm", 16#1F1F2#, 16#1F1F2#), (+"flag-mn", 16#1F1F2#, 16#1F1F3#), (+"flag-mo", 16#1F1F2#, 16#1F1F4#), (+"flag-mp", 16#1F1F2#, 16#1F1F5#), (+"flag-mq", 16#1F1F2#, 16#1F1F6#), (+"flag-mr", 16#1F1F2#, 16#1F1F7#), (+"flag-ms", 16#1F1F2#, 16#1F1F8#), (+"flag-mt", 16#1F1F2#, 16#1F1F9#), (+"flag-mu", 16#1F1F2#, 16#1F1FA#), (+"flag-mv", 16#1F1F2#, 16#1F1FB#), (+"flag-mw", 16#1F1F2#, 16#1F1FC#), (+"flag-mx", 16#1F1F2#, 16#1F1FD#), (+"flag-my", 16#1F1F2#, 16#1F1FE#), (+"flag-mz", 16#1F1F2#, 16#1F1FF#), (+"flag-na", 16#1F1F3#, 16#1F1E6#), (+"flag-nc", 16#1F1F3#, 16#1F1E8#), (+"flag-ne", 16#1F1F3#, 16#1F1EA#), (+"flag-nf", 16#1F1F3#, 16#1F1EB#), (+"flag-ng", 16#1F1F3#, 16#1F1EC#), (+"flag-ni", 16#1F1F3#, 16#1F1EE#), (+"flag-nl", 16#1F1F3#, 16#1F1F1#), (+"flag-no", 16#1F1F3#, 16#1F1F4#), (+"flag-np", 16#1F1F3#, 16#1F1F5#), (+"flag-nr", 16#1F1F3#, 16#1F1F7#), (+"flag-nu", 16#1F1F3#, 16#1F1FA#), (+"flag-nz", 16#1F1F3#, 16#1F1FF#), (+"flag-om", 16#1F1F4#, 16#1F1F2#), (+"flag-pa", 16#1F1F5#, 16#1F1E6#), (+"flag-pe", 16#1F1F5#, 16#1F1EA#), (+"flag-pf", 16#1F1F5#, 16#1F1EB#), (+"flag-pg", 16#1F1F5#, 16#1F1EC#), (+"flag-ph", 16#1F1F5#, 16#1F1ED#), (+"flag-pk", 16#1F1F5#, 16#1F1F0#), (+"flag-pl", 16#1F1F5#, 16#1F1F1#), (+"flag-pm", 16#1F1F5#, 16#1F1F2#), (+"flag-pn", 16#1F1F5#, 16#1F1F3#), (+"flag-pr", 16#1F1F5#, 16#1F1F7#), (+"flag-ps", 16#1F1F5#, 16#1F1F8#), (+"flag-pt", 16#1F1F5#, 16#1F1F9#), (+"flag-pw", 16#1F1F5#, 16#1F1FC#), (+"flag-py", 16#1F1F5#, 16#1F1FE#), (+"flag-qa", 16#1F1F6#, 16#1F1E6#), (+"flag-re", 16#1F1F7#, 16#1F1EA#), (+"flag-ro", 16#1F1F7#, 16#1F1F4#), (+"flag-rs", 16#1F1F7#, 16#1F1F8#), (+"flag-ru", 16#1F1F7#, 16#1F1FA#), (+"flag-rw", 16#1F1F7#, 16#1F1FC#), (+"flag-sa", 16#1F1F8#, 16#1F1E6#), (+"flag-sb", 16#1F1F8#, 16#1F1E7#), (+"flag-sc", 16#1F1F8#, 16#1F1E8#), (+"flag-sd", 16#1F1F8#, 16#1F1E9#), (+"flag-se", 16#1F1F8#, 16#1F1EA#), (+"flag-sg", 16#1F1F8#, 16#1F1EC#), (+"flag-sh", 16#1F1F8#, 16#1F1ED#), (+"flag-si", 16#1F1F8#, 16#1F1EE#), (+"flag-sj", 16#1F1F8#, 16#1F1EF#), (+"flag-sk", 16#1F1F8#, 16#1F1F0#), (+"flag-sl", 16#1F1F8#, 16#1F1F1#), (+"flag-sm", 16#1F1F8#, 16#1F1F2#), (+"flag-sn", 16#1F1F8#, 16#1F1F3#), (+"flag-so", 16#1F1F8#, 16#1F1F4#), (+"flag-sr", 16#1F1F8#, 16#1F1F7#), (+"flag-ss", 16#1F1F8#, 16#1F1F8#), (+"flag-st", 16#1F1F8#, 16#1F1F9#), (+"flag-sv", 16#1F1F8#, 16#1F1FB#), (+"flag-sx", 16#1F1F8#, 16#1F1FD#), (+"flag-sy", 16#1F1F8#, 16#1F1FE#), (+"flag-sz", 16#1F1F8#, 16#1F1FF#), (+"flag-ta", 16#1F1F9#, 16#1F1E6#), (+"flag-tc", 16#1F1F9#, 16#1F1E8#), (+"flag-td", 16#1F1F9#, 16#1F1E9#), (+"flag-tf", 16#1F1F9#, 16#1F1EB#), (+"flag-tg", 16#1F1F9#, 16#1F1EC#), (+"flag-th", 16#1F1F9#, 16#1F1ED#), (+"flag-tj", 16#1F1F9#, 16#1F1EF#), (+"flag-tk", 16#1F1F9#, 16#1F1F0#), (+"flag-tl", 16#1F1F9#, 16#1F1F1#), (+"flag-tm", 16#1F1F9#, 16#1F1F2#), (+"flag-tn", 16#1F1F9#, 16#1F1F3#), (+"flag-to", 16#1F1F9#, 16#1F1F4#), (+"flag-tr", 16#1F1F9#, 16#1F1F7#), (+"flag-tt", 16#1F1F9#, 16#1F1F9#), (+"flag-tv", 16#1F1F9#, 16#1F1FB#), (+"flag-tw", 16#1F1F9#, 16#1F1FC#), (+"flag-tz", 16#1F1F9#, 16#1F1FF#), (+"flag-ua", 16#1F1FA#, 16#1F1E6#), (+"flag-ug", 16#1F1FA#, 16#1F1EC#), (+"flag-um", 16#1F1FA#, 16#1F1F2#), (+"flag-un", 16#1F1FA#, 16#1F1F3#), (+"flag-us", 16#1F1FA#, 16#1F1F8#), (+"flag-uy", 16#1F1FA#, 16#1F1FE#), (+"flag-uz", 16#1F1FA#, 16#1F1FF#), (+"flag-va", 16#1F1FB#, 16#1F1E6#), (+"flag-vc", 16#1F1FB#, 16#1F1E8#), (+"flag-ve", 16#1F1FB#, 16#1F1EA#), (+"flag-vg", 16#1F1FB#, 16#1F1EC#), (+"flag-vi", 16#1F1FB#, 16#1F1EE#), (+"flag-vn", 16#1F1FB#, 16#1F1F3#), (+"flag-vu", 16#1F1FB#, 16#1F1FA#), (+"flag-wf", 16#1F1FC#, 16#1F1EB#), (+"flag-ws", 16#1F1FC#, 16#1F1F8#), (+"flag-xk", 16#1F1FD#, 16#1F1F0#), (+"flag-ye", 16#1F1FE#, 16#1F1EA#), (+"flag-yt", 16#1F1FE#, 16#1F1F9#), (+"flag-za", 16#1F1FF#, 16#1F1E6#), (+"flag-zm", 16#1F1FF#, 16#1F1F2#), (+"flag-zw", 16#1F1FF#, 16#1F1FC#), (+"flag-sa", 16#1F202#, 16#FE0F#), (+"u6708", 16#1F237#, 16#FE0F#), (+"thermometer", 16#1F321#, 16#FE0F#), (+"mostly_sunny", 16#1F324#, 16#FE0F#), (+"barely_sunny", 16#1F325#, 16#FE0F#), (+"partly_sunny_rain", 16#1F326#, 16#FE0F#), (+"rain_cloud", 16#1F327#, 16#FE0F#), (+"snow_cloud", 16#1F328#, 16#FE0F#), (+"lightning", 16#1F329#, 16#FE0F#), (+"tornado", 16#1F32A#, 16#FE0F#), (+"fog", 16#1F32B#, 16#FE0F#), (+"wind_blowing_face", 16#1F32C#, 16#FE0F#), (+"hot_pepper", 16#1F336#, 16#FE0F#), (+"knife_fork_plate", 16#1F37D#, 16#FE0F#), (+"medal", 16#1F396#, 16#FE0F#), (+"reminder_ribbon", 16#1F397#, 16#FE0F#), (+"studio_microphone", 16#1F399#, 16#FE0F#), (+"level_slider", 16#1F39A#, 16#FE0F#), (+"control_knobs", 16#1F39B#, 16#FE0F#), (+"film_frames", 16#1F39E#, 16#FE0F#), (+"admission_tickets", 16#1F39F#, 16#FE0F#), (+"weight_lifter", 16#1F3CB#, 16#FE0F#), (+"golfer", 16#1F3CC#, 16#FE0F#), (+"racing_motorcycle", 16#1F3CD#, 16#FE0F#), (+"racing_car", 16#1F3CE#, 16#FE0F#), (+"snow_capped_mountain", 16#1F3D4#, 16#FE0F#), (+"camping", 16#1F3D5#, 16#FE0F#), (+"beach_with_umbrella", 16#1F3D6#, 16#FE0F#), (+"building_construction", 16#1F3D7#, 16#FE0F#), (+"house_buildings", 16#1F3D8#, 16#FE0F#), (+"cityscape", 16#1F3D9#, 16#FE0F#), (+"derelict_house_building", 16#1F3DA#, 16#FE0F#), (+"classical_building", 16#1F3DB#, 16#FE0F#), (+"desert", 16#1F3DC#, 16#FE0F#), (+"desert_island", 16#1F3DD#, 16#FE0F#), (+"national_park", 16#1F3DE#, 16#FE0F#), (+"stadium", 16#1F3DF#, 16#FE0F#), (+"waving_white_flag", 16#1F3F3#, 16#FE0F#), (+"rosette", 16#1F3F5#, 16#FE0F#), (+"label", 16#1F3F7#, 16#FE0F#), (+"chipmunk", 16#1F43F#, 16#FE0F#), (+"eye", 16#1F441#, 16#FE0F#), (+"film_projector", 16#1F4FD#, 16#FE0F#), (+"om_symbol", 16#1F549#, 16#FE0F#), (+"dove_of_peace", 16#1F54A#, 16#FE0F#), (+"candle", 16#1F56F#, 16#FE0F#), (+"mantelpiece_clock", 16#1F570#, 16#FE0F#), (+"hole", 16#1F573#, 16#FE0F#), (+"man_in_business_suit_levitating", 16#1F574#, 16#FE0F#), (+"sleuth_or_spy", 16#1F575#, 16#FE0F#), (+"dark_sunglasses", 16#1F576#, 16#FE0F#), (+"spider", 16#1F577#, 16#FE0F#), (+"spider_web", 16#1F578#, 16#FE0F#), (+"joystick", 16#1F579#, 16#FE0F#), (+"linked_paperclips", 16#1F587#, 16#FE0F#), (+"lower_left_ballpoint_pen", 16#1F58A#, 16#FE0F#), (+"lower_left_fountain_pen", 16#1F58B#, 16#FE0F#), (+"lower_left_paintbrush", 16#1F58C#, 16#FE0F#), (+"lower_left_crayon", 16#1F58D#, 16#FE0F#), (+"raised_hand_with_fingers_splayed", 16#1F590#, 16#FE0F#), (+"desktop_computer", 16#1F5A5#, 16#FE0F#), (+"printer", 16#1F5A8#, 16#FE0F#), (+"three_button_mouse", 16#1F5B1#, 16#FE0F#), (+"trackball", 16#1F5B2#, 16#FE0F#), (+"frame_with_picture", 16#1F5BC#, 16#FE0F#), (+"card_index_dividers", 16#1F5C2#, 16#FE0F#), (+"card_file_box", 16#1F5C3#, 16#FE0F#), (+"file_cabinet", 16#1F5C4#, 16#FE0F#), (+"wastebasket", 16#1F5D1#, 16#FE0F#), (+"spiral_note_pad", 16#1F5D2#, 16#FE0F#), (+"spiral_calendar_pad", 16#1F5D3#, 16#FE0F#), (+"compression", 16#1F5DC#, 16#FE0F#), (+"old_key", 16#1F5DD#, 16#FE0F#), (+"rolled_up_newspaper", 16#1F5DE#, 16#FE0F#), (+"dagger_knife", 16#1F5E1#, 16#FE0F#), (+"speaking_head_in_silhouette", 16#1F5E3#, 16#FE0F#), (+"left_speech_bubble", 16#1F5E8#, 16#FE0F#), (+"right_anger_bubble", 16#1F5EF#, 16#FE0F#), (+"ballot_box_with_ballot", 16#1F5F3#, 16#FE0F#), (+"world_map", 16#1F5FA#, 16#FE0F#), (+"couch_and_lamp", 16#1F6CB#, 16#FE0F#), (+"shopping_bags", 16#1F6CD#, 16#FE0F#), (+"bellhop_bell", 16#1F6CE#, 16#FE0F#), (+"bed", 16#1F6CF#, 16#FE0F#), (+"hammer_and_wrench", 16#1F6E0#, 16#FE0F#), (+"shield", 16#1F6E1#, 16#FE0F#), (+"oil_drum", 16#1F6E2#, 16#FE0F#), (+"motorway", 16#1F6E3#, 16#FE0F#), (+"railway_track", 16#1F6E4#, 16#FE0F#), (+"motor_boat", 16#1F6E5#, 16#FE0F#), (+"small_airplane", 16#1F6E9#, 16#FE0F#), (+"satellite", 16#1F6F0#, 16#FE0F#), (+"passenger_ship", 16#1F6F3#, 16#FE0F#), (+"bangbang", 16#203C#, 16#FE0F#), (+"interrobang", 16#2049#, 16#FE0F#), (+"tm", 16#2122#, 16#FE0F#), (+"information_source", 16#2139#, 16#FE0F#), (+"left_right_arrow", 16#2194#, 16#FE0F#), (+"arrow_up_down", 16#2195#, 16#FE0F#), (+"arrow_upper_left", 16#2196#, 16#FE0F#), (+"arrow_upper_right", 16#2197#, 16#FE0F#), (+"arrow_lower_right", 16#2198#, 16#FE0F#), (+"arrow_lower_left", 16#2199#, 16#FE0F#), (+"leftwards_arrow_with_hook", 16#21A9#, 16#FE0F#), (+"arrow_right_hook", 16#21AA#, 16#FE0F#), (+"keyboard", 16#2328#, 16#FE0F#), (+"eject", 16#23CF#, 16#FE0F#), (+"black_right_pointing_double_triangle_with_vertical_bar", 16#23ED#, 16#FE0F#), (+"black_left_pointing_double_triangle_with_vertical_bar", 16#23EE#, 16#FE0F#), (+"black_right_pointing_triangle_with_double_vertical_bar", 16#23EF#, 16#FE0F#), (+"stopwatch", 16#23F1#, 16#FE0F#), (+"timer_clock", 16#23F2#, 16#FE0F#), (+"double_vertical_bar", 16#23F8#, 16#FE0F#), (+"black_square_for_stop", 16#23F9#, 16#FE0F#), (+"black_circle_for_record", 16#23FA#, 16#FE0F#), (+"m", 16#24C2#, 16#FE0F#), (+"black_small_square", 16#25AA#, 16#FE0F#), (+"white_small_square", 16#25AB#, 16#FE0F#), (+"arrow_forward", 16#25B6#, 16#FE0F#), (+"arrow_backward", 16#25C0#, 16#FE0F#), (+"white_medium_square", 16#25FB#, 16#FE0F#), (+"black_medium_square", 16#25FC#, 16#FE0F#), (+"sunny", 16#2600#, 16#FE0F#), (+"cloud", 16#2601#, 16#FE0F#), (+"umbrella", 16#2602#, 16#FE0F#), (+"snowman", 16#2603#, 16#FE0F#), (+"comet", 16#2604#, 16#FE0F#), (+"phone", 16#260E#, 16#FE0F#), (+"ballot_box_with_check", 16#2611#, 16#FE0F#), (+"shamrock", 16#2618#, 16#FE0F#), (+"point_up", 16#261D#, 16#FE0F#), (+"skull_and_crossbones", 16#2620#, 16#FE0F#), (+"radioactive_sign", 16#2622#, 16#FE0F#), (+"biohazard_sign", 16#2623#, 16#FE0F#), (+"orthodox_cross", 16#2626#, 16#FE0F#), (+"star_and_crescent", 16#262A#, 16#FE0F#), (+"peace_symbol", 16#262E#, 16#FE0F#), (+"yin_yang", 16#262F#, 16#FE0F#), (+"wheel_of_dharma", 16#2638#, 16#FE0F#), (+"white_frowning_face", 16#2639#, 16#FE0F#), (+"relaxed", 16#263A#, 16#FE0F#), (+"female_sign", 16#2640#, 16#FE0F#), (+"male_sign", 16#2642#, 16#FE0F#), (+"chess_pawn", 16#265F#, 16#FE0F#), (+"spades", 16#2660#, 16#FE0F#), (+"clubs", 16#2663#, 16#FE0F#), (+"hearts", 16#2665#, 16#FE0F#), (+"diamonds", 16#2666#, 16#FE0F#), (+"hotsprings", 16#2668#, 16#FE0F#), (+"recycle", 16#267B#, 16#FE0F#), (+"infinity", 16#267E#, 16#FE0F#), (+"hammer_and_pick", 16#2692#, 16#FE0F#), (+"crossed_swords", 16#2694#, 16#FE0F#), (+"medical_symbol", 16#2695#, 16#FE0F#), (+"scales", 16#2696#, 16#FE0F#), (+"alembic", 16#2697#, 16#FE0F#), (+"gear", 16#2699#, 16#FE0F#), (+"atom_symbol", 16#269B#, 16#FE0F#), (+"fleur_de_lis", 16#269C#, 16#FE0F#), (+"warning", 16#26A0#, 16#FE0F#), (+"transgender_symbol", 16#26A7#, 16#FE0F#), (+"coffin", 16#26B0#, 16#FE0F#), (+"funeral_urn", 16#26B1#, 16#FE0F#), (+"thunder_cloud_and_rain", 16#26C8#, 16#FE0F#), (+"pick", 16#26CF#, 16#FE0F#), (+"helmet_with_white_cross", 16#26D1#, 16#FE0F#), (+"chains", 16#26D3#, 16#FE0F#), (+"shinto_shrine", 16#26E9#, 16#FE0F#), (+"mountain", 16#26F0#, 16#FE0F#), (+"umbrella_on_ground", 16#26F1#, 16#FE0F#), (+"ferry", 16#26F4#, 16#FE0F#), (+"skier", 16#26F7#, 16#FE0F#), (+"ice_skate", 16#26F8#, 16#FE0F#), (+"person_with_ball", 16#26F9#, 16#FE0F#), (+"scissors", 16#2702#, 16#FE0F#), (+"airplane", 16#2708#, 16#FE0F#), (+"email", 16#2709#, 16#FE0F#), (+"v", 16#270C#, 16#FE0F#), (+"writing_hand", 16#270D#, 16#FE0F#), (+"pencil2", 16#270F#, 16#FE0F#), (+"black_nib", 16#2712#, 16#FE0F#), (+"heavy_check_mark", 16#2714#, 16#FE0F#), (+"heavy_multiplication_x", 16#2716#, 16#FE0F#), (+"latin_cross", 16#271D#, 16#FE0F#), (+"star_of_david", 16#2721#, 16#FE0F#), (+"eight_spoked_asterisk", 16#2733#, 16#FE0F#), (+"eight_pointed_black_star", 16#2734#, 16#FE0F#), (+"snowflake", 16#2744#, 16#FE0F#), (+"sparkle", 16#2747#, 16#FE0F#), (+"heavy_heart_exclamation_mark_ornament", 16#2763#, 16#FE0F#), (+"heart", 16#2764#, 16#FE0F#), (+"arrow_right", 16#27A1#, 16#FE0F#), (+"arrow_heading_up", 16#2934#, 16#FE0F#), (+"arrow_heading_down", 16#2935#, 16#FE0F#), (+"arrow_left", 16#2B05#, 16#FE0F#), (+"arrow_up", 16#2B06#, 16#FE0F#), (+"arrow_down", 16#2B07#, 16#FE0F#), (+"wavy_dash", 16#3030#, 16#FE0F#), (+"part_alternation_mark", 16#303D#, 16#FE0F#), (+"congratulations", 16#3297#, 16#FE0F#), (+"secret", 16#3299#, 16#FE0F#)); Name_Emojis_1 : constant array (Positive range <>) of Text_1_Points_Pair := ((+"mahjong", 16#1F004#), (+"black_joker", 16#1F0CF#), (+"ab", 16#1F18E#), (+"cl", 16#1F191#), (+"cool", 16#1F192#), (+"free", 16#1F193#), (+"id", 16#1F194#), (+"new", 16#1F195#), (+"ng", 16#1F196#), (+"ok", 16#1F197#), (+"sos", 16#1F198#), (+"up", 16#1F199#), (+"vs", 16#1F19A#), (+"koko", 16#1F201#), (+"u7121", 16#1F21A#), (+"u6307", 16#1F22F#), (+"u7981", 16#1F232#), (+"u7a7a", 16#1F233#), (+"u5408", 16#1F234#), (+"u6e80", 16#1F235#), (+"u6709", 16#1F236#), (+"u7533", 16#1F238#), (+"u5272", 16#1F239#), (+"u55b6", 16#1F23A#), (+"ideograph_advantage", 16#1F250#), (+"accept", 16#1F251#), (+"cyclone", 16#1F300#), (+"foggy", 16#1F301#), (+"closed_umbrella", 16#1F302#), (+"night_with_stars", 16#1F303#), (+"sunrise_over_mountains", 16#1F304#), (+"sunrise", 16#1F305#), (+"city_sunset", 16#1F306#), (+"city_sunrise", 16#1F307#), (+"rainbow", 16#1F308#), (+"bridge_at_night", 16#1F309#), (+"ocean", 16#1F30A#), (+"volcano", 16#1F30B#), (+"milky_way", 16#1F30C#), (+"earth_africa", 16#1F30D#), (+"earth_americas", 16#1F30E#), (+"earth_asia", 16#1F30F#), (+"globe_with_meridians", 16#1F310#), (+"new_moon", 16#1F311#), (+"waxing_crescent_moon", 16#1F312#), (+"first_quarter_moon", 16#1F313#), (+"moon", 16#1F314#), (+"full_moon", 16#1F315#), (+"waning_gibbous_moon", 16#1F316#), (+"last_quarter_moon", 16#1F317#), (+"waning_crescent_moon", 16#1F318#), (+"crescent_moon", 16#1F319#), (+"new_moon_with_face", 16#1F31A#), (+"first_quarter_moon_with_face", 16#1F31B#), (+"last_quarter_moon_with_face", 16#1F31C#), (+"full_moon_with_face", 16#1F31D#), (+"sun_with_face", 16#1F31E#), (+"star2", 16#1F31F#), (+"stars", 16#1F320#), (+"hotdog", 16#1F32D#), (+"taco", 16#1F32E#), (+"burrito", 16#1F32F#), (+"chestnut", 16#1F330#), (+"seedling", 16#1F331#), (+"evergreen_tree", 16#1F332#), (+"deciduous_tree", 16#1F333#), (+"palm_tree", 16#1F334#), (+"cactus", 16#1F335#), (+"tulip", 16#1F337#), (+"cherry_blossom", 16#1F338#), (+"rose", 16#1F339#), (+"hibiscus", 16#1F33A#), (+"sunflower", 16#1F33B#), (+"blossom", 16#1F33C#), (+"corn", 16#1F33D#), (+"ear_of_rice", 16#1F33E#), (+"herb", 16#1F33F#), (+"four_leaf_clover", 16#1F340#), (+"maple_leaf", 16#1F341#), (+"fallen_leaf", 16#1F342#), (+"leaves", 16#1F343#), (+"mushroom", 16#1F344#), (+"tomato", 16#1F345#), (+"eggplant", 16#1F346#), (+"grapes", 16#1F347#), (+"melon", 16#1F348#), (+"watermelon", 16#1F349#), (+"tangerine", 16#1F34A#), (+"lemon", 16#1F34B#), (+"banana", 16#1F34C#), (+"pineapple", 16#1F34D#), (+"apple", 16#1F34E#), (+"green_apple", 16#1F34F#), (+"pear", 16#1F350#), (+"peach", 16#1F351#), (+"cherries", 16#1F352#), (+"strawberry", 16#1F353#), (+"hamburger", 16#1F354#), (+"pizza", 16#1F355#), (+"meat_on_bone", 16#1F356#), (+"poultry_leg", 16#1F357#), (+"rice_cracker", 16#1F358#), (+"rice_ball", 16#1F359#), (+"rice", 16#1F35A#), (+"curry", 16#1F35B#), (+"ramen", 16#1F35C#), (+"spaghetti", 16#1F35D#), (+"bread", 16#1F35E#), (+"fries", 16#1F35F#), (+"sweet_potato", 16#1F360#), (+"dango", 16#1F361#), (+"oden", 16#1F362#), (+"sushi", 16#1F363#), (+"fried_shrimp", 16#1F364#), (+"fish_cake", 16#1F365#), (+"icecream", 16#1F366#), (+"shaved_ice", 16#1F367#), (+"ice_cream", 16#1F368#), (+"doughnut", 16#1F369#), (+"cookie", 16#1F36A#), (+"chocolate_bar", 16#1F36B#), (+"candy", 16#1F36C#), (+"lollipop", 16#1F36D#), (+"custard", 16#1F36E#), (+"honey_pot", 16#1F36F#), (+"cake", 16#1F370#), (+"bento", 16#1F371#), (+"stew", 16#1F372#), (+"fried_egg", 16#1F373#), (+"fork_and_knife", 16#1F374#), (+"tea", 16#1F375#), (+"sake", 16#1F376#), (+"wine_glass", 16#1F377#), (+"cocktail", 16#1F378#), (+"tropical_drink", 16#1F379#), (+"beer", 16#1F37A#), (+"beers", 16#1F37B#), (+"baby_bottle", 16#1F37C#), (+"champagne", 16#1F37E#), (+"popcorn", 16#1F37F#), (+"ribbon", 16#1F380#), (+"gift", 16#1F381#), (+"birthday", 16#1F382#), (+"jack_o_lantern", 16#1F383#), (+"christmas_tree", 16#1F384#), (+"santa", 16#1F385#), (+"fireworks", 16#1F386#), (+"sparkler", 16#1F387#), (+"balloon", 16#1F388#), (+"tada", 16#1F389#), (+"confetti_ball", 16#1F38A#), (+"tanabata_tree", 16#1F38B#), (+"crossed_flags", 16#1F38C#), (+"bamboo", 16#1F38D#), (+"dolls", 16#1F38E#), (+"flags", 16#1F38F#), (+"wind_chime", 16#1F390#), (+"rice_scene", 16#1F391#), (+"school_satchel", 16#1F392#), (+"mortar_board", 16#1F393#), (+"carousel_horse", 16#1F3A0#), (+"ferris_wheel", 16#1F3A1#), (+"roller_coaster", 16#1F3A2#), (+"fishing_pole_and_fish", 16#1F3A3#), (+"microphone", 16#1F3A4#), (+"movie_camera", 16#1F3A5#), (+"cinema", 16#1F3A6#), (+"headphones", 16#1F3A7#), (+"art", 16#1F3A8#), (+"tophat", 16#1F3A9#), (+"circus_tent", 16#1F3AA#), (+"ticket", 16#1F3AB#), (+"clapper", 16#1F3AC#), (+"performing_arts", 16#1F3AD#), (+"video_game", 16#1F3AE#), (+"dart", 16#1F3AF#), (+"slot_machine", 16#1F3B0#), (+"8ball", 16#1F3B1#), (+"game_die", 16#1F3B2#), (+"bowling", 16#1F3B3#), (+"flower_playing_cards", 16#1F3B4#), (+"musical_note", 16#1F3B5#), (+"notes", 16#1F3B6#), (+"saxophone", 16#1F3B7#), (+"guitar", 16#1F3B8#), (+"musical_keyboard", 16#1F3B9#), (+"trumpet", 16#1F3BA#), (+"violin", 16#1F3BB#), (+"musical_score", 16#1F3BC#), (+"running_shirt_with_sash", 16#1F3BD#), (+"tennis", 16#1F3BE#), (+"ski", 16#1F3BF#), (+"basketball", 16#1F3C0#), (+"checkered_flag", 16#1F3C1#), (+"snowboarder", 16#1F3C2#), (+"runner", 16#1F3C3#), (+"surfer", 16#1F3C4#), (+"sports_medal", 16#1F3C5#), (+"trophy", 16#1F3C6#), (+"horse_racing", 16#1F3C7#), (+"football", 16#1F3C8#), (+"rugby_football", 16#1F3C9#), (+"swimmer", 16#1F3CA#), (+"cricket_bat_and_ball", 16#1F3CF#), (+"volleyball", 16#1F3D0#), (+"field_hockey_stick_and_ball", 16#1F3D1#), (+"ice_hockey_stick_and_puck", 16#1F3D2#), (+"table_tennis_paddle_and_ball", 16#1F3D3#), (+"house", 16#1F3E0#), (+"house_with_garden", 16#1F3E1#), (+"office", 16#1F3E2#), (+"post_office", 16#1F3E3#), (+"european_post_office", 16#1F3E4#), (+"hospital", 16#1F3E5#), (+"bank", 16#1F3E6#), (+"atm", 16#1F3E7#), (+"hotel", 16#1F3E8#), (+"love_hotel", 16#1F3E9#), (+"convenience_store", 16#1F3EA#), (+"school", 16#1F3EB#), (+"department_store", 16#1F3EC#), (+"factory", 16#1F3ED#), (+"izakaya_lantern", 16#1F3EE#), (+"japanese_castle", 16#1F3EF#), (+"european_castle", 16#1F3F0#), (+"waving_black_flag", 16#1F3F4#), (+"badminton_racquet_and_shuttlecock", 16#1F3F8#), (+"bow_and_arrow", 16#1F3F9#), (+"amphora", 16#1F3FA#), (+"skin-tone-2", 16#1F3FB#), (+"skin-tone-3", 16#1F3FC#), (+"skin-tone-4", 16#1F3FD#), (+"skin-tone-5", 16#1F3FE#), (+"skin-tone-6", 16#1F3FF#), (+"rat", 16#1F400#), (+"mouse2", 16#1F401#), (+"ox", 16#1F402#), (+"water_buffalo", 16#1F403#), (+"cow2", 16#1F404#), (+"tiger2", 16#1F405#), (+"leopard", 16#1F406#), (+"rabbit2", 16#1F407#), (+"cat2", 16#1F408#), (+"dragon", 16#1F409#), (+"crocodile", 16#1F40A#), (+"whale2", 16#1F40B#), (+"snail", 16#1F40C#), (+"snake", 16#1F40D#), (+"racehorse", 16#1F40E#), (+"ram", 16#1F40F#), (+"goat", 16#1F410#), (+"sheep", 16#1F411#), (+"monkey", 16#1F412#), (+"rooster", 16#1F413#), (+"chicken", 16#1F414#), (+"dog2", 16#1F415#), (+"pig2", 16#1F416#), (+"boar", 16#1F417#), (+"elephant", 16#1F418#), (+"octopus", 16#1F419#), (+"shell", 16#1F41A#), (+"bug", 16#1F41B#), (+"ant", 16#1F41C#), (+"bee", 16#1F41D#), (+"ladybug", 16#1F41E#), (+"fish", 16#1F41F#), (+"tropical_fish", 16#1F420#), (+"blowfish", 16#1F421#), (+"turtle", 16#1F422#), (+"hatching_chick", 16#1F423#), (+"baby_chick", 16#1F424#), (+"hatched_chick", 16#1F425#), (+"bird", 16#1F426#), (+"penguin", 16#1F427#), (+"koala", 16#1F428#), (+"poodle", 16#1F429#), (+"dromedary_camel", 16#1F42A#), (+"camel", 16#1F42B#), (+"dolphin", 16#1F42C#), (+"mouse", 16#1F42D#), (+"cow", 16#1F42E#), (+"tiger", 16#1F42F#), (+"rabbit", 16#1F430#), (+"cat", 16#1F431#), (+"dragon_face", 16#1F432#), (+"whale", 16#1F433#), (+"horse", 16#1F434#), (+"monkey_face", 16#1F435#), (+"dog", 16#1F436#), (+"pig", 16#1F437#), (+"frog", 16#1F438#), (+"hamster", 16#1F439#), (+"wolf", 16#1F43A#), (+"bear", 16#1F43B#), (+"panda_face", 16#1F43C#), (+"pig_nose", 16#1F43D#), (+"feet", 16#1F43E#), (+"eyes", 16#1F440#), (+"ear", 16#1F442#), (+"nose", 16#1F443#), (+"lips", 16#1F444#), (+"tongue", 16#1F445#), (+"point_up_2", 16#1F446#), (+"point_down", 16#1F447#), (+"point_left", 16#1F448#), (+"point_right", 16#1F449#), (+"facepunch", 16#1F44A#), (+"wave", 16#1F44B#), (+"ok_hand", 16#1F44C#), (+"+1", 16#1F44D#), (+"-1", 16#1F44E#), (+"clap", 16#1F44F#), (+"open_hands", 16#1F450#), (+"crown", 16#1F451#), (+"womans_hat", 16#1F452#), (+"eyeglasses", 16#1F453#), (+"necktie", 16#1F454#), (+"shirt", 16#1F455#), (+"jeans", 16#1F456#), (+"dress", 16#1F457#), (+"kimono", 16#1F458#), (+"bikini", 16#1F459#), (+"womans_clothes", 16#1F45A#), (+"purse", 16#1F45B#), (+"handbag", 16#1F45C#), (+"pouch", 16#1F45D#), (+"mans_shoe", 16#1F45E#), (+"athletic_shoe", 16#1F45F#), (+"high_heel", 16#1F460#), (+"sandal", 16#1F461#), (+"boot", 16#1F462#), (+"footprints", 16#1F463#), (+"bust_in_silhouette", 16#1F464#), (+"busts_in_silhouette", 16#1F465#), (+"boy", 16#1F466#), (+"girl", 16#1F467#), (+"man", 16#1F468#), (+"woman", 16#1F469#), (+"family", 16#1F46A#), (+"man_and_woman_holding_hands", 16#1F46B#), (+"two_men_holding_hands", 16#1F46C#), (+"two_women_holding_hands", 16#1F46D#), (+"cop", 16#1F46E#), (+"dancers", 16#1F46F#), (+"bride_with_veil", 16#1F470#), (+"person_with_blond_hair", 16#1F471#), (+"man_with_gua_pi_mao", 16#1F472#), (+"man_with_turban", 16#1F473#), (+"older_man", 16#1F474#), (+"older_woman", 16#1F475#), (+"baby", 16#1F476#), (+"construction_worker", 16#1F477#), (+"princess", 16#1F478#), (+"japanese_ogre", 16#1F479#), (+"japanese_goblin", 16#1F47A#), (+"ghost", 16#1F47B#), (+"angel", 16#1F47C#), (+"alien", 16#1F47D#), (+"space_invader", 16#1F47E#), (+"imp", 16#1F47F#), (+"skull", 16#1F480#), (+"information_desk_person", 16#1F481#), (+"guardsman", 16#1F482#), (+"dancer", 16#1F483#), (+"lipstick", 16#1F484#), (+"nail_care", 16#1F485#), (+"massage", 16#1F486#), (+"haircut", 16#1F487#), (+"barber", 16#1F488#), (+"syringe", 16#1F489#), (+"pill", 16#1F48A#), (+"kiss", 16#1F48B#), (+"love_letter", 16#1F48C#), (+"ring", 16#1F48D#), (+"gem", 16#1F48E#), (+"couplekiss", 16#1F48F#), (+"bouquet", 16#1F490#), (+"couple_with_heart", 16#1F491#), (+"wedding", 16#1F492#), (+"heartbeat", 16#1F493#), (+"broken_heart", 16#1F494#), (+"two_hearts", 16#1F495#), (+"sparkling_heart", 16#1F496#), (+"heartpulse", 16#1F497#), (+"cupid", 16#1F498#), (+"blue_heart", 16#1F499#), (+"green_heart", 16#1F49A#), (+"yellow_heart", 16#1F49B#), (+"purple_heart", 16#1F49C#), (+"gift_heart", 16#1F49D#), (+"revolving_hearts", 16#1F49E#), (+"heart_decoration", 16#1F49F#), (+"diamond_shape_with_a_dot_inside", 16#1F4A0#), (+"bulb", 16#1F4A1#), (+"anger", 16#1F4A2#), (+"bomb", 16#1F4A3#), (+"zzz", 16#1F4A4#), (+"boom", 16#1F4A5#), (+"sweat_drops", 16#1F4A6#), (+"droplet", 16#1F4A7#), (+"dash", 16#1F4A8#), (+"hankey", 16#1F4A9#), (+"muscle", 16#1F4AA#), (+"dizzy", 16#1F4AB#), (+"speech_balloon", 16#1F4AC#), (+"thought_balloon", 16#1F4AD#), (+"white_flower", 16#1F4AE#), (+"100", 16#1F4AF#), (+"moneybag", 16#1F4B0#), (+"currency_exchange", 16#1F4B1#), (+"heavy_dollar_sign", 16#1F4B2#), (+"credit_card", 16#1F4B3#), (+"yen", 16#1F4B4#), (+"dollar", 16#1F4B5#), (+"euro", 16#1F4B6#), (+"pound", 16#1F4B7#), (+"money_with_wings", 16#1F4B8#), (+"chart", 16#1F4B9#), (+"seat", 16#1F4BA#), (+"computer", 16#1F4BB#), (+"briefcase", 16#1F4BC#), (+"minidisc", 16#1F4BD#), (+"floppy_disk", 16#1F4BE#), (+"cd", 16#1F4BF#), (+"dvd", 16#1F4C0#), (+"file_folder", 16#1F4C1#), (+"open_file_folder", 16#1F4C2#), (+"page_with_curl", 16#1F4C3#), (+"page_facing_up", 16#1F4C4#), (+"date", 16#1F4C5#), (+"calendar", 16#1F4C6#), (+"card_index", 16#1F4C7#), (+"chart_with_upwards_trend", 16#1F4C8#), (+"chart_with_downwards_trend", 16#1F4C9#), (+"bar_chart", 16#1F4CA#), (+"clipboard", 16#1F4CB#), (+"pushpin", 16#1F4CC#), (+"round_pushpin", 16#1F4CD#), (+"paperclip", 16#1F4CE#), (+"straight_ruler", 16#1F4CF#), (+"triangular_ruler", 16#1F4D0#), (+"bookmark_tabs", 16#1F4D1#), (+"ledger", 16#1F4D2#), (+"notebook", 16#1F4D3#), (+"notebook_with_decorative_cover", 16#1F4D4#), (+"closed_book", 16#1F4D5#), (+"book", 16#1F4D6#), (+"green_book", 16#1F4D7#), (+"blue_book", 16#1F4D8#), (+"orange_book", 16#1F4D9#), (+"books", 16#1F4DA#), (+"name_badge", 16#1F4DB#), (+"scroll", 16#1F4DC#), (+"memo", 16#1F4DD#), (+"telephone_receiver", 16#1F4DE#), (+"pager", 16#1F4DF#), (+"fax", 16#1F4E0#), (+"satellite_antenna", 16#1F4E1#), (+"loudspeaker", 16#1F4E2#), (+"mega", 16#1F4E3#), (+"outbox_tray", 16#1F4E4#), (+"inbox_tray", 16#1F4E5#), (+"package", 16#1F4E6#), (+"e-mail", 16#1F4E7#), (+"incoming_envelope", 16#1F4E8#), (+"envelope_with_arrow", 16#1F4E9#), (+"mailbox_closed", 16#1F4EA#), (+"mailbox", 16#1F4EB#), (+"mailbox_with_mail", 16#1F4EC#), (+"mailbox_with_no_mail", 16#1F4ED#), (+"postbox", 16#1F4EE#), (+"postal_horn", 16#1F4EF#), (+"newspaper", 16#1F4F0#), (+"iphone", 16#1F4F1#), (+"calling", 16#1F4F2#), (+"vibration_mode", 16#1F4F3#), (+"mobile_phone_off", 16#1F4F4#), (+"no_mobile_phones", 16#1F4F5#), (+"signal_strength", 16#1F4F6#), (+"camera", 16#1F4F7#), (+"camera_with_flash", 16#1F4F8#), (+"video_camera", 16#1F4F9#), (+"tv", 16#1F4FA#), (+"radio", 16#1F4FB#), (+"vhs", 16#1F4FC#), (+"prayer_beads", 16#1F4FF#), (+"twisted_rightwards_arrows", 16#1F500#), (+"repeat", 16#1F501#), (+"repeat_one", 16#1F502#), (+"arrows_clockwise", 16#1F503#), (+"arrows_counterclockwise", 16#1F504#), (+"low_brightness", 16#1F505#), (+"high_brightness", 16#1F506#), (+"mute", 16#1F507#), (+"speaker", 16#1F508#), (+"sound", 16#1F509#), (+"loud_sound", 16#1F50A#), (+"battery", 16#1F50B#), (+"electric_plug", 16#1F50C#), (+"mag", 16#1F50D#), (+"mag_right", 16#1F50E#), (+"lock_with_ink_pen", 16#1F50F#), (+"closed_lock_with_key", 16#1F510#), (+"key", 16#1F511#), (+"lock", 16#1F512#), (+"unlock", 16#1F513#), (+"bell", 16#1F514#), (+"no_bell", 16#1F515#), (+"bookmark", 16#1F516#), (+"link", 16#1F517#), (+"radio_button", 16#1F518#), (+"back", 16#1F519#), (+"end", 16#1F51A#), (+"on", 16#1F51B#), (+"soon", 16#1F51C#), (+"top", 16#1F51D#), (+"underage", 16#1F51E#), (+"keycap_ten", 16#1F51F#), (+"capital_abcd", 16#1F520#), (+"abcd", 16#1F521#), (+"1234", 16#1F522#), (+"symbols", 16#1F523#), (+"abc", 16#1F524#), (+"fire", 16#1F525#), (+"flashlight", 16#1F526#), (+"wrench", 16#1F527#), (+"hammer", 16#1F528#), (+"nut_and_bolt", 16#1F529#), (+"hocho", 16#1F52A#), (+"gun", 16#1F52B#), (+"microscope", 16#1F52C#), (+"telescope", 16#1F52D#), (+"crystal_ball", 16#1F52E#), (+"six_pointed_star", 16#1F52F#), (+"beginner", 16#1F530#), (+"trident", 16#1F531#), (+"black_square_button", 16#1F532#), (+"white_square_button", 16#1F533#), (+"red_circle", 16#1F534#), (+"large_blue_circle", 16#1F535#), (+"large_orange_diamond", 16#1F536#), (+"large_blue_diamond", 16#1F537#), (+"small_orange_diamond", 16#1F538#), (+"small_blue_diamond", 16#1F539#), (+"small_red_triangle", 16#1F53A#), (+"small_red_triangle_down", 16#1F53B#), (+"arrow_up_small", 16#1F53C#), (+"arrow_down_small", 16#1F53D#), (+"kaaba", 16#1F54B#), (+"mosque", 16#1F54C#), (+"synagogue", 16#1F54D#), (+"menorah_with_nine_branches", 16#1F54E#), (+"clock1", 16#1F550#), (+"clock2", 16#1F551#), (+"clock3", 16#1F552#), (+"clock4", 16#1F553#), (+"clock5", 16#1F554#), (+"clock6", 16#1F555#), (+"clock7", 16#1F556#), (+"clock8", 16#1F557#), (+"clock9", 16#1F558#), (+"clock10", 16#1F559#), (+"clock11", 16#1F55A#), (+"clock12", 16#1F55B#), (+"clock130", 16#1F55C#), (+"clock230", 16#1F55D#), (+"clock330", 16#1F55E#), (+"clock430", 16#1F55F#), (+"clock530", 16#1F560#), (+"clock630", 16#1F561#), (+"clock730", 16#1F562#), (+"clock830", 16#1F563#), (+"clock930", 16#1F564#), (+"clock1030", 16#1F565#), (+"clock1130", 16#1F566#), (+"clock1230", 16#1F567#), (+"man_dancing", 16#1F57A#), (+"middle_finger", 16#1F595#), (+"spock-hand", 16#1F596#), (+"black_heart", 16#1F5A4#), (+"mount_fuji", 16#1F5FB#), (+"tokyo_tower", 16#1F5FC#), (+"statue_of_liberty", 16#1F5FD#), (+"japan", 16#1F5FE#), (+"moyai", 16#1F5FF#), (+"grinning", 16#1F600#), (+"grin", 16#1F601#), (+"joy", 16#1F602#), (+"smiley", 16#1F603#), (+"smile", 16#1F604#), (+"sweat_smile", 16#1F605#), (+"laughing", 16#1F606#), (+"innocent", 16#1F607#), (+"smiling_imp", 16#1F608#), (+"wink", 16#1F609#), (+"blush", 16#1F60A#), (+"yum", 16#1F60B#), (+"relieved", 16#1F60C#), (+"heart_eyes", 16#1F60D#), (+"sunglasses", 16#1F60E#), (+"smirk", 16#1F60F#), (+"neutral_face", 16#1F610#), (+"expressionless", 16#1F611#), (+"unamused", 16#1F612#), (+"sweat", 16#1F613#), (+"pensive", 16#1F614#), (+"confused", 16#1F615#), (+"confounded", 16#1F616#), (+"kissing", 16#1F617#), (+"kissing_heart", 16#1F618#), (+"kissing_smiling_eyes", 16#1F619#), (+"kissing_closed_eyes", 16#1F61A#), (+"stuck_out_tongue", 16#1F61B#), (+"stuck_out_tongue_winking_eye", 16#1F61C#), (+"stuck_out_tongue_closed_eyes", 16#1F61D#), (+"disappointed", 16#1F61E#), (+"worried", 16#1F61F#), (+"angry", 16#1F620#), (+"rage", 16#1F621#), (+"cry", 16#1F622#), (+"persevere", 16#1F623#), (+"triumph", 16#1F624#), (+"disappointed_relieved", 16#1F625#), (+"frowning", 16#1F626#), (+"anguished", 16#1F627#), (+"fearful", 16#1F628#), (+"weary", 16#1F629#), (+"sleepy", 16#1F62A#), (+"tired_face", 16#1F62B#), (+"grimacing", 16#1F62C#), (+"sob", 16#1F62D#), (+"open_mouth", 16#1F62E#), (+"hushed", 16#1F62F#), (+"cold_sweat", 16#1F630#), (+"scream", 16#1F631#), (+"astonished", 16#1F632#), (+"flushed", 16#1F633#), (+"sleeping", 16#1F634#), (+"dizzy_face", 16#1F635#), (+"no_mouth", 16#1F636#), (+"mask", 16#1F637#), (+"smile_cat", 16#1F638#), (+"joy_cat", 16#1F639#), (+"smiley_cat", 16#1F63A#), (+"heart_eyes_cat", 16#1F63B#), (+"smirk_cat", 16#1F63C#), (+"kissing_cat", 16#1F63D#), (+"pouting_cat", 16#1F63E#), (+"crying_cat_face", 16#1F63F#), (+"scream_cat", 16#1F640#), (+"slightly_frowning_face", 16#1F641#), (+"slightly_smiling_face", 16#1F642#), (+"upside_down_face", 16#1F643#), (+"face_with_rolling_eyes", 16#1F644#), (+"no_good", 16#1F645#), (+"ok_woman", 16#1F646#), (+"bow", 16#1F647#), (+"see_no_evil", 16#1F648#), (+"hear_no_evil", 16#1F649#), (+"speak_no_evil", 16#1F64A#), (+"raising_hand", 16#1F64B#), (+"raised_hands", 16#1F64C#), (+"person_frowning", 16#1F64D#), (+"person_with_pouting_face", 16#1F64E#), (+"pray", 16#1F64F#), (+"rocket", 16#1F680#), (+"helicopter", 16#1F681#), (+"steam_locomotive", 16#1F682#), (+"railway_car", 16#1F683#), (+"bullettrain_side", 16#1F684#), (+"bullettrain_front", 16#1F685#), (+"train2", 16#1F686#), (+"metro", 16#1F687#), (+"light_rail", 16#1F688#), (+"station", 16#1F689#), (+"tram", 16#1F68A#), (+"train", 16#1F68B#), (+"bus", 16#1F68C#), (+"oncoming_bus", 16#1F68D#), (+"trolleybus", 16#1F68E#), (+"busstop", 16#1F68F#), (+"minibus", 16#1F690#), (+"ambulance", 16#1F691#), (+"fire_engine", 16#1F692#), (+"police_car", 16#1F693#), (+"oncoming_police_car", 16#1F694#), (+"taxi", 16#1F695#), (+"oncoming_taxi", 16#1F696#), (+"car", 16#1F697#), (+"oncoming_automobile", 16#1F698#), (+"blue_car", 16#1F699#), (+"truck", 16#1F69A#), (+"articulated_lorry", 16#1F69B#), (+"tractor", 16#1F69C#), (+"monorail", 16#1F69D#), (+"mountain_railway", 16#1F69E#), (+"suspension_railway", 16#1F69F#), (+"mountain_cableway", 16#1F6A0#), (+"aerial_tramway", 16#1F6A1#), (+"ship", 16#1F6A2#), (+"rowboat", 16#1F6A3#), (+"speedboat", 16#1F6A4#), (+"traffic_light", 16#1F6A5#), (+"vertical_traffic_light", 16#1F6A6#), (+"construction", 16#1F6A7#), (+"rotating_light", 16#1F6A8#), (+"triangular_flag_on_post", 16#1F6A9#), (+"door", 16#1F6AA#), (+"no_entry_sign", 16#1F6AB#), (+"smoking", 16#1F6AC#), (+"no_smoking", 16#1F6AD#), (+"put_litter_in_its_place", 16#1F6AE#), (+"do_not_litter", 16#1F6AF#), (+"potable_water", 16#1F6B0#), (+"non-potable_water", 16#1F6B1#), (+"bike", 16#1F6B2#), (+"no_bicycles", 16#1F6B3#), (+"bicyclist", 16#1F6B4#), (+"mountain_bicyclist", 16#1F6B5#), (+"walking", 16#1F6B6#), (+"no_pedestrians", 16#1F6B7#), (+"children_crossing", 16#1F6B8#), (+"mens", 16#1F6B9#), (+"womens", 16#1F6BA#), (+"restroom", 16#1F6BB#), (+"baby_symbol", 16#1F6BC#), (+"toilet", 16#1F6BD#), (+"wc", 16#1F6BE#), (+"shower", 16#1F6BF#), (+"bath", 16#1F6C0#), (+"bathtub", 16#1F6C1#), (+"passport_control", 16#1F6C2#), (+"customs", 16#1F6C3#), (+"baggage_claim", 16#1F6C4#), (+"left_luggage", 16#1F6C5#), (+"sleeping_accommodation", 16#1F6CC#), (+"place_of_worship", 16#1F6D0#), (+"octagonal_sign", 16#1F6D1#), (+"shopping_trolley", 16#1F6D2#), (+"hindu_temple", 16#1F6D5#), (+"hut", 16#1F6D6#), (+"elevator", 16#1F6D7#), (+"airplane_departure", 16#1F6EB#), (+"airplane_arriving", 16#1F6EC#), (+"scooter", 16#1F6F4#), (+"motor_scooter", 16#1F6F5#), (+"canoe", 16#1F6F6#), (+"sled", 16#1F6F7#), (+"flying_saucer", 16#1F6F8#), (+"skateboard", 16#1F6F9#), (+"auto_rickshaw", 16#1F6FA#), (+"pickup_truck", 16#1F6FB#), (+"roller_skate", 16#1F6FC#), (+"large_orange_circle", 16#1F7E0#), (+"large_yellow_circle", 16#1F7E1#), (+"large_green_circle", 16#1F7E2#), (+"large_purple_circle", 16#1F7E3#), (+"large_brown_circle", 16#1F7E4#), (+"large_red_square", 16#1F7E5#), (+"large_blue_square", 16#1F7E6#), (+"large_orange_square", 16#1F7E7#), (+"large_yellow_square", 16#1F7E8#), (+"large_green_square", 16#1F7E9#), (+"large_purple_square", 16#1F7EA#), (+"large_brown_square", 16#1F7EB#), (+"pinched_fingers", 16#1F90C#), (+"white_heart", 16#1F90D#), (+"brown_heart", 16#1F90E#), (+"pinching_hand", 16#1F90F#), (+"zipper_mouth_face", 16#1F910#), (+"money_mouth_face", 16#1F911#), (+"face_with_thermometer", 16#1F912#), (+"nerd_face", 16#1F913#), (+"thinking_face", 16#1F914#), (+"face_with_head_bandage", 16#1F915#), (+"robot_face", 16#1F916#), (+"hugging_face", 16#1F917#), (+"the_horns", 16#1F918#), (+"call_me_hand", 16#1F919#), (+"raised_back_of_hand", 16#1F91A#), (+"left-facing_fist", 16#1F91B#), (+"right-facing_fist", 16#1F91C#), (+"handshake", 16#1F91D#), (+"crossed_fingers", 16#1F91E#), (+"i_love_you_hand_sign", 16#1F91F#), (+"face_with_cowboy_hat", 16#1F920#), (+"clown_face", 16#1F921#), (+"nauseated_face", 16#1F922#), (+"rolling_on_the_floor_laughing", 16#1F923#), (+"drooling_face", 16#1F924#), (+"lying_face", 16#1F925#), (+"face_palm", 16#1F926#), (+"sneezing_face", 16#1F927#), (+"face_with_raised_eyebrow", 16#1F928#), (+"star-struck", 16#1F929#), (+"zany_face", 16#1F92A#), (+"shushing_face", 16#1F92B#), (+"face_with_symbols_on_mouth", 16#1F92C#), (+"face_with_hand_over_mouth", 16#1F92D#), (+"face_vomiting", 16#1F92E#), (+"exploding_head", 16#1F92F#), (+"pregnant_woman", 16#1F930#), (+"breast-feeding", 16#1F931#), (+"palms_up_together", 16#1F932#), (+"selfie", 16#1F933#), (+"prince", 16#1F934#), (+"person_in_tuxedo", 16#1F935#), (+"mrs_claus", 16#1F936#), (+"shrug", 16#1F937#), (+"person_doing_cartwheel", 16#1F938#), (+"juggling", 16#1F939#), (+"fencer", 16#1F93A#), (+"wrestlers", 16#1F93C#), (+"water_polo", 16#1F93D#), (+"handball", 16#1F93E#), (+"diving_mask", 16#1F93F#), (+"wilted_flower", 16#1F940#), (+"drum_with_drumsticks", 16#1F941#), (+"clinking_glasses", 16#1F942#), (+"tumbler_glass", 16#1F943#), (+"spoon", 16#1F944#), (+"goal_net", 16#1F945#), (+"first_place_medal", 16#1F947#), (+"second_place_medal", 16#1F948#), (+"third_place_medal", 16#1F949#), (+"boxing_glove", 16#1F94A#), (+"martial_arts_uniform", 16#1F94B#), (+"curling_stone", 16#1F94C#), (+"lacrosse", 16#1F94D#), (+"softball", 16#1F94E#), (+"flying_disc", 16#1F94F#), (+"croissant", 16#1F950#), (+"avocado", 16#1F951#), (+"cucumber", 16#1F952#), (+"bacon", 16#1F953#), (+"potato", 16#1F954#), (+"carrot", 16#1F955#), (+"baguette_bread", 16#1F956#), (+"green_salad", 16#1F957#), (+"shallow_pan_of_food", 16#1F958#), (+"stuffed_flatbread", 16#1F959#), (+"egg", 16#1F95A#), (+"glass_of_milk", 16#1F95B#), (+"peanuts", 16#1F95C#), (+"kiwifruit", 16#1F95D#), (+"pancakes", 16#1F95E#), (+"dumpling", 16#1F95F#), (+"fortune_cookie", 16#1F960#), (+"takeout_box", 16#1F961#), (+"chopsticks", 16#1F962#), (+"bowl_with_spoon", 16#1F963#), (+"cup_with_straw", 16#1F964#), (+"coconut", 16#1F965#), (+"broccoli", 16#1F966#), (+"pie", 16#1F967#), (+"pretzel", 16#1F968#), (+"cut_of_meat", 16#1F969#), (+"sandwich", 16#1F96A#), (+"canned_food", 16#1F96B#), (+"leafy_green", 16#1F96C#), (+"mango", 16#1F96D#), (+"moon_cake", 16#1F96E#), (+"bagel", 16#1F96F#), (+"smiling_face_with_3_hearts", 16#1F970#), (+"yawning_face", 16#1F971#), (+"smiling_face_with_tear", 16#1F972#), (+"partying_face", 16#1F973#), (+"woozy_face", 16#1F974#), (+"hot_face", 16#1F975#), (+"cold_face", 16#1F976#), (+"ninja", 16#1F977#), (+"disguised_face", 16#1F978#), (+"pleading_face", 16#1F97A#), (+"sari", 16#1F97B#), (+"lab_coat", 16#1F97C#), (+"goggles", 16#1F97D#), (+"hiking_boot", 16#1F97E#), (+"womans_flat_shoe", 16#1F97F#), (+"crab", 16#1F980#), (+"lion_face", 16#1F981#), (+"scorpion", 16#1F982#), (+"turkey", 16#1F983#), (+"unicorn_face", 16#1F984#), (+"eagle", 16#1F985#), (+"duck", 16#1F986#), (+"bat", 16#1F987#), (+"shark", 16#1F988#), (+"owl", 16#1F989#), (+"fox_face", 16#1F98A#), (+"butterfly", 16#1F98B#), (+"deer", 16#1F98C#), (+"gorilla", 16#1F98D#), (+"lizard", 16#1F98E#), (+"rhinoceros", 16#1F98F#), (+"shrimp", 16#1F990#), (+"squid", 16#1F991#), (+"giraffe_face", 16#1F992#), (+"zebra_face", 16#1F993#), (+"hedgehog", 16#1F994#), (+"sauropod", 16#1F995#), (+"t-rex", 16#1F996#), (+"cricket", 16#1F997#), (+"kangaroo", 16#1F998#), (+"llama", 16#1F999#), (+"peacock", 16#1F99A#), (+"hippopotamus", 16#1F99B#), (+"parrot", 16#1F99C#), (+"raccoon", 16#1F99D#), (+"lobster", 16#1F99E#), (+"mosquito", 16#1F99F#), (+"microbe", 16#1F9A0#), (+"badger", 16#1F9A1#), (+"swan", 16#1F9A2#), (+"mammoth", 16#1F9A3#), (+"dodo", 16#1F9A4#), (+"sloth", 16#1F9A5#), (+"otter", 16#1F9A6#), (+"orangutan", 16#1F9A7#), (+"skunk", 16#1F9A8#), (+"flamingo", 16#1F9A9#), (+"oyster", 16#1F9AA#), (+"beaver", 16#1F9AB#), (+"bison", 16#1F9AC#), (+"seal", 16#1F9AD#), (+"guide_dog", 16#1F9AE#), (+"probing_cane", 16#1F9AF#), (+"bone", 16#1F9B4#), (+"leg", 16#1F9B5#), (+"foot", 16#1F9B6#), (+"tooth", 16#1F9B7#), (+"superhero", 16#1F9B8#), (+"supervillain", 16#1F9B9#), (+"safety_vest", 16#1F9BA#), (+"ear_with_hearing_aid", 16#1F9BB#), (+"motorized_wheelchair", 16#1F9BC#), (+"manual_wheelchair", 16#1F9BD#), (+"mechanical_arm", 16#1F9BE#), (+"mechanical_leg", 16#1F9BF#), (+"cheese_wedge", 16#1F9C0#), (+"cupcake", 16#1F9C1#), (+"salt", 16#1F9C2#), (+"beverage_box", 16#1F9C3#), (+"garlic", 16#1F9C4#), (+"onion", 16#1F9C5#), (+"falafel", 16#1F9C6#), (+"waffle", 16#1F9C7#), (+"butter", 16#1F9C8#), (+"mate_drink", 16#1F9C9#), (+"ice_cube", 16#1F9CA#), (+"bubble_tea", 16#1F9CB#), (+"standing_person", 16#1F9CD#), (+"kneeling_person", 16#1F9CE#), (+"deaf_person", 16#1F9CF#), (+"face_with_monocle", 16#1F9D0#), (+"adult", 16#1F9D1#), (+"child", 16#1F9D2#), (+"older_adult", 16#1F9D3#), (+"bearded_person", 16#1F9D4#), (+"person_with_headscarf", 16#1F9D5#), (+"person_in_steamy_room", 16#1F9D6#), (+"person_climbing", 16#1F9D7#), (+"person_in_lotus_position", 16#1F9D8#), (+"mage", 16#1F9D9#), (+"fairy", 16#1F9DA#), (+"vampire", 16#1F9DB#), (+"merperson", 16#1F9DC#), (+"elf", 16#1F9DD#), (+"genie", 16#1F9DE#), (+"zombie", 16#1F9DF#), (+"brain", 16#1F9E0#), (+"orange_heart", 16#1F9E1#), (+"billed_cap", 16#1F9E2#), (+"scarf", 16#1F9E3#), (+"gloves", 16#1F9E4#), (+"coat", 16#1F9E5#), (+"socks", 16#1F9E6#), (+"red_envelope", 16#1F9E7#), (+"firecracker", 16#1F9E8#), (+"jigsaw", 16#1F9E9#), (+"test_tube", 16#1F9EA#), (+"petri_dish", 16#1F9EB#), (+"dna", 16#1F9EC#), (+"compass", 16#1F9ED#), (+"abacus", 16#1F9EE#), (+"fire_extinguisher", 16#1F9EF#), (+"toolbox", 16#1F9F0#), (+"bricks", 16#1F9F1#), (+"magnet", 16#1F9F2#), (+"luggage", 16#1F9F3#), (+"lotion_bottle", 16#1F9F4#), (+"thread", 16#1F9F5#), (+"yarn", 16#1F9F6#), (+"safety_pin", 16#1F9F7#), (+"teddy_bear", 16#1F9F8#), (+"broom", 16#1F9F9#), (+"basket", 16#1F9FA#), (+"roll_of_paper", 16#1F9FB#), (+"soap", 16#1F9FC#), (+"sponge", 16#1F9FD#), (+"receipt", 16#1F9FE#), (+"nazar_amulet", 16#1F9FF#), (+"ballet_shoes", 16#1FA70#), (+"one-piece_swimsuit", 16#1FA71#), (+"briefs", 16#1FA72#), (+"shorts", 16#1FA73#), (+"thong_sandal", 16#1FA74#), (+"drop_of_blood", 16#1FA78#), (+"adhesive_bandage", 16#1FA79#), (+"stethoscope", 16#1FA7A#), (+"yo-yo", 16#1FA80#), (+"kite", 16#1FA81#), (+"parachute", 16#1FA82#), (+"boomerang", 16#1FA83#), (+"magic_wand", 16#1FA84#), (+"pinata", 16#1FA85#), (+"nesting_dolls", 16#1FA86#), (+"ringed_planet", 16#1FA90#), (+"chair", 16#1FA91#), (+"razor", 16#1FA92#), (+"axe", 16#1FA93#), (+"diya_lamp", 16#1FA94#), (+"banjo", 16#1FA95#), (+"military_helmet", 16#1FA96#), (+"accordion", 16#1FA97#), (+"long_drum", 16#1FA98#), (+"coin", 16#1FA99#), (+"carpentry_saw", 16#1FA9A#), (+"screwdriver", 16#1FA9B#), (+"ladder", 16#1FA9C#), (+"hook", 16#1FA9D#), (+"mirror", 16#1FA9E#), (+"window", 16#1FA9F#), (+"plunger", 16#1FAA0#), (+"sewing_needle", 16#1FAA1#), (+"knot", 16#1FAA2#), (+"bucket", 16#1FAA3#), (+"mouse_trap", 16#1FAA4#), (+"toothbrush", 16#1FAA5#), (+"headstone", 16#1FAA6#), (+"placard", 16#1FAA7#), (+"rock", 16#1FAA8#), (+"fly", 16#1FAB0#), (+"worm", 16#1FAB1#), (+"beetle", 16#1FAB2#), (+"cockroach", 16#1FAB3#), (+"potted_plant", 16#1FAB4#), (+"wood", 16#1FAB5#), (+"feather", 16#1FAB6#), (+"anatomical_heart", 16#1FAC0#), (+"lungs", 16#1FAC1#), (+"people_hugging", 16#1FAC2#), (+"blueberries", 16#1FAD0#), (+"bell_pepper", 16#1FAD1#), (+"olive", 16#1FAD2#), (+"flatbread", 16#1FAD3#), (+"tamale", 16#1FAD4#), (+"fondue", 16#1FAD5#), (+"teapot", 16#1FAD6#), (+"watch", 16#231A#), (+"hourglass", 16#231B#), (+"fast_forward", 16#23E9#), (+"rewind", 16#23EA#), (+"arrow_double_up", 16#23EB#), (+"arrow_double_down", 16#23EC#), (+"alarm_clock", 16#23F0#), (+"hourglass_flowing_sand", 16#23F3#), (+"white_medium_small_square", 16#25FD#), (+"black_medium_small_square", 16#25FE#), (+"umbrella_with_rain_drops", 16#2614#), (+"coffee", 16#2615#), (+"aries", 16#2648#), (+"taurus", 16#2649#), (+"gemini", 16#264A#), (+"cancer", 16#264B#), (+"leo", 16#264C#), (+"virgo", 16#264D#), (+"libra", 16#264E#), (+"scorpius", 16#264F#), (+"sagittarius", 16#2650#), (+"capricorn", 16#2651#), (+"aquarius", 16#2652#), (+"pisces", 16#2653#), (+"wheelchair", 16#267F#), (+"anchor", 16#2693#), (+"zap", 16#26A1#), (+"white_circle", 16#26AA#), (+"black_circle", 16#26AB#), (+"soccer", 16#26BD#), (+"baseball", 16#26BE#), (+"snowman_without_snow", 16#26C4#), (+"partly_sunny", 16#26C5#), (+"ophiuchus", 16#26CE#), (+"no_entry", 16#26D4#), (+"church", 16#26EA#), (+"fountain", 16#26F2#), (+"golf", 16#26F3#), (+"boat", 16#26F5#), (+"tent", 16#26FA#), (+"fuelpump", 16#26FD#), (+"white_check_mark", 16#2705#), (+"fist", 16#270A#), (+"hand", 16#270B#), (+"sparkles", 16#2728#), (+"x", 16#274C#), (+"negative_squared_cross_mark", 16#274E#), (+"question", 16#2753#), (+"grey_question", 16#2754#), (+"grey_exclamation", 16#2755#), (+"exclamation", 16#2757#), (+"heavy_plus_sign", 16#2795#), (+"heavy_minus_sign", 16#2796#), (+"heavy_division_sign", 16#2797#), (+"curly_loop", 16#27B0#), (+"loop", 16#27BF#), (+"black_large_square", 16#2B1B#), (+"white_large_square", 16#2B1C#), (+"star", 16#2B50#), (+"o", 16#2B55#)); end Emojis;