content
stringlengths
23
1.05M
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . W C H _ W T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-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 System.WCh_Con; use System.WCh_Con; with System.WCh_Cnv; use System.WCh_Cnv; package body System.WCh_WtS is ----------------------- -- Local Subprograms -- ----------------------- procedure Store_UTF_32_Character (U : UTF_32_Code; S : out String; P : in out Integer; EM : WC_Encoding_Method); -- Stores the string representation of the wide or wide wide character -- whose code is given as U, starting at S (P + 1). P is incremented to -- point to the last character stored. Raises CE if character cannot be -- stored using the given encoding method. ---------------------------- -- Store_UTF_32_Character -- ---------------------------- procedure Store_UTF_32_Character (U : UTF_32_Code; S : out String; P : in out Integer; EM : WC_Encoding_Method) is procedure Out_Char (C : Character); pragma Inline (Out_Char); -- Procedure to increment P and store C at S (P) procedure Store_Chars is new UTF_32_To_Char_Sequence (Out_Char); -------------- -- Out_Char -- -------------- procedure Out_Char (C : Character) is begin P := P + 1; S (P) := C; end Out_Char; begin Store_Chars (U, EM); end Store_UTF_32_Character; --------------------------- -- Wide_String_To_String -- --------------------------- function Wide_String_To_String (S : Wide_String; EM : WC_Encoding_Method) return String is Max_Chars : constant Natural := WC_Longest_Sequences (EM); Result : String (S'First .. S'First + Max_Chars * S'Length); Result_Idx : Natural; begin Result_Idx := Result'First - 1; for S_Idx in S'Range loop Store_UTF_32_Character (U => Wide_Character'Pos (S (S_Idx)), S => Result, P => Result_Idx, EM => EM); end loop; return Result (Result'First .. Result_Idx); end Wide_String_To_String; -------------------------------- -- Wide_Wide_String_To_String -- -------------------------------- function Wide_Wide_String_To_String (S : Wide_Wide_String; EM : WC_Encoding_Method) return String is Max_Chars : constant Natural := WC_Longest_Sequences (EM); Result : String (S'First .. S'First + Max_Chars * S'Length); Result_Idx : Natural; begin Result_Idx := Result'First - 1; for S_Idx in S'Range loop Store_UTF_32_Character (U => Wide_Wide_Character'Pos (S (S_Idx)), S => Result, P => Result_Idx, EM => EM); end loop; return Result (Result'First .. Result_Idx); end Wide_Wide_String_To_String; end System.WCh_WtS;
pragma License (Unrestricted); -- extended unit package Ada.Fixed is -- Ada.Decimal-like utilities for ordinary fixed types. pragma Pure; generic type Dividend_Type is delta <>; type Divisor_Type is delta <>; type Quotient_Type is delta <>; type Remainder_Type is delta <>; procedure Divide ( Dividend : Dividend_Type; Divisor : Divisor_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type); end Ada.Fixed;
-------------------------------------------------------------------------------- -- Copyright (c) 2013, Felix Krause <contact@flyx.org> -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- with Ada.Finalization; with Interfaces.C; with System; private with Interfaces.C.Pointers; package CL is pragma Preelaborate (CL); ----------------------------------------------------------------------------- -- OpenCL scalar types that are available -- in the OpenCL C programming language ----------------------------------------------------------------------------- -- signed integer types type Char is new Interfaces.Integer_8; type Short is new Interfaces.Integer_16; type Int is new Interfaces.Integer_32; type Long is new Interfaces.Integer_64; for Char'Size use 8; for Short'Size use 16; for Int'Size use 32; for Long'Size use 64; -- unsigned integer types type UChar is new Interfaces.Unsigned_8; type UShort is new Interfaces.Unsigned_16; type UInt is new Interfaces.Unsigned_32; type ULong is new Interfaces.Unsigned_64; for UChar'Size use 8; for UShort'Size use 16; for UInt'Size use 32; for ULong'Size use 64; -- floating point types type Float is new Standard.Float; type Half is new Short; for Half'Size use Short'Size; -- ranges of vector types subtype Range2 is Natural range 0 .. 1; subtype Range3 is Natural range 0 .. 2; subtype Range4 is Natural range 0 .. 3; subtype Range8 is Natural range 0 .. 7; subtype Range16 is Natural range 0 .. 15; -- Mainly needed in order to have a single interface for -- converting numeric values to string when instantiating -- generic packages like Vector_Operations. ('Img cannot -- be used directly because it takes both integer and floating -- point types, and there is no common supertype that supports -- 'Img) function To_String (Value : Char) return String; function To_String (Value : Short) return String; function To_String (Value : Int) return String; function To_String (Value : Long) return String; function To_String (Value : UChar) return String; function To_String (Value : UShort) return String; function To_String (Value : UInt) return String; function To_String (Value : ULong) return String; function To_String (Value : CL.Float) return String; pragma Inline (To_String); -- Float types should be compared with a small epsilon value to -- compensate rounding errors and such. generic Epsilon : Float; function Float_Equals (Left, Right : Float) return Boolean; ----------------------------------------------------------------------------- -- Types used by this API ----------------------------------------------------------------------------- type Size is new Interfaces.C.size_t; type Size_List is array (Positive range <>) of aliased Size; type Char_List is array (Positive range <>) of aliased Interfaces.C.unsigned_char; -- only Runtime_Objects implement Adjust and Finalize, but as multiple -- inheritance isn't possible, we have to derive CL_Object from Controlled type CL_Object is abstract new Ada.Finalization.Controlled with private; function "=" (Left, Right : CL_Object) return Boolean; type Runtime_Object is abstract new CL_Object with private; function Initialized (Object : Runtime_Object) return Boolean; function Reference_Count (Source : Runtime_Object) return UInt is abstract; function Raw (Source : Runtime_Object) return System.Address; ----------------------------------------------------------------------------- -- Exceptions ----------------------------------------------------------------------------- Invalid_Global_Work_Size : exception; Invalid_Mip_Level : exception; Invalid_Buffer_Size : exception; Invalid_GL_Object : exception; Invalid_Operation : exception; Invalid_Event : exception; Invalid_Event_Wait_List : exception; Invalid_Global_Offset : exception; Invalid_Work_Item_Size : exception; Invalid_Work_Group_Size : exception; Invalid_Work_Dimension : exception; Invalid_Kernel_Args : exception; Invalid_Arg_Size : exception; Invalid_Arg_Value : exception; Invalid_Arg_Index : exception; Invalid_Kernel : exception; Invalid_Kernel_Definition : exception; Invalid_Kernel_Name : exception; Invalid_Program_Executable : exception; Invalid_Program : exception; Invalid_Build_Options : exception; Invalid_Binary : exception; Invalid_Sampler : exception; Invalid_Image_Size : exception; Invalid_Image_Format_Descriptor : exception; Invalid_Mem_Object : exception; Invalid_Host_Ptr : exception; Invalid_Command_Queue : exception; Invalid_Queue_Properties : exception; Invalid_Context : exception; Invalid_Device : exception; Invalid_Platform : exception; Invalid_Device_Type : exception; Invalid_Value : exception; Kernel_Arg_Info_Not_Available : exception; Device_Partition_Failed : exception; Link_Program_Failure : exception; Linker_Not_Available : exception; Compile_Program_Failure : exception; Exec_Status_Error_For_Events_In_Wait_List : exception; Misaligned_Sub_Buffer_Offset : exception; Map_Failure : exception; Build_Program_Failure : exception; Image_Format_Not_Supported : exception; Image_Format_Mismatch : exception; Mem_Copy_Overlap : exception; Profiling_Info_Not_Available : exception; Out_Of_Host_Memory : exception; Out_Of_Resources : exception; Mem_Object_Allocation_Failure : exception; Compiler_Not_Available : exception; Device_Not_Available : exception; Device_Not_Found : exception; Internal_Error : exception; Invalid_Local_Work_Size : exception; private type CL_Object is abstract new Ada.Finalization.Controlled with record Location : System.Address := System.Null_Address; end record; type Runtime_Object is abstract new CL_Object with null record; ----------------------------------------------------------------------------- -- Types used with C calls ----------------------------------------------------------------------------- type Size_Ptr is access all Size; type UInt_Ptr is access all UInt; type Address_Ptr is access all System.Address; type Address_List is array (Positive range <>) of aliased System.Address; pragma Convention (C, Size_Ptr); pragma Convention (C, UInt_Ptr); pragma Convention (C, Address_Ptr); pragma Convention (C, Address_List); type Bool is new Boolean; for Bool use (False => 0, True => 1); for Bool'Size use UInt'Size; type Bitfield is new ULong; for Bitfield'Size use ULong'Size; package IFC renames Interfaces.C; package C_Chars is new Interfaces.C.Pointers (Index => Positive, Element => IFC.unsigned_char, Element_Array => Char_List, Default_Terminator => 0); end CL;
limited with Limited_With2_Pkg2; package Limited_With2_Pkg1 is type Rec2 is record F : access Limited_With2_Pkg2.Rec3; end record; end Limited_With2_Pkg1;
with Ada.Text_IO; use Ada.Text_IO; -- afficher la classe à laquelle appartient un caractère lu au clavier procedure Classer_Caractere is -- Constantes pour définir la classe des caractères -- Remarque : Dans la suite du cours nous verrons une meilleure -- façon de faire que de définir ces constantes. Laquelle ? Chiffre : constant Character := 'C'; Lettre : constant Character := 'L'; Ponctuation : constant Character := 'P'; Autre : constant Character := 'A'; C : Character; -- le caractère à classer Classe: Character; -- la classe du caractère C begin -- Demander le caractère Get (C); -- Déterminer la classe du caractère c Classe := 'A'; if (C >= 'A' and C <= 'Z') or (C >= 'a' and C <= 'z') then Classe := 'L'; elsif C >= '0' and C <= '9' then Classe := 'C'; elsif C = ',' or C = '.' or C = ';' or C = '?' or C = '!' then Classe := 'P'; end if; -- Afficher la classe du caractère Put (Classe); end Classer_Caractere;
package Based_Numbers is TWO_HUNDRED_FIFTY_FIVE_0 : constant := 255; TWO_HUNDRED_FIFTY_FIVE_1 : constant := 2#1111_1111#; TWO_HUNDRED_FIFTY_FIVE_2 : constant := 16#FF#; TWO_HUNDRED_FIFTY_FIVE_3 : constant := 016#0FF#; TWO_HUNDRED_TWENTY_FOUR_0 : constant := 224; TWO_HUNDRED_TWENTY_FOUR_1 : constant := 16#E#E1; TWO_HUNDRED_TWENTY_FOUR_2 : constant := 2#1110_0000#; F4095_0_0 : constant := 4095.0; F4095_0_1 : constant := 16#F.FF#E+2; F4095_0_2 : constant := 2#1.1111_1111_1110#E11; end Based_Numbers;
with Ada.Directories.Temporary; with Ada.Streams.Stream_IO; procedure filelock is use Ada.Streams.Stream_IO; Name : String := Ada.Directories.Temporary.Create_Temporary_File; begin Ada.Debug.Put (Name); -- raising declare Step : Integer := 0; File_1, File_2 : File_Type; begin Step := 1; Open (File_1, In_File, Name); -- read lock Step := 2; Open (File_2, In_File, Name, Form => "shared=deny"); -- write lock Step := 3; exception when Tasking_Error => if Step /= 2 then Ada.Debug.Put ("bad"); end if; end; -- waiting declare Step : Integer := 0; pragma Atomic (Step); File_1 : File_Type; task Task_2 is end Task_2; task body Task_2 is File_2 : File_Type; begin delay 0.1; pragma Assert (Step = 2); Step := 3; Open (File_2, In_File, Name, Form => "shared=deny,wait=true"); -- write lock pragma Assert (Step = 4); Step := 5; end Task_2; begin pragma Assert (Step = 0); Step := 1; Open (File_1, In_File, Name, Form => "wait=true"); -- read lock pragma Assert (Step = 1); Step := 2; delay 0.2; pragma Assert (Step = 3); Step := 4; Close (File_1); end; Ada.Directories.Delete_File (Name); Ada.Debug.Put ("OK"); end filelock;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Calendar; with Ada.Containers.Vectors; with GNAT.Sockets; with League.Stream_Element_Vectors; with League.Strings; with Slim.Fonts; with Slim.Messages; with Slim.Menu_Views; limited with Slim.Players.Displays; with Slim.Menu_Models; package Slim.Players is type Player is tagged limited private; type Player_Access is access all Player'Class; procedure Initialize (Self : in out Player'Class; Socket : GNAT.Sockets.Socket_Type; Font : League.Strings.Universal_String; Splash : League.Strings.Universal_String; Menu : League.Strings.Universal_String); procedure Play_Radio (Self : in out Player'Class; URL : League.Strings.Universal_String); type Song is record File : League.Strings.Universal_String; Title : League.Strings.Universal_String; end record; type Song_Array is array (Positive range <>) of Song; procedure Play_Files (Self : in out Player'Class; Root : League.Strings.Universal_String; M3U : League.Strings.Universal_String; List : Song_Array; From : Positive; Skip : Natural); -- Start playing given playlist. Skip given number of seconds of the first -- song procedure Play_Next_File (Self : in out Player'Class; Immediate : Boolean := True); procedure Play_Previous_File (Self : in out Player'Class; Immediate : Boolean := True); procedure Stop (Self : in out Player'Class); procedure Save_Position (Self : in out Player'Class); -- If play a playlist, then remember current position procedure Get_Position (Self : in out Player'Class; M3U : League.Strings.Universal_String; Index : out Positive; Skip : out Natural); -- Find saved position for given playlist. Return (1,0) if not found procedure Volume (Self : in out Player'Class; Value : Natural); not overriding procedure Process_Message (Self : in out Player); private type State_Kind is (Connected, Idle, Play_Radio, Play_Files); type Play_State is record Volume : Natural range 0 .. 100; Volume_Set_Time : Ada.Calendar.Time; Current_Song : League.Strings.Universal_String; Seconds : Natural; Paused : Boolean; end record; package Song_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Song); type Player_State (Kind : State_Kind := Connected) is record case Kind is when Connected => null; when Idle => Time : Ada.Calendar.Time; -- Time on players display Menu_View : Slim.Menu_Views.Menu_View; when Play_Radio | Play_Files => Play_State : Slim.Players.Play_State; case Kind is when Play_Files => Root : League.Strings.Universal_String; M3U_Name : League.Strings.Universal_String; Playlist : Song_Vectors.Vector; Index : Positive; Offset : Natural; -- If current file started playing with Offset when others => null; end case; end case; end record; type Menu_Model_Access is access all Slim.Menu_Models.Menu_Model'Class; type Player is tagged limited record Socket : GNAT.Sockets.Socket_Type := GNAT.Sockets.No_Socket; State : Player_State; Ping : Ada.Calendar.Time := Ada.Calendar.Clock; Font : aliased Slim.Fonts.Font; Splash : League.Stream_Element_Vectors.Stream_Element_Vector; Menu : Menu_Model_Access; -- Splash screen WiFi : Natural; -- Wireless Signal Strength (0-100) -- Elapsed : Natural := 0; -- elapsed seconds of the current stream end record; procedure Write_Message (Socket : GNAT.Sockets.Socket_Type; Message : Slim.Messages.Message'Class); function Get_Display (Self : Player; Height : Positive := 32; Width : Positive := 160) return Slim.Players.Displays.Display; function First_Menu (Self : Player'Class) return Slim.Menu_Views.Menu_View; function "+" (X : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; procedure Request_Next_File (Self : in out Player'Class); end Slim.Players;
--------------------------------------------------------------- -- Author: Matthew Bennett -- Class: CSC410 Burgess -- Date: 09-21-04 Modified: 9-21-04 -- Desc: Assignment 3: PETERSON'S ALGORITHM -- a simple implementation of -- PETERSON's algorithm which describes -- mutual exclusion, fairness, and deadlock avoidance -- n processes (TASKS) assuming fair hardware. -- This algorithm is famed for simplicity and undestandability. -- PETERSON'S as described in -- "Algorithms for Mutual Exclusion", M. Raynal -- MIT PRESS Cambridge, 1986 ISBN: 0-262-18119-3 -- Originally from the 198x paper: -- "Myths about the mutual exclusion problem" ---------------------------------------------------------------- -- dependencies -- style note: the reason I sometimes "with" in but do not "use" packages -- are the same reasons a competent C++ programmer does--as a style -- convention--to avoid crowding of the namespace but more importantly -- to be very explicit where abstract data types and methods are coming from. -- for instance, the line -- G : Ada.Numerics.Float_Random.Generator; -- is much more explicit than -- G : Generator; WITH ADA.TEXT_IO; USE ADA.TEXT_IO; WITH ADA.INTEGER_TEXT_IO; USE ADA.INTEGER_TEXT_IO; WITH ADA.NUMERICS.FLOAT_RANDOM; --USE ADA.NUMERICS.FLOAT_RANDOM; WITH ADA.CALENDAR; --USE ADA.CALENDAR; -- (provides cast: natural -> time for input into delay) WITH ADA.STRINGS; USE ADA.STRINGS; ---------------------------------------------------------------- -- specifications PROCEDURE as3 IS --globals to all tasks: Generator, constant scale factor, turn[]. flag[] G : Ada.Numerics.Float_Random.Generator;-- yields a random Natural after seed MAX_TASKS : CONSTANT := 100; --global constant for mem allocation restriction RANDOM_SCALE_FACTOR : CONSTANT := 50.0; --used to increase "spread" of random delays SPACES : STRING(1..80) := (Others => ' '); turn : ARRAY(0..MAX_TASKS-1) OF Integer := (OTHERS => -1); --array of TURN for all processes, initialized to -1 flag : ARRAY(0..MAX_TASKS) OF Integer := (OTHERS => 0); --array of flags for all processes, initialized to 0 --here comes the specification for our processes (TASKs) TASK TYPE single_task IS ENTRY start ( id_self : IN Integer; tasks_user : IN Integer; iterations_in : IN Integer); --"ENTRY start is like the constructor for a task" END single_task; -- "since TASK TYPE single_task is part of PROCEDURE dekker, -- we must define it here or in a specifications file " TASK BODY single_task IS --variables defined at task creation time n : Integer; --total number of tasks--"n" is used --to keep our code looking like the book's i,j : Integer; -- identity, other task identity iterations : Integer; -- # of iterations fallthrough : BOOLEAN; --kludge, 1st half of conditional (FIX IT!) BEGIN --single_task -- this is EISENBURG / MACGUIRE ALGORITHM implementation, the tasks themselves ACCEPT start (id_self : IN Integer; tasks_user : IN Integer; iterations_in : IN Integer) DO n := tasks_user; i := id_self; iterations := iterations_in; END Start; FOR iteration_index IN 1 .. iterations LOOP --!!-- start of Eigenberg's algorithm (optimized knuth's) DELAY (Standard.Duration((Ada.Numerics.Float_Random.Random(G) + RANDOM_SCALE_FACTOR) ) ); --give the other guys a fighting chance -- Begin Peterson Algorithm FOR j in 0..(n-2) LOOP flag(i) := j; turn(j) := i; LOOP fallthrough := true; FOR k IN 0..(n-1) LOOP IF ( k /= i AND NOT ((flag(k) < j) OR (turn(j) /= i))) THEN fallthrough := false; END IF; END LOOP; -- "universal quantifier" loop EXIT WHEN (fallthrough = true); --"wait until" condition END LOOP; END LOOP; -- Critical Section -- Put(i, (80/i - 8 ) ); Put_Line(" in CS"); DELAY (Standard.Duration((Ada.Numerics.Float_Random.Random(G) * RANDOM_SCALE_FACTOR) ) ); Put (SPACES(1..(80/i - 8 )) ); Put ("Turn Array: "); FOR turn_index in 0..(n-2) LOOP put(Turn(turn_index),0); put (" "); END LOOP; put_line(""); Put(i, (80/i - 8) ); -- outputs i to column Put_Line (" out CS"); -- End of the Critical Section -- flag(i) := -1; END LOOP; END single_task; PROCEDURE driver IS --implementation of the driver and user interface --PLEASE NOTE: no global variables! these are local to the driver --variables that are user defined at runtime-- iterations_user : Integer; -- iterations per task, defined at execution time tasks_user : Integer RANGE 0..MAX_TASKS; -- num tasks, defined at execution time seed_user : Integer RANGE 0..Integer'LAST; -- random seed, provided by user --we have to use a pointer every time we throw off a new task TYPE st_ptr IS ACCESS single_task; --reference type ptr : ARRAY(0..MAX_TASKS) OF st_ptr; --how do we allocate dynamically? BEGIN --procedure driver; user input and task spawning put("# random seed: "); get(seed_user); --to ensure a significantly random series, a seed is needed -- to generate pseudo-random numbers Ada.Numerics.Float_Random.Reset(G,seed_user); --like seed_rand(seed_user) in c --sanity checked on the input LOOP put("# tasks[1-50]: "); get(tasks_user); EXIT WHEN (tasks_user > 0 AND tasks_user <= 50); END LOOP; LOOP put("# iterations[1-50]: "); get(iterations_user); EXIT WHEN (iterations_user > 0 AND iterations_user <= 50); END LOOP; -- For each task, start it and pass its id and number of iterations FOR tasks_index IN 0 .. (tasks_user-1) LOOP ptr(tasks_index) := NEW single_task; ptr(tasks_index).Start(tasks_index, tasks_user, iterations_user); END LOOP; END driver; BEGIN --as3 driver; --procedure call, sepration of functionality and variables END as3;
pragma License (Unrestricted); with Ada.Finalization; with System.Storage_Elements; package System.Storage_Pools is pragma Preelaborate; type Root_Storage_Pool is abstract limited new Ada.Finalization.Limited_Controlled with private; pragma Preelaborable_Initialization (Root_Storage_Pool); procedure Allocate ( Pool : in out Root_Storage_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count) is abstract; procedure Deallocate ( Pool : in out Root_Storage_Pool; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count) is abstract; function Storage_Size (Pool : Root_Storage_Pool) return Storage_Elements.Storage_Count is abstract; -- to use in System.Finalization_Masters type Storage_Pool_Access is access all Root_Storage_Pool'Class; for Storage_Pool_Access'Storage_Size use 0; private type Root_Storage_Pool is abstract limited new Ada.Finalization.Limited_Controlled with null record; -- required for allocation with explicit 'Storage_Pool by compiler -- (s-stopoo.ads) procedure Allocate_Any ( Pool : in out Root_Storage_Pool'Class; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); -- required for deallocation with explicit 'Storage_Pool by compiler -- (s-stopoo.ads) procedure Deallocate_Any ( Pool : in out Root_Storage_Pool'Class; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); -- required for extra parameter of built-in-place (s-stopoo.ads) subtype Root_Storage_Pool_Ptr is Storage_Pool_Access; end System.Storage_Pools;
----------------------------------------------------------------------- -- hestia-time -- Date and time information -- Copyright (C) 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 Net.NTP; package Hestia.Time is type Month_Name is (January, February, March, April, May, June, July, August, September, October, November, December); type Day_Name is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); subtype Day_Number is Natural range 1 .. 31; subtype Hour_Number is Natural range 0 .. 23; subtype Minute_Number is Natural range 0 .. 59; subtype Second_Number is Natural range 0 .. 59; subtype Year_Number is Natural range 1901 .. 2399; function "-" (Left, Right : in Day_Name) return Integer; type Time_Offset is range -(28 * 60) .. 28 * 60; type Date_Time is record Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Sub_Seconds : Net.Uint32 := 0; Week_Day : Day_Name; Year_Day : Natural; Day : Day_Number; Month : Month_Name; Year : Year_Number; end record; -- Convert the NTP time reference to a date. function Convert (Time : in Net.NTP.NTP_Reference) return Date_Time with Pre => Time.Status in Net.NTP.SYNCED | Net.NTP.RESYNC; Month_Names : constant array (Month_Name) of String (1 .. 9) := ("Janvier ", "Fevrier ", "Mars ", "Avril ", "Mai ", "Juin ", "Juillet ", "Aout ", "Septembre", "Octobre ", "Novembre ", "Decembre "); Day_Names : constant array (Day_Name) of String (1 .. 8) := ("Lundi ", "Mardi ", "Mercredi", "Jeudi ", "Vendredi", "Samedi ", "Dimanche"); end Hestia.Time;
with System; package ACO.Configuration is -- Defines static parameters for the CANopen stack pragma Pure; Max_Nof_Heartbeat_Slaves : constant := 8; Max_Nof_Handler_Event_Subscribers : constant := 16; Max_Nof_Node_Event_Subscribers : constant := 16; Max_Nof_Event_Queue_Data_Items : constant := 16; Event_Queue_Ceiling : constant System.Priority := System.Max_Priority; Periodic_Task_Priority : constant System.Priority := System.Max_Priority; Messages_Buffer_Size : constant := 8; Messages_Buffer_Ceiling : constant System.Priority := System.Max_Priority; Max_Nof_Simultaneous_SDO_Sessions : constant := 4; Max_SDO_Transfer_Size : constant := 32; SDO_Session_Timeout_Ms : constant := 3000; end ACO.Configuration;
package body COBS is ------------------------- -- Max_Encoding_Length -- ------------------------- function Max_Encoding_Length (Data_Len : Storage_Count) return Storage_Count is begin return Data_Len + (Data_Len / 254) + (if (Data_Len mod 254) > 0 then 1 else 0); end Max_Encoding_Length; ------------ -- Encode -- ------------ procedure Encode (Data : Storage_Array; Output : in out Storage_Array; Output_Last : out Storage_Offset; Success : out Boolean) is Code_Pointer : Storage_Offset := Output'First; Out_Pointer : Storage_Offset := Code_Pointer + 1; Code : Storage_Element := 1; Input : Storage_Element; begin for Index in Data'Range loop if Out_Pointer not in Output'Range then Success := False; return; end if; Input := Data (Index); if Input /= 0 then Output (Out_Pointer) := Input; Out_Pointer := Out_Pointer + 1; Code := Code + 1; end if; if Input = 0 or else Code = 16#FF# then Output (Code_Pointer) := Code; Code := 1; Code_Pointer := Out_Pointer; if Input = 0 or else Index /= Data'Last then Out_Pointer := Out_Pointer + 1; end if; end if; end loop; if Code_Pointer /= Out_Pointer then Output (Code_Pointer) := Code; end if; Output_Last := Out_Pointer - 1; Success := True; end Encode; ------------ -- Decode -- ------------ procedure Decode (Data : Storage_Array; Output : in out Storage_Array; Output_Last : out Storage_Offset; Success : out Boolean) is In_Index : Storage_Offset := Data'First; Out_Index : Storage_Offset := Output'First; procedure Push (D : Storage_Element); -- Push one element to the output function Pop return Storage_Element; -- Pop one element from the input ---------- -- Push -- ---------- procedure Push (D : Storage_Element) is begin Output (Out_Index) := D; Out_Index := Out_Index + 1; end Push; --------- -- Pop -- --------- function Pop return Storage_Element is Result : constant Storage_Element := Data (In_Index); begin In_Index := In_Index + 1; return Result; end Pop; Code : Storage_Element; begin while In_Index <= Data'Last loop Code := Pop; exit when Code = 0; if Code > 1 then -- Check input and output boundaries if Out_Index + Storage_Count (Code - 1) > Output'Last + 1 or else In_Index + Storage_Count (Code - 1) > Data'Last + 1 then Success := False; return; end if; for X in 1 .. (Code - 1) loop Push (Pop); end loop; end if; if Code /= 16#FF# and then In_Index <= Data'Last then Push (0); end if; end loop; Output_Last := Out_Index - 1; Success := True; end Decode; --------------------- -- Decode_In_Place -- --------------------- procedure Decode_In_Place (Data : in out Storage_Array; Last : out Storage_Offset; Success : out Boolean) is In_Index : Storage_Offset := Data'First; Out_Index : Storage_Offset := Data'First; procedure Push (D : Storage_Element); -- Push one element to the output function Pop return Storage_Element; -- Pop one element from the input ---------- -- Push -- ---------- procedure Push (D : Storage_Element) is begin Data (Out_Index) := D; Out_Index := Out_Index + 1; end Push; --------- -- Pop -- --------- function Pop return Storage_Element is Result : constant Storage_Element := Data (In_Index); begin In_Index := In_Index + 1; return Result; end Pop; Code : Storage_Element; begin while In_Index <= Data'Last loop Code := Pop; exit when Code = 0; if Code > 1 then -- Check input and output boundaries if Out_Index + Storage_Count (Code - 1) > Data'Last + 1 or else In_Index + Storage_Count (Code - 1) > Data'Last + 1 then Success := False; return; end if; for X in 1 .. (Code - 1) loop Push (Pop); end loop; end if; if Code /= 16#FF# and then In_Index <= Data'Last then Push (0); end if; end loop; Last := Out_Index - 1; Success := True; end Decode_In_Place; end COBS;
with Ada.Text_IO; with Ada.Integer_Text_IO; package body Problem_34 is package IO renames Ada.Text_IO; package I_IO renames Ada.Integer_Text_IO; function Factorial(n: Integer) return Integer is product : Integer := 1; begin for i in 2 .. n loop product := product * i; end loop; return product; end Factorial; procedure Solve is subtype Digit is Integer range 0 .. 9; facts : constant Array(Digit) of Integer := (Factorial(0), Factorial(1), Factorial(2), Factorial(3), Factorial(4), Factorial(5), Factorial(6), Factorial(7), Factorial(8), Factorial(9)); function Fact_Sum(n : Integer) return Integer is part_n : Integer := n; modulo : Digit; sum : Integer := 0; begin loop modulo := part_n mod 10; part_n := part_n / 10; sum := sum + Factorial(modulo); exit when part_n = 0; end loop; return sum; end Fact_Sum; total_sum : Integer := 0; begin for num in 3 .. 7*facts(9) loop declare sum : constant Integer := fact_sum(num); begin if sum = num then total_sum := total_sum + num; end if; end; end loop; I_IO.Put(total_sum); IO.New_Line; end Solve; end Problem_34;
with TEXT_IO; with INFLECTIONS_PACKAGE; use INFLECTIONS_PACKAGE; with DICTIONARY_PACKAGE; use DICTIONARY_PACKAGE; with ADDONS_PACKAGE; use ADDONS_PACKAGE; with UNIQUES_PACKAGE; use UNIQUES_PACKAGE; package LINE_STUFF is use TEXT_IO; type DICTIONARY_ITEM; type DICTIONARY_LIST is access DICTIONARY_ITEM; type DICTIONARY_ITEM is record DE : DICTIONARY_ENTRY := NULL_DICTIONARY_ENTRY; SUCC : DICTIONARY_LIST; end record; type DICTIONARY is array (CHARACTER) of DICTIONARY_LIST; NULL_DICTIONARY : DICTIONARY := (others => null); --DICT, UNIQUES, QUES : DICTIONARY := NULL_DICTIONARY; DICT, UNIQUES : DICTIONARY := NULL_DICTIONARY; DICT_LOC : DICTIONARY := NULL_DICTIONARY; type TACKON_LINE is record POFS : PART_OF_SPEECH_TYPE := TACKON; TACK : STEM_TYPE := NULL_STEM_TYPE; ENTR : TACKON_ENTRY := NULL_TACKON_ENTRY; MEAN : MEANING_TYPE := NULL_MEANING_TYPE; end record; NULL_TACKON_LINE : TACKON_LINE; package TACKON_LINE_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; P : out TACKON_LINE); procedure GET(P : out TACKON_LINE); procedure PUT(F : in FILE_TYPE; P : in TACKON_LINE); procedure PUT(P : in TACKON_LINE); procedure GET(S : in STRING; P : out TACKON_LINE; LAST : out INTEGER); procedure PUT(S : out STRING; P : in TACKON_LINE); end TACKON_LINE_IO; type PREFIX_LINE is record POFS : PART_OF_SPEECH_TYPE := PREFIX; FIX : FIX_TYPE := NULL_FIX_TYPE; CONNECT : CHARACTER := ' '; ENTR : PREFIX_ENTRY := NULL_PREFIX_ENTRY; MEAN : MEANING_TYPE := NULL_MEANING_TYPE; end record; NULL_PREFIX_LINE : PREFIX_LINE; package PREFIX_LINE_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; P : out PREFIX_LINE); procedure GET(P : out PREFIX_LINE); procedure PUT(F : in FILE_TYPE; P : in PREFIX_LINE); procedure PUT(P : in PREFIX_LINE); procedure GET(S : in STRING; P : out PREFIX_LINE; LAST : out INTEGER); procedure PUT(S : out STRING; P : in PREFIX_LINE); end PREFIX_LINE_IO; type SUFFIX_LINE is record POFS : PART_OF_SPEECH_TYPE := SUFFIX; FIX : FIX_TYPE := NULL_FIX_TYPE; CONNECT : CHARACTER := ' '; ENTR : SUFFIX_ENTRY := NULL_SUFFIX_ENTRY; MEAN : MEANING_TYPE := NULL_MEANING_TYPE; end record; NULL_SUFFIX_LINE : SUFFIX_LINE; package SUFFIX_LINE_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; P : out SUFFIX_LINE); procedure GET(P : out SUFFIX_LINE); procedure PUT(F : in FILE_TYPE; P : in SUFFIX_LINE); procedure PUT(P : in SUFFIX_LINE); procedure GET(S : in STRING; P : out SUFFIX_LINE; LAST : out INTEGER); procedure PUT(S : out STRING; P : in SUFFIX_LINE); end SUFFIX_LINE_IO; type UNIQUE_ENTRY is record STEM : STEM_TYPE := NULL_STEM_TYPE; QUAL : QUALITY_RECORD := NULL_QUALITY_RECORD; KIND : KIND_ENTRY := NULL_KIND_ENTRY; TRAN : TRANSLATION_RECORD := NULL_TRANSLATION_RECORD; end record; package UNIQUE_ENTRY_IO is DEFAULT_WIDTH : FIELD; procedure GET(F : in FILE_TYPE; P : out UNIQUE_ENTRY); procedure GET(P : out UNIQUE_ENTRY); procedure PUT(F : in FILE_TYPE; P : in UNIQUE_ENTRY); procedure PUT(P : in UNIQUE_ENTRY); procedure GET(S : in STRING; P : out UNIQUE_ENTRY; LAST : out INTEGER); procedure PUT(S : out STRING; P : in UNIQUE_ENTRY); end UNIQUE_ENTRY_IO; procedure LOAD_STEM_FILE(D_K : DICTIONARY_KIND); procedure LOAD_DICTIONARY(DICT : in out DICTIONARY; DICTIONARY_FILE_NAME : STRING); procedure LOAD_UNIQUES(UNQ : in out LATIN_UNIQUES; FILE_NAME : in STRING); end LINE_STUFF;
with Ada.Environment_Variables; use Ada.Environment_Variables; with Ada.Text_Io; use Ada.Text_Io; procedure Env_Vars is procedure Print_Vars(Name, Value : in String) is begin Put_Line(Name & " : " & Value); end Print_Vars; begin Iterate(Print_Vars'access); end Env_Vars;
package body Loop_Optimization1_Pkg is type Unconstrained_Array_Type is array (Index_Type range <>) of Element_Type; procedure Local (UA : in out Unconstrained_Array_Type) is begin null; end; procedure Proc (CA : in out Constrained_Array_Type) is begin Local (Unconstrained_Array_Type (CA)); end; end Loop_Optimization1_Pkg;
pragma License (Unrestricted); -- implementation unit required by compiler with Ada.Finalization; with System.Storage_Elements; with System.Storage_Pools; private with System.Storage_Barriers; package System.Finalization_Masters is pragma Preelaborate; type Finalize_Address_Ptr is access procedure (Obj : Address); type FM_Node is private; type FM_Node_Ptr is access all FM_Node; Header_Size : constant Storage_Elements.Storage_Offset; subtype Any_Storage_Pool_Ptr is Storage_Pools.Storage_Pool_Access; pragma Suppress (Access_Check, Any_Storage_Pool_Ptr); type Finalization_Master is limited new Ada.Finalization.Limited_Controlled with private; procedure Attach_Unprotected (N, L : not null FM_Node_Ptr); procedure Detach_Unprotected (N : not null FM_Node_Ptr); function Objects_Unprotected ( Master : aliased in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr) return FM_Node_Ptr; function Finalization_Started (Master : Finalization_Master'Class) return Boolean; pragma Inline (Finalization_Started); procedure Set_Finalize_Address_Unprotected ( Master : in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr); -- required by compiler (s-finmas.ads) procedure Set_Finalize_Address ( Master : in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr); -- required by compiler (s-finmas.ads) procedure Set_Is_Heterogeneous ( Master : in out Finalization_Master'Class) is null; pragma Inline (Set_Is_Heterogeneous); -- [gcc-7] can not skip calling null procedure -- required by compiler (s-finmas.ads) type Finalization_Master_Ptr is access all Finalization_Master; for Finalization_Master_Ptr'Storage_Size use 0; private use type Storage_Elements.Storage_Offset; type FM_Node is record Prev : FM_Node_Ptr; Next : FM_Node_Ptr; end record; pragma Suppress_Initialization (FM_Node); Header_Size : constant Storage_Elements.Storage_Offset := FM_Node'Size / Standard'Storage_Unit; type FM_List; type FM_List_Access is access all FM_List; type FM_List is limited record Objects : aliased FM_Node; Finalize_Address : Finalize_Address_Ptr; Next : FM_List_Access; end record; pragma Suppress_Initialization (FM_List); type Finalization_Master is limited new Ada.Finalization.Limited_Controlled with record List : aliased FM_List; Base_Pool : Any_Storage_Pool_Ptr := null; Finalization_Started : aliased Storage_Barriers.Flag; end record; overriding procedure Initialize (Object : in out Finalization_Master); overriding procedure Finalize (Object : in out Finalization_Master); -- reraise some exception propagated from its own objects -- required by compiler (s-finmas.ads) function Base_Pool (Master : Finalization_Master'Class) return Any_Storage_Pool_Ptr; procedure Set_Base_Pool ( Master : in out Finalization_Master'Class; Pool_Ptr : Any_Storage_Pool_Ptr); pragma Inline (Base_Pool); -- required by compiler (s-finmas.ads) function Add_Offset_To_Address ( Addr : Address; Offset : Storage_Elements.Storage_Offset) return Address renames Storage_Elements."+"; end System.Finalization_Masters;
with Vect3_Pkg; package Vect3 is -- Unconstrained array types are vectorizable, possibly with special -- help for the programmer type Varray is array (Vect3_Pkg.Index_Type range <>) of Long_Float; for Varray'Alignment use 16; function "+" (X, Y : Varray) return Varray; procedure Add (X, Y : Varray; R : out Varray); procedure Add (X, Y : not null access Varray; R : not null access Varray); -- Constrained array types are vectorizable type Sarray is array (Vect3_Pkg.Index_Type(1) .. Vect3_Pkg.Index_Type(4)) of Long_Float; for Sarray'Alignment use 16; function "+" (X, Y : Sarray) return Sarray; procedure Add (X, Y : Sarray; R : out Sarray); procedure Add (X, Y : not null access Sarray; R : not null access Sarray); type Darray1 is array (Vect3_Pkg.Index_Type(1) .. Vect3_Pkg.N) of Long_Float; for Darray1'Alignment use 16; function "+" (X, Y : Darray1) return Darray1; procedure Add (X, Y : Darray1; R : out Darray1); procedure Add (X, Y : not null access Darray1; R : not null access Darray1); type Darray2 is array (Vect3_Pkg.K .. Vect3_Pkg.Index_Type(4)) of Long_Float; for Darray2'Alignment use 16; function "+" (X, Y : Darray2) return Darray2; procedure Add (X, Y : Darray2; R : out Darray2); procedure Add (X, Y : not null access Darray2; R : not null access Darray2); type Darray3 is array (Vect3_Pkg.K .. Vect3_Pkg.N) of Long_Float; for Darray3'Alignment use 16; function "+" (X, Y : Darray3) return Darray3; procedure Add (X, Y : Darray3; R : out Darray3); procedure Add (X, Y : not null access Darray3; R : not null access Darray3); end Vect3;
-- SPDX-License-Identifier: MIT -- -- Copyright (c) 2007 - 2018 Gautier de Montmollin (Maintainer of the Ada version) -- SWITZERLAND -- -- 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. -- Zip.Compress -- ------------ -- -- This package facilitates the storage or compression of data. -- -- Note that unlike decompression where the decoding is unique, -- there is a quasi indefinite number of ways of compressing data into -- most Zip-supported formats, including LZW (Shrink), Reduce, Deflate, or LZMA. -- As a result, you may want to use your own way for compressing data. -- This package is a portable one and doesn't claim to be the "best". -- The term "best" is relative to the needs, since there are at least -- two criteria that usually go in opposite directions: speed and -- compression ratio, a bit like risk and return in finance. with DCF.Streams; package DCF.Zip.Compress is pragma Preelaborate; -- Compression_Method is actually reflecting the way of compressing -- data, not only the final compression format called "method" in -- Zip specifications. type Compression_Method is -- No compression: (Store, -- Deflate combines LZ and Huffman encoding; 4 strengths available: Deflate_Fixed, Deflate_1, Deflate_2, Deflate_3); type Method_To_Format_Type is array (Compression_Method) of Pkzip_Method; Method_To_Format : constant Method_To_Format_Type; -- Deflate_Fixed compresses the data into a single block and with predefined -- ("fixed") compression structures. The data are basically LZ-compressed -- only, since the Huffman code sets are flat and not tailored for the data. subtype Deflation_Method is Compression_Method range Deflate_Fixed .. Deflate_3; -- The multi-block Deflate methods use refined techniques to decide when to -- start a new block and what sort of block to put next. subtype Taillaule_Deflation_Method is Compression_Method range Deflate_1 .. Deflate_3; User_Abort : exception; -- Compress data from an input stream to an output stream until -- End_Of_File(input) = True, or number of input bytes = input_size. -- If password /= "", an encryption header is written. procedure Compress_Data (Input, Output : in out DCF.Streams.Root_Zipstream_Type'Class; Input_Size : File_Size_Type; Method : Compression_Method; Feedback : Feedback_Proc; CRC : out Unsigned_32; Output_Size : out File_Size_Type; Zip_Type : out Unsigned_16); -- ^ code corresponding to the compression method actually used private Method_To_Format : constant Method_To_Format_Type := (Store => Store, Deflation_Method => Deflate); end DCF.Zip.Compress;
with Ada.Exceptions; use Ada.Exceptions; package Noreturn2 is procedure Raise_From (X : Exception_Occurrence); pragma No_Return (Raise_From); end Noreturn2;
with GNAT.OS_Lib; with Simple_Logging; with CLIC.Config.Info; with CLIC.Config.Edit; with CLIC.Config.Load; package body CLIC_Ex.Commands.Config is package Trace renames Simple_Logging; ------------- -- Execute -- ------------- overriding procedure Execute (Cmd : in out Instance; Args : AAA.Strings.Vector) is Enabled : Natural := 0; Config_Path : constant String := (if Cmd.Global then "global_config.toml" else "local_config.toml"); begin -- Check no multi-action Enabled := Enabled + (if Cmd.List then 1 else 0); Enabled := Enabled + (if Cmd.Get then 1 else 0); Enabled := Enabled + (if Cmd.Set then 1 else 0); Enabled := Enabled + (if Cmd.Unset then 1 else 0); Enabled := Enabled + (if Cmd.Builtins_Doc then 1 else 0); if Enabled > 1 then Trace.Error ("Specify at most one subcommand"); GNAT.OS_Lib.OS_Exit (1); end if; if Enabled = 0 then -- The default command is --list Cmd.List := True; end if; if Cmd.Show_Origin and then not Cmd.List then Trace.Error ("--show-origin only valid with --list"); GNAT.OS_Lib.OS_Exit (1); end if; if Cmd.List then case Args.Count is when 0 => Trace.Always (CLIC.Config.Info.List (Cmd.Config, Filter => "*", Show_Origin => Cmd.Show_Origin).Flatten (ASCII.LF)); when 1 => Trace.Always (CLIC.Config.Info.List (Cmd.Config, Filter => Args.First_Element, Show_Origin => Cmd.Show_Origin).Flatten (ASCII.LF)); when others => Trace.Error ("List expects at most one argument"); GNAT.OS_Lib.OS_Exit (1); end case; elsif Cmd.Get then if Args.Count /= 1 then Trace.Error ("Unset expects one argument"); GNAT.OS_Lib.OS_Exit (1); end if; if not CLIC.Config.Is_Valid_Config_Key (Args.First_Element) then Trace.Error ("Invalid configration key '" & Args.First_Element & "'"); GNAT.OS_Lib.OS_Exit (1); end if; if Cmd.Config.Defined (Args.First_Element) then Trace.Always (Cmd.Config.Get_As_String (Args.First_Element)); else Trace.Error ("Configuration key '" & Args.First_Element & "' is not defined"); GNAT.OS_Lib.OS_Exit (1); end if; elsif Cmd.Set then if Args.Count /= 2 then Trace.Error ("Set expects two arguments"); GNAT.OS_Lib.OS_Exit (1); end if; declare Key : constant String := Args.Element (1); Val : constant String := Args.Element (2); begin if not CLIC.Config.Is_Valid_Config_Key (Key) then Trace.Error ("Invalid configration key '" & Key & "'"); GNAT.OS_Lib.OS_Exit (1); end if; if not CLIC.Config.Edit.Set (Config_Path, Key, Val) then GNAT.OS_Lib.OS_Exit (1); end if; end; elsif Cmd.Unset then if Args.Count /= 1 then Trace.Error ("Unset expects one argument"); GNAT.OS_Lib.OS_Exit (1); end if; declare Key : constant String := Args.Element (1); begin if not CLIC.Config.Is_Valid_Config_Key (Key) then Trace.Error ("Invalid configration key '" & Key & "'"); GNAT.OS_Lib.OS_Exit (1); end if; if not CLIC.Config.Edit.Unset (Config_Path, Key) then GNAT.OS_Lib.OS_Exit (1); end if; end; end if; end Execute; -------------------- -- Setup_Switches -- -------------------- overriding procedure Setup_Switches (Cmd : in out Instance; Config : in out CLIC.Subcommand.Switches_Configuration) is use CLIC.Subcommand; begin Define_Switch (Config => Config, Output => Cmd.List'Access, Long_Switch => "--list", Help => "List configuration options"); Define_Switch (Config => Config, Output => Cmd.Show_Origin'Access, Long_Switch => "--show-origin", Help => "Show origin of configuration values in --list"); Define_Switch (Config => Config, Output => Cmd.Get'Access, Long_Switch => "--get", Help => "Print value of a configuration option"); Define_Switch (Config => Config, Output => Cmd.Set'Access, Long_Switch => "--set", Help => "Set a configuration option"); Define_Switch (Config => Config, Output => Cmd.Unset'Access, Long_Switch => "--unset", Help => "Unset a configuration option"); Define_Switch (Config => Config, Output => Cmd.Global'Access, Long_Switch => "--global", Help => "Set and Unset global configuration instead" & " of the local one"); Define_Switch (Config => Config, Output => Cmd.Builtins_Doc'Access, Long_Switch => "--builtins-doc", Help => "Print Markdown list of built-in configuration options"); end Setup_Switches; end CLIC_Ex.Commands.Config;
with DDS.Request_Reply.Replier.Typed_Replier_Generic; with Dds.Builtin_Octets_DataReader; with Dds.Builtin_Octets_DataWriter; package DDS.Request_Reply.Tests.Simple.Octets_Replier is new DDS.Request_Reply.Replier.Typed_Replier_Generic (Reply_DataWriter => Dds.Builtin_Octets_DataWriter, Request_DataReader => Dds.Builtin_Octets_DataReader);
-- Project: StratoX -- System: Stratosphere Balloon Flight Controller -- Author: Martin Becker (becker@rcs.ei.tum.de) -- @summary tools for SD Logging package SDLog.Tools with SPARK_Mode => Off is procedure Perf_Test (FS : in FAT_Filesystem.FAT_Filesystem_Access; megabytes : Interfaces.Unsigned_32); -- Write performance test. Creates a file with the given length -- dumps throughput. procedure List_Rootdir (FS : in FAT_Filesystem.FAT_Filesystem_Access); end SDLog.Tools;
with avtas.lmcp.types; use avtas.lmcp.types; with afrl.cmasi.object; use afrl.cmasi.object; with afrl.cmasi.enumerations; use afrl.cmasi.enumerations; with Ada.Containers.Vectors; package afrl.cmasi.operatingRegion is type OperatingRegion is new afrl.cmasi.object.Object with private; type OperatingRegion_Acc is access all OperatingRegion; type OperatingRegion_Class_Acc is access all OperatingRegion'Class; package Vect_Int64_t is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Int64_t); type Vect_Int64_t_Acc is access all Vect_Int64_t.Vector; function getFullLmcpTypeName(this : OperatingRegion) return String; function getLmcpTypeName(this : OperatingRegion) return String; function getLmcpType(this : OperatingRegion) return UInt32_t; function getID(this : OperatingRegion'Class) return Int64_t; procedure setID(this : out OperatingRegion'Class; ID : in Int64_t); function getKeepInAreas(this : OperatingRegion'Class) return Vect_Int64_t_Acc; function getKeepOutAreas(this : OperatingRegion'Class) return Vect_Int64_t_Acc; private type OperatingRegion is new afrl.cmasi.object.Object with record ID : Int64_t := 0; KeepInAreas : Vect_Int64_t_Acc := new Vect_Int64_t.Vector; KeepOutAreas : Vect_Int64_t_Acc := new Vect_Int64_t.Vector; end record; end afrl.cmasi.operatingRegion;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" private with GL.Low_Level; package GL.Enums.Textures is pragma Preelaborate; -- Texture_Kind is declared in GL.Low_Level.Enums to be accessible for -- OpenCLAda type Parameter is (Border_Color, Border, Mag_Filter, Min_Filter, Wrap_S, Wrap_T, Priority, Resident, Wrap_R, Min_LoD, Max_LoD, Base_Level, Max_Level, Generate_Mipmap, Depth, Compare_Mode, Compare_Func); -- needs to be declared here because of subtypes for Parameter use (Border_Color => 16#1003#, Border => 16#1004#, Mag_Filter => 16#2800#, Min_Filter => 16#2801#, Wrap_S => 16#2802#, Wrap_T => 16#2803#, Priority => 16#8066#, Resident => 16#8067#, Wrap_R => 16#8072#, Min_LoD => 16#813A#, Max_LoD => 16#813B#, Base_Level => 16#813C#, Max_Level => 16#813D#, Generate_Mipmap => 16#8191#, Depth => 16#884B#, Compare_Mode => 16#884C#, Compare_Func => 16#884D#); for Parameter'Size use Low_Level.Enum'Size; subtype LoD is Parameter range Min_LoD .. Max_Level; type Compare_Kind is (None, Compare_R_To_Texture); type Env_Target is (Texture_Env, Filter_Control, Point_Sprite); type Env_Parameter is (Alpha_Scale, Env_Mode, Env_Color, LoD_Bias, Combine_RGB, Combine_Alpha, RGB_Scale, Src0_RGB, Src1_RGB, Src2_RGB, Src0_Alpha, Src1_Alpha, Src2_Alpha, Operand0_RGB, Operand1_RGB, Operand2_RGB, Operand0_Alpha, Operand1_Alpha, Operand2_Alpha, Coord_Replace); type Level_Parameter is (Width, Height, Internal_Format, Red_Size, Green_Size, Blue_Size, Alpha_Size, Luminance_Size, Intensity_Size, Compressed_Image_Size, Compressed, Depth_Size, Red_Type, Green_Type, Blue_Type, Alpha_Type, Depth_Type, Buffer_Offset, Buffer_Size); Texture_Unit_Start_Rep : constant := 16#84C0#; -- oh god why --type Texture_Unit is (Texture0, Texture1, Texture2, Texture3, Texture4, -- Texture5, Texture6, Texture7, Texture8, Texture9, -- Texture10, Texture11, Texture12, Texture13, Texture14, -- Texture15, Texture16, Texture17, Texture18, Texture19, -- Texture20, Texture21, Texture22, Texture23, Texture24, -- Texture25, Texture26, Texture27, Texture28, Texture29, -- Texture30, Texture31); private for Compare_Kind use (None => 0, Compare_R_To_Texture => 16#884E#); for Compare_Kind'Size use Low_Level.Enum'Size; for Env_Target use (Texture_Env => 16#2300#, Filter_Control => 16#8500#, Point_Sprite => 16#8861#); for Env_Target'Size use Low_Level.Enum'Size; for Env_Parameter use (Alpha_Scale => 16#0D1C#, Env_Mode => 16#2200#, Env_Color => 16#2201#, LoD_Bias => 16#8501#, Combine_RGB => 16#8571#, Combine_Alpha => 16#8572#, RGB_Scale => 16#8573#, Src0_RGB => 16#8580#, Src1_RGB => 16#8581#, Src2_RGB => 16#8582#, Src0_Alpha => 16#8588#, Src1_Alpha => 16#8589#, Src2_Alpha => 16#858A#, Operand0_RGB => 16#8590#, Operand1_RGB => 16#8591#, Operand2_RGB => 16#8592#, Operand0_Alpha => 16#8598#, Operand1_Alpha => 16#8599#, Operand2_Alpha => 16#859A#, Coord_Replace => 16#8862#); for Env_Parameter'Size use Low_Level.Enum'Size; for Level_Parameter use (Width => 16#1000#, Height => 16#1001#, Internal_Format => 16#1002#, Red_Size => 16#805C#, Green_Size => 16#805D#, Blue_Size => 16#805E#, Alpha_Size => 16#805F#, Luminance_Size => 16#8060#, Intensity_Size => 16#8061#, Compressed_Image_Size => 16#86A0#, Compressed => 16#86A1#, Depth_Size => 16#884A#, Red_Type => 16#8C10#, Green_Type => 16#8C11#, Blue_Type => 16#8C12#, Alpha_Type => 16#8C13#, Depth_Type => 16#8C14#, Buffer_Offset => 16#919D#, Buffer_Size => 16#919E#); for Level_Parameter'Size use Low_Level.Enum'Size; --for Texture_Unit use (Texture0 => 16#84C0#, -- Texture1 => 16#84C1#, -- Texture2 => 16#84C2#, -- Texture3 => 16#84C3#, -- Texture4 => 16#84C4#, -- Texture5 => 16#84C5#, -- Texture6 => 16#84C6#, -- Texture7 => 16#84C7#, -- Texture8 => 16#84C8#, -- Texture9 => 16#84C9#, -- Texture10 => 16#84CA#, -- Texture11 => 16#84CB#, -- Texture12 => 16#84CC#, -- Texture13 => 16#84CD#, -- Texture14 => 16#84CE#, -- Texture15 => 16#84CF#, -- Texture16 => 16#84D0#, -- Texture17 => 16#84D1#, -- Texture18 => 16#84D2#, -- Texture19 => 16#84D3#, -- Texture20 => 16#84D4#, -- Texture21 => 16#84D5#, -- Texture22 => 16#84D6#, -- Texture23 => 16#84D7#, -- Texture24 => 16#84D8#, -- Texture25 => 16#84D9#, -- Texture26 => 16#84DA#, -- Texture27 => 16#84DB#, -- Texture28 => 16#84DC#, -- Texture29 => 16#84DD#, -- Texture30 => 16#84DE#, -- Texture31 => 16#84DF#); --for Texture_Unit'Size use Low_Level.Enum'Size; end GL.Enums.Textures;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. generic Fallback_Instance : Instance_Type_Access; package Apsepp.Generic_Shared_Instance.Fallback_Switch is function Instance_FS return Instance_Type_Access is (if Instantiated then Instance else Fallback_Instance); end Apsepp.Generic_Shared_Instance.Fallback_Switch;
-- C45231A.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. --* -- CHECK THAT THE RELATIONAL AND MEMBERSHIP OPERATIONS YIELD CORRECT -- RESULTS FOR PREDEFINED TYPE INTEGER (INCLUDING THE CASE IN WHICH THE -- RELATIONAL OPERATORS ARE REDEFINED). -- SUBTESTS ARE: -- (A). TESTS FOR RELATIONAL OPERATORS. -- (B). TESTS FOR MEMBERSHIP OPERATORS. -- (C). TESTS FOR MEMBERSHIP OPERATORS IN THE CASE IN WHICH THE -- RELATIONAL OPERATORS ARE REDEFINED. -- RJW 2/4/86 WITH REPORT; USE REPORT; PROCEDURE C45231A IS BEGIN TEST ( "C45231A", "CHECK THAT THE RELATIONAL AND " & "MEMBERSHIP OPERATIONS YIELD CORRECT " & "RESULTS FOR PREDEFINED TYPE INTEGER " & "(INCLUDING THE CASE IN WHICH THE " & "RELATIONAL OPERATORS ARE REDEFINED)" ); DECLARE -- (A) I1A, I1B : INTEGER := IDENT_INT (1); I2 : INTEGER := IDENT_INT (2); CI2 : CONSTANT INTEGER := 2; BEGIN -- (A) IF (I2 = CI2) AND (NOT (I2 /= CI2)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 1" ); END IF; IF (I2 /= 4) AND (NOT (I2 = 4)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 2" ); END IF; IF (I1A = I1B) AND (NOT (I1A /= I1B)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 3" ); END IF; IF (I2 >= CI2) AND (NOT (I2 < CI2)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 4"); END IF; IF (I2 <= 4) AND (NOT (I2 > 4)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 5" ); END IF; IF (I1A >= I1B) AND (I1A <= I1B) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 6" ); END IF; IF ">" (LEFT => CI2, RIGHT => I1A) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 7" ); END IF; IF "<" (LEFT => I1A, RIGHT => I2) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 8" ); END IF; IF ">=" (LEFT => I1A, RIGHT => I1A ) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 9 "); END IF; IF "<=" (LEFT => I1A, RIGHT => CI2) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 10 "); END IF; IF "=" (LEFT => I1A, RIGHT => I1B ) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 11 "); END IF; IF "/=" (LEFT => CI2, RIGHT => 4) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 12 "); END IF; END; -- (A) ---------------------------------------------------------------- DECLARE -- (B) SUBTYPE ST IS INTEGER RANGE -10 .. 10; I1 : INTEGER := IDENT_INT (1); I5 : INTEGER := IDENT_INT (5); CI2 : CONSTANT INTEGER := 2; CI10 : CONSTANT INTEGER := 10; BEGIN -- (B) IF (I1 IN ST) AND (I1 NOT IN CI2 .. CI10) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.1" ); END IF; IF (IDENT_INT (11) NOT IN ST) AND (CI2 IN I1 .. I5) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.2" ); END IF; IF NOT (I5 NOT IN CI2 .. 10) AND NOT (IDENT_INT (-11) IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.3" ); END IF; IF NOT (I1 IN CI2 .. CI10) AND NOT (I5 NOT IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.4" ); END IF; IF (I1 NOT IN I5 .. I1) AND NOT (I5 IN I5 .. I1) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.5" ); END IF; END; -- (B) ------------------------------------------------------------- DECLARE -- (C) SUBTYPE ST IS INTEGER RANGE -10 .. 10; I1 : INTEGER := IDENT_INT (1); I5 : INTEGER := IDENT_INT (5); CI2 : CONSTANT INTEGER := 2; CI10 : CONSTANT INTEGER := 10; FUNCTION ">" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) <= INTEGER'POS (R); END; FUNCTION ">=" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) < INTEGER'POS (R); END; FUNCTION "<" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) >= INTEGER'POS (R); END; FUNCTION "<=" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) > INTEGER'POS (R); END; BEGIN -- (C) IF (I1 IN ST) AND (I1 NOT IN CI2 .. CI10) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.1" ); END IF; IF (IDENT_INT (11) NOT IN ST) AND (CI2 IN I1 .. I5) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.2" ); END IF; IF NOT (I5 NOT IN CI2 .. 10) AND NOT (IDENT_INT (-11) IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.3" ); END IF; IF NOT (I1 IN CI2 .. CI10) AND NOT (I5 NOT IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.4" ); END IF; IF (I1 NOT IN I5 .. I1) AND NOT (I5 IN I5 .. I1) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.5" ); END IF; END; -- (C) RESULT; END C45231A;
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com> -- -- 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.Text_IO; with Gdk.Cairo; with Gdk.Color; with Glib.Convert; with GNAT.Directory_Operations; with GNAT.Strings; with Gtk.About_Dialog; with Gtk.Button; with Gtk.Check_Button; with Gtk.Color_Chooser_Dialog; with Gtk.Dialog; with Gtk.Enums; with Gtk.File_Chooser; with Gtk.File_Chooser_Dialog; with Gtk.Image; with Gtk.Image_Menu_Item; with Gtk.Main; with Gtk.Message_Dialog; with Gtk.Text_Iter; with Gtk.Tool_Button; with Gtk.Style_Context; with LSE.IO.Drawing_Area; with LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr; with LSE.Model.IO.Text_File; with LSE.View.Callbacks; package body LSE.View.View is procedure Initialize (This : in out Instance; Builder : Gtk_Builder; Presenter : access LSE.Presenter.Presenter.Instance) is pragma Unreferenced (Presenter); use Ada.Text_IO; use Gtk.Image_Menu_Item; use Gtk.Tool_Button; use LSE.View.Callbacks; Bar_Menu_Item : Gtk_Image_Menu_Item; Icon_Menu_Item : Gtk_Tool_Button; begin This.Window := Gtk_Window (Builder.Get_Object ("main_window")); This.Level_Selector := Gtk_Spin_Button (Builder.Get_Object ("ls_level")); This.Text_Error := Gtk_Text_Buffer (Builder.Get_Object ("text_error")); This.Text_Editor := Gtk_Text_Buffer (Builder.Get_Object ("text_editor")); This.Render_Area := Gtk_Drawing_Area (Builder.Get_Object ("render_area")); Connect (This.Window, "destroy", Stop_Program'Access); Connect (This.Level_Selector, "value-changed", LS_Level_Cb'Access); if not This.Window.Set_Icon_From_File (App_Icon_Location) then raise ICON_NOT_LOADED; end if; This.Window.Set_Title (App_Name); ------------------------- -- Configure bar menu -- ------------------------- Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_new")); Connect (Bar_Menu_Item, "activate", New_File_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_open")); Connect (Bar_Menu_Item, "activate", Open_File_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_save")); Connect (Bar_Menu_Item, "activate", Save_File_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_save_as")); Connect (Bar_Menu_Item, "activate", Save_As_File_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_quit")); Connect (Bar_Menu_Item, "activate", Stop_Program'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_validate")); Connect (Bar_Menu_Item, "activate", Validate_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_bg_color")); Connect (Bar_Menu_Item, "activate", Bg_Color_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_fg_color")); Connect (Bar_Menu_Item, "activate", Fg_Color_Cb'Access); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_export_ps")); Connect (Bar_Menu_Item, "activate", Export_Cb'Access, "PS"); Bar_Menu_Item := Gtk_Image_Menu_Item (Builder.Get_Object ("menu_item_about")); Connect (Bar_Menu_Item, "activate", About_Cb'Access); -------------------------- -- Configure icon menu -- -------------------------- Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_new")); Connect (Icon_Menu_Item, "clicked", New_File_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_open")); Connect (Icon_Menu_Item, "clicked", Open_File_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_save")); Connect (Icon_Menu_Item, "clicked", Save_File_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_save_as")); Connect (Icon_Menu_Item, "clicked", Save_As_File_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_quit")); Connect (Icon_Menu_Item, "clicked", Stop_Program'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_validate")); Connect (Icon_Menu_Item, "clicked", Validate_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_bg_color")); Connect (Icon_Menu_Item, "clicked", Bg_Color_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_fg_color")); Connect (Icon_Menu_Item, "clicked", Fg_Color_Cb'Access); Icon_Menu_Item := Gtk_Tool_Button (Builder.Get_Object ("menu_icon_about")); Connect (Icon_Menu_Item, "clicked", About_Cb'Access); --------------------------- -- Set default L-System -- --------------------------- This.Text_Editor.Set_Text (Default_LSystem); This.Render_Area.On_Draw (Draw_Cb'Access); This.Render_Area.On_Size_Allocate (Size_Allocate_Cb'Access); exception when ICON_NOT_LOADED => Put_Line ("App icon cannot be loaded"); end Initialize; function Initialize (Builder : Gtk_Builder; Presenter : access LSE.Presenter.Presenter.Instance) return Instance is This : Instance; begin This.Initialize (Builder, Presenter); return This; end Initialize; procedure Start (This : Instance) is begin This.Validate; end Start; procedure Set_Presenter (This : in out Instance; Value : LSE.Presenter.Presenter.Instance) is begin This.Presenter := new LSE.Presenter.Presenter.Instance '(Value); LSE.View.Callbacks.View := This; end Set_Presenter; procedure Stop_Program (This : Instance) is pragma Unreferenced (This); use Gtk.Dialog; use Gtk.Main; use Gtk.Message_Dialog; Dialog : Gtk_Message_Dialog; begin Gtk_New (Dialog, null, 0, Message_Error, Buttons_Ok_Cancel, "Are you sure to want to quit the app ?"); Dialog.Set_Title ("Confirmation exit the application"); Dialog.Show_All; if Dialog.Run = Gtk_Response_OK then Dialog.Close; Main_Quit; else Dialog.Close; end if; end Stop_Program; procedure New_File (This : Instance) is use Gtk.Dialog; use Gtk.Message_Dialog; Dialog : Gtk_Message_Dialog; begin if File_Path.Element = "" then This.Text_Editor.Set_Text (""); else Gtk_New (Dialog, null, 0, Message_Error, Buttons_Ok_Cancel, "Are you sure to want create a new file ?"); Dialog.Set_Title ("Confirmation create a new file"); Dialog.Show_All; if Dialog.Run = Gtk_Response_OK then Dialog.Close; This.Text_Editor.Set_Text (""); File_Path.Reference := To_Unbounded_String (""); This.Window.Set_Title (App_Name); else Dialog.Close; end if; end if; end New_File; procedure Save (This : Instance; Save_As : Boolean := False) is use Gtk.Button; use Gtk.Dialog; use Gtk.File_Chooser; use Gtk.File_Chooser_Dialog; use LSE.Model.IO.Text_File; Dialog : Gtk_File_Chooser_Dialog; Btn_Ok : Gtk_Button; Btn_Ko : Gtk_Button; Save : Boolean := False; begin if File_Path.Element = "" or Save_As then Btn_Ko := Gtk_Button_New_With_Mnemonic ("_Cancel"); Btn_Ok := Gtk_Button_New_With_Mnemonic ("_Save"); Dialog := Gtk_File_Chooser_Dialog_New ("Save File", This.Window, Action_Save); Dialog.Set_Do_Overwrite_Confirmation (True); Dialog.Add_Action_Widget (Btn_Ko, Gtk.Dialog.Gtk_Response_Cancel); Dialog.Add_Action_Widget (Btn_Ok, Gtk.Dialog.Gtk_Response_Accept); Dialog.Set_Extra_Widget (Btn_Ok); Dialog.Set_Extra_Widget (Btn_Ko); Dialog.Set_Current_Name (Default_File_Name & Default_LS_Extension); if Dialog.Run = Gtk.Dialog.Gtk_Response_Accept then Save := True; File_Path.Reference := To_Unbounded_String (Dialog.Get_Filename); This.Window.Set_Title (App_Name & " - " & Dialog.Get_Filename); Dialog.Destroy; else Dialog.Destroy; end if; else Save := True; end if; if Save then Save_To_File (To_String (File_Path.Element), This.Get_Text_Editor_Content); end if; end Save; procedure Validate (This : Instance) is begin if This.Presenter.Validate (This.Get_Text_Editor_Content) then This.Text_Error.Set_Text (""); This.Level_Selector.Set_Value (0.0); This.Render; else This.Text_Error.Set_Text (This.Presenter.Get_Error); end if; end Validate; procedure Open (This : Instance) is use Gtk.Button; use Gtk.Dialog; use Gtk.File_Chooser; use Gtk.File_Chooser_Dialog; use LSE.Model.IO.Text_File; Dialog : Gtk_File_Chooser_Dialog; Btn_Ok : Gtk_Button; Btn_Ko : Gtk_Button; begin Btn_Ko := Gtk_Button_New_With_Mnemonic ("_Cancel"); Btn_Ok := Gtk_Button_New_With_Mnemonic ("_Open"); Dialog := Gtk_File_Chooser_Dialog_New ("Open File", This.Window, Action_Open); Dialog.Set_Do_Overwrite_Confirmation (True); Dialog.Add_Action_Widget (Btn_Ko, Gtk.Dialog.Gtk_Response_Cancel); Dialog.Add_Action_Widget (Btn_Ok, Gtk.Dialog.Gtk_Response_Accept); Dialog.Set_Extra_Widget (Btn_Ok); Dialog.Set_Extra_Widget (Btn_Ko); if Dialog.Run = Gtk.Dialog.Gtk_Response_Accept then File_Path.Reference := To_Unbounded_String (Dialog.Get_Filename); This.Window.Set_Title (App_Name & " - " & Dialog.Get_Filename); This.Text_Editor.Set_Text (Read_From_File (Dialog.Get_Filename)); Dialog.Destroy; else Dialog.Destroy; end if; end Open; procedure About (This : Instance) is use GNAT.Strings; use Gtk.About_Dialog; use Gtk.Dialog; use Gtk.Image; pragma Unreferenced (This); Dialog : Gtk_About_Dialog; List1 : GNAT.Strings.String_List (1 .. 1); Image : Gtk_Image; begin List1 (1) := new String '("Quentin Dauprat (Heziode)"); -- Create about dialog Gtk_New (Dialog); Gtk_New (Image, App_Icon_Location); Dialog.Set_Logo (Image.Get); Dialog.Set_Program_Name ("Lindenmayer system editor"); Dialog.Set_Comments ("This program is an editor of L-System"); Dialog.Set_License_Type (License_Mit_X11); Dialog.Set_Version ("1.0.0"); Dialog.Set_Website ("https://github.com/Heziode/lsystem-editor"); Dialog.Set_Website_Label ("Source-code"); Dialog.Set_Authors (List1); -- Dialog.Show_All; if Dialog.Run = Gtk.Dialog.Gtk_Response_Close then Dialog.Destroy; else Dialog.Destroy; end if; end About; procedure LS_Level (This : Instance; Value : Integer) is begin This.Presenter.LS_Level (Value); This.Render; end LS_Level; procedure Background_Color (This : Instance) is use Gdk.RGBA; use Gtk.Color_Chooser_Dialog; use Gtk.Dialog; Dialog : Gtk_Color_Chooser_Dialog; Rgba : Gdk_RGBA; begin Dialog := Gtk_Color_Chooser_Dialog_New ("Background Color", This.Window); if Dialog.Run = Gtk.Dialog.Gtk_Response_OK then Dialog.Get_Rgba (Rgba); This.Presenter.Set_Background_Color (Rgba); This.Render_Area.Queue_Draw; Dialog.Destroy; else Dialog.Destroy; end if; end Background_Color; procedure Foreground_Color (This : Instance) is use Gdk.RGBA; use Gtk.Color_Chooser_Dialog; use Gtk.Dialog; Dialog : Gtk_Color_Chooser_Dialog; Rgba : Gdk_RGBA; begin Dialog := Gtk_Color_Chooser_Dialog_New ("Foreground Color", This.Window); if Dialog.Run = Gtk.Dialog.Gtk_Response_OK then Dialog.Get_Rgba (Rgba); This.Presenter.Set_Foreground_Color (Rgba); This.Render_Area.Queue_Draw; Dialog.Destroy; else Dialog.Destroy; end if; end Foreground_Color; procedure Export (This : Instance; Format : String) is use Glib; use GNAT.Directory_Operations; use Gtk.Button; use Gtk.Dialog; use Gtk.File_Chooser; use Gtk.File_Chooser_Dialog; Unknown_Color : exception; Dialog : Gtk_File_Chooser_Dialog; Btn_Ok : Gtk_Button; Btn_Ko : Gtk_Button; Path : Unbounded_String; Width : Gint := Gint (This.Presenter.Get_Width); Height : Gint := Gint (This.Presenter.Get_Height); Margin_Top : Gint := Gint (This.Presenter.Get_Margin_Top); Margin_Right : Gint := Gint (This.Presenter.Get_Margin_Right); Margin_Bottom : Gint := Gint (This.Presenter.Get_Margin_Bottom); Margin_Left : Gint := Gint (This.Presenter.Get_Margin_Left); Bg_Rgba : Gdk_RGBA; Fg_Rgba : Gdk_RGBA; Export : Boolean; Success : Boolean; Have_Bg : Boolean := This.Presenter.Get_Background_Color /= ""; File_Choose : Boolean := False; begin -- While user give bad file Choose : while not File_Choose loop Btn_Ko := Gtk_Button_New_With_Mnemonic ("_Cancel"); Btn_Ok := Gtk_Button_New_With_Mnemonic ("_Save"); Dialog := Gtk_File_Chooser_Dialog_New ("Export File", This.Window, Action_Save); Dialog.Set_Do_Overwrite_Confirmation (True); Dialog.Add_Action_Widget (Btn_Ko, Gtk.Dialog.Gtk_Response_Cancel); Dialog.Add_Action_Widget (Btn_Ok, Gtk.Dialog.Gtk_Response_Accept); Dialog.Set_Extra_Widget (Btn_Ok); Dialog.Set_Extra_Widget (Btn_Ko); Dialog.Set_Current_Name (Default_File_Name); if Dialog.Run = Gtk.Dialog.Gtk_Response_Accept then Path := To_Unbounded_String (Dialog.Get_Filename); Dialog.Destroy; -- Check if file is valid Check_File : declare Name : constant String := Base_Name (To_String (Path)); File_Format : constant String := This.Presenter.Get_Extension (Format); begin if Name'Length < File_Format'Length then File_Choose := True; Path := Path & File_Format; elsif Name'Length = 0 then File_Choose := False; elsif Name (Name'Last - File_Format'Length + 1 .. Name'Last) /= File_Format then File_Choose := True; Path := Path & File_Format; else File_Choose := True; end if; end Check_File; else Dialog.Destroy; exit Choose; end if; end loop Choose; if File_Choose then -- Configure export Parse (Bg_Rgba, This.Presenter.Get_Background_Color, Success); if This.Presenter.Get_Background_Color /= "" and then not Success then raise Unknown_Color; end if; Parse (Fg_Rgba, This.Presenter.Get_Foreground_Color, Success); if not Success then raise Unknown_Color; end if; This.Get_Export_Param (Width => Width, Height => Height, Margin_Top => Margin_Top, Margin_Right => Margin_Right, Margin_Bottom => Margin_Bottom, Margin_Left => Margin_Left, Bg_Rgba => Bg_Rgba, Fg_Rgba => Fg_Rgba, Have_Bg => Have_Bg, Export => Export); if Export then This.Presenter.Export (Format, To_String (Path), Width, Height, Margin_Top, Margin_Right, Margin_Bottom, Margin_Left, Bg_Rgba, Fg_Rgba, Have_Bg); end if; end if; end Export; function Get_Text_Editor_Content (This : Instance) return String is use Gtk.Text_Iter; Start, The_End : Gtk_Text_Iter; begin Get_Bounds (This.Text_Editor, Start, The_End); return Get_Text (This.Text_Editor, Start, The_End); end Get_Text_Editor_Content; procedure Render (This : Instance) is begin This.Presenter.Develop; This.Presenter.Interpret; This.Render_Area.Queue_Draw; end Render; procedure Get_Export_Param (This : Instance; Width, Height, Margin_Top, Margin_Right, Margin_Bottom, Margin_Left : in out Gint; Bg_Rgba, Fg_Rgba : in out Gdk_RGBA; Have_Bg : in out Boolean; Export : out Boolean) is pragma Unreferenced (This); use Glib.Convert; use Gtk.Builder; use Gtk.Button; use Gtk.Check_Button; use Gtk.Dialog; use LSE.View.Callbacks; Builder : Gtk_Builder; Dialog : Gtk_Dialog := Gtk_Dialog_New; Btn_Ok : Gtk_Button; Btn_Ko : Gtk_Button; Check : Gtk_Check_Button; Spin : Gtk_Spin_Button; Color : Gtk_Color_Button; begin Gtk_New_From_File (Builder, Locale_To_UTF8 ("ressources/dialog_export.glade")); Dialog := Gtk_Dialog (Builder.Get_Object ("dialog_export")); Btn_Ko := Gtk_Button (Builder.Get_Object ("btn_cancel")); Btn_Ok := Gtk_Button (Builder.Get_Object ("btn_export")); Dialog.Add_Action_Widget (Btn_Ko, Gtk.Dialog.Gtk_Response_Cancel); Dialog.Add_Action_Widget (Btn_Ok, Gtk.Dialog.Gtk_Response_Accept); -- Set background color Color := Gtk_Color_Button (Builder.Get_Object ("bg_color")); if Have_Bg then Color.Set_Rgba (Bg_Rgba); end if; -- Toggle checkbox for background color Check := Gtk_Check_Button (Builder.Get_Object ("checkbox_bg")); Check.Set_Active (Have_Bg); Color.Set_Sensitive (Have_Bg); Connect (Check, "toggled", Export_Bg_Color_Cb'Access, Color); -- Set foreground color Color := Gtk_Color_Button (Builder.Get_Object ("fg_color")); Color.Set_Rgba (Fg_Rgba); -- Set Width Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_width")); Spin.Set_Value (Gdouble (Width)); -- Set Height Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_height")); Spin.Set_Value (Gdouble (Height)); -- Set margin top Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_top")); Spin.Set_Value (Gdouble (Margin_Top)); -- Set margin right Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_right")); Spin.Set_Value (Gdouble (Margin_Right)); -- Set margin bottom Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_bottom")); Spin.Set_Value (Gdouble (Margin_Bottom)); -- Set margin left Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_left")); Spin.Set_Value (Gdouble (Margin_Left)); if Dialog.Run = Gtk.Dialog.Gtk_Response_Accept then -- Set background color if Check.Get_Active then Color := Gtk_Color_Button (Builder.Get_Object ("bg_color")); Color.Get_Rgba (Bg_Rgba); Have_Bg := True; else Have_Bg := False; end if; -- Set foreground color Color := Gtk_Color_Button (Builder.Get_Object ("fg_color")); Color.Get_Rgba (Fg_Rgba); -- Set Width Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_width")); Width := Spin.Get_Value_As_Int; -- Set Height Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_height")); Height := Spin.Get_Value_As_Int; -- Set margin top Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_top")); Margin_Top := Spin.Get_Value_As_Int; -- Set margin right Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_right")); Margin_Right := Spin.Get_Value_As_Int; -- Set margin bottom Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_bottom")); Margin_Bottom := Spin.Get_Value_As_Int; -- Set margin left Spin := Gtk_Spin_Button (Builder.Get_Object ("spin_margin_left")); Margin_Left := Spin.Get_Value_As_Int; Dialog.Destroy; Export := True; else Dialog.Destroy; Export := False; end if; end Get_Export_Param; procedure Draw (This : Instance; Cr : Cairo.Cairo_Context) is use Gdk.Cairo; use Gdk.Color; use Gtk.Enums; use Gtk.Style_Context; use LSE.IO.Drawing_Area; use LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr; Context : constant Gtk_Style_Context := Get_Style_Context (This.Render_Area); Fg_Color : constant Gdk_Color := Parse (This.Presenter.Get_Foreground_Color); Bg_Color : Gdk_Color := Null_Color; begin This.Presenter.Set_Medium (To_Holder (Initialize (Cr))); Render_Background (Context, Cr, 0.0, 0.0, Gdouble (This.Render_Area.Get_Allocated_Width), Gdouble (This.Render_Area.Get_Allocated_Height)); -- Set foreground if This.Presenter.Get_Background_Color /= "" then Bg_Color := Parse (This.Presenter.Get_Background_Color); end if; Set_Source_Color (Cr, Fg_Color); -- Set background This.Render_Area.Modify_Bg (State_Normal, Bg_Color); if First_Run then This.Presenter.Set_Width (This.Render_Area.Get_Allocated_Width); This.Presenter.Set_Height (This.Render_Area.Get_Allocated_Height); This.Presenter.Develop; First_Run := False; end if; This.Presenter.Interpret; end Draw; procedure Size_Allocate (This : Instance) is begin This.Presenter.Set_Width (This.Render_Area.Get_Allocated_Width); This.Presenter.Set_Height (This.Render_Area.Get_Allocated_Height); This.Render; end Size_Allocate; end LSE.View.View;
with Ada.Characters.Handling; with Ada.Text_IO; use Ada.Text_IO; with GNATCOLL.Opt_Parse; with GNATCOLL.Strings; with GNATCOLL.VFS; with Langkit_Support.Text; with Libadalang.Analysis; with Libadalang.Common; with Libadalang.Helpers; with Libadalang.Iterators; with Put_Title; procedure Navigate is package LAL renames Libadalang.Analysis; package LALCO renames Libadalang.Common; package LALIT renames Libadalang.Iterators; package X renames GNATCOLL.Strings; type Enabled_Kinds_Type is array (LALCO.Ada_Node_Kind_Type) of Boolean; All_Kinds : constant Enabled_Kinds_Type := (others => True); function String_To_Kinds (List : String) return Enabled_Kinds_Type; procedure Process_File (Context : Libadalang.Helpers.App_Job_Context; Unit : LAL.Analysis_Unit); package App is new Libadalang.Helpers.App (Name => "navigate", Description => "Navigate between AST nodes (spec/body/...).", Process_Unit => Process_File); package Args is use GNATCOLL.Opt_Parse; package Kinds is new Parse_Option (App.Args.Parser, "-k", "--kinds", "Comma-separated list of AST node kind names, like" & " ""Ada_Subp_Body,Ada_Package_Decl"". This will filter the" & " nodes on which we navigate.", Enabled_Kinds_Type, Default_Val => All_Kinds, Convert => String_To_Kinds); end Args; function Short_Image (Node : LAL.Ada_Node'Class) return String is (Langkit_Support.Text.Image (Node.Short_Text_Image)); function To_Lower (S : String) return String renames Ada.Characters.Handling.To_Lower; function Is_Navigation_Disabled (N : LAL.Ada_Node) return Boolean; procedure Print_Navigation (Part_Name : String; Orig, Dest : LAL.Ada_Node'Class); function Basename (Filename : String) return String; -- Return the base name of the Filename path -------------- -- Basename -- -------------- function Basename (Filename : String) return String is use GNATCOLL.VFS; begin return +Create (+Filename).Base_Name; end Basename; ------------------ -- Process_File -- ------------------ procedure Process_File (Context : Libadalang.Helpers.App_Job_Context; Unit : LAL.Analysis_Unit) is pragma Unreferenced (Context); use GNATCOLL.VFS; At_Least_Once : Boolean := False; function Filter (N : LAL.Ada_Node) return Boolean is (Args.Kinds.Get (N.Kind) and then not Is_Navigation_Disabled (N)); begin Put_Title ('#', +Create (+Unit.Get_Filename).Base_Name); if Unit.Has_Diagnostics then for D of Unit.Diagnostics loop Put_Line (Unit.Format_GNU_Diagnostic (D)); end loop; New_Line; return; end if; for Node of LALIT.Find (Unit.Root, Filter'Access).Consume loop declare Processed_Something : Boolean := True; begin case Node.Kind is -- Bodies when LALCO.Ada_Body_Node => Print_Navigation ("Body previous part", Node, Node.As_Body_Node.P_Previous_Part); Print_Navigation ("Decl", Node, Node.As_Body_Node.P_Decl_Part); case Node.Kind is when LALCO.Ada_Package_Body_Stub => Print_Navigation ("Body", Node, Node.As_Package_Body_Stub.P_Body_Part_For_Decl); when others => null; end case; -- Packages when LALCO.Ada_Base_Type_Decl => Print_Navigation ("Type previous part", Node, Node.As_Base_Type_Decl.P_Previous_Part); case Node.Kind is when LALCO.Ada_Protected_Type_Decl => Print_Navigation ("Protected decl next part", Node, Node.As_Basic_Decl.P_Next_Part_For_Decl); Print_Navigation ("Protected decl body part", Node, Node.As_Basic_Decl.P_Body_Part_For_Decl); when others => -- Protected type decls don't have a type next part Print_Navigation ("Type next part", Node, Node.As_Base_Type_Decl.P_Next_Part); end case; when LALCO.Ada_Base_Package_Decl => Print_Navigation ("Body", Node, Node.As_Base_Package_Decl.P_Body_Part); when LALCO.Ada_Generic_Package_Decl => Print_Navigation ("Body", Node, Node.As_Generic_Package_Decl.P_Body_Part); -- Subprograms when LALCO.Ada_Basic_Subp_Decl => Print_Navigation ("Body", Node, Node.As_Basic_Subp_Decl.P_Body_Part); when LALCO.Ada_Generic_Subp_Decl => Print_Navigation ("Body", Node, Node.As_Generic_Subp_Decl.P_Body_Part); when others => Processed_Something := False; end case; At_Least_Once := At_Least_Once or else Processed_Something; exception when LALCO.Property_Error => Put_Line ("Error when processing " & Short_Image (Node)); At_Least_Once := True; end; end loop; if not At_Least_Once then Put_Line ("<no node to process>"); end if; New_Line; end Process_File; ---------------------- -- Print_Navigation -- ---------------------- procedure Print_Navigation (Part_Name : String; Orig, Dest : LAL.Ada_Node'Class) is begin if Dest.Is_Null then Put_Line (Short_Image (Orig) & " has no " & To_Lower (Part_Name)); else Put_Line (Part_Name & " of " & Short_Image (Orig) & " is " & Short_Image (Dest) & " [" & Basename (Dest.Unit.Get_Filename) & "]"); end if; end Print_Navigation; ------------------ -- Decode_Kinds -- ------------------ function String_To_Kinds (List : String) return Enabled_Kinds_Type is Enabled_Kinds : Enabled_Kinds_Type := (others => False); Names : constant X.XString_Array := X.To_XString (List).Split (","); begin for Name of Names loop if Name.Length /= 0 then begin declare Kind : constant LALCO.Ada_Node_Kind_Type := LALCO.Ada_Node_Kind_Type'Value (X.To_String (Name)); begin Enabled_Kinds (Kind) := True; end; exception when Constraint_Error => raise GNATCOLL.Opt_Parse.Opt_Parse_Error with "invalid kind name: " & X.To_String (Name); end; end if; end loop; return Enabled_Kinds; end String_To_Kinds; ---------------------------- -- Is_Navigation_Disabled -- ---------------------------- function Is_Navigation_Disabled (N : LAL.Ada_Node) return Boolean is function Lowercase_Name (Id : LAL.Identifier) return String is (To_Lower (Langkit_Support.Text.Image (Id.Text))); function Has_Disable_Navigation (Aspects : LAL.Aspect_Spec) return Boolean; ---------------------------- -- Has_Disable_Navigation -- ---------------------------- function Has_Disable_Navigation (Aspects : LAL.Aspect_Spec) return Boolean is use type LALCO.Ada_Node_Kind_Type; begin if Aspects.Is_Null then return False; end if; for Child of LAL.Ada_Node_Array'(Aspects.F_Aspect_Assocs.Children) loop declare Assoc : constant LAL.Aspect_Assoc := Child.As_Aspect_Assoc; begin if Assoc.F_Id.Kind = LALCO.Ada_Identifier then declare Id : constant LAL.Identifier := Assoc.F_Id.As_Identifier; begin return Lowercase_Name (Id) = "disable_navigation"; end; end if; end; end loop; return False; end Has_Disable_Navigation; begin case N.Kind is when LALCO.Ada_Base_Package_Decl => return Has_Disable_Navigation (N.As_Base_Package_Decl.F_Aspects); when others => return False; end case; end Is_Navigation_Disabled; begin App.Run; Put_Line ("Done."); end Navigate;
-- wsdl2aws SOAP Generator v2.4.0 -- -- AWS 3.3.0w - SOAP 1.5.0 -- This file was generated on Friday 15 May 2015 at 14:44:08 -- -- $ wsdl2aws gprslaves-nameserver.ads.wsdl -f -main gprslaves-server -- -timeouts 1 -cb -spec gprslaves.nameserver with AWS.Config.Set; pragma Elaborate_All (AWS.Config.Set); with AWS.Server; pragma Elaborate_All (AWS.Server); with AWS.Status; pragma Elaborate_All (AWS.Status); with AWS.Response; pragma Elaborate_All (AWS.Response); with SOAP.Dispatchers.Callback; pragma Elaborate_All (SOAP.Dispatchers.Callback); with Gprslaves.Nameserver_Service.CB; pragma Elaborate_All (Gprslaves.Nameserver_Service.CB); with Gprslaves.Nameserver_Service.Server; pragma Elaborate_All (Gprslaves.Nameserver_Service.Server); procedure Gprslaves.server is use AWS; function CB (Request : Status.Data) return Response.Data is R : Response.Data; begin return R; end CB; WS : AWS.Server.HTTP; Conf : Config.Object; Disp : Gprslaves.Nameserver_Service.CB.Handler; begin Config.Set.Server_Port (Conf, Gprslaves.Nameserver_Service.Server.Port); Disp := SOAP.Dispatchers.Callback.Create (CB'Unrestricted_Access, Gprslaves.Nameserver_Service.CB.SOAP_CB'Access); AWS.Server.Start (WS, Disp, Conf); AWS.Server.Wait (AWS.Server.Forever); end Gprslaves.server;
pragma License (Unrestricted); private with Ada.Finalization; private with System.Storage_Barriers; private with System.Synchronous_Objects; package Ada.Synchronous_Task_Control is pragma Preelaborate; type Suspension_Object is limited private; procedure Set_True (S : in out Suspension_Object); procedure Set_False (S : in out Suspension_Object); function Current_State (S : Suspension_Object) return Boolean; -- modified procedure Suspend_Until_True ( S : in out Suspension_Object; Multi : Boolean := False); -- additional pragma Inline (Current_State); private type Suspension_Object is limited new Finalization.Limited_Controlled with record Object : System.Synchronous_Objects.Event; Waiting : aliased System.Storage_Barriers.Flag; -- for CXDA002 end record; overriding procedure Initialize (Object : in out Suspension_Object); overriding procedure Finalize (Object : in out Suspension_Object); end Ada.Synchronous_Task_Control;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 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 Interfaces.C.Strings; with Interfaces.C; with System; with Ada.Strings.Unbounded; package EGL is pragma Preelaborate; package C renames Interfaces.C; type Bool is new Boolean; subtype Int is C.int; subtype Enum is C.unsigned; subtype Attrib is C.ptrdiff_t; type ID_Type is private; function None return Int; function None return Attrib; type Enum_Array is array (Natural range <>) of Enum with Convention => C; type Attribute_Array is array (Natural range <>) of Attrib with Convention => C; type Int_Array is array (Natural range <>) of Int with Convention => C; package SU renames Ada.Strings.Unbounded; type String_List is array (Positive range <>) of SU.Unbounded_String; function Has_Extension (Extensions : String_List; Name : String) return Boolean; -- Return True if the extension with the given name can be found in -- the list of extensions, False otherwise procedure Check_Extension (Extensions : String_List; Name : String); -- Raise Feature_Not_Supported if the extension with the given -- name cannot be found in the list of extensions Feature_Not_Supported : exception; -- Raised when a function that is not available is called type Native_Window_Ptr is private; type Native_Display_Ptr is private; private type Native_Window is limited null record; type Native_Window_Ptr is access all Native_Window with Convention => C; type Native_Display is limited null record; type Native_Display_Ptr is access all Native_Display with Convention => C; function None return Int is (16#3038#); function None return Attrib is (16#3038#); type Void_Ptr is new System.Address; type ID_Type is new Void_Ptr; type ID_Array is array (Natural range <>) of ID_Type with Convention => C; for Bool use (False => 0, True => 1); for Bool'Size use C.unsigned'Size; function Trim (Value : C.Strings.chars_ptr) return String; function Extensions (Value : C.Strings.chars_ptr) return String_List; type Display_Query_Param is (Vendor, Version, Extensions, Client_APIs); for Display_Query_Param use (Vendor => 16#3053#, Version => 16#3054#, Extensions => 16#3055#, Client_APIs => 16#308D#); for Display_Query_Param'Size use Int'Size; type Context_Query_Param is (Render_Buffer); for Context_Query_Param use (Render_Buffer => 16#3086#); for Context_Query_Param'Size use Int'Size; type Surface_Query_Param is (Height, Width, Swap_Behavior); for Surface_Query_Param use (Height => 16#3056#, Width => 16#3057#, Swap_Behavior => 16#3093#); for Surface_Query_Param'Size use Int'Size; type Device_Query_Param is (Extensions, DRM_Device_File); for Device_Query_Param use (Extensions => 16#3055#, DRM_Device_File => 16#3233#); for Device_Query_Param'Size use Int'Size; end EGL;
with VisitablePackage, EnvironmentPackage, VisitFailurePackage; use VisitablePackage, EnvironmentPackage, VisitFailurePackage; package body NoStrategy is ---------------------------------------------------------------------------- -- Object implementation ---------------------------------------------------------------------------- overriding function toString(n: No) return String is begin return "Not()"; end; ---------------------------------------------------------------------------- -- Strategy implementation ---------------------------------------------------------------------------- overriding function visitLight(str:access No; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is optr : ObjectPtr; exceptionRaised : Boolean := true; begin optr := visitLight(StrategyPtr(str.arguments(ARG)), any, i); exceptionRaised := false; raise VisitFailure; exception when VisitFailure => if exceptionRaised then return any; else raise; -- exception propagated end if; end; overriding function visit(str: access No; i: access Introspector'Class) return Integer is subject : ObjectPtr := getSubject(str.env.all); status : Integer := visit( StrategyPtr( str.arguments(ARG)), i); begin setSubject(str.env.all, subject); if status /= EnvironmentPackage.SUCCESS then return EnvironmentPackage.SUCCESS; else return EnvironmentPackage.FAILURE; end if; end; ---------------------------------------------------------------------------- procedure makeNo(n : in out No; v : StrategyPtr) is begin initSubterm(n, v); end; function newNo(v : StrategyPtr) return StrategyPtr is ret: StrategyPtr := new No; begin makeNo(No(ret.all), v); return ret; end; ---------------------------------------------------------------------------- end NoStrategy;
------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This file provides declarations for the user LEDs on the TMS570LS31 -- board from Texas Instruments. with TMS570.GPIO; use TMS570.GPIO; with System; package TMS570.LEDs is pragma Elaborate_Body; type User_LED is (Right_Top, Right, Left_Top, Bottom, Right_Bottom, Left, Left_Bottom, Top); for User_LED use (Right_Top => GPIO_Pin_0, Right => GPIO_Pin_5, Left_Top => GPIO_Pin_17, Bottom => GPIO_Pin_18, Right_Bottom => GPIO_Pin_25, Left => GPIO_Pin_27, Left_Bottom => GPIO_Pin_29, Top => GPIO_Pin_31); -- As a result of the representation clause, avoid iterating directly over -- the type since that will require an implicit lookup in the generated -- code of the loop. Such usage seems unlikely so this direct -- representation is reasonable, and efficient. for User_LED'Size use Word'Size; -- we convert the LED values to Word values in order to write them to -- the registers, so the size must be the same procedure On (This : User_LED); pragma Inline (On); procedure Off (This : User_LED); pragma Inline (Off); private HET_Port : GPIO_Register; pragma Volatile (HET_Port); for HET_Port'Address use System'To_Address (16#FFF7_B84C#); -- HET Port 1 pragma Import (Ada, HET_Port); end TMS570.LEDs;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_gpio.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief Header file of GPIO HAL module. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides definitions for the GPIO ports on the STM32F4 (ARM -- Cortex M4F) microcontrollers from ST Microelectronics. private with STM32_SVD.GPIO; with STM32.EXTI; with HAL.GPIO; package STM32.GPIO is type GPIO_Port is limited private; type GPIO_Pin is (Pin_0, Pin_1, Pin_2, Pin_3, Pin_4, Pin_5, Pin_6, Pin_7, Pin_8, Pin_9, Pin_10, Pin_11, Pin_12, Pin_13, Pin_14, Pin_15); for GPIO_Pin use (Pin_0 => 16#0001#, Pin_1 => 16#0002#, Pin_2 => 16#0004#, Pin_3 => 16#0008#, Pin_4 => 16#0010#, Pin_5 => 16#0020#, Pin_6 => 16#0040#, Pin_7 => 16#0080#, Pin_8 => 16#0100#, Pin_9 => 16#0200#, Pin_10 => 16#0400#, Pin_11 => 16#0800#, Pin_12 => 16#1000#, Pin_13 => 16#2000#, Pin_14 => 16#4000#, Pin_15 => 16#8000#); for GPIO_Pin'Size use 16; -- for compatibility with hardware registers type GPIO_Pins is array (Positive range <>) of GPIO_Pin; -- Note that, in addition to aggregates, the language-defined catenation -- operator "&" is available for types GPIO_Pin and GPIO_Pins, allowing one -- to construct GPIO_Pins values conveniently All_Pins : constant GPIO_Pins := (Pin_0, Pin_1, Pin_2, Pin_3, Pin_4, Pin_5, Pin_6, Pin_7, Pin_8, Pin_9, Pin_10, Pin_11, Pin_12, Pin_13, Pin_14, Pin_15); type Pin_IO_Modes is (Mode_In, Mode_Out, Mode_AF, Mode_Analog) with Size => 2; for Pin_IO_Modes use (Mode_In => 0, Mode_Out => 1, Mode_AF => 2, Mode_Analog => 3); type Pin_Output_Types is (Push_Pull, Open_Drain) with Size => 1; for Pin_Output_Types use (Push_Pull => 0, Open_Drain => 1); type Pin_Output_Speeds is (Speed_2MHz, Speed_25MHz, Speed_50MHz, Speed_100MHz) with Size => 2; for Pin_Output_Speeds use (Speed_2MHz => 0, -- low Speed_25MHz => 1, -- medium Speed_50MHz => 2, -- high Speed_100MHz => 3); -- very high Speed_Low : Pin_Output_Speeds renames Speed_2MHz; Speed_Medium : Pin_Output_Speeds renames Speed_25MHz; Speed_High : Pin_Output_Speeds renames Speed_50MHz; Speed_Very_High : Pin_Output_Speeds renames Speed_100MHz; type Internal_Pin_Resistors is (Floating, Pull_Up, Pull_Down) with Size => 2; for Internal_Pin_Resistors use (Floating => 0, Pull_Up => 1, Pull_Down => 2); type GPIO_Port_Configuration is record Mode : Pin_IO_Modes; Output_Type : Pin_Output_Types; Speed : Pin_Output_Speeds; Resistors : Internal_Pin_Resistors; end record; type GPIO_Point is new HAL.GPIO.GPIO_Point with record Periph : access GPIO_Port; -- Port should be a not null access, but this raises an exception -- during elaboration. Pin : GPIO_Pin; end record; overriding function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode; overriding function Set_Mode (This : in out GPIO_Point; Mode : HAL.GPIO.GPIO_Config_Mode) return Boolean; overriding function Pull_Resistor (This : GPIO_Point) return HAL.GPIO.GPIO_Pull_Resistor; overriding function Set_Pull_Resistor (This : in out GPIO_Point; Pull : HAL.GPIO.GPIO_Pull_Resistor) return Boolean; overriding function Set (This : GPIO_Point) return Boolean with Inline; -- Returns True if the bit specified by This.Pin is set (not zero) in the -- input data register of This.Port.all; returns False otherwise. overriding procedure Set (This : in out GPIO_Point) with Inline; -- For This.Port.all, sets the output data register bit specified by -- This.Pin to one. Other pins are unaffected. overriding procedure Clear (This : in out GPIO_Point) with Inline; -- For This.Port.all, sets the output data register bit specified by -- This.Pin to zero. Other pins are unaffected. overriding procedure Toggle (This : in out GPIO_Point) with Inline; -- For This.Port.all, negates the output data register bit specified by -- This.Pin (one becomes zero and vice versa). Other pins are unaffected. procedure Lock (This : GPIO_Point) with Pre => not Locked (This), Post => Locked (This); -- For the given GPIO port, locks the current configuration of Pin until -- the MCU is reset. function Locked (This : GPIO_Point) return Boolean with Inline; procedure Configure_IO (This : GPIO_Point; Config : GPIO_Port_Configuration); -- For Point.Pin on the Point.Port.all, configures the -- characteristics specified by Config function Interrupt_Line_Number (This : GPIO_Point) return EXTI.External_Line_Number; -- Returns the external interrupt line number that corresponds to the -- GPIO point. procedure Configure_Trigger (This : GPIO_Point; Trigger : EXTI.External_Triggers); -- For Point.Pin on Point.Port.all, connects the external line and enables -- the external Trigger. Enables the SYSCFG clock. procedure Configure_Alternate_Function (This : GPIO_Point; AF : GPIO_Alternate_Function); -- For Point.Pin on Point.Port.all, sets the alternate function -- specified by AF type GPIO_Points is array (Positive range <>) of GPIO_Point; function Any_Set (Pins : GPIO_Points) return Boolean with Inline; -- Returns True if any one of the bits specified by Pins is set (not zero) -- in the Port input data register; returns False otherwise. function Set (Pins : GPIO_Points) return Boolean renames Any_Set; -- Defined for readability when only one pin is specified in GPIO_Pins function All_Set (Pins : GPIO_Points) return Boolean with Inline; -- Returns True iff all of the bits specified by Pins are set (not zero) in -- the Port input data register; returns False otherwise. procedure Set (Pins : in out GPIO_Points) with Inline; -- For the given GPIO port, sets all of the output data register bits -- specified by Pins to one. Other pins are unaffected. procedure Clear (Pins : in out GPIO_Points) with Inline; -- For the given GPIO port, sets of all of the output data register bits -- specified by Pins to zero. Other pins are unaffected. procedure Toggle (Points : in out GPIO_Points) with Inline; -- For the given GPIO ports, negates all of the output data register bis -- specified by Pins (ones become zeros and vice versa). Other pins are -- unaffected. procedure Lock (Points : GPIO_Points); -- For the given GPIO port, locks the current configuration of Pin until -- the MCU is reset. procedure Configure_IO (Points : GPIO_Points; Config : GPIO_Port_Configuration); -- For Point.Pin on the Point.Port.all, configures the -- characteristics specified by Config procedure Configure_Trigger (Points : GPIO_Points; Trigger : EXTI.External_Triggers); -- For Point.Pin on Point.Port.all, configures the -- characteristics specified by Trigger procedure Configure_Alternate_Function (Points : GPIO_Points; AF : GPIO_Alternate_Function); -- For Point.Pin on Point.Port.all, sets the alternate function -- specified by AF private type GPIO_Port is new STM32_SVD.GPIO.GPIO_Peripheral; LCCK : constant UInt32 := 16#0001_0000#; -- As per the Reference Manual (RM0090; Doc ID 018909 Rev 6) pg 282, -- this is the "Lock Key" used to control the locking of port/pin -- configurations. It is bit 16 in the lock register (LCKR) of any -- given port, thus the first bit of the upper 16 bits of the word. end STM32.GPIO;
----------------------------------------------------------------------- -- awa-storages-tests -- Unit tests for storages module -- Copyright (C) 2018, 2019, 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.Strings.Unbounded; with Util.Test_Caller; with ASF.Tests; with AWA.Tests.Helpers.Users; with Servlet.requests.Mockup; with Servlet.Responses.Mockup; package body AWA.Storages.Tests is package Caller is new Util.Test_Caller (Test, "Storages.Beans"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Storages.Beans.Create", Test_Create_Document'Access); Caller.Add_Test (Suite, "Test AWA.Storages.Servlets (missing)", Test_Missing_Document'Access); end Add_Tests; -- ------------------------------ -- Get some access on the wiki as anonymous users. -- ------------------------------ procedure Verify_Anonymous (T : in out Test; Page : in String; Title : in String) is pragma Unreferenced (Title); Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/documents.html", "storage-anonymous-list.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list recent page is invalid"); end Verify_Anonymous; -- ------------------------------ -- Verify that the wiki lists contain the given page. -- ------------------------------ procedure Verify_List_Contains (T : in out Test; Page : in String) is Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/documents.html", "storage-list.html"); ASF.Tests.Assert_Contains (T, "Documents of the workspace", Reply, "List of documents is invalid"); end Verify_List_Contains; -- ------------------------------ -- Test access to the blog as anonymous user. -- ------------------------------ procedure Test_Anonymous_Access (T : in out Test) is begin T.Verify_Anonymous ("", ""); end Test_Anonymous_Access; -- ------------------------------ -- Test creation of document by simulating web requests. -- ------------------------------ procedure Test_Create_Document (T : in out Test) is Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin AWA.Tests.Helpers.Users.Login ("test-storage@test.com", Request); Request.Set_Parameter ("folder-name", "Test Folder Name"); Request.Set_Parameter ("storage-folder-create-form", "1"); Request.Set_Parameter ("storage-folder-create-button", "1"); ASF.Tests.Do_Post (Request, Reply, "/storages/forms/folder-create.html", "folder-create-form.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after folder creation"); ASF.Tests.Do_Get (Request, Reply, "/storages/documents.html", "storage-list.html"); ASF.Tests.Assert_Contains (T, "Documents of the workspace", Reply, "List of documents is invalid (title)"); ASF.Tests.Assert_Contains (T, "Test Folder Name", Reply, "List of documents is invalid (content)"); end Test_Create_Document; -- ------------------------------ -- Test getting a document which does not exist. -- ------------------------------ procedure Test_Missing_Document (T : in out Test) is Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/files/12345345/view/missing.pdf", "storage-file-missing.html"); ASF.Tests.Assert_Matches (T, ".title.Page not found./title.", Reply, "Page for a missing document is invalid", Servlet.Responses.SC_NOT_FOUND); end Test_Missing_Document; end AWA.Storages.Tests;
with Ada.Text_IO; use Ada.Text_IO; package Utils is subtype Long_Long_Natural is Long_Long_Integer range 0 .. Long_Long_Integer'Last; -- The parameter "wcem=8" indicates that we want to open a file in -- UTF-8 format (which can therefore contain accents) DEFAULT_FILE_FORM_VALUE : constant String := "wcem=8"; -- Default file name DEFAULT_FILENAME : constant String := "input.txt"; -- Open a file. By default, if file does not exist, it create it. -- @param File The file container -- @param Mode Mode to open the file -- @param Path Location of the file -- @param File_Form "Form" to pass to the file -- @param Auto True if auto create the file if it does not exist, false otherwise procedure Open_File (File : in out File_Type; Mode : File_Mode; Path : String; File_Form : String := DEFAULT_FILE_FORM_VALUE; Auto : Boolean := False); -- Open the file at the default location. -- Raise an error if the file cannot be found / open. -- @param File The openned file will be inside this param. procedure Get_File (File : in out File_Type); -- Check if the file is opened before attempt to close it (to prevent raise of error). -- @param File The file that shall be closed. procedure Close_If_Open (File : in out File_Type); end Utils;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . I N D E F I N I T E _ H O L D E R S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2013-2016, 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/>. -- ------------------------------------------------------------------------------ -- Note: special attention must be paid to the case of simultaneous access -- to internal shared objects and elements by different tasks. The Reference -- counter of internal shared object is the only component protected using -- atomic operations; other components and elements can be modified only when -- reference counter is equal to one (so there are no other references to this -- internal shared object and element). with Ada.Unchecked_Deallocation; package body Ada.Containers.Indefinite_Holders is procedure Free is new Ada.Unchecked_Deallocation (Element_Type, Element_Access); procedure Detach (Container : Holder); -- Detach data from shared copy if necessary. This is necessary to prepare -- container to be modified. --------- -- "=" -- --------- function "=" (Left, Right : Holder) return Boolean is begin if Left.Reference = Right.Reference then -- Covers both null and not null but the same shared object cases return True; elsif Left.Reference /= null and Right.Reference /= null then return Left.Reference.Element.all = Right.Reference.Element.all; else return False; end if; end "="; ------------ -- Adjust -- ------------ overriding procedure Adjust (Container : in out Holder) is begin if Container.Reference /= null then if Container.Busy = 0 then -- Container is not locked, reuse existing internal shared object Reference (Container.Reference); else -- Otherwise, create copy of both internal shared object and -- element. Container.Reference := new Shared_Holder' (Counter => <>, Element => new Element_Type'(Container.Reference.Element.all)); end if; end if; Container.Busy := 0; end Adjust; overriding procedure Adjust (Control : in out Reference_Control_Type) is begin if Control.Container /= null then Reference (Control.Container.Reference); Control.Container.Busy := Control.Container.Busy + 1; end if; end Adjust; ------------ -- Assign -- ------------ procedure Assign (Target : in out Holder; Source : Holder) is begin if Target.Busy /= 0 then raise Program_Error with "attempt to tamper with elements"; end if; if Target.Reference /= Source.Reference then if Target.Reference /= null then Unreference (Target.Reference); end if; Target.Reference := Source.Reference; if Source.Reference /= null then Reference (Target.Reference); end if; end if; end Assign; ----------- -- Clear -- ----------- procedure Clear (Container : in out Holder) is begin if Container.Busy /= 0 then raise Program_Error with "attempt to tamper with elements"; end if; if Container.Reference /= null then Unreference (Container.Reference); Container.Reference := null; end if; end Clear; ------------------------ -- Constant_Reference -- ------------------------ function Constant_Reference (Container : aliased Holder) return Constant_Reference_Type is begin if Container.Reference = null then raise Constraint_Error with "container is empty"; end if; Detach (Container); declare Ref : constant Constant_Reference_Type := (Element => Container.Reference.Element.all'Access, Control => (Controlled with Container'Unrestricted_Access)); begin Reference (Ref.Control.Container.Reference); Ref.Control.Container.Busy := Ref.Control.Container.Busy + 1; return Ref; end; end Constant_Reference; ---------- -- Copy -- ---------- function Copy (Source : Holder) return Holder is begin if Source.Reference = null then return (Controlled with null, 0); elsif Source.Busy = 0 then -- Container is not locked, reuse internal shared object Reference (Source.Reference); return (Controlled with Source.Reference, 0); else -- Otherwise, create copy of both internal shared object and element return (Controlled with new Shared_Holder' (Counter => <>, Element => new Element_Type'(Source.Reference.Element.all)), 0); end if; end Copy; ------------ -- Detach -- ------------ procedure Detach (Container : Holder) is begin if Container.Busy = 0 and then not System.Atomic_Counters.Is_One (Container.Reference.Counter) then -- Container is not locked and internal shared object is used by -- other container, create copy of both internal shared object and -- element. declare Old : constant Shared_Holder_Access := Container.Reference; begin Container'Unrestricted_Access.Reference := new Shared_Holder' (Counter => <>, Element => new Element_Type'(Container.Reference.Element.all)); Unreference (Old); end; end if; end Detach; ------------- -- Element -- ------------- function Element (Container : Holder) return Element_Type is begin if Container.Reference = null then raise Constraint_Error with "container is empty"; else return Container.Reference.Element.all; end if; end Element; -------------- -- Finalize -- -------------- overriding procedure Finalize (Container : in out Holder) is begin if Container.Busy /= 0 then raise Program_Error with "attempt to tamper with elements"; end if; if Container.Reference /= null then Unreference (Container.Reference); Container.Reference := null; end if; end Finalize; overriding procedure Finalize (Control : in out Reference_Control_Type) is begin if Control.Container /= null then Unreference (Control.Container.Reference); Control.Container.Busy := Control.Container.Busy - 1; Control.Container := null; end if; end Finalize; -------------- -- Is_Empty -- -------------- function Is_Empty (Container : Holder) return Boolean is begin return Container.Reference = null; end Is_Empty; ---------- -- Move -- ---------- procedure Move (Target : in out Holder; Source : in out Holder) is begin if Target.Busy /= 0 then raise Program_Error with "attempt to tamper with elements"; end if; if Source.Busy /= 0 then raise Program_Error with "attempt to tamper with elements"; end if; if Target.Reference /= Source.Reference then if Target.Reference /= null then Unreference (Target.Reference); end if; Target.Reference := Source.Reference; Source.Reference := null; end if; end Move; ------------------- -- Query_Element -- ------------------- procedure Query_Element (Container : Holder; Process : not null access procedure (Element : Element_Type)) is B : Natural renames Container'Unrestricted_Access.Busy; begin if Container.Reference = null then raise Constraint_Error with "container is empty"; end if; Detach (Container); B := B + 1; begin Process (Container.Reference.Element.all); exception when others => B := B - 1; raise; end; B := B - 1; end Query_Element; ---------- -- Read -- ---------- procedure Read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Container : out Holder) is begin Clear (Container); if not Boolean'Input (Stream) then Container.Reference := new Shared_Holder' (Counter => <>, Element => new Element_Type'(Element_Type'Input (Stream))); end if; 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; 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; --------------- -- Reference -- --------------- procedure Reference (Item : not null Shared_Holder_Access) is begin System.Atomic_Counters.Increment (Item.Counter); end Reference; function Reference (Container : aliased in out Holder) return Reference_Type is begin if Container.Reference = null then raise Constraint_Error with "container is empty"; end if; Detach (Container); declare Ref : constant Reference_Type := (Element => Container.Reference.Element.all'Access, Control => (Controlled with Container'Unrestricted_Access)); begin Reference (Ref.Control.Container.Reference); Ref.Control.Container.Busy := Ref.Control.Container.Busy + 1; return Ref; end; end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Container : in out Holder; New_Item : Element_Type) is -- Element allocator may need an accessibility check in case actual type -- is class-wide or has access discriminants (RM 4.8(10.1) and -- AI12-0035). pragma Unsuppress (Accessibility_Check); begin if Container.Busy /= 0 then raise Program_Error with "attempt to tamper with elements"; end if; if Container.Reference = null then -- Holder is empty, allocate new Shared_Holder. Container.Reference := new Shared_Holder' (Counter => <>, Element => new Element_Type'(New_Item)); elsif System.Atomic_Counters.Is_One (Container.Reference.Counter) then -- Shared_Holder can be reused. Free (Container.Reference.Element); Container.Reference.Element := new Element_Type'(New_Item); else Unreference (Container.Reference); Container.Reference := new Shared_Holder' (Counter => <>, Element => new Element_Type'(New_Item)); end if; end Replace_Element; --------------- -- To_Holder -- --------------- function To_Holder (New_Item : Element_Type) return Holder is -- The element allocator may need an accessibility check in the case the -- actual type is class-wide or has access discriminants (RM 4.8(10.1) -- and AI12-0035). pragma Unsuppress (Accessibility_Check); begin return (Controlled with new Shared_Holder' (Counter => <>, Element => new Element_Type'(New_Item)), 0); end To_Holder; ----------------- -- Unreference -- ----------------- procedure Unreference (Item : not null Shared_Holder_Access) is procedure Free is new Ada.Unchecked_Deallocation (Shared_Holder, Shared_Holder_Access); Aux : Shared_Holder_Access := Item; begin if System.Atomic_Counters.Decrement (Aux.Counter) then Free (Aux.Element); Free (Aux); end if; end Unreference; -------------------- -- Update_Element -- -------------------- procedure Update_Element (Container : in out Holder; Process : not null access procedure (Element : in out Element_Type)) is B : Natural renames Container.Busy; begin if Container.Reference = null then raise Constraint_Error with "container is empty"; end if; Detach (Container); B := B + 1; begin Process (Container.Reference.Element.all); exception when others => B := B - 1; raise; end; B := B - 1; end Update_Element; ----------- -- Write -- ----------- procedure Write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Container : Holder) is begin Boolean'Output (Stream, Container.Reference = null); if Container.Reference /= null then Element_Type'Output (Stream, Container.Reference.Element.all); end if; 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.Indefinite_Holders;
Pragma Ada_2012; Pragma Wide_Character_Encoding( UTF8 ); with Risi_Script.Types.Identifier.Scope_Package; Package Risi_Script.Types.Identifier.Scope is use Risi_Script.Types.Identifier.Scope_Package; Type Scope is new Vector with null record; Function "+"( Right : Scope ) Return Vector; Function "+"( Right : Vector ) Return Scope; Function Image( Input : Scope ) return String; Function Value( Input : String ) return Scope with Pre => Input(Input'First) /= '.' and Input(Input'Last) /= '.'; ----------------- -- Constants -- ----------------- Global : Constant Scope; Private Function "+"( Right : Scope ) Return Vector is ( Vector(Right) ); Function "+"( Right : Vector ) Return Scope is ( Right with null record ); Global : Constant Scope:= +Empty_Vector; End Risi_Script.Types.Identifier.Scope;
---------------------------------------------------------------------------- -- Symbolic Expressions (symexpr) -- -- Copyright (C) 2012, Riccardo Bernardini -- -- This file is part of symexpr. -- -- symexpr is free software: you can redistribute it and/or modify -- it under the terms of the Lesser GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- symexpr is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the Lesser GNU General Public License -- along with gclp. If not, see <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- with Ada.Strings.Fixed; package body Test_Report is function Pad_To (What : String; To : Positive) return String is use Ada.Strings.Fixed; begin if What'Length < To then return (To - What'Length) * " " & What; else return What; end if; end Pad_To; procedure Be_Verbose (This : in out Reporter_Type; Flag : in Boolean := True) is begin This.Verbose := Flag; end Be_Verbose; procedure Set_Tab (This : in out Reporter_Type; Tab : in Positive) is begin This.Tab := Tab; end Set_Tab; procedure Close_Suite (This : in out Reporter_Type) is Suite_Name : constant String := To_String (This.Name); begin if (This.N_Tests = 0) then return; end if; if (Suite_Name /= "") then declare Buf : constant String := " Test suite '" & Suite_Name & "'"; begin if (This.Tab <= Buf'Length) then This.Tab := Buf'Length + 1; end if; if This.Tab > Buf'Length then Put (File => This.Output_To.all, Item => Buf & To_String ((This.Tab - Buf'Length) * '.')); else Put (File => This.Output_To.all, Item => Buf & "..."); This.Tab := Buf'Length + 3; end if; Put (File => This.Output_To.all, Item => " passed "); end; else Put (File => This.Output_To.all, Item => "Passed "); end if; declare Plural : String := "s"; begin if (This.N_Test_Ok = 1) then Plural := " "; end if; Put (File => This.Output_To.all, Item => Pad_To (Positive'Image (This.N_Test_OK), 3) & " test" & Plural & " out of " & Pad_To (Natural'Image (This.N_Tests), 3) & ": "); end; if (This.N_Tests = This.N_Test_OK) then This.N_Suite_OK := This.N_Suite_OK + 1; Put_Line (File => This.Output_To.all, Item => "SUCCESS"); else Put (File => This.Output_To.all, Item => "FAILURE"); Put (" "); declare use Boolean_Lists; Position : Cursor; begin Position := This.Suite_Results.First; while Position /= No_Element loop if Element (Position) then Put ("+"); else Put ("-"); end if; Next (Position); end loop; end; This.Status := Ada.Command_Line.Failure; end if; This.N_Tests := 0; This.N_Test_OK := 0; This.N_Suites := This.N_Suites + 1; end Close_Suite; procedure Final (This : in out Reporter_Type; Set_Status : in Boolean := True) is function Plural(X : Natural) return String is begin if (X = 1) then return ""; else return "s"; end if; end Plural; begin if (This.N_Suites = 0 and This.N_Tests = 0) then return; end if; -- Put_Line ("XXX" & Integer'Image (This.N_Tests)); if (This.N_Tests > 0) then Close_Suite(This); end if; if (This.N_Suites > 1) then New_Line (File => This.Output_To.all); Put (File => This.Output_To.all, Item => "Passed " & Pad_To (Integer'Image (This.N_Suite_OK), 3) & " test suite" & Plural (This.N_Suite_OK) & " out of " & Pad_To (Integer'Image (This.N_Suites), 3) & ": "); if (This.N_Suites = This.N_Suite_OK) then Put_Line(File => This.Output_To.all, Item => "SUCCESS"); else Put_Line(File => This.Output_To.all, Item => "FAILURE"); end if; end if; if (Set_Status) then Ada.Command_Line.Set_Exit_Status(This.Status); end if; end Final; procedure New_Suite (This : in out Reporter_Type; Name : in String := "") is begin if (This.Verbose) then Put_line (This.Output_To.all, "New test suite " & Name); end if; -- Put_Line ("YYY" & Integer'Image (This.N_Tests)); if (This.N_Tests /= 0) then Close_Suite(This); end if; This.Name := To_Unbounded_String (Name); This.Suite_Results.Clear; end New_Suite; procedure Success (This : in out Reporter_Type) is begin New_Result (This, True); end Success; procedure Failure (This : in out Reporter_Type) is begin New_Result (This, False); end Failure; procedure New_Result (This : in out Reporter_Type; Ok : in Boolean) is begin if (This.Verbose) then if (Ok) then Put_line (This.Output_To.all, "Success"); else Put_line (This.Output_To.all, "FAILURE"); end if; end if; This.N_Tests := This.N_Tests + 1; if (Ok) then This.N_Test_OK := This.N_Test_OK + 1; end if; This.Suite_Results.Append (OK); end New_Result; procedure Do_Suite (This : in out Reporter_Type; Cases : in Test_Case_Array; Name : in String := "") is begin New_Suite(This, Name); for I in Cases'Range loop if (This.Verbose) then Put (File => This.Output_To.all, Item => "Test # " & Positive'Image(I) & " "); end if; New_Result(This, Check(Cases(I))); end loop; end Do_Suite; procedure Set_Output (This : in out Reporter_Type; File : in File_Access) is begin This.Output_To := File; end Set_Output; end Test_Report; -- -- function "and" (X, Y : Ada.Command_Line.Exit_Status) -- -- return Ada.Command_Line.Exit_Status is -- -- begin -- -- if (X = Ada.Command_Line.Success) then -- -- return Y; -- -- else -- -- return Ada.Command_Line.Failure; -- -- end if; -- -- end "and"; -- -- procedure Do_Report (This : in out Reporter_Type; -- Num_Trials : in Positive; -- Num_Success : in Natural; -- Name : in String := ""; -- Set_Status : in Boolean := True) -- is -- -- begin -- This.N_Suites := This.N_Suites + 1; -- -- if (Name /= "") then -- Put ("Test " & Name & ": passed "); -- else -- Put ("Passed "); -- end if; -- -- Put (Positive'Image(Num_Success) -- & " tests out of " -- & Natural'Image(Num_Trials) -- & ": "); -- -- if (Num_Success = Num_Trials) then -- This.N_Suite_OK := This.N_Suite_OK + 1; -- Put_Line ("SUCCESS"); -- else -- Put_Line ("FAILURE"); -- This.Status := Ada.Command_Line.Failure; -- end if; -- -- if (Set_Status) then -- Ada.Command_Line.Set_Exit_Status(This.Status); -- end if; -- end Do_Report;
-- { dg-excess-errors "no code generated" } generic type Id_T is private; type Data_T is private; package Varsize_Return_Pkg2 is type T is private; function Get (X : T) return Data_T; private type T is null record; end Varsize_Return_Pkg2;
with Ada.Containers.Ordered_Maps; with EU_Projects.Nodes; package EU_Projects.Node_Tables is type Node_Table is tagged private with Constant_Indexing => Element; type Table_Ref (D : access Node_Table) is tagged limited null record with Implicit_Dereference => D; function Contains (T : Node_Table; ID : Nodes.Node_Label) return Boolean; function Element (T : Node_Table; ID : Nodes.Node_Label) return Nodes.Node_Access with Pre => T.Contains (ID); procedure Insert (T : in out Node_Table; ID : Nodes.Node_Label; Item : Nodes.Node_Access) with Pre => not T.Contains (ID), Post => T.Contains (ID); function Labels_Of (T : Node_Table; Class : Nodes.Node_Class) return Nodes.Node_Label_Lists.Vector; procedure Dump (T : Node_Table); Duplicated_Label : exception; private use type Nodes.Node_Label; use type Nodes.Node_Access; package Node_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Nodes.Node_Label, Element_Type => Nodes.Node_Access); type Node_Table is tagged record Table : Node_Maps.Map; end record; function Contains (T : Node_Table; ID : Nodes.Node_Label) return Boolean is (T.Table.Contains (ID)); function Element (T : Node_Table; ID : Nodes.Node_Label) return Nodes.Node_Access is (T.Table.Element (ID)); end EU_Projects.Node_Tables;
--- tools/configure/configure-tests-postgresql.adb.orig 2011-12-27 08:20:56 UTC +++ tools/configure/configure-tests-postgresql.adb @@ -187,7 +187,7 @@ package body Configure.Tests.PostgreSQL (PostgreSQL_Library_Options, +"""-L" & Self.Switches.Libdir - & """, ""-lpq"""); + & """, ""-lpq"", ""-Wl,-rpath,@PREFIX@/lib"""); Self.Report_Status ("yes (command line)"); @@ -197,7 +197,7 @@ package body Configure.Tests.PostgreSQL elsif Has_Pg_Config then Self.Report_Status ("yes (pg_config)"); Substitutions.Insert - (PostgreSQL_Library_Options, +"""-L" & Pg_Libdir & """, ""-lpq"""); + (PostgreSQL_Library_Options, +"""-L" & Pg_Libdir & """, ""-lpq"", ""-Wl,-rpath,@PREFIX@/lib"""); else Self.Report_Status ("no (pg_config not found)");
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. with Ada.Text_IO; with Ada.Direct_IO; with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package; with Latin_Utils.Dictionary_Package; use Latin_Utils.Dictionary_Package; package Support_Utils.Word_Support_Package is Followed_By_Period, Capitalized, All_Caps : Boolean := False; type Dictionary_Stem is record Stem : Stem_Type := Null_Stem_Type; Part : Part_Entry := Null_Part_Entry; Key : Stem_Key_Type := 0; MNPC : Dict_IO.Count := Null_MNPC; end record; package Stem_Io is new Ada.Direct_IO (Dictionary_Stem); package Count_Io is new Ada.Text_IO.Integer_IO (Stem_Io.Count); subtype Dictionary_File_Kind is Dictionary_Kind range General .. Local; Default_Dictionary_File_Kind : Dictionary_File_Kind := General; Stem_File : array (Dictionary_File_Kind) of Stem_Io.File_Type; Stem_List : array (Dictionary_File_Kind) of Ada.Text_IO.File_Type; Indx_File : array (Dictionary_File_Kind) of Ada.Text_IO.File_Type; type Dict_Array is array (Positive range <>) of Dictionary_Stem; Bdl : Dict_Array (1 .. 100); Bdl_Last : Integer := 0; --SIZE_OF_DICTIONARY_ARRAY : constant INTEGER := 120; --DDL : DICT_ARRAY (1 .. SIZE_OF_DICTIONARY_ARRAY); type Dict_Array_Index is array (Character range <>, Character range <>, Dictionary_File_Kind range <>) of Stem_Io.Count; Bblf, Bbll : Dict_Array_Index (' ' .. ' ', ' ' .. ' ', Dictionary_File_Kind) := (others => (others => (others => 0))); Bdlf, Bdll : Dict_Array_Index ('a' .. 'z', ' ' .. ' ', Dictionary_File_Kind) := (others => (others => (others => 0))); Ddlf, Ddll : Dict_Array_Index ('a' .. 'z', 'a' .. 'z', Dictionary_File_Kind) := (others => (others => (others => 0))); function Adj_Comp_From_Key (Key : Stem_Key_Type) return Comparison_Type; function Adv_Comp_From_Key (Key : Stem_Key_Type) return Comparison_Type; function Num_Sort_From_Key (Key : Stem_Key_Type) return Numeral_Sort_Type; function Eff_Part (Part : Part_Of_Speech_Type) return Part_Of_Speech_Type; function Len (S : String) return Integer; function First_Index (Input_Word : String; D_K : Dictionary_File_Kind := Default_Dictionary_File_Kind) return Stem_Io.Count; function Last_Index (Input_Word : String; D_K : Dictionary_File_Kind := Default_Dictionary_File_Kind) return Stem_Io.Count; procedure Load_Indices_From_Indx_File (D_K : Dictionary_Kind); procedure Load_Bdl_From_Disk; end Support_Utils.Word_Support_Package;
-- Abstract: -- -- Root package for Stephe's Ada Library packages. -- -- See sal.html for more information. -- -- See http://stephe-leake.org/ada/sal.html for the -- latest version. -- -- Contact Stephe at stephen_leake@stephe-leake.org. -- -- Copyright (C) 1997 - 2004, 2008, 2009, 2015, 2017, 2018 Free Software Foundation, Inc. -- -- SAL 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. SAL is distributed in the hope that it will be -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. You should have received a -- copy of the GNU General Public License distributed with SAL; 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 -- SAL, or you link SAL object files with other files to produce -- an executable, that 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. pragma License (Modified_GPL); with Ada.Containers; package SAL is pragma Pure; function Version return String; -- Returns string with format "SAL x.xx". Container_Empty : exception; Container_Full : exception; Config_File_Error : exception; Domain_Error : exception; Duplicate_Key : exception; Initialization_Error : exception; Invalid_Format : exception; Invalid_Limit : exception; Invalid_Operation : exception; Invalid_Range : exception; Iterator_Error : exception; Not_Found : exception; Not_Implemented : exception; Parameter_Error : exception; Programmer_Error : exception; Range_Error : exception; -------------- -- General options type Direction_Type is (Forward, Backward); type Duplicate_Action_Type is (Allow, Ignore, Error); type Overflow_Action_Type is (Overwrite, Error); -- We use a new type for Peek_Type, not just -- Ada.Containers.Count_Type, to enforce Peek_Type'First = top/first. type Base_Peek_Type is new Ada.Containers.Count_Type range 0 .. Ada.Containers.Count_Type'Last; subtype Peek_Type is Base_Peek_Type range 1 .. Base_Peek_Type'Last; Invalid_Peek_Index : constant Base_Peek_Type := 0; type Compare_Result is (Less, Equal, Greater); end SAL;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T A S K _ I D E N T I F I C A T I O N -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Address_Image; with System.Parameters; with System.Soft_Links; with System.Task_Primitives; with System.Task_Primitives.Operations; with Ada.Unchecked_Conversion; pragma Warnings (Off); -- Allow withing of non-Preelaborated units in Ada 2005 mode where this -- package will be categorized as Preelaborate. See AI-362 for details. -- It is safe in the context of the run-time to violate the rules. with System.Tasking.Utilities; pragma Warnings (On); package body Ada.Task_Identification with SPARK_Mode => Off is use System.Parameters; package STPO renames System.Task_Primitives.Operations; ----------------------- -- Local Subprograms -- ----------------------- function Convert_Ids (T : Task_Id) return System.Tasking.Task_Id; function Convert_Ids (T : System.Tasking.Task_Id) return Task_Id; pragma Inline (Convert_Ids); -- Conversion functions between different forms of Task_Id --------- -- "=" -- --------- function "=" (Left, Right : Task_Id) return Boolean is begin return System.Tasking."=" (Convert_Ids (Left), Convert_Ids (Right)); end "="; ----------------- -- Abort_Task -- ---------------- procedure Abort_Task (T : Task_Id) is begin if T = Null_Task_Id then raise Program_Error; else System.Tasking.Utilities.Abort_Tasks (System.Tasking.Task_List'(1 => Convert_Ids (T))); end if; end Abort_Task; ---------------------------- -- Activation_Is_Complete -- ---------------------------- function Activation_Is_Complete (T : Task_Id) return Boolean is use type System.Tasking.Task_Id; begin return Convert_Ids (T).Common.Activator = null; end Activation_Is_Complete; ----------------- -- Convert_Ids -- ----------------- function Convert_Ids (T : Task_Id) return System.Tasking.Task_Id is begin return System.Tasking.Task_Id (T); end Convert_Ids; function Convert_Ids (T : System.Tasking.Task_Id) return Task_Id is begin return Task_Id (T); end Convert_Ids; ------------------ -- Current_Task -- ------------------ function Current_Task return Task_Id is begin return Convert_Ids (System.Task_Primitives.Operations.Self); end Current_Task; ---------------------- -- Environment_Task -- ---------------------- function Environment_Task return Task_Id is begin return Convert_Ids (System.Task_Primitives.Operations.Environment_Task); end Environment_Task; ----------- -- Image -- ----------- function Image (T : Task_Id) return String is function To_Address is new Ada.Unchecked_Conversion (Task_Id, System.Task_Primitives.Task_Address); begin if T = Null_Task_Id then return ""; elsif T.Common.Task_Image_Len = 0 then return System.Address_Image (To_Address (T)); else return T.Common.Task_Image (1 .. T.Common.Task_Image_Len) & "_" & System.Address_Image (To_Address (T)); end if; end Image; ----------------- -- Is_Callable -- ----------------- function Is_Callable (T : Task_Id) return Boolean is Result : Boolean; Id : constant System.Tasking.Task_Id := Convert_Ids (T); begin if T = Null_Task_Id then raise Program_Error; else System.Soft_Links.Abort_Defer.all; if Single_Lock then STPO.Lock_RTS; end if; STPO.Write_Lock (Id); Result := Id.Callable; STPO.Unlock (Id); if Single_Lock then STPO.Unlock_RTS; end if; System.Soft_Links.Abort_Undefer.all; return Result; end if; end Is_Callable; ------------------- -- Is_Terminated -- ------------------- function Is_Terminated (T : Task_Id) return Boolean is Result : Boolean; Id : constant System.Tasking.Task_Id := Convert_Ids (T); use System.Tasking; begin if T = Null_Task_Id then raise Program_Error; else System.Soft_Links.Abort_Defer.all; if Single_Lock then STPO.Lock_RTS; end if; STPO.Write_Lock (Id); Result := Id.Common.State = Terminated; STPO.Unlock (Id); if Single_Lock then STPO.Unlock_RTS; end if; System.Soft_Links.Abort_Undefer.all; return Result; end if; end Is_Terminated; end Ada.Task_Identification;
with openGL.Palette, openGL.Light; package openGL.Program.lit -- -- Models an openGL program which uses lighting. -- is type Item is new openGL.Program.item with private; type View is access all Item'Class; ------------ -- Uniforms -- overriding procedure camera_Site_is (Self : in out Item; Now : in Vector_3); overriding procedure model_Matrix_is (Self : in out Item; Now : in Matrix_4x4); overriding procedure Lights_are (Self : in out Item; Now : in Light.items); overriding procedure set_Uniforms (Self : in Item); procedure specular_Color_is (Self : in out Item; Now : in Color); private type Item is new openGL.Program.item with record Lights : Light.items (1 .. 50); light_Count : Natural := 0; specular_Color : Color := Palette.Grey; -- The materials specular color. camera_Site : Vector_3; model_Transform : Matrix_4x4 := Identity_4x4; end record; end openGL.Program.lit;
----------------------------------------------------------------------- -- widgets-factory -- Factory for widget Components -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Views.Nodes; with ASF.Components.Base; with ASF.Components.Widgets.Inputs; with ASF.Components.Widgets.Gravatars; with ASF.Components.Widgets.Likes; with ASF.Components.Widgets.Panels; with ASF.Components.Widgets.Tabs; package body ASF.Components.Widgets.Factory is use ASF.Components.Base; function Create_Accordion return UIComponent_Access; function Create_Input return UIComponent_Access; function Create_Input_Date return UIComponent_Access; function Create_Complete return UIComponent_Access; function Create_Gravatar return UIComponent_Access; function Create_Like return UIComponent_Access; function Create_Panel return UIComponent_Access; function Create_TabView return UIComponent_Access; function Create_Tab return UIComponent_Access; -- ------------------------------ -- Create a UIAccordion component -- ------------------------------ function Create_Accordion return UIComponent_Access is begin return new ASF.Components.Widgets.Tabs.UIAccordion; end Create_Accordion; -- ------------------------------ -- Create a UIInput component -- ------------------------------ function Create_Input return UIComponent_Access is begin return new ASF.Components.Widgets.Inputs.UIInput; end Create_Input; -- ------------------------------ -- Create a UIInput component -- ------------------------------ function Create_Input_Date return UIComponent_Access is begin return new ASF.Components.Widgets.Inputs.UIInputDate; end Create_Input_Date; -- ------------------------------ -- Create a UIComplete component -- ------------------------------ function Create_Complete return UIComponent_Access is begin return new ASF.Components.Widgets.Inputs.UIComplete; end Create_Complete; -- ------------------------------ -- Create a UIGravatar component -- ------------------------------ function Create_Gravatar return UIComponent_Access is begin return new ASF.Components.Widgets.Gravatars.UIGravatar; end Create_Gravatar; -- ------------------------------ -- Create a UILike component -- ------------------------------ function Create_Like return UIComponent_Access is begin return new ASF.Components.Widgets.Likes.UILike; end Create_Like; -- ------------------------------ -- Create a UIPanel component -- ------------------------------ function Create_Panel return UIComponent_Access is begin return new ASF.Components.Widgets.Panels.UIPanel; end Create_Panel; -- ------------------------------ -- Create a UITab component -- ------------------------------ function Create_Tab return UIComponent_Access is begin return new ASF.Components.Widgets.Tabs.UITab; end Create_Tab; -- ------------------------------ -- Create a UITabView component -- ------------------------------ function Create_TabView return UIComponent_Access is begin return new ASF.Components.Widgets.Tabs.UITabView; end Create_TabView; use ASF.Views.Nodes; URI : aliased constant String := "http://code.google.com/p/ada-asf/widget"; ACCORDION_TAG : aliased constant String := "accordion"; AUTOCOMPLETE_TAG : aliased constant String := "autocomplete"; INPUT_DATE_TAG : aliased constant String := "inputDate"; INPUT_TEXT_TAG : aliased constant String := "inputText"; GRAVATAR_TAG : aliased constant String := "gravatar"; LIKE_TAG : aliased constant String := "like"; PANEL_TAG : aliased constant String := "panel"; TAB_TAG : aliased constant String := "tab"; TAB_VIEW_TAG : aliased constant String := "tabView"; Widget_Bindings : aliased constant ASF.Factory.Binding_Array := (1 => (Name => ACCORDION_TAG'Access, Component => Create_Accordion'Access, Tag => Create_Component_Node'Access), 2 => (Name => AUTOCOMPLETE_TAG'Access, Component => Create_Complete'Access, Tag => Create_Component_Node'Access), 3 => (Name => INPUT_DATE_TAG'Access, Component => Create_Input_Date'Access, Tag => Create_Component_Node'Access), 4 => (Name => INPUT_TEXT_TAG'Access, Component => Create_Input'Access, Tag => Create_Component_Node'Access), 5 => (Name => GRAVATAR_TAG'Access, Component => Create_Gravatar'Access, Tag => Create_Component_Node'Access), 6 => (Name => LIKE_TAG'Access, Component => Create_Like'Access, Tag => Create_Component_Node'Access), 7 => (Name => PANEL_TAG'Access, Component => Create_Panel'Access, Tag => Create_Component_Node'Access), 8 => (Name => TAB_TAG'Access, Component => Create_Tab'Access, Tag => Create_Component_Node'Access), 9 => (Name => TAB_VIEW_TAG'Access, Component => Create_TabView'Access, Tag => Create_Component_Node'Access) ); Core_Factory : aliased constant ASF.Factory.Factory_Bindings := (URI => URI'Access, Bindings => Widget_Bindings'Access); -- ------------------------------ -- Get the widget component factory. -- ------------------------------ function Definition return ASF.Factory.Factory_Bindings_Access is begin return Core_Factory'Access; end Definition; end ASF.Components.Widgets.Factory;
----------------------------------------------------------------------- -- css-comments -- CSS comments recording -- Copyright (C) 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.Unchecked_Deallocation; with Ada.Characters.Latin_1; package body CSS.Comments is function Get_Line_Count (Text : in String) return Positive; -- ------------------------------ -- Get the line number where the comment was written. -- ------------------------------ function Get_Line_Number (Comment : in Comment_Type) return Natural is begin return Comment.Object.Line; end Get_Line_Number; -- ------------------------------ -- Get the number of lines that the comment span. -- ------------------------------ function Get_Line_Count (Comment : in Comment_Type) return Natural is begin return Comment.Object.Line_Count; end Get_Line_Count; -- ------------------------------ -- Get the full or stripped comment text. -- ------------------------------ function Get_Text (Comment : in Comment_Type; Strip : in Boolean := False) return String is begin return Comment.Object.Text; end Get_Text; -- ------------------------------ -- Get the given line of the comment text. -- ------------------------------ function Get_Text (Comment : in Comment_Type; Line : in Positive; Strip : in Boolean := False) return String is Start, Finish : Positive; begin if Line > Comment.Object.Line_Count then return ""; else Start := Comment.Object.Lines (Line).Start; Finish := Comment.Object.Lines (Line).Finish; if Strip then while Start <= Finish loop exit when Comment.Object.Text (Start) /= ' ' and Comment.Object.Text (Start) /= ASCII.HT; Start := Start + 1; end loop; while Start <= Finish loop exit when Comment.Object.Text (Finish) /= ' ' and Comment.Object.Text (Finish) /= ASCII.HT; Finish := Finish - 1; end loop; end if; return Comment.Object.Text (Start .. Finish); end if; end Get_Text; function Get_Line_Count (Text : in String) return Positive is Result : Positive := 1; begin for I in Text'Range loop if Text (I) = Ada.Characters.Latin_1.LF then Result := Result + 1; end if; end loop; return Result; end Get_Line_Count; -- ------------------------------ -- Insert in the comment list the comment described by <tt>Text</tt> -- and associated with source line number <tt>Line</tt>. After insertion -- the comment reference is returned to identify the new comment. -- ------------------------------ procedure Insert (List : in out CSSComment_List; Text : in String; Line : in Natural; Index : out Comment_Type) is N : constant Positive := Get_Line_Count (Text); C : constant Comment_Access := new Comment '(Len => Text'Length, Line_Count => N, Text => Text, Line => Line, Next => List.Chain, Lines => (others => (1, 0))); First : Natural := 1; Last : constant Natural := Text'Length; Pos : Positive := 1; begin Index.Object := C.all'Access; List.Chain := C; while First <= Last loop if Text (First) = Ada.Characters.Latin_1.LF then C.Lines (Pos).Finish := First - 1; Pos := Pos + 1; C.Lines (Pos).Start := First + 1; end if; First := First + 1; end loop; C.Lines (Pos).Finish := Last; end Insert; -- ------------------------------ -- Release the memory used by the comment list. -- ------------------------------ overriding procedure Finalize (List : in out CSSComment_List) is procedure Free is new Ada.Unchecked_Deallocation (Comment, Comment_Access); Current : Comment_Access := List.Chain; begin while Current /= null loop declare Next : constant Comment_Access := Current.Next; begin Free (Current); Current := Next; end; end loop; List.Chain := null; end Finalize; end CSS.Comments;
-- 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.Real_Time; with Ada.Task_Identification; package Ada.Execution_Time is type CPU_Time is private; CPU_Time_First : constant CPU_Time; CPU_Time_Last : constant CPU_Time; CPU_Time_Unit : constant := implementation_defined; CPU_Tick : constant Ada.Real_Time.Time_Span; function Clock (T : in Ada.Task_Identification.Task_Id := Ada.Task_Identification.Current_Task) return CPU_Time; function "+" (Left : in CPU_Time; Right : in Ada.Real_Time.Time_Span) return CPU_Time; function "+" (Left : in Ada.Real_Time.Time_Span; Right : in CPU_Time) return CPU_Time; function "-" (Left : in CPU_Time; Right : in Ada.Real_Time.Time_Span) return CPU_Time; function "-" (Left : in CPU_Time; Right : in CPU_Time) return Ada.Real_Time.Time_Span; function "<" (Left : in CPU_Time; Right : in CPU_Time) return Boolean; function "<=" (Left : in CPU_Time; Right : in CPU_Time) return Boolean; function ">" (Left : in CPU_Time; Right : in CPU_Time) return Boolean; function ">=" (Left : in CPU_Time; Right : in CPU_Time) return Boolean; procedure Split (T : in CPU_Time; SC : out Ada.Real_Time.Seconds_Count; TS : out Ada.Real_Time.Time_Span); function Time_Of (SC : in Ada.Real_Time.Seconds_Count; TS : in Ada.Real_Time.Time_Span := Ada.Real_Time.Time_Span_Zero) return CPU_Time; private pragma Import (Ada, CPU_Time); pragma Import (Ada, CPU_Time_First); pragma Import (Ada, CPU_Time_Last); pragma Import (Ada, CPU_Tick); end Ada.Execution_Time;
-------------------------------------------------------- -- E n c o d i n g s -- -- -- -- Tools for convertion strings between Unicode and -- -- national/vendor character sets. -- -- - - - - - - - - - -- -- Read copyright and license at the end of this file -- -------------------------------------------------------- with Encodings.Maps.ISO_8859_1; with Encodings.Maps.ISO_8859_2; with Encodings.Maps.ISO_8859_3; with Encodings.Maps.ISO_8859_4; with Encodings.Maps.ISO_8859_5; with Encodings.Maps.ISO_8859_6; with Encodings.Maps.ISO_8859_7; with Encodings.Maps.ISO_8859_8; with Encodings.Maps.ISO_8859_9; with Encodings.Maps.ISO_8859_10; with Encodings.Maps.ISO_8859_11; with Encodings.Maps.ISO_8859_13; with Encodings.Maps.ISO_8859_14; with Encodings.Maps.ISO_8859_15; with Encodings.Maps.ISO_8859_16; with Encodings.Maps.CP_037; with Encodings.Maps.CP_424; with Encodings.Maps.CP_437; with Encodings.Maps.CP_500; with Encodings.Maps.CP_737; with Encodings.Maps.CP_775; with Encodings.Maps.CP_850; with Encodings.Maps.CP_852; with Encodings.Maps.CP_855; with Encodings.Maps.CP_856; with Encodings.Maps.CP_857; with Encodings.Maps.CP_860; with Encodings.Maps.CP_861; with Encodings.Maps.CP_862; with Encodings.Maps.CP_863; with Encodings.Maps.CP_864; with Encodings.Maps.CP_865; with Encodings.Maps.CP_866; with Encodings.Maps.CP_869; with Encodings.Maps.CP_874; with Encodings.Maps.CP_875; with Encodings.Maps.CP_1006; with Encodings.Maps.CP_1026; with Encodings.Maps.CP_1250; with Encodings.Maps.CP_1251; with Encodings.Maps.CP_1252; with Encodings.Maps.CP_1253; with Encodings.Maps.CP_1254; with Encodings.Maps.CP_1255; with Encodings.Maps.CP_1256; with Encodings.Maps.CP_1257; with Encodings.Maps.CP_1258; with Encodings.Maps.AtariST; with Encodings.Maps.KOI8_R; package body Encodings.Unicode is ------------ -- Decode -- ------------ procedure Decode (Buffer : in String; Index : in out Positive; Free : in Positive; Map : in Encoding; Char : out Unicode_Character) is subtype C is Character; subtype W is Wide_Character; Ind : Positive := Index; function Continuing return Boolean is begin if Ind = Buffer'Last then Ind := Buffer'First; else Ind := Ind + 1; end if; if Ind = Free then Char := Empty_Buffer; return False; elsif C'Pos (Buffer (Ind)) in 2#1000_0000# .. 2#1011_1111# then Char := (Char * 2 ** 6) or (C'Pos (Buffer (Ind)) and 2#0011_1111#); return True; else raise Invalid_Encoding; end if; end Continuing; pragma Inline (Continuing); begin if Ind = Free then Char := Empty_Buffer; return; end if; case Map is when UTF_8 => case C'Pos (Buffer (Ind)) is when 2#0000_0000# .. 2#0111_1111# => Char := C'Pos (Buffer (Ind)); when 2#1100_0000# .. 2#1101_1111# => Char := C'Pos (Buffer (Ind)) and 2#0001_1111#; if not Continuing then return; end if; when 2#1110_0000# .. 2#1110_1111# => Char := C'Pos (Buffer (Ind)) and 2#0000_1111#; if not (Continuing and then Continuing) then return; end if; when 2#1111_0000# .. 2#1111_0111# => Char := C'Pos (Buffer (Ind)) and 2#0000_0111#; if not (Continuing and then Continuing and then Continuing) then return; end if; when 2#1111_1000# .. 2#1111_1011# => Char := C'Pos (Buffer (Ind)) and 2#0000_0011#; if not (Continuing and then Continuing and then Continuing and then Continuing) then return; end if; when 2#1111_1100# .. 2#1111_1101# => Char := C'Pos (Buffer (Ind)) and 2#0000_0001#; if not (Continuing and then Continuing and then Continuing and then Continuing and then Continuing) then return; end if; when others => raise Invalid_Encoding; end case; when ISO_8859_1 => Char := W'Pos (Maps.ISO_8859_1.Decode (Buffer (Ind))); when ISO_8859_2 => Char := W'Pos (Maps.ISO_8859_2.Decode (Buffer (Ind))); when ISO_8859_3 => Char := W'Pos (Maps.ISO_8859_3.Decode (Buffer (Ind))); when ISO_8859_4 => Char := W'Pos (Maps.ISO_8859_4.Decode (Buffer (Ind))); when ISO_8859_5 => Char := W'Pos (Maps.ISO_8859_5.Decode (Buffer (Ind))); when ISO_8859_6 => Char := W'Pos (Maps.ISO_8859_6.Decode (Buffer (Ind))); when ISO_8859_7 => Char := W'Pos (Maps.ISO_8859_7.Decode (Buffer (Ind))); when ISO_8859_8 => Char := W'Pos (Maps.ISO_8859_8.Decode (Buffer (Ind))); when ISO_8859_9 => Char := W'Pos (Maps.ISO_8859_9.Decode (Buffer (Ind))); when ISO_8859_10 => Char := W'Pos (Maps.ISO_8859_10.Decode (Buffer (Ind))); when ISO_8859_11 => Char := W'Pos (Maps.ISO_8859_11.Decode (Buffer (Ind))); when ISO_8859_13 => Char := W'Pos (Maps.ISO_8859_13.Decode (Buffer (Ind))); when ISO_8859_14 => Char := W'Pos (Maps.ISO_8859_14.Decode (Buffer (Ind))); when ISO_8859_15 => Char := W'Pos (Maps.ISO_8859_15.Decode (Buffer (Ind))); when ISO_8859_16 => Char := W'Pos (Maps.ISO_8859_16.Decode (Buffer (Ind))); when CP_037 => Char := W'Pos (Maps.CP_037.Decode (Buffer (Ind))); when CP_424 => Char := W'Pos (Maps.CP_424.Decode (Buffer (Ind))); when CP_437 => Char := W'Pos (Maps.CP_437.Decode (Buffer (Ind))); when CP_500 => Char := W'Pos (Maps.CP_500.Decode (Buffer (Ind))); when CP_875 => Char := W'Pos (Maps.CP_875.Decode (Buffer (Ind))); when CP_737 => Char := W'Pos (Maps.CP_737.Decode (Buffer (Ind))); when CP_775 => Char := W'Pos (Maps.CP_775.Decode (Buffer (Ind))); when CP_850 => Char := W'Pos (Maps.CP_850.Decode (Buffer (Ind))); when CP_852 => Char := W'Pos (Maps.CP_852.Decode (Buffer (Ind))); when CP_855 => Char := W'Pos (Maps.CP_855.Decode (Buffer (Ind))); when CP_856 => Char := W'Pos (Maps.CP_856.Decode (Buffer (Ind))); when CP_857 => Char := W'Pos (Maps.CP_857.Decode (Buffer (Ind))); when CP_860 => Char := W'Pos (Maps.CP_860.Decode (Buffer (Ind))); when CP_861 => Char := W'Pos (Maps.CP_861.Decode (Buffer (Ind))); when CP_862 => Char := W'Pos (Maps.CP_862.Decode (Buffer (Ind))); when CP_863 => Char := W'Pos (Maps.CP_863.Decode (Buffer (Ind))); when CP_864 => Char := W'Pos (Maps.CP_864.Decode (Buffer (Ind))); when CP_865 => Char := W'Pos (Maps.CP_865.Decode (Buffer (Ind))); when CP_866 => Char := W'Pos (Maps.CP_866.Decode (Buffer (Ind))); when CP_869 => Char := W'Pos (Maps.CP_869.Decode (Buffer (Ind))); when CP_874 => Char := W'Pos (Maps.CP_874.Decode (Buffer (Ind))); when CP_1006 => Char := W'Pos (Maps.CP_1006.Decode (Buffer (Ind))); when CP_1026 => Char := W'Pos (Maps.CP_1026.Decode (Buffer (Ind))); when CP_1250 => Char := W'Pos (Maps.CP_1250.Decode (Buffer (Ind))); when CP_1251 => Char := W'Pos (Maps.CP_1251.Decode (Buffer (Ind))); when CP_1252 => Char := W'Pos (Maps.CP_1252.Decode (Buffer (Ind))); when CP_1253 => Char := W'Pos (Maps.CP_1253.Decode (Buffer (Ind))); when CP_1254 => Char := W'Pos (Maps.CP_1254.Decode (Buffer (Ind))); when CP_1255 => Char := W'Pos (Maps.CP_1255.Decode (Buffer (Ind))); when CP_1256 => Char := W'Pos (Maps.CP_1256.Decode (Buffer (Ind))); when CP_1257 => Char := W'Pos (Maps.CP_1257.Decode (Buffer (Ind))); when CP_1258 => Char := W'Pos (Maps.CP_1258.Decode (Buffer (Ind))); when KOI8_R => Char := W'Pos (Maps.KOI8_R.Decode (Buffer (Ind))); when AtariST => Char := W'Pos (Maps.AtariST.Decode (Buffer (Ind))); when Unknown => raise Invalid_Encoding; end case; if Ind = Buffer'Last then Index := Buffer'First; else Index := Ind + 1; end if; end Decode; end Encodings.Unicode; ------------------------------------------------------------------------------ -- 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 Trendy_Test.Assertions; package body Trendy_Terminal.Lines.Tests is use Trendy_Test.Assertions; procedure Test_Make (Op : in out Trendy_Test.Operation'Class) is begin Op.Register; declare L : Line; begin L := Make("a simple line"); Assert_EQ (Op, Current (L), "a simple line"); end; end Test_Make; --------------------------------------------------------------------------- -- Test Registry --------------------------------------------------------------------------- function All_Tests return Trendy_Test.Test_Group is ( 1 => Test_Make'Access ); end Trendy_Terminal.Lines.Tests;
----------------------------------------------------------------------- -- mat-targets-probes - Definition and Analysis of process start events -- Copyright (C) 2014, 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with MAT.Events; with MAT.Events.Targets; with MAT.Events.Probes; package MAT.Targets.Probes is type Process_Probe_Type is new MAT.Events.Probes.Probe_Type with record Target : Target_Type_Access; Manager : MAT.Events.Probes.Probe_Manager_Type_Access; Events : MAT.Events.Targets.Target_Events_Access; Frames : MAT.Frames.Targets.Target_Frames_Access; end record; type Process_Probe_Type_Access is access all Process_Probe_Type'Class; -- Create a new process after the begin event is received from the event stream. procedure Create_Process (Probe : in Process_Probe_Type; Pid : in MAT.Types.Target_Process_Ref; Path : in Ada.Strings.Unbounded.Unbounded_String); -- Extract the probe information from the message. overriding procedure Extract (Probe : in Process_Probe_Type; Params : in MAT.Events.Const_Attribute_Table_Access; Msg : in out MAT.Readers.Message_Type; Event : in out MAT.Events.Target_Event_Type); procedure Execute (Probe : in Process_Probe_Type; Event : in out MAT.Events.Target_Event_Type); -- Register the reader to extract and analyze process events. procedure Register (Into : in out MAT.Events.Probes.Probe_Manager_Type'Class; Probe : in Process_Probe_Type_Access); -- Initialize the target object to prepare for reading process events. procedure Initialize (Target : in out Target_Type; Manager : in out MAT.Events.Probes.Probe_Manager_Type'Class); private procedure Probe_Begin (Probe : in Process_Probe_Type; Defs : in MAT.Events.Attribute_Table; Msg : in out MAT.Readers.Message; Event : in out MAT.Events.Target_Event_Type); -- Extract the information from the 'library' event. procedure Probe_Library (Probe : in Process_Probe_Type; Defs : in MAT.Events.Attribute_Table; Msg : in out MAT.Readers.Message; Event : in out MAT.Events.Target_Event_Type); end MAT.Targets.Probes;
with Ada.Unchecked_Conversion; with Interfaces.C; with System; package body OpenAL.Load is package C renames Interfaces.C; function Load_Subprogram (Name : in String) return Subprogram_Access_Type is pragma Assert (Subprogram_Access_Type'Size = System.Address'Size); function Get_Proc_Address (Name : System.Address) return System.Address; pragma Import (C, Get_Proc_Address, "alGetProcAddress"); function Convert is new Ada.Unchecked_Conversion (Source => System.Address, Target => Subprogram_Access_Type); use type System.Address; C_Name : aliased C.char_array := C.To_C (Name); Address : constant System.Address := Get_Proc_Address (C_Name (C_Name'First)'Address); begin if Address = System.Null_Address then raise Load_Error with "subprogram " & Name & " not found"; end if; return Convert (Address); end Load_Subprogram; end OpenAL.Load;
------------------------------------------------------------------------------ -- 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 Nodes; with Tokens; with Asis_Trait_Kinds; with Gramar_Items.Code; with Text_Streams.File; with XML_IO.Stream_Readers; with Ada.Characters.Handling; with Gela.Embeded_Links.Lists; package body Gramar_Items is Format_Error : exception; function Get_Trait_Kind (Name : String) return String; ------------------- -- Sequence_Node -- ------------------- function Get_Next (Item : Item_Ptr) return Item_Ptr; procedure Set_Next (Item, Next : Item_Ptr); package Item_Lists is new Gela.Embeded_Links.Lists (Item'Class, Item_Ptr); type Sequence_Node is tagged limited record Next : Sequence; List : Item_Lists.List; Parent : Rule; Parent_Item : Item_Ptr; Item_Index : Natural := 0; List_Index : Natural := 0; end record; function Get_Next (Item : Sequence) return Sequence; procedure Set_Next (Item, Next : Sequence); package Sequence_Lists is new Gela.Embeded_Links.Lists (Sequence_Node'Class, Sequence); --------------- -- Rule_Node -- --------------- type Rule_Node is tagged limited record List : Sequence_Lists.List; Name : Unbounded_String; Next : Rule; end record; function Get_Next (Item : Rule) return Rule; procedure Set_Next (Item, Next : Rule); package Rule_Lists is new Gela.Embeded_Links.Lists (Rule_Node'Class, Rule); ----------------- -- Gramar_Node -- ----------------- type Gramar_Node is record List : Rule_Lists.List; end record; type Gramar_Ptr is access all Gramar_Node; Gramar : Gramar_Ptr; type Option_Node is record List : Sequence_Lists.List; end record; function Compound_Name (Item : Sequence; Conflict : Boolean := False) return String; function Compound_Name (Item : Sequence; Part : Positive) return String; function Find_Item (Seq : Sequence; Name : String; Inst : Positive) return Natural; type Reference_Ptr is access all Reference; type Keyword_Ptr is access all Keyword; type Delimiter_Ptr is access all Delimiter; type List_Ptr is access all List; type Option_Ptr is access all Option; ----------- -- Count -- ----------- function Count (Item : Sequence) return Natural is begin return Natural (Item_Lists.Length (Item.List)); end Count; ----------- -- Count -- ----------- function Count (Item : Rule) return Natural is begin return Natural (Sequence_Lists.Length (Item.List)); end Count; ----------- -- Count -- ----------- function Count (Item : Option) return Natural is begin return Natural (Sequence_Lists.Length (Item.Node.List)); end Count; --------------------- -- Get_Alternative -- --------------------- function Get_Alternative (Item : Rule; Index : Positive) return Sequence is use Sequence_Lists; Result : Sequence := First (Item.List); begin for J in 2 .. Index loop Result := Next (Item.List, Result); end loop; return Result; end Get_Alternative; -------------- -- Get_Item -- -------------- function Get_Item (Object : Sequence; Index : Positive) return Item_Ptr is use Item_Lists; Result : Item_Ptr := First (Object.List); begin for J in 2 .. Index loop Result := Next (Object.List, Result); end loop; return Result; end Get_Item; ----------- -- Index -- ----------- function Wrapper_Index (Object : Wrapper) return Natural is begin return Object.Index; end Wrapper_Index; -------------- -- Is_Token -- -------------- function Is_Token (Item : Reference) return Boolean is begin return Item.Is_Token; end Is_Token; ----------- -- Items -- ----------- function Items (Item : Option; Index : Positive := 1) return Sequence is use Sequence_Lists; Result : Sequence := First (Item.Node.List); begin for J in 2 .. Index loop Result := Next (Item.Node.List, Result); end loop; return Result; end Items; ----------- -- Items -- ----------- function Items (Item : List) return Sequence is begin return Item.Items; end Items; ---------- -- Name -- ---------- function Name (Item : Rule) return String is begin return To_String (Item.Name); end Name; ---------- -- Name -- ---------- function Name (Item : Reference) return String is begin return To_String (Item.Name); end Name; ---------- -- Text -- ---------- function Text (Item : Keyword) return String is begin return To_String (Item.Text); end Text; ---------- -- Text -- ---------- function Text (Item : Delimiter) return String is begin return To_String (Item.Text); end Text; -------------- -- Set_Next -- -------------- procedure Set_Next (Item, Next : Item_Ptr) is begin Item.Next := Next; end Set_Next; -------------- -- Set_Next -- -------------- procedure Set_Next (Item, Next : Rule) is begin Item.Next := Next; end Set_Next; -------------- -- Set_Next -- -------------- procedure Set_Next (Item, Next : Sequence) is begin Item.Next := Next; end Set_Next; -------------- -- Get_Next -- -------------- function Get_Next (Item : Item_Ptr) return Item_Ptr is begin return Item.Next; end Get_Next; -------------- -- Get_Next -- -------------- function Get_Next (Item : Sequence) return Sequence is begin return Item.Next; end Get_Next; -------------- -- Get_Next -- -------------- function Get_Next (Item : Rule) return Rule is begin return Item.Next; end Get_Next; ------------------ -- Set_Sequence -- ------------------ procedure Set_Sequence (Object : in out Item; Child : in Sequence) is begin raise Format_Error; end Set_Sequence; ------------------ -- Set_Sequence -- ------------------ procedure Set_Sequence (Object : in out Option; Child : in Sequence) is begin Sequence_Lists.Append (Object.Node.List, Child); end Set_Sequence; ------------------ -- Set_Sequence -- ------------------ procedure Set_Sequence (Object : in out List; Child : in Sequence) is begin Object.Items := Child; end Set_Sequence; --------------- -- Read_File -- --------------- procedure Read_File (Name : String) is use XML_IO; package R renames XML_IO.Stream_Readers; Max_Level : constant := 8; Stream : aliased Text_Streams.File.File_Text_Stream; Parser : R.Reader (Stream'Access, R.Default_Buffer_Size); Last_Rule : Rule; Seq : array (1 .. Max_Level) of Sequence; Last_Seq : Natural := 0; Items : array (1 .. Max_Level) of Item_Ptr; Last_Item : Natural := 0; ------------------- -- Last_Sequence -- ------------------- function Last_Sequence return Sequence is begin return Seq (Last_Seq); end Last_Sequence; --------------------- -- Count_Instances -- --------------------- function Count_Instances (Name : String) return Positive is use Item_Lists; Instance : Positive := 1; Item : aliased Item_Ptr; begin while Iterate (Last_Sequence.List, Item'Access) loop if Name = Item_Name (Item.all) then Instance := Instance + 1; end if; end loop; return Instance; end Count_Instances; ------------------- -- Get_Attribute -- ------------------- function Get_Attribute (Name : String) return String is begin return R.Attribute_Value (Parser, Name); end Get_Attribute; ------------------- -- Get_Attribute -- ------------------- function Get_Attribute (Name : String) return Unbounded_String is begin return To_Unbounded_String (R.Attribute_Value (Parser, Name)); end Get_Attribute; ---------------- -- On_Element -- ---------------- procedure On_Element is use Item_Lists; use Rule_Lists; use Sequence_Lists; Local_Name : constant String := R.Name (Parser); begin if Local_Name = "gramar" then Gramar := new Gramar_Node; elsif Local_Name = "rule" then Last_Rule := new Rule_Node; Last_Rule.Name := Get_Attribute ("name"); Append (Gramar.List, Last_Rule); elsif Local_Name = "seq" then Last_Seq := Last_Seq + 1; Seq (Last_Seq) := new Sequence_Node; if Last_Item > 0 then Set_Sequence (Items (Last_Item).all, Last_Sequence); Last_Sequence.Parent_Item := Items (Last_Item); else Append (Last_Rule.List, Last_Sequence); Last_Sequence.Parent := Last_Rule; end if; elsif Local_Name = "ref" then declare Node : constant Reference_Ptr := new Reference; Name : constant String := Get_Attribute ("name"); begin Node.Name := To_Unbounded_String (Name); Node.Instance := Count_Instances (Name); Node.Parent := Last_Sequence; if Node.Name = "identifier" or Node.Name = "numeric_literal" or Node.Name = "character_literal" or Node.Name = "string_literal" then Node.Is_Token := True; end if; Append (Last_Sequence.List, Item_Ptr (Node)); end; elsif Local_Name = "keyword" then declare Node : constant Keyword_Ptr := new Keyword; Name : constant String := Get_Attribute ("text"); begin Node.Text := To_Unbounded_String (Name); Node.Instance := Count_Instances (Name); Node.Parent := Last_Sequence; Append (Last_Sequence.List, Item_Ptr (Node)); end; elsif Local_Name = "delim" then declare Node : constant Delimiter_Ptr := new Delimiter; Name : constant String := Get_Attribute ("text"); begin Node.Text := To_Unbounded_String (Name); Node.Parent := Last_Sequence; Append (Last_Sequence.List, Item_Ptr (Node)); end; elsif Local_Name = "list" then declare Node : constant List_Ptr := new List; begin Last_Item := Last_Item + 1; Items (Last_Item) := Item_Ptr (Node); Node.Parent := Last_Sequence; Append (Last_Sequence.List, Item_Ptr (Node)); end; elsif Local_Name = "opt" then declare Data : constant Option_Node_Ptr := new Option_Node; Node : constant Option_Ptr := new Option; begin Node.Node := Data; Last_Item := Last_Item + 1; Items (Last_Item) := Item_Ptr (Node); Node.Parent := Last_Sequence; Append (Last_Sequence.List, Item_Ptr (Node)); end; else raise Format_Error; end if; end On_Element; begin Text_Streams.File.Open (Stream, Name); R.Initialize (Parser); while R.More_Pieces (Parser) loop case R.Piece_Kind (Parser) is when Start_Element => On_Element; when End_Element => if R.Name (Parser) = "seq" then Last_Seq := Last_Seq - 1; elsif R.Name (Parser) = "opt" or R.Name (Parser) = "list" then Last_Item := Last_Item - 1; end if; when others => null; end case; R.Next (Parser); end loop; end Read_File; function Rule_Count return Natural is begin return Natural (Rule_Lists.Length (Gramar.List)); end Rule_Count; function Get_Rule (Index : Positive) return Rule is use Rule_Lists; Result : Rule := First (Gramar.List); begin for J in 2 .. Index loop Result := Next (Gramar.List, Result); end loop; return Result; end Get_Rule; function Pass_Through (Item : Sequence) return Boolean is begin return Code.Pass_Throgh (Rule_Name (Item), Item); end Pass_Through; function Infix (Item : Sequence) return String is begin return Code.Infix (Rule_Name (Item), Item); end Infix; function True_Node (Item : Sequence) return String is begin return Nodes.Get_Node_Type_Name (Code.True_Node (Rule_Name (Item), Item)); end True_Node; function False_Node (Item : Sequence) return String is begin return Nodes.Get_Node_Type_Name (Code.False_Node (Rule_Name (Item), Item)); end False_Node; function Node_Name (Item : Sequence) return String is R_Name : constant String := Rule_Name (Item); C_Name : constant String := Code.Node_Name (R_Name, Item); begin if Item = null then return ""; elsif C_Name /= "" then return Nodes.Get_Node_Type_Name (C_Name); elsif Pass_Through (Item) then declare I : constant Natural := Find_First_Reference (Item); begin if I /= 0 then return Node_Name (Get_Item (Item, I).all); else return ""; end if; end; -- elsif Is_Item_And_List (Item) then -- declare -- List_Index : constant Natural := Find_First_List (Item); -- begin -- return Node_Name (Get_Item (Item, List_Index)); -- end; else declare Wrap_Name : constant String := Code.User_Wrap_Node (R_Name, Item, 1); begin if Wrap_Name /= "" then return Nodes.Get_Node_Type_Name (Wrap_Name); else return Nodes.Get_Node_Type_Name (R_Name); end if; end; end if; end Node_Name; function Alternative_Node_Name (Item : Option) return String is I_Name : constant String := Item_Name (Item); R_Name : constant String := Rule_Name (Item.Parent); begin return Code.Alternative_Node_Name(R_Name, Item.Parent, I_Name); end Alternative_Node_Name; function Trait_Name (Object : Item) return String is I_Name : constant String := Item_Name (Item'Class (Object)); R_Name : constant String := Rule_Name (Object.Parent); Trait : constant String := Get_Trait_Kind (I_Name); C_Trt : constant String := Code.Trait_Name(R_Name, Object.Parent, I_Name); begin if C_Trt /= "" then return Get_Trait_Kind (C_Trt); else return Trait; end if; end Trait_Name; function Item_Name (Object : Reference) return String is begin return Name (Object); end Item_Name; function Item_Name (Object : Option) return String is begin if Count (Object) > 1 then return Compound_Name (Items (Object)) & "option" & To_String (Count (Object)); elsif Separate_Option (Object) then declare Name : constant String := Compound_Name (Items (Object)) & "option"; begin if Code.Conflict_Name (Name) then return Compound_Name (Items (Object), True) & "option"; else return Name; end if; end; else return Item_Name (Get_Item (Items (Object), 1).all); end if; end Item_Name; function Item_Name (Object : List) return String is begin return Compound_Name (Items (Object)) & "list"; end Item_Name; function Item_Name (Object : Keyword) return String is begin return Text (Object); end Item_Name; function Item_Name (Object : Delimiter) return String is begin return Tokens.Delimiter_Name (Text (Object)); end Item_Name; function Separate_Option (Item : in Option) return Boolean is Seq : constant Sequence := Items (Item); Child : Gramar_Items.Item'Class renames Get_Item (Seq, 1).all; begin if Count (Item) > 1 then return False; end if; if Count (Seq) = 1 and then (Child in Reference or Child in Keyword or Child in Delimiter) then return False; else return True; end if; end Separate_Option; function Inline_Option (Item : Option) return Boolean is begin return Code.Inline_Option (Item_Name (Item), Items (Item)); end Inline_Option; function Compound_Name (Item : Sequence; Conflict : Boolean := False) return String is Length : constant Positive := Count (Item); begin if Conflict then return Compound_Name (Item, Part => 1) & Compound_Name (Item, Part => 2) & Compound_Name (Item, Part => Length); elsif Length > 1 then return Compound_Name (Item, Part => 1) & Compound_Name (Item, Part => 2); else return Compound_Name (Item, Part => 1); end if; end Compound_Name; function Compound_Name (Item : Sequence; Part : Positive ) return String is Child : Gramar_Items.Item'Class renames Get_Item (Item, Part).all; begin if Child in Option then return Compound_Name (Items (Option (Child))); elsif Child in List then return Compound_Name (Items (List (Child))); elsif Child in Keyword then return Text (Keyword (Child)) & "_"; elsif Child in Reference then return Name (Reference (Child)) & "_"; elsif Child in Delimiter then return Tokens.Delimiter_Name (Text (Delimiter (Child))) & "_"; else return ""; end if; end Compound_Name; function Node_Name (Item : Rule) return String is Result : constant String := Node_Name (Get_Alternative (Item, 1)); begin if Result = "" then return ""; end if; for I in 2 .. Count (Item) loop if Result /= Node_Name (Get_Alternative (Item, I)) then return ""; end if; end loop; return Result; end Node_Name; function Node_Name (Object : Item) return String is begin return ""; end Node_Name; function Node_Name (Object : Option) return String is begin return Node_Name (Items (Object)); end Node_Name; function Node_Name (Object : List) return String is begin return Node_Name (Object.Items); end Node_Name; function Node_Name (Object : Reference) return String is begin if Is_Token (Object) then return Nodes.Capitalise (Item_Name (Object) & "_Node"); end if; return Node_Name (Get_Rule (Item_Name (Object))); exception when Not_Found => return ""; end Node_Name; function Get_Rule (Name : String) return Rule is use Rule_Lists; Found : aliased Rule; begin while Iterate (Gramar.List, Found'Access) loop if Found.Name = Name then return Found; end if; end loop; raise Not_Found; end Get_Rule; function Find_First_Reference (Item : Sequence) return Natural is begin for I in 1 .. Count (Item) loop declare Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all; begin if Child in Reference then return I; end if; end; end loop; return 0; end Find_First_Reference; function Choise_Item_Index (Item : Sequence) return Natural is begin for I in 1 .. Count (Item) loop if Choise (Get_Item (Item, I).all) /= "" then return I; end if; end loop; return 0; end Choise_Item_Index; function Find_First_List (Item : Sequence) return Natural is begin for I in 1 .. Count (Item) loop declare Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all; begin if Child in List then return I; end if; end; end loop; return 0; end Find_First_List; function User_Attr (Object : Item) return String is I_Name : constant String := Item_Name (Item'Class (Object)); R_Name : constant String := Rule_Name (Object.Parent); begin return Code.Get_Use_Attr (R_Name, Object.Parent, I_Name, Object.Instance); end User_Attr; function Create_Node (Object : Item) return String is I_Name : constant String := Item_Name (Item'Class (Object)); R_Name : constant String := Rule_Name (Object.Parent); begin return Nodes.Get_Node_Type_Name (Code.Created_Node_Name (R_Name, Object.Parent, I_Name)); end Create_Node; function Choise (Object : Item) return String is I_Name : constant String := Item_Name (Item'Class (Object)); R_Name : constant String := Rule_Name (Object.Parent); begin return Code.Choise (R_Name, Object.Parent, I_Name); end Choise; function Value (Object : Item) return String is I_Name : constant String := Item_Name (Item'Class (Object)); R_Name : constant String := Rule_Name (Object.Parent); begin return Code.Value (R_Name, Object.Parent, I_Name); end Value; function Rule_Name (Seq : Sequence) return String is begin if Seq.Parent /= null then return Name (Seq.Parent); elsif Seq.Parent_Item.all in Option and then Inline_Option (Option (Seq.Parent_Item.all)) then return Rule_Name (Seq.Parent_Item.Parent); else return Item_Name (Seq.Parent_Item.all); end if; end Rule_Name; function Is_Item_And_List (Seq : Sequence) return Boolean is begin for I in 1 .. Count (Seq) loop declare The_List : Gramar_Items.Item'Class renames Get_Item (Seq, I).all; begin if The_List in List then if List_Item_Node_Name (List (The_List)) /= "" then for J in 1 .. Count (Seq) loop declare The_Ref : Gramar_Items.Item'Class renames Get_Item (Seq, J).all; begin if The_Ref in Reference and then Node_Name (The_Ref) = List_Item_Node_Name (List (The_List)) then Seq.List_Index := I; Seq.Item_Index := J; return True; end if; end; end loop; end if; end if; end; end loop; return False; end Is_Item_And_List; function List_Item_Node_Name (Object : List) return String is Seq : constant Sequence := Items (Object); Ref_Index : constant Natural := Find_First_Reference (Seq); begin if Ref_Index > 0 then return Node_Name (Get_Item (Seq, Ref_Index).all); else return ""; end if; end List_Item_Node_Name; function Item_Of_List_Index (Seq : Sequence) return Natural is begin return Seq.Item_Index; end Item_Of_List_Index; function List_For_Item_Index (Seq : Sequence) return Natural is begin return Seq.List_Index; end List_For_Item_Index; function Node_Name (Object : Wrapper) return String is begin return To_String (Object.Node_Name); end Node_Name; function Parent (Object : Wrapper) return Wrapper is begin return Get_Wrapper (Object.Seq, Object.Parent); end Parent; function Item_Index (Object : Wrapper) return Natural is begin return Object.Item_Index; end Item_Index; function Object_Name (Object : Wrapper) return String is begin return To_String (Object.Object_Name); end Object_Name; function User_Attr_Name (Object : Wrapper) return String is begin return To_String (Object.Attr_Name); end User_Attr_Name; function Position (Object : Wrapper) return String is begin return To_String (Object.Position); end Position; function Wrap_Count (Item : Sequence) return Natural is R_Name : constant String := Rule_Name (Item); User_Wraps : constant Natural := Code.User_Wraps (R_Name, Item); begin if User_Wraps > 0 then return User_Wraps; else if Pass_Through (Item) then return 0; elsif Is_Item_And_List (Item) and then Node_Name (Item) /= "" then return 2; else return 1; end if; end if; end Wrap_Count; function Get_Wrapper (Seq : Sequence; Index : Positive) return Wrapper is function U (Text : String) return Unbounded_String renames To_Unbounded_String; R_Name : constant String := Rule_Name (Seq); User_Wraps : constant Natural := Code.User_Wraps (R_Name, Seq); begin if User_Wraps > 0 then declare Node : constant String := Code.User_Wrap_Node (R_Name, Seq, Index); Name : constant String := Nodes.Get_Node_Type_Name (Node); Item : constant String := Code.Wrap_Item_Name (R_Name, Seq, Index); Attr : constant String := Code.Wrap_Attr_Name (R_Name, Seq, Index); Pos : constant String := Code.Wrapper_Position (R_Name, Seq, Index); Inst : constant Positive := Code.Wrapper_Instance (R_Name, Seq, Index); Ind : constant Natural := Find_Item (Seq, Item, Inst); begin return (Node_Name => U (Name), Object_Name => U ("Wrap" & To_String (Index)), Parent => Code.Wrapper_Index (R_Name, Seq, Index), Attr_Name => U (Attr), Position => U (Pos), Item_Index => Ind, Seq => Seq, Index => Index); end; else if Is_Item_And_List (Seq) then declare List_Index : constant Natural := List_For_Item_Index (Seq); The_List : Item'Class renames Get_Item (Seq, List_Index).all; List_Name : constant String := Node_Name (The_List); Wrap : constant String := Node_Name (Seq); begin if Index = 1 then if Wrap = "" then return (Node_Name => U (List_Name), Object_Name => U ("New_Node"), Attr_Name => Null_Unbounded_String, Position => Null_Unbounded_String, Parent => 0, Item_Index => List_Index, Seq => Seq, Index => 0); else return (Node_Name => U (Wrap), Object_Name => U ("Wrap"), Attr_Name => Null_Unbounded_String, Position => Null_Unbounded_String, Parent => 0, Item_Index => 0, Seq => Seq, Index => 0); end if; else return (Node_Name => U (List_Name), Object_Name => U ("New_Node"), Attr_Name => Null_Unbounded_String, Position => Null_Unbounded_String, Parent => 1, Item_Index => List_Index, Seq => Seq, Index => 0); end if; end; else return (Node_Name => U (Node_Name (Seq)), Object_Name => U ("New_Node"), Attr_Name => Null_Unbounded_String, Position => Null_Unbounded_String, Parent => 0, Item_Index => 0, Seq => Seq, Index => 0); end if; end if; end Get_Wrapper; function Parent (Object : Item) return Wrapper is I_Name : constant String := Item_Name (Item'Class (Object)); R_Name : constant String := Rule_Name (Object.Parent); Wrap_I : Natural := Code.Wrapper_Index (R_Name, Object.Parent, I_Name, Object.Instance); begin if Wrap_I = 0 then Wrap_I := 1; end if; return Get_Wrapper (Object.Parent, Wrap_I); end Parent; function To_String (X : Natural) return String is Image : constant String := Natural'Image (X); begin return Image (2 .. Image'Last); end To_String; function Find_Item (Seq : Sequence; Name : String; Inst : Positive) return Natural is Cnt : Positive := Inst; begin if Name = "" then return 0; end if; for I in 1 .. Count (Seq) loop if Item_Name (Get_Item (Seq, I).all) = Name then if Cnt = 1 then return I; else Cnt := Cnt - 1; end if; end if; end loop; return 0; end Find_Item; function Top (Object : Wrapper) return Boolean is begin return Object.Parent = 0; end Top; function Get_Trait_Kind (Name : String) return String is use Asis_Trait_Kinds; use Ada.Characters.Handling; Upper_Name1 : constant String := "A_" & To_Upper (Name) & "_TRAIT"; Upper_Name2 : constant String := "AN_" & To_Upper (Name) & "_TRAIT"; begin for I in Trait_Kinds loop declare Image : constant String := Trait_Kinds'Image (I); Upper : constant String := To_Upper (Image); begin if Upper = Upper_Name1 or Upper = Upper_Name2 then return Nodes.Capitalise (Image); end if; end; end loop; return ""; end Get_Trait_Kind; end Gramar_Items; ------------------------------------------------------------------------------ -- Copyright (c) 2006, 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. ------------------------------------------------------------------------------
package C_Words is type Comparable is limited interface; type Word (<>) is tagged private; function New_Word (Str : String) return Word; type C_Word (<>) is new Word and Comparable with private; function New_Word (Str : String) return C_Word; private type Word (Length : Natural) is tagged record Str : String (1 .. Length) := (others => ' '); end record; type C_Word is new Word and Comparable with null record; end C_Words;
-- Test handling for Random and Basic_Rand. Rewritten to pass gnatprove. generic No_Of_Seeds : Positive; type Parent_Random_Int is mod <>; package Text_Utilities with Spark_Mode => On is pragma Pure; --No_Of_Seeds : constant Positive := 3; --type Parent_Random_Int is mod 2**64; pragma Assert (Parent_Random_Int'Last = 2**64-1); Rand_Image_Width : constant := 20; -- 2^64-1 = 18_446_744_073_709_551_615 Max_Image_Width : constant Positive := Rand_Image_Width * No_Of_Seeds; subtype Random_Int_String_Index is Positive range 1 .. Rand_Image_Width; subtype Random_Int_String is String (Random_Int_String_Index); subtype Character_Digit is Character range '0' .. '9'; -- All state values State.X(i) are less than 2^64. -- -- All state values State.X(i) are in a range that is correctly evaluated by -- function 'Value'. -- -- The calculation uses the modular arithmetic on modular type Parent_Random_Int. -- If the image string encodes a number out-of-range of Parent_Random_Int, -- (i.e. > 2^64-1), then of course the function can't return that value. function Value (Random_Int_Image : in Random_Int_String) return Parent_Random_Int with Pre => (for all i in Random_Int_String'Range => Random_Int_Image(i) in Character_Digit); function Image (X : in Parent_Random_Int) return Random_Int_String with Pre => Parent_Random_Int'Last = 2**63 + (2**63-1) and Random_Int_String'Length = 20; end Text_Utilities;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . I N I T I A L I Z A T I O N -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, 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 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides overall initialization of the tasking portion of the -- RTS. This package must be elaborated before any tasking features are used. package System.Tasking.Initialization is procedure Remove_From_All_Tasks_List (T : Task_Id); -- Remove T from All_Tasks_List. Call this function with RTS_Lock taken procedure Finalize_Attributes (T : Task_Id); -- Finalize all attributes from T. This is to be called just before the -- ATCB is deallocated. It relies on the caller holding T.L write-lock -- on entry. --------------------------------- -- Tasking-Specific Soft Links -- --------------------------------- ------------------------- -- Abort Defer/Undefer -- ------------------------- -- Defer_Abort defers the effects of low-level abort and priority change -- in the calling task until a matching Undefer_Abort call is executed. -- Undefer_Abort DOES MORE than just undo the effects of one call to -- Defer_Abort. It is the universal "polling point" for deferred -- processing, including the following: -- 1) base priority changes -- 2) abort/ATC -- Abort deferral MAY be nested (Self_ID.Deferral_Level is a count), but -- to avoid waste and undetected errors, it generally SHOULD NOT be -- nested. The symptom of over-deferring abort is that an exception may -- fail to be raised, or an abort may fail to take place. -- Therefore, there are two sets of the inlineable defer/undefer routines, -- which are the ones to be used inside GNARL. One set allows nesting. The -- other does not. People who maintain the GNARL should try to avoid using -- the nested versions, or at least look very critically at the places -- where they are used. -- In general, any GNARL call that is potentially blocking, or whose -- semantics require that it sometimes raise an exception, or that is -- required to be an abort completion point, must be made with abort -- Deferral_Level = 1. -- In general, non-blocking GNARL calls, which may be made from inside a -- protected action, are likely to need to allow nested abort deferral. -- With some critical exceptions (which are supposed to be documented), -- internal calls to the tasking runtime system assume abort is already -- deferred, and do not modify the deferral level. -- There is also a set of non-inlineable defer/undefer routines, for direct -- call from the compiler. These are not inlineable because they may need -- to be called via pointers ("soft links"). For the sake of efficiency, -- the version with Self_ID as parameter should used wherever possible. -- These are all nestable. -- Non-nestable inline versions procedure Defer_Abort (Self_ID : Task_Id); pragma Inline (Defer_Abort); procedure Undefer_Abort (Self_ID : Task_Id); pragma Inline (Undefer_Abort); -- Nestable inline versions procedure Defer_Abort_Nestable (Self_ID : Task_Id); pragma Inline (Defer_Abort_Nestable); procedure Undefer_Abort_Nestable (Self_ID : Task_Id); pragma Inline (Undefer_Abort_Nestable); procedure Do_Pending_Action (Self_ID : Task_Id); -- Only call with no locks, and when Self_ID.Pending_Action = True Perform -- necessary pending actions (e.g. abort, priority change). This procedure -- is usually called when needed as a result of calling Undefer_Abort, -- although in the case of e.g. No_Abort restriction, it can be necessary -- to force execution of pending actions. function Check_Abort_Status return Integer; -- Returns Boolean'Pos (True) iff abort signal should raise -- Standard'Abort_Signal. Only used by IRIX currently. -------------------------- -- Change Base Priority -- -------------------------- procedure Change_Base_Priority (T : Task_Id); -- Change the base priority of T. Has to be called with the affected -- task's ATCB write-locked. May temporarily release the lock. ---------------------- -- Task Lock/Unlock -- ---------------------- procedure Task_Lock (Self_ID : Task_Id); pragma Inline (Task_Lock); procedure Task_Unlock (Self_ID : Task_Id); pragma Inline (Task_Unlock); -- These are versions of Lock_Task and Unlock_Task created for use -- within the GNARL. procedure Final_Task_Unlock (Self_ID : Task_Id); -- This version is only for use in Terminate_Task, when the task is -- relinquishing further rights to its own ATCB. There is a very -- interesting potential race condition there, where the old task may run -- concurrently with a new task that is allocated the old tasks (now -- reused) ATCB. The critical thing here is to not make any reference to -- the ATCB after the lock is released. See also comments on -- Terminate_Task and Unlock. procedure Wakeup_Entry_Caller (Self_ID : Task_Id; Entry_Call : Entry_Call_Link; New_State : Entry_Call_State); pragma Inline (Wakeup_Entry_Caller); -- This is called at the end of service of an entry call, to abort the -- caller if he is in an abortable part, and to wake up the caller if he -- is on Entry_Caller_Sleep. Call it holding the lock of Entry_Call.Self. -- -- Timed_Call or Simple_Call: -- The caller is waiting on Entry_Caller_Sleep, in Wait_For_Completion, -- or Wait_For_Completion_With_Timeout. -- -- Conditional_Call: -- The caller might be in Wait_For_Completion, -- waiting for a rendezvous (possibly requeued without abort) to -- complete. -- -- Asynchronous_Call: -- The caller may be executing in the abortable part an async. select, -- or on a time delay, if Entry_Call.State >= Was_Abortable. procedure Locked_Abort_To_Level (Self_ID : Task_Id; T : Task_Id; L : ATC_Level_Base); pragma Inline (Locked_Abort_To_Level); -- Abort a task to a specified ATC level. Call this only with T locked end System.Tasking.Initialization;
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- 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. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 Keccak.Generic_Parallel_XOF; with Keccak.Types; pragma Elaborate_All (Keccak.Generic_Parallel_XOF); -- @summary -- Parallel implementation of the cSHAKE algorithm. -- -- @description -- This package supports N separate instances of cSHAKE which are processed -- in parallel, where N = Num_Parallel_Instances. It is built on top of any -- instantiation of the Generic_Parallel_CSHAKE package. -- -- This is the basis of parallel algorithms, e.g. ParallelHash. -- -- This API is used as follows: -- -- 1 Initialise a new context by calling Init. Customization strings can be -- optionally given to Init to provide domain separation between different -- uses of cSHAKE. -- -- 2 Call Update_Separate one or more times to input an arbitrary amount of -- data into each cSHAKE instance. -- -- 3 Call Extract_Separate one or more times to produce an arbitrary number -- of output bytes from each cSHAKE instance. -- -- @group cSHAKE generic with package XOF is new Keccak.Generic_Parallel_XOF (<>); package Keccak.Generic_Parallel_CSHAKE is Num_Parallel_Instances : constant Positive := XOF.Num_Parallel_Instances; type Context is private; type States is (Updating, Extracting, Finished); subtype Rate_Bits_Number is XOF.Rate_Bits_Number; procedure Init (Ctx : out Context; Customization : in String; Function_Name : in String) with Global => null, Pre => Customization /= "" or Function_Name /= "", Post => State_Of (Ctx) = Updating; -- Initialize the parallel cSHAKE context. -- -- All parallel instances are initialised with the same Customization -- and Function_Name strings. -- -- Note that the Customization and Function_Name strings are optional, but -- at least one must be a non-empty string. -- -- In cases where many cSHAKE computations are performed with the same -- customization and function name strings it is possible to initialize -- a context once with the desired parameters, then copy the context as -- many times as necessary for the different computations. The following -- example creates two contexts initialised to the same value: -- -- declare -- Ctx1 : Context; -- Ctx2 : Context; -- begin -- Init (Ctx1, "Example", ""); -- -- Ctx2 := Ctx1; -- end; -- -- @param Ctx The context to initialize. -- -- @param Customization An optional customization string to provide domain -- separation from different usages of cSHAKE. -- -- @param Function_Name An optional name for the function for which cSHAKE -- is being used. This is intended to be used only for NIST-defined -- constructions based on cSHAKE. For other non-NIST usages this string -- should be the empty string. procedure Update_Separate (Ctx : in out Context; Data : in Types.Byte_Array) with Global => null, Pre => (Data'Length mod Num_Parallel_Instances = 0 and Data'Length / Num_Parallel_Instances <= Natural'Last / 8 and State_Of (Ctx) = Updating), Contract_Cases => ((Data'Length / Num_Parallel_Instances) mod (Rate / 8) = 0 => State_Of (Ctx) = Updating, others => State_Of (Ctx) = Extracting); -- Input data into each cSHAKE instance. -- -- The Data buffer is split into N equal-sized chunks, where N is the -- number of parallel instances. For example, with 4-level parallelism, the -- Data will be split into four chunks of equal length: -- -- +-----------+-----------+-----------+-----------+ -- | 0 | 1 | 2 | 3 | Data (split into N chunks) -- +-----------+-----------+-----------+-----------+ -- | | | | Absorb -- V V V V -- +-----------+-----------+-----------+-----------+ -- | 0 | 1 | 2 | 3 | Context (N cSHAKE instances) -- +-----------+-----------+-----------+-----------+ -- -- Chunk 0 will be absorbed into the first cSHAKE instance; chunk 1 will -- be absorbed into the second cSHAKE instance, and so on... -- -- This procedure can be called multiple times to absorb an arbitrary -- amount of data, provided that the length of each chunk is a multiple -- of the rate. If the chunk length is not a multiple of the rate then -- the data will be absorbed, but the Context will advance to the -- Squeezing state and no more data can be absorbed. procedure Extract_Separate (Ctx : in out Context; Data : out Types.Byte_Array) with Global => null, Pre => (Data'Length mod Num_Parallel_Instances = 0 and State_Of (Ctx) in Updating | Extracting), Contract_Cases => ((Data'Length / Num_Parallel_Instances) mod (Rate / 8) = 0 => State_Of (Ctx) = Extracting, others => State_Of (Ctx) = Finished); -- Get output bytes from each cSHAKE instance. -- -- +-----------+-----------+-----------+-----------+ -- | 0 | 1 | 2 | 3 | Context (N cSHAKE instances) -- +-----------+-----------+-----------+-----------+ -- | | | | Extract -- V V V V -- +-----------+-----------+-----------+-----------+ -- | 0 | 1 | 2 | 3 | Data (split into N chunks) -- +-----------+-----------+-----------+-----------+ -- -- This function may be called multiple times to generate a large amount of -- output data, as long as the length of the Data buffer is a multiple of -- N * Rate, where N is Num_Parallel_Instances and Rate is the Rate parameter -- in bytes. If the Data buffer length does not meet this criterea, then -- the context enters the Finished state and no more output bytes can be -- produced. function State_Of (Ctx : in Context) return States with Global => null; -- Get the current state of the context. function Rate return Rate_Bits_Number with Global => null; -- Get the rate of the context, in bits. private type Context is record XOF_Ctx : XOF.Context; end record; function State_Of (Ctx : in Context) return States is (case XOF.State_Of (Ctx.XOF_Ctx) is when XOF.Updating => Updating, when XOF.Extracting => Extracting, when XOF.Finished => Finished); function Rate return Rate_Bits_Number is (XOF.Rate); end Keccak.Generic_Parallel_CSHAKE;
----------------------------------------------------------------------- -- asf-components-base -- Component tree -- Copyright (C) 2009 - 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; with Util.Log.Loggers; with Ada.Exceptions; with Ada.Unchecked_Deallocation; with ASF.Views.Nodes; with ASF.Contexts.Writer; with ASF.Contexts.Writer.String; with ASF.Components.Utils; with ASF.Components.Core; with ASF.Components.Core.Views; with ASF.Events.Faces; with EL.Variables; with EL.Contexts.Default; with ASF.Applications.Messages; with ASF.Applications.Messages.Factory; package body ASF.Components.Base is -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Components.Base"); procedure Free_Component is new Ada.Unchecked_Deallocation (Object => UIComponent'Class, Name => UIComponent_Access); procedure Free_Attribute is new Ada.Unchecked_Deallocation (Object => UIAttribute, Name => UIAttribute_Access); -- Get the UIAttribute associated with the given name. -- Returns null if there is no UIAttribute with such name. function Get_Attribute (UI : in UIComponent; Name : in String) return UIAttribute_Access; -- ------------------------------ -- Get the parent component. -- Returns null if the node is the root element. -- ------------------------------ function Get_Parent (UI : UIComponent) return UIComponent_Access is begin return UI.Parent; end Get_Parent; -- ------------------------------ -- Return a client-side identifier for this component, generating -- one if necessary. -- ------------------------------ function Get_Client_Id (UI : UIComponent) return Unbounded_String is begin return UI.Id; end Get_Client_Id; -- ------------------------------ -- Returns True if the client-side identifier was generated automatically. -- ------------------------------ function Is_Generated_Id (UI : in UIComponent) return Boolean is begin return UI.Id_Generated; end Is_Generated_Id; -- ------------------------------ -- Returns True if the component has a client-side identifier matching the given name. -- ------------------------------ function Is_Client_Id (UI : in UIComponent; Id : in String) return Boolean is begin return UI.Id = Id; end Is_Client_Id; -- ------------------------------ -- Get the list of children. -- ------------------------------ function Get_Children (UI : UIComponent) return UIComponent_List is Result : UIComponent_List; begin Result.Child := UI.First_Child; return Result; end Get_Children; -- ------------------------------ -- Get the number of children. -- ------------------------------ function Get_Children_Count (UI : UIComponent) return Natural is Result : Natural := 0; Child : UIComponent_Access := UI.First_Child; begin while Child /= null loop Result := Result + 1; Child := Child.Next; end loop; return Result; end Get_Children_Count; -- ------------------------------ -- Get the first child component. -- Returns null if the component has no children. -- ------------------------------ function Get_First_Child (UI : UIComponent) return UIComponent_Access is begin return UI.First_Child; end Get_First_Child; -- ------------------------------ -- Get the tag node that created this component. -- ------------------------------ function Get_Tag (UI : in UIComponent'Class) return access ASF.Views.Nodes.Tag_Node'Class is begin return UI.Tag; end Get_Tag; -- ------------------------------ -- Initialize the component when restoring the view. -- The default initialization gets the client ID and allocates it if necessary. -- ------------------------------ procedure Initialize (UI : in out UIComponent; Context : in out Faces_Context'Class) is -- Then, look in the static attributes Attr : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("id"); Id : Natural; begin if Attr = null then Context.Create_Unique_Id (Id); UI.Id := To_Unbounded_String ("id" & Util.Strings.Image (Id)); UI.Id_Generated := True; else UI.Id := EL.Objects.To_Unbounded_String (ASF.Views.Nodes.Get_Value (Attr.all, UI)); UI.Id_Generated := False; end if; end Initialize; procedure Append (UI : in UIComponent_Access; Child : in UIComponent_Access; Tag : access ASF.Views.Nodes.Tag_Node'Class) is begin Child.Tag := Tag; Child.Parent := UI; Child.Next := null; if UI.Last_Child = null then UI.First_Child := Child; else UI.Last_Child.Next := Child; end if; UI.Last_Child := Child; end Append; -- ------------------------------ -- Search within the component tree for the {@link UIComponent} with -- an <code>id</code> that matches the specified search expression. -- ------------------------------ function Find_Child (UI : in UIComponent'Class; Id : in String) return UIComponent_Access is Child : UIComponent_Access := UI.First_Child; begin while Child /= null loop if Child.Is_Client_Id (Id) then return Child; end if; if Child.First_Child /= null then declare Result : constant UIComponent_Access := Child.Find_Child (Id); begin if Result /= null then return Result; end if; end; end if; Child := Child.Next; end loop; return null; end Find_Child; -- ------------------------------ -- Get the number of facets that this component contains. -- ------------------------------ function Get_Facet_Count (UI : in UIComponent'Class) return Natural is begin if UI.Facets = null then return 0; else return Natural (UI.Facets.Length); end if; end Get_Facet_Count; -- ------------------------------ -- Get the facet identified by the given name. -- Returns null if there is no such facet. -- ------------------------------ function Get_Facet (UI : in UIComponent'Class; Name : in String) return UIComponent_Access is begin if UI.Facets = null then return null; else declare Pos : constant Component_Maps.Cursor := UI.Facets.Find (Name); begin if Component_Maps.Has_Element (Pos) then Log.Debug ("Get facet {0}", Name); return Component_Maps.Element (Pos); else Log.Debug ("Facet {0}, not found", Name); return null; end if; end; end if; end Get_Facet; -- ------------------------------ -- Add the facet represented by the root component <b>Facet</b> under the name <b>Name</b>. -- The facet component is added to the facet map and it get be retrieved later on by -- using the <b>Get_Facet</b> operation. The facet component will be destroyed when this -- component is deleted. -- ------------------------------ procedure Add_Facet (UI : in out UIComponent'Class; Name : in String; Facet : in UIComponent_Access; Tag : access ASF.Views.Nodes.Tag_Node'Class) is Pos : Component_Maps.Cursor; begin Log.Debug ("Adding facet {0}", Name); if UI.Facets = null then UI.Facets := new Component_Maps.Map; end if; Pos := UI.Facets.Find (Name); if Component_Maps.Has_Element (Pos) then declare Facet : UIComponent_Access := Component_Maps.Element (Pos); begin Free_Component (Facet); end; UI.Log_Error ("Facet {0} already part of the component tree.", Name); UI.Facets.Replace_Element (Pos, Facet); else UI.Facets.Insert (Name, Facet); end if; Facet.Tag := Tag; Facet.Parent := UI'Unchecked_Access; Facet.Next := null; end Add_Facet; -- ------------------------------ -- Search for and return the {@link UIComponent} with an <code>id</code> -- that matches the specified search expression (if any), according to -- the algorithm described below. -- o look first in the sub-tree representing the parent node. -- o if not found, move to the parent's node -- Returns null if the component was not found in the view. -- ------------------------------ function Find (UI : in UIComponent; Id : in String) return UIComponent_Access is Ignore : UIComponent_Access := null; Parent : UIComponent_Access := UI.Parent; Node : UIComponent_Access; Result : UIComponent_Access; begin while Parent /= null loop if Parent.Is_Client_Id (Id) then return Parent; end if; -- Search the children recursively but skip the previous sub-tree we come from. Node := Parent.First_Child; while Node /= null loop if Node /= Ignore then if Node.Is_Client_Id (Id) then return Node; end if; Result := Node.Find_Child (Id => Id); if Result /= null then return Result; end if; end if; Node := Node.Next; end loop; -- Move up to the parent and ignore this sub-tree now. Ignore := Parent; Parent := Parent.Parent; end loop; return null; end Find; function Get_Context (UI : in UIComponent) return ASF.Contexts.Faces.Faces_Context_Access is pragma Unreferenced (UI); begin return ASF.Contexts.Faces.Current; end Get_Context; -- ------------------------------ -- Check whether the component and its children must be rendered. -- ------------------------------ function Is_Rendered (UI : UIComponent; Context : Faces_Context'Class) return Boolean is Attr : constant EL.Objects.Object := UI.Get_Attribute (Context, RENDERED_NAME); begin if EL.Objects.Is_Null (Attr) then return True; end if; return EL.Objects.To_Boolean (Attr); end Is_Rendered; -- ------------------------------ -- Set whether the component is rendered. -- ------------------------------ procedure Set_Rendered (UI : in out UIComponent; Rendered : in Boolean) is begin null; end Set_Rendered; -- ------------------------------ -- Get the UIAttribute associated with the given name. -- Returns null if there is no UIAttribute with such name. -- ------------------------------ function Get_Attribute (UI : in UIComponent; Name : in String) return UIAttribute_Access is use type ASF.Views.Nodes.Tag_Attribute; Attribute : UIAttribute_Access := UI.Attributes; begin -- Look first in the dynamic attribute list (owned by this UIComponent) while Attribute /= null loop if Attribute.Definition.all = Name then return Attribute; end if; Attribute := Attribute.Next_Attr; end loop; return null; end Get_Attribute; function Get_Attribute (UI : UIComponent; Context : Faces_Context'Class; Name : String) return EL.Objects.Object is Attribute : constant UIAttribute_Access := Get_Attribute (UI, Name); begin if Attribute /= null then begin -- The attribute value can be a constant or an expression. if not EL.Objects.Is_Null (Attribute.Value) then return Attribute.Value; else return Attribute.Expr.Get_Value (Context.Get_ELContext.all); end if; exception when EL.Variables.No_Variable => UI.Tag.Error ("Variable not found in expression: {0}", Attribute.Expr.Get_Expression); return EL.Objects.Null_Object; when E : others => Log.Error ("Evaluation error for '" & Attribute.Expr.Get_Expression & "'", E); UI.Tag.Error ("Exception raised when evaluating expression: {0}", Attribute.Expr.Get_Expression); return EL.Objects.Null_Object; end; end if; -- Then, look in the static attributes declare Attr : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute (Name); begin if Attr = null then return EL.Objects.Null_Object; end if; return ASF.Views.Nodes.Get_Value (Attr.all, UI); end; end Get_Attribute; -- ------------------------------ -- Get the attribute tag -- ------------------------------ function Get_Attribute (UI : UIComponent; Name : String) return access ASF.Views.Nodes.Tag_Attribute is begin if UI.Tag = null then return null; else return UI.Tag.Get_Attribute (Name); end if; end Get_Attribute; -- ------------------------------ -- Get the attribute value as a boolean. -- If the attribute does not exist, returns the default. -- ------------------------------ function Get_Attribute (UI : in UIComponent; Name : in String; Context : in Faces_Context'Class; Default : in Boolean := False) return Boolean is Attr : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, Name); begin if Util.Beans.Objects.Is_Null (Attr) then return Default; else return Util.Beans.Objects.To_Boolean (Attr); end if; end Get_Attribute; -- ------------------------------ -- Get the attribute value as a boolean. -- If the attribute does not exist, returns the default. -- ------------------------------ function Get_Attribute (UI : in UIComponent; Name : in String; Context : in Faces_Context'Class; Default : in Integer := 0) return Integer is Attr : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, Name); begin if Util.Beans.Objects.Is_Null (Attr) then return Default; else return Util.Beans.Objects.To_Integer (Attr); end if; end Get_Attribute; -- ------------------------------ -- Get the attribute value as a string. -- If the attribute does not exist, returns the default. -- ------------------------------ function Get_Attribute (UI : in UIComponent; Name : in String; Context : in Faces_Context'Class; Default : in String := "") return String is Attr : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, Name); begin if Util.Beans.Objects.Is_Null (Attr) then return Default; else return Util.Beans.Objects.To_String (Attr); end if; end Get_Attribute; procedure Set_Attribute (UI : in out UIComponent; Name : in String; Value : in EL.Objects.Object) is begin null; end Set_Attribute; procedure Set_Attribute (UI : in out UIComponent; Def : access ASF.Views.Nodes.Tag_Attribute; Value : in EL.Expressions.Expression) is use type ASF.Views.Nodes.Tag_Attribute; Attribute : UIAttribute_Access := UI.Attributes; begin while Attribute /= null loop if Def.all = Attribute.Definition.all then -- Attr_Name = Name then Attribute.Expr := Value; Attribute.Value := EL.Objects.Null_Object; return; end if; Attribute := Attribute.Next_Attr; end loop; Attribute := new UIAttribute; Attribute.Definition := Def; Attribute.Value := EL.Objects.Null_Object; Attribute.Expr := Value; Attribute.Next_Attr := UI.Attributes; UI.Attributes := Attribute; end Set_Attribute; procedure Set_Attribute (UI : in out UIComponent; Def : access ASF.Views.Nodes.Tag_Attribute; Value : in EL.Objects.Object) is use type ASF.Views.Nodes.Tag_Attribute; Attribute : UIAttribute_Access := UI.Attributes; begin while Attribute /= null loop if Def.all = Attribute.Definition.all then Attribute.Value := Value; return; end if; Attribute := Attribute.Next_Attr; end loop; Attribute := new UIAttribute; Attribute.Definition := Def; Attribute.Value := Value; Attribute.Next_Attr := UI.Attributes; UI.Attributes := Attribute; end Set_Attribute; -- ------------------------------ -- Get the <b>label</b> attribute from the component. If the attribute is -- empty, returns the client id. -- ------------------------------ function Get_Label (UI : in UIComponent'Class; Context : in Faces_Context'Class) return Util.Beans.Objects.Object is Result : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, LABEL_NAME); begin if not Util.Beans.Objects.Is_Null (Result) then return Result; else return Util.Beans.Objects.To_Object (UI.Get_Client_Id); end if; end Get_Label; -- ------------------------------ -- Get the expression -- ------------------------------ function Get_Expression (UI : in UIComponent; Name : in String) return EL.Expressions.Expression is Attribute : constant UIAttribute_Access := Get_Attribute (UI, Name); begin if Attribute /= null then begin -- The attribute value can be a constant or an expression. if EL.Objects.Is_Null (Attribute.Value) then return Attribute.Expr; end if; exception when EL.Variables.No_Variable => UI.Tag.Error ("Variable not found in expression: {0}", Attribute.Expr.Get_Expression); when E : others => Log.Error ("Evaluation error for '" & Attribute.Expr.Get_Expression & "'", E); UI.Tag.Error ("Exception raised when evaluating expression: {0}", Attribute.Expr.Get_Expression); end; else -- Then, look in the static attributes declare Value : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute (Name); begin if Value /= null then return ASF.Views.Nodes.Get_Expression (Value.all); end if; end; end if; raise EL.Expressions.Invalid_Expression with "No value expression for: " & Name; end Get_Expression; -- ------------------------------ -- Get the value expression -- ------------------------------ function Get_Value_Expression (UI : in UIComponent; Name : in String) return EL.Expressions.Value_Expression is Attribute : constant UIAttribute_Access := Get_Attribute (UI, Name); begin if Attribute /= null then begin -- The attribute value can be a constant or an expression. if EL.Objects.Is_Null (Attribute.Value) then return EL.Expressions.Create_Expression (Attribute.Expr); end if; exception when EL.Variables.No_Variable => UI.Tag.Error ("Variable not found in expression: {0}", Attribute.Expr.Get_Expression); when E : others => Log.Error ("Evaluation error for '" & Attribute.Expr.Get_Expression & "'", E); UI.Tag.Error ("Exception raised when evaluating expression: {0}", Attribute.Expr.Get_Expression); end; else -- Then, look in the static attributes declare Value : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute (Name); begin if Value /= null then return ASF.Views.Nodes.Get_Value_Expression (Value.all); end if; end; end if; raise EL.Expressions.Invalid_Expression with "No value expression for: " & Name; end Get_Value_Expression; -- ------------------------------ -- Get the method expression -- Raise an Invalid_Expression if the method expression is invalid. -- ------------------------------ function Get_Method_Expression (UI : in UIComponent; Name : in String) return EL.Expressions.Method_Expression is Attribute : constant UIAttribute_Access := Get_Attribute (UI, Name); begin if Attribute /= null then begin -- The attribute value can be a constant or an expression. if EL.Objects.Is_Null (Attribute.Value) then return EL.Expressions.Create_Expression (Attribute.Expr); end if; exception when EL.Variables.No_Variable => UI.Tag.Error ("Variable not found in expression: {0}", Attribute.Expr.Get_Expression); when E : others => Log.Error ("Evaluation error for '" & Attribute.Expr.Get_Expression & "'", E); UI.Tag.Error ("Exception raised when evaluating expression: {0}", Attribute.Expr.Get_Expression); end; else -- Then, look in the static attributes declare Value : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute (Name); begin if Value /= null then return ASF.Views.Nodes.Get_Method_Expression (Value.all); end if; end; end if; raise EL.Expressions.Invalid_Expression with "No method expression for: " & Name; end Get_Method_Expression; -- ------------------------------ -- Add a message for the component. Look for the message attribute identified -- by <b>Name</b> on the <b>UI</b> component. Add this message in the faces context -- and associated with the component client id. Otherwise, add the default -- message whose bundle key is identified by <b>default</b>. -- ------------------------------ procedure Add_Message (UI : in UIComponent'Class; Name : in String; Default : in String; Context : in out Faces_Context'Class) is Args : constant ASF.Utils.Object_Array (1 .. 0) := (others => <>); begin UI.Add_Message (Name, Default, Args, Context); end Add_Message; -- ------------------------------ -- Add a message for the component. Look for the message attribute identified -- by <b>Name</b> on the <b>UI</b> component. Add this message in the faces context -- and associated with the component client id. Otherwise, add the default -- message whose bundle key is identified by <b>default</b>. -- ------------------------------ procedure Add_Message (UI : in UIComponent'Class; Name : in String; Default : in String; Arg1 : in Util.Beans.Objects.Object; Context : in out Faces_Context'Class) is Args : constant ASF.Utils.Object_Array (1 .. 1) := (1 => Arg1); begin UI.Add_Message (Name, Default, Args, Context); end Add_Message; -- ------------------------------ -- Add a message for the component. Look for the message attribute identified -- by <b>Name</b> on the <b>UI</b> component. Add this message in the faces context -- and associated with the component client id. Otherwise, add the default -- message whose bundle key is identified by <b>default</b>. -- ------------------------------ procedure Add_Message (UI : in UIComponent'Class; Name : in String; Default : in String; Arg1 : in Util.Beans.Objects.Object; Arg2 : in Util.Beans.Objects.Object; Context : in out Faces_Context'Class) is Args : constant ASF.Utils.Object_Array (1 .. 2) := (1 => Arg1, 2 => Arg2); begin UI.Add_Message (Name, Default, Args, Context); end Add_Message; -- ------------------------------ -- Add a message for the component. Look for the message attribute identified -- by <b>Name</b> on the <b>UI</b> component. Add this message in the faces context -- and associated with the component client id. Otherwise, use the default -- message whose bundle key is identified by <b>default</b>. The message is -- formatted with the arguments passed in <b>Args</b>. -- ------------------------------ procedure Add_Message (UI : in UIComponent'Class; Name : in String; Default : in String; Args : in ASF.Utils.Object_Array; Context : in out Faces_Context'Class) is Id : constant String := To_String (UI.Get_Client_Id); Msg : constant EL.Objects.Object := UI.Get_Attribute (Name => Name, Context => Context); Message : ASF.Applications.Messages.Message; begin if EL.Objects.Is_Null (Msg) then Message := ASF.Applications.Messages.Factory.Get_Message (Context => Context, Message_Id => Default, Args => Args); else -- The message is already localized, we just need to set and format it. ASF.Applications.Messages.Set_Severity (Message, ASF.Applications.Messages.ERROR); ASF.Applications.Messages.Format_Summary (Message, EL.Objects.To_String (Msg), Args); end if; Context.Add_Message (Client_Id => Id, Message => Message); end Add_Message; procedure Encode_Begin (UI : in UIComponent; Context : in out Faces_Context'Class) is begin null; end Encode_Begin; procedure Encode_Children (UI : in UIComponent; Context : in out Faces_Context'Class) is Child : UIComponent_Access; begin -- Do not render the children if the component is not rendered. if not UI.Is_Rendered (Context) then return; end if; Child := UI.First_Child; while Child /= null loop Child.Encode_All (Context); Child := Child.Next; end loop; end Encode_Children; -- ------------------------------ -- Encode the children components in a local buffer and after the rendering execute -- the <b>Process</b> procedure with the generated content. -- If this component is not rendered, do nothing. -- ------------------------------ procedure Wrap_Encode_Children (UI : in UIComponent; Context : in out ASF.Contexts.Faces.Faces_Context'Class; Process : not null access procedure (Content : in Unbounded_String)) is Child : UIComponent_Access := UI.First_Child; begin if not UI.Is_Rendered (Context) then return; elsif Child = null then Process (Null_Unbounded_String); else -- Replace temporarily the response writer by a local buffer. -- Make sure that if an exception is raised, the original response writer is restored. declare Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer; Buffer : aliased ASF.Contexts.Writer.String.String_Writer; begin Context.Set_Response_Writer (Buffer'Unchecked_Access); while Child /= null loop Child.Encode_All (Context); Child := Child.Next; end loop; Context.Set_Response_Writer (Writer); Process (Buffer.Get_Response); exception when others => Context.Set_Response_Writer (Writer); raise; end; end if; end Wrap_Encode_Children; procedure Wrap_Encode_Children (UI : in UIComponent; Context : in out ASF.Contexts.Faces.Faces_Context'Class; Process : not null access procedure (Content : in String)) is Child : UIComponent_Access := UI.First_Child; begin if not UI.Is_Rendered (Context) then return; elsif Child = null then Process (""); else -- Replace temporarily the response writer by a local buffer. -- Make sure that if an exception is raised, the original response writer is restored. declare Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer; Buffer : aliased ASF.Contexts.Writer.String.String_Writer; begin Context.Set_Response_Writer (Buffer'Unchecked_Access); while Child /= null loop Child.Encode_All (Context); Child := Child.Next; end loop; Context.Set_Response_Writer (Writer); Process (Ada.Strings.Unbounded.To_String (Buffer.Get_Response)); exception when others => Context.Set_Response_Writer (Writer); raise; end; end if; end Wrap_Encode_Children; procedure Encode_End (UI : in UIComponent; Context : in out Faces_Context'Class) is begin null; end Encode_End; procedure Encode_All (UI : in UIComponent'Class; Context : in out Faces_Context'Class) is begin UI.Encode_Begin (Context); UI.Encode_Children (Context); UI.Encode_End (Context); end Encode_All; procedure Decode (UI : in out UIComponent; Context : in out Faces_Context'Class) is begin null; end Decode; procedure Decode_Children (UI : in UIComponent'Class; Context : in out Faces_Context'Class) is Child : UIComponent_Access; begin Child := UI.First_Child; while Child /= null loop Child.Process_Decodes (Context); Child := Child.Next; end loop; end Decode_Children; procedure Process_Decodes (UI : in out UIComponent; Context : in out Faces_Context'Class) is begin -- Do not decode the component nor its children if the component is not rendered. if not UI.Is_Rendered (Context) then return; end if; UI.Decode_Children (Context); UIComponent'Class (UI).Decode (Context); end Process_Decodes; -- ------------------------------ -- Perform the component tree processing required by the <b>Process Validations</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_Validators</b> of all facets and children. -- <ul> -- ------------------------------ procedure Process_Validators (UI : in out UIComponent; Context : in out Faces_Context'Class) is Child : UIComponent_Access; begin -- Do not process validation of the component nor its children -- if this component is not rendered. if not UI.Is_Rendered (Context) then return; end if; Child := UI.First_Child; while Child /= null loop Child.Process_Validators (Context); Child := Child.Next; end loop; end Process_Validators; procedure Process_Updates (UI : in out UIComponent; Context : in out Faces_Context'Class) is Child : UIComponent_Access; begin -- Do not decode the component nor its children if the component is not rendered. if not UI.Is_Rendered (Context) then return; end if; Child := UI.First_Child; while Child /= null loop Child.Process_Updates (Context); Child := Child.Next; end loop; end Process_Updates; -- ------------------------------ -- Queue an event for broadcast at the end of the current request -- processing lifecycle phase. The default implementation in -- delegates this call to the parent component. The <b>UIViewRoot</b> -- component is in charge of queueing events. The event object -- will be freed after being dispatched. -- ------------------------------ procedure Queue_Event (UI : in out UIComponent; Event : not null access ASF.Events.Faces.Faces_Event'Class) is begin if UI.Parent = null then Log.Error ("The component tree does not have a UIView root component. Event ignored."); else UI.Parent.Queue_Event (Event); end if; end Queue_Event; -- ------------------------------ -- Broadcast the event to the event listeners installed on this component. -- Listeners are called in the order in which they were added. -- ------------------------------ procedure Broadcast (UI : in out UIComponent; Event : not null access ASF.Events.Faces.Faces_Event'Class; Context : in out Faces_Context'Class) is pragma Unreferenced (UI, Event, Context); begin Log.Error ("Event dispatched to a component that cannot handle it"); end Broadcast; -- ------------------------------ -- Finalize the object. -- ------------------------------ overriding procedure Finalize (UI : in out UIComponent) is procedure Free is new Ada.Unchecked_Deallocation (Object => Component_Maps.Map, Name => Component_Map_Access); begin -- If this component has some facets, we have to delete them. if UI.Facets /= null then loop declare Iter : Component_Maps.Cursor := UI.Facets.First; Item : UIComponent_Access; begin exit when not Component_Maps.Has_Element (Iter); Item := Component_Maps.Element (Iter); Free_Component (Item); UI.Facets.Delete (Iter); end; end loop; Free (UI.Facets); end if; -- Release the dynamic attributes. declare A : UIAttribute_Access := UI.Attributes; begin while A /= null loop UI.Attributes := A.Next_Attr; Free_Attribute (A); A := UI.Attributes; end loop; end; -- And release the children of this component recursively. declare C : UIComponent_Access := UI.First_Child; begin while C /= null loop UI.First_Child := C.Next; Free_Component (C); C := UI.First_Child; end loop; end; end Finalize; -- ------------------------------ -- Iterate over the children of the component and execute -- the <b>Process</b> procedure. -- ------------------------------ procedure Iterate (UI : in UIComponent'Class) is Child : UIComponent_Access := UI.First_Child; begin while Child /= null loop Process (Child); Child := Child.Next; end loop; end Iterate; -- ------------------------------ -- Iterate over the attributes defined on the component and -- execute the <b>Process</b> procedure. -- ------------------------------ procedure Iterate_Attributes (UI : in UIComponent'Class) is Attribute : UIAttribute_Access := UI.Attributes; procedure Process_Tag_Attribute (Attr : in ASF.Views.Nodes.Tag_Attribute_Access); procedure Process_Tag_Attribute (Attr : in ASF.Views.Nodes.Tag_Attribute_Access) is A : UIAttribute; N : UIAttribute_Access := UI.Attributes; begin while N /= null loop if N.Definition = Attr then return; end if; N := N.Next_Attr; end loop; A.Definition := Attr; Process (ASF.Views.Nodes.Get_Name (Attr.all), A); end Process_Tag_Attribute; procedure Iterate_Tag_Attributes is new ASF.Views.Nodes.Iterate_Attributes (Process_Tag_Attribute); begin -- Iterate first over the component modified attributes. while Attribute /= null loop Process (ASF.Views.Nodes.Get_Name (Attribute.Definition.all), Attribute.all); Attribute := Attribute.Next_Attr; end loop; Iterate_Tag_Attributes (UI.Tag.all); end Iterate_Attributes; -- ------------------------------ -- Get the attribute value. -- ------------------------------ function Get_Value (Attr : UIAttribute; UI : UIComponent'Class) return EL.Objects.Object is procedure Handle_Exception (E : in Ada.Exceptions.Exception_Occurrence); procedure Handle_Exception (E : in Ada.Exceptions.Exception_Occurrence) is begin ASF.Views.Nodes.Error (Attr.Definition.all, "Evaluation error: {0}", Ada.Exceptions.Exception_Message (E)); end Handle_Exception; begin if not EL.Objects.Is_Null (Attr.Value) then return Attr.Value; elsif not Attr.Expr.Is_Null then declare Ctx : constant EL.Contexts.ELContext_Access := UI.Get_Context.Get_ELContext; Context : EL.Contexts.Default.Guarded_Context (Handle_Exception'Access, Ctx); begin return Attr.Expr.Get_Value (Context); end; else return ASF.Views.Nodes.Get_Value (Attr.Definition.all, UI); end if; end Get_Value; -- ------------------------------ -- Report an error message in the logs caused by an invalid configuration or -- setting on the component. -- ------------------------------ procedure Log_Error (UI : in UIComponent'Class; Message : in String; Arg1 : in String := ""; Arg2 : in String := ""; Arg3 : in String := "") is begin Log.Error (Utils.Get_Line_Info (UI) & ": " & Message, Arg1, Arg2, Arg3); end Log_Error; -- ------------------------------ -- Get the root component from the <b>UI</b> component tree. -- After the operation, the <b>UI</b> component tree will contain no -- nodes. -- If the <b>Root</b> pointer is not null, first deletes recursively -- the component tree. -- ------------------------------ procedure Steal_Root_Component (UI : in out UIComponent'Class; Root : in out UIComponent_Access) is procedure Move_Siblings (Tree : in UIComponent_Access); -- Move siblings of the component at end of children list. procedure Move_Siblings (Tree : in UIComponent_Access) is Node, Prev : UIComponent_Access; begin Node := Tree.Next; Tree.Next := null; if Tree.Last_Child = null then Tree.First_Child := Node; else Tree.Last_Child.Next := Node; end if; -- And reparent these left nodes. while Node /= null loop Prev := Node; Node.Parent := Tree; Node := Node.Next; end loop; Tree.Last_Child := Prev; end Move_Siblings; begin if Root /= null then Free_Component (Root); end if; if UI.First_Child = null then Root := null; elsif UI.First_Child.Next = null and then UI.First_Child.all in ASF.Components.Core.Views.UIView'Class then Root := UI.First_Child; Root.Parent := null; UI.First_Child := null; UI.Last_Child := null; else declare View : Core.Views.UIView_Access; Tree : UIComponent_Access := UI.First_Child; Node : UIComponent_Access := Tree; Prev : UIComponent_Access := null; begin while Node /= null and then not (Node.all in Core.Views.UIView'Class) loop Prev := Node; Node := Node.Next; end loop; if Node /= null then View := Core.Views.UIView'Class (Node.all)'Access; -- Move the left components below the <f:view> component. if Prev /= null then Prev.Next := null; -- Reparent the first left node to the real <f:view> root component -- and make it the root of the left tree before the <f:view>. Tree.Parent := View.all'Access; View.Set_Before_View (Tree); -- Move other left nodes at end of children list of our new left tree. -- This is necessary to correctly release them. Move_Siblings (Tree); Node := View.all'Access; end if; -- Move the right components below the <f:view> component. if Node.Next /= null then Tree := Node.Next; -- Reparent the first right node to the real <f:view> root component -- and make it the root of the right tree after the <f:view>. Tree.Parent := View.all'Access; View.Set_After_View (Tree); Move_Siblings (Tree); Node := View.all'Access; end if; else View := new Components.Core.Views.UIView; View.Set_Content_Type ("text/html"); Root := View.all'Access; Root.First_Child := UI.First_Child; Root.Last_Child := UI.Last_Child; Node := UI.First_Child; -- Reparent the children. while Node /= null loop Node.Parent := Root; Node := Node.Next; end loop; end if; Root := View.all'Access; Root.Parent := null; UI.First_Child := null; UI.Last_Child := null; end; end if; end Steal_Root_Component; -- ------------------------------ -- Get an iterator to scan the component children. -- ------------------------------ function First (UI : in UIComponent'Class) return Cursor is begin return Cursor '(Child => UI.First_Child); end First; -- ------------------------------ -- Returns True if the iterator points to a valid child. -- ------------------------------ function Has_Element (Pos : in Cursor) return Boolean is begin return Pos.Child /= null; end Has_Element; -- ------------------------------ -- Get the child component pointed to by the iterator. -- ------------------------------ function Element (Pos : in Cursor) return UIComponent_Access is begin return Pos.Child; end Element; -- ------------------------------ -- Move to the next child. -- ------------------------------ procedure Next (Pos : in out Cursor) is begin if Pos.Child /= null then Pos.Child := Pos.Child.Next; end if; end Next; end ASF.Components.Base;
with Ada.Text_IO; use Ada.Text_IO; with Extract_List_Files; use Extract_List_Files; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Parser_Xml; use Parser_Xml; procedure Main is Return_From_Call_String : Unbounded_String; Return_From_Call_Vector : Parser_Xml.String_Vector.Vector; begin -- Print the list of xml files -- Put_Line(Extract_List_Files.Print_List("obj/xml")); -- Return_From_Call_Vector := Get_List("obj/xml"); -- Put_Line(Integer'Image(Integer(Return_From_Call_Vector.Length))); -- --Return_From_Call_String := -- Extract_Nodes(File_Name => "obj/xml/xml_test.xml", -- Parent_Name => "lillo"); Return_From_Call_Vector := Get_Nodes_Value_From_Xml_Tree(Xml_Tree => Get_Xml_Tree_From_File( File_Name => "obj/xml/xml_test.xml", Description => "Addresses list"), Value_Description => "addr"); for Index in 0 .. (Integer(Return_From_Call_Vector.Length) - 1) loop Put_Line(Return_From_Call_Vector.Element(Integer(Index))); end loop; end Main;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package arm_linux_gnueabihf_asm_posix_types_h is -- * arch/arm/include/asm/posix_types.h -- * -- * Copyright (C) 1996-1998 Russell King. -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License version 2 as -- * published by the Free Software Foundation. -- * -- * Changelog: -- * 27-06-1996 RMK Created -- -- * This file is generally used by user-level software, so you need to -- * be a little careful about namespace pollution etc. Also, we cannot -- * assume GCC is being used. -- subtype uu_kernel_mode_t is unsigned_short; -- /usr/include/arm-linux-gnueabihf/asm/posix_types.h:22 subtype uu_kernel_ipc_pid_t is unsigned_short; -- /usr/include/arm-linux-gnueabihf/asm/posix_types.h:25 subtype uu_kernel_uid_t is unsigned_short; -- /usr/include/arm-linux-gnueabihf/asm/posix_types.h:28 subtype uu_kernel_gid_t is unsigned_short; -- /usr/include/arm-linux-gnueabihf/asm/posix_types.h:29 subtype uu_kernel_old_dev_t is unsigned_short; -- /usr/include/arm-linux-gnueabihf/asm/posix_types.h:32 end arm_linux_gnueabihf_asm_posix_types_h;
----------------------------------------------------------------------- -- log.tests -- Unit tests for loggers -- Copyright (C) 2009, 2010, 2011, 2013, 2015, 2018, 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Fixed; with Ada.Directories; with Ada.Text_IO; with Ada.Strings.Unbounded; with Util.Test_Caller; with Util.Log; with Util.Log.Loggers; with Util.Files; with Util.Properties; with Util.Measures; package body Util.Log.Tests is Log : constant Loggers.Logger := Loggers.Create ("util.log.test"); procedure Test_Log (T : in out Test) is L : Loggers.Logger := Loggers.Create ("util.log.test.debug"); begin L.Set_Level (DEBUG_LEVEL); Log.Info ("My log message"); Log.Error ("My error message"); Log.Debug ("A debug message Not printed"); L.Info ("An info message"); L.Info ("A {0} {1} {2} {3}", "info", "message", "not", "printed"); L.Debug ("A debug message on logger 'L'"); Util.Tests.Assert_Equals (T, "DEBUG", L.Get_Level_Name, "Get_Level_Name function is invalid"); end Test_Log; procedure Test_Debug (T : in out Test) is L : Loggers.Logger := Loggers.Create ("util.log.test.debug"); C : Ada.Strings.Unbounded.Unbounded_String; begin L.Set_Level (DEBUG_LEVEL); L.Info ("My log message"); L.Error ("My error message"); L.Debug ("A {0} {1} {2} {3}", "debug", "message", "not", "printed"); L.Debug ("A {0} {1} {2} {3}", C, "message", "printed"); L.Info ("An info message"); L.Debug ("A debug message on logger 'L'"); Util.Tests.Assert_Equals (T, "DEBUG", L.Get_Level_Name, "Get_Level_Name function is invalid"); end Test_Debug; -- Test configuration and creation of file procedure Test_File_Appender (T : in out Test) is Path : constant String := Util.Tests.Get_Test_Path ("test.log"); Props : Util.Properties.Manager; begin Props.Set ("log4j.appender.test", "File"); Props.Set ("log4j.appender.test.File", Path); Props.Set ("log4j.logger.util.log.test.file", "DEBUG,test"); Util.Log.Loggers.Initialize (Props); declare L : constant Loggers.Logger := Loggers.Create ("util.log.test.file"); begin L.Debug ("Writing a debug message"); L.Debug ("{0}: {1}", "Parameter", "Value"); end; T.Assert (Ada.Directories.Exists (Path), "Log file " & Path & " not found"); end Test_File_Appender; procedure Test_Log_Perf (T : in out Test) is Path : constant String := Util.Tests.Get_Test_Path ("test_perf.log"); Props : Util.Properties.Manager; begin Props.Set ("log4j.appender.test", "File"); Props.Set ("log4j.appender.test.File", Path); Props.Set ("log4j.logger.util.log.test.perf", "DEBUG,test"); Util.Log.Loggers.Initialize (Props); for I in 1 .. 1000 loop declare S : Util.Measures.Stamp; begin Util.Measures.Report (S, "Util.Measures.Report", 1000); end; end loop; declare L : Loggers.Logger := Loggers.Create ("util.log.test.perf"); S : Util.Measures.Stamp; begin L.Set_Level (DEBUG_LEVEL); for I in 1 .. 1000 loop L.Info ("My log message: {0}: {1}", "A message", "A second parameter"); end loop; Util.Measures.Report (S, "Log.Info message (output)", 1000); L.Set_Level (INFO_LEVEL); for I in 1 .. 10_000 loop L.Debug ("My log message: {0}: {1}", "A message", "A second parameter"); end loop; Util.Measures.Report (S, "Log.Debug message (no output)", 10_000); end; T.Assert (Ada.Directories.Exists (Path), "Log file " & Path & " not found"); end Test_Log_Perf; -- ------------------------------ -- Test appending the log on several log files -- ------------------------------ procedure Test_List_Appender (T : in out Test) is use Ada.Strings; use Ada.Directories; Props : Util.Properties.Manager; begin for I in 1 .. 10 loop declare Id : constant String := Fixed.Trim (Integer'Image (I), Both); Path : constant String := Util.Tests.Get_Test_Path ("test" & Id & ".log"); Name : constant String := "log4j.appender.test" & Id; begin Props.Set (Name, "File"); Props.Set (Name & ".File", Path); Props.Set (Name & ".layout", "date-level-message"); if I > 5 then Props.Set (Name & ".level", "INFO"); end if; end; end loop; Props.Set ("log4j.rootCategory", "DEBUG, test.log"); Props.Set ("log4j.appender.test.log.File", Util.Tests.Get_Test_Path ("test-default.log")); Props.Set ("log4j.logger.util.log.test.file", "DEBUG,test4,test1 , test2,test3, test4, test5 , test6 , test7,test8,"); Util.Log.Loggers.Initialize (Props); declare L : constant Loggers.Logger := Loggers.Create ("util.log.test.file"); begin L.Debug ("Writing a debug message"); L.Debug ("{0}: {1}", "Parameter", "Value"); L.Debug ("Done"); end; -- Check that we have non empty log files (up to test8.log). for I in 1 .. 8 loop declare Id : constant String := Fixed.Trim (Integer'Image (I), Both); Path : constant String := Util.Tests.Get_Test_Path ("test" & Id & ".log"); begin T.Assert (Ada.Directories.Exists (Path), "Log file " & Path & " not found"); if I > 5 then T.Assert (Ada.Directories.Size (Path) < 100, "Log file " & Path & " should be empty"); else T.Assert (Ada.Directories.Size (Path) > 100, "Log file " & Path & " is empty"); end if; end; end loop; end Test_List_Appender; -- ------------------------------ -- Test file appender with different modes. -- ------------------------------ procedure Test_File_Appender_Modes (T : in out Test) is use Ada.Directories; Append_Path : constant String := Util.Tests.Get_Test_Path ("test-append.log"); Append2_Path : constant String := Util.Tests.Get_Test_Path ("test-append2.log"); Global_Path : constant String := Util.Tests.Get_Test_Path ("test-append-global.log"); Props : Util.Properties.Manager; begin Props.Set ("log4j.appender.test", "File"); Props.Set ("log4j.appender.test.File", Append_Path); Props.Set ("log4j.appender.test.append", "true"); Props.Set ("log4j.appender.test.immediateFlush", "true"); Props.Set ("log4j.appender.test_global", "File"); Props.Set ("log4j.appender.test_global.File", Global_Path); Props.Set ("log4j.appender.test_global.append", "false"); Props.Set ("log4j.appender.test_global.immediateFlush", "false"); Props.Set ("log4j.logger.util.log.test.file", "DEBUG"); Props.Set ("log4j.rootCategory", "DEBUG,test_global,test"); Util.Log.Loggers.Initialize (Props); declare L : constant Loggers.Logger := Loggers.Create ("util.log.test.file"); begin L.Debug ("Writing a debug message"); L.Debug ("{0}: {1}", "Parameter", "Value"); L.Debug ("Done"); L.Error ("This is the error test message"); end; Props.Set ("log4j.appender.test_append", "File"); Props.Set ("log4j.appender.test_append.File", Append2_Path); Props.Set ("log4j.appender.test_append.append", "true"); Props.Set ("log4j.appender.test_append.immediateFlush", "true"); Props.Set ("log4j.logger.util.log.test2.file", "DEBUG,test_append,test_global"); Util.Log.Loggers.Initialize (Props); declare L1 : constant Loggers.Logger := Loggers.Create ("util.log.test.file"); L2 : constant Loggers.Logger := Loggers.Create ("util.log.test2.file"); begin L1.Info ("L1-1 Writing a info message"); L2.Info ("L2-2 {0}: {1}", "Parameter", "Value"); L1.Info ("L1-3 Done"); L2.Error ("L2-4 This is the error test2 message"); end; Props.Set ("log4j.appender.test_append.append", "plop"); Props.Set ("log4j.appender.test_append.immediateFlush", "falsex"); Props.Set ("log4j.rootCategory", "DEBUG, test.log"); Util.Log.Loggers.Initialize (Props); T.Assert (Ada.Directories.Size (Append_Path) > 100, "Log file test-append.log is empty"); T.Assert (Ada.Directories.Size (Append2_Path) > 100, "Log file test-append2.log is empty"); T.Assert (Ada.Directories.Size (Global_Path) > 100, "Log file test-append.log is empty"); end Test_File_Appender_Modes; -- ------------------------------ -- Test file appender with different modes. -- ------------------------------ procedure Test_Console_Appender (T : in out Test) is Path : constant String := Util.Tests.Get_Test_Path ("test_err.log"); Props : Util.Properties.Manager; File : Ada.Text_IO.File_Type; Content : Ada.Strings.Unbounded.Unbounded_String; begin Ada.Text_IO.Create (File, Ada.Text_IO.Out_File, Path); Ada.Text_IO.Set_Error (File); Props.Set ("log4j.appender.test_console", "Console"); Props.Set ("log4j.appender.test_console.stderr", "true"); Props.Set ("log4j.appender.test_console.level", "WARN"); Props.Set ("log4j.rootCategory", "INFO,test_console"); Util.Log.Loggers.Initialize (Props); declare L : constant Loggers.Logger := Loggers.Create ("util.log.test.file"); begin L.Debug ("Writing a debug message"); L.Debug ("{0}: {1}", "Parameter", "Value"); L.Debug ("Done"); L.Info ("INFO MESSAGE!"); L.Warn ("WARN MESSAGE!"); L.Error ("This {0} {1} {2} test message", "is", "the", "error"); end; Ada.Text_IO.Flush (Ada.Text_IO.Current_Error); Ada.Text_IO.Set_Error (Ada.Text_IO.Standard_Error); Ada.Text_IO.Close (File); Util.Files.Read_File (Path, Content); Util.Tests.Assert_Matches (T, ".*WARN MESSAGE!", Content, "Invalid console log (WARN)"); Util.Tests.Assert_Matches (T, ".*This is the error test message", Content, "Invalid console log (ERROR)"); exception when others => Ada.Text_IO.Set_Error (Ada.Text_IO.Standard_Error); raise; end Test_Console_Appender; procedure Test_Missing_Config (T : in out Test) is pragma Unreferenced (T); L : constant Loggers.Logger := Loggers.Create ("util.log.test.debug"); begin Util.Log.Loggers.Initialize ("plop"); L.Info ("An info message"); L.Debug ("A debug message on logger 'L'"); end Test_Missing_Config; procedure Test_Log_Traceback (T : in out Test) is Path : constant String := Util.Tests.Get_Test_Path ("test-traceback.log"); Props : Util.Properties.Manager; Content : Ada.Strings.Unbounded.Unbounded_String; begin Props.Set ("log4j.appender.test", "File"); Props.Set ("log4j.appender.test.File", Path); Props.Set ("log4j.appender.test.append", "false"); Props.Set ("log4j.appender.test.immediateFlush", "true"); Props.Set ("log4j.rootCategory", "DEBUG,test"); Util.Log.Loggers.Initialize (Props); declare L : constant Loggers.Logger := Loggers.Create ("util.log.test.file"); begin L.Error ("This is the error test message"); raise Constraint_Error with "Test"; exception when E : others => L.Error ("Something wrong", E, True); end; Props.Set ("log4j.rootCategory", "DEBUG,console"); Props.Set ("log4j.appender.console", "Console"); Util.Log.Loggers.Initialize (Props); Util.Files.Read_File (Path, Content); Util.Tests.Assert_Matches (T, ".*Something wrong: Exception CONSTRAINT_ERROR:", Content, "Invalid console log (ERROR)"); end Test_Log_Traceback; package Caller is new Util.Test_Caller (Test, "Log"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Log.Loggers.Info", Test_Log'Access); Caller.Add_Test (Suite, "Test Util.Log.Loggers.Debug", Test_Debug'Access); Caller.Add_Test (Suite, "Test Util.Log.Loggers.Set_Level", Test_Log'Access); Caller.Add_Test (Suite, "Test Util.Log.Loggers.Error", Test_Log_Traceback'Access); Caller.Add_Test (Suite, "Test Util.Log.Loggers.Initialize", Test_Missing_Config'Access); Caller.Add_Test (Suite, "Test Util.Log.Appenders.File_Appender", Test_File_Appender'Access); Caller.Add_Test (Suite, "Test Util.Log.Appenders.File_Appender (append)", Test_File_Appender_Modes'Access); Caller.Add_Test (Suite, "Test Util.Log.Appenders.List_Appender", Test_List_Appender'Access); Caller.Add_Test (Suite, "Test Util.Log.Appenders.Console", Test_Console_Appender'Access); Caller.Add_Test (Suite, "Test Util.Log.Loggers.Log (Perf)", Test_Log_Perf'Access); end Add_Tests; end Util.Log.Tests;
with freetype_C.Binding, freetype_C.FT_Vector, freetype_C.FT_Bitmap, freetype_C.FT_Size_Metrics, freetype_C.FT_BBox, freetype_C.FT_CharMapRec, interfaces.C.Strings; procedure launch_freetype_linkage_Test -- -- Tests linkage to Freetype functions. -- Is not meant to be run. -- is use Freetype_C, freetype_C.Binding, Interfaces; an_Error : FT_Error; pragma Unreferenced (an_Error); an_FT_UShort : FT_UShort; pragma Unreferenced (an_FT_UShort); an_FT_Uint : FT_Uint; pragma Unreferenced (an_FT_Uint); an_FT_Int : FT_Int; pragma Unreferenced (an_FT_Int); an_FT_Long : FT_Long; pragma Unreferenced (an_FT_Long); an_FT_Outline : access FT_Outline; pragma Unreferenced (an_FT_Outline); an_FT_Vector : FT_Vector.Item; pragma Unreferenced (an_FT_Vector); an_FT_Bitmap : FT_Bitmap.Item; pragma Unreferenced (an_FT_Bitmap); an_Unsigned : interfaces.c.unsigned; pragma Unreferenced (an_Unsigned); an_FT_Size_Metrics : FT_Size_Metrics.Item; pragma Unreferenced (an_FT_Size_Metrics); an_FT_Face : access freetype_c.FT_FaceRec; pragma Unreferenced (an_FT_Face); an_FT_SizeRec : access freetype_c.FT_SizeRec; pragma Unreferenced (an_FT_SizeRec); an_FT_BBox : FT_BBox.item; pragma Unreferenced (an_FT_BBox); an_FT_CharMap : access freetype_c.FT_CharMapRec.Item; pragma Unreferenced (an_FT_CharMap); an_FT_GlyphSlot : access freetype_c.FT_GlyphSlotRec; pragma Unreferenced (an_FT_GlyphSlot); begin FT_Outline_Get_CBox (null, null); an_Error := FT_Init_FreeType (null); an_Error := FT_Done_FreeType (null); an_Error := FT_Render_Glyph (null, FT_RENDER_MODE_NORMAL); an_Error := FT_Set_Char_Size (null, 0, 0, 0, 0); an_Error := FT_Done_Face (null); an_Error := FT_Attach_File (null, Interfaces.C.Strings.null_ptr); an_Error := FT_Set_Charmap (null, null); an_Error := FT_Select_Charmap (null, 0); an_FT_uint := FT_Get_Char_Index (null, 0); an_Error := FT_Get_Kerning (null, 0, 0, 0, null); an_Error := FT_Load_Glyph (null, 0, 0); an_FT_Outline := FT_GlyphSlot_Get_Outline (null); an_FT_Vector := FT_GlyphSlot_Get_Advance (null); an_FT_Bitmap := FT_GlyphSlot_Get_Bitmap (null); an_FT_Int := FT_GlyphSlot_Get_bitmap_left (null); an_FT_Int := FT_GlyphSlot_Get_bitmap_top (null); an_Unsigned := FT_GlyphSlot_Get_Format (null); an_FT_Size_Metrics := FT_Size_Get_Metrics (null); an_FT_Face := new_FT_Face (null, C.Strings.null_ptr); an_FT_Face := new_FT_Memory_Face (null, null, 0); an_FT_SizeRec := FT_Face_Get_Size (null); an_FT_Long := FT_Face_IS_SCALABLE (null); an_FT_Long := FT_Face_HAS_KERNING (null); an_FT_BBox := FT_Face_Get_BBox (null); an_FT_UShort := FT_Face_Get_units_per_EM (null); an_FT_Long := FT_Face_Get_num_glyphs (null); an_FT_CharMap := FT_Face_Get_charmap (null); an_FT_CharMap := FT_Face_Get_charmap_at (null, 0); an_FT_Int := FT_Face_Get_num_charmaps (null); an_FT_GlyphSlot := FT_Face_Get_glyph (null); an_Error := FT_Face_Attach_Stream (null, null, 0); an_Unsigned := get_FT_GLYPH_FORMAT_NONE; an_Unsigned := get_FT_GLYPH_FORMAT_COMPOSITE; an_Unsigned := get_FT_GLYPH_FORMAT_BITMAP; an_Unsigned := get_FT_GLYPH_FORMAT_OUTLINE; an_Unsigned := get_FT_GLYPH_FORMAT_PLOTTER; an_Unsigned := FT_ENCODING_NONE_enum; an_Unsigned := FT_ENCODING_MS_SYMBOL_enum; an_Unsigned := FT_ENCODING_UNICODE_enum; an_Unsigned := FT_ENCODING_SJIS_enum; an_Unsigned := FT_ENCODING_GB2312_enum; an_Unsigned := FT_ENCODING_BIG5_enum; an_Unsigned := FT_ENCODING_WANSUNG_enum; an_Unsigned := FT_ENCODING_JOHAB_enum; an_Unsigned := FT_ENCODING_ADOBE_STANDARD_enum; an_Unsigned := FT_ENCODING_ADOBE_EXPERT_enum; an_Unsigned := FT_ENCODING_ADOBE_CUSTOM_enum; an_Unsigned := FT_ENCODING_ADOBE_LATIN_1_enum; an_Unsigned := FT_ENCODING_OLD_LATIN_2_enum; an_Unsigned := FT_ENCODING_APPLE_ROMAN_enum; an_Unsigned := FT_LOAD_DEFAULT_flag; an_Unsigned := FT_LOAD_NO_SCALE_flag; an_Unsigned := FT_LOAD_NO_HINTING_flag; an_Unsigned := FT_LOAD_RENDER_flag; an_Unsigned := FT_LOAD_NO_BITMAP_flag; an_Unsigned := FT_LOAD_VERTICAL_LAYOUT_flag; an_Unsigned := FT_LOAD_FORCE_AUTOHINT_flag; an_Unsigned := FT_LOAD_CROP_BITMAP_flag; an_Unsigned := FT_LOAD_PEDANTIC_flag; an_Unsigned := FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH_flag; an_Unsigned := FT_LOAD_NO_RECURSE_flag; an_Unsigned := FT_LOAD_IGNORE_TRANSFORM_flag; an_Unsigned := FT_LOAD_MONOCHROME_flag; an_Unsigned := FT_LOAD_LINEAR_DESIGN_flag; an_Unsigned := FT_LOAD_NO_AUTOHINT_flag; end launch_freetype_linkage_Test;
with ada.Strings.Hash; package body lace.Event is function Hash (the_Kind : in Kind) return ada.Containers.Hash_type is begin return ada.Strings.Hash (String (the_Kind)); end Hash; end lace.Event;
with Clases; package Menu is type Opcion is (Insertar,Mirar,Salir); procedure Pide_Opcion (La_Opcion : out Opcion); procedure Lee_Num_Alumno (Num : out Clases.Num_Alumno); procedure Mensaje_Error (Mensaje : in String); end Menu;
----------------------------------------------------------------------- -- ADO Databases -- Database Objects -- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2018, 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.Strings.Unbounded; with Ada.Streams; with Ada.Calendar; with Util.Refs; with Util.Nullables; package ADO is type Int64 is range -2**63 .. 2**63 - 1; for Int64'Size use 64; type Unsigned64 is mod 2**64; for Unsigned64'Size use 64; DEFAULT_TIME : constant Ada.Calendar.Time; -- ------------------------------ -- Database Identifier -- ------------------------------ -- type Identifier is range -2**47 .. 2**47 - 1; NO_IDENTIFIER : constant Identifier := -1; type Entity_Type is range 0 .. 2**16 - 1; NO_ENTITY_TYPE : constant Entity_Type := 0; type Object_Id is record Id : Identifier; Kind : Entity_Type; end record; pragma Pack (Object_Id); -- ------------------------------ -- Nullable Types -- ------------------------------ -- Most database allow to store a NULL instead of an actual integer, date or string value. -- Unlike Java, there is no easy way to distinguish between a NULL and an actual valid value. -- The <b>Nullable_T</b> types provide a way to specify and check whether a value is null -- or not. subtype Nullable_Boolean is Util.Nullables.Nullable_Boolean; function "=" (Left, Right : in Nullable_Boolean) return Boolean renames Util.Nullables."="; Null_Boolean : constant Nullable_Boolean; -- An integer which can be null. subtype Nullable_Integer is Util.Nullables.Nullable_Integer; function "=" (Left, Right : in Nullable_Integer) return Boolean renames Util.Nullables."="; Null_Integer : constant Nullable_Integer; -- A string which can be null. subtype Nullable_String is Util.Nullables.Nullable_String; Null_String : constant Nullable_String; -- A date which can be null. subtype Nullable_Time is Util.Nullables.Nullable_Time; Null_Time : constant Nullable_Time; -- Return True if the two nullable times are identical (both null or both same time). function "=" (Left, Right : in Nullable_Time) return Boolean; type Nullable_Entity_Type is record Value : Entity_Type := 0; Is_Null : Boolean := True; end record; Null_Entity_Type : constant Nullable_Entity_Type; -- ------------------------------ -- Blob data type -- ------------------------------ -- The <b>Blob</b> type is used to represent database blobs. The data is stored -- in an <b>Ada.Streams.Stream_Element_Array</b> pointed to by the <b>Data</b> member. -- The query statement and bind parameter will use a <b>Blob_Ref</b> which represents -- a reference to the blob data. This is intended to minimize data copy. type Blob (Len : Ada.Streams.Stream_Element_Offset) is new Util.Refs.Ref_Entity with record Data : Ada.Streams.Stream_Element_Array (1 .. Len); end record; type Blob_Access is access all Blob; package Blob_References is new Util.Refs.Indefinite_References (Blob, Blob_Access); subtype Blob_Ref is Blob_References.Ref; subtype Blob_Accessor is Blob_References.Element_Accessor; -- Create a blob with an allocated buffer of <b>Size</b> bytes. function Create_Blob (Size : in Natural) return Blob_Ref; -- Create a blob initialized with the given data buffer. function Create_Blob (Data : in Ada.Streams.Stream_Element_Array) return Blob_Ref; -- Create a blob initialized with the content from the file whose path is <b>Path</b>. -- Raises an IO exception if the file does not exist. function Create_Blob (Path : in String) return Blob_Ref; -- Return a null blob. function Null_Blob return Blob_Ref; private DEFAULT_TIME : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1901, Month => 1, Day => 2, Seconds => 0.0); Null_Boolean : constant Nullable_Boolean := Nullable_Boolean '(Is_Null => True, Value => False); Null_Integer : constant Nullable_Integer := Nullable_Integer '(Is_Null => True, Value => 0); Null_String : constant Nullable_String := Nullable_String '(Is_Null => True, Value => Ada.Strings.Unbounded.Null_Unbounded_String); Null_Time : constant Nullable_Time := Nullable_Time '(Is_Null => True, Value => DEFAULT_TIME); Null_Entity_Type : constant Nullable_Entity_Type := Nullable_Entity_Type '(Is_Null => True, Value => 0); end ADO;
----------------------------------------------------------------------- -- helios-schemas -- Helios schemas -- Copyright (C) 2017, 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.Strings.Fixed; package body Helios.Schemas is function Allocate_Index (From : in Definition_Type_Access) return Value_Index; Root : aliased Definition_Type (Len => 0); Current_Index : Monitor_Index := 0; function Allocate_Index (From : in Definition_Type_Access) return Value_Index is begin if From.Kind = V_NONE and From.Parent = Root'Access then From.Index := From.Index + 1; return From.Index; else return Allocate_Index (From.Parent); end if; end Allocate_Index; -- ------------------------------ -- Returns true if the node has some definition children. -- ------------------------------ function Has_Children (Node : in Definition_Type_Access) return Boolean is begin return Node.Child /= null; end Has_Children; -- ------------------------------ -- Returns true if the node has other nodes that contain values. -- ------------------------------ function Has_Snapshots (Node : in Definition_Type_Access) return Boolean is begin return Node.Child /= null and then Node.Child.Child = null; end Has_Snapshots; -- ------------------------------ -- Returns true if the name is allowed by the filter configuration. -- The filter string is a comma separated list of allowed names. -- The special value "*" allows any name. -- ------------------------------ function Is_Filter_Enable (Name : in String; Filter : in String) return Boolean is Pos : Natural; begin if Filter = "*" then return True; end if; Pos := Ada.Strings.Fixed.Index (Filter, Name); if Pos = 0 then return False; end if; return True; end Is_Filter_Enable; -- ------------------------------ -- Add a new definition node to the definition. -- ------------------------------ function Create_Definition (Into : in Definition_Type_Access; Name : in String; Filter : in String := "*"; Kind : in Value_Type := V_INTEGER) return Definition_Type_Access is Result : Definition_Type_Access; begin if not Is_Filter_Enable (Name, Filter) then return null; end if; Result := new Definition_Type (Len => Name'Length); Result.Kind := Kind; if Kind = V_NONE then Current_Index := Current_Index + 1; Result.Monitor := Current_Index; else Result.Monitor := Into.Monitor; Result.Index := Allocate_Index (Into); end if; Result.Name := Name; Result.Parent := Into; if Into /= null then Result.Next := Into.Child; Into.Child := Result; else Result.Parent := Root'Access; Result.Next := Root.Child; Root.Child := Result; end if; return Result; end Create_Definition; -- ------------------------------ -- Add a definition to the agent. -- ------------------------------ procedure Add_Definition (Into : in Definition_Type_Access; Def : in Definition_Type_Access) is begin Def.Index := Allocate_Index (Into); Def.Monitor := Into.Monitor; Def.Parent := Into; Def.Next := Into.Child; Into.Child := Def; end Add_Definition; -- ------------------------------ -- Find a child definition with the given name. -- Returns null if there is no such definition. -- ------------------------------ function Find_Definition (From : in Definition_Type_Access; Name : in String) return Definition_Type_Access is Node : Definition_Type_Access := From; begin while Node /= null loop if Node.Name = Name then return Node; end if; Node := Node.Next; end loop; return null; end Find_Definition; end Helios.Schemas;
-- { dg-do assemble } package body Array20 is type Arr is array (Positive range <>) of Integer; type P_Arr is access Arr; N : constant P_Arr := null; Table : P_Arr := N; end Array20;
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -- -- SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from rp2040.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; -- QSPI flash execute-in-place block package RP_SVD.XIP_CTRL is pragma Preelaborate; --------------- -- Registers -- --------------- -- Cache control type CTRL_Register is record -- When 1, enable the cache. When the cache is disabled, all XIP -- accesses\n will go straight to the flash, without querying the cache. -- When enabled,\n cacheable XIP accesses will query the cache, and the -- flash will\n not be accessed if the tag matches and the valid bit is -- set.\n\n If the cache is enabled, cache-as-SRAM accesses have no -- effect on the\n cache data RAM, and will produce a bus error -- response. EN : Boolean := True; -- When 1, writes to any alias other than 0x0 (caching, allocating)\n -- will produce a bus fault. When 0, these writes are silently -- ignored.\n In either case, writes to the 0x0 alias will deallocate on -- tag match,\n as usual. ERR_BADWRITE : Boolean := True; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- When 1, the cache memories are powered down. They retain state,\n but -- can not be accessed. This reduces static power dissipation.\n Writing -- 1 to this bit forces CTRL_EN to 0, i.e. the cache cannot\n be enabled -- when powered down.\n Cache-as-SRAM accesses will produce a bus error -- response when\n the cache is powered down. POWER_DOWN : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CTRL_Register use record EN at 0 range 0 .. 0; ERR_BADWRITE at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; POWER_DOWN at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Cache Flush control type FLUSH_Register is record -- After a write operation all bits in the field are cleared (set to -- zero). Write 1 to flush the cache. This clears the tag memory, but\n -- the data memory retains its contents. (This means cache-as-SRAM\n -- contents is not affected by flush or reset.)\n Reading will hold the -- bus (stall the processor) until the flush\n completes. Alternatively -- STAT can be polled until completion. FLUSH : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FLUSH_Register use record FLUSH at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Cache Status type STAT_Register is record -- Read-only. Reads as 0 while a cache flush is in progress, and 1 -- otherwise.\n The cache is flushed whenever the XIP block is reset, -- and also\n when requested via the FLUSH register. FLUSH_READY : Boolean; -- Read-only. When 1, indicates the XIP streaming FIFO is completely -- empty. FIFO_EMPTY : Boolean; -- Read-only. When 1, indicates the XIP streaming FIFO is completely -- full.\n The streaming FIFO is 2 entries deep, so the full and empty\n -- flag allow its level to be ascertained. FIFO_FULL : Boolean; -- unspecified Reserved_3_31 : HAL.UInt29; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for STAT_Register use record FLUSH_READY at 0 range 0 .. 0; FIFO_EMPTY at 0 range 1 .. 1; FIFO_FULL at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype STREAM_ADDR_STREAM_ADDR_Field is HAL.UInt30; -- FIFO stream address type STREAM_ADDR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- The address of the next word to be streamed from flash to the -- streaming FIFO.\n Increments automatically after each flash access.\n -- Write the initial access address here before starting a streaming -- read. STREAM_ADDR : STREAM_ADDR_STREAM_ADDR_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for STREAM_ADDR_Register use record Reserved_0_1 at 0 range 0 .. 1; STREAM_ADDR at 0 range 2 .. 31; end record; subtype STREAM_CTR_STREAM_CTR_Field is HAL.UInt22; -- FIFO stream control type STREAM_CTR_Register is record -- Write a nonzero value to start a streaming read. This will then\n -- progress in the background, using flash idle cycles to transfer\n a -- linear data block from flash to the streaming FIFO.\n Decrements -- automatically (1 at a time) as the stream\n progresses, and halts on -- reaching 0.\n Write 0 to halt an in-progress stream, and discard any -- in-flight\n read, so that a new stream can immediately be started -- (after\n draining the FIFO and reinitialising STREAM_ADDR) STREAM_CTR : STREAM_CTR_STREAM_CTR_Field := 16#0#; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for STREAM_CTR_Register use record STREAM_CTR at 0 range 0 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- QSPI flash execute-in-place block type XIP_CTRL_Peripheral is record -- Cache control CTRL : aliased CTRL_Register; -- Cache Flush control FLUSH : aliased FLUSH_Register; -- Cache Status STAT : aliased STAT_Register; -- Cache Hit counter\n A 32 bit saturating counter that increments upon -- each cache hit,\n i.e. when an XIP access is serviced directly from -- cached data.\n Write any value to clear. CTR_HIT : aliased HAL.UInt32; -- Cache Access counter\n A 32 bit saturating counter that increments -- upon each XIP access,\n whether the cache is hit or not. This -- includes noncacheable accesses.\n Write any value to clear. CTR_ACC : aliased HAL.UInt32; -- FIFO stream address STREAM_ADDR : aliased STREAM_ADDR_Register; -- FIFO stream control STREAM_CTR : aliased STREAM_CTR_Register; -- FIFO stream data\n Streamed data is buffered here, for retrieval by -- the system DMA.\n This FIFO can also be accessed via the XIP_AUX -- slave, to avoid exposing\n the DMA to bus stalls caused by other XIP -- traffic. STREAM_FIFO : aliased HAL.UInt32; end record with Volatile; for XIP_CTRL_Peripheral use record CTRL at 16#0# range 0 .. 31; FLUSH at 16#4# range 0 .. 31; STAT at 16#8# range 0 .. 31; CTR_HIT at 16#C# range 0 .. 31; CTR_ACC at 16#10# range 0 .. 31; STREAM_ADDR at 16#14# range 0 .. 31; STREAM_CTR at 16#18# range 0 .. 31; STREAM_FIFO at 16#1C# range 0 .. 31; end record; -- QSPI flash execute-in-place block XIP_CTRL_Periph : aliased XIP_CTRL_Peripheral with Import, Address => XIP_CTRL_Base; end RP_SVD.XIP_CTRL;
package GESTE_Fonts.FreeMonoOblique12pt7b is Font : constant Bitmap_Font_Ref; private FreeMonoOblique12pt7bBitmaps : aliased constant Font_Bitmap := ( 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#01#, 16#80#, 16#00#, 16#C0#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#30#, 16#00#, 16#18#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#E0#, 16#0C#, 16#60#, 16#06#, 16#30#, 16#07#, 16#38#, 16#03#, 16#18#, 16#01#, 16#8C#, 16#00#, 16#C6#, 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#00#, 16#00#, 16#02#, 16#40#, 16#02#, 16#20#, 16#01#, 16#20#, 16#00#, 16#90#, 16#00#, 16#88#, 16#01#, 16#FF#, 16#00#, 16#24#, 16#00#, 16#12#, 16#00#, 16#12#, 16#00#, 16#7F#, 16#E0#, 16#04#, 16#80#, 16#02#, 16#40#, 16#02#, 16#40#, 16#01#, 16#20#, 16#00#, 16#90#, 16#00#, 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#02#, 16#00#, 16#01#, 16#00#, 16#03#, 16#D0#, 16#02#, 16#18#, 16#02#, 16#04#, 16#02#, 16#00#, 16#01#, 16#80#, 16#00#, 16#60#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#20#, 16#00#, 16#10#, 16#18#, 16#10#, 16#0E#, 16#10#, 16#05#, 16#F0#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 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#0E#, 16#00#, 16#08#, 16#80#, 16#08#, 16#40#, 16#04#, 16#20#, 16#03#, 16#20#, 16#00#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#0E#, 16#00#, 16#38#, 16#00#, 16#23#, 16#80#, 16#02#, 16#20#, 16#02#, 16#10#, 16#01#, 16#08#, 16#00#, 16#CC#, 16#00#, 16#38#, 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#F0#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#18#, 16#00#, 16#34#, 16#60#, 16#11#, 16#40#, 16#10#, 16#A0#, 16#08#, 16#60#, 16#06#, 16#30#, 16#01#, 16#EC#, 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#03#, 16#80#, 16#01#, 16#80#, 16#00#, 16#C0#, 16#00#, 16#E0#, 16#00#, 16#60#, 16#00#, 16#30#, 16#00#, 16#18#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#18#, 16#00#, 16#08#, 16#00#, 16#0C#, 16#00#, 16#04#, 16#00#, 16#06#, 16#00#, 16#03#, 16#00#, 16#01#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#30#, 16#00#, 16#18#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 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#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#60#, 16#00#, 16#30#, 16#00#, 16#18#, 16#00#, 16#0C#, 16#00#, 16#06#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#80#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#C0#, 16#00#, 16#40#, 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#00#, 16#00#, 16#01#, 16#00#, 16#01#, 16#80#, 16#00#, 16#80#, 16#06#, 16#44#, 16#00#, 16#FC#, 16#00#, 16#30#, 16#00#, 16#3C#, 16#00#, 16#32#, 16#00#, 16#11#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#FF#, 16#E0#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 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#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#07#, 16#80#, 16#03#, 16#80#, 16#03#, 16#80#, 16#01#, 16#80#, 16#00#, 16#C0#, 16#00#, 16#C0#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#E0#, 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#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#01#, 16#C0#, 16#00#, 16#E0#, 16#00#, 16#70#, 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#20#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#18#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#0C#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#06#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 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#07#, 16#80#, 16#04#, 16#20#, 16#04#, 16#10#, 16#06#, 16#04#, 16#02#, 16#02#, 16#01#, 16#01#, 16#01#, 16#01#, 16#00#, 16#80#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#20#, 16#08#, 16#10#, 16#04#, 16#10#, 16#03#, 16#18#, 16#00#, 16#F0#, 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#03#, 16#00#, 16#03#, 16#80#, 16#03#, 16#80#, 16#03#, 16#40#, 16#03#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#03#, 16#FE#, 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#07#, 16#80#, 16#0C#, 16#20#, 16#0C#, 16#18#, 16#04#, 16#04#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#06#, 16#00#, 16#06#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#0C#, 16#04#, 16#07#, 16#FE#, 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#07#, 16#80#, 16#0C#, 16#20#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#06#, 16#00#, 16#1C#, 16#00#, 16#03#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#18#, 16#00#, 16#08#, 16#06#, 16#18#, 16#00#, 16#F0#, 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#C0#, 16#00#, 16#A0#, 16#00#, 16#90#, 16#00#, 16#90#, 16#00#, 16#48#, 16#00#, 16#44#, 16#00#, 16#42#, 16#00#, 16#41#, 16#00#, 16#21#, 16#00#, 16#20#, 16#80#, 16#3F#, 16#E0#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#BC#, 16#00#, 16#E3#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#04#, 16#18#, 16#01#, 16#F0#, 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#F0#, 16#01#, 16#80#, 16#01#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#01#, 16#80#, 16#00#, 16#9E#, 16#00#, 16#51#, 16#80#, 16#30#, 16#40#, 16#30#, 16#20#, 16#10#, 16#10#, 16#08#, 16#08#, 16#02#, 16#08#, 16#01#, 16#88#, 16#00#, 16#78#, 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#3F#, 16#E0#, 16#10#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#40#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#80#, 16#04#, 16#20#, 16#04#, 16#08#, 16#04#, 16#04#, 16#02#, 16#02#, 16#01#, 16#02#, 16#00#, 16#42#, 16#00#, 16#1E#, 16#00#, 16#31#, 16#80#, 16#20#, 16#40#, 16#10#, 16#10#, 16#10#, 16#10#, 16#04#, 16#08#, 16#02#, 16#18#, 16#00#, 16#F0#, 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#03#, 16#80#, 16#06#, 16#20#, 16#04#, 16#08#, 16#02#, 16#04#, 16#02#, 16#02#, 16#01#, 16#01#, 16#00#, 16#C1#, 16#80#, 16#23#, 16#40#, 16#0F#, 16#40#, 16#00#, 16#20#, 16#00#, 16#30#, 16#00#, 16#10#, 16#00#, 16#30#, 16#00#, 16#30#, 16#03#, 16#E0#, 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#38#, 16#00#, 16#3C#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#E0#, 16#00#, 16#70#, 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#70#, 16#00#, 16#38#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#C0#, 16#01#, 16#C0#, 16#01#, 16#C0#, 16#00#, 16#C0#, 16#00#, 16#C0#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#06#, 16#00#, 16#0C#, 16#00#, 16#18#, 16#00#, 16#30#, 16#00#, 16#60#, 16#00#, 16#60#, 16#00#, 16#18#, 16#00#, 16#03#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#18#, 16#00#, 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#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#03#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#F0#, 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#00#, 16#06#, 16#00#, 16#01#, 16#80#, 16#00#, 16#30#, 16#00#, 16#0C#, 16#00#, 16#01#, 16#80#, 16#00#, 16#60#, 16#00#, 16#C0#, 16#01#, 16#80#, 16#03#, 16#00#, 16#06#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 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#03#, 16#E0#, 16#06#, 16#18#, 16#02#, 16#04#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#03#, 16#00#, 16#06#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#70#, 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#07#, 16#80#, 16#04#, 16#20#, 16#04#, 16#10#, 16#04#, 16#08#, 16#02#, 16#04#, 16#01#, 16#0E#, 16#01#, 16#19#, 16#00#, 16#90#, 16#80#, 16#48#, 16#80#, 16#26#, 16#40#, 16#21#, 16#E0#, 16#10#, 16#00#, 16#08#, 16#00#, 16#02#, 16#00#, 16#01#, 16#80#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#01#, 16#40#, 16#00#, 16#A0#, 16#00#, 16#90#, 16#00#, 16#48#, 16#00#, 16#42#, 16#00#, 16#41#, 16#00#, 16#20#, 16#80#, 16#3F#, 16#C0#, 16#10#, 16#20#, 16#10#, 16#10#, 16#08#, 16#04#, 16#08#, 16#02#, 16#1F#, 16#0F#, 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#3F#, 16#E0#, 16#04#, 16#18#, 16#04#, 16#04#, 16#02#, 16#02#, 16#01#, 16#01#, 16#00#, 16#83#, 16#00#, 16#7F#, 16#00#, 16#40#, 16#40#, 16#20#, 16#10#, 16#10#, 16#08#, 16#08#, 16#04#, 16#08#, 16#04#, 16#04#, 16#04#, 16#0F#, 16#FC#, 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#03#, 16#E8#, 16#06#, 16#1C#, 16#04#, 16#06#, 16#04#, 16#01#, 16#02#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#04#, 16#03#, 16#0C#, 16#00#, 16#F8#, 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#3F#, 16#C0#, 16#08#, 16#30#, 16#04#, 16#04#, 16#02#, 16#02#, 16#02#, 16#01#, 16#01#, 16#00#, 16#80#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#20#, 16#10#, 16#10#, 16#08#, 16#08#, 16#08#, 16#04#, 16#18#, 16#0F#, 16#F0#, 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#3F#, 16#F8#, 16#04#, 16#04#, 16#04#, 16#04#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#88#, 16#00#, 16#7C#, 16#00#, 16#42#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#08#, 16#08#, 16#04#, 16#04#, 16#02#, 16#0F#, 16#FF#, 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#3F#, 16#F8#, 16#04#, 16#04#, 16#04#, 16#02#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#88#, 16#00#, 16#7C#, 16#00#, 16#42#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#0F#, 16#E0#, 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#03#, 16#E8#, 16#06#, 16#1C#, 16#06#, 16#02#, 16#06#, 16#01#, 16#02#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#41#, 16#F8#, 16#20#, 16#10#, 16#10#, 16#08#, 16#08#, 16#04#, 16#03#, 16#02#, 16#00#, 16#FE#, 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#1E#, 16#78#, 16#04#, 16#08#, 16#04#, 16#04#, 16#02#, 16#02#, 16#01#, 16#02#, 16#00#, 16#81#, 16#00#, 16#7F#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#20#, 16#08#, 16#10#, 16#04#, 16#08#, 16#04#, 16#04#, 16#0F#, 16#8F#, 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#1F#, 16#F0#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#03#, 16#FE#, 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#03#, 16#FE#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#10#, 16#08#, 16#10#, 16#06#, 16#10#, 16#01#, 16#F0#, 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#3E#, 16#3C#, 16#04#, 16#08#, 16#04#, 16#18#, 16#02#, 16#18#, 16#01#, 16#10#, 16#00#, 16#90#, 16#00#, 16#78#, 16#00#, 16#62#, 16#00#, 16#20#, 16#80#, 16#10#, 16#40#, 16#08#, 16#20#, 16#08#, 16#08#, 16#04#, 16#04#, 16#0F#, 16#83#, 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#3F#, 16#80#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#08#, 16#04#, 16#04#, 16#02#, 16#04#, 16#01#, 16#02#, 16#07#, 16#FF#, 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#78#, 16#0E#, 16#14#, 16#0C#, 16#0A#, 16#0A#, 16#05#, 16#05#, 16#02#, 16#84#, 16#82#, 16#24#, 16#41#, 16#12#, 16#40#, 16#8A#, 16#20#, 16#45#, 16#10#, 16#23#, 16#08#, 16#20#, 16#04#, 16#10#, 16#04#, 16#08#, 16#02#, 16#1F#, 16#0F#, 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#78#, 16#7C#, 16#0C#, 16#04#, 16#07#, 16#04#, 16#02#, 16#82#, 16#02#, 16#41#, 16#01#, 16#30#, 16#80#, 16#88#, 16#40#, 16#44#, 16#40#, 16#21#, 16#20#, 16#20#, 16#90#, 16#10#, 16#68#, 16#08#, 16#14#, 16#04#, 16#0C#, 16#0F#, 16#82#, 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#03#, 16#C0#, 16#06#, 16#18#, 16#04#, 16#04#, 16#04#, 16#03#, 16#02#, 16#00#, 16#82#, 16#00#, 16#41#, 16#00#, 16#20#, 16#80#, 16#20#, 16#80#, 16#10#, 16#40#, 16#08#, 16#10#, 16#08#, 16#08#, 16#08#, 16#02#, 16#18#, 16#00#, 16#F0#, 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#3F#, 16#C0#, 16#04#, 16#18#, 16#04#, 16#04#, 16#02#, 16#02#, 16#01#, 16#01#, 16#00#, 16#81#, 16#00#, 16#81#, 16#00#, 16#7F#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#0F#, 16#E0#, 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#03#, 16#C0#, 16#06#, 16#18#, 16#04#, 16#04#, 16#04#, 16#03#, 16#02#, 16#00#, 16#82#, 16#00#, 16#41#, 16#00#, 16#20#, 16#80#, 16#20#, 16#80#, 16#10#, 16#40#, 16#08#, 16#10#, 16#08#, 16#08#, 16#08#, 16#02#, 16#18#, 16#00#, 16#F8#, 16#00#, 16#60#, 16#00#, 16#7C#, 16#40#, 16#61#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#04#, 16#18#, 16#04#, 16#04#, 16#02#, 16#02#, 16#01#, 16#01#, 16#00#, 16#81#, 16#00#, 16#41#, 16#00#, 16#7F#, 16#00#, 16#21#, 16#80#, 16#10#, 16#40#, 16#08#, 16#10#, 16#08#, 16#08#, 16#04#, 16#02#, 16#0F#, 16#81#, 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#03#, 16#D0#, 16#06#, 16#18#, 16#06#, 16#04#, 16#02#, 16#02#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#30#, 16#00#, 16#07#, 16#80#, 16#00#, 16#20#, 16#00#, 16#10#, 16#10#, 16#08#, 16#08#, 16#08#, 16#0A#, 16#0C#, 16#04#, 16#F8#, 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#3F#, 16#F8#, 16#10#, 16#84#, 16#08#, 16#42#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#01#, 16#FC#, 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#3E#, 16#7C#, 16#08#, 16#04#, 16#04#, 16#04#, 16#02#, 16#02#, 16#02#, 16#01#, 16#01#, 16#00#, 16#80#, 16#80#, 16#40#, 16#40#, 16#40#, 16#20#, 16#20#, 16#20#, 16#10#, 16#10#, 16#08#, 16#08#, 16#08#, 16#02#, 16#18#, 16#00#, 16#F0#, 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#7C#, 16#3E#, 16#10#, 16#04#, 16#04#, 16#02#, 16#02#, 16#02#, 16#01#, 16#02#, 16#00#, 16#81#, 16#00#, 16#41#, 16#00#, 16#20#, 16#80#, 16#08#, 16#80#, 16#04#, 16#80#, 16#02#, 16#40#, 16#01#, 16#40#, 16#00#, 16#A0#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#3E#, 16#10#, 16#04#, 16#08#, 16#02#, 16#04#, 16#21#, 16#02#, 16#31#, 16#01#, 16#18#, 16#80#, 16#94#, 16#40#, 16#4A#, 16#20#, 16#48#, 16#A0#, 16#24#, 16#50#, 16#14#, 16#28#, 16#0A#, 16#18#, 16#06#, 16#0C#, 16#03#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#3C#, 16#08#, 16#08#, 16#02#, 16#08#, 16#01#, 16#08#, 16#00#, 16#48#, 16#00#, 16#3C#, 16#00#, 16#0C#, 16#00#, 16#0E#, 16#00#, 16#0D#, 16#00#, 16#04#, 16#C0#, 16#04#, 16#20#, 16#04#, 16#08#, 16#04#, 16#04#, 16#0F#, 16#0F#, 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#3C#, 16#3C#, 16#0C#, 16#08#, 16#02#, 16#08#, 16#01#, 16#0C#, 16#00#, 16#44#, 16#00#, 16#24#, 16#00#, 16#1C#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#01#, 16#FC#, 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#0F#, 16#F0#, 16#08#, 16#08#, 16#04#, 16#08#, 16#02#, 16#08#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#0C#, 16#00#, 16#0C#, 16#10#, 16#04#, 16#08#, 16#04#, 16#08#, 16#04#, 16#04#, 16#03#, 16#FE#, 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#01#, 16#E0#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 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#20#, 16#00#, 16#10#, 16#00#, 16#0C#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 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#0F#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#78#, 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#01#, 16#80#, 16#01#, 16#20#, 16#01#, 16#10#, 16#01#, 16#04#, 16#01#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 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#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#03#, 16#FF#, 16#F0#, 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#00#, 16#08#, 16#00#, 16#02#, 16#00#, 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#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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#02#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#1F#, 16#C0#, 16#30#, 16#20#, 16#10#, 16#10#, 16#10#, 16#18#, 16#0C#, 16#38#, 16#03#, 16#E7#, 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#60#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#02#, 16#7C#, 16#01#, 16#61#, 16#00#, 16#C0#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#20#, 16#08#, 16#10#, 16#0C#, 16#0C#, 16#04#, 16#07#, 16#0C#, 16#0E#, 16#78#, 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#7D#, 16#00#, 16#C1#, 16#80#, 16#80#, 16#40#, 16#40#, 16#20#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#04#, 16#02#, 16#0C#, 16#00#, 16#F8#, 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#70#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#79#, 16#00#, 16#C2#, 16#80#, 16#80#, 16#C0#, 16#80#, 16#40#, 16#40#, 16#20#, 16#40#, 16#10#, 16#20#, 16#08#, 16#08#, 16#0C#, 16#06#, 16#1C#, 16#01#, 16#F3#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#C3#, 16#00#, 16#80#, 16#80#, 16#80#, 16#20#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#06#, 16#06#, 16#00#, 16#FC#, 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#01#, 16#F8#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#01#, 16#FF#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#03#, 16#FE#, 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#F9#, 16#C0#, 16#87#, 16#00#, 16#81#, 16#80#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#20#, 16#10#, 16#10#, 16#08#, 16#18#, 16#06#, 16#14#, 16#01#, 16#F2#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 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#70#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#7C#, 16#00#, 16#C3#, 16#00#, 16#40#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#30#, 16#08#, 16#10#, 16#08#, 16#08#, 16#04#, 16#04#, 16#0F#, 16#8F#, 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#03#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#07#, 16#FE#, 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#80#, 16#00#, 16#40#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#1F#, 16#00#, 16#84#, 16#00#, 16#4C#, 16#00#, 16#28#, 16#00#, 16#1C#, 16#00#, 16#13#, 16#00#, 16#08#, 16#80#, 16#04#, 16#20#, 16#02#, 16#08#, 16#07#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#07#, 16#FE#, 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#0E#, 16#E7#, 16#01#, 16#9C#, 16#81#, 16#08#, 16#40#, 16#84#, 16#20#, 16#42#, 16#10#, 16#21#, 16#08#, 16#21#, 16#04#, 16#10#, 16#84#, 16#08#, 16#42#, 16#1E#, 16#31#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#3C#, 16#00#, 16#E3#, 16#00#, 16#40#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#20#, 16#08#, 16#10#, 16#04#, 16#08#, 16#04#, 16#04#, 16#0F#, 16#8F#, 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#7C#, 16#00#, 16#C3#, 16#00#, 16#80#, 16#C0#, 16#80#, 16#20#, 16#40#, 16#10#, 16#20#, 16#08#, 16#10#, 16#08#, 16#08#, 16#08#, 16#02#, 16#08#, 16#00#, 16#F8#, 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#06#, 16#7C#, 16#01#, 16#61#, 16#00#, 16#C0#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#30#, 16#08#, 16#18#, 16#0C#, 16#0C#, 16#04#, 16#05#, 16#0C#, 16#02#, 16#78#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#01#, 16#F8#, 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#F9#, 16#C0#, 16#C2#, 16#80#, 16#80#, 16#C0#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#10#, 16#18#, 16#08#, 16#14#, 16#06#, 16#14#, 16#00#, 16#F2#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#03#, 16#F0#, 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#01#, 16#C7#, 16#80#, 16#2C#, 16#00#, 16#18#, 16#00#, 16#18#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#07#, 16#FC#, 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#7A#, 16#00#, 16#C3#, 16#00#, 16#40#, 16#80#, 16#20#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#60#, 16#00#, 16#18#, 16#08#, 16#08#, 16#06#, 16#0C#, 16#02#, 16#F8#, 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#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#0C#, 16#00#, 16#F8#, 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#07#, 16#0F#, 16#00#, 16#81#, 16#00#, 16#40#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#10#, 16#20#, 16#08#, 16#10#, 16#04#, 16#08#, 16#02#, 16#1C#, 16#01#, 16#F3#, 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#07#, 16#C7#, 16#C1#, 16#00#, 16#80#, 16#40#, 16#80#, 16#20#, 16#80#, 16#10#, 16#40#, 16#08#, 16#40#, 16#02#, 16#40#, 16#01#, 16#20#, 16#00#, 16#A0#, 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#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#07#, 16#83#, 16#C1#, 16#00#, 16#80#, 16#80#, 16#40#, 16#46#, 16#40#, 16#25#, 16#20#, 16#12#, 16#90#, 16#0A#, 16#50#, 16#06#, 16#28#, 16#03#, 16#18#, 16#01#, 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#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#03#, 16#C7#, 16#80#, 16#81#, 16#00#, 16#23#, 16#00#, 16#0B#, 16#00#, 16#06#, 16#00#, 16#03#, 16#80#, 16#06#, 16#40#, 16#06#, 16#10#, 16#04#, 16#04#, 16#0F#, 16#8F#, 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#07#, 16#87#, 16#81#, 16#00#, 16#80#, 16#40#, 16#80#, 16#20#, 16#80#, 16#10#, 16#40#, 16#0C#, 16#40#, 16#02#, 16#40#, 16#01#, 16#40#, 16#00#, 16#A0#, 16#00#, 16#20#, 16#00#, 16#20#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#FC#, 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#01#, 16#FE#, 16#00#, 16#83#, 16#00#, 16#03#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#00#, 16#02#, 16#04#, 16#03#, 16#FE#, 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#C0#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#08#, 16#00#, 16#0C#, 16#00#, 16#18#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#04#, 16#00#, 16#02#, 16#00#, 16#01#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 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#06#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 16#08#, 16#00#, 16#02#, 16#00#, 16#00#, 16#C0#, 16#01#, 16#80#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#40#, 16#00#, 16#20#, 16#00#, 16#10#, 16#00#, 16#10#, 16#00#, 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#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#70#, 16#40#, 16#44#, 16#40#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#); Font_D : aliased constant Bitmap_Font := ( Bytes_Per_Glyph => 51, Glyph_Width => 17, Glyph_Height => 24, Data => FreeMonoOblique12pt7bBitmaps'Access); Font : constant Bitmap_Font_Ref := Font_D'Access; end GESTE_Fonts.FreeMonoOblique12pt7b;
----------------------------------------------------------------------- -- AUnit utils - Helper for writing unit tests -- Copyright (C) 2009, 2010, 2011, 2012, 2013 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 GNAT.Command_Line; with GNAT.Regpat; with GNAT.Traceback.Symbolic; with Ada.Command_Line; with Ada.Directories; with Ada.IO_Exceptions; with Ada.Text_IO; with Ada.Calendar.Formatting; with Ada.Exceptions; with Util.Strings; with Util.Measures; with Util.Files; with Util.Log.Loggers; package body Util.Tests is Test_Properties : Util.Properties.Manager; -- When a test uses external test files to match a result against a well -- defined content, it can be difficult to maintain those external files. -- The <b>Assert_Equal_Files</b> can automatically maintain the reference -- file by updating it with the lastest test result. -- -- Of course, using this mode means the test does not validate anything. Update_Test_Files : Boolean := False; -- The default timeout for a test case execution. Default_Timeout : Duration := 60.0; -- A prefix that is added to the test class names. Adding a prefix is useful when -- the same testsuite is executed several times with different configurations. It allows -- to track and identify the tests in different environments and have a global view -- in Jenkins. See option '-p prefix'. Harness_Prefix : Unbounded_String; -- Verbose flag activated by the '-v' option. Verbose_Flag : Boolean := False; -- When not empty, defines the name of the test that is enabled. Other tests are disabled. -- This is initialized by the -r test option. Enabled_Test : Unbounded_String; -- ------------------------------ -- Get a path to access a test file. -- ------------------------------ function Get_Path (File : String) return String is Dir : constant String := Get_Parameter ("test.dir", "."); begin return Dir & "/" & File; end Get_Path; -- ------------------------------ -- Get a path to create a test file. -- ------------------------------ function Get_Test_Path (File : String) return String is Dir : constant String := Get_Parameter ("test.result.dir", "."); begin return Dir & "/" & File; end Get_Test_Path; -- ------------------------------ -- Get the timeout for the test execution. -- ------------------------------ function Get_Test_Timeout (Name : in String) return Duration is Prop_Name : constant String := "test.timeout." & Name; Value : constant String := Test_Properties.Get (Prop_Name, Duration'Image (Default_Timeout)); begin return Duration'Value (Value); exception when Constraint_Error => return Default_Timeout; end Get_Test_Timeout; -- ------------------------------ -- Get the testsuite harness prefix. This prefix is added to the test class name. -- By default it is empty. It is allows to execute the test harness on different -- environment (ex: MySQL or SQLlite) and be able to merge and collect the two result -- sets together. -- ------------------------------ function Get_Harness_Prefix return String is begin return To_String (Harness_Prefix); end Get_Harness_Prefix; -- ------------------------------ -- Get a test configuration parameter. -- ------------------------------ function Get_Parameter (Name : String; Default : String := "") return String is begin return Test_Properties.Get (Name, Default); end Get_Parameter; -- ------------------------------ -- Get the test configuration properties. -- ------------------------------ function Get_Properties return Util.Properties.Manager is begin return Test_Properties; end Get_Properties; -- ------------------------------ -- Get a new unique string -- ------------------------------ function Get_Uuid return String is Time : constant Ada.Calendar.Time := Ada.Calendar.Clock; Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; T : Ada.Calendar.Day_Duration; V : Long_Long_Integer; begin Ada.Calendar.Split (Date => Time, Year => Year, Month => Month, Day => Day, Seconds => T); V := (Long_Long_Integer (Year) * 365 * 24 * 3600 * 1000) + (Long_Long_Integer (Month) * 31 * 24 * 3600 * 1000) + (Long_Long_Integer (Day) * 24 * 3600 * 1000) + (Long_Long_Integer (T * 1000)); return "U" & Util.Strings.Image (V); end Get_Uuid; -- ------------------------------ -- Get the verbose flag that can be activated with the <tt>-v</tt> option. -- ------------------------------ function Verbose return Boolean is begin return Verbose_Flag; end Verbose; -- ------------------------------ -- Returns True if the test with the given name is enabled. -- By default all the tests are enabled. When the -r test option is passed -- all the tests are disabled except the test specified by the -r option. -- ------------------------------ function Is_Test_Enabled (Name : in String) return Boolean is begin return Length (Enabled_Test) = 0 or Enabled_Test = Name; end Is_Test_Enabled; -- ------------------------------ -- Check that the value matches what we expect. -- ------------------------------ procedure Assert_Equals (T : in Test'Class; Expect, Value : in Ada.Calendar.Time; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is use Ada.Calendar.Formatting; use Ada.Calendar; begin T.Assert (Condition => Image (Expect) = Image (Value), Message => Message & ": expecting '" & Image (Expect) & "'" & " value was '" & Image (Value) & "'", Source => Source, Line => Line); end Assert_Equals; -- ------------------------------ -- Check that the value matches what we expect. -- ------------------------------ procedure Assert_Equals (T : in Test'Class; Expect, Value : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is begin T.Assert (Condition => Expect = Value, Message => Message & ": expecting '" & Expect & "'" & " value was '" & Value & "'", Source => Source, Line => Line); end Assert_Equals; -- ------------------------------ -- Check that the value matches what we expect. -- ------------------------------ procedure Assert_Equals (T : in Test'Class; Expect : in String; Value : in Unbounded_String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is begin Assert_Equals (T => T, Expect => Expect, Value => To_String (Value), Message => Message, Source => Source, Line => Line); end Assert_Equals; -- ------------------------------ -- Check that the value matches the regular expression -- ------------------------------ procedure Assert_Matches (T : in Test'Class; Pattern : in String; Value : in Unbounded_String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is begin Assert_Matches (T => T, Pattern => Pattern, Value => To_String (Value), Message => Message, Source => Source, Line => Line); end Assert_Matches; -- ------------------------------ -- Check that the value matches the regular expression -- ------------------------------ procedure Assert_Matches (T : in Test'Class; Pattern : in String; Value : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is use GNAT.Regpat; Regexp : constant Pattern_Matcher := Compile (Expression => Pattern, Flags => Multiple_Lines); begin T.Assert (Condition => Match (Regexp, Value), Message => Message & ". Value '" & Value & "': Does not Match '" & Pattern & "'", Source => Source, Line => Line); end Assert_Matches; -- ------------------------------ -- Check that the file exists. -- ------------------------------ procedure Assert_Exists (T : in Test'Class; File : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is begin T.Assert (Condition => Ada.Directories.Exists (File), Message => Message & ": file '" & File & "' does not exist", Source => Source, Line => Line); end Assert_Exists; -- ------------------------------ -- Check that two files are equal. This is intended to be used by -- tests that create files that are then checked against patterns. -- ------------------------------ procedure Assert_Equal_Files (T : in Test_Case'Class; Expect : in String; Test : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is use Util.Files; Expect_File : Unbounded_String; Test_File : Unbounded_String; Same : Boolean; begin begin if not Ada.Directories.Exists (Expect) then T.Assert (Condition => False, Message => "Expect file '" & Expect & "' does not exist", Source => Source, Line => Line); end if; Read_File (Path => Expect, Into => Expect_File); Read_File (Path => Test, Into => Test_File); exception when others => if Update_Test_Files then Ada.Directories.Copy_File (Source_Name => Test, Target_Name => Expect); else raise; end if; end; -- Check file sizes Assert_Equals (T => T, Expect => Length (Expect_File), Value => Length (Test_File), Message => Message & ": Invalid file sizes", Source => Source, Line => Line); Same := Expect_File = Test_File; if Same then return; end if; end Assert_Equal_Files; -- ------------------------------ -- Check that two files are equal. This is intended to be used by -- tests that create files that are then checked against patterns. -- ------------------------------ procedure Assert_Equal_Files (T : in Test'Class; Expect : in String; Test : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is use Util.Files; Expect_File : Unbounded_String; Test_File : Unbounded_String; Same : Boolean; begin begin if not Ada.Directories.Exists (Expect) then T.Assert (Condition => False, Message => "Expect file '" & Expect & "' does not exist", Source => Source, Line => Line); end if; Read_File (Path => Expect, Into => Expect_File); Read_File (Path => Test, Into => Test_File); exception when others => if Update_Test_Files then Ada.Directories.Copy_File (Source_Name => Test, Target_Name => Expect); else raise; end if; end; -- Check file sizes Assert_Equals (T => T, Expect => Length (Expect_File), Value => Length (Test_File), Message => Message & ": Invalid file sizes", Source => Source, Line => Line); Same := Expect_File = Test_File; if Same then return; end if; end Assert_Equal_Files; -- ------------------------------ -- Report a test failed. -- ------------------------------ procedure Fail (T : in Test'Class; Message : in String := "Test failed"; Source : in String := GNAT.Source_Info.File; Line : in Natural := GNAT.Source_Info.Line) is begin T.Assert (False, Message, Source, Line); end Fail; -- ------------------------------ -- Default initialization procedure. -- ------------------------------ procedure Initialize_Test (Props : in Util.Properties.Manager) is begin null; end Initialize_Test; -- ------------------------------ -- The main testsuite program. This launches the tests, collects the -- results, create performance logs and set the program exit status -- according to the testsuite execution status. -- -- The <b>Initialize</b> procedure is called before launching the unit tests. It is intended -- to configure the tests according to some external environment (paths, database access). -- -- The <b>Finish</b> procedure is called after the test suite has executed. -- ------------------------------ procedure Harness (Name : in String) is use GNAT.Command_Line; use Ada.Text_IO; use type Util.XUnit.Status; procedure Help; procedure Help is begin Put_Line ("Test harness: " & Name); Put ("Usage: harness [-xml result.xml] [-t timeout] [-p prefix] [-v]" & "[-config file.properties] [-d dir] [-r testname]"); Put_Line ("[-update]"); Put_Line ("-xml file Produce an XML test report"); Put_Line ("-config file Specify a test configuration file"); Put_Line ("-d dir Change the current directory to <dir>"); Put_Line ("-t timeout Test execution timeout in seconds"); Put_Line ("-v Activate the verbose test flag"); Put_Line ("-p prefix Add the prefix to the test class names"); Put_Line ("-r testname Run only the tests for the given testsuite name"); Put_Line ("-update Update the test reference files if a file"); Put_Line (" is missing or the test generates another output"); Put_Line (" (See Assert_Equals_File)"); Ada.Command_Line.Set_Exit_Status (2); end Help; Perf : aliased Util.Measures.Measure_Set; Result : Util.XUnit.Status; XML : Boolean := False; Output : Ada.Strings.Unbounded.Unbounded_String; Chdir : Ada.Strings.Unbounded.Unbounded_String; begin loop case Getopt ("h u v x: t: p: c: config: d: r: update help xml: timeout:") is when ASCII.NUL => exit; when 'c' => declare Name : constant String := Parameter; begin Test_Properties.Load_Properties (Name); Default_Timeout := Get_Test_Timeout ("default"); exception when Ada.IO_Exceptions.Name_Error => Ada.Text_IO.Put_Line ("Cannot find configuration file: " & Name); Ada.Command_Line.Set_Exit_Status (2); return; end; when 'd' => Chdir := To_Unbounded_String (Parameter); when 'u' => Update_Test_Files := True; when 't' => begin Default_Timeout := Duration'Value (Parameter); exception when Constraint_Error => Ada.Text_IO.Put_Line ("Invalid timeout: " & Parameter); Ada.Command_Line.Set_Exit_Status (2); return; end; when 'r' => Enabled_Test := To_Unbounded_String (Parameter); when 'p' => Harness_Prefix := To_Unbounded_String (Parameter & " "); when 'v' => Verbose_Flag := True; when 'x' => XML := True; Output := To_Unbounded_String (Parameter); when others => Help; return; end case; end loop; -- Initialization is optional. Get the log configuration by reading the property -- file 'samples/log4j.properties'. The 'log.util' logger will use a DEBUG level -- and write the message in 'result.log'. Util.Log.Loggers.Initialize (Test_Properties); Initialize (Test_Properties); if Length (Chdir) /= 0 then begin Ada.Directories.Set_Directory (To_String (Chdir)); exception when Ada.IO_Exceptions.Name_Error => Put_Line ("Invalid directory " & To_String (Chdir)); Ada.Command_Line.Set_Exit_Status (1); return; end; end if; declare procedure Runner is new Util.XUnit.Harness (Suite); S : Util.Measures.Stamp; begin Util.Measures.Set_Current (Perf'Unchecked_Access); Runner (Output, XML, Result); Util.Measures.Report (Perf, S, "Testsuite execution"); Util.Measures.Write (Perf, "Test measures", Name); end; Finish (Result); -- Program exit status reflects the testsuite result if Result /= Util.XUnit.Success then Ada.Command_Line.Set_Exit_Status (1); else Ada.Command_Line.Set_Exit_Status (0); end if; exception when Invalid_Switch => Put_Line ("Invalid Switch " & Full_Switch); Help; return; when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); Help; return; when E : others => Put_Line ("Exception: " & Ada.Exceptions.Exception_Name (E)); Put_Line ("Message: " & Ada.Exceptions.Exception_Message (E)); Put_Line ("Stacktrace:"); Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); Ada.Command_Line.Set_Exit_Status (4); end Harness; end Util.Tests;
----------------------------------------------------------------------- -- search-positions -- Token positions -- 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.Streams; private with Util.Refs; -- == Positions == -- A compact data structure intended to record the positions of a token with a document field. -- While indexing a document field, the token position is added to the list. It is expected -- that a new token position is always greater or equal than previous one. package Search.Positions is type Position_Type is tagged private; -- Initialize the positions with the data stream. procedure Initialize (Positions : in out Position_Type; Data : in Ada.Streams.Stream_Element_Array); -- Get the last recorded position. function Last (Positions : in Position_Type) return Natural; -- Add the position to the list of positions. procedure Add (Positions : in out Position_Type; Value : in Natural) with Pre => Value >= Last (Positions); -- Give access to the packed array representing the collected positions. procedure Pack (Positions : in Position_Type; Process : not null access procedure (Data : in Ada.Streams.Stream_Element_Array)); -- Write the list of positions in the stream. procedure Write (Stream : access Ada.Streams.Root_Stream_Type'Class; Positions : in Position_Type); -- Read a list of positions from the stream. function Read (Stream : access Ada.Streams.Root_Stream_Type'Class) return Position_Type; private subtype Stream_Element_Size is Ada.Streams.Stream_Element_Offset range 0 .. Ada.Streams.Stream_Element_Offset'Last; type Position_Content_Type (Length : Stream_Element_Size) is limited new Util.Refs.Ref_Entity with record Size : Stream_Element_Size := 0; Last : Natural := 0; Data : Ada.Streams.Stream_Element_Array (1 .. Length); end record; type Position_Content_Access is access all Position_Content_Type'Class; package Position_Refs is new Util.Refs.Indefinite_References (Element_Type => Position_Content_Type'Class, Element_Access => Position_Content_Access); type Position_Type is new Position_Refs.Ref with null record; end Search.Positions;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with soc.exti; with ewok.exported.gpios; package ewok.exti with spark_mode => off is exti_line_registered : array (soc.exti.t_exti_line_index) of boolean := (others => false); --------------- -- Functions -- --------------- -- Initialize the EXTI module procedure init; -- Disable a given line procedure disable (ref : in ewok.exported.gpios.t_gpio_ref) with inline; -- Enable (i.e. activate at EXTI and NVIC level) the EXTI line. -- This is done by calling soc_exti_enable() only. No generic call here. procedure enable (ref : in ewok.exported.gpios.t_gpio_ref); -- Return true if EXTI line is already registered. function is_used (ref : ewok.exported.gpios.t_gpio_ref) return boolean; -- Brief Register a new EXTI line. -- Check that the EXTI line is not already registered. procedure register (conf : in ewok.exported.gpios.t_gpio_config_access; success : out boolean); procedure release (conf : in ewok.exported.gpios.t_gpio_config_access); end ewok.exti;
-- ----------------------------------------------------------------- -- -- -- -- This is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- ----------------------------------------------------------------- -- -- ----------------------------------------------------------------- -- -- This is a translation, to the Ada programming language, of the -- -- original C test files written by Sam Lantinga - www.libsdl.org -- -- translation made by Antonio F. Vargas - www.adapower.net/~avargas -- -- ----------------------------------------------------------------- -- -- ----------------------------------------------------------------- -- -- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING -- ----------------------------------------------------------------- -- -- SERIOUS WARNING: The Ada code in this files may, at some points, -- rely directly on pointer arithmetic which is considered very -- unsafe and PRONE TO ERROR. The AdaSDL_Mixer examples are -- more appropriate and easier to understand. They should be used in -- replacement of this files. Please go there. -- This file exists only for the sake of completness and to test -- AdaSDL without the dependency of AdaSDL_Mixer. -- ----------------------------------------------------------------- -- -- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING -- ----------------------------------------------------------------- -- with Interfaces.C; with Interfaces.C.Pointers; with SDL.Types; use SDL.Types; with SDL.Audio; package Loopwave_Callback is package A renames SDL.Audio; package C renames Interfaces.C; use type C.int; done : C.int := 0; type Wave_Type is record spec : aliased A.AudioSpec; sound : aliased Uint8_ptr; -- Pointer do wave data soundlen : aliased Uint32; -- Length of wave data soundpos : C.int; -- Current play position end record; pragma Convention (C, Wave_Type); wave : Wave_Type; procedure fillerup (userdata : void_ptr; the_stream : Uint8_ptr; the_len : C.int); pragma Convention (C, fillerup); procedure poked (sig : C.int); pragma Convention (C, poked); end Loopwave_Callback;
-- 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. with Ada.Numerics.Generic_Elementary_Functions; package body Orka.Transforms.SIMD_Quaternions is package EF is new Ada.Numerics.Generic_Elementary_Functions (Vectors.Element_Type); function Vector_Part (Elements : Quaternion) return Vector4 is begin return Result : Vector4 := Vector4 (Elements) do Result (W) := 0.0; end return; end Vector_Part; function "+" (Left, Right : Quaternion) return Quaternion is use Vectors; begin return Quaternion (Vector4 (Left) + Vector4 (Right)); end "+"; function "*" (Left, Right : Quaternion) return Quaternion is use Vectors; Lv : constant Vector4 := Vector_Part (Left); Rv : constant Vector4 := Vector_Part (Right); Ls : constant Vectors.Element_Type := Left (W); Rs : constant Vectors.Element_Type := Right (W); V : constant Vector4 := Ls * Rv + Rs * Lv + Vectors.Cross (Lv, Rv); S : constant Element_Type := Ls * Rs - Vectors.Dot (Lv, Rv); begin return Result : Quaternion := Quaternion (V) do Result (W) := S; end return; end "*"; function "*" (Left : Vectors.Element_Type; Right : Quaternion) return Quaternion is use Vectors; begin return Quaternion (Left * Vector4 (Right)); end "*"; function "*" (Left : Quaternion; Right : Vectors.Element_Type) return Quaternion is (Right * Left); -- Scalar multiplication is commutative function Conjugate (Elements : Quaternion) return Quaternion is Element_W : constant Vectors.Element_Type := Elements (W); use Vectors; begin return Result : Quaternion := Quaternion (-Vector4 (Elements)) do Result (W) := Element_W; end return; end Conjugate; function Inverse (Elements : Quaternion) return Quaternion is Length : constant Vectors.Element_Type := Vectors.Magnitude2 (Vector4 (Elements)); begin return Quaternion (Vectors.Divide_Or_Zero (Vector4 (Conjugate (Elements)), (Length, Length, Length, Length))); end Inverse; function Norm (Elements : Quaternion) return Vectors.Element_Type is (Vectors.Magnitude (Vector4 (Elements))); function Normalize (Elements : Quaternion) return Quaternion is (Quaternion (Vectors.Normalize (Vector4 (Elements)))); function Normalized (Elements : Quaternion) return Boolean is (Vectors.Normalized (Vector4 (Elements))); function To_Axis_Angle (Elements : Quaternion) return Axis_Angle is use type Vectors.Element_Type; Angle : constant Vectors.Element_Type := EF.Arccos (Elements (W)) * 2.0; SA : constant Vectors.Element_Type := EF.Sin (Angle / 2.0); begin if SA /= 0.0 then declare use Vectors; Axis : Vector4 := Vector4 (Elements) * (1.0 / SA); begin Axis (W) := 0.0; return (Axis => Vectors.Direction (Axis), Angle => Angle); end; else -- Singularity occurs when angle is 0. Return an arbitrary axis return (Axis => (1.0, 0.0, 0.0, 0.0), Angle => 0.0); end if; end To_Axis_Angle; function From_Axis_Angle (Value : Axis_Angle) return Quaternion is (R (Axis => Vector4 (Value.Axis), Angle => Value.Angle)); function R (Axis : Vector4; Angle : Vectors.Element_Type) return Quaternion is use type Vectors.Element_Type; CA : constant Vectors.Element_Type := EF.Cos (Angle / 2.0); SA : constant Vectors.Element_Type := EF.Sin (Angle / 2.0); use Vectors; Result : Quaternion := Quaternion (Axis * SA); begin Result (W) := CA; return Normalize (Result); end R; function R (Left, Right : Vector4) return Quaternion is use type Vectors.Element_Type; S : constant Vector4 := Vectors.Normalize (Left); T : constant Vector4 := Vectors.Normalize (Right); E : constant Vectors.Element_Type := Vectors.Dot (S, T); SRE : constant Vectors.Element_Type := EF.Sqrt (2.0 * (1.0 + E)); use Vectors; begin -- Division by zero if Left and Right are in opposite direction. -- Use rotation axis perpendicular to s and angle of 180 degrees if SRE /= 0.0 then -- Equation 4.53 from chapter 4.3 Quaternions from Real-Time Rendering -- (third edition, 2008) declare Result : Quaternion := Quaternion ((1.0 / SRE) * Vectors.Cross (S, T)); begin Result (W) := SRE / 2.0; return Normalize (Result); end; else if abs S (Z) < abs S (X) then return R ((S (Y), -S (X), 0.0, 0.0), Ada.Numerics.Pi); else return R ((0.0, -S (Z), S (Y), 0.0), Ada.Numerics.Pi); end if; end if; end R; function Difference (Left, Right : Quaternion) return Quaternion is begin return Right * Conjugate (Left); end Difference; procedure Rotate_At_Origin (Vector : in out Vector4; Elements : Quaternion) is Result : Vectors.Vector_Type; begin Result := Vectors.Vector_Type (Elements * Quaternion (Vector) * Conjugate (Elements)); Vector := Result; end Rotate_At_Origin; function Lerp (Left, Right : Quaternion; Time : Vectors.Element_Type) return Quaternion is use type Vectors.Element_Type; begin return Normalize ((1.0 - Time) * Left + Time * Right); end Lerp; function Slerp (Left, Right : Quaternion; Time : Vectors.Element_Type) return Quaternion is use type Vectors.Element_Type; Cos_Angle : constant Vectors.Element_Type := Vectors.Dot (Vector4 (Left), Vector4 (Right)); Angle : constant Vectors.Element_Type := EF.Arccos (Cos_Angle); SA : constant Vectors.Element_Type := EF.Sin (Angle); SL : constant Vectors.Element_Type := EF.Sin ((1.0 - Time) * Angle); SR : constant Vectors.Element_Type := EF.Sin (Time * Angle); use Vectors; begin if SA = 0.0 then return Lerp (Left, Right, Time); else return Normalize ((SL / SA) * Left + (SR / SA) * Right); end if; end Slerp; end Orka.Transforms.SIMD_Quaternions;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ I N T R -- -- -- -- B o d y -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; with Elists; use Elists; with Expander; use Expander; with Exp_Atag; use Exp_Atag; with Exp_Ch4; use Exp_Ch4; with Exp_Ch7; use Exp_Ch7; with Exp_Ch11; use Exp_Ch11; with Exp_Code; use Exp_Code; with Exp_Fixd; use Exp_Fixd; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Inline; use Inline; with Nmake; use Nmake; with Nlists; use Nlists; with Opt; use Opt; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; 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 Sinfo; use Sinfo; with Sinput; use Sinput; with Snames; use Snames; with Stand; use Stand; with Tbuild; use Tbuild; with Uintp; use Uintp; with Urealp; use Urealp; package body Exp_Intr is ----------------------- -- Local Subprograms -- ----------------------- procedure Expand_Binary_Operator_Call (N : Node_Id); -- Expand a call to an intrinsic arithmetic operator when the operand -- types or sizes are not identical. procedure Expand_Is_Negative (N : Node_Id); -- Expand a call to the intrinsic Is_Negative function procedure Expand_Dispatching_Constructor_Call (N : Node_Id); -- Expand a call to an instantiation of Generic_Dispatching_Constructor -- into a dispatching call to the actual subprogram associated with the -- Constructor formal subprogram, passing it the Parameters actual of -- the call to the instantiation and dispatching based on call's Tag -- parameter. procedure Expand_Exception_Call (N : Node_Id; Ent : RE_Id); -- Expand a call to Exception_Information/Message/Name. The first -- parameter, N, is the node for the function call, and Ent is the -- entity for the corresponding routine in the Ada.Exceptions package. procedure Expand_Import_Call (N : Node_Id); -- Expand a call to Import_Address/Longest_Integer/Value. The parameter -- N is the node for the function call. procedure Expand_Shift (N : Node_Id; E : Entity_Id; K : Node_Kind); -- Expand an intrinsic shift operation, N and E are from the call to -- Expand_Intrinsic_Call (call node and subprogram spec entity) and -- K is the kind for the shift node procedure Expand_Unc_Conversion (N : Node_Id; E : Entity_Id); -- Expand a call to an instantiation of Unchecked_Conversion into a node -- N_Unchecked_Type_Conversion. procedure Expand_Unc_Deallocation (N : Node_Id); -- Expand a call to an instantiation of Unchecked_Deallocation into a node -- N_Free_Statement and appropriate context. procedure Expand_To_Address (N : Node_Id); procedure Expand_To_Pointer (N : Node_Id); -- Expand a call to corresponding function, declared in an instance of -- System.Address_To_Access_Conversions. procedure Expand_Source_Info (N : Node_Id; Nam : Name_Id); -- Rewrite the node as the appropriate string literal or positive -- constant. Nam is the name of one of the intrinsics declared in -- GNAT.Source_Info; see g-souinf.ads for documentation of these -- intrinsics. --------------------- -- Add_Source_Info -- --------------------- procedure Add_Source_Info (Buf : in out Bounded_String; Loc : Source_Ptr; Nam : Name_Id) is begin case Nam is when Name_Line => Append (Buf, Nat (Get_Logical_Line_Number (Loc))); when Name_File => Append (Buf, Reference_Name (Get_Source_File_Index (Loc))); when Name_Source_Location => Build_Location_String (Buf, Loc); when Name_Enclosing_Entity => -- Skip enclosing blocks to reach enclosing unit declare Ent : Entity_Id := Current_Scope; begin while Present (Ent) loop exit when Ekind (Ent) not in E_Block | E_Loop; Ent := Scope (Ent); end loop; -- Ent now points to the relevant defining entity Append_Entity_Name (Buf, Ent); end; when Name_Compilation_ISO_Date => Append (Buf, Opt.Compilation_Time (1 .. 10)); when Name_Compilation_Date => declare subtype S13 is String (1 .. 3); Months : constant array (1 .. 12) of S13 := ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); M1 : constant Character := Opt.Compilation_Time (6); M2 : constant Character := Opt.Compilation_Time (7); MM : constant Natural range 1 .. 12 := (Character'Pos (M1) - Character'Pos ('0')) * 10 + (Character'Pos (M2) - Character'Pos ('0')); begin -- Reformat ISO date into MMM DD YYYY (__DATE__) format Append (Buf, Months (MM)); Append (Buf, ' '); Append (Buf, Opt.Compilation_Time (9 .. 10)); Append (Buf, ' '); Append (Buf, Opt.Compilation_Time (1 .. 4)); end; when Name_Compilation_Time => Append (Buf, Opt.Compilation_Time (12 .. 19)); when others => raise Program_Error; end case; end Add_Source_Info; --------------------------------- -- Expand_Binary_Operator_Call -- --------------------------------- procedure Expand_Binary_Operator_Call (N : Node_Id) is T1 : constant Entity_Id := Underlying_Type (Etype (Left_Opnd (N))); T2 : constant Entity_Id := Underlying_Type (Etype (Right_Opnd (N))); TR : constant Entity_Id := Etype (N); T3 : Entity_Id; Res : Node_Id; Siz : constant Uint := UI_Max (RM_Size (T1), RM_Size (T2)); -- Maximum of operand sizes begin -- Nothing to do if the operands have the same modular type if Base_Type (T1) = Base_Type (T2) and then Is_Modular_Integer_Type (T1) then return; end if; -- Use Unsigned_32 for sizes of 32 or below, else Unsigned_64 if Siz > 32 then T3 := RTE (RE_Unsigned_64); else T3 := RTE (RE_Unsigned_32); end if; -- Copy operator node, and reset type and entity fields, for -- subsequent reanalysis. Res := New_Copy (N); Set_Etype (Res, T3); case Nkind (N) is when N_Op_And => Set_Entity (Res, Standard_Op_And); when N_Op_Or => Set_Entity (Res, Standard_Op_Or); when N_Op_Xor => Set_Entity (Res, Standard_Op_Xor); when others => raise Program_Error; end case; -- Convert operands to large enough intermediate type Set_Left_Opnd (Res, Unchecked_Convert_To (T3, Relocate_Node (Left_Opnd (N)))); Set_Right_Opnd (Res, Unchecked_Convert_To (T3, Relocate_Node (Right_Opnd (N)))); -- Analyze and resolve result formed by conversion to target type Rewrite (N, Unchecked_Convert_To (TR, Res)); Analyze_And_Resolve (N, TR); end Expand_Binary_Operator_Call; ----------------------------------------- -- Expand_Dispatching_Constructor_Call -- ----------------------------------------- -- Transform a call to an instantiation of Generic_Dispatching_Constructor -- of the form: -- GDC_Instance (The_Tag, Parameters'Access) -- to a class-wide conversion of a dispatching call to the actual -- associated with the formal subprogram Construct, designating The_Tag -- as the controlling tag of the call: -- T'Class (Construct'Actual (Params)) -- Controlling tag is The_Tag -- which will eventually be expanded to the following: -- T'Class (The_Tag.all (Construct'Actual'Index).all (Params)) -- A class-wide membership test is also generated, preceding the call, to -- ensure that the controlling tag denotes a type in T'Class. procedure Expand_Dispatching_Constructor_Call (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Tag_Arg : constant Node_Id := First_Actual (N); Param_Arg : constant Node_Id := Next_Actual (Tag_Arg); Subp_Decl : constant Node_Id := Parent (Parent (Entity (Name (N)))); Inst_Pkg : constant Node_Id := Parent (Subp_Decl); Act_Rename : Node_Id; Act_Constr : Entity_Id; Iface_Tag : Node_Id := Empty; Cnstr_Call : Node_Id; Result_Typ : Entity_Id; begin -- Remove side effects from tag argument early, before rewriting -- the dispatching constructor call, as Remove_Side_Effects relies -- on Tag_Arg's Parent link properly attached to the tree (once the -- call is rewritten, the Parent is inconsistent as it points to the -- rewritten node, which is not the syntactic parent of the Tag_Arg -- anymore). Remove_Side_Effects (Tag_Arg); -- Check that we have a proper tag Insert_Action (N, Make_Implicit_If_Statement (N, Condition => Make_Op_Eq (Loc, Left_Opnd => New_Copy_Tree (Tag_Arg), Right_Opnd => New_Occurrence_Of (RTE (RE_No_Tag), Loc)), Then_Statements => New_List ( Make_Raise_Statement (Loc, New_Occurrence_Of (RTE (RE_Tag_Error), Loc))))); -- Check that it is not the tag of an abstract type Insert_Action (N, Make_Implicit_If_Statement (N, Condition => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Is_Abstract), Loc), Parameter_Associations => New_List (New_Copy_Tree (Tag_Arg))), Then_Statements => New_List ( Make_Raise_Statement (Loc, New_Occurrence_Of (RTE (RE_Tag_Error), Loc))))); -- The subprogram is the third actual in the instantiation, and is -- retrieved from the corresponding renaming declaration. However, -- freeze nodes may appear before, so we retrieve the declaration -- with an explicit loop. Act_Rename := First (Visible_Declarations (Inst_Pkg)); while Nkind (Act_Rename) /= N_Subprogram_Renaming_Declaration loop Next (Act_Rename); end loop; Act_Constr := Entity (Name (Act_Rename)); Result_Typ := Class_Wide_Type (Etype (Act_Constr)); -- Check that the accessibility level of the tag is no deeper than that -- of the constructor function (unless CodePeer_Mode) if not CodePeer_Mode then Insert_Action (N, Make_Implicit_If_Statement (N, Condition => Make_Op_Gt (Loc, Left_Opnd => Build_Get_Access_Level (Loc, New_Copy_Tree (Tag_Arg)), Right_Opnd => Make_Integer_Literal (Loc, Scope_Depth (Act_Constr))), Then_Statements => New_List ( Make_Raise_Statement (Loc, New_Occurrence_Of (RTE (RE_Tag_Error), Loc))))); end if; if Is_Interface (Etype (Act_Constr)) then -- If the result type is not known to be a parent of Tag_Arg then we -- need to locate the tag of the secondary dispatch table. if not Is_Ancestor (Etype (Result_Typ), Etype (Tag_Arg), Use_Full_View => True) and then Tagged_Type_Expansion then -- Obtain the reference to the Ada.Tags service before generating -- the Object_Declaration node to ensure that if this service is -- not available in the runtime then we generate a clear error. declare Fname : constant Node_Id := New_Occurrence_Of (RTE (RE_Secondary_Tag), Loc); begin pragma Assert (not Is_Interface (Etype (Tag_Arg))); -- The tag is the first entry in the dispatch table of the -- return type of the constructor. Iface_Tag := Make_Object_Declaration (Loc, Defining_Identifier => Make_Temporary (Loc, 'V'), Object_Definition => New_Occurrence_Of (RTE (RE_Tag), Loc), Expression => Make_Function_Call (Loc, Name => Fname, Parameter_Associations => New_List ( Relocate_Node (Tag_Arg), New_Occurrence_Of (Node (First_Elmt (Access_Disp_Table (Etype (Act_Constr)))), Loc)))); Insert_Action (N, Iface_Tag); end; end if; end if; -- Create the call to the actual Constructor function Cnstr_Call := Make_Function_Call (Loc, Name => New_Occurrence_Of (Act_Constr, Loc), Parameter_Associations => New_List (Relocate_Node (Param_Arg))); -- Establish its controlling tag from the tag passed to the instance -- The tag may be given by a function call, in which case a temporary -- should be generated now, to prevent out-of-order insertions during -- the expansion of that call when stack-checking is enabled. if Present (Iface_Tag) then Set_Controlling_Argument (Cnstr_Call, New_Occurrence_Of (Defining_Identifier (Iface_Tag), Loc)); else Set_Controlling_Argument (Cnstr_Call, Relocate_Node (Tag_Arg)); end if; -- Rewrite and analyze the call to the instance as a class-wide -- conversion of the call to the actual constructor. When the result -- type is a class-wide interface type this conversion is required to -- force the displacement of the pointer to the object to reference the -- corresponding dispatch table. Rewrite (N, Convert_To (Result_Typ, Cnstr_Call)); -- Do not generate a run-time check on the built object if tag -- checks are suppressed for the result type or tagged type expansion -- is disabled or if CodePeer_Mode. if Tag_Checks_Suppressed (Etype (Result_Typ)) or else not Tagged_Type_Expansion or else CodePeer_Mode then null; -- Generate a class-wide membership test to ensure that the call's tag -- argument denotes a type within the class. We must keep separate the -- case in which the Result_Type of the constructor function is a tagged -- type from the case in which it is an abstract interface because the -- run-time subprogram required to check these cases differ (and have -- one difference in their parameters profile). -- Call CW_Membership if the Result_Type is a tagged type to look for -- the tag in the table of ancestor tags. elsif not Is_Interface (Result_Typ) then Insert_Action (N, Make_Implicit_If_Statement (N, Condition => Make_Op_Not (Loc, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_CW_Membership), Loc), Parameter_Associations => New_List ( New_Copy_Tree (Tag_Arg), New_Occurrence_Of ( Node (First_Elmt (Access_Disp_Table ( Root_Type (Result_Typ)))), Loc)))), Then_Statements => New_List ( Make_Raise_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Tag_Error), Loc))))); -- Call IW_Membership test if the Result_Type is an abstract interface -- to look for the tag in the table of interface tags. else Insert_Action (N, Make_Implicit_If_Statement (N, Condition => Make_Op_Not (Loc, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_IW_Membership), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Copy_Tree (Tag_Arg), Attribute_Name => Name_Address), New_Occurrence_Of ( Node (First_Elmt (Access_Disp_Table ( Root_Type (Result_Typ)))), Loc)))), Then_Statements => New_List ( Make_Raise_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Tag_Error), Loc))))); end if; Analyze_And_Resolve (N, Etype (Act_Constr)); end Expand_Dispatching_Constructor_Call; --------------------------- -- Expand_Exception_Call -- --------------------------- -- If the function call is not within an exception handler, then the call -- is replaced by a null string. Otherwise the appropriate routine in -- Ada.Exceptions is called passing the choice parameter specification -- from the enclosing handler. If the enclosing handler lacks a choice -- parameter, then one is supplied. procedure Expand_Exception_Call (N : Node_Id; Ent : RE_Id) is Loc : constant Source_Ptr := Sloc (N); P : Node_Id; E : Entity_Id; begin -- Climb up parents to see if we are in exception handler P := Parent (N); loop -- Case of not in exception handler, replace by null string if No (P) then Rewrite (N, Make_String_Literal (Loc, Strval => "")); exit; -- Case of in exception handler elsif Nkind (P) = N_Exception_Handler then -- Handler cannot be used for a local raise, and furthermore, this -- is a violation of the No_Exception_Propagation restriction. Set_Local_Raise_Not_OK (P); Check_Restriction (No_Exception_Propagation, N); -- If no choice parameter present, then put one there. Note that -- we do not need to put it on the entity chain, since no one will -- be referencing it by normal visibility methods. if No (Choice_Parameter (P)) then E := Make_Temporary (Loc, 'E'); Set_Choice_Parameter (P, E); Set_Ekind (E, E_Variable); Set_Etype (E, RTE (RE_Exception_Occurrence)); Set_Scope (E, Current_Scope); end if; Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Ent), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Choice_Parameter (P), Loc)))); exit; -- Keep climbing else P := Parent (P); end if; end loop; Analyze_And_Resolve (N, Standard_String); end Expand_Exception_Call; ------------------------ -- Expand_Import_Call -- ------------------------ -- The function call must have a static string as its argument. We create -- a dummy variable which uses this string as the external name in an -- Import pragma. The result is then obtained as the address of this -- dummy variable, converted to the appropriate target type. procedure Expand_Import_Call (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Entity_Id := Entity (Name (N)); Str : constant Node_Id := First_Actual (N); Dum : constant Entity_Id := Make_Temporary (Loc, 'D'); begin Insert_Actions (N, New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Dum, Object_Definition => New_Occurrence_Of (Standard_Character, Loc)), Make_Pragma (Loc, Chars => Name_Import, Pragma_Argument_Associations => New_List ( Make_Pragma_Argument_Association (Loc, Expression => Make_Identifier (Loc, Name_Ada)), Make_Pragma_Argument_Association (Loc, Expression => Make_Identifier (Loc, Chars (Dum))), Make_Pragma_Argument_Association (Loc, Chars => Name_Link_Name, Expression => Relocate_Node (Str)))))); Rewrite (N, Unchecked_Convert_To (Etype (Ent), Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Chars (Dum)), Attribute_Name => Name_Address))); Analyze_And_Resolve (N, Etype (Ent)); end Expand_Import_Call; --------------------------- -- Expand_Intrinsic_Call -- --------------------------- procedure Expand_Intrinsic_Call (N : Node_Id; E : Entity_Id) is Nam : Name_Id; begin -- If an external name is specified for the intrinsic, it is handled -- by the back-end: leave the call node unchanged for now. if Present (Interface_Name (E)) then return; end if; -- If the intrinsic subprogram is generic, gets its original name if Present (Parent (E)) and then Present (Generic_Parent (Parent (E))) then Nam := Chars (Generic_Parent (Parent (E))); else Nam := Chars (E); end if; if Nam = Name_Asm then Expand_Asm_Call (N); elsif Nam = Name_Divide then Expand_Decimal_Divide_Call (N); elsif Nam = Name_Exception_Information then Expand_Exception_Call (N, RE_Exception_Information); elsif Nam = Name_Exception_Message then Expand_Exception_Call (N, RE_Exception_Message); elsif Nam = Name_Exception_Name then Expand_Exception_Call (N, RE_Exception_Name_Simple); elsif Nam = Name_Generic_Dispatching_Constructor then Expand_Dispatching_Constructor_Call (N); elsif Nam in Name_Import_Address | Name_Import_Largest_Value | Name_Import_Value then Expand_Import_Call (N); elsif Nam = Name_Is_Negative then Expand_Is_Negative (N); elsif Nam = Name_Rotate_Left then Expand_Shift (N, E, N_Op_Rotate_Left); elsif Nam = Name_Rotate_Right then Expand_Shift (N, E, N_Op_Rotate_Right); elsif Nam = Name_Shift_Left then Expand_Shift (N, E, N_Op_Shift_Left); elsif Nam = Name_Shift_Right then Expand_Shift (N, E, N_Op_Shift_Right); elsif Nam = Name_Shift_Right_Arithmetic then Expand_Shift (N, E, N_Op_Shift_Right_Arithmetic); elsif Nam = Name_Unchecked_Conversion then Expand_Unc_Conversion (N, E); elsif Nam = Name_Unchecked_Deallocation then Expand_Unc_Deallocation (N); elsif Nam = Name_To_Address then Expand_To_Address (N); elsif Nam = Name_To_Pointer then Expand_To_Pointer (N); elsif Nam in Name_File | Name_Line | Name_Source_Location | Name_Enclosing_Entity | Name_Compilation_ISO_Date | Name_Compilation_Date | Name_Compilation_Time then Expand_Source_Info (N, Nam); -- If we have a renaming, expand the call to the original operation, -- which must itself be intrinsic, since renaming requires matching -- conventions and this has already been checked. elsif Present (Alias (E)) then Expand_Intrinsic_Call (N, Alias (E)); elsif Nkind (N) in N_Binary_Op then Expand_Binary_Operator_Call (N); -- The only other case is where an external name was specified, since -- this is the only way that an otherwise unrecognized name could -- escape the checking in Sem_Prag. Nothing needs to be done in such -- a case, since we pass such a call to the back end unchanged. else null; end if; end Expand_Intrinsic_Call; ------------------------ -- Expand_Is_Negative -- ------------------------ procedure Expand_Is_Negative (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Opnd : constant Node_Id := Relocate_Node (First_Actual (N)); begin -- We replace the function call by the following expression -- if Opnd < 0.0 then -- True -- else -- if Opnd > 0.0 then -- False; -- else -- Float_Unsigned!(Float (Opnd)) /= 0 -- end if; -- end if; Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Lt (Loc, Left_Opnd => Duplicate_Subexpr (Opnd), Right_Opnd => Make_Real_Literal (Loc, Ureal_0)), New_Occurrence_Of (Standard_True, Loc), Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Gt (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Opnd), Right_Opnd => Make_Real_Literal (Loc, Ureal_0)), New_Occurrence_Of (Standard_False, Loc), Make_Op_Ne (Loc, Left_Opnd => Unchecked_Convert_To (RTE (RE_Float_Unsigned), Convert_To (Standard_Float, Duplicate_Subexpr_No_Checks (Opnd))), Right_Opnd => Make_Integer_Literal (Loc, 0))))))); Analyze_And_Resolve (N, Standard_Boolean); end Expand_Is_Negative; ------------------ -- Expand_Shift -- ------------------ -- This procedure is used to convert a call to a shift function to the -- corresponding operator node. This conversion is not done by the usual -- circuit for converting calls to operator functions (e.g. "+"(1,2)) to -- operator nodes, because shifts are not predefined operators. -- As a result, whenever a shift is used in the source program, it will -- remain as a call until converted by this routine to the operator node -- form which the back end is expecting to see. -- Note: it is possible for the expander to generate shift operator nodes -- directly, which will be analyzed in the normal manner by calling Analyze -- and Resolve. Such shift operator nodes will not be seen by Expand_Shift. procedure Expand_Shift (N : Node_Id; E : Entity_Id; K : Node_Kind) is Entyp : constant Entity_Id := Etype (E); Left : constant Node_Id := First_Actual (N); Loc : constant Source_Ptr := Sloc (N); Right : constant Node_Id := Next_Actual (Left); Ltyp : constant Node_Id := Etype (Left); Rtyp : constant Node_Id := Etype (Right); Typ : constant Entity_Id := Etype (N); Snode : Node_Id; begin Snode := New_Node (K, Loc); Set_Right_Opnd (Snode, Relocate_Node (Right)); Set_Chars (Snode, Chars (E)); Set_Etype (Snode, Base_Type (Entyp)); Set_Entity (Snode, E); if Compile_Time_Known_Value (Type_High_Bound (Rtyp)) and then Expr_Value (Type_High_Bound (Rtyp)) < Esize (Ltyp) then Set_Shift_Count_OK (Snode, True); end if; if Typ = Entyp then -- Note that we don't call Analyze and Resolve on this node, because -- it already got analyzed and resolved when it was a function call. Set_Left_Opnd (Snode, Relocate_Node (Left)); Rewrite (N, Snode); Set_Analyzed (N); -- However, we do call the expander, so that the expansion for -- rotates and shift_right_arithmetic happens if Modify_Tree_For_C -- is set. if Expander_Active then Expand (N); end if; else -- If the context type is not the type of the operator, it is an -- inherited operator for a derived type. Wrap the node in a -- conversion so that it is type-consistent for possible further -- expansion (e.g. within a lock-free protected type). Set_Left_Opnd (Snode, Unchecked_Convert_To (Base_Type (Entyp), Relocate_Node (Left))); Rewrite (N, Unchecked_Convert_To (Typ, Snode)); -- Analyze and resolve result formed by conversion to target type Analyze_And_Resolve (N, Typ); end if; end Expand_Shift; ------------------------ -- Expand_Source_Info -- ------------------------ procedure Expand_Source_Info (N : Node_Id; Nam : Name_Id) is Loc : constant Source_Ptr := Sloc (N); begin -- Integer cases if Nam = Name_Line then Rewrite (N, Make_Integer_Literal (Loc, Intval => UI_From_Int (Int (Get_Logical_Line_Number (Loc))))); Analyze_And_Resolve (N, Standard_Positive); -- String cases else declare Buf : Bounded_String; begin Add_Source_Info (Buf, Loc, Nam); Rewrite (N, Make_String_Literal (Loc, Strval => +Buf)); Analyze_And_Resolve (N, Standard_String); end; end if; Set_Is_Static_Expression (N); end Expand_Source_Info; --------------------------- -- Expand_Unc_Conversion -- --------------------------- procedure Expand_Unc_Conversion (N : Node_Id; E : Entity_Id) is Func : constant Entity_Id := Entity (Name (N)); Conv : Node_Id; Ftyp : Entity_Id; Ttyp : Entity_Id; begin -- Rewrite as unchecked conversion node. Note that we must convert -- the operand to the formal type of the input parameter of the -- function, so that the resulting N_Unchecked_Type_Conversion -- call indicates the correct types for Gigi. -- Right now, we only do this if a scalar type is involved. It is -- not clear if it is needed in other cases. If we do attempt to -- do the conversion unconditionally, it crashes 3411-018. To be -- investigated further ??? Conv := Relocate_Node (First_Actual (N)); Ftyp := Etype (First_Formal (Func)); if Is_Scalar_Type (Ftyp) then Conv := Convert_To (Ftyp, Conv); Set_Parent (Conv, N); Analyze_And_Resolve (Conv); end if; -- The instantiation of Unchecked_Conversion creates a wrapper package, -- and the target type is declared as a subtype of the actual. Recover -- the actual, which is the subtype indic. in the subtype declaration -- for the target type. This is semantically correct, and avoids -- anomalies with access subtypes. For entities, leave type as is. -- We do the analysis here, because we do not want the compiler -- to try to optimize or otherwise reorganize the unchecked -- conversion node. Ttyp := Etype (E); if Is_Entity_Name (Conv) then null; elsif Nkind (Parent (Ttyp)) = N_Subtype_Declaration then Ttyp := Entity (Subtype_Indication (Parent (Etype (E)))); elsif Is_Itype (Ttyp) then Ttyp := Entity (Subtype_Indication (Associated_Node_For_Itype (Ttyp))); else raise Program_Error; end if; Rewrite (N, Unchecked_Convert_To (Ttyp, Conv)); Set_Etype (N, Ttyp); Set_Analyzed (N); if Nkind (N) = N_Unchecked_Type_Conversion then Expand_N_Unchecked_Type_Conversion (N); end if; end Expand_Unc_Conversion; ----------------------------- -- Expand_Unc_Deallocation -- ----------------------------- procedure Expand_Unc_Deallocation (N : Node_Id) is Arg : constant Node_Id := First_Actual (N); Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (Arg); Desig_Typ : constant Entity_Id := Available_View (Designated_Type (Typ)); Needs_Fin : constant Boolean := Needs_Finalization (Desig_Typ); Root_Typ : constant Entity_Id := Underlying_Type (Root_Type (Typ)); Pool : constant Entity_Id := Associated_Storage_Pool (Root_Typ); Stmts : constant List_Id := New_List; Arg_Known_Non_Null : constant Boolean := Known_Non_Null (N); -- This captures whether we know the argument to be non-null so that -- we can avoid the test. The reason that we need to capture this is -- that we analyze some generated statements before properly attaching -- them to the tree, and that can disturb current value settings. Exceptions_OK : constant Boolean := not Restriction_Active (No_Exception_Propagation); Abrt_Blk : Node_Id := Empty; Abrt_Blk_Id : Entity_Id; Abrt_HSS : Node_Id; AUD : Entity_Id; Fin_Blk : Node_Id; Fin_Call : Node_Id; Fin_Data : Finalization_Exception_Data; Free_Arg : Node_Id; Free_Nod : Node_Id; Gen_Code : Node_Id; Obj_Ref : Node_Id; begin -- Nothing to do if we know the argument is null if Known_Null (N) then return; end if; -- Processing for pointer to controlled types. Generate: -- Abrt : constant Boolean := ...; -- Ex : Exception_Occurrence; -- Raised : Boolean := False; -- begin -- Abort_Defer; -- begin -- [Deep_]Finalize (Obj_Ref); -- exception -- when others => -- if not Raised then -- Raised := True; -- Save_Occurrence (Ex, Get_Current_Excep.all.all); -- end; -- at end -- Abort_Undefer_Direct; -- end; -- Depending on whether exception propagation is enabled and/or aborts -- are allowed, the generated code may lack block statements. if Needs_Fin then -- Ada 2005 (AI-251): In case of abstract interface type we displace -- the pointer to reference the base of the object to deallocate its -- memory, unless we're targetting a VM, in which case no special -- processing is required. if Is_Interface (Directly_Designated_Type (Typ)) and then Tagged_Type_Expansion then Obj_Ref := Make_Explicit_Dereference (Loc, Prefix => Unchecked_Convert_To (Typ, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Base_Address), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Address), Duplicate_Subexpr_No_Checks (Arg)))))); else Obj_Ref := Make_Explicit_Dereference (Loc, Prefix => Duplicate_Subexpr_No_Checks (Arg)); end if; -- If the designated type is tagged, the finalization call must -- dispatch because the designated type may not be the actual type -- of the object. If the type is synchronized, the deallocation -- applies to the corresponding record type. if Is_Tagged_Type (Desig_Typ) then if Is_Concurrent_Type (Desig_Typ) then Obj_Ref := Unchecked_Convert_To (Class_Wide_Type (Corresponding_Record_Type (Desig_Typ)), Obj_Ref); elsif not Is_Class_Wide_Type (Desig_Typ) then Obj_Ref := Unchecked_Convert_To (Class_Wide_Type (Desig_Typ), Obj_Ref); end if; -- Otherwise the designated type is untagged. Set the type of the -- dereference explicitly to force a conversion when needed given -- that [Deep_]Finalize may be inherited from a parent type. else Set_Etype (Obj_Ref, Desig_Typ); end if; -- Generate: -- [Deep_]Finalize (Obj_Ref); Fin_Call := Make_Final_Call (Obj_Ref => Obj_Ref, Typ => Desig_Typ); -- Generate: -- Abrt : constant Boolean := ...; -- Ex : Exception_Occurrence; -- Raised : Boolean := False; -- begin -- <Fin_Call> -- exception -- when others => -- if not Raised then -- Raised := True; -- Save_Occurrence (Ex, Get_Current_Excep.all.all); -- end; if Exceptions_OK then Build_Object_Declarations (Fin_Data, Stmts, Loc); Fin_Blk := Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Fin_Call), Exception_Handlers => New_List ( Build_Exception_Handler (Fin_Data)))); -- Otherwise exception propagation is not allowed else Fin_Blk := Fin_Call; end if; -- The finalization action must be protected by an abort defer and -- undefer pair when aborts are allowed. Generate: -- begin -- Abort_Defer; -- <Fin_Blk> -- at end -- Abort_Undefer_Direct; -- end; if Abort_Allowed then AUD := RTE (RE_Abort_Undefer_Direct); Abrt_HSS := Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Build_Runtime_Call (Loc, RE_Abort_Defer), Fin_Blk), At_End_Proc => New_Occurrence_Of (AUD, Loc)); Abrt_Blk := Make_Block_Statement (Loc, Handled_Statement_Sequence => Abrt_HSS); Add_Block_Identifier (Abrt_Blk, Abrt_Blk_Id); Expand_At_End_Handler (Abrt_HSS, Abrt_Blk_Id); -- Present the Abort_Undefer_Direct function to the backend so -- that it can inline the call to the function. Add_Inlined_Body (AUD, N); -- Otherwise aborts are not allowed else Abrt_Blk := Fin_Blk; end if; Append_To (Stmts, Abrt_Blk); end if; -- For a task type, call Free_Task before freeing the ATCB. We used to -- detect the case of Abort followed by a Free here, because the Free -- wouldn't actually free if it happens before the aborted task actually -- terminates. The warning was removed, because Free now works properly -- (the task will be freed once it terminates). if Is_Task_Type (Desig_Typ) then Append_To (Stmts, Cleanup_Task (N, Duplicate_Subexpr_No_Checks (Arg))); -- For composite types that contain tasks, recurse over the structure -- to build the selectors for the task subcomponents. elsif Has_Task (Desig_Typ) then if Is_Array_Type (Desig_Typ) then Append_List_To (Stmts, Cleanup_Array (N, Arg, Desig_Typ)); elsif Is_Record_Type (Desig_Typ) then Append_List_To (Stmts, Cleanup_Record (N, Arg, Desig_Typ)); end if; end if; -- Same for simple protected types. Eventually call Finalize_Protection -- before freeing the PO for each protected component. if Is_Simple_Protected_Type (Desig_Typ) then Append_To (Stmts, Cleanup_Protected_Object (N, Duplicate_Subexpr_No_Checks (Arg))); elsif Has_Simple_Protected_Object (Desig_Typ) then if Is_Array_Type (Desig_Typ) then Append_List_To (Stmts, Cleanup_Array (N, Arg, Desig_Typ)); elsif Is_Record_Type (Desig_Typ) then Append_List_To (Stmts, Cleanup_Record (N, Arg, Desig_Typ)); end if; end if; -- Normal processing for non-controlled types. The argument to free is -- a renaming rather than a constant to ensure that the original context -- is always set to null after the deallocation takes place. Free_Arg := Duplicate_Subexpr_No_Checks (Arg, Renaming_Req => True); Free_Nod := Make_Free_Statement (Loc, Empty); Append_To (Stmts, Free_Nod); Set_Storage_Pool (Free_Nod, Pool); -- Attach to tree before analysis of generated subtypes below Set_Parent (Stmts, Parent (N)); -- Deal with storage pool if Present (Pool) then -- Freeing the secondary stack is meaningless if Is_RTE (Pool, RE_SS_Pool) then null; -- If the pool object is of a simple storage pool type, then attempt -- to locate the type's Deallocate procedure, if any, and set the -- free operation's procedure to call. If the type doesn't have a -- Deallocate (which is allowed), then the actual will simply be set -- to null. elsif Present (Get_Rep_Pragma (Etype (Pool), Name_Simple_Storage_Pool_Type)) then declare Pool_Typ : constant Entity_Id := Base_Type (Etype (Pool)); Dealloc : Entity_Id; begin Dealloc := Get_Name_Entity_Id (Name_Deallocate); while Present (Dealloc) loop if Scope (Dealloc) = Scope (Pool_Typ) and then Present (First_Formal (Dealloc)) and then Etype (First_Formal (Dealloc)) = Pool_Typ then Set_Procedure_To_Call (Free_Nod, Dealloc); exit; else Dealloc := Homonym (Dealloc); end if; end loop; end; -- Case of a class-wide pool type: make a dispatching call to -- Deallocate through the class-wide Deallocate_Any. elsif Is_Class_Wide_Type (Etype (Pool)) then Set_Procedure_To_Call (Free_Nod, RTE (RE_Deallocate_Any)); -- Case of a specific pool type: make a statically bound call else Set_Procedure_To_Call (Free_Nod, Find_Prim_Op (Etype (Pool), Name_Deallocate)); end if; end if; if Present (Procedure_To_Call (Free_Nod)) then -- For all cases of a Deallocate call, the back-end needs to be able -- to compute the size of the object being freed. This may require -- some adjustments for objects of dynamic size. -- -- If the type is class wide, we generate an implicit type with the -- right dynamic size, so that the deallocate call gets the right -- size parameter computed by GIGI. Same for an access to -- unconstrained packed array. if Is_Class_Wide_Type (Desig_Typ) or else (Is_Array_Type (Desig_Typ) and then not Is_Constrained (Desig_Typ) and then Is_Packed (Desig_Typ)) then declare Deref : constant Node_Id := Make_Explicit_Dereference (Loc, Duplicate_Subexpr_No_Checks (Arg)); D_Subtyp : Node_Id; D_Type : Entity_Id; begin -- Perform minor decoration as it is needed by the side effect -- removal mechanism. Set_Etype (Deref, Desig_Typ); Set_Parent (Deref, Free_Nod); D_Subtyp := Make_Subtype_From_Expr (Deref, Desig_Typ); if Nkind (D_Subtyp) in N_Has_Entity then D_Type := Entity (D_Subtyp); else D_Type := Make_Temporary (Loc, 'A'); Insert_Action (Deref, Make_Subtype_Declaration (Loc, Defining_Identifier => D_Type, Subtype_Indication => D_Subtyp)); end if; -- Force freezing at the point of the dereference. For the -- class wide case, this avoids having the subtype frozen -- before the equivalent type. Freeze_Itype (D_Type, Deref); Set_Actual_Designated_Subtype (Free_Nod, D_Type); end; end if; end if; -- Ada 2005 (AI-251): In case of abstract interface type we must -- displace the pointer to reference the base of the object to -- deallocate its memory, unless we're targetting a VM, in which case -- no special processing is required. -- Generate: -- free (Base_Address (Obj_Ptr)) if Is_Interface (Directly_Designated_Type (Typ)) and then Tagged_Type_Expansion then Set_Expression (Free_Nod, Unchecked_Convert_To (Typ, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Base_Address), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Address), Free_Arg))))); -- Generate: -- free (Obj_Ptr) else Set_Expression (Free_Nod, Free_Arg); end if; -- Only remaining step is to set result to null, or generate a raise of -- Constraint_Error if the target object is "not null". if Can_Never_Be_Null (Etype (Arg)) then Append_To (Stmts, Make_Raise_Constraint_Error (Loc, Reason => CE_Access_Check_Failed)); else declare Lhs : constant Node_Id := Duplicate_Subexpr_No_Checks (Arg); begin Set_Assignment_OK (Lhs); Append_To (Stmts, Make_Assignment_Statement (Loc, Name => Lhs, Expression => Make_Null (Loc))); end; end if; -- Generate a test of whether any earlier finalization raised an -- exception, and in that case raise Program_Error with the previous -- exception occurrence. -- Generate: -- if Raised and then not Abrt then -- raise Program_Error; -- for restricted RTS -- <or> -- Raise_From_Controlled_Operation (E); -- all other cases -- end if; if Needs_Fin and then Exceptions_OK then Append_To (Stmts, Build_Raise_Statement (Fin_Data)); end if; -- If we know the argument is non-null, then make a block statement -- that contains the required statements, no need for a test. if Arg_Known_Non_Null then Gen_Code := Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Stmts)); -- If the argument may be null, wrap the statements inside an IF that -- does an explicit test to exclude the null case. else Gen_Code := Make_Implicit_If_Statement (N, Condition => Make_Op_Ne (Loc, Left_Opnd => Duplicate_Subexpr (Arg), Right_Opnd => Make_Null (Loc)), Then_Statements => Stmts); end if; -- Rewrite the call Rewrite (N, Gen_Code); Analyze (N); end Expand_Unc_Deallocation; ----------------------- -- Expand_To_Address -- ----------------------- procedure Expand_To_Address (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Arg : constant Node_Id := First_Actual (N); Obj : Node_Id; begin Remove_Side_Effects (Arg); Obj := Make_Explicit_Dereference (Loc, Relocate_Node (Arg)); Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => New_Copy_Tree (Arg), Right_Opnd => Make_Null (Loc)), New_Occurrence_Of (RTE (RE_Null_Address), Loc), Make_Attribute_Reference (Loc, Prefix => Obj, Attribute_Name => Name_Address)))); Analyze_And_Resolve (N, RTE (RE_Address)); end Expand_To_Address; ----------------------- -- Expand_To_Pointer -- ----------------------- procedure Expand_To_Pointer (N : Node_Id) is Arg : constant Node_Id := First_Actual (N); begin Rewrite (N, Unchecked_Convert_To (Etype (N), Arg)); Analyze (N); end Expand_To_Pointer; end Exp_Intr;
------------------------------------------------------------------------------ -- -- -- Command Line Interface Toolkit -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2019-2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Ensi Martini (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. -- -- -- ------------------------------------------------------------------------------ package CLI is -- Note: CLI is line-oriented. Any widgets updated after New_Line will -- be rendered on the new line type Text_Style is private; function "+" (Left, Right : Text_Style) return Text_Style; -- This operator works like an "overwrite" -- Will keep any attributes of Left, adding to it the attributes of Right -- that it does not currently have -- NOTE: The color for the new Text_Style will always be the same as the -- color of the Right cursor, so if a user wishes to make a cursor that is -- the same as their current one, just with a different color, they should -- use: New_Style : Text_Style := Current_Style + New_Desired_Color_Style -- NOT the other way around function "-" (Left, Right : Text_Style) return Text_Style; -- This operator works like a "clear" for all attributes that appear in both -- Will retain all Left attributes that are not in Right cursor -- NOTE: The color for the new Text_Style will always be the same as the -- color of the Left cursor, because this is the one we are subtracting from -- With the preceding two operators and the following presets, any style -- and color combination cursor can be made -- COLOR PRESET CURSORS -- Neutral : constant Text_Style; -- Follow the text-style set from prior output -- Foreground Colors -- Black_FG : constant Text_Style; Red_FG : constant Text_Style; Green_FG : constant Text_Style; Yellow_FG : constant Text_Style; Blue_FG : constant Text_Style; Magenta_FG : constant Text_Style; Cyan_FG : constant Text_Style; White_FG : constant Text_Style; -- Background Colors -- Black_BG : constant Text_Style; Red_BG : constant Text_Style; Green_BG : constant Text_Style; Yellow_BG : constant Text_Style; Blue_BG : constant Text_Style; Magenta_BG : constant Text_Style; Cyan_BG : constant Text_Style; White_BG : constant Text_Style; -- ATTRIBUTE PRESET CURSORS -- Bold : constant Text_Style; Underline : constant Text_Style; Blink : constant Text_Style; Reverse_Vid : constant Text_Style; function Terminal_Width return Positive; -- Width of the terminal in columns. If the output is not a terminal, -- a value of 80 is always returned procedure Set_Column (Col: in Positive); function Current_Column return Positive; -- Sets or returns the current column number of the cursor. procedure Clear_Screen; procedure Clear_Line; procedure Clear_To_End; -- Note: all Wide_Wide_Strings/Characters are encoded in UTF-8 prior to -- output procedure Put (Char : in Character; Style: in Text_Style := Neutral); procedure Put (Message: in String; Style : in Text_Style := Neutral); procedure Wide_Wide_Put (Char : in Wide_Wide_Character; Style: in Text_Style := Neutral); procedure Wide_Wide_Put (Message: in Wide_Wide_String; Style : in Text_Style := Neutral); procedure Put_At (Char : in Character; Column : in Positive; Style : in Text_Style := Neutral); procedure Put_At (Message: in String; Column : in Positive; Style : in Text_Style := Neutral); procedure Wide_Wide_Put_At (Char : in Wide_Wide_Character; Column: in Positive; Style : in Text_Style := Neutral); procedure Wide_Wide_Put_At (Message: in Wide_Wide_String; Column : in Positive; Style : in Text_Style := Neutral); -- Put_At opeartions do not change the cursor position procedure Put_Line (Message: String; Style : Text_Style := Neutral); procedure Wide_Wide_Put_Line (Message: Wide_Wide_String; Style : Text_Style := Neutral); procedure New_Line; procedure Get (Item: out String); procedure Get (Item: out Character); procedure Get_Line (Item: out String; Last: out Natural); procedure Get_Immediate (Item: out Character; Available: out Boolean); function Output_Is_Terminal return Boolean; -- True if Standard_Output is a terminal, and False otherwise. -- If False, all ANSI code output is supressed. -- -- The use should avoid using widgets if Is_TTY is False private -- Clears to the end of the line from the current column type Color is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, Default); type Text_Style is record Bold : Boolean := False; Underscore : Boolean := False; Blink : Boolean := False; Reverse_Vid : Boolean := False; Concealed : Boolean := False; Foreground : Color := Default; Background : Color := Default; end record; Neutral : constant Text_Style := (others => <>); Black_FG : constant Text_Style := (Foreground => Black, others => <>); Red_FG : constant Text_Style := (Foreground => Red, others => <>); Green_FG : constant Text_Style := (Foreground => Green, others => <>); Yellow_FG : constant Text_Style := (Foreground => Yellow, others => <>); Blue_FG : constant Text_Style := (Foreground => Blue, others => <>); Magenta_FG : constant Text_Style := (Foreground => Magenta, others => <>); Cyan_FG : constant Text_Style := (Foreground => Cyan, others => <>); White_FG : constant Text_Style := (Foreground => White, others => <>); Black_BG : constant Text_Style := (Background => Black, others => <>); Red_BG : constant Text_Style := (Background => Red, others => <>); Green_BG : constant Text_Style := (Background => Green, others => <>); Yellow_BG : constant Text_Style := (Background => Yellow, others => <>); Blue_BG : constant Text_Style := (Background => Blue, others => <>); Magenta_BG : constant Text_Style := (Background => Magenta, others => <>); Cyan_BG : constant Text_Style := (Background => Cyan, others => <>); White_BG : constant Text_Style := (Background => White, others => <>); Bold : constant Text_Style := (Bold => True, others => <>); Underline : constant Text_Style := (Underscore => True, others => <>); Blink : constant Text_Style := (Blink => True, others => <>); Reverse_Vid: constant Text_Style := (Reverse_Vid => True, others => <>); procedure Apply_Style (Style: Text_Style); procedure Clear_Style; end CLI;
----------------------------------------------------------------------- -- keystore-io-headers -- Keystore file header operations -- 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.SHA256; with Keystore.Buffers; package Keystore.IO.Headers is type Wallet_Storage is record Identifier : Storage_Identifier; Pos : Block_Index; Kind : Interfaces.Unsigned_16; Readonly : Boolean := False; Sealed : Boolean := False; Max_Block : Natural := 0; HMAC : Util.Encoders.SHA256.Hash_Array; end record; type Wallet_Header is limited record UUID : UUID_Type; Identifier : Storage_Identifier; Version : Natural := 0; Block_Size : Natural := 0; Data_Count : Keystore.Header_Slot_Count_Type := 0; Header_Last_Pos : Block_Index; Storage_Count : Natural := 0; HMAC : Util.Encoders.SHA256.Hash_Array; Buffer : Keystore.Buffers.Storage_Buffer; end record; -- Build a new header with the given UUID and for the storage. -- The header buffer is allocated and filled so that it can be written by Write_Header. procedure Build_Header (UUID : in UUID_Type; Storage : in Storage_Identifier; Header : in out Wallet_Header); -- Read the header block and verify its integrity. procedure Read_Header (Header : in out Wallet_Header); -- Scan the header block for the storage and call the Process procedure for each -- storage information found in the header block. procedure Scan_Storage (Header : in out Wallet_Header; Process : not null access procedure (Storage : in Wallet_Storage)); -- Sign the header block for the storage. procedure Sign_Header (Header : in out Wallet_Header; Sign : in Secret_Key); -- Set some header data in the keystore file. procedure Set_Header_Data (Header : in out Wallet_Header; Index : in Header_Slot_Index_Type; Kind : in Header_Slot_Type; Data : in Ada.Streams.Stream_Element_Array); -- Get the header data information from the keystore file. procedure Get_Header_Data (Header : in out Wallet_Header; Index : in Header_Slot_Index_Type; Kind : out Header_Slot_Type; Data : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); -- Add a new storage reference in the header and return its position in the header. -- Raises the No_Header_Slot if there is no room in the header. procedure Add_Storage (Header : in out Wallet_Header; Identifier : in Storage_Identifier; Max_Block : in Positive; Pos : out Block_Index); end Keystore.IO.Headers;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S O C K E T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-2020, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides an interface to the sockets communication facility -- provided on many operating systems. This is implemented on the following -- platforms: -- All native ports, with restrictions as follows -- Multicast is available only on systems which provide support for this -- feature, so it is not available if Multicast is not supported, or not -- installed. -- VxWorks cross ports fully implement this package -- This package is not yet implemented on LynxOS or other cross ports with Ada.Exceptions; with Ada.Streams; with Ada.Strings.Unbounded; with Ada.Unchecked_Deallocation; with Interfaces.C; with System.OS_Constants; with System.Storage_Elements; package GNAT.Sockets is -- Sockets are designed to provide a consistent communication facility -- between applications. This package provides an Ada binding to the -- de-facto standard BSD sockets API. The documentation below covers -- only the specific binding provided by this package. It assumes that -- the reader is already familiar with general network programming and -- sockets usage. A useful reference on this matter is W. Richard Stevens' -- "UNIX Network Programming: The Sockets Networking API" -- (ISBN: 0131411551). -- GNAT.Sockets has been designed with several ideas in mind -- This is a system independent interface. Therefore, we try as much as -- possible to mask system incompatibilities. Some functionalities are not -- available because there are not fully supported on some systems. -- This is a thick binding. For instance, a major effort has been done to -- avoid using memory addresses or untyped ints. We preferred to define -- streams and enumeration types. Errors are not returned as returned -- values but as exceptions. -- This package provides a POSIX-compliant interface (between two -- different implementations of the same routine, we adopt the one closest -- to the POSIX specification). For instance, using select(), the -- notification of an asynchronous connect failure is delivered in the -- write socket set (POSIX) instead of the exception socket set (NT). -- The example below demonstrates various features of GNAT.Sockets: -- with GNAT.Sockets; use GNAT.Sockets; -- with Ada.Text_IO; -- with Ada.Exceptions; use Ada.Exceptions; -- procedure PingPong is -- Group : constant String := "239.255.128.128"; -- -- Multicast group: administratively scoped IP address -- task Pong is -- entry Start; -- entry Stop; -- end Pong; -- task body Pong is -- Address : Sock_Addr_Type; -- Server : Socket_Type; -- Socket : Socket_Type; -- Channel : Stream_Access; -- begin -- -- Get an Internet address of a host (here the local host name). -- -- Note that a host can have several addresses. Here we get -- -- the first one which is supposed to be the official one. -- Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1); -- -- Get a socket address that is an Internet address and a port -- Address.Port := 5876; -- -- The first step is to create a socket. Once created, this -- -- socket must be associated to with an address. Usually only a -- -- server (Pong here) needs to bind an address explicitly. Most -- -- of the time clients can skip this step because the socket -- -- routines will bind an arbitrary address to an unbound socket. -- Create_Socket (Server); -- -- Allow reuse of local addresses -- Set_Socket_Option -- (Server, -- Socket_Level, -- (Reuse_Address, True)); -- Bind_Socket (Server, Address); -- -- A server marks a socket as willing to receive connect events -- Listen_Socket (Server); -- -- Once a server calls Listen_Socket, incoming connects events -- -- can be accepted. The returned Socket is a new socket that -- -- represents the server side of the connection. Server remains -- -- available to receive further connections. -- accept Start; -- Accept_Socket (Server, Socket, Address); -- -- Return a stream associated to the connected socket -- Channel := Stream (Socket); -- -- Force Pong to block -- delay 0.2; -- -- Receive and print message from client Ping -- declare -- Message : String := String'Input (Channel); -- begin -- Ada.Text_IO.Put_Line (Message); -- -- Send same message back to client Ping -- String'Output (Channel, Message); -- end; -- Close_Socket (Server); -- Close_Socket (Socket); -- -- Part of the multicast example -- -- Create a datagram socket to send connectionless, unreliable -- -- messages of a fixed maximum length. -- Create_Socket (Socket, Family_Inet, Socket_Datagram); -- -- Allow reuse of local addresses -- Set_Socket_Option -- (Socket, -- Socket_Level, -- (Reuse_Address, True)); -- -- Controls the live time of the datagram to avoid it being -- -- looped forever due to routing errors. Routers decrement -- -- the TTL of every datagram as it traverses from one network -- -- to another and when its value reaches 0 the packet is -- -- dropped. Default is 1. -- Set_Socket_Option -- (Socket, -- IP_Protocol_For_IP_Level, -- (Multicast_TTL, 1)); -- -- Want the data you send to be looped back to your host -- Set_Socket_Option -- (Socket, -- IP_Protocol_For_IP_Level, -- (Multicast_Loop, True)); -- -- If this socket is intended to receive messages, bind it -- -- to a given socket address. -- Address.Addr := Any_Inet_Addr; -- Address.Port := 55505; -- Bind_Socket (Socket, Address); -- -- Join a multicast group -- -- Portability note: On Windows, this option may be set only -- -- on a bound socket. -- Set_Socket_Option -- (Socket, -- IP_Protocol_For_IP_Level, -- (Add_Membership, Inet_Addr (Group), Any_Inet_Addr)); -- -- If this socket is intended to send messages, provide the -- -- receiver socket address. -- Address.Addr := Inet_Addr (Group); -- Address.Port := 55506; -- Channel := Stream (Socket, Address); -- -- Receive and print message from client Ping -- declare -- Message : String := String'Input (Channel); -- begin -- -- Get the address of the sender -- Address := Get_Address (Channel); -- Ada.Text_IO.Put_Line (Message & " from " & Image (Address)); -- -- Send same message back to client Ping -- String'Output (Channel, Message); -- end; -- Close_Socket (Socket); -- accept Stop; -- exception when E : others => -- Ada.Text_IO.Put_Line -- (Exception_Name (E) & ": " & Exception_Message (E)); -- end Pong; -- task Ping is -- entry Start; -- entry Stop; -- end Ping; -- task body Ping is -- Address : Sock_Addr_Type; -- Socket : Socket_Type; -- Channel : Stream_Access; -- begin -- accept Start; -- -- See comments in Ping section for the first steps -- Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1); -- Address.Port := 5876; -- Create_Socket (Socket); -- Set_Socket_Option -- (Socket, -- Socket_Level, -- (Reuse_Address, True)); -- -- Force Ping to block -- delay 0.2; -- -- If the client's socket is not bound, Connect_Socket will -- -- bind to an unused address. The client uses Connect_Socket to -- -- create a logical connection between the client's socket and -- -- a server's socket returned by Accept_Socket. -- Connect_Socket (Socket, Address); -- Channel := Stream (Socket); -- -- Send message to server Pong -- String'Output (Channel, "Hello world"); -- -- Force Ping to block -- delay 0.2; -- -- Receive and print message from server Pong -- Ada.Text_IO.Put_Line (String'Input (Channel)); -- Close_Socket (Socket); -- -- Part of multicast example. Code similar to Pong's one -- Create_Socket (Socket, Family_Inet, Socket_Datagram); -- Set_Socket_Option -- (Socket, -- Socket_Level, -- (Reuse_Address, True)); -- Set_Socket_Option -- (Socket, -- IP_Protocol_For_IP_Level, -- (Multicast_TTL, 1)); -- Set_Socket_Option -- (Socket, -- IP_Protocol_For_IP_Level, -- (Multicast_Loop, True)); -- Address.Addr := Any_Inet_Addr; -- Address.Port := 55506; -- Bind_Socket (Socket, Address); -- Set_Socket_Option -- (Socket, -- IP_Protocol_For_IP_Level, -- (Add_Membership, Inet_Addr (Group), Any_Inet_Addr)); -- Address.Addr := Inet_Addr (Group); -- Address.Port := 55505; -- Channel := Stream (Socket, Address); -- -- Send message to server Pong -- String'Output (Channel, "Hello world"); -- -- Receive and print message from server Pong -- declare -- Message : String := String'Input (Channel); -- begin -- Address := Get_Address (Channel); -- Ada.Text_IO.Put_Line (Message & " from " & Image (Address)); -- end; -- Close_Socket (Socket); -- accept Stop; -- exception when E : others => -- Ada.Text_IO.Put_Line -- (Exception_Name (E) & ": " & Exception_Message (E)); -- end Ping; -- begin -- Initialize; -- Ping.Start; -- Pong.Start; -- Ping.Stop; -- Pong.Stop; -- Finalize; -- end PingPong; package SOSC renames System.OS_Constants; -- Renaming used to provide short-hand notations throughout the sockets -- binding. Note that System.OS_Constants is an internal unit, and the -- entities declared therein are not meant for direct access by users, -- including through this renaming. use type Interfaces.C.int; -- Need visibility on "-" operator so that we can write -1 procedure Initialize; pragma Obsolescent (Entity => Initialize, Message => "explicit initialization is no longer required"); -- Initialize must be called before using any other socket routines. -- Note that this operation is a no-op on UNIX platforms, but applications -- should make sure to call it if portability is expected: some platforms -- (such as Windows) require initialization before any socket operation. -- This is now a no-op (initialization and finalization are done -- automatically). procedure Initialize (Process_Blocking_IO : Boolean); pragma Obsolescent (Entity => Initialize, Message => "passing a parameter to Initialize is no longer supported"); -- Previous versions of GNAT.Sockets used to require the user to indicate -- whether socket I/O was process- or thread-blocking on the platform. -- This property is now determined automatically when the run-time library -- is built. The old version of Initialize, taking a parameter, is kept -- for compatibility reasons, but this interface is obsolete (and if the -- value given is wrong, an exception will be raised at run time). -- This is now a no-op (initialization and finalization are done -- automatically). procedure Finalize; pragma Obsolescent (Entity => Finalize, Message => "explicit finalization is no longer required"); -- After Finalize is called it is not possible to use any routines -- exported in by this package. This procedure is idempotent. -- This is now a no-op (initialization and finalization are done -- automatically). type Socket_Type is private; -- Sockets are used to implement a reliable bi-directional point-to-point, -- stream-based connections between hosts. No_Socket provides a special -- value to denote uninitialized sockets. No_Socket : constant Socket_Type; type Selector_Type is limited private; type Selector_Access is access all Selector_Type; -- Selector objects are used to wait for i/o events to occur on sockets Null_Selector : constant Selector_Type; -- The Null_Selector can be used in place of a normal selector without -- having to call Create_Selector if the use of Abort_Selector is not -- required. -- Timeval_Duration is a subtype of Standard.Duration because the full -- range of Standard.Duration cannot be represented in the equivalent C -- structure (struct timeval). Moreover, negative values are not allowed -- to avoid system incompatibilities. Immediate : constant Duration := 0.0; Forever : constant Duration := Duration'Min (Duration'Last, (if SOSC."=" (SOSC.Target_OS, SOSC.Windows) then Duration (2 ** 32 / 1000) else 1.0 * SOSC.MAX_tv_sec)); -- Largest possible Duration that is also a valid value for the OS type -- used for socket timeout. subtype Timeval_Duration is Duration range Immediate .. Forever; subtype Selector_Duration is Timeval_Duration; -- Timeout value for selector operations type Selector_Status is (Completed, Expired, Aborted); -- Completion status of a selector operation, indicated as follows: -- Complete: one of the expected events occurred -- Expired: no event occurred before the expiration of the timeout -- Aborted: an external action cancelled the wait operation before -- any event occurred. Socket_Error : exception; -- There is only one exception in this package to deal with an error during -- a socket routine. Once raised, its message contains a string describing -- the error code. function Image (Socket : Socket_Type) return String; -- Return a printable string for Socket function To_Ada (Fd : Integer) return Socket_Type with Inline; -- Convert a file descriptor to Socket_Type. This is useful when a socket -- file descriptor is obtained from an external library call. function To_C (Socket : Socket_Type) return Integer with Inline; -- Return a file descriptor to be used by external subprograms. This is -- useful for C functions that are not yet interfaced in this package. type Family_Type is (Family_Inet, Family_Inet6, Family_Unix, Family_Unspec); -- Address family (or protocol family) identifies the communication domain -- and groups protocols with similar address formats. -- The order of the enumeration elements should not be changed unilaterally -- because the IPv6_TCP_Preferred routine rely on it. subtype Family_Inet_4_6 is Family_Type range Family_Inet .. Family_Inet6; type Mode_Type is (Socket_Stream, Socket_Datagram, Socket_Raw); -- Stream sockets provide connection-oriented byte streams. Datagram -- sockets support unreliable connectionless message-based communication. -- Raw sockets provide raw network-protocol access. -- The order of the enumeration elements should not be changed unilaterally -- because the IPv6_TCP_Preferred routine relies on it. type Shutmode_Type is (Shut_Read, Shut_Write, Shut_Read_Write); -- When a process closes a socket, the policy is to retain any data queued -- until either a delivery or a timeout expiration (in this case, the data -- are discarded). Finer control is available through shutdown. With -- Shut_Read, no more data can be received from the socket. With_Write, no -- more data can be transmitted. Neither transmission nor reception can be -- performed with Shut_Read_Write. type Port_Type is range 0 .. 16#ffff#; -- TCP/UDP port number Any_Port : constant Port_Type; -- All ports No_Port : constant Port_Type; -- Uninitialized port number type Inet_Addr_Comp_Type is mod 2 ** 8; -- Octet for Internet address Inet_Addr_Bytes_Length : constant array (Family_Inet_4_6) of Natural := (Family_Inet => 4, Family_Inet6 => 16); type Inet_Addr_Bytes is array (Natural range <>) of Inet_Addr_Comp_Type; subtype Inet_Addr_V4_Type is Inet_Addr_Bytes (1 .. Inet_Addr_Bytes_Length (Family_Inet)); subtype Inet_Addr_V6_Type is Inet_Addr_Bytes (1 .. Inet_Addr_Bytes_Length (Family_Inet6)); subtype Inet_Addr_VN_Type is Inet_Addr_Bytes; -- For backwards compatibility type Inet_Addr_Type (Family : Family_Inet_4_6 := Family_Inet) is record case Family is when Family_Inet => Sin_V4 : Inet_Addr_V4_Type := (others => 0); when Family_Inet6 => Sin_V6 : Inet_Addr_V6_Type := (others => 0); end case; end record; -- An Internet address depends on an address family (IPv4 contains 4 octets -- and IPv6 contains 16 octets). Any_Inet_Addr : constant Inet_Addr_Type; -- Wildcard enabling all addresses to use with bind Any_Inet6_Addr : constant Inet_Addr_Type; -- Idem for IPV6 socket No_Inet_Addr : constant Inet_Addr_Type; -- Uninitialized inet address Broadcast_Inet_Addr : constant Inet_Addr_Type; -- Broadcast destination address in the current network Loopback_Inet_Addr : constant Inet_Addr_Type; -- Loopback address to the local host Loopback_Inet6_Addr : constant Inet_Addr_Type; -- IPv6 Loopback address to the local host -- Useful constants for multicast addresses Unspecified_Group_Inet_Addr : constant Inet_Addr_Type; -- IPv4 multicast mask with prefix length 4 Unspecified_Group_Inet6_Addr : constant Inet_Addr_Type; -- IPv6 multicast mask with prefix length 16 All_Hosts_Group_Inet_Addr : constant Inet_Addr_Type; -- Multicast group addresses all hosts on the same network segment All_Hosts_Group_Inet6_Addr : constant Inet_Addr_Type; -- Idem for IPv6 protocol All_Routers_Group_Inet_Addr : constant Inet_Addr_Type; -- Multicast group addresses all routers on the same network segment All_Routers_Group_Inet6_Addr : constant Inet_Addr_Type; -- Idem for IPv6 protocol IPv4_To_IPv6_Prefix : constant Inet_Addr_Bytes := (1 .. 10 => 0, 11 .. 12 => 255); -- Prefix for IPv4 mapped to IPv6 addresses -- Functions to handle masks and prefixes function Mask (Family : Family_Inet_4_6; Length : Natural; Host : Boolean := False) return Inet_Addr_Type; -- Return an address mask of the given family with the given prefix length. -- If Host is False, this is a network mask (i.e. network bits are 1, -- and host bits are 0); if Host is True, this is a host mask (i.e. -- network bits are 0, and host bits are 1). function "and" (Addr, Mask : Inet_Addr_Type) return Inet_Addr_Type; function "or" (Net, Host : Inet_Addr_Type) return Inet_Addr_Type; function "not" (Mask : Inet_Addr_Type) return Inet_Addr_Type; -- Bit-wise operations on inet addresses (both operands must have the -- same address family). type Sock_Addr_Type (Family : Family_Type := Family_Inet) is record case Family is when Family_Unix => Name : Ada.Strings.Unbounded.Unbounded_String; when Family_Inet_4_6 => Addr : Inet_Addr_Type (Family); Port : Port_Type; when Family_Unspec => null; end case; end record; pragma No_Component_Reordering (Sock_Addr_Type); -- Socket addresses fully define a socket connection with protocol family, -- an Internet address and a port. No_Sock_Addr provides a special value -- for uninitialized socket addresses. No_Sock_Addr : constant Sock_Addr_Type; -- Uninitialized socket address function Is_IPv4_Address (Name : String) return Boolean; -- Return true when Name is an IPv4 address in dotted quad notation function Is_IPv6_Address (Name : String) return Boolean; -- Return true when Name is an IPv6 address in numeric format function Image (Value : Inet_Addr_Type) return String; -- Return an image of an Internet address. IPv4 notation consists in 4 -- octets in decimal format separated by dots. IPv6 notation consists in -- 8 hextets in hexadecimal format separated by colons. function Image (Value : Sock_Addr_Type) return String; -- Return socket address image. Network socket address image will be with -- a port image separated by a colon. function Inet_Addr (Image : String) return Inet_Addr_Type; -- Convert address image from numbers-dots-and-colons notation into an -- inet address. function Unix_Socket_Address (Addr : String) return Sock_Addr_Type; -- Convert unix local socket name to Sock_Addr_Type function Network_Socket_Address (Addr : Inet_Addr_Type; Port : Port_Type) return Sock_Addr_Type; -- Create network socket address -- Host entries provide complete information on a given host: the official -- name, an array of alternative names or aliases and array of network -- addresses. type Host_Entry_Type (Aliases_Length, Addresses_Length : Natural) is private; function Official_Name (E : Host_Entry_Type) return String; -- Return official name in host entry function Aliases_Length (E : Host_Entry_Type) return Natural; -- Return number of aliases in host entry function Addresses_Length (E : Host_Entry_Type) return Natural; -- Return number of addresses in host entry function Aliases (E : Host_Entry_Type; N : Positive := 1) return String; -- Return N'th aliases in host entry. The first index is 1 function Addresses (E : Host_Entry_Type; N : Positive := 1) return Inet_Addr_Type; -- Return N'th addresses in host entry. The first index is 1 Host_Error : exception; -- Exception raised by the two following procedures. Once raised, its -- message contains a string describing the error code. This exception is -- raised when an host entry cannot be retrieved. function Get_Host_By_Address (Address : Inet_Addr_Type; Family : Family_Type := Family_Inet) return Host_Entry_Type; -- Return host entry structure for the given Inet address. Note that no -- result will be returned if there is no mapping of this IP address to a -- host name in the system tables (host database, DNS or otherwise). function Get_Host_By_Name (Name : String) return Host_Entry_Type; -- Return host entry structure for the given host name. Here name is -- either a host name, or an IP address. If Name is an IP address, this -- is equivalent to Get_Host_By_Address (Inet_Addr (Name)). function Host_Name return String; -- Return the name of the current host type Service_Entry_Type (Aliases_Length : Natural) is private; -- Service entries provide complete information on a given service: the -- official name, an array of alternative names or aliases and the port -- number. function Official_Name (S : Service_Entry_Type) return String; -- Return official name in service entry function Port_Number (S : Service_Entry_Type) return Port_Type; -- Return port number in service entry function Protocol_Name (S : Service_Entry_Type) return String; -- Return Protocol in service entry (usually UDP or TCP) function Aliases_Length (S : Service_Entry_Type) return Natural; -- Return number of aliases in service entry function Aliases (S : Service_Entry_Type; N : Positive := 1) return String; -- Return N'th aliases in service entry (the first index is 1) function Get_Service_By_Name (Name : String; Protocol : String) return Service_Entry_Type; -- Return service entry structure for the given service name function Get_Service_By_Port (Port : Port_Type; Protocol : String) return Service_Entry_Type; -- Return service entry structure for the given service port number Service_Error : exception; -- Comment required ??? -- Errors are described by an enumeration type. There is only one exception -- Socket_Error in this package to deal with an error during a socket -- routine. Once raised, its message contains the error code between -- brackets and a string describing the error code. -- The name of the enumeration constant documents the error condition -- Note that on some platforms, a single error value is used for both -- EWOULDBLOCK and EAGAIN. Both errors are therefore always reported as -- Resource_Temporarily_Unavailable. type Error_Type is (Success, Permission_Denied, Address_Already_In_Use, Cannot_Assign_Requested_Address, Address_Family_Not_Supported_By_Protocol, Operation_Already_In_Progress, Bad_File_Descriptor, Software_Caused_Connection_Abort, Connection_Refused, Connection_Reset_By_Peer, Destination_Address_Required, Bad_Address, Host_Is_Down, No_Route_To_Host, Operation_Now_In_Progress, Interrupted_System_Call, Invalid_Argument, Input_Output_Error, Transport_Endpoint_Already_Connected, Too_Many_Symbolic_Links, Too_Many_Open_Files, Message_Too_Long, File_Name_Too_Long, Network_Is_Down, Network_Dropped_Connection_Because_Of_Reset, Network_Is_Unreachable, No_Buffer_Space_Available, Protocol_Not_Available, Transport_Endpoint_Not_Connected, Socket_Operation_On_Non_Socket, Operation_Not_Supported, Protocol_Family_Not_Supported, Protocol_Not_Supported, Protocol_Wrong_Type_For_Socket, Cannot_Send_After_Transport_Endpoint_Shutdown, Socket_Type_Not_Supported, Connection_Timed_Out, Too_Many_References, Resource_Temporarily_Unavailable, Broken_Pipe, Unknown_Host, Host_Name_Lookup_Failure, Non_Recoverable_Error, Unknown_Server_Error, Cannot_Resolve_Error); -- Get_Socket_Options and Set_Socket_Options manipulate options associated -- with a socket. Options may exist at multiple protocol levels in the -- communication stack. Socket_Level is the uppermost socket level. type Level_Type is (Socket_Level, IP_Protocol_For_IP_Level, IP_Protocol_For_IPv6_Level, IP_Protocol_For_UDP_Level, IP_Protocol_For_TCP_Level, IP_Protocol_For_ICMP_Level, IP_Protocol_For_IGMP_Level, IP_Protocol_For_RAW_Level); -- There are several options available to manipulate sockets. Each option -- has a name and several values available. Most of the time, the value -- is a boolean to enable or disable this option. Each socket option is -- provided with an appropriate C name taken from the sockets API comments. -- The C name can be used to find a detailed description in the OS-specific -- documentation. The options are grouped by main Level_Type value, which -- can be used together with this option in calls to the Set_Socket_Option -- and Get_Socket_Option routines. Note that some options can be used with -- more than one level. type Option_Name is (Generic_Option, -- Can be used to set/get any socket option via an OS-specific option -- code with an integer value. ------------------ -- Socket_Level -- ------------------ Keep_Alive, -- SO_KEEPALIVE -- Enable sending of keep-alive messages on connection-oriented sockets Reuse_Address, -- SO_REUSEADDR -- Enable binding to an address and port already in use Broadcast, -- SO_BROADCAST -- Enable sending broadcast datagrams on the socket Send_Buffer, -- SO_SNDBUF -- Set/get the maximum socket send buffer in bytes Receive_Buffer, -- SO_RCVBUF -- Set/get the maximum socket receive buffer in bytes Linger, -- SO_LINGER -- When enabled, a Close_Socket or Shutdown_Socket will wait until all -- queued messages for the socket have been successfully sent or the -- linger timeout has been reached. Error, -- SO_ERROR -- Get and clear the pending socket error integer code Send_Timeout, -- SO_SNDTIMEO -- Specify sending timeout until reporting an error Receive_Timeout, -- SO_RCVTIMEO -- Specify receiving timeout until reporting an error Busy_Polling, -- SO_BUSY_POLL -- Sets the approximate time in microseconds to busy poll on a blocking -- receive when there is no data. ------------------------------- -- IP_Protocol_For_TCP_Level -- ------------------------------- No_Delay, -- TCP_NODELAY -- Disable the Nagle algorithm. This means that output buffer content -- is always sent as soon as possible, even if there is only a small -- amount of data. ------------------------------ -- IP_Protocol_For_IP_Level -- ------------------------------ Add_Membership_V4, -- IP_ADD_MEMBERSHIP -- Join a multicast group Drop_Membership_V4, -- IP_DROP_MEMBERSHIP -- Leave a multicast group Multicast_If_V4, -- IP_MULTICAST_IF -- Set/Get outgoing interface for sending multicast packets Multicast_Loop_V4, -- IP_MULTICAST_LOOP -- This boolean option determines whether sent multicast packets should -- be looped back to the local sockets. Multicast_TTL, -- IP_MULTICAST_TTL -- Set/Get the time-to-live of sent multicast packets Receive_Packet_Info, -- IP_PKTINFO -- Receive low-level packet info as ancillary data -------------------------------- -- IP_Protocol_For_IPv6_Level -- -------------------------------- Add_Membership_V6, -- IPV6_ADD_MEMBERSHIP -- Join IPv6 multicast group Drop_Membership_V6, -- IPV6_DROP_MEMBERSHIP -- Leave IPv6 multicast group Multicast_If_V6, -- IPV6_MULTICAST_IF -- Set/Get outgoing interface index for sending multicast packets Multicast_Loop_V6, -- IPV6_MULTICAST_LOOP -- This boolean option determines whether sent multicast IPv6 packets -- should be looped back to the local sockets. IPv6_Only, -- IPV6_V6ONLY -- Restricted to IPv6 communications only Multicast_Hops -- IPV6_MULTICAST_HOPS -- Set the multicast hop limit for the IPv6 socket ); subtype Specific_Option_Name is Option_Name range Keep_Alive .. Option_Name'Last; Add_Membership : Option_Name renames Add_Membership_V4; Drop_Membership : Option_Name renames Drop_Membership_V4; Multicast_If : Option_Name renames Multicast_If_V4; Multicast_Loop : Option_Name renames Multicast_Loop_V4; type Option_Type (Name : Option_Name := Keep_Alive) is record case Name is when Generic_Option => Optname : Interfaces.C.int := -1; Optval : Interfaces.C.int; when Keep_Alive | Reuse_Address | Broadcast | Linger | No_Delay | Receive_Packet_Info | IPv6_Only | Multicast_Loop_V4 | Multicast_Loop_V6 => Enabled : Boolean; case Name is when Linger => Seconds : Natural; when others => null; end case; when Busy_Polling => Microseconds : Natural; when Send_Buffer | Receive_Buffer => Size : Natural; when Error => Error : Error_Type; when Add_Membership_V4 | Add_Membership_V6 | Drop_Membership_V4 | Drop_Membership_V6 => Multicast_Address : Inet_Addr_Type; case Name is when Add_Membership_V4 | Drop_Membership_V4 => Local_Interface : Inet_Addr_Type; when others => Interface_Index : Natural; end case; when Multicast_If_V4 => Outgoing_If : Inet_Addr_Type; when Multicast_If_V6 => Outgoing_If_Index : Natural; when Multicast_TTL => Time_To_Live : Natural; when Multicast_Hops => Hop_Limit : Integer range -1 .. 255; when Send_Timeout | Receive_Timeout => Timeout : Timeval_Duration; end case; end record; -- There are several controls available to manipulate sockets. Each option -- has a name and several values available. These controls differ from the -- socket options in that they are not specific to sockets but are -- available for any device. type Request_Name is (Non_Blocking_IO, -- Cause a caller not to wait on blocking operations N_Bytes_To_Read); -- Return the number of bytes available to read type Request_Type (Name : Request_Name := Non_Blocking_IO) is record case Name is when Non_Blocking_IO => Enabled : Boolean; when N_Bytes_To_Read => Size : Natural; end case; end record; -- A request flag allows specification of the type of message transmissions -- or receptions. A request flag can be combination of zero or more -- predefined request flags. type Request_Flag_Type is private; No_Request_Flag : constant Request_Flag_Type; -- This flag corresponds to the normal execution of an operation Process_Out_Of_Band_Data : constant Request_Flag_Type; -- This flag requests that the receive or send function operates on -- out-of-band data when the socket supports this notion (e.g. -- Socket_Stream). Peek_At_Incoming_Data : constant Request_Flag_Type; -- This flag causes the receive operation to return data from the beginning -- of the receive queue without removing that data from the queue. A -- subsequent receive call will return the same data. Wait_For_A_Full_Reception : constant Request_Flag_Type; -- This flag requests that the operation block until the full request is -- satisfied. However, the call may still return less data than requested -- if a signal is caught, an error or disconnect occurs, or the next data -- to be received is of a different type than that returned. Note that -- this flag depends on support in the underlying sockets implementation, -- and is not supported under Windows. Send_End_Of_Record : constant Request_Flag_Type; -- This flag indicates that the entire message has been sent and so this -- terminates the record. function "+" (L, R : Request_Flag_Type) return Request_Flag_Type; -- Combine flag L with flag R type Stream_Element_Reference is access all Ada.Streams.Stream_Element; type Vector_Element is record Base : Stream_Element_Reference; Length : Interfaces.C.size_t; end record; type Vector_Type is array (Integer range <>) of Vector_Element; type Address_Info is record Addr : Sock_Addr_Type; Mode : Mode_Type := Socket_Stream; Level : Level_Type := IP_Protocol_For_IP_Level; end record; type Address_Info_Array is array (Positive range <>) of Address_Info; function Get_Address_Info (Host : String; Service : String; Family : Family_Type := Family_Unspec; Mode : Mode_Type := Socket_Stream; Level : Level_Type := IP_Protocol_For_IP_Level; Numeric_Host : Boolean := False; Passive : Boolean := False; Unknown : access procedure (Family, Mode, Level, Length : Integer) := null) return Address_Info_Array; -- Returns available addresses for the Host and Service names. -- If Family is Family_Unspec, all available protocol families returned. -- Service is the name of service as defined in /etc/services or port -- number in string representation. -- If Unknown procedure access specified it will be called in case of -- unknown family found. -- Numeric_Host flag suppresses any potentially lengthy network host -- address lookups, and Host have to represent numerical network address in -- this case. -- If Passive is True and Host is empty then the returned socket addresses -- will be suitable for binding a socket that will accept connections. -- The returned socket address will contain the "wildcard address". -- The wildcard address is used by applications (typically servers) that -- intend to accept connections on any of the hosts's network addresses. -- If Host is not empty, then the Passive flag is ignored. -- If Passive is False, then the returned socket addresses will be suitable -- for use with connect, sendto, or sendmsg. If Host is empty, then the -- network address will be set to the loopback interface address; -- this is used by applications that intend to communicate with peers -- running on the same host. procedure Sort (Addr_Info : in out Address_Info_Array; Compare : access function (Left, Right : Address_Info) return Boolean); -- Sort address info array in order defined by compare function function IPv6_TCP_Preferred (Left, Right : Address_Info) return Boolean; -- To use with Sort to order where IPv6 and TCP addresses first type Host_Service (Host_Length, Service_Length : Natural) is record Host : String (1 .. Host_Length); Service : String (1 .. Service_Length); end record; function Get_Name_Info (Addr : Sock_Addr_Type; Numeric_Host : Boolean := False; Numeric_Serv : Boolean := False) return Host_Service; -- Returns host and service names by the address and port. -- If Numeric_Host is True, then the numeric form of the hostname is -- returned. When Numeric_Host is False, this will still happen in case the -- host name cannot be determined. -- If Numenric_Serv is True, then the numeric form of the service address -- (port number) is returned. When Numenric_Serv is False, this will still -- happen in case the service's name cannot be determined. procedure Create_Socket (Socket : out Socket_Type; Family : Family_Type := Family_Inet; Mode : Mode_Type := Socket_Stream; Level : Level_Type := IP_Protocol_For_IP_Level); -- Create an endpoint for communication. Raises Socket_Error on error. procedure Create_Socket_Pair (Left : out Socket_Type; Right : out Socket_Type; Family : Family_Type := Family_Unspec; Mode : Mode_Type := Socket_Stream; Level : Level_Type := IP_Protocol_For_IP_Level); -- Create two connected sockets. Raises Socket_Error on error. -- If Family is unspecified, it creates Family_Unix sockets on UNIX and -- Family_Inet sockets on non UNIX platforms. procedure Accept_Socket (Server : Socket_Type; Socket : out Socket_Type; Address : out Sock_Addr_Type); -- Extracts the first connection request on the queue of pending -- connections, creates a new connected socket with mostly the same -- properties as Server, and allocates a new socket. The returned Address -- is filled in with the address of the connection. Raises Socket_Error on -- error. Note: if Server is a non-blocking socket, whether or not this -- aspect is inherited by Socket is platform-dependent. procedure Accept_Socket (Server : Socket_Type; Socket : out Socket_Type; Address : out Sock_Addr_Type; Timeout : Selector_Duration; Selector : access Selector_Type := null; Status : out Selector_Status); -- Accept a new connection on Server using Accept_Socket, waiting no longer -- than the given timeout duration. Status is set to indicate whether the -- operation completed successfully, timed out, or was aborted. If Selector -- is not null, the designated selector is used to wait for the socket to -- become available, else a private selector object is created by this -- procedure and destroyed before it returns. procedure Bind_Socket (Socket : Socket_Type; Address : Sock_Addr_Type); -- Once a socket is created, assign a local address to it. Raise -- Socket_Error on error. procedure Close_Socket (Socket : Socket_Type); -- Close a socket and more specifically a non-connected socket procedure Connect_Socket (Socket : Socket_Type; Server : Sock_Addr_Type); -- Make a connection to another socket which has the address of Server. -- Raises Socket_Error on error. procedure Connect_Socket (Socket : Socket_Type; Server : Sock_Addr_Type; Timeout : Selector_Duration; Selector : access Selector_Type := null; Status : out Selector_Status); -- Connect Socket to the given Server address using Connect_Socket, waiting -- no longer than the given timeout duration. Status is set to indicate -- whether the operation completed successfully, timed out, or was aborted. -- If Selector is not null, the designated selector is used to wait for the -- socket to become available, else a private selector object is created -- by this procedure and destroyed before it returns. If Timeout is 0.0, -- no attempt is made to detect whether the connection has succeeded; it -- is up to the user to determine this using Check_Selector later on. procedure Control_Socket (Socket : Socket_Type; Request : in out Request_Type); -- Obtain or set parameter values that control the socket. This control -- differs from the socket options in that they are not specific to sockets -- but are available for any device. function Get_Peer_Name (Socket : Socket_Type) return Sock_Addr_Type; -- Return the peer or remote socket address of a socket. Raise -- Socket_Error on error. function Get_Socket_Name (Socket : Socket_Type) return Sock_Addr_Type; -- Return the local or current socket address of a socket. Return -- No_Sock_Addr on error (e.g. socket closed or not locally bound). function Get_Socket_Option (Socket : Socket_Type; Level : Level_Type; Name : Option_Name; Optname : Interfaces.C.int := -1) return Option_Type; -- Get the options associated with a socket. Raises Socket_Error on error. -- Optname identifies specific option when Name is Generic_Option. procedure Listen_Socket (Socket : Socket_Type; Length : Natural := 15); -- To accept connections, a socket is first created with Create_Socket, -- a willingness to accept incoming connections and a queue Length for -- incoming connections are specified. Raise Socket_Error on error. -- The queue length of 15 is an example value that should be appropriate -- in usual cases. It can be adjusted according to each application's -- particular requirements. procedure Receive_Socket (Socket : Socket_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flags : Request_Flag_Type := No_Request_Flag); -- Receive message from Socket. Last is the index value such that Item -- (Last) is the last character assigned. Note that Last is set to -- Item'First - 1 when the socket has been closed by peer. This is not -- an error, and no exception is raised in this case unless Item'First -- is Stream_Element_Offset'First, in which case Constraint_Error is -- raised. Flags allows control of the reception. Raise Socket_Error on -- error. procedure Receive_Socket (Socket : Socket_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; From : out Sock_Addr_Type; Flags : Request_Flag_Type := No_Request_Flag); -- Receive message from Socket. If Socket is not connection-oriented, the -- source address From of the message is filled in. Last is the index -- value such that Item (Last) is the last character assigned. Flags -- allows control of the reception. Raises Socket_Error on error. procedure Receive_Vector (Socket : Socket_Type; Vector : Vector_Type; Count : out Ada.Streams.Stream_Element_Count; Flags : Request_Flag_Type := No_Request_Flag); -- Receive data from a socket and scatter it into the set of vector -- elements Vector. Count is set to the count of received stream elements. -- Flags allow control over reception. function Resolve_Exception (Occurrence : Ada.Exceptions.Exception_Occurrence) return Error_Type; -- When Socket_Error or Host_Error are raised, the exception message -- contains the error code between brackets and a string describing the -- error code. Resolve_Error extracts the error code from an exception -- message and translate it into an enumeration value. procedure Send_Socket (Socket : Socket_Type; Item : Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; To : access Sock_Addr_Type; Flags : Request_Flag_Type := No_Request_Flag); pragma Inline (Send_Socket); -- Transmit a message over a socket. For a datagram socket, the address -- is given by To.all. For a stream socket, To must be null. Last -- is the index value such that Item (Last) is the last character -- sent. Note that Last is set to Item'First - 1 if the socket has been -- closed by the peer (unless Item'First is Stream_Element_Offset'First, -- in which case Constraint_Error is raised instead). This is not an error, -- and Socket_Error is not raised in that case. Flags allows control of the -- transmission. Raises exception Socket_Error on error. Note: this -- subprogram is inlined because it is also used to implement the two -- variants below. procedure Send_Socket (Socket : Socket_Type; Item : Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flags : Request_Flag_Type := No_Request_Flag); -- Transmit a message over a socket. Upon return, Last is set to the index -- within Item of the last element transmitted. Flags allows control of -- the transmission. Raises Socket_Error on any detected error condition. procedure Send_Socket (Socket : Socket_Type; Item : Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; To : Sock_Addr_Type; Flags : Request_Flag_Type := No_Request_Flag); -- Transmit a message over a datagram socket. The destination address is -- To. Flags allows control of the transmission. Raises Socket_Error on -- error. procedure Send_Vector (Socket : Socket_Type; Vector : Vector_Type; Count : out Ada.Streams.Stream_Element_Count; Flags : Request_Flag_Type := No_Request_Flag); -- Transmit data gathered from the set of vector elements Vector to a -- socket. Count is set to the count of transmitted stream elements. Flags -- allow control over transmission. procedure Set_Close_On_Exec (Socket : Socket_Type; Close_On_Exec : Boolean; Status : out Boolean); -- When Close_On_Exec is True, mark Socket to be closed automatically when -- a new program is executed by the calling process (i.e. prevent Socket -- from being inherited by child processes). When Close_On_Exec is False, -- mark Socket to not be closed on exec (i.e. allow it to be inherited). -- Status is False if the operation could not be performed, or is not -- supported on the target platform. procedure Set_Socket_Option (Socket : Socket_Type; Level : Level_Type; Option : Option_Type); -- Manipulate socket options. Raises Socket_Error on error procedure Shutdown_Socket (Socket : Socket_Type; How : Shutmode_Type := Shut_Read_Write); -- Shutdown a connected socket. If How is Shut_Read further receives will -- be disallowed. If How is Shut_Write further sends will be disallowed. -- If How is Shut_Read_Write further sends and receives will be disallowed. type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; -- Same interface as Ada.Streams.Stream_IO function Stream (Socket : Socket_Type) return Stream_Access; -- Create a stream associated with a connected stream-based socket. -- Note: keep in mind that the default stream attributes for composite -- types perform separate Read/Write operations for each component, -- recursively. If performance is an issue, you may want to consider -- introducing a buffering stage. function Stream (Socket : Socket_Type; Send_To : Sock_Addr_Type) return Stream_Access; -- Create a stream associated with an already bound datagram-based socket. -- Send_To is the destination address to which messages are being sent. function Get_Address (Stream : not null Stream_Access) return Sock_Addr_Type; -- Return the socket address from which the last message was received procedure Free is new Ada.Unchecked_Deallocation (Ada.Streams.Root_Stream_Type'Class, Stream_Access); -- Destroy a stream created by one of the Stream functions above, releasing -- the corresponding resources. The user is responsible for calling this -- subprogram when the stream is not needed anymore. type Socket_Set_Type is limited private; -- This type allows manipulation of sets of sockets. It allows waiting -- for events on multiple endpoints at one time. This type has default -- initialization, and the default value is the empty set. -- -- Note: This type used to contain a pointer to dynamically allocated -- storage, but this is not the case anymore, and no special precautions -- are required to avoid memory leaks. procedure Clear (Item : in out Socket_Set_Type; Socket : Socket_Type); -- Remove Socket from Item procedure Copy (Source : Socket_Set_Type; Target : out Socket_Set_Type); -- Copy Source into Target as Socket_Set_Type is limited private procedure Empty (Item : out Socket_Set_Type); -- Remove all Sockets from Item procedure Get (Item : in out Socket_Set_Type; Socket : out Socket_Type); -- Extract a Socket from socket set Item. Socket is set to -- No_Socket when the set is empty. function Is_Empty (Item : Socket_Set_Type) return Boolean; -- Return True iff Item is empty function Is_Set (Item : Socket_Set_Type; Socket : Socket_Type) return Boolean; -- Return True iff Socket is present in Item procedure Set (Item : in out Socket_Set_Type; Socket : Socket_Type); -- Insert Socket into Item function Image (Item : Socket_Set_Type) return String; -- Return a printable image of Item, for debugging purposes -- The select(2) system call waits for events to occur on any of a set of -- file descriptors. Usually, three independent sets of descriptors are -- watched (read, write and exception). A timeout gives an upper bound -- on the amount of time elapsed before select returns. This function -- blocks until an event occurs. On some platforms, the select(2) system -- can block the full process (not just the calling thread). -- -- Check_Selector provides the very same behavior. The only difference is -- that it does not watch for exception events. Note that on some platforms -- it is kept process blocking on purpose. The timeout parameter allows the -- user to have the behavior he wants. Abort_Selector allows the safe -- abort of a blocked Check_Selector call. A special socket is opened by -- Create_Selector and included in each call to Check_Selector. -- -- Abort_Selector causes an event to occur on this descriptor in order to -- unblock Check_Selector. Note that each call to Abort_Selector will cause -- exactly one call to Check_Selector to return with Aborted status. The -- special socket created by Create_Selector is closed when Close_Selector -- is called. -- -- A typical case where it is useful to abort a Check_Selector operation is -- the situation where a change to the monitored sockets set must be made. procedure Create_Selector (Selector : out Selector_Type); -- Initialize (open) a new selector procedure Close_Selector (Selector : in out Selector_Type); -- Close Selector and all internal descriptors associated; deallocate any -- associated resources. This subprogram may be called only when there is -- no other task still using Selector (i.e. still executing Check_Selector -- or Abort_Selector on this Selector). Has no effect if Selector is -- already closed. procedure Check_Selector (Selector : Selector_Type; R_Socket_Set : in out Socket_Set_Type; W_Socket_Set : in out Socket_Set_Type; Status : out Selector_Status; Timeout : Selector_Duration := Forever); -- Return when one Socket in R_Socket_Set has some data to be read or if -- one Socket in W_Socket_Set is ready to transmit some data. In these -- cases Status is set to Completed and sockets that are ready are set in -- R_Socket_Set or W_Socket_Set. Status is set to Expired if no socket was -- ready after a Timeout expiration. Status is set to Aborted if an abort -- signal has been received while checking socket status. -- -- Note that two different Socket_Set_Type objects must be passed as -- R_Socket_Set and W_Socket_Set (even if they denote the same set of -- Sockets), or some event may be lost. Also keep in mind that this -- procedure modifies the passed socket sets to indicate which sockets -- actually had events upon return. The socket set therefore has to -- be reset by the caller for further calls. -- -- Socket_Error is raised when the select(2) system call returns an error -- condition, or when a read error occurs on the signalling socket used for -- the implementation of Abort_Selector. procedure Check_Selector (Selector : Selector_Type; R_Socket_Set : in out Socket_Set_Type; W_Socket_Set : in out Socket_Set_Type; E_Socket_Set : in out Socket_Set_Type; Status : out Selector_Status; Timeout : Selector_Duration := Forever); -- This refined version of Check_Selector allows watching for exception -- events (i.e. notifications of out-of-band transmission and reception). -- As above, all of R_Socket_Set, W_Socket_Set and E_Socket_Set must be -- different objects. procedure Abort_Selector (Selector : Selector_Type); -- Send an abort signal to the selector. The Selector may not be the -- Null_Selector. type Fd_Set is private; -- ??? This type must not be used directly, it needs to be visible because -- it is used in the visible part of GNAT.Sockets.Thin_Common. This is -- really an inversion of abstraction. The private part of GNAT.Sockets -- needs to have visibility on this type, but since Thin_Common is a child -- of Sockets, the type can't be declared there. The correct fix would -- be to move the thin sockets binding outside of GNAT.Sockets altogether, -- e.g. by renaming it to GNAT.Sockets_Thin. private package ASU renames Ada.Strings.Unbounded; type Socket_Type is new Integer; No_Socket : constant Socket_Type := -1; -- A selector is either a null selector, which is always "open" and can -- never be aborted, or a regular selector, which is created "closed", -- becomes "open" when Create_Selector is called, and "closed" again when -- Close_Selector is called. type Selector_Type (Is_Null : Boolean := False) is limited record case Is_Null is when True => null; when False => R_Sig_Socket : Socket_Type := No_Socket; W_Sig_Socket : Socket_Type := No_Socket; -- Signalling sockets used to abort a select operation end case; end record; pragma Volatile (Selector_Type); Null_Selector : constant Selector_Type := (Is_Null => True); type Fd_Set is new System.Storage_Elements.Storage_Array (1 .. SOSC.SIZEOF_fd_set); for Fd_Set'Alignment use Interfaces.C.long'Alignment; -- Set conservative alignment so that our Fd_Sets are always adequately -- aligned for the underlying data type (which is implementation defined -- and may be an array of C long integers). type Fd_Set_Access is access all Fd_Set; pragma Convention (C, Fd_Set_Access); No_Fd_Set_Access : constant Fd_Set_Access := null; type Socket_Set_Type is record Last : Socket_Type := No_Socket; -- Highest socket in set. Last = No_Socket denotes an empty set (which -- is the default initial value). Set : aliased Fd_Set; -- Underlying socket set. Note that the contents of this component is -- undefined if Last = No_Socket. end record; Any_Port : constant Port_Type := 0; No_Port : constant Port_Type := 0; Any_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (others => 0)); Any_Inet6_Addr : constant Inet_Addr_Type := (Family_Inet6, (others => 0)); No_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (others => 0)); Broadcast_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (others => 255)); Loopback_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (127, 0, 0, 1)); Loopback_Inet6_Addr : constant Inet_Addr_Type := (Family_Inet6, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)); Unspecified_Group_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (224, 0, 0, 0)); All_Hosts_Group_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (224, 0, 0, 1)); All_Routers_Group_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (224, 0, 0, 2)); Unspecified_Group_Inet6_Addr : constant Inet_Addr_Type := (Family_Inet6, (255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); All_Hosts_Group_Inet6_Addr : constant Inet_Addr_Type := (Family_Inet6, (255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)); All_Routers_Group_Inet6_Addr : constant Inet_Addr_Type := (Family_Inet6, (255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2)); No_Sock_Addr : constant Sock_Addr_Type := (Family_Inet, No_Inet_Addr, 0); Max_Name_Length : constant := 64; -- The constant MAXHOSTNAMELEN is usually set to 64 subtype Name_Index is Natural range 1 .. Max_Name_Length; type Name_Type (Length : Name_Index := Max_Name_Length) is record Name : String (1 .. Length); end record; -- We need fixed strings to avoid access types in host entry type type Name_Array is array (Positive range <>) of Name_Type; type Inet_Addr_Array is array (Positive range <>) of Inet_Addr_Type; type Host_Entry_Type (Aliases_Length, Addresses_Length : Natural) is record Official : Name_Type; Aliases : Name_Array (1 .. Aliases_Length); Addresses : Inet_Addr_Array (1 .. Addresses_Length); end record; type Service_Entry_Type (Aliases_Length : Natural) is record Official : Name_Type; Port : Port_Type; Protocol : Name_Type; Aliases : Name_Array (1 .. Aliases_Length); end record; type Request_Flag_Type is mod 2 ** 8; No_Request_Flag : constant Request_Flag_Type := 0; Process_Out_Of_Band_Data : constant Request_Flag_Type := 1; Peek_At_Incoming_Data : constant Request_Flag_Type := 2; Wait_For_A_Full_Reception : constant Request_Flag_Type := 4; Send_End_Of_Record : constant Request_Flag_Type := 8; end GNAT.Sockets;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.STRINGS.UTF_ENCODING.WIDE_WIDE_STRINGS -- -- -- -- 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 is an Ada 2012 package defined in AI05-0137-1. It is used for encoding -- and decoding Wide_String values using UTF encodings. Note: this package is -- consistent with Ada 2005, and may be used in Ada 2005 mode, but cannot be -- used in Ada 95 mode, since Wide_Wide_Character is an Ada 2005 feature. package Ada.Strings.UTF_Encoding.Wide_Wide_Strings is pragma Pure (Wide_Wide_Strings); -- The encoding routines take a Wide_Wide_String as input and encode the -- result using the specified UTF encoding method. The result includes a -- BOM if the Output_BOM parameter is set to True. function Encode (Item : Wide_Wide_String; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String; -- Encode Wide_Wide_String using UTF-8, UTF-16LE or UTF-16BE encoding as -- specified by the Output_Scheme parameter. function Encode (Item : Wide_Wide_String; Output_BOM : Boolean := False) return UTF_8_String; -- Encode Wide_Wide_String using UTF-8 encoding function Encode (Item : Wide_Wide_String; Output_BOM : Boolean := False) return UTF_16_Wide_String; -- Encode Wide_Wide_String using UTF_16 encoding -- The decoding routines take a UTF String as input, and return a decoded -- Wide_String. If the UTF String starts with a BOM that matches the -- encoding method, it is ignored. An incorrect BOM raises Encoding_Error. function Decode (Item : UTF_String; Input_Scheme : Encoding_Scheme) return Wide_Wide_String; -- The input is encoded in UTF_8, UTF_16LE or UTF_16BE as specified by the -- Input_Scheme parameter. It is decoded and returned as a Wide_Wide_String -- value. Note: a convenient form for Scheme may be Encoding (UTF_String). function Decode (Item : UTF_8_String) return Wide_Wide_String; -- The input is encoded in UTF-8 and returned as a Wide_Wide_String value function Decode (Item : UTF_16_Wide_String) return Wide_Wide_String; -- The input is encoded in UTF-16 and returned as a Wide_String value end Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2017, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides symbol table to store frequently used strings, -- allocate identifier for them and reduce number of memory allocations by -- reusing shared strings. ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with League.Strings.Internals; with Matreshka.Internals.Strings.Operations; with Matreshka.Internals.Unicode.Characters.Latin; package body Matreshka.Internals.XML.Symbol_Tables is use Matreshka.Internals.Unicode.Characters.Latin; procedure Free is new Ada.Unchecked_Deallocation (Symbol_Record_Array, Symbol_Record_Array_Access); function Is_Valid_NS_Name_Start_Character (Code : Matreshka.Internals.Unicode.Code_Point) return Boolean; -- Returns True when code point belongs to NSNameStartChar. ------------- -- Element -- ------------- function Element (Self : Symbol_Table; Identifier : Symbol_Identifier) return Element_Identifier is begin return Self.Table (Identifier).Element; end Element; -------------- -- Finalize -- -------------- procedure Finalize (Self : in out Symbol_Table) is begin for J in Self.Table'First .. Self.Last loop Matreshka.Internals.Strings.Dereference (Self.Table (J).String); end loop; Free (Self.Table); end Finalize; -------------------- -- General_Entity -- -------------------- function General_Entity (Self : Symbol_Table; Identifier : Symbol_Identifier) return Entity_Identifier is begin return Self.Table (Identifier).General_Entity; end General_Entity; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Symbol_Table) is procedure Register_Predefined_Entity (Name : League.Strings.Universal_String; Entity : Entity_Identifier); -- Registers predefined entity. procedure Register_Symbol (Name : League.Strings.Universal_String); -------------------------------- -- Register_Predefined_Entity -- -------------------------------- procedure Register_Predefined_Entity (Name : League.Strings.Universal_String; Entity : Entity_Identifier) is N : constant Matreshka.Internals.Strings.Shared_String_Access := League.Strings.Internals.Internal (Name); begin Matreshka.Internals.Strings.Reference (N); Self.Last := Self.Last + 1; Self.Table (Self.Last) := (String => N, Namespace_Processed => False, Prefix_Name => No_Symbol, Local_Name => No_Symbol, Element => No_Element, Notation => No_Notation, Parameter_Entity => No_Entity, General_Entity => Entity); end Register_Predefined_Entity; --------------------- -- Register_Symbol -- --------------------- procedure Register_Symbol (Name : League.Strings.Universal_String) is N : constant Matreshka.Internals.Strings.Shared_String_Access := League.Strings.Internals.Internal (Name); begin Matreshka.Internals.Strings.Reference (N); Self.Last := Self.Last + 1; Self.Table (Self.Last) := (String => N, Namespace_Processed => False, Prefix_Name => No_Symbol, Local_Name => No_Symbol, Element => No_Element, Notation => No_Notation, Parameter_Entity => No_Entity, General_Entity => No_Entity); end Register_Symbol; begin Self.Table := new Symbol_Record_Array (0 .. 31); Self.Table (No_Symbol) := (String => Matreshka.Internals.Strings.Shared_Empty'Access, Namespace_Processed => True, Prefix_Name => No_Symbol, Local_Name => No_Symbol, Element => No_Element, Notation => No_Notation, Parameter_Entity => No_Entity, General_Entity => No_Entity); Self.Last := No_Symbol; -- Register predefined entities. Register_Predefined_Entity (Name => League.Strings.To_Universal_String ("lt"), Entity => Entity_lt); Register_Predefined_Entity (Name => League.Strings.To_Universal_String ("gt"), Entity => Entity_gt); Register_Predefined_Entity (Name => League.Strings.To_Universal_String ("amp"), Entity => Entity_amp); Register_Predefined_Entity (Name => League.Strings.To_Universal_String ("apos"), Entity => Entity_apos); Register_Predefined_Entity (Name => League.Strings.To_Universal_String ("quot"), Entity => Entity_quot); -- Register attribute type's names. Register_Symbol (League.Strings.To_Universal_String ("CDATA")); Register_Symbol (League.Strings.To_Universal_String ("ID")); Register_Symbol (League.Strings.To_Universal_String ("IDREF")); Register_Symbol (League.Strings.To_Universal_String ("IDREFS")); Register_Symbol (League.Strings.To_Universal_String ("NMTOKEN")); Register_Symbol (League.Strings.To_Universal_String ("NMTOKENS")); Register_Symbol (League.Strings.To_Universal_String ("ENTITY")); Register_Symbol (League.Strings.To_Universal_String ("ENTITIES")); Register_Symbol (League.Strings.To_Universal_String ("NOTATION")); -- Register well known names and namespaces. Register_Symbol (League.Strings.To_Universal_String ("xml")); Register_Symbol (League.Strings.To_Universal_String ("xmlns")); Register_Symbol (League.Strings.To_Universal_String ("http://www.w3.org/XML/1998/namespace")); Register_Symbol (League.Strings.To_Universal_String ("http://www.w3.org/2000/xmlns/")); Register_Symbol (League.Strings.To_Universal_String ("xml:base")); end Initialize; ------------ -- Insert -- ------------ procedure Insert (Self : in out Symbol_Table; String : not null Matreshka.Internals.Strings.Shared_String_Access; First : Matreshka.Internals.Utf16.Utf16_String_Index; Size : Matreshka.Internals.Utf16.Utf16_String_Index; Length : Natural; Namespaces : Boolean; Qname_Error : out Qualified_Name_Errors; Identifier : out Symbol_Identifier) is use Matreshka.Internals.Unicode; use Matreshka.Internals.Utf16; D_Position : Utf16_String_Index; D_Index : Natural; C : Code_Point; C_Position : Utf16_String_Index; C_Index : Natural; Found : Boolean := False; N_Position : Utf16_String_Index; T_Position : Utf16_String_Index; Prefix_Name : Symbol_Identifier; Local_Name : Symbol_Identifier; begin for J in Self.Table'First .. Self.Last loop if Self.Table (J).String.Unused = Size then N_Position := First; T_Position := 0; while N_Position < First + Size loop exit when String.Value (N_Position) /= Self.Table (J).String.Value (T_Position); N_Position := N_Position + 1; T_Position := T_Position + 1; end loop; if N_Position = First + Size then Identifier := J; Found := True; exit; end if; end if; end loop; if not Found then Self.Last := Self.Last + 1; Identifier := Self.Last; if Self.Last > Self.Table'Last then declare Old : Symbol_Record_Array_Access := Self.Table; begin Self.Table := new Symbol_Record_Array (0 .. Old'Last + 32); Self.Table (Old'Range) := Old.all; Free (Old); end; end if; Self.Table (Identifier) := (String => Matreshka.Internals.Strings.Operations.Slice (String, First, Size, Length), Namespace_Processed => False, Prefix_Name => No_Symbol, Local_Name => No_Symbol, Element => No_Element, Notation => No_Notation, Parameter_Entity => No_Entity, General_Entity => No_Entity); end if; if Namespaces and then not Self.Table (Identifier).Namespace_Processed then D_Position := First; D_Index := 1; Found := False; while D_Position < First + Size loop Unchecked_Next (String.Value, D_Position, C); D_Index := D_Index + 1; if C = Colon then if Found then -- Second colon found in qualified name, document is not -- wellformed. Identifier := No_Symbol; Qname_Error := Multiple_Colons; return; else -- Colon occupy one code unit, use this fact instead of -- more expensive Unchecked_Previous. C_Position := D_Position - 1; C_Index := D_Index - 1; Found := True; end if; end if; end loop; if Found then if C_Position = First then -- Colon is the first character in the qualified name, -- document is not wellformed. Identifier := No_Symbol; Qname_Error := Colon_At_Start; return; elsif C_Position = First + Size - 1 then -- Colon is the last character in the qualified name, -- document is not wellformed. Identifier := No_Symbol; Qname_Error := Colon_At_End; return; end if; -- Check whether the first character after colon belongs to -- NSNameStartChar. D_Position := C_Position + 1; Unchecked_Next (String.Value, D_Position, C); if not Is_Valid_NS_Name_Start_Character (C) then Identifier := No_Symbol; Qname_Error := First_Character_Is_Not_NS_Name_Start_Char; return; end if; Insert (Self, String, First, C_Position - First, C_Index - 1, False, Qname_Error, Prefix_Name); Insert (Self, String, C_Position + 1, First + Size - C_Position - 1, Length - C_Index, False, Qname_Error, Local_Name); Self.Table (Identifier).Prefix_Name := Prefix_Name; Self.Table (Identifier).Local_Name := Local_Name; else Self.Table (Identifier).Local_Name := Identifier; end if; Self.Table (Identifier).Namespace_Processed := True; end if; Qname_Error := Valid; end Insert; ------------ -- Insert -- ------------ procedure Insert (Self : in out Symbol_Table; String : not null Matreshka.Internals.Strings.Shared_String_Access; Identifier : out Symbol_Identifier) is Error : Qualified_Name_Errors; begin Insert (Self, String, 0, String.Unused, String.Length, False, Error, Identifier); end Insert; -------------------------------------- -- Is_Valid_NS_Name_Start_Character -- -------------------------------------- function Is_Valid_NS_Name_Start_Character (Code : Matreshka.Internals.Unicode.Code_Point) return Boolean is use type Matreshka.Internals.Unicode.Code_Point; begin return Code in 16#0041# .. 16#005A# -- A-Z or Code = 16#005F# -- _ or Code in 16#0061# .. 16#007A# -- a-z or Code in 16#00C0# .. 16#00D6# -- \u00C0-\u00D6 or Code in 16#00D8# .. 16#00F6# -- \u00D8-\u00F6 or Code in 16#00F8# .. 16#02FF# -- \u00F8-\u02FF or Code in 16#0370# .. 16#037D# -- \u0370-\u037D or Code in 16#037F# .. 16#1FFF# -- \u037F-\u1FFF or Code in 16#200C# .. 16#200D# -- \u200C-\u200D or Code in 16#2070# .. 16#218F# -- \u2070-\u218F or Code in 16#2C00# .. 16#2FEF# -- \u2C00-\u2FEF or Code in 16#3001# .. 16#D7FF# -- \u3001-\uD7FF or Code in 16#F900# .. 16#FDCF# -- \uF900-\uFDCF or Code in 16#FDF0# .. 16#FFFD# -- \uFDF0-\uFFFD or Code in 16#10000# .. 16#EFFFF#; -- \u10000-\uEFFFF end Is_Valid_NS_Name_Start_Character; ---------------- -- Local_Name -- ---------------- function Local_Name (Self : Symbol_Table; Identifier : Symbol_Identifier) return Symbol_Identifier is begin return Self.Table (Identifier).Local_Name; end Local_Name; ---------------- -- Local_Name -- ---------------- function Local_Name (Self : Symbol_Table; Identifier : Symbol_Identifier) return not null Matreshka.Internals.Strings.Shared_String_Access is begin return Self.Table (Self.Table (Identifier).Local_Name).String; end Local_Name; ---------- -- Name -- ---------- function Name (Self : Symbol_Table; Identifier : Symbol_Identifier) return not null Matreshka.Internals.Strings.Shared_String_Access is begin return Self.Table (Identifier).String; end Name; ---------- -- Name -- ---------- function Name (Self : Symbol_Table; Identifier : Symbol_Identifier) return League.Strings.Universal_String is begin return League.Strings.Internals.Create (Self.Table (Identifier).String); end Name; -------------- -- Notation -- -------------- function Notation (Self : Symbol_Table; Identifier : Symbol_Identifier) return Notation_Identifier is begin return Self.Table (Identifier).Notation; end Notation; ---------------------- -- Parameter_Entity -- ---------------------- function Parameter_Entity (Self : Symbol_Table; Identifier : Symbol_Identifier) return Entity_Identifier is begin return Self.Table (Identifier).Parameter_Entity; end Parameter_Entity; ----------------- -- Prefix_Name -- ----------------- function Prefix_Name (Self : Symbol_Table; Identifier : Symbol_Identifier) return Symbol_Identifier is begin return Self.Table (Identifier).Prefix_Name; end Prefix_Name; ----------- -- Reset -- ----------- procedure Reset (Self : in out Symbol_Table) is begin Finalize (Self); Initialize (Self); end Reset; ----------------- -- Set_Element -- ----------------- procedure Set_Element (Self : in out Symbol_Table; Identifier : Symbol_Identifier; Element : Element_Identifier) is begin Self.Table (Identifier).Element := Element; end Set_Element; ------------------------ -- Set_General_Entity -- ------------------------ procedure Set_General_Entity (Self : in out Symbol_Table; Identifier : Symbol_Identifier; Entity : Entity_Identifier) is begin Self.Table (Identifier).General_Entity := Entity; end Set_General_Entity; ------------------ -- Set_Notation -- ------------------ procedure Set_Notation (Self : in out Symbol_Table; Identifier : Symbol_Identifier; Notation : Notation_Identifier) is begin Self.Table (Identifier).Notation := Notation; end Set_Notation; -------------------------- -- Set_Parameter_Entity -- -------------------------- procedure Set_Parameter_Entity (Self : in out Symbol_Table; Identifier : Symbol_Identifier; Entity : Entity_Identifier) is begin Self.Table (Identifier).Parameter_Entity := Entity; end Set_Parameter_Entity; end Matreshka.Internals.XML.Symbol_Tables;
with Ada.Text_IO, Ada.Numerics.Generic_Elementary_Functions; procedure Trabb_Pardo_Knuth is type Real is digits 6 range -400.0 .. 400.0; package TIO renames Ada.Text_IO; package FIO is new TIO.Float_IO(Real); package Math is new Ada.Numerics.Generic_Elementary_Functions(Real); function F(X: Real) return Real is begin return (Math.Sqrt(abs(X)) + 5.0 * X**3); end F; Values: array(1 .. 11) of Real; begin TIO.Put("Please enter 11 Numbers:"); for I in Values'Range loop FIO.Get(Values(I)); end loop; for I in reverse Values'Range loop TIO.Put("f("); FIO.Put(Values(I), Fore => 2, Aft => 3, Exp => 0); TIO.Put(")="); begin FIO.Put(F(Values(I)), Fore=> 4, Aft => 3, Exp => 0); exception when Constraint_Error => TIO.Put("-->too large<--"); end; TIO.New_Line; end loop; end Trabb_Pardo_Knuth;
-- -- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc. -- ALL RIGHTS RESERVED -- Permission to use, copy, modify, and distribute this software for -- any purpose and without fee is hereby granted, provided that the above -- copyright notice appear in all copies and that both the copyright notice -- and this permission notice appear in supporting documentation, and that -- the name of Silicon Graphics, Inc. not be used in advertising -- or publicity pertaining to distribution of the software without specific, -- written prior permission. -- -- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- -- US Government Users Restricted Rights -- Use, duplication, or disclosure by the Government is subject to -- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- (c)(1)(ii) of the Rights in Technical Data and Computer Software -- clause at DFARS 252.227-7013 and/or in similar or successor -- clauses in the FAR or the DOD or NASA FAR Supplement. -- Unpublished-- rights reserved under the copyright laws of the -- United States. Contractor/manufacturer is Silicon Graphics, -- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- -- OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- with GL; use GL; with Glut; use Glut; package body Teapots_Procs is procedure DoInit is ambient : array (0 .. 3) of aliased GLfloat := (0.0, 0.0, 0.0, 1.0); diffuse : array (0 .. 3) of aliased GLfloat := (1.0, 1.0, 1.0, 1.0); specular : array (0 .. 3) of aliased GLfloat := (1.0, 1.0, 1.0, 1.0); position : array (0 .. 3) of aliased GLfloat := (0.0, 3.0, 3.0, 0.0); lmodel_ambient : array (0 .. 3) of aliased GLfloat := (0.2, 0.2, 0.2, 1.0); local_view : aliased GLfloat := 0.0; begin glLightfv (GL_LIGHT0, GL_AMBIENT, ambient (0)'Access); glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse (0)'Access); glLightfv (GL_LIGHT0, GL_POSITION, position (0)'Access); glLightModelfv (GL_LIGHT_MODEL_AMBIENT, lmodel_ambient (0)'Access); glLightModelfv (GL_LIGHT_MODEL_LOCAL_VIEWER, local_view'Access); glFrontFace (GL_CW); glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); glEnable (GL_AUTO_NORMAL); glEnable (GL_NORMALIZE); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); end DoInit; procedure renderTeapot (x : GLfloat; y : GLfloat; ambr : GLfloat; ambg : GLfloat; ambb : GLfloat; difr : GLfloat; difg : GLfloat; difb : GLfloat; specr : GLfloat; specg : GLfloat; specb : GLfloat; shine : GLfloat) is mat : array (0 .. 3) of aliased GLfloat; begin glPushMatrix; glTranslatef (x, y, 0.0); mat (0) := ambr; mat (1) := ambg; mat (2) := ambb; mat (3) := 1.0; glMaterialfv (GL_FRONT, GL_AMBIENT, mat (0)'Access); mat (0) := difr; mat (1) := difg; mat (2) := difb; glMaterialfv (GL_FRONT, GL_DIFFUSE, mat (0)'Access); mat (0) := specr; mat (1) := specg; mat (2) := specb; glMaterialfv (GL_FRONT, GL_SPECULAR, mat (0)'Access); glMaterialf (GL_FRONT, GL_SHININESS, shine * 128.0); glutSolidTeapot (1.0); glPopMatrix; end renderTeapot; procedure DoDisplay is begin -- 16#4100# = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); renderTeapot (2.0, 17.0, 0.0215, 0.1745, 0.0215, 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); renderTeapot (2.0, 14.0, 0.135, 0.2225, 0.1575, 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1); renderTeapot (2.0, 11.0, 0.05375, 0.05, 0.06625, 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3); renderTeapot (2.0, 8.0, 0.25, 0.20725, 0.20725, 1.0, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088); renderTeapot (2.0, 5.0, 0.1745, 0.01175, 0.01175, 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); renderTeapot (2.0, 2.0, 0.1, 0.18725, 0.1745, 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1); renderTeapot (6.0, 17.0, 0.329412, 0.223529, 0.027451, 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, 0.21794872); renderTeapot (6.0, 14.0, 0.2125, 0.1275, 0.054, 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2); renderTeapot (6.0, 11.0, 0.25, 0.25, 0.25, 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6); renderTeapot (6.0, 8.0, 0.19125, 0.0735, 0.0225, 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1); renderTeapot (6.0, 5.0, 0.24725, 0.1995, 0.0745, 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); renderTeapot (6.0, 2.0, 0.19225, 0.19225, 0.19225, 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); renderTeapot (10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, 0.50, 0.50, 0.50, 0.25); renderTeapot (10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, 0.50196078, 0.50196078, 0.50196078, 0.25); renderTeapot (10.0, 11.0, 0.0, 0.0, 0.0, 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, 0.25); renderTeapot (10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.7, 0.6, 0.6, 0.25); renderTeapot (10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, 0.70, 0.70, 0.70, 0.25); renderTeapot (10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.60, 0.60, 0.50, 0.25); renderTeapot (14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, 0.4, 0.4, 0.4, 0.078125); renderTeapot (14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, 0.04, 0.7, 0.7, 0.078125); renderTeapot (14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, 0.04, 0.7, 0.04, 0.078125); renderTeapot (14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, 0.7, 0.04, 0.04, 0.078125); renderTeapot (14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, 0.7, 0.7, 0.7, 0.078125); renderTeapot (14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, 0.7, 0.7, 0.04, 0.078125); glFlush; end DoDisplay; procedure ReshapeCallback (w : Integer; h : Integer) is begin glViewport (0, 0, GLsizei(w), GLsizei(h)); glMatrixMode (GL_PROJECTION); glLoadIdentity; if w <= h then glOrtho (0.0, 16.0, 0.0, GLdouble (16.0*Float (h)/Float (w)), -10.0, 0.0); else glOrtho (0.0, GLdouble (16.0*Float (w)/Float (h)), 0.0, 16.0, -10.0, 10.0); end if; glMatrixMode (GL_MODELVIEW); end ReshapeCallback; end Teapots_Procs;
with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_Io; with datos; use datos; procedure escribir_lista (L : in Lista_Enteros ) is --Pre: --Post: se han escrito en pantalla los valores de L -- desde 1 hasta L.Cont begin for pos in 1 .. L.Cont loop Put(L.Numeros(pos), width => 3); end loop; new_line; end escribir_lista;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ S I N P U T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2010, Free Software Foundation, Inc. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; with System.WCh_Con; use System.WCh_Con; with Asis.Set_Get; use Asis.Set_Get; with Atree; use Atree; with Opt; use Opt; with Sinfo; use Sinfo; with Sinput; use Sinput; with Widechar; use Widechar; package body A4G.A_Sinput is use ASCII; -- Make control characters visible ----------------------- -- Local subprograms -- ----------------------- procedure Skip_Comment (P : in out Source_Ptr); -- When P is set on the first '-' of a comment, this procedure resets -- the value of P to the first character of the group of control -- characters signifying the end of line containing the comment -- initially indicated by P. -- -- This procedure should not be used for the last comment in the -- group of comments following a compilation unit in a compilation. procedure Skip_String (P : in out Source_Ptr); -- When P set on the first quoter of a string literal (it may be '"' or -- '%', this procedure resets the value of P to the first character -- after the literal. ------------------------- -- A_Get_Column_Number -- ------------------------- function A_Get_Column_Number (P : Source_Ptr) return Source_Ptr is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S : Source_Ptr; Result : Source_Ptr := 0; begin S := Line_Start (P); while S <= P loop if Is_Start_Of_Wide_Char_For_ASIS (Src, S) then Skip_Wide_For_ASIS (Src, S); else S := S + 1; end if; Result := Result + 1; end loop; return Result; end A_Get_Column_Number; ----------------------- -- Comment_Beginning -- ----------------------- function Comment_Beginning (Line_Image : Text_Buffer) return Source_Ptr is Line_Image_Start : constant Source_Ptr := Line_Image'First; Line_Image_End : constant Source_Ptr := Line_Image'Last; Scanner_Pos : Source_Ptr; String_Delimiter : Standard.Character; begin Scanner_Pos := Line_Image_Start - 1; Scan_The_Line : while Scanner_Pos < Line_Image_End loop Scanner_Pos := Scanner_Pos + 1; case Line_Image (Scanner_Pos) is when '"' | '%' => if not ((Scanner_Pos - 1) >= Line_Image_Start and then Line_Image (Scanner_Pos - 1) = ''' and then (Scanner_Pos + 1) <= Line_Image_End and then Line_Image (Scanner_Pos + 1) = ''') then -- We have to awoid considering character literals '"' -- '%' as string brackets String_Delimiter := Line_Image (Scanner_Pos); Skip_String_Literal : loop Scanner_Pos := Scanner_Pos + 1; if Line_Image (Scanner_Pos) = String_Delimiter then -- we are in a legal Ada source, therefore: if Scanner_Pos < Line_Image'Last and then Line_Image (Scanner_Pos + 1) = String_Delimiter then -- Delimiter as character inside the literal. Scanner_Pos := Scanner_Pos + 1; else -- End of the literal. exit Skip_String_Literal; end if; end if; end loop Skip_String_Literal; end if; when '-' => if (Scanner_Pos < Line_Image'Last) and then (Line_Image (Scanner_Pos + 1) = '-') then return Scanner_Pos; end if; when others => null; end case; end loop Scan_The_Line; -- There wasn't any comment if we reach this point. return No_Location; end Comment_Beginning; -------------------- -- Exp_Name_Image -- -------------------- function Exp_Name_Image (Name : Node_Id) return String is Prefix_Node : Node_Id; Selector_Node : Node_Id; begin if Nkind (Name) = N_Identifier or else Nkind (Name) = N_Defining_Identifier then -- ????? See E729-A04! return Identifier_Image (Name); end if; if Nkind (Name) = N_Defining_Program_Unit_Name then Prefix_Node := Sinfo.Name (Name); Selector_Node := Defining_Identifier (Name); else -- Nkind (Name) = N_Expanded_Name Prefix_Node := Prefix (Name); Selector_Node := Selector_Name (Name); end if; return Exp_Name_Image (Prefix_Node) & '.' & Identifier_Image (Selector_Node); -- ??? end Exp_Name_Image; ------------------- -- Get_Character -- ------------------- function Get_Character (P : Source_Ptr) return Character is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); begin return Src (P); end Get_Character; ------------------ -- Get_Location -- ------------------ function Get_Location (E : Asis.Element) return Source_Ptr is begin return Sloc (Node (E)); end Get_Location; ------------------------- -- Get_Num_Literal_End -- ------------------------- function Get_Num_Literal_End (P : Source_Ptr) return Source_Ptr is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S : Source_Ptr; B_Char : Character; begin -- Src (P) is the leading digit of a numeric literal S := P + 1; loop if Is_Hexadecimal_Digit (Src (S)) or else Src (S) = '_' then S := S + 1; elsif Src (S) = '#' or else Src (S) = ':' then -- based literal: 16#E#E1 or 016#offf# -- J.2 (3): "The number sign characters (#) of a based_literal -- can be replaced by colons (:) provided that the replacement -- is done for both occurrences. But in case of a colon, we -- have to make sure that we indeed have a based literal, but not -- a decimal literal immediatelly followed by an assignment sign, -- see G119-012: -- -- SPLIT_INDEX:INTEGER RANGE 1..80:=1; if Src (S) = ':' and then Src (S + 1) = '=' then S := S - 1; exit; end if; B_Char := Src (S); -- and now - looking for trailing '#' or ':': S := S + 1; while Src (S) /= B_Char loop S := S + 1; end loop; if Src (S + 1) = 'E' or else Src (S + 1) = 'e' then -- this means something like 5#1234.1234#E2 S := S + 2; else exit; end if; elsif Src (S) = '+' or else Src (S) = '-' then -- 12E+34 or 12+34? if Src (S - 1) = 'E' or else Src (S - 1) = 'e' then -- it is the sign of the exponent S := S + 1; else S := S - 1; -- to go back in the literal exit; end if; elsif Src (S) = '.' then -- 3.14 or 3..14? if Is_Hexadecimal_Digit (Src (S + 1)) then S := S + 1; else S := S - 1; -- to go back in the literal exit; end if; else -- for sure, we already are outside the literal S := S - 1; -- to go back in the literal exit; end if; end loop; return S; end Get_Num_Literal_End; -------------------- -- Get_String_End -- -------------------- function Get_String_End (P : Source_Ptr) return Source_Ptr is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S : Source_Ptr; Quote : Character; begin -- Src (P) is the leading quotation of the non-nul string constant -- which can be either '"' OR '%' (J.2 (2)). Quote := Src (P); S := P + 1; loop if Src (S) = Quote and then Src (S + 1) = Quote then S := S + 2; elsif Src (S) /= Quote then if Is_Start_Of_Wide_Char_For_ASIS (Src, S) then Skip_Wide_For_ASIS (Src, S); else S := S + 1; end if; else -- S points to the trailing quotation of the constant exit; end if; end loop; return S; end Get_String_End; ------------------- -- Get_Wide_Word -- ------------------- function Get_Wide_Word (P_Start : Source_Ptr; P_End : Source_Ptr) return Wide_String is Sindex : constant Source_File_Index := Get_Source_File_Index (P_Start); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); Result : Wide_String (1 .. Positive (P_End - P_Start + 1)); Last_Idx : Natural := 0; Next_Ch : Char_Code; S : Source_Ptr; Success : Boolean; pragma Unreferenced (Success); begin S := P_Start; while S <= P_End loop Last_Idx := Last_Idx + 1; if Is_Start_Of_Wide_Char_For_ASIS (Src, S) then Scan_Wide (Src, S, Next_Ch, Success); Result (Last_Idx) := Wide_Character'Val (Next_Ch); else Result (Last_Idx) := To_Wide_Character (Src (S)); S := S + 1; end if; end loop; return Result (1 .. Last_Idx); end Get_Wide_Word; ----------------- -- Get_Wide_Ch -- ----------------- function Get_Wide_Ch (S : Source_Ptr) return Wide_Character is Sindex : constant Source_File_Index := Get_Source_File_Index (S); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S1 : Source_Ptr := S; Ch : Char_Code; Result : Wide_Character; Success : Boolean; pragma Unreferenced (Success); begin if Is_Start_Of_Wide_Char_For_ASIS (Src, S1) then Scan_Wide (Src, S1, Ch, Success); Result := Wide_Character'Val (Ch); else Result := To_Wide_Character (Src (S1)); end if; return Result; end Get_Wide_Ch; ------------------ -- Get_Word_End -- ------------------ function Get_Word_End (P : Source_Ptr; In_Word : In_Word_Condition) return Source_Ptr is S : Source_Ptr; begin S := P; while In_Word (S + 1) loop S := S + 1; end loop; return S; end Get_Word_End; ---------------------- -- Identifier_Image -- ---------------------- function Identifier_Image (Ident : Node_Id) return String is Image_Start : Source_Ptr; Image_End : Source_Ptr; begin Image_Start := Sloc (Ident); Image_End := Get_Word_End (P => Image_Start, In_Word => In_Identifier'Access); -- See E729-A04!!! return To_String (Get_Wide_Word (Image_Start, Image_End)); end Identifier_Image; ------------------- -- In_Identifier -- ------------------- function In_Identifier (P : Source_Ptr) return Boolean is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); Char : Character; Result : Boolean := True; begin Char := Src (P); if Char = ' ' or else Char = '&' or else Char = ''' or else Char = '(' or else Char = ')' or else Char = '*' or else Char = '+' or else Char = ',' or else Char = '-' or else Char = '.' or else Char = '/' or else Char = ':' or else Char = ';' or else Char = '<' or else Char = '=' or else Char = '>' or else Char = '|' or else Char = '!' or else Char = ASCII.LF or else Char = ASCII.FF or else Char = ASCII.HT or else Char = ASCII.VT or else Char = ASCII.CR then Result := False; end if; return Result; end In_Identifier; ----------------- -- Is_EOL_Char -- ----------------- function Is_EOL_Char (Ch : Character) return Boolean is Result : Boolean := False; begin Result := Ch = ASCII.CR or else Ch = ASCII.LF or else Ch = ASCII.FF or else Ch = ASCII.VT; return Result; end Is_EOL_Char; ------------------------------------ -- Is_Start_Of_Wide_Char_For_ASIS -- ------------------------------------ function Is_Start_Of_Wide_Char_For_ASIS (S : Source_Buffer_Ptr; P : Source_Ptr; C : Source_Ptr := No_Location) return Boolean is Result : Boolean := False; begin if C /= No_Location and then P > C then -- We are in comment, so we can not have bracket encoding if Wide_Character_Encoding_Method /= WCEM_Brackets then Result := Is_Start_Of_Wide_Char (S, P); end if; else Result := Is_Start_Of_Wide_Char (S, P); if not Result then Result := P <= S'Last - 2 and then S (P) = '[' and then S (P + 1) = '"' and then (S (P + 2) in '0' .. '9' or else S (P + 2) in 'a' .. 'f' or else S (P + 2) in 'A' .. 'F'); end if; end if; return Result; end Is_Start_Of_Wide_Char_For_ASIS; --------------------- -- Next_Identifier -- --------------------- function Next_Identifier (P : Source_Ptr) return Source_Ptr is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S : Source_Ptr; begin S := P + 1; while not Is_Letter (Src (S)) loop if Src (S) = '-' and then Src (S + 1) = '-' then Skip_Comment (S); else S := S + 1; end if; end loop; return S; end Next_Identifier; --------------------- -- Number_Of_Lines -- --------------------- function Number_Of_Lines (E : Asis.Element) return Integer is SFI : constant Source_File_Index := Get_Source_File_Index (Get_Location (E)); begin -- return Integer (Num_Source_Lines (SFI) + Line_Offset (SFI)); return Integer (Num_Source_Lines (SFI)); end Number_Of_Lines; -------------------- -- Operator_Image -- -------------------- function Operator_Image (Node : Node_Id) return String is S_Start : constant Source_Ptr := Sloc (Node); -- S_Start points to the leading character of a given operator symbol. Sindex : constant Source_File_Index := Get_Source_File_Index (S_Start); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S_End : Source_Ptr := S_Start; -- should be set as pointing to the last character of a given -- operator symbol. Ch : Character; begin Ch := Src (S_Start); if Ch = 'A' or else Ch = 'a' -- "abs" or "and" or else Ch = 'M' or else Ch = 'm' -- "mod" or else Ch = 'N' or else Ch = 'n' -- "not" or else Ch = 'R' or else Ch = 'r' -- "rem" or else Ch = 'X' or else Ch = 'x' -- "xor" then S_End := S_Start + 2; elsif Ch = 'O' or else Ch = 'o' then -- "or" S_End := S_Start + 1; elsif Ch = '=' -- "=" or else Ch = '+' -- "+" or else Ch = '-' -- "-" or else Ch = '&' -- "&" then S_End := S_Start; elsif Ch = '/' -- "/=" or "/"? or else Ch = '<' -- "<=" or "<"? or else Ch = '>' -- ">=" or ">"? or else Ch = '*' -- "**" or "*"? then Ch := Src (S_Start + 1); if Ch = '=' or else -- "/=", "<=" or ">=" Ch = '*' -- "**" then S_End := S_Start + 1; else S_End := S_Start; -- "<", ">", "*" or "/" end if; end if; return (1 => '"') & String (Src (S_Start .. S_End)) & (1 => '"'); end Operator_Image; ------------------------- -- Rightmost_Non_Blank -- ------------------------- function Rightmost_Non_Blank (P : Source_Ptr) return Source_Ptr is S : Source_Ptr := P; Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); begin loop if Src (S) = '-' and then Src (S + 1) = '-' then Skip_Comment (S); elsif Is_Graphic (Src (S)) and then Src (S) /= ' ' then exit; else S := S + 1; end if; end loop; return S; end Rightmost_Non_Blank; ------------------------------ -- Search_Beginning_Of_Word -- ------------------------------ function Search_Beginning_Of_Word (S : Source_Ptr) return Source_Ptr is SFI : constant Source_File_Index := Get_Source_File_Index (S); Src : constant Source_Buffer_Ptr := Source_Text (SFI); S_P : Source_Ptr; begin S_P := S; while S_P >= Source_First (SFI) and then (Src (S_P) in 'A' .. 'Z' or else Src (S_P) in 'a' .. 'z' or else Src (S_P) in '0' .. '9' or else Src (S_P) = '_') loop S_P := S_P - 1; end loop; return S_P + 1; end Search_Beginning_Of_Word; ------------------------ -- Search_End_Of_Word -- ------------------------ function Search_End_Of_Word (S : Source_Ptr) return Source_Ptr is S_P : Source_Ptr := S; SFI : constant Source_File_Index := Get_Source_File_Index (S); Src : constant Source_Buffer_Ptr := Source_Text (SFI); Char : Character; begin Char := Src (S_P); while not (Char = ' ' or else Char = '&' or else Char = ''' or else Char = '(' or else Char = ')' or else Char = '*' or else Char = '+' or else Char = ',' or else Char = '-' or else Char = '.' or else Char = '/' or else Char = ':' or else Char = ';' or else Char = '<' or else Char = '=' or else Char = '>' or else Char = '|' or else Char = '!' or else Char = ASCII.LF or else Char = ASCII.FF or else Char = ASCII.HT or else Char = ASCII.VT or else Char = ASCII.CR) loop S_P := S_P + 1; Char := Src (S_P); end loop; S_P := S_P - 1; return S_P; end Search_End_Of_Word; ----------------------------- -- Search_Left_Parenthesis -- ----------------------------- function Search_Left_Parenthesis (S : Source_Ptr) return Source_Ptr is S_P : Source_Ptr := S - 1; SFI : constant Source_File_Index := Get_Source_File_Index (S); Src : constant Source_Buffer_Ptr := Source_Text (SFI); begin loop case Src (S_P) is when '(' => return S_P; when CR | LF => declare TempS : Source_Ptr := Line_Start (S_P); begin while (Src (TempS) /= '-' or else Src (TempS + 1) /= '-') and then TempS < S_P loop TempS := TempS + 1; end loop; S_P := TempS - 1; end; when others => S_P := S_P - 1; end case; end loop; end Search_Left_Parenthesis; ---------------------- -- Search_Next_Word -- ---------------------- function Search_Next_Word (S : Source_Ptr) return Source_Ptr is S_P : Source_Ptr := S + 1; SFI : constant Source_File_Index := Get_Source_File_Index (S); Src : constant Source_Buffer_Ptr := Source_Text (SFI); begin loop case Src (S_P) is when ' ' | HT | CR | LF => S_P := S_P + 1; when '-' => if Src (S_P + 1) = '-' then Skip_Comment (S_P); else return S_P; end if; when others => return S_P; end case; end loop; end Search_Next_Word; ---------------------- -- Search_Prev_Word -- ---------------------- function Search_Prev_Word (S : Source_Ptr) return Source_Ptr is S_P : Source_Ptr := S - 1; SFI : constant Source_File_Index := Get_Source_File_Index (S); Src : constant Source_Buffer_Ptr := Source_Text (SFI); begin loop case Src (S_P) is when ' ' | HT => S_P := S_P - 1; when CR | LF => declare TempS : Source_Ptr := Line_Start (S_P); begin while (Src (TempS) /= '-' or else Src (TempS + 1) /= '-') and then TempS < S_P loop TempS := TempS + 1; end loop; S_P := TempS - 1; end; when others => return S_P; end case; end loop; end Search_Prev_Word; ---------------------------- -- Search_Prev_Word_Start -- ---------------------------- function Search_Prev_Word_Start (S : Source_Ptr) return Source_Ptr is begin return Search_Beginning_Of_Word (Search_Prev_Word (S)); end Search_Prev_Word_Start; ----------------------------- -- Search_Rightmost_Symbol -- ----------------------------- function Search_Rightmost_Symbol (P : Source_Ptr; Char : Character := ';') return Source_Ptr is S : Source_Ptr := P; -- the location to be returned, the search is started from P Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); begin while Src (S) /= Char loop if Src (S) = '-' and then Src (S + 1) = '-' then Skip_Comment (S); elsif (Src (S) = '"' or else Src (S) = '%') and then not (Src (S - 1) = ''' and then Src (S + 1) = ''') then Skip_String (S); else S := S + 1; end if; end loop; return S; end Search_Rightmost_Symbol; ----------------- -- Skip_String -- ----------------- procedure Skip_String (P : in out Source_Ptr) is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); Quoter : constant Character := Src (P); begin -- we are in the beginning of a legal string literal in a legal -- Ada program. So we do not have to be careful with all -- the checks: while not (Src (P) = Quoter and then Src (P + 1) /= Quoter) loop P := P + 1; end loop; P := P + 1; end Skip_String; ------------------ -- Skip_Comment -- ------------------ procedure Skip_Comment (P : in out Source_Ptr) is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); begin if Src (P) = '-' and then Src (P + 1) = '-' then P := P + 2; while not (Src (P) = VT or else Src (P) = CR or else Src (P) = LF or else Src (P) = FF) loop P := P + 1; end loop; end if; end Skip_Comment; ------------------------ -- Skip_Wide_For_ASIS -- ------------------------ procedure Skip_Wide_For_ASIS (S : Source_Buffer_Ptr; P : in out Source_Ptr) is Old_P : constant Source_Ptr := P; Old_Wide_Character_Encoding_Method : WC_Encoding_Method; begin Skip_Wide (S, P); if P = Old_P + 1 then -- We have a bracket encoding, but the encoding method is different -- from WCEM_Brackets P := P - 1; Old_Wide_Character_Encoding_Method := Wide_Character_Encoding_Method; Wide_Character_Encoding_Method := WCEM_Brackets; Skip_Wide (S, P); Wide_Character_Encoding_Method := Old_Wide_Character_Encoding_Method; end if; end Skip_Wide_For_ASIS; ------------------------------ -- Source_Locations_To_Span -- ------------------------------ function Source_Locations_To_Span (Span_Beg : Source_Ptr; Span_End : Source_Ptr) return Span is Sp : Span; begin Sp.First_Line := Line_Number (Get_Physical_Line_Number (Span_Beg)); Sp.First_Column := Character_Position (A_Get_Column_Number (Span_Beg)); Sp.Last_Line := Line_Number (Get_Physical_Line_Number (Span_End)); Sp.Last_Column := Character_Position (A_Get_Column_Number (Span_End)); return Sp; end Source_Locations_To_Span; ----------------------- -- Wide_String_Image -- ----------------------- function Wide_String_Image (Node : Node_Id) return Wide_String is S_Start : constant Source_Ptr := Sloc (Node); -- S_Start points to the leading quote of a given string literal. Sindex : constant Source_File_Index := Get_Source_File_Index (S_Start); Src : constant Source_Buffer_Ptr := Source_Text (Sindex); S_End : Source_Ptr := S_Start + 1; -- should be set as pointing to the last character of a -- string literal; empty and non-empty literals are processed -- in the same way - we simply take a literal as it is from the -- Source Buffer Quote : constant Character := Src (S_Start); -- Quoter may be '"' or '%'! begin loop if Src (S_End) = Quote and then Src (S_End + 1) = Quote then -- doubled string quote as an element of a given string S_End := S_End + 2; elsif Src (S_End) /= Quote then -- "usial" string element S_End := S_End + 1; else -- S_End points to the trailing quote of a given string exit; end if; end loop; declare Result : Wide_String (1 .. Positive (S_End - S_Start + 1)); Last_Idx : Natural := 0; Next_Ch : Char_Code; S : Source_Ptr; Success : Boolean; pragma Unreferenced (Success); begin S := S_Start; while S <= S_End loop Last_Idx := Last_Idx + 1; if Is_Start_Of_Wide_Char_For_ASIS (Src, S) then Scan_Wide (Src, S, Next_Ch, Success); Result (Last_Idx) := Wide_Character'Val (Next_Ch); else Result (Last_Idx) := To_Wide_Character (Src (S)); S := S + 1; end if; end loop; return Result (1 .. Last_Idx); end; end Wide_String_Image; end A4G.A_Sinput;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M -- -- -- -- S p e c -- -- -- -- $Revision: 33902 $ -- -- -- -- This specification is adapted 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. -- -- -- ------------------------------------------------------------------------------ -- Note: although the values in System are target dependent, the source of -- the package System itself is target independent in GNAT. This is achieved -- by using attributes for all values, including the special additional GNAT -- Standard attributes that are provided for exactly this purpose. pragma Ada_95; -- Since we may be withed from Ada_83 code package System is pragma Pure (System); -- Note that we take advantage of the implementation permission to -- make this unit Pure instead of Preelaborable, see RM 13.7(36) type Name is (GNAT); System_Name : constant Name := GNAT; -- System-Dependent Named Numbers Min_Int : constant := Long_Long_Integer'First; Max_Int : constant := Long_Long_Integer'Last; Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size; Max_Nonbinary_Modulus : constant := Integer'Last; Max_Base_Digits : constant := Long_Long_Float'Digits; Max_Digits : constant := Long_Long_Float'Digits; Max_Mantissa : constant := Long_Long_Integer'Size - 1; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); -- Changed value to avoid using GNAT Standard attributes -- Tick : constant := Standard'Tick; Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; -- Changed values to avoid using GNAT Standard attributes --Storage_Unit : constant := Standard'Storage_Unit; --Word_Size : constant := Standard'Word_Size; --Memory_Size : constant := 2 ** Standard'Address_Size; Storage_Unit : constant := 8; -- System-Dependent Word_Size : constant := 32; -- System-Dependent Memory_Size : constant := 2 ** 32; -- System-Dependent -- Address comparison function "<" (Left, Right : Address) return Boolean; function "<=" (Left, Right : Address) return Boolean; function ">" (Left, Right : Address) return Boolean; function ">=" (Left, Right : Address) return Boolean; function "=" (Left, Right : Address) return Boolean; pragma Import (Intrinsic, "<"); pragma Import (Intrinsic, "<="); pragma Import (Intrinsic, ">"); pragma Import (Intrinsic, ">="); pragma Import (Intrinsic, "="); -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); Default_Bit_Order : constant Bit_Order; -- Priority-related Declarations (RM D.1) Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; subtype Any_Priority is Integer range 0 .. 31; subtype Priority is Any_Priority range 0 .. 30; subtype Interrupt_Priority is Any_Priority range 31 .. 31; Default_Priority : constant Priority := 15; private type Address is mod Memory_Size; Null_Address : constant Address := 0; Default_Bit_Order : constant Bit_Order := Low_Order_First; end System;
with Giza.Widget; use Giza; with Giza.Colors; use Giza.Colors; with bmp_test_indexed_8bits; with bmp_test_indexed_8bits_dma2d; package body Test_Button_Window is ------------- -- On_Init -- ------------- overriding procedure On_Init (This : in out Button_Window) is begin On_Init (Test_Window (This)); This.Button_1 := new Button.Instance; This.Button_1.Set_Text ("Button"); This.Button_1.Set_Size ((This.Get_Size.W, This.Get_Size.H / 3 - 1)); This.Add_Child (Widget.Reference (This.Button_1), (0, 0)); This.Button_2 := new Button.Instance; This.Button_2.Set_Text ("Toggle"); This.Button_2.Set_Toggle; This.Button_2.Set_Size ((This.Get_Size.W, This.Get_Size.H / 3 - 1)); This.Add_Child (Widget.Reference (This.Button_2), (0, This.Button_1.Get_Size.H)); This.Button_3 := new Button.Instance; This.Button_3.Disable_Frame; This.Button_3.Set_Background (White); This.Button_3.Set_Foreground (White); This.Button_3.Set_Image (bmp_test_indexed_8bits.Image'Access); This.Button_3.Set_Invert_Image (bmp_test_indexed_8bits_dma2d.Image); This.Button_3.Set_Size ((This.Get_Size.W, This.Get_Size.H / 3)); This.Add_Child (Widget.Reference (This.Button_3), (0, This.Button_1.Get_Size.H * 2)); end On_Init; ------------------ -- On_Displayed -- ------------------ overriding procedure On_Displayed (This : in out Button_Window) is pragma Unreferenced (This); begin null; end On_Displayed; --------------- -- On_Hidden -- --------------- overriding procedure On_Hidden (This : in out Button_Window) is pragma Unreferenced (This); begin null; end On_Hidden; end Test_Button_Window;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.AES is pragma Preelaborate; --------------- -- Registers -- --------------- -- AES Modes of operation type CTRLA_AESMODESelect is (-- Electronic code book mode ECB, -- Cipher block chaining mode CBC, -- Output feedback mode OFB, -- Cipher feedback mode CFB, -- Counter mode COUNTER, -- CCM mode CCM, -- Galois counter mode GCM) with Size => 3; for CTRLA_AESMODESelect use (ECB => 0, CBC => 1, OFB => 2, CFB => 3, COUNTER => 4, CCM => 5, GCM => 6); -- Cipher Feedback Block Size type CTRLA_CFBSSelect is (-- 128-bit Input data block for Encryption/Decryption in Cipher Feedback mode Val_128BIT, -- 64-bit Input data block for Encryption/Decryption in Cipher Feedback mode Val_64BIT, -- 32-bit Input data block for Encryption/Decryption in Cipher Feedback mode Val_32BIT, -- 16-bit Input data block for Encryption/Decryption in Cipher Feedback mode Val_16BIT, -- 8-bit Input data block for Encryption/Decryption in Cipher Feedback mode Val_8BIT) with Size => 3; for CTRLA_CFBSSelect use (Val_128BIT => 0, Val_64BIT => 1, Val_32BIT => 2, Val_16BIT => 3, Val_8BIT => 4); -- Encryption Key Size type CTRLA_KEYSIZESelect is (-- 128-bit Key for Encryption / Decryption Val_128BIT, -- 192-bit Key for Encryption / Decryption Val_192BIT, -- 256-bit Key for Encryption / Decryption Val_256BIT) with Size => 2; for CTRLA_KEYSIZESelect use (Val_128BIT => 0, Val_192BIT => 1, Val_256BIT => 2); -- Cipher Mode type CTRLA_CIPHERSelect is (-- Decryption DEC, -- Encryption ENC) with Size => 1; for CTRLA_CIPHERSelect use (DEC => 0, ENC => 1); -- Start Mode Select type CTRLA_STARTMODESelect is (-- Start Encryption / Decryption in Manual mode MANUAL, -- Start Encryption / Decryption in Auto mode AUTO) with Size => 1; for CTRLA_STARTMODESelect use (MANUAL => 0, AUTO => 1); -- Last Output Data Mode type CTRLA_LODSelect is (-- No effect NONE, -- Start encryption in Last Output Data mode LAST) with Size => 1; for CTRLA_LODSelect use (NONE => 0, LAST => 1); -- Last Key Generation type CTRLA_KEYGENSelect is (-- No effect NONE, -- Start Computation of the last NK words of the expanded key LAST) with Size => 1; for CTRLA_KEYGENSelect use (NONE => 0, LAST => 1); -- XOR Key Operation type CTRLA_XORKEYSelect is (-- No effect NONE, -- The user keyword gets XORed with the previous keyword register content. XOR_k) with Size => 1; for CTRLA_XORKEYSelect use (NONE => 0, XOR_k => 1); subtype AES_CTRLA_CTYPE_Field is HAL.UInt4; -- Control A type AES_CTRLA_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- AES Modes of operation AESMODE : CTRLA_AESMODESelect := SAM_SVD.AES.ECB; -- Cipher Feedback Block Size CFBS : CTRLA_CFBSSelect := SAM_SVD.AES.Val_128BIT; -- Encryption Key Size KEYSIZE : CTRLA_KEYSIZESelect := SAM_SVD.AES.Val_128BIT; -- Cipher Mode CIPHER : CTRLA_CIPHERSelect := SAM_SVD.AES.DEC; -- Start Mode Select STARTMODE : CTRLA_STARTMODESelect := SAM_SVD.AES.MANUAL; -- Last Output Data Mode LOD : CTRLA_LODSelect := SAM_SVD.AES.NONE; -- Last Key Generation KEYGEN : CTRLA_KEYGENSelect := SAM_SVD.AES.NONE; -- XOR Key Operation XORKEY : CTRLA_XORKEYSelect := SAM_SVD.AES.NONE; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Counter Measure Type CTYPE : AES_CTRLA_CTYPE_Field := 16#0#; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AES_CTRLA_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; AESMODE at 0 range 2 .. 4; CFBS at 0 range 5 .. 7; KEYSIZE at 0 range 8 .. 9; CIPHER at 0 range 10 .. 10; STARTMODE at 0 range 11 .. 11; LOD at 0 range 12 .. 12; KEYGEN at 0 range 13 .. 13; XORKEY at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; CTYPE at 0 range 16 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- Control B type AES_CTRLB_Register is record -- Start Encryption/Decryption START : Boolean := False; -- New message NEWMSG : Boolean := False; -- End of message EOM : Boolean := False; -- GF Multiplication GFMUL : Boolean := False; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for AES_CTRLB_Register use record START at 0 range 0 .. 0; NEWMSG at 0 range 1 .. 1; EOM at 0 range 2 .. 2; GFMUL at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; end record; -- Interrupt Enable Clear type AES_INTENCLR_Register is record -- Encryption Complete Interrupt Enable ENCCMP : Boolean := False; -- GF Multiplication Complete Interrupt Enable GFMCMP : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for AES_INTENCLR_Register use record ENCCMP at 0 range 0 .. 0; GFMCMP at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; end record; -- Interrupt Enable Set type AES_INTENSET_Register is record -- Encryption Complete Interrupt Enable ENCCMP : Boolean := False; -- GF Multiplication Complete Interrupt Enable GFMCMP : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for AES_INTENSET_Register use record ENCCMP at 0 range 0 .. 0; GFMCMP at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; end record; -- Interrupt Flag Status type AES_INTFLAG_Register is record -- Encryption Complete ENCCMP : Boolean := False; -- GF Multiplication Complete GFMCMP : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for AES_INTFLAG_Register use record ENCCMP at 0 range 0 .. 0; GFMCMP at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; end record; subtype AES_DATABUFPTR_INDATAPTR_Field is HAL.UInt2; -- Data buffer pointer type AES_DATABUFPTR_Register is record -- Input Data Pointer INDATAPTR : AES_DATABUFPTR_INDATAPTR_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for AES_DATABUFPTR_Register use record INDATAPTR at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; end record; -- Debug control type AES_DBGCTRL_Register is record -- Debug Run DBGRUN : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for AES_DBGCTRL_Register use record DBGRUN at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- Keyword n -- Keyword n type AES_KEYWORD_Registers is array (0 .. 7) of HAL.UInt32; -- Initialisation Vector n -- Initialisation Vector n type AES_INTVECTV_Registers is array (0 .. 3) of HAL.UInt32; -- Hash key n -- Hash key n type AES_HASHKEY_Registers is array (0 .. 3) of HAL.UInt32; -- Galois Hash n -- Galois Hash n type AES_GHASH_Registers is array (0 .. 3) of HAL.UInt32; ----------------- -- Peripherals -- ----------------- -- Advanced Encryption Standard type AES_Peripheral is record -- Control A CTRLA : aliased AES_CTRLA_Register; -- Control B CTRLB : aliased AES_CTRLB_Register; -- Interrupt Enable Clear INTENCLR : aliased AES_INTENCLR_Register; -- Interrupt Enable Set INTENSET : aliased AES_INTENSET_Register; -- Interrupt Flag Status INTFLAG : aliased AES_INTFLAG_Register; -- Data buffer pointer DATABUFPTR : aliased AES_DATABUFPTR_Register; -- Debug control DBGCTRL : aliased AES_DBGCTRL_Register; -- Keyword n KEYWORD : aliased AES_KEYWORD_Registers; -- Indata INDATA : aliased HAL.UInt32; -- Initialisation Vector n INTVECTV : aliased AES_INTVECTV_Registers; -- Hash key n HASHKEY : aliased AES_HASHKEY_Registers; -- Galois Hash n GHASH : aliased AES_GHASH_Registers; -- Cipher Length CIPLEN : aliased HAL.UInt32; -- Random Seed RANDSEED : aliased HAL.UInt32; end record with Volatile; for AES_Peripheral use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 7; INTENCLR at 16#5# range 0 .. 7; INTENSET at 16#6# range 0 .. 7; INTFLAG at 16#7# range 0 .. 7; DATABUFPTR at 16#8# range 0 .. 7; DBGCTRL at 16#9# range 0 .. 7; KEYWORD at 16#C# range 0 .. 255; INDATA at 16#38# range 0 .. 31; INTVECTV at 16#3C# range 0 .. 127; HASHKEY at 16#5C# range 0 .. 127; GHASH at 16#6C# range 0 .. 127; CIPLEN at 16#80# range 0 .. 31; RANDSEED at 16#84# range 0 .. 31; end record; -- Advanced Encryption Standard AES_Periph : aliased AES_Peripheral with Import, Address => AES_Base; end SAM_SVD.AES;
-- 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.USB is pragma Preelaborate; --------------- -- Registers -- --------------- subtype DEVCMDSTAT_DEV_ADDR_Field is HAL.UInt7; -- Forces the NEEDCLK output to always be on: type DEVCMDSTAT_FORCE_NEEDCLK_Field is ( -- USB_NEEDCLK has normal function. Normal, -- USB_NEEDCLK always 1. Clock will not be stopped in case of suspend. Always_On) with Size => 1; for DEVCMDSTAT_FORCE_NEEDCLK_Field use (Normal => 0, Always_On => 1); -- LPM Supported: type DEVCMDSTAT_LPM_SUP_Field is ( -- LPM not supported. No, -- LPM supported. Yes) with Size => 1; for DEVCMDSTAT_LPM_SUP_Field use (No => 0, Yes => 1); -- Interrupt on NAK for interrupt and bulk OUT EP type DEVCMDSTAT_INTONNAK_AO_Field is ( -- Only acknowledged packets generate an interrupt Disabled, -- Both acknowledged and NAKed packets generate interrupts. Enabled) with Size => 1; for DEVCMDSTAT_INTONNAK_AO_Field use (Disabled => 0, Enabled => 1); -- Interrupt on NAK for interrupt and bulk IN EP type DEVCMDSTAT_INTONNAK_AI_Field is ( -- Only acknowledged packets generate an interrupt Disabled, -- Both acknowledged and NAKed packets generate interrupts. Enabled) with Size => 1; for DEVCMDSTAT_INTONNAK_AI_Field use (Disabled => 0, Enabled => 1); -- Interrupt on NAK for control OUT EP type DEVCMDSTAT_INTONNAK_CO_Field is ( -- Only acknowledged packets generate an interrupt Disabled, -- Both acknowledged and NAKed packets generate interrupts. Enabled) with Size => 1; for DEVCMDSTAT_INTONNAK_CO_Field use (Disabled => 0, Enabled => 1); -- Interrupt on NAK for control IN EP type DEVCMDSTAT_INTONNAK_CI_Field is ( -- Only acknowledged packets generate an interrupt Disabled, -- Both acknowledged and NAKed packets generate interrupts. Enabled) with Size => 1; for DEVCMDSTAT_INTONNAK_CI_Field use (Disabled => 0, Enabled => 1); -- USB Device Command/Status register type DEVCMDSTAT_Register is record -- USB device address. After bus reset, the address is reset to 0x00. If -- the enable bit is set, the device will respond on packets for -- function address DEV_ADDR. When receiving a SetAddress Control -- Request from the USB host, software must program the new address -- before completing the status phase of the SetAddress Control Request. DEV_ADDR : DEVCMDSTAT_DEV_ADDR_Field := 16#0#; -- USB device enable. If this bit is set, the HW will start responding -- on packets for function address DEV_ADDR. DEV_EN : Boolean := False; -- SETUP token received. If a SETUP token is received and acknowledged -- by the device, this bit is set. As long as this bit is set all -- received IN and OUT tokens will be NAKed by HW. SW must clear this -- bit by writing a one. If this bit is zero, HW will handle the tokens -- to the CTRL EP0 as indicated by the CTRL EP0 IN and OUT data -- information programmed by SW. SETUP : Boolean := False; -- Forces the NEEDCLK output to always be on: FORCE_NEEDCLK : DEVCMDSTAT_FORCE_NEEDCLK_Field := NXP_SVD.USB.Normal; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- LPM Supported: LPM_SUP : DEVCMDSTAT_LPM_SUP_Field := NXP_SVD.USB.Yes; -- Interrupt on NAK for interrupt and bulk OUT EP INTONNAK_AO : DEVCMDSTAT_INTONNAK_AO_Field := NXP_SVD.USB.Disabled; -- Interrupt on NAK for interrupt and bulk IN EP INTONNAK_AI : DEVCMDSTAT_INTONNAK_AI_Field := NXP_SVD.USB.Disabled; -- Interrupt on NAK for control OUT EP INTONNAK_CO : DEVCMDSTAT_INTONNAK_CO_Field := NXP_SVD.USB.Disabled; -- Interrupt on NAK for control IN EP INTONNAK_CI : DEVCMDSTAT_INTONNAK_CI_Field := NXP_SVD.USB.Disabled; -- Device status - connect. The connect bit must be set by SW to -- indicate that the device must signal a connect. The pull-up resistor -- on USB_DP will be enabled when this bit is set and the VBUSDEBOUNCED -- bit is one. DCON : Boolean := False; -- Device status - suspend. The suspend bit indicates the current -- suspend state. It is set to 1 when the device hasn't seen any -- activity on its upstream port for more than 3 milliseconds. It is -- reset to 0 on any activity. When the device is suspended (Suspend bit -- DSUS = 1) and the software writes a 0 to it, the device will generate -- a remote wake-up. This will only happen when the device is connected -- (Connect bit = 1). When the device is not connected or not suspended, -- a writing a 0 has no effect. Writing a 1 never has an effect. DSUS : Boolean := False; -- unspecified Reserved_18_18 : HAL.Bit := 16#0#; -- Device status - LPM Suspend. This bit represents the current LPM -- suspend state. It is set to 1 by HW when the device has acknowledged -- the LPM request from the USB host and the Token Retry Time of 10 ms -- has elapsed. When the device is in the LPM suspended state (LPM -- suspend bit = 1) and the software writes a zero to this bit, the -- device will generate a remote walk-up. Software can only write a zero -- to this bit when the LPM_REWP bit is set to 1. HW resets this bit -- when it receives a host initiated resume. HW only updates the LPM_SUS -- bit when the LPM_SUPP bit is equal to one. LPM_SUS : Boolean := False; -- Read-only. LPM Remote Wake-up Enabled by USB host. HW sets this bit -- to one when the bRemoteWake bit in the LPM extended token is set to -- 1. HW will reset this bit to 0 when it receives the host initiated -- LPM resume, when a remote wake-up is sent by the device or when a USB -- bus reset is received. Software can use this bit to check if the -- remote wake-up feature is enabled by the host for the LPM -- transaction. LPM_REWP : Boolean := False; -- unspecified Reserved_21_23 : HAL.UInt3 := 16#0#; -- Device status - connect change. The Connect Change bit is set when -- the device's pull-up resistor is disconnected because VBus -- disappeared. The bit is reset by writing a one to it. DCON_C : Boolean := False; -- Device status - suspend change. The suspend change bit is set to 1 -- when the suspend bit toggles. The suspend bit can toggle because: - -- The device goes in the suspended state - The device is disconnected - -- The device receives resume signaling on its upstream port. The bit is -- reset by writing a one to it. DSUS_C : Boolean := False; -- Device status - reset change. This bit is set when the device -- received a bus reset. On a bus reset the device will automatically go -- to the default state (unconfigured and responding to address 0). The -- bit is reset by writing a one to it. DRES_C : Boolean := False; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Read-only. This bit indicates if Vbus is detected or not. The bit -- raises immediately when Vbus becomes high. It drops to zero if Vbus -- is low for at least 3 ms. If this bit is high and the DCon bit is -- set, the HW will enable the pull-up resistor to signal a connect. VBUSDEBOUNCED : Boolean := False; -- unspecified Reserved_29_31 : HAL.UInt3 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DEVCMDSTAT_Register use record DEV_ADDR at 0 range 0 .. 6; DEV_EN at 0 range 7 .. 7; SETUP at 0 range 8 .. 8; FORCE_NEEDCLK at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; LPM_SUP at 0 range 11 .. 11; INTONNAK_AO at 0 range 12 .. 12; INTONNAK_AI at 0 range 13 .. 13; INTONNAK_CO at 0 range 14 .. 14; INTONNAK_CI at 0 range 15 .. 15; DCON at 0 range 16 .. 16; DSUS at 0 range 17 .. 17; Reserved_18_18 at 0 range 18 .. 18; LPM_SUS at 0 range 19 .. 19; LPM_REWP at 0 range 20 .. 20; Reserved_21_23 at 0 range 21 .. 23; DCON_C at 0 range 24 .. 24; DSUS_C at 0 range 25 .. 25; DRES_C at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; VBUSDEBOUNCED at 0 range 28 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; subtype INFO_FRAME_NR_Field is HAL.UInt11; -- The error code which last occurred: type INFO_ERR_CODE_Field is ( -- No error No_Error, -- PID encoding error Pid_Encoding_Error, -- PID unknown Pid_Unknown, -- Packet unexpected Packet_Unexpected, -- Token CRC error Token_Crc_Error, -- Data CRC error Data_Crc_Error, -- Time out Timeout, -- Babble Babble, -- Truncated EOP Truncated_Eop, -- Sent/Received NAK Sent_Received_Nak, -- Sent Stall Sent_Stall, -- Overrun Overrun, -- Sent empty packet Sent_Empty_Packet, -- Bitstuff error Bitstuff_Error, -- Sync error Sync_Error, -- Wrong data toggle Wrong_Data_Toggle) with Size => 4; for INFO_ERR_CODE_Field use (No_Error => 0, Pid_Encoding_Error => 1, Pid_Unknown => 2, Packet_Unexpected => 3, Token_Crc_Error => 4, Data_Crc_Error => 5, Timeout => 6, Babble => 7, Truncated_Eop => 8, Sent_Received_Nak => 9, Sent_Stall => 10, Overrun => 11, Sent_Empty_Packet => 12, Bitstuff_Error => 13, Sync_Error => 14, Wrong_Data_Toggle => 15); subtype INFO_MINREV_Field is HAL.UInt8; subtype INFO_MAJREV_Field is HAL.UInt8; -- USB Info register type INFO_Register is record -- Read-only. Frame number. This contains the frame number of the last -- successfully received SOF. In case no SOF was received by the device -- at the beginning of a frame, the frame number returned is that of the -- last successfully received SOF. In case the SOF frame number -- contained a CRC error, the frame number returned will be the -- corrupted frame number as received by the device. FRAME_NR : INFO_FRAME_NR_Field := 16#0#; -- The error code which last occurred: ERR_CODE : INFO_ERR_CODE_Field := NXP_SVD.USB.No_Error; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Read-only. Minor Revision. MINREV : INFO_MINREV_Field := 16#0#; -- Read-only. Major Revision. MAJREV : INFO_MAJREV_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INFO_Register use record FRAME_NR at 0 range 0 .. 10; ERR_CODE at 0 range 11 .. 14; Reserved_15_15 at 0 range 15 .. 15; MINREV at 0 range 16 .. 23; MAJREV at 0 range 24 .. 31; end record; subtype EPLISTSTART_EP_LIST_Field is HAL.UInt24; -- USB EP Command/Status List start address type EPLISTSTART_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Start address of the USB EP Command/Status List. EP_LIST : EPLISTSTART_EP_LIST_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EPLISTSTART_Register use record Reserved_0_7 at 0 range 0 .. 7; EP_LIST at 0 range 8 .. 31; end record; subtype DATABUFSTART_DA_BUF_Field is HAL.UInt10; -- USB Data buffer start address type DATABUFSTART_Register is record -- unspecified Reserved_0_21 : HAL.UInt22 := 16#0#; -- Start address of the buffer pointer page where all endpoint data -- buffers are located. DA_BUF : DATABUFSTART_DA_BUF_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DATABUFSTART_Register use record Reserved_0_21 at 0 range 0 .. 21; DA_BUF at 0 range 22 .. 31; end record; subtype LPM_HIRD_HW_Field is HAL.UInt4; subtype LPM_HIRD_SW_Field is HAL.UInt4; -- USB Link Power Management register type LPM_Register is record -- Read-only. Host Initiated Resume Duration - HW. This is the HIRD -- value from the last received LPM token HIRD_HW : LPM_HIRD_HW_Field := 16#0#; -- Host Initiated Resume Duration - SW. This is the time duration -- required by the USB device system to come out of LPM initiated -- suspend after receiving the host initiated LPM resume. HIRD_SW : LPM_HIRD_SW_Field := 16#0#; -- As long as this bit is set to one and LPM supported bit is set to -- one, HW will return a NYET handshake on every LPM token it receives. -- If LPM supported bit is set to one and this bit is zero, HW will -- return an ACK handshake on every LPM token it receives. If SW has -- still data pending and LPM is supported, it must set this bit to 1. DATA_PENDING : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LPM_Register use record HIRD_HW at 0 range 0 .. 3; HIRD_SW at 0 range 4 .. 7; DATA_PENDING at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype EPSKIP_SKIP_Field is HAL.UInt10; -- USB Endpoint skip type EPSKIP_Register is record -- Endpoint skip: Writing 1 to one of these bits, will indicate to HW -- that it must deactivate the buffer assigned to this endpoint and -- return control back to software. When HW has deactivated the -- endpoint, it will clear this bit, but it will not modify the EPINUSE -- bit. An interrupt will be generated when the Active bit goes from 1 -- to 0. Note: In case of double-buffering, HW will only clear the -- Active bit of the buffer indicated by the EPINUSE bit. SKIP : EPSKIP_SKIP_Field := 16#0#; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EPSKIP_Register use record SKIP at 0 range 0 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype EPINUSE_BUF_Field is HAL.UInt8; -- USB Endpoint Buffer in use type EPINUSE_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Buffer in use: This register has one bit per physical endpoint. 0: HW -- is accessing buffer 0. 1: HW is accessing buffer 1. BUF : EPINUSE_BUF_Field := 16#0#; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EPINUSE_Register use record Reserved_0_1 at 0 range 0 .. 1; BUF at 0 range 2 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype EPBUFCFG_BUF_SB_Field is HAL.UInt8; -- USB Endpoint Buffer Configuration register type EPBUFCFG_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Buffer usage: This register has one bit per physical endpoint. 0: -- Single-buffer. 1: Double-buffer. If the bit is set to single-buffer -- (0), it will not toggle the corresponding EPINUSE bit when it clears -- the active bit. If the bit is set to double-buffer (1), HW will -- toggle the EPINUSE bit when it clears the Active bit for the buffer. BUF_SB : EPBUFCFG_BUF_SB_Field := 16#0#; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EPBUFCFG_Register use record Reserved_0_1 at 0 range 0 .. 1; BUF_SB at 0 range 2 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- USB interrupt status register type INTSTAT_Register is record -- Interrupt status register bit for the Control EP0 OUT direction. This -- bit will be set if NBytes transitions to zero or the skip bit is set -- by software or a SETUP packet is successfully received for the -- control EP0. If the IntOnNAK_CO is set, this bit will also be set -- when a NAK is transmitted for the Control EP0 OUT direction. Software -- can clear this bit by writing a one to it. EP0OUT : Boolean := False; -- Interrupt status register bit for the Control EP0 IN direction. This -- bit will be set if NBytes transitions to zero or the skip bit is set -- by software. If the IntOnNAK_CI is set, this bit will also be set -- when a NAK is transmitted for the Control EP0 IN direction. Software -- can clear this bit by writing a one to it. EP0IN : Boolean := False; -- Interrupt status register bit for the EP1 OUT direction. This bit -- will be set if the corresponding Active bit is cleared by HW. This is -- done in case the programmed NBytes transitions to zero or the skip -- bit is set by software. If the IntOnNAK_AO is set, this bit will also -- be set when a NAK is transmitted for the EP1 OUT direction. Software -- can clear this bit by writing a one to it. EP1OUT : Boolean := False; -- Interrupt status register bit for the EP1 IN direction. This bit will -- be set if the corresponding Active bit is cleared by HW. This is done -- in case the programmed NBytes transitions to zero or the skip bit is -- set by software. If the IntOnNAK_AI is set, this bit will also be set -- when a NAK is transmitted for the EP1 IN direction. Software can -- clear this bit by writing a one to it. EP1IN : Boolean := False; -- Interrupt status register bit for the EP2 OUT direction. This bit -- will be set if the corresponding Active bit is cleared by HW. This is -- done in case the programmed NBytes transitions to zero or the skip -- bit is set by software. If the IntOnNAK_AO is set, this bit will also -- be set when a NAK is transmitted for the EP2 OUT direction. Software -- can clear this bit by writing a one to it. EP2OUT : Boolean := False; -- Interrupt status register bit for the EP2 IN direction. This bit will -- be set if the corresponding Active bit is cleared by HW. This is done -- in case the programmed NBytes transitions to zero or the skip bit is -- set by software. If the IntOnNAK_AI is set, this bit will also be set -- when a NAK is transmitted for the EP2 IN direction. Software can -- clear this bit by writing a one to it. EP2IN : Boolean := False; -- Interrupt status register bit for the EP3 OUT direction. This bit -- will be set if the corresponding Active bit is cleared by HW. This is -- done in case the programmed NBytes transitions to zero or the skip -- bit is set by software. If the IntOnNAK_AO is set, this bit will also -- be set when a NAK is transmitted for the EP3 OUT direction. Software -- can clear this bit by writing a one to it. EP3OUT : Boolean := False; -- Interrupt status register bit for the EP3 IN direction. This bit will -- be set if the corresponding Active bit is cleared by HW. This is done -- in case the programmed NBytes transitions to zero or the skip bit is -- set by software. If the IntOnNAK_AI is set, this bit will also be set -- when a NAK is transmitted for the EP3 IN direction. Software can -- clear this bit by writing a one to it. EP3IN : Boolean := False; -- Interrupt status register bit for the EP4 OUT direction. This bit -- will be set if the corresponding Active bit is cleared by HW. This is -- done in case the programmed NBytes transitions to zero or the skip -- bit is set by software. If the IntOnNAK_AO is set, this bit will also -- be set when a NAK is transmitted for the EP4 OUT direction. Software -- can clear this bit by writing a one to it. EP4OUT : Boolean := False; -- Interrupt status register bit for the EP4 IN direction. This bit will -- be set if the corresponding Active bit is cleared by HW. This is done -- in case the programmed NBytes transitions to zero or the skip bit is -- set by software. If the IntOnNAK_AI is set, this bit will also be set -- when a NAK is transmitted for the EP4 IN direction. Software can -- clear this bit by writing a one to it. EP4IN : Boolean := False; -- unspecified Reserved_10_29 : HAL.UInt20 := 16#0#; -- Frame interrupt. This bit is set to one every millisecond when the -- VbusDebounced bit and the DCON bit are set. This bit can be used by -- software when handling isochronous endpoints. Software can clear this -- bit by writing a one to it. FRAME_INT : Boolean := False; -- Device status interrupt. This bit is set by HW when one of the bits -- in the Device Status Change register are set. Software can clear this -- bit by writing a one to it. DEV_INT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INTSTAT_Register use record EP0OUT at 0 range 0 .. 0; EP0IN at 0 range 1 .. 1; EP1OUT at 0 range 2 .. 2; EP1IN at 0 range 3 .. 3; EP2OUT at 0 range 4 .. 4; EP2IN at 0 range 5 .. 5; EP3OUT at 0 range 6 .. 6; EP3IN at 0 range 7 .. 7; EP4OUT at 0 range 8 .. 8; EP4IN at 0 range 9 .. 9; Reserved_10_29 at 0 range 10 .. 29; FRAME_INT at 0 range 30 .. 30; DEV_INT at 0 range 31 .. 31; end record; subtype INTEN_EP_INT_EN_Field is HAL.UInt10; -- USB interrupt enable register type INTEN_Register is record -- If this bit is set and the corresponding USB interrupt status bit is -- set, a HW interrupt is generated on the interrupt line indicated by -- the corresponding USB interrupt routing bit. EP_INT_EN : INTEN_EP_INT_EN_Field := 16#0#; -- unspecified Reserved_10_29 : HAL.UInt20 := 16#0#; -- If this bit is set and the corresponding USB interrupt status bit is -- set, a HW interrupt is generated on the interrupt line indicated by -- the corresponding USB interrupt routing bit. FRAME_INT_EN : Boolean := False; -- If this bit is set and the corresponding USB interrupt status bit is -- set, a HW interrupt is generated on the interrupt line indicated by -- the corresponding USB interrupt routing bit. DEV_INT_EN : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INTEN_Register use record EP_INT_EN at 0 range 0 .. 9; Reserved_10_29 at 0 range 10 .. 29; FRAME_INT_EN at 0 range 30 .. 30; DEV_INT_EN at 0 range 31 .. 31; end record; subtype INTSETSTAT_EP_SET_INT_Field is HAL.UInt10; -- USB set interrupt status register type INTSETSTAT_Register is record -- If software writes a one to one of these bits, the corresponding USB -- interrupt status bit is set. When this register is read, the same -- value as the USB interrupt status register is returned. EP_SET_INT : INTSETSTAT_EP_SET_INT_Field := 16#0#; -- unspecified Reserved_10_29 : HAL.UInt20 := 16#0#; -- If software writes a one to one of these bits, the corresponding USB -- interrupt status bit is set. When this register is read, the same -- value as the USB interrupt status register is returned. FRAME_SET_INT : Boolean := False; -- If software writes a one to one of these bits, the corresponding USB -- interrupt status bit is set. When this register is read, the same -- value as the USB interrupt status register is returned. DEV_SET_INT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INTSETSTAT_Register use record EP_SET_INT at 0 range 0 .. 9; Reserved_10_29 at 0 range 10 .. 29; FRAME_SET_INT at 0 range 30 .. 30; DEV_SET_INT at 0 range 31 .. 31; end record; subtype EPTOGGLE_TOGGLE_Field is HAL.UInt10; -- USB Endpoint toggle register type EPTOGGLE_Register is record -- Endpoint data toggle: This field indicates the current value of the -- data toggle for the corresponding endpoint. TOGGLE : EPTOGGLE_TOGGLE_Field := 16#0#; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EPTOGGLE_Register use record TOGGLE at 0 range 0 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- USB 2.0 Device Controller type USB0_Peripheral is record -- USB Device Command/Status register DEVCMDSTAT : aliased DEVCMDSTAT_Register; -- USB Info register INFO : aliased INFO_Register; -- USB EP Command/Status List start address EPLISTSTART : aliased EPLISTSTART_Register; -- USB Data buffer start address DATABUFSTART : aliased DATABUFSTART_Register; -- USB Link Power Management register LPM : aliased LPM_Register; -- USB Endpoint skip EPSKIP : aliased EPSKIP_Register; -- USB Endpoint Buffer in use EPINUSE : aliased EPINUSE_Register; -- USB Endpoint Buffer Configuration register EPBUFCFG : aliased EPBUFCFG_Register; -- USB interrupt status register INTSTAT : aliased INTSTAT_Register; -- USB interrupt enable register INTEN : aliased INTEN_Register; -- USB set interrupt status register INTSETSTAT : aliased INTSETSTAT_Register; -- USB Endpoint toggle register EPTOGGLE : aliased EPTOGGLE_Register; end record with Volatile; for USB0_Peripheral use record DEVCMDSTAT at 16#0# range 0 .. 31; INFO at 16#4# range 0 .. 31; EPLISTSTART at 16#8# range 0 .. 31; DATABUFSTART at 16#C# range 0 .. 31; LPM at 16#10# range 0 .. 31; EPSKIP at 16#14# range 0 .. 31; EPINUSE at 16#18# range 0 .. 31; EPBUFCFG at 16#1C# range 0 .. 31; INTSTAT at 16#20# range 0 .. 31; INTEN at 16#24# range 0 .. 31; INTSETSTAT at 16#28# range 0 .. 31; EPTOGGLE at 16#34# range 0 .. 31; end record; -- USB 2.0 Device Controller USB0_Periph : aliased USB0_Peripheral with Import, Address => System'To_Address (16#40084000#); end NXP_SVD.USB;
-- { dg-do compile } procedure access_discr is type One; type Iface is limited interface; type Base is tagged limited null record; type Two_Alone (Parent : access One) is limited null record; type Two_Iface (Parent : access One) is limited new Iface with null record; type Two_Base (Parent : access One) is new Base with null record; type One is limited record TA : Two_Alone (One'Access); TI : Two_Iface (One'Access); -- OFFENDING LINE TB : Two_Base (One'Access); end record; begin null; end;
-- -- Copyright 2021 (C) Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Exceptions; with Ada.Text_IO; with Tests; use Tests; with Notcurses.Context; with Notcurses; procedure Notcurses_Test is begin begin Notcurses.Context.Initialize; Test_Version; Test_Hello_World; Test_Colors; Test_Palette; Test_Dimensions; Test_Plane_Split; Test_Progress_Bar; Test_Visual_File; Test_Visual_Bitmap; Test_Visual_Pixel; -- Test_Input; Notcurses.Context.Stop; exception when E : others => Notcurses.Context.Stop; Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); return; end; Test_Direct; end Notcurses_Test;
package Matrix_Ops is type Matrix is array (Natural range <>, Natural range <>) of Float; function "*" (Left, Right : Matrix) return Matrix; end Matrix_Ops; package body Matrix_Ops is --------- -- "*" -- --------- function "*" (Left, Right : Matrix) return Matrix is Temp : Matrix(Left'Range(1), Right'Range(2)) := (others =>(others => 0.0)); begin if Left'Length(2) /= Right'Length(1) then raise Constraint_Error; end if; for I in Left'range(1) loop for J in Right'range(2) loop for K in Left'range(2) loop Temp(I,J) := Temp(I,J) + Left(I, K)*Right(K, J); end loop; end loop; end loop; return Temp; end "*"; end Matrix_Ops;
pragma License (Unrestricted); with Ada.Streams.Naked_Stream_IO; with Interfaces.C_Streams; package System.File_Control_Block is pragma Preelaborate; type AFCB_Ptr is tagged private; -- Ada.Streams.Stream_IO.File_Type function Stream (File : AFCB_Ptr) return Interfaces.C_Streams.FILEs; private type AFCB_Ptr is tagged record Stream : aliased Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type; end record; end System.File_Control_Block;
-- C45672A.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. --* -- CHECK THAT "NOT" YIELDS THE CORRECT RESULTS WHEN APPLIED TO -- ONE-DIMENSIONAL BOOLEAN ARRAYS. -- JWC 11/15/85 WITH REPORT;USE REPORT; PROCEDURE C45672A IS BEGIN TEST ("C45672A", "CHECK THE UNARY OPERATOR 'NOT' APPLIED TO " & "ONE-DIMENSIONAL BOOLEAN ARRAYS"); DECLARE TYPE ARR1 IS ARRAY (INTEGER RANGE 1 .. 4) OF BOOLEAN; TYPE ARR2 IS ARRAY (INTEGER RANGE 1 .. 40) OF BOOLEAN; TYPE ARR3 IS ARRAY (INTEGER RANGE <>) OF BOOLEAN; TYPE ARR4 IS ARRAY (INTEGER RANGE 1 .. 4) OF BOOLEAN; TYPE ARR5 IS ARRAY (INTEGER RANGE 1 .. 40) OF BOOLEAN; PRAGMA PACK (ARR4); PRAGMA PACK (ARR5); A1 : ARR1 := ARR1'(1 | 3 => TRUE, OTHERS => FALSE); A2 : ARR2 := ARR2'(1 | 14 .. 18 | 30 .. 33 | 35 .. 37 => TRUE, OTHERS => FALSE); A3 : ARR3(IDENT_INT(3) .. IDENT_INT(4)) := ARR3'(TRUE, FALSE); A4 : ARR4 := ARR4'(1 | 3 => TRUE, OTHERS => FALSE); A5 : ARR5 := ARR5'(1 | 14 .. 18 | 30 .. 33 | 35 .. 37 => TRUE, OTHERS => FALSE); A6 : ARR3 (IDENT_INT(9) .. IDENT_INT(7)); PROCEDURE P (A : ARR3; F : INTEGER; L : INTEGER) IS BEGIN IF A'FIRST /= F OR A'LAST /= L THEN FAILED ("'NOT' YIELDED THE WRONG BOUNDS"); END IF; END P; BEGIN P (NOT A3, 3, 4); P (NOT A6, 9, 7); IF NOT A1 /= ARR1'(1 | 3 => FALSE, OTHERS => TRUE) THEN FAILED ("WRONG RESULT WHEN 'NOT' APPLIED " & "TO SMALL ARRAY"); END IF; IF NOT A2 /= ARR2'(1 | 14 .. 18 | 30 .. 33 | 35 .. 37 => FALSE, OTHERS => TRUE) THEN FAILED ("WRONG RESULT WHEN 'NOT' APPLIED " & "TO LARGE ARRAY"); END IF; IF NOT A4 /= ARR4'(1 | 3 => FALSE, OTHERS => TRUE) THEN FAILED ("WRONG RESULT WHEN 'NOT' APPLIED " & "TO SMALL PACKED ARRAY"); END IF; IF NOT A5 /= ARR5'(1 | 14 .. 18 | 30 .. 33 | 35 .. 37 => FALSE, OTHERS => TRUE) THEN FAILED ("WRONG RESULT WHEN 'NOT' APPLIED " & "TO LARGE PACKED ARRAY"); END IF; IF "NOT" (RIGHT => A1) /= ARR1'(1 | 3 => FALSE, OTHERS => TRUE) THEN FAILED ("WRONG RESULT WHEN 'NOT' APPLIED " & "TO SMALL ARRAY USING NAMED NOTATION"); END IF; IF "NOT" (RIGHT => A5) /= ARR5'(1 | 14 .. 18 | 30 .. 33 | 35 .. 37 => FALSE, OTHERS => TRUE) THEN FAILED ("WRONG RESULT WHEN 'NOT' APPLIED TO LARGE " & "PACKED ARRAY USING NAMED NOTATION"); END IF; END; RESULT; END C45672A;
with Freetype; package Render.Fonts is FONT_SIZE : constant := 14; -- We reuse this object to store the current character glyph face : Freetype.FT_Face; emojiFace : Freetype.FT_Face; --glyph : Freetype.FT_GlyphSlot; function loadGlyph (c : Character; fontFace : Freetype.FT_Face) return Boolean; function loadGlyph (c : Wide_Wide_Character; fontFace : Freetype.FT_Face) return Boolean; --------------------------------------------------------------------------- -- start -- Initialize Freetype and Fontconfig libraries --------------------------------------------------------------------------- procedure start; --------------------------------------------------------------------------- -- stop -- Perform clean up of Freetype and Fontconfig libraries --------------------------------------------------------------------------- procedure stop; end Render.Fonts;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This package provide a low level driver to access the native file system. -- It is recommended to _not_ use this interface directly but to access the -- file system using the File_IO package. For more info, see the file system -- chapter of the documentation. private with Ada.Containers.Vectors; private with Ada.Direct_IO; private with Ada.Strings.Unbounded; with HAL.Filesystem; use HAL.Filesystem; with System; -- Simple wrappers around the Ada standard library to provide implementations -- for HAL.Filesystem interfaces. package Filesystem.Native is package HALFS renames HAL.Filesystem; ---------------------- -- Native_FS_Driver -- ---------------------- type Native_FS_Driver is limited new HALFS.Filesystem_Driver with private; type Native_FS_Driver_Access is access all Native_FS_Driver; type File_Handle is limited new HALFS.File_Handle with private; type File_Handle_Access is access all File_Handle; type Directory_Handle is limited new HALFS.Directory_Handle with private; type Directory_Handle_Access is access all Directory_Handle; type Node_Handle is new HALFS.Node_Handle with private; type Node_Handle_Access is access all Node_Handle; --------------------------- -- Directory operations -- --------------------------- overriding function Open (This : in out Native_FS_Driver; Path : String; Handle : out Any_Directory_Handle) return Status_Code; -- Open a new Directory Handle at the given Filesystem Path overriding function Create_File (This : in out Native_FS_Driver; Path : String) return Status_Code; overriding function Unlink (This : in out Native_FS_Driver; Path : String) return Status_Code; -- Remove the regular file located at Path in the This filesystem overriding function Remove_Directory (This : in out Native_FS_Driver; Path : String) return Status_Code; -- Remove the directory located at Path in the This filesystem overriding function Get_FS (This : Directory_Handle) return Any_Filesystem_Driver; -- Return the filesystem the handle belongs to. overriding function Root_Node (This : in out Native_FS_Driver; As : String; Handle : out Any_Node_Handle) return Status_Code; -- Open a new Directory Handle at the given Filesystem Path overriding function Read (This : in out Directory_Handle; Handle : out Any_Node_Handle) return Status_Code; -- Reads the next directory entry. If no such entry is there, an error -- code is returned in Status. overriding procedure Reset (This : in out Directory_Handle); -- Resets the handle to the first node overriding procedure Close (This : in out Directory_Handle); -- Closes the handle, and free the associated resources. --------------------- -- Node operations -- --------------------- overriding function Get_FS (This : Node_Handle) return Any_Filesystem_Driver; overriding function Basename (This : Node_Handle) return String; overriding function Is_Read_Only (This : Node_Handle) return Boolean; overriding function Is_Hidden (This : Node_Handle) return Boolean; overriding function Is_Subdirectory (This : Node_Handle) return Boolean; overriding function Is_Symlink (This : Node_Handle) return Boolean; overriding function Size (This : Node_Handle) return File_Size; overriding procedure Close (This : in out Node_Handle); --------------------- -- File operations -- --------------------- overriding function Open (This : in out Native_FS_Driver; Path : String; Mode : File_Mode; Handle : out Any_File_Handle) return Status_Code; -- Open a new File Handle at the given Filesystem Path overriding function Open (This : Node_Handle; Name : String; Mode : File_Mode; Handle : out Any_File_Handle) return Status_Code with Pre'Class => Is_Subdirectory (This); overriding function Get_FS (This : in out File_Handle) return Any_Filesystem_Driver; overriding function Size (This : File_Handle) return File_Size; overriding function Mode (This : File_Handle) return File_Mode; overriding function Read (This : in out File_Handle; Addr : System.Address; Length : in out File_Size) return Status_Code; overriding function Write (This : in out File_Handle; Addr : System.Address; Length : File_Size) return Status_Code; overriding function Offset (This : File_Handle) return File_Size; overriding function Flush (This : in out File_Handle) return Status_Code; overriding function Seek (This : in out File_Handle; Origin : Seek_Mode; Amount : in out File_Size) return Status_Code; overriding procedure Close (This : in out File_Handle); ------------------- -- FS operations -- ------------------- overriding procedure Close (This : in out Native_FS_Driver); procedure Destroy (This : in out Native_FS_Driver_Access); function Create (FS : out Native_FS_Driver; Root_Dir : String) return Status_Code; -- Create a Native_FS_Driver considering Root_Dir as its root directory. -- All other pathnames in this API are processed as relative to it. -- -- Note that this does not provide real isolation: trying to access the -- ".." directory will access the parent of the root directory, not the -- root directory itself. type File_Kind is (Regular_File, Directory); function Create_Node (This : in out Native_FS_Driver; Path : String; Kind : File_Kind) return Status_Code; function Create_Directory (This : in out Native_FS_Driver; Path : String) return Status_Code; function Rename (This : in out Native_FS_Driver; Old_Path : String; New_Path : String) return Status_Code; function Truncate_File (This : in out Native_FS_Driver; Path : String; Length : File_Size) return Status_Code; ------------- -- Helpers -- ------------- function Join (Prefix, Suffix : String; Ignore_Absolute_Suffixes : Boolean) return String; -- Like Ada.Directories.Compose, but also accepts a full path as Suffix. -- For instance: -- -- Join ("/a", "b") => "/a/b" -- Join ("/a", "b/c") => "/a/b/c" -- -- If Ignore_Absolute_Suffixes is True, if Suffix is an absolute path, do -- as if it was a relative path instead: -- -- Join ("/a", "/b") => "/a/b" -- -- Otherwise, if sufifx is an absolute path, just return Suffix. private package Byte_IO is new Ada.Direct_IO (UInt8); type Native_FS_Driver is limited new Filesystem_Driver with record Root_Dir : Ada.Strings.Unbounded.Unbounded_String; -- Path on the host file system to be used as root directory for this FS Free_File_Handles : File_Handle_Access; -- Linked list of file handles available to use Free_Dir_Handles : Directory_Handle_Access; -- Likend list of directory handles available to use end record; function Get_Handle (FS : in out Native_FS_Driver) return File_Handle_Access; function Get_Handle (FS : in out Native_FS_Driver) return Directory_Handle_Access; -- Return an existing free handle or create one if none is available procedure Add_Free_Handle (FS : in out Native_FS_Driver; Handle : in out File_Handle_Access) with Pre => Handle /= null, Post => Handle = null; procedure Add_Free_Handle (FS : in out Native_FS_Driver; Handle : in out Directory_Handle_Access) with Pre => Handle /= null, Post => Handle = null; -- Add Handle to the list of available handles type File_Handle is limited new HALFS.File_Handle with record FS : Native_FS_Driver_Access; -- The filesystem that owns this handle Next : File_Handle_Access; -- If this handle is used, this is undefined. Otherwise, -- this is the next free handle in the list (see -- Native_FS_Driver.Free_File_Handles). File : Byte_IO.File_Type; Mode : File_Mode; end record; type Node_Handle is new HALFS.Node_Handle with record FS : Native_FS_Driver_Access; Kind : File_Kind; Name : Ada.Strings.Unbounded.Unbounded_String; Read_Only : Boolean; Hidden : Boolean; Symlink : Boolean; Size : File_Size; end record; -- Set of information we handle for a node package Node_Vectors is new Ada.Containers.Vectors (Positive, Node_Handle); type Directory_Handle is limited new HALFS.Directory_Handle with record FS : Native_FS_Driver_Access; -- The filesystem that owns this handle Next : Directory_Handle_Access; -- If this handle is used, this is undefined. Otherwise, -- this is the next free handle in the list (see -- Native_FS_Driver.Free_Dir_Handles). Full_Name : Ada.Strings.Unbounded.Unbounded_String; -- Absolute path for this directory Data : Node_Vectors.Vector; -- Vector of entries for this directory. -- -- On one hand, HAL.Filesystem exposes an index-based API to access -- directory entries. On the other hand, Ada.Directories exposes a -- kind of single-linked list. What we do here is that when we open a -- directory, we immediately get all entries and build a vector out of -- it for convenient random access. Index : Positive; -- Current index in the vector of Node end record; end Filesystem.Native;
with Ada.Containers.Indefinite_Ordered_Maps; with Protypo.Api.Engine_Values.Engine_Value_Holders; with Protypo.Api.Engine_Values.Engine_Value_Vectors; with Protypo.Api.Engine_Values.Handlers; with Protypo.Api.Engine_Values.Constant_Wrappers; -- -- This package provides resources to define a record-like variable -- where the field names are specified as values of an enumerative -- type. Since the enumerative type is not specified a priori, we -- need to make this package generic. -- -- The record-like variable will appear to have fields whose name is -- obtained by removing the Prefix from the enumerative values. This -- is done in order to turn around the fact that some words are reserved -- in Ada. -- -- > For example, suppose one wants to export the field "range." -- Unfortunately, it is not possible to have "range" as an enumerative value. -- One can solve this problem by using --- for example --- `Prefix="Field_"` -- so that the enumerative value `Field_Range` can be used. -- generic type Field_Name is (<>); Prefix : String := ""; package Protypo.Api.Engine_Values.Enumerated_Records is type Aggregate_Type is array (Field_Name) of Engine_Value_Holders.Holder; -- Type that allows to specify an enumerated record similarly -- to an Ada aggregate, for example, -- -- (First_Name => Create ("Pippo"), -- Last_Name => Create ("Recupero"), -- Telephone => Create ("3204365972")) Void_Aggregate : constant Aggregate_Type := (others => Engine_Value_Holders.Empty_Holder); type Multi_Aggregate is array (Positive range <>) of Aggregate_Type; -- Array of aggregate type. It allows to write constant "databases" -- of enumerated records function To_Array (Db : Multi_Aggregate) return Engine_Value_Vectors.Vector with Post => (for all Item of To_Array'Result => Item.Class = Record_Handler); -- Convert an array of aggregates into an Engine_Value_Vectors.Vector whose -- entries are Enumerated_Records. -- Very useful in initializing other wrappers (e.g., from Array_Wrappers) type Enumerated_Record is new Handlers.Record_Interface with private; type Enumerated_Record_Access is access Enumerated_Record; function Make_Record (Init : Aggregate_Type := Void_Aggregate) return Enumerated_Record_Access; -- Create a new record-like handler initialized with the values -- specified in the aggregate function Make_Value (Init : Aggregate_Type) return Record_Value; -- Syntactic sugar that creates the handler and embed it into -- an Engine_Value. Equivalent to -- -- Create (Record_Interface_Access (Make_Record (Init))) procedure Fill (Item : in out Enumerated_Record; Values : Aggregate_Type); -- Write the values to the field of the Enumerated_Record procedure Set (Item : in out Enumerated_Record; Field : Field_Name; Value : Engine_Value); -- Write a field of the Enumerated_Record overriding function Get (Item : Enumerated_Record; Field : ID) return Handler_Value; overriding function Is_Field (Item : Enumerated_Record; Field : ID) return Boolean; private package Record_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => ID, Element_Type => Engine_Value); type Enumerated_Record is new Handlers.Record_Interface with record Map : Record_Maps.Map; end record; function Apply_Prefix (X : Id) return ID is (ID (Prefix & String (X))); function Get (Item : Enumerated_Record; Field : Id) return Handler_Value is (if Item.Map.Contains (Apply_Prefix (Field)) then Constant_Wrappers.To_Handler_Value (Item.Map (Apply_Prefix (Field))) else raise Handlers.Unknown_Field); end Protypo.Api.Engine_Values.Enumerated_Records;
-- C48008A.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. --* -- FOR ALLOCATORS OF THE FORM "NEW T X", CHECK THAT CONSTRAINT_ERROR IS -- RAISED IF T IS AN UNCONSTRAINED RECORD, PRIVATE, OR LIMITED TYPE, X -- IS A DISCRIMINANT CONSTRAINT, AND -- 1) ONE OF THE VALUES OF X IS OUTSIDE THE RANGE OF THE CORRESPONDING -- DISCRIMINANT; -- 2) ONE OF THE DISCRIMINANT VALUES IS NOT COMPATIBLE WITH A -- CONSTRAINT OF A SUBCOMPONENT IN WHICH IT IS USED; -- 3) ONE OF THE DISCRIMINANT VALUES DOES NOT EQUAL THE CORRESPONDING -- VALUE OF THE ALLOCATOR'S BASE TYPE; -- 4) A DEFAULT INITIALIZATION RAISES AN EXCEPTION. -- RM 01/08/80 -- NL 10/13/81 -- SPS 10/26/82 -- JBG 03/02/83 -- EG 07/05/84 -- PWB 02/05/86 CORRECTED TEST ERROR: -- CHANGED "FAILED" TO "COMMENT" IN PROCEDURE INCR_CHECK, -- SO AS NOT TO PROHIBIT EVAL OF DEFLT EXPR (AI-00397/01) -- ADDED COMMENTS FOR CASES. WITH REPORT; PROCEDURE C48008A IS USE REPORT; BEGIN TEST( "C48008A" , "FOR ALLOCATORS OF THE FORM 'NEW T X', " & "CHECK THAT CONSTRAINT_ERROR IS RAISED WHEN " & "APPROPRIATE - UNCONSTRAINED RECORD AND " & "PRIVATE TYPES"); DECLARE DISC_FLAG : BOOLEAN := FALSE; INCR_VAL : INTEGER; FUNCTION INCR(A : INTEGER) RETURN INTEGER; SUBTYPE I1_7 IS INTEGER RANGE IDENT_INT(1)..IDENT_INT(7); SUBTYPE I1_10 IS INTEGER RANGE IDENT_INT(1)..IDENT_INT(10); SUBTYPE I2_9 IS INTEGER RANGE IDENT_INT(2)..IDENT_INT(9); TYPE REC (A : I2_9) IS RECORD B : INTEGER := INCR(2); END RECORD; TYPE ARR IS ARRAY (I2_9 RANGE <>) OF INTEGER; TYPE T_REC (C : I1_10) IS RECORD D : REC(C); END RECORD; TYPE T_ARR (C : I1_10) IS RECORD D : ARR(2..C); E : ARR(C..9); END RECORD; TYPE T_REC_REC (A : I1_10) IS RECORD B : T_REC(A); END RECORD; TYPE T_REC_ARR (A : I1_10) IS RECORD B : T_ARR(A); END RECORD; TYPE TB ( A : I1_7 ) IS RECORD R : INTEGER := INCR(1); END RECORD; TYPE UR (A : INTEGER) IS RECORD B : I2_9 := INCR(1); END RECORD; TYPE A_T_REC_REC IS ACCESS T_REC_REC; TYPE A_T_REC_ARR IS ACCESS T_REC_ARR; TYPE ATB IS ACCESS TB; TYPE ACTB IS ACCESS TB(3); TYPE A_UR IS ACCESS UR; VA_T_REC_REC : A_T_REC_REC; VA_T_REC_ARR : A_T_REC_ARR; VB : ATB; VCB : ACTB; V_A_UR : A_UR; BOOL : BOOLEAN; FUNCTION DISC (A : INTEGER) RETURN INTEGER; PACKAGE P IS TYPE PRIV( A : I1_10 := DISC(8) ) IS PRIVATE; CONS_PRIV : CONSTANT PRIV; PRIVATE TYPE PRIV( A : I1_10 := DISC(8) ) IS RECORD R : INTEGER := INCR(1); END RECORD; CONS_PRIV : CONSTANT PRIV := (2, 3); END P; TYPE A_PRIV IS ACCESS P.PRIV; TYPE A_CPRIV IS ACCESS P.PRIV (3); VP : A_PRIV; VCP : A_CPRIV; PROCEDURE PREC_REC (X : A_T_REC_REC) IS BEGIN NULL; END PREC_REC; PROCEDURE PREC_ARR (X : A_T_REC_ARR) IS BEGIN NULL; END PREC_ARR; PROCEDURE PB (X : ATB) IS BEGIN NULL; END PB; PROCEDURE PCB (X : ACTB) IS BEGIN NULL; END PCB; PROCEDURE PPRIV (X : A_PRIV) IS BEGIN NULL; END PPRIV; PROCEDURE PCPRIV (X : A_CPRIV) IS BEGIN NULL; END PCPRIV; FUNCTION DISC (A : INTEGER) RETURN INTEGER IS BEGIN DISC_FLAG := TRUE; RETURN A; END DISC; FUNCTION INCR(A : INTEGER) RETURN INTEGER IS BEGIN INCR_VAL := IDENT_INT(INCR_VAL+1); RETURN A; END INCR; PROCEDURE INCR_CHECK(CASE_ID : STRING) IS BEGIN IF INCR_VAL /= IDENT_INT(0) THEN COMMENT ("DEFAULT INITIAL VALUE WAS EVALUATED - " & "CASE " & CASE_ID); END IF; END INCR_CHECK; BEGIN BEGIN -- A1A: 0 ILLEGAL FOR TB.A. INCR_VAL := 0; VB := NEW TB (A => 0); FAILED ("NO EXCEPTION RAISED - CASE A1A"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A1A"); WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - CASE A1A" ); END; -- A1A BEGIN -- A1B: 8 ILLEGAL IN I1_7. INCR_VAL := 0; VB := NEW TB (A => I1_7'(IDENT_INT(8))); FAILED ("NO EXCEPTION RAISED - CASE A1B"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A1B"); WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - CASE A1B"); END; -- A1B BEGIN -- A1C: 8 ILLEGAL FOR TB.A. INCR_VAL := 0; PB(NEW TB (A => 8)); FAILED ("NO EXCEPTION RAISED - CASE A1C"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A1C"); WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - CASE A1C"); END; --A1C BEGIN --A1D: 0 ILLEGAL FOR TB.A. INCR_VAL := 0; BOOL := ATB'(NEW TB(A => 0)) = NULL; FAILED ("NO EXCEPTION RAISED - CASE A1D"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A1D"); WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - CASE A1D"); END; --A1D BEGIN --A1E: 11 ILLEGAL FOR PRIV.A. DISC_FLAG := FALSE; INCR_VAL := 0; VP := NEW P.PRIV(11); FAILED("NO EXCEPTION RAISED - CASE A1E"); EXCEPTION WHEN CONSTRAINT_ERROR => IF DISC_FLAG THEN FAILED ("DISCR DEFAULT EVALUATED WHEN " & "EXPLICIT VALUE WAS PROVIDED - A1E"); END IF; INCR_CHECK("A1E"); WHEN OTHERS => FAILED("WRONG EXCEPTION RAISED - CASE A1E"); END; -- A1E BEGIN -- A2A: 1 ILLEGAL FOR REC.A. INCR_VAL := 0; VA_T_REC_REC := NEW T_REC_REC(A => I1_10'(IDENT_INT(1))); FAILED ("NO EXCEPTION RAISED - CASE A2A"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A2A"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A2A"); END; -- A2A BEGIN --A2B: 10 ILLEGAL FOR REC.A. INCR_VAL := 0; VA_T_REC_REC := NEW T_REC_REC (10); FAILED ("NO EXCEPTION RAISED - CASE A2B"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A2B"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A2B"); END; -- A2B BEGIN -- A2C: 1 ILLEGAL FOR T.ARR.E'FIRST. INCR_VAL := 0; PREC_ARR (NEW T_REC_ARR (1)); FAILED ("NO EXCEPTION RAISED - CASE A2C"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK ("A2C"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A2C"); END; -- A2C BEGIN -- A2D: 10 ILLEGAL FOR T_ARR.D'LAST. INCR_VAL := 0; BOOL := NEW T_REC_ARR (IDENT_INT(10)) = NULL; FAILED ("NO EXCEPTION RAISED - CASE A2D"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK ("A2D"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A2D"); END; -- A2D BEGIN -- A3A: ASSIGNMENT VIOLATES CONSTRAINT ON VCB'S SUBTYPE. INCR_VAL := 0; VCB := NEW TB (4); FAILED ("NO EXCEPTION RAISED - CASE A3A"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A3A"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A3A"); END; -- A3A BEGIN -- A3B: PARM ASSOC VIOLATES CONSTRAINT ON PARM SUBTYPE. INCR_VAL := 0; PCB (NEW TB (4)); FAILED ("NO EXCEPTION RAISED - CASE A3B"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A3B"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A3B"); END; -- A3B BEGIN -- A3C: 2 VIOLATES CONSTRAINT ON SUBTYPE ACTB. INCR_VAL := 0; BOOL := ACTB'(NEW TB (IDENT_INT(2))) = NULL; FAILED ("NO EXCEPTION RAISED - CASE A3C"); EXCEPTION WHEN CONSTRAINT_ERROR => INCR_CHECK("A3C"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A3C"); END; -- A3C BEGIN -- A4A: EVALUATION OF DEFAULT RAISES EXCEPTION. INCR_VAL := 0; V_A_UR := NEW UR(4); FAILED ("NO EXCEPTION RAISED - CASE A4A"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - CASE A4A"); END; -- A4A END; RESULT; END C48008A;