repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
Componolit/libsparkcrypto
Ada
16,474
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2018 Componolit GmbH -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- 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 nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.Types; with LSC.Internal.RIPEMD160; with AUnit.Assertions; use AUnit.Assertions; with Util; use Util; use type LSC.Internal.Types.Word32_Array_Type; pragma Style_Checks ("-s"); pragma Warnings (Off, "formal parameter ""T"" is not referenced"); package body LSC_Internal_Test_RIPEMD160 is -- RIPEMD-160: A Strengthened Version of RIPEMD , Appendix B: Test values -- procedure Test_RIPEMD160_Empty (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "" (empty string) Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 0); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#9c1185a5#), M (16#c5e9fc54#), M (16#61280897#), M (16#7ee8f548#), M (16#b2258d31#)), "Hash differs"); end Test_RIPEMD160_Empty; --------------------------------------------------------------------------- procedure Test_RIPEMD160_A (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "a" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61000000#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 8); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#0bdc9d2d#), M (16#256b3ee9#), M (16#daae347b#), M (16#e6f4dc83#), M (16#5a467ffe#)), "Hash differs"); end Test_RIPEMD160_A; --------------------------------------------------------------------------- procedure Test_RIPEMD160_ABC (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "abc" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61626300#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 24); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#8eb208f7#), M (16#e05d987a#), M (16#9b044a8e#), M (16#98c6b087#), M (16#f15a0bfc#)), "Hash differs"); end Test_RIPEMD160_ABC; --------------------------------------------------------------------------- procedure Test_RIPEMD160_Message_Digest (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "message digest" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#6d657373#), M (16#61676520#), M (16#64696765#), M (16#73740000#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 112); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#5d0689ef#), M (16#49d2fae5#), M (16#72b881b1#), M (16#23a85ffa#), M (16#21595f36#)), "Hash differs"); end Test_RIPEMD160_Message_Digest; --------------------------------------------------------------------------- procedure Test_RIPEMD160_AtoZ (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "abcdefghijklmnopqrstuvwxyz" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61626364#), M (16#65666768#), M (16#696a6b6c#), M (16#6d6e6f70#), M (16#71727374#), M (16#75767778#), M (16#797a0000#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 208); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#f71c2710#), M (16#9c692c1b#), M (16#56bbdceb#), M (16#5b9d2865#), M (16#b3708dbc#)), "Hash differs"); end Test_RIPEMD160_AtoZ; --------------------------------------------------------------------------- procedure Test_RIPEMD160_ABCDEFG (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61626364#), M (16#62636465#), M (16#63646566#), M (16#64656667#), M (16#65666768#), M (16#66676869#), M (16#6768696a#), M (16#68696a6b#), M (16#696a6b6c#), M (16#6a6b6c6d#), M (16#6b6c6d6e#), M (16#6c6d6e6f#), M (16#6d6e6f70#), M (16#6e6f7071#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 448); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#12a05338#), M (16#4a9c0c88#), M (16#e405a06c#), M (16#27dcf49a#), M (16#da62eb2b#)), "Hash differs"); end Test_RIPEMD160_ABCDEFG; --------------------------------------------------------------------------- procedure Test_RIPEMD160_AZaz09 (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#41424344#), M (16#45464748#), M (16#494a4b4c#), M (16#4d4e4f50#), M (16#51525354#), M (16#55565758#), M (16#595a6162#), M (16#63646566#), M (16#6768696a#), M (16#6b6c6d6e#), M (16#6f707172#), M (16#73747576#), M (16#7778797a#), M (16#30313233#), M (16#34353637#), M (16#38390000#)); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 496); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#b0e20b6e#), M (16#31166402#), M (16#86ed3a87#), M (16#a5713079#), M (16#b21f5189#)), "Hash differs"); end Test_RIPEMD160_AZaz09; --------------------------------------------------------------------------- procedure Test_RIPEMD160_8x1to0 (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- 8 times "1234567890" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#31323334#), M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), M (16#31323334#), M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), M (16#31323334#), M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), M (16#31323334#)); LSC.Internal.RIPEMD160.Context_Update (Ctx, Message); Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 128); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#9b752e45#), M (16#573d4b39#), M (16#f4dbd332#), M (16#3cab82bf#), M (16#63326bfb#)), "Hash differs"); end Test_RIPEMD160_8x1to0; --------------------------------------------------------------------------- procedure Test_RIPEMD160_1millionAs (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- 1 million times "a" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(others => M (16#61616161#)); for I in Natural range 1 .. 15625 loop LSC.Internal.RIPEMD160.Context_Update (Ctx, Message); end loop; LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 0); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#52783243#), M (16#c1697bdb#), M (16#e16d37f9#), M (16#7f68f083#), M (16#25dc1528#)), "Hash differs"); end Test_RIPEMD160_1millionAs; --------------------------------------------------------------------------- procedure Register_Tests (T : in out Test_Case) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_RIPEMD160_Empty'Access, "RIPEMD160 (empty string)"); Register_Routine (T, Test_RIPEMD160_A'Access, "RIPEMD160 ('a')"); Register_Routine (T, Test_RIPEMD160_ABC'Access, "RIPEMD160 ('abc')"); Register_Routine (T, Test_RIPEMD160_Message_Digest'Access, "RIPEMD160 ('message digest')"); Register_Routine (T, Test_RIPEMD160_AtoZ'Access, "RIPEMD160 ('a..z')"); Register_Routine (T, Test_RIPEMD160_ABCDEFG'Access, "RIPEMD160 ('abcdefg...')"); Register_Routine (T, Test_RIPEMD160_AZaz09'Access, "RIPEMD160 ('A..Za..z0..9')"); Register_Routine (T, Test_RIPEMD160_8x1to0'Access, "RIPEMD160 (8x'1..0'"); Register_Routine (T, Test_RIPEMD160_1millionAs'Access, "RIPEMD160 (1 million 'a's)"); end Register_Tests; --------------------------------------------------------------------------- function Name (T : Test_Case) return Test_String is begin return Format ("RIPEMD160"); end Name; end LSC_Internal_Test_RIPEMD160;
gitter-badger/spat
Ada
4,590
ads
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------------ -- -- SPARK Proof Analysis Tool -- -- S.P.A.T. - Root package -- ------------------------------------------------------------------------------ limited with Ada.Containers; limited with Ada.Strings.Unbounded.Hash; with GNATCOLL.JSON; package SPAT is subtype JSON_Data is Ada.Strings.Unbounded.Unbounded_String; subtype Subject_Name is Ada.Strings.Unbounded.Unbounded_String; -- Type denoting some kind of name (i.e. file name, entity name, rule name -- etc. pp.) Null_Name : Subject_Name renames Ada.Strings.Unbounded.Null_Unbounded_String; -- Provide a renaming for the null string. --------------------------------------------------------------------------- -- Image function for Duration. Used by certain Image functions. --------------------------------------------------------------------------- function Image (Value : in Duration) return String; --------------------------------------------------------------------------- -- To_String --------------------------------------------------------------------------- function To_String (Source : in Subject_Name) return String renames Ada.Strings.Unbounded.To_String; --------------------------------------------------------------------------- -- To_Name --------------------------------------------------------------------------- function To_Name (Source : in String) return Subject_Name renames Ada.Strings.Unbounded.To_Unbounded_String; --------------------------------------------------------------------------- -- "=" --------------------------------------------------------------------------- function "=" (Left : in Ada.Strings.Unbounded.Unbounded_String; Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean renames Ada.Strings.Unbounded."="; --------------------------------------------------------------------------- -- "<" --------------------------------------------------------------------------- function "<" (Left : in Ada.Strings.Unbounded.Unbounded_String; Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean renames Ada.Strings.Unbounded."<"; --------------------------------------------------------------------------- -- Hash --------------------------------------------------------------------------- function Hash (Key : Ada.Strings.Unbounded.Unbounded_String) return Ada.Containers.Hash_Type renames Ada.Strings.Unbounded.Hash; --------------------------------------------------------------------------- -- Length --------------------------------------------------------------------------- function Length (Source : in Ada.Strings.Unbounded.Unbounded_String) return Natural renames Ada.Strings.Unbounded.Length; -- Derived types for all kind of "names". type File_Name is new Subject_Name; -- A file on disk. type Entity_Name is new Subject_Name; -- An Ada language entity. type SPARK_File_Name is new File_Name; -- Name of a ".spark" file. type Source_File_Name is new File_Name; -- Name of an "Ada" source file. -- Type renames for commonly used JSON types from GNATCOLL.JSON subtype JSON_Array is GNATCOLL.JSON.JSON_Array; subtype JSON_Value is GNATCOLL.JSON.JSON_Value; subtype JSON_Value_Type is GNATCOLL.JSON.JSON_Value_Type; subtype UTF8_String is GNATCOLL.JSON.UTF8_String; type File_Version is (GNAT_CE_2019, GNAT_CE_2020); -- Version information. Right now I only have access to the community -- releases of SPARK, so these are the only ones fully supported. type Prover_Steps is range -2 ** 63 .. 2 ** 63 - 1; -- Define our own type instead of using Long_Integer; pragma Compile_Time_Warning (Long_Integer'Size < Prover_Steps'Size, "Long_Integer is less than 64 bit."); -- We use the Long_Integer version of GNATCOLL.JSON.Get to read values of -- this type, so the size of Long_Integer must be sufficient. end SPAT;
stcarrez/ada-awa
Ada
7,212
adb
----------------------------------------------------------------------- -- awa-sysadmin-modules -- Module sysadmin -- Copyright (C) 2019, 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with AWA.Applications; with AWA.Modules.Get; with AWA.Modules.Beans; with AWA.Sysadmin.Models; with Util.Log.Loggers; with ADO.Sessions; with ADO.Statements; with ADO.Queries; with ADO.Utils.Serialize; with Servlet.Rest; with Swagger.Servers.Operation; with AWA.Sysadmin.Beans; package body AWA.Sysadmin.Modules is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Awa.Sysadmin.Module"); package Register is new AWA.Modules.Beans (Module => Sysadmin_Module, Module_Access => Sysadmin_Module_Access); Mimes : aliased constant Swagger.Mime_List := (1 => Swagger.Mime_Json, 2 => Swagger.Mime_Xml); procedure List_Users (Req : in out Swagger.Servers.Request'Class; Reply : in out Swagger.Servers.Response'Class; Stream : in out Swagger.Servers.Output_Stream'Class; Context : in out Swagger.Servers.Context_Type); procedure List_Sessions (Req : in out Swagger.Servers.Request'Class; Reply : in out Swagger.Servers.Response'Class; Stream : in out Swagger.Servers.Output_Stream'Class; Context : in out Swagger.Servers.Context_Type); procedure List_Jobs (Req : in out Swagger.Servers.Request'Class; Reply : in out Swagger.Servers.Response'Class; Stream : in out Swagger.Servers.Output_Stream'Class; Context : in out Swagger.Servers.Context_Type); package API_List_Users is new Swagger.Servers.Operation (Handler => List_Users, Method => Swagger.Servers.GET, URI => "/sysadmin/api/v1/users", Mimes => Mimes'Access); package API_List_Sessions is new Swagger.Servers.Operation (Handler => List_Sessions, Method => Swagger.Servers.GET, URI => "/sysadmin/api/v1/sessions", Mimes => Mimes'Access); package API_List_Jobs is new Swagger.Servers.Operation (Handler => List_Jobs, Method => Swagger.Servers.GET, URI => "/sysadmin/api/v1/jobs", Mimes => Mimes'Access); procedure List_Users (Req : in out Swagger.Servers.Request'Class; Reply : in out Swagger.Servers.Response'Class; Stream : in out Swagger.Servers.Output_Stream'Class; Context : in out Swagger.Servers.Context_Type) is pragma Unreferenced (Req, Reply); Module : constant Sysadmin_Module_Access := Get_Sysadmin_Module; Session : constant ADO.Sessions.Session := Module.Get_Session; Query : ADO.Queries.Context; Stmt : ADO.Statements.Query_Statement; begin Log.Info ("List users"); Query.Set_Query (AWA.Sysadmin.Models.Query_Sysadmin_User_List); Stmt := Session.Create_Statement (Query); Stmt.Execute; Stream.Start_Document; ADO.Utils.Serialize.Write_Query (Stream, "", Stmt); Stream.End_Document; Context.Set_Status (200); end List_Users; procedure List_Sessions (Req : in out Swagger.Servers.Request'Class; Reply : in out Swagger.Servers.Response'Class; Stream : in out Swagger.Servers.Output_Stream'Class; Context : in out Swagger.Servers.Context_Type) is pragma Unreferenced (Req, Reply); Module : constant Sysadmin_Module_Access := Get_Sysadmin_Module; Session : constant ADO.Sessions.Session := Module.Get_Session; Query : ADO.Queries.Context; Stmt : ADO.Statements.Query_Statement; begin Log.Info ("List sessions"); Query.Set_Query (AWA.Sysadmin.Models.Query_Sysadmin_Session_List); Stmt := Session.Create_Statement (Query); Stmt.Execute; Stream.Start_Document; ADO.Utils.Serialize.Write_Query (Stream, "", Stmt); Stream.End_Document; Context.Set_Status (200); end List_Sessions; procedure List_Jobs (Req : in out Swagger.Servers.Request'Class; Reply : in out Swagger.Servers.Response'Class; Stream : in out Swagger.Servers.Output_Stream'Class; Context : in out Swagger.Servers.Context_Type) is pragma Unreferenced (Req, Reply); Module : constant Sysadmin_Module_Access := Get_Sysadmin_Module; Session : constant ADO.Sessions.Session := Module.Get_Session; Query : ADO.Queries.Context; Stmt : ADO.Statements.Query_Statement; begin Log.Info ("List jobs"); Query.Set_Query (AWA.Sysadmin.Models.Query_Sysadmin_Job_List); Stmt := Session.Create_Statement (Query); Stmt.Execute; Stream.Start_Document; ADO.Utils.Serialize.Write_Query (Stream, "", Stmt); Stream.End_Document; Context.Set_Status (200); end List_Jobs; -- ------------------------------ -- Initialize the sysadmin module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Sysadmin_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the sysadmin module"); App.Add_Servlet ("sysadmin", Plugin.API_Servlet'Unchecked_Access); App.Add_Filter ("sysadmin-filter", Plugin.API_Filter'Unchecked_Access); Register.Register (Plugin => Plugin, Name => "AWA.Sysadmin.Beans.Authenticate_Bean", Handler => AWA.Sysadmin.Beans.Create_Authenticate_Bean'Access); App.Add_Mapping (Name => "sysadmin", Pattern => "/sysadmin/api/*"); AWA.Modules.Module (Plugin).Initialize (App, Props); Servlet.Rest.Register (App.all, API_List_Users.Definition); Servlet.Rest.Register (App.all, API_List_Sessions.Definition); Servlet.Rest.Register (App.all, API_List_Jobs.Definition); end Initialize; -- ------------------------------ -- Get the sysadmin module. -- ------------------------------ function Get_Sysadmin_Module return Sysadmin_Module_Access is function Get is new AWA.Modules.Get (Sysadmin_Module, Sysadmin_Module_Access, NAME); begin return Get; end Get_Sysadmin_Module; end AWA.Sysadmin.Modules;
AdaCore/gpr
Ada
68
adb
package body Q is function F return Boolean is separate; end Q;
DavJo-dotdotdot/Ada_Drivers_Library
Ada
458
adb
with MicroBit.DisplayRT; use MicroBit.DisplayRT; with Beacon; with Ada.Real_Time; use Ada.Real_Time; procedure Main is begin MicroBit.DisplayRT.Set_Animation_Step_Duration (80); Beacon.Initialize_Radio; loop if not MicroBit.DisplayRT.Animation_In_Progress then MicroBit.DisplayRT.Display_Async ("BLE beacon "); end if; Beacon.Send_Beacon_Packet; delay until Clock + Milliseconds (500); end loop; end Main;
AdaCore/gpr
Ada
690
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Fixed; use Ada.Strings.Fixed; package body InDash is ------------- -- Display -- ------------- procedure Display (This : access Instrument) is begin New_Line; Put (Head (To_String (This.Name), 13)); Put (" : "); end Display; ---------- -- Name -- ---------- function Name (This : access Instrument) return String is begin return To_String (This.Name); end Name; -------------- -- Set_Name -- -------------- procedure Set_Name (This : access Instrument; To : String) is begin This.Name := To_Unbounded_String (To); end Set_Name; end InDash;
AdaCore/gpr
Ada
180
adb
with Ada.Text_IO; use Ada.Text_IO; package body Other_Naming is procedure Dummy is begin Put_Line (Item => "from Other_Naming.Dummy"); end Dummy; end Other_Naming;
AdaCore/libadalang
Ada
127,553
adb
------------------------------------------------------------------------------ -- -- -- GPR TECHNOLOGY -- -- -- -- Copyright (C) 2011-2017, AdaCore -- -- -- -- This 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. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with GNAT; see file COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Exceptions; use Ada.Exceptions; with Ada.Strings.Fixed; use Ada, Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with GNAT.Directory_Operations; use GNAT, GNAT.Directory_Operations; with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables; with Gpr_Build_Util; use Gpr_Build_Util; with Gpr_Util; use Gpr_Util; with Gprbuild.Compilation.Process; use Gprbuild.Compilation.Process; with Gprbuild.Compilation.Slave; with GPR.Env; with GPR.Names; use GPR.Names; with GPR.Opt; use GPR.Opt; with GPR.Snames; use GPR.Snames; with GPR.Tempdir; with GPR.Util; use GPR.Util; package body Gprbuild.Compile is procedure Add_Compilation_Switches (Source : Source_Id); -- Add to the compilation option, the switches declared in -- Compiler'Switches(<source file name>), if it is defined, otherwise in -- Compiler'Default_Switches (<language name>), if it is defined. procedure Await_Compile (Source : out Queue.Source_Info; OK : out Boolean; Slave : out Unbounded_String); -- Wait for the end of a compilation and indicate that the object directory -- is free. procedure Compilation_Phase (Main_Project : Project_Id; Project_Tree : Project_Tree_Ref); procedure Recursive_Import (Project : Project_Id); -- Add to table Imports the projects imported by Project, recursively function Project_Extends (Extending : Project_Id; Extended : Project_Id) return Boolean; -- Returns True if Extending is Extended or is extending Extended directly -- or indirectly. function Directly_Imports (Project : Project_Id; Imported : Project_Id) return Boolean; -- Returns True if Project directly withs Imported or a project extending -- Imported. procedure Create_Config_File (For_Project : Project_Id; Config : Language_Config; Language : Name_Id); -- Create a new config file function Config_File_For (Project : Project_Id; Package_Name : Name_Id; Attribute_Name : Name_Id; Language : Name_Id) return Path_Name_Type; -- Returns the name of a config file. Returns No_Name if there is no -- config file. procedure Create_Object_Path_File (Project : Project_Id; Shared : Shared_Project_Tree_Data_Access); -- Create a temporary file that contains the list of object directories -- in the correct order. procedure Print_Compilation_Outputs (For_Source : Source_Id; Always : Boolean := False); -- In complete output mode, or when Always is True, put the outputs from -- last compilation to standard output and/or standard error. function "<" (Left, Right : Source_Id) return Boolean is (Left.File < Right.File); package Bad_Compilations_Set is new Containers.Indefinite_Ordered_Maps (Source_Id, String); Bad_Compilations : Bad_Compilations_Set.Map; -- Records bad compilation with the given slave name if any Outstanding_Compiles : Natural := 0; -- The number of compilation jobs currently spawned Slave_Initialized : Boolean := False; -- Record wether the remote compilation slaves have been initialized when -- running in distributed mode. type Process_Purpose is (Compilation, Dependency); -- A type to distinguish between compilation jobs and dependency file -- building jobs. type Process_Data is record Process : Gprbuild.Compilation.Id := Gprbuild.Compilation.Invalid_Process; Source : Queue.Source_Info := Queue.No_Source_Info; Source_Project : Project_Id := null; Mapping_File : Path_Name_Type := No_Path; Purpose : Process_Purpose := Compilation; Options : String_List_Access := null; end record; -- Data recorded for each spawned jobs, compilation of dependency file -- building. No_Process_Data : constant Process_Data := (Process => Gprbuild.Compilation.Invalid_Process, Source => Queue.No_Source_Info, Source_Project => null, Mapping_File => No_Path, Purpose => Compilation, Options => null); package Compilation_Htable is new GNAT.HTable.Simple_HTable (Header_Num => Gprbuild.Compilation.Process.Header_Num, Element => Process_Data, No_Element => No_Process_Data, Key => Gprbuild.Compilation.Id, Hash => Hash, Equal => Gprbuild.Compilation."="); -- Hash table to keep data for all spawned jobs package Naming_Datas is new GNAT.Table (Table_Component_Type => Lang_Naming_Data, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100); -- Naming data when creating config files package Imports is new GNAT.HTable.Simple_HTable (Header_Num => GPR.Header_Num, Element => Boolean, No_Element => False, Key => Project_Id, Hash => Hash, Equal => "="); -- When --direct-import-only is used, contains the project ids a non Ada -- source is allowed to import source from. package Included_Sources is new GNAT.Table (Table_Component_Type => Source_Id, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100); package Subunits is new GNAT.Table (Table_Component_Type => GNAT.OS_Lib.String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100); -- A table to store the subunit names when switch --no-split-units is used ------------------------------ -- Add_Compilation_Switches -- ------------------------------ Inner_Cargs : aliased String := "-inner-cargs"; -- When the --compiler-pkg-subst switch is given, this is used to pass -- switches from "package Compiler" to the ASIS tool and thence through to -- the actual compiler. procedure Add_Compilation_Switches (Source : Source_Id) is procedure Process_One_Package (Pkg_Name : Name_Id); -- Get the switches for the named package ------------------------- -- Process_One_Package -- ------------------------- procedure Process_One_Package (Pkg_Name : Name_Id) is Options : Variable_Value; Ignored : Boolean; begin Get_Switches (Source, Pkg_Name, Project_Tree, Options, Ignored); if Options /= Nil_Variable_Value then declare List : String_List_Id := Options.Values; Element : String_Element; Option : GNAT.OS_Lib.String_Access; begin while List /= Nil_String loop Element := Project_Tree.Shared.String_Elements.Table (List); -- Ignore empty options if Element.Value /= Empty_String then Option := Get_Option (Element.Value); Add_Option_Internal_Codepeer (Value => Option, To => Compilation_Options, Display => True); end if; List := Element.Next; end loop; end; end if; end Process_One_Package; begin -- If the --compiler-pkg-subst switch was given, get switches from the -- relevant package (e.g. "package Pretty_Printer"). if Compiler_Pkg_Subst /= No_Name then Process_One_Package (Compiler_Pkg_Subst); Add_Option_Internal_Codepeer (Value => Inner_Cargs'Unchecked_Access, To => Compilation_Options, Display => True); end if; -- Always get switches from "package Compiler". If the -- --compiler-pkg-subst switch was given, these are preceded by -- -inner-cargs (see above) to indicate that the ASIS tool should pass -- them along to gcc. Process_One_Package (Name_Compiler); end Add_Compilation_Switches; ------------------- -- Await_Compile -- ------------------- procedure Await_Compile (Source : out Queue.Source_Info; OK : out Boolean; Slave : out Unbounded_String) is use type Gprbuild.Compilation.Id; Process : Gprbuild.Compilation.Id; Comp_Data : Process_Data; Language : Language_Ptr; Config : Language_Config; begin loop Source := Queue.No_Source_Info; Wait_Result (Process, OK); if Process = Gprbuild.Compilation.Invalid_Process then return; end if; Comp_Data := Compilation_Htable.Get (Process); if Comp_Data /= No_Process_Data then Source := Comp_Data.Source; Queue.Set_Obj_Dir_Free (Source.Id.Project.Object_Directory.Name); if Comp_Data.Purpose = Compilation then Print_Compilation_Outputs (Source.Id, Always => not No_Complete_Output); if OK then -- We created a new dependency file, so reset the attributes -- of the old one. Source.Id.Dep_TS := Unknown_Attributes; if Comp_Data.Options /= null and then Source.Id.Switches_Path /= No_Path and then Opt.Check_Switches then -- First, update the time stamp of the object file that -- will be written in the switches file. Source.Id.Object_TS := File_Stamp (Source.Id.Object_Path); -- Write the switches file, now that we have the updated -- time stamp for the object file. declare File : Text_IO.File_Type; begin Create (File, Out_File, Get_Name_String (Source.Id.Switches_Path)); Put_Line (File, String (Source.Id.Object_TS)); for J in Comp_Data.Options'Range loop Put_Line (File, Comp_Data.Options (J).all); end loop; Close (File); exception when others => Fail_Program (Source.Tree, "could not create switches file """ & Get_Name_String (Source.Id.Switches_Path) & '"'); end; -- For all languages other than Ada, update the time -- stamp of the object file as it is written in the -- global archive dependency file. For all languages, -- update the time stamp of the object file if it is in -- a library project. elsif Source.Id.Language.Config.Dependency_Kind /= ALI_File or else Source.Id.Project.Library then Source.Id.Object_TS := File_Stamp (Source.Id.Object_Path); end if; else Set_Failed_Compilation_Status (Comp_Data.Source_Project); Slave := To_Unbounded_String (Get_Slave_For (Process)); end if; Language := Source.Id.Language; -- If there is a mapping file used, recycle it in the hash -- table of the language. if Comp_Data.Mapping_File /= No_Path and then Language /= No_Language_Index then Mapping_Files_Htable.Set (T => Language.Mapping_Files, K => Comp_Data.Mapping_File, E => Comp_Data.Mapping_File); end if; Config := Language.Config; if OK and then Config.Dependency_Kind = Makefile and then Config.Compute_Dependency /= No_Name_List then declare Current_Dir : constant Dir_Name_Str := Get_Current_Dir; List : Name_List_Index := Config.Compute_Dependency; Nam : Name_Node := Source.Tree.Shared.Name_Lists.Table (List); Exec_Name : constant String := Get_Name_String (Nam.Name); Exec_Path : OS_Lib.String_Access; begin Change_Dir (Get_Name_String (Source.Id.Project.Object_Directory.Display_Name)); Comp_Data.Mapping_File := No_Path; Comp_Data.Purpose := Dependency; -- ??? We search for it on the PATH for every file, -- this is very inefficient Exec_Path := Locate_Exec_On_Path (Exec_Name); if Exec_Path = null then Fail_Program (Source.Tree, "unable to find dependency builder " & Exec_Name); end if; List := Nam.Next; Compilation_Options.Last := 0; if List = No_Name_List then Name_Len := 0; else loop Nam := Source.Tree.Shared.Name_Lists.Table (List); List := Nam.Next; if List = No_Name_List then Get_Name_String (Nam.Name); exit; end if; Add_Option (Nam.Name, Compilation_Options, Opt.Verbose_Mode); end loop; end if; Add_Str_To_Name_Buffer (Get_Name_String (Source.Id.Path.Display_Name)); Add_Option (Name_Buffer (1 .. Name_Len), Compilation_Options, Opt.Verbose_Mode, Simple_Name => not Opt.Verbose_Mode); if not Opt.Quiet_Output then if Opt.Verbose_Mode then Put (Exec_Path.all); else Put (Exec_Name); end if; Put (" "); for Option in 1 .. Compilation_Options.Last loop if Compilation_Options.Visible (Option) then Put (Compilation_Options.Options (Option).all); Put (" "); end if; end loop; New_Line; end if; Comp_Data.Process := Run (Executable => Exec_Path.all, Options => Compilation_Options.Options (1 .. Compilation_Options.Last), Project => Comp_Data.Source_Project, Obj_Name => Get_Name_String (Source.Id.Object), Output_File => Get_Name_String (Source.Id.Dep_Path), Err_To_Out => True, Force_Local => True); Compilation_Htable.Set (Comp_Data.Process, Comp_Data); Free (Exec_Path); Change_Dir (Current_Dir); end; else Outstanding_Compiles := Outstanding_Compiles - 1; return; end if; elsif Comp_Data.Purpose = Dependency then Outstanding_Compiles := Outstanding_Compiles - 1; return; end if; end if; end loop; end Await_Compile; --------------------- -- Config_File_For -- --------------------- function Config_File_For (Project : Project_Id; Package_Name : Name_Id; Attribute_Name : Name_Id; Language : Name_Id) return Path_Name_Type is function Absolute_Path (Path : Path_Name_Type; Project : Project_Id) return Path_Name_Type; -- Returns an absolute path for a config file ------------------- -- Absolute_Path -- ------------------- function Absolute_Path (Path : Path_Name_Type; Project : Project_Id) return Path_Name_Type is begin Get_Name_String (Path); if not Is_Absolute_Path (Name_Buffer (1 .. Name_Len)) then Get_Name_String (Project.Directory.Display_Name); if Name_Buffer (Name_Len) /= Directory_Separator then Add_Char_To_Name_Buffer (Directory_Separator); end if; Add_Str_To_Name_Buffer (Get_Name_String (Path)); end if; return Name_Find; end Absolute_Path; Config_Package : constant Package_Id := Value_Of (Name => Package_Name, In_Packages => Project.Decl.Packages, Shared => Project_Tree.Shared); Config_Variable : Variable_Value := Value_Of (Name => Language, Attribute_Or_Array_Name => Attribute_Name, In_Package => Config_Package, Shared => Project_Tree.Shared); begin -- Get the config pragma attribute when the language is Ada and the -- config file attribute is not declared. if Config_Variable = Nil_Variable_Value and then Config_Package /= No_Package and then Language = Name_Ada then if Attribute_Name = Name_Global_Config_File then Config_Variable := Value_Of (Variable_Name => Name_Global_Configuration_Pragmas, In_Variables => Project_Tree.Shared.Packages.Table (Config_Package).Decl.Attributes, Shared => Project_Tree.Shared); elsif Attribute_Name = Name_Local_Config_File then Config_Variable := Value_Of (Variable_Name => Name_Local_Configuration_Pragmas, In_Variables => Project_Tree.Shared.Packages.Table (Config_Package).Decl.Attributes, Shared => Project_Tree.Shared); end if; end if; if Config_Variable = Nil_Variable_Value then return No_Path; else Get_Name_String (Config_Variable.Value); if Name_Len = 0 then return No_Path; else return Absolute_Path (Path_Name_Type (Config_Variable.Value), Config_Variable.Project); end if; end if; end Config_File_For; ------------------------ -- Create_Config_File -- ------------------------ procedure Create_Config_File (For_Project : Project_Id; Config : Language_Config; Language : Name_Id) is File_Name : Path_Name_Type := No_Path; File : File_Descriptor := Invalid_FD; Source : Source_Id; Iter : Source_Iterator; procedure Check (Project : Project_Id; Tree : Project_Tree_Ref; Dummy : in out Boolean); -- Check the naming schemes of the different projects of the project -- tree. For each different naming scheme issue the pattern config -- declarations. procedure Check_Temp_File; -- Check if a temp file has been created. If not, create one procedure Copy_Config_File (Project : Project_Id; Package_Name : Name_Id; Attribute_Name : Name_Id; Language : Name_Id); -- If a specified config file exists, copy it in the temporary config -- file. procedure Put_Line (File : File_Descriptor; S : String); -- Output procedure, analogous to normal Text_IO proc of same name ----------- -- Check -- ----------- procedure Check (Project : Project_Id; Tree : Project_Tree_Ref; Dummy : in out Boolean) is pragma Unreferenced (Dummy, Tree); Lang_Id : Language_Ptr := Project.Languages; Current_Naming : Positive := 1; procedure Replace; ------------- -- Replace -- ------------- procedure Replace is Cur : Positive := 1; procedure Substitute (N : File_Name_Type); procedure Substitute (Name : String); ---------------- -- Substitute -- ---------------- procedure Substitute (N : File_Name_Type) is begin if N = No_File then Cur := Cur + 1; else Substitute (Get_Name_String (N)); end if; end Substitute; procedure Substitute (Name : String) is begin Name_Buffer (Cur + Name'Length .. Name_Len - 2 + Name'Length) := Name_Buffer (Cur + 2 .. Name_Len); Name_Buffer (Cur .. Cur + Name'Length - 1) := Name; Name_Len := Name_Len - 2 + Name'Length; Cur := Cur + Name'Length; end Substitute; begin while Cur < Name_Len loop if Name_Buffer (Cur) = '%' then case Name_Buffer (Cur + 1) is when 'b' => Substitute (Lang_Id.Config.Naming_Data.Body_Suffix); when 's' => Substitute (Lang_Id.Config.Naming_Data.Spec_Suffix); when 'd' => Substitute (Lang_Id.Config.Naming_Data.Dot_Replacement); when 'c' => Substitute (Image (Lang_Id.Config.Naming_Data.Casing)); when '%' => Name_Buffer (Cur .. Name_Len - 1) := Name_Buffer (Cur + 1 .. Name_Len); Name_Len := Name_Len - 1; Cur := Cur + 1; when others => Cur := Cur + 1; end case; else Cur := Cur + 1; end if; end loop; end Replace; begin if Current_Verbosity = High then Put ("Checking project file """); Put (Get_Name_String (Project.Name)); Put ("""."); New_Line; end if; while Lang_Id /= No_Language_Index loop exit when Lang_Id.Name = Language; Lang_Id := Lang_Id.Next; end loop; if Lang_Id /= No_Language_Index then Current_Naming := Naming_Datas.First; while Current_Naming <= Naming_Datas.Last loop exit when Naming_Datas.Table (Current_Naming) = Lang_Id.Config.Naming_Data; Current_Naming := Current_Naming + 1; end loop; if Current_Naming > Naming_Datas.Last then Naming_Datas.Increment_Last; Naming_Datas.Table (Naming_Datas.Last) := Lang_Id.Config.Naming_Data; Check_Temp_File; if Lang_Id.Config.Config_Spec_Pattern /= No_Name then Get_Name_String (Lang_Id.Config.Config_Spec_Pattern); Replace; Put_Line (File, Name_Buffer (1 .. Name_Len)); end if; if Lang_Id.Config.Config_Body_Pattern /= No_Name then Get_Name_String (Lang_Id.Config.Config_Body_Pattern); Replace; Put_Line (File, Name_Buffer (1 .. Name_Len)); end if; end if; end if; end Check; --------------------- -- Check_Temp_File -- --------------------- procedure Check_Temp_File is begin if File = Invalid_FD then Tempdir.Create_Temp_File (File, Name => File_Name); if File = Invalid_FD then Fail_Program (Project_Tree, "unable to create temporary configuration pragmas file"); else Record_Temp_File (Project_Tree.Shared, File_Name); if Opt.Verbosity_Level > Opt.Low then Put ("Creating temp file """); Put (Get_Name_String (File_Name)); Put_Line (""""); end if; end if; end if; end Check_Temp_File; ---------------------- -- Copy_Config_File -- ---------------------- procedure Copy_Config_File (Project : Project_Id; Package_Name : Name_Id; Attribute_Name : Name_Id; Language : Name_Id) is Config_File_Path : constant Path_Name_Type := Config_File_For (Project, Package_Name, Attribute_Name, Language); Config_File : Text_IO.File_Type; Line : String (1 .. 1_000); Last : Natural; begin if Config_File_Path /= No_Path then begin Open (Config_File, In_File, Get_Name_String (Config_File_Path)); exception when others => Fail_Program (Project_Tree, "unable to open config file " & Get_Name_String (Config_File_Path)); end; Check_Temp_File; while not End_Of_File (Config_File) loop Get_Line (Config_File, Line, Last); Put_Line (File, Line (1 .. Last)); end loop; Close (Config_File); end if; end Copy_Config_File; -------------- -- Put_Line -- -------------- procedure Put_Line (File : File_Descriptor; S : String) is S0 : String (1 .. S'Length + 1); Last : Natural; begin -- Add an ASCII.LF to the string. As this config file is supposed to -- be used only by the compiler, we don't care about the characters -- for the end of line. In fact we could have put a space, but -- it is more convenient to be able to read gnat.adc during -- development, for which the ASCII.LF is fine. S0 (1 .. S'Length) := S; S0 (S0'Last) := ASCII.LF; Last := Write (File, S0'Address, S0'Length); if Last /= S'Length + 1 then Fail_Program (Project_Tree, "Disk full"); end if; if Current_Verbosity = High then Put_Line (S); end if; end Put_Line; procedure Check_All_Projects is new For_Every_Project_Imported (Boolean, Check); Dummy : Boolean := False; -- Start of processing for Create_Config_File begin -- Nothing to do if config has already been checked if For_Project.Config_Checked then return; end if; if Config.Config_File_Unique then -- Copy an eventual global config file Copy_Config_File (Main_Project, Name_Builder, Name_Global_Config_File, Language); -- Copy an eventual local config file Copy_Config_File (For_Project, Name_Compiler, Name_Local_Config_File, Language); end if; For_Project.Config_Checked := True; Naming_Datas.Init; Check_All_Projects (For_Project, Project_Tree, Dummy); -- Visit all the units and issue the config declarations for those that -- need one. Iter := For_Each_Source (Project_Tree); loop Source := GPR.Element (Iter); exit when Source = No_Source; if Source.Language.Name = Language and then Source.Naming_Exception /= No and then Source.Unit /= No_Unit_Index and then not Source.Locally_Removed and then Source.Replaced_By = No_Source then Name_Len := 0; if Source.Kind = Spec then if Source.Index = 0 and then Config.Config_Spec /= No_Name then Get_Name_String (Config.Config_Spec); elsif Source.Index /= 0 and then Config.Config_Spec_Index /= No_Name then Get_Name_String (Config.Config_Spec_Index); end if; else if Source.Index = 0 and then Config.Config_Body /= No_Name then Get_Name_String (Config.Config_Body); elsif Source.Index /= 0 and then Config.Config_Body_Index /= No_Name then Get_Name_String (Config.Config_Body_Index); end if; end if; if Name_Len /= 0 then declare Cur : Positive := 1; Unit : constant String := Get_Name_String (Source.Unit.Name); File_Name : constant String := Get_Name_String (Source.Display_File); begin while Cur < Name_Len loop if Name_Buffer (Cur) /= '%' then Cur := Cur + 1; else case Name_Buffer (Cur + 1) is when 'u' => Name_Buffer (Cur + Unit'Length .. Name_Len - 2 + Unit'Length) := Name_Buffer (Cur + 2 .. Name_Len); Name_Buffer (Cur .. Cur + Unit'Length - 1) := Unit; Cur := Cur + Unit'Length; Name_Len := Name_Len - 2 + Unit'Length; when 'f' => Name_Buffer (Cur + File_Name'Length .. Name_Len - 2 + File_Name'Length) := Name_Buffer (Cur + 2 .. Name_Len); Name_Buffer (Cur .. Cur + File_Name'Length - 1) := File_Name; Cur := Cur + File_Name'Length; Name_Len := Name_Len - 2 + File_Name'Length; when 'i' => declare Index_String : constant String := Source.Index'Img; begin Name_Buffer (Cur + Index_String'Length .. Name_Len - 2 + Index_String'Length) := Name_Buffer (Cur + 2 .. Name_Len); Name_Buffer (Cur .. Cur + Index_String'Length - 1) := Index_String; Cur := Cur + Index_String'Length; Name_Len := Name_Len - 2 + Index_String'Length; end; when '%' => Name_Buffer (Cur .. Name_Len - 1) := Name_Buffer (Cur + 1 .. Name_Len); Cur := Cur + 1; Name_Len := Name_Len - 1; when others => Cur := Cur + 1; end case; end if; end loop; Put_Line (File, Name_Buffer (1 .. Name_Len)); end; end if; end if; Next (Iter); end loop; if File /= Invalid_FD then Close (File); For_Project.Config_File_Name := File_Name; end if; end Create_Config_File; ----------------------------- -- Create_Object_Path_File -- ----------------------------- procedure Create_Object_Path_File (Project : Project_Id; Shared : Shared_Project_Tree_Data_Access) is FD : File_Descriptor; Name : Path_Name_Type; LF : constant String := (1 => ASCII.LF); procedure Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean); -- Add the object directory of a project to the file --------- -- Add -- --------- procedure Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean) is pragma Unreferenced (Dummy, In_Tree); Path : constant Path_Name_Type := Get_Object_Directory (Project, Including_Libraries => True, Only_If_Ada => False); Last : Natural; pragma Unreferenced (Last); begin if Path /= No_Path then Get_Name_String (Path); Last := Write (FD, Name_Buffer (1)'Address, Name_Len); Last := Write (FD, LF (1)'Address, 1); end if; Dummy := True; end Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Add); Status : Boolean := False; pragma Warnings (Off, Status); begin GPR.Env.Create_Temp_File (Shared, FD, Name, "object path file"); Project.Object_Path_File := Name; For_All_Projects (Project, Project_Tree, Status, Include_Aggregated => True); Close (FD, Status); end Create_Object_Path_File; ---------------------- -- Recursive_Import -- ---------------------- procedure Recursive_Import (Project : Project_Id) is Ext : constant Project_Id := Project.Extends; L : Project_List := Project.Imported_Projects; begin if Ext /= No_Project and then not Imports.Get (Ext) then Imports.Set (Ext, True); Recursive_Import (Ext); end if; while L /= null loop if not Imports.Get (L.Project) then Imports.Set (L.Project, True); Recursive_Import (L.Project); end if; L := L.Next; end loop; end Recursive_Import; ---------------------- -- Directly_Imports -- ---------------------- function Directly_Imports (Project : Project_Id; Imported : Project_Id) return Boolean is L : Project_List := Project.Imported_Projects; P : Project_Id; begin while L /= null loop P := L.Project; while P /= No_Project loop if Imported = P then return True; end if; P := P.Extends; end loop; L := L.Next; end loop; return False; end Directly_Imports; ------------------------------- -- Print_Compilation_Outputs -- ------------------------------- procedure Print_Compilation_Outputs (For_Source : Source_Id; Always : Boolean := False) is begin if Complete_Output or else Always then declare Proj : constant Project_Id := Ultimate_Extending_Project_Of (For_Source.Project); File_Path : constant String := Get_Name_String (Proj.Object_Directory.Name) & Directory_Separator & Get_Name_String (For_Source.File); File : Ada.Text_IO.File_Type; Line : String (1 .. 1_000); Last : Natural; begin begin Open (File, In_File, File_Path & ".stdout"); while not End_Of_File (File) loop Get_Line (File, Line, Last); Put_Line (Standard_Output, Line (1 .. Last)); end loop; Close (File); Open (File, In_File, File_Path & ".stderr"); while not End_Of_File (File) loop Get_Line (File, Line, Last); Put_Line (Standard_Error, Line (1 .. Last)); end loop; Close (File); exception -- Ignore any exception. Most likely it means that the -- files do no exist. when others => null; end; end; end if; end Print_Compilation_Outputs; --------- -- Run -- --------- procedure Run is procedure Do_Compile (Project : Project_Id; Tree : Project_Tree_Ref); ---------------- -- Do_Compile -- ---------------- procedure Do_Compile (Project : Project_Id; Tree : Project_Tree_Ref) is use type Containers.Count_Type; begin if Builder_Data (Tree).Need_Compilation then Compilation_Phase (Project, Tree); if Total_Errors_Detected > 0 or else not Bad_Compilations.Is_Empty then -- If switch -k or -jnn (with nn > 1), output a summary of the -- sources that could not be compiled. if (Opt.Keep_Going or else Get_Maximum_Processes > 1) and then not Bad_Compilations.Is_Empty and then not Opt.No_Exit_Message then New_Line; for Index in Bad_Compilations.Iterate loop declare Source : constant Source_Id := Bad_Compilations_Set.Key (Index); Slave : constant String := Bad_Compilations_Set.Element (Index); begin if Source /= No_Source then Put (" compilation of "); Put (Get_Name_String (Source.Display_File)); Put (" failed"); if Slave /= "" then Put (" on " & Slave); end if; New_Line; end if; end; end loop; New_Line; end if; if Opt.Keep_Going and then Project.Qualifier = Aggregate then Bad_Compilations.Clear; Exit_Code := E_Fatal; else if Distributed_Mode and then Slave_Initialized then Gprbuild.Compilation.Slave.Unregister_Remote_Slaves; end if; Fail_Program (Tree, "*** compilation phase failed", No_Message => Opt.No_Exit_Message); end if; end if; end if; end Do_Compile; procedure Compile_All is new For_Project_And_Aggregated (Do_Compile); begin Compile_All (Main_Project, Project_Tree); -- Unregister the slaves and get back compiled object code. This is a -- nop if no compilation has been done. Gprbuild.Compilation.Slave.Unregister_Remote_Slaves; end Run; ----------------------- -- Compilation_Phase -- ----------------------- procedure Compilation_Phase (Main_Project : Project_Id; Project_Tree : Project_Tree_Ref) is type Local_Project_Data is record Include_Language : Language_Ptr := No_Language_Index; -- Prepared arguments for "include" parameters (-I or include file). -- These are specific to each language and project. Include_Path_File : Path_Name_Type; -- The path name of the of the source search directory file Imported_Dirs_Switches : Argument_List_Access; -- List of the source search switches (-I<source dir>) to be used -- when compiling. Include_Path : OS_Lib.String_Access := null; -- The search source path for the project. Used as the value for an -- environment variable, specified by attribute Include_Path -- (<langu>). The names of the environment variables are in component -- Include_Path of the records Language_Config. end record; -- project-specific data required for this procedure. These are not -- stored in the Project_Data record so that projects kept in memory do -- not have to allocate space for these temporary data No_Local_Project_Data : constant Local_Project_Data := (Include_Language => No_Language_Index, Include_Path => null, Imported_Dirs_Switches => null, Include_Path_File => No_Path); package Local_Projects_HT is new Simple_HTable (Header_Num => GPR.Header_Num, Element => Local_Project_Data, No_Element => No_Local_Project_Data, Key => Project_Id, Hash => GPR.Hash, Equal => "="); Local_Projects : Local_Projects_HT.Instance; Current_Project : Project_Id := No_Project; Current_Language_Ind : Language_Ptr := No_Language_Index; -- The project for which the include path environment has been set last, -- to avoid computing it several times. Dep_File : Text_File; Start : Natural; Finish : Natural; Last_Obj : Natural; procedure Add_Config_File_Switch (Config : Language_Config; Path_Name : Path_Name_Type); procedure Record_ALI_For (Source_Identity : Queue.Source_Info; The_ALI : ALI.ALI_Id := ALI.No_ALI_Id); -- Record the Id of an ALI file in Good_ALI table. -- The_ALI can contain the pre-parsed ali file, to save time. -- Tree is the tree to which Source_Identity belongs function Phase_2_Makefile (Src_Data : Queue.Source_Info) return Boolean; function Phase_2_ALI (Src_Data : Queue.Source_Info) return Boolean; -- Process Wait_For_Available_Slot depending on Src_Data.Dependency type -- This returns whether the compilation is considered as successful or -- not. procedure Set_Options_For_File (Id : Source_Id); -- Prepare the compiler options to use when building Id procedure Process_Project_Phase_1 (Source : Queue.Source_Info); -- If some compilation is needed for this project, perform it function Must_Exit_Because_Of_Error return Boolean; -- Return True if there were errors and the user decided to exit in such -- a case. This waits for any outstanding compilation. function Check_Switches_File (Id : Source_Id) return Boolean; -- Check in its switches file where Id was compiled with the same -- switches procedure Update_Object_Path (Id : Source_Id; Source_Project : Project_Id); -- Update, if necessary, the path of the object file, of the dependency -- file and of the switches file, in the case of the compilation of a -- source in an extended project, when the source is in a project being -- extended. procedure Add_Dependency_Options (Id : Source_Id); -- Add switches to the compilation command line to create the -- dependency file procedure Add_Object_File_Switches (Id : Source_Id); -- If there are switches to specify the name of the object file, add -- them. procedure Add_Object_Path_Switches (Id : Source_Id); -- If attribute Compiler'Object_Path_Switches has been specified, create -- the temporary object path file, if not already done, and add the -- switch(es) to the invocation of the compiler. procedure Add_Config_File_Switches (Id : Source_Id; Source_Project : Project_Id); -- If Config_File_Switches is specified, check if a config file need to -- be specified. Return the path to the config file procedure Add_Trailing_Switches (Id : Source_Id); -- Add the trailing required switches, if any, so that they will be put -- in the switches file. procedure Add_Name_Of_Source_Switches (Id : Source_Id); -- Add the name of the source to be compiled function Add_Mapping_File_Switches (Source : Queue.Source_Info; Source_Project : Project_Id) return Path_Name_Type; -- If the compiler supports mapping files, add the necessary switch. -- Returns the name of the mapping file to use (or No_File) procedure Add_Multi_Unit_Switches (Id : Source_Id); -- Add, if needed, the required switches to compile a multi-unit source -- file. procedure Spawn_Compiler_And_Register (Source : Queue.Source_Info; Source_Project : Project_Id; Compiler_Path : String; Mapping_File_Path : Path_Name_Type; Last_Switches_For_File : Integer); -- Spawn the compiler with the arguments currently set in -- Compiler_Options. It registers the process we just spawned, so that -- we start monitoring it. -- This also displays on the output the command we are spawning. -- Last_Switches_For_File is the index in Compilation_Options of the -- last switch that should be written to the switches file. All -- following switches are not output in that file. function Get_Compatible_Languages (Lang : Language_Ptr) return Name_Ids; -- Return the list of languages that Id could potentially include (for -- instance "C" if Id is a "C++" file. This also includes Id's own -- language. procedure Prepare_Imported_Dirs_Switches (Data : out Local_Project_Data; Project : Project_Id; Lang : Language_Ptr); -- Add the switches for include directories to the command line (these -- are the "-I" switches in the case of C for instance). procedure Prepare_Include_Path_File (Data : out Local_Project_Data; Project : Project_Id; Lang : Language_Ptr); -- Create a file to pass the include directories to the compiler procedure Start_Compile_If_Possible; -- Checks if there is more work that we can do (ie the Queue is non -- empty). If there is, do it only if we have not yet used up all the -- available processes. procedure Wait_For_Available_Slot; -- Check if we should wait for a compilation to finish. This is the case -- if all the available processes are busy compiling sources or there is -- nothing else to do (that is the Q is empty and there are outstanding -- compilations). procedure Set_Env_For_Include_Dirs (Id : Source_Id; Source_Project : Project_Id); -- Set environment variables or switches to pass the include directories -- to the compiler ---------------------------- -- Add_Config_File_Switch -- ---------------------------- procedure Add_Config_File_Switch (Config : Language_Config; Path_Name : Path_Name_Type) is List : Name_List_Index := Config.Config_File_Switches; Nam : Name_Node; begin while List /= No_Name_List loop Nam := Project_Tree.Shared.Name_Lists.Table (List); Get_Name_String (Nam.Name); if Nam.Next = No_Name_List then Add_Str_To_Name_Buffer (Get_Name_String (Path_Name)); end if; Add_Option (Name_Buffer (1 .. Name_Len), To => Compilation_Options, Display => Opt.Verbose_Mode); List := Nam.Next; end loop; end Add_Config_File_Switch; -------------------- -- Record_ALI_For -- -------------------- procedure Record_ALI_For (Source_Identity : Queue.Source_Info; The_ALI : ALI.ALI_Id := ALI.No_ALI_Id) is Local_ALI : ALI.ALI_Id := The_ALI; Text : Text_Buffer_Ptr; begin if The_ALI = ALI.No_ALI_Id then Text := Read_Library_Info_From_Full (File_Name_Type (Source_Identity.Id.Dep_Path), Source_Identity.Id.Dep_TS'Access); if Text /= null then -- Read the ALI file but read only the necessary lines Local_ALI := ALI.Scan_ALI (File_Name_Type (Source_Identity.Id.Dep_Path), Text, Ignore_ED => False, Err => True, Read_Lines => "W"); Free (Text); end if; end if; if Local_ALI /= ALI.No_ALI_Id then Queue.Insert_Withed_Sources_For (Local_ALI, Source_Identity.Tree); ALI.Initialize_ALI; -- ALI.Util.Initialize_ALI_Source; end if; end Record_ALI_For; ---------------------- -- Phase_2_Makefile -- ---------------------- function Phase_2_Makefile (Src_Data : Queue.Source_Info) return Boolean is Object_Path : GNAT.OS_Lib.String_Access; type Src_Record; type Src_Access is access Src_Record; type Src_Record is record File : GNAT.OS_Lib.String_Access; TS : Time_Stamp_Type; Next : Src_Access; end record; First_Src : Src_Access := null; Last_Src : Src_Access := null; procedure Free is new Unchecked_Deallocation (Src_Record, Src_Access); procedure Purge; -- Deallocate Object_Path and the list of sources rooted at -- First_Src. ----------- -- Purge -- ----------- procedure Purge is Curr : Src_Access := First_Src; Next : Src_Access := null; begin Free (Object_Path); Curr := First_Src; First_Src := null; Last_Src := null; while Curr /= null loop Next := Curr.Next; Free (Curr.File); Free (Curr); Curr := Next; end loop; end Purge; Compilation_OK : Boolean := True; Dep_File_OK : Boolean := False; begin Open (Dep_File, Get_Name_String (Src_Data.Id.Dep_Path)); if Is_Valid (Dep_File) then Big_Loop : loop declare End_Of_File_Reached : Boolean := False; Object_Found : Boolean := False; begin loop if End_Of_File (Dep_File) then End_Of_File_Reached := True; exit; end if; Get_Line (Dep_File, Name_Buffer, Name_Len); if Name_Len > 0 and then Name_Buffer (1) /= '#' then -- Skip a first line that is an empty -- continuation line. for J in 1 .. Name_Len - 1 loop if Name_Buffer (J) /= ' ' then Object_Found := True; exit; end if; end loop; exit when Object_Found or else Name_Buffer (Name_Len) /= '\'; end if; end loop; exit Big_Loop when End_Of_File_Reached; end; Start := 1; Finish := Index (Name_Buffer (1 .. Name_Len), ": "); exit Big_Loop when Finish = 0; Last_Obj := Finish; loop Last_Obj := Last_Obj - 1; exit when Last_Obj = Start or else Name_Buffer (Last_Obj) /= ' '; end loop; while Start < Last_Obj and then Name_Buffer (Start) = ' ' loop Start := Start + 1; end loop; Object_Path := new String'(Name_Buffer (Start .. Last_Obj)); Dep_File_OK := True; Start := Finish + 2; -- Process each line Line_Loop : loop declare Line : constant String := Name_Buffer (1 .. Name_Len); Last : constant Natural := Name_Len; begin Name_Loop : loop -- Find the beginning of the next source path -- name. while Start < Last and then Line (Start) = ' ' loop Start := Start + 1; end loop; -- Go to next line when there is a -- continuation character \ at the end of the -- line. exit Name_Loop when Start = Last and then Line (Start) = '\'; -- We should not be at the end of the line, -- without a continuation character \. exit Name_Loop when Start = Last; -- Look for the end of the source path name Finish := Start; while Finish < Last loop if Line (Finish) = '\' then -- On Windows, a '\' is part of the -- path name, except when it is not the -- first character followed by another -- '\' or by a space. On other -- platforms, when we are getting a '\' -- that is not the last character of -- the line, the next character is part -- of the path name, even if it is a -- space. if On_Windows and then Finish = Start and then Line (Finish + 1) = '\' then Finish := Finish + 2; else Finish := Finish + 1; end if; else -- A space that is not preceded by '\' -- indicates the end of the path name. exit when Line (Finish + 1) = ' '; Finish := Finish + 1; end if; end loop; -- Check this source declare Src_Name : constant String := Normalize_Pathname (Name => Line (Start .. Finish), Resolve_Links => False, Case_Sensitive => False); Src_Name_Id : Name_Id; Unescaped : constant String := Unescape (Line (Start .. Finish)); Unescaped_Id : Name_Id; -- Only use to get the time stamp Source_2 : Source_Id; Src_TS : Time_Stamp_Type; begin Name_Len := 0; Add_Str_To_Name_Buffer (Src_Name); Src_Name_Id := Name_Find; Name_Len := 0; Add_Str_To_Name_Buffer (Unescaped); Unescaped_Id := Name_Find; Source_2 := Source_Paths_Htable.Get (Src_Data.Tree.Source_Paths_HT, Path_Name_Type (Src_Name_Id)); Src_TS := File_Stamp (File_Name_Type (Unescaped_Id)); if Source_2 /= No_Source then -- It is a source of a project if not Project_Extends (Src_Data.Id.Project, Source_2.Project) and then not Project_Extends (Source_2.Project, Src_Data.Id.Project) then -- It is not a source of the same project -- as the source just compiled. Check if -- it can be imported. if not Indirect_Imports then if Directly_Imports (Src_Data.Id.Project, Source_2.Project) then -- It is a source of a directly -- imported project. Record its -- project, for later processing. Imports.Set (Source_2.Project, True); else -- It is a source of a project that -- is not directly imported. Record -- the source for later processing. Included_Sources.Append (Source_2); end if; end if; if not Source_2.In_Interfaces then -- It is not a source in the interfaces -- of its project. Report an error and -- invalidate the compilation. Put ('"'); Put (Get_Name_String (Src_Data.Id.Path.Display_Name)); Put (""" cannot import """); Put (Src_Name); Put_Line (""":"); Put (" it is not part of the " & "interfaces of its project """); Put (Get_Name_String (Source_2.Project.Display_Name)); Put_Line (""""); Compilation_OK := False; end if; end if; end if; if First_Src = null then First_Src := new Src_Record' (File => new String'(Src_Name), TS => Src_TS, Next => null); Last_Src := First_Src; else Last_Src.Next := new Src_Record' (File => new String'(Src_Name), TS => Src_TS, Next => null); Last_Src := Last_Src.Next; end if; end; exit Line_Loop when Finish = Last; -- Go get the next source on the line Start := Finish + 1; end loop Name_Loop; end; -- If we are here, we had a continuation character -- \ at the end of the line, so we continue with -- the next line. Get_Line (Dep_File, Name_Buffer, Name_Len); Start := 1; Finish := 1; end loop Line_Loop; end loop Big_Loop; Close (Dep_File); if Included_Sources.Last > 0 then -- Sources in project that are not directly imported -- have been found. Check if they may be imported by -- other allowed imported sources. declare L : Project_List := Src_Data.Id.Project.Imported_Projects; begin -- Put in hash table Imports the project trees -- rooted at the projects that are already in -- Imports. while L /= null loop if Imports.Get (L.Project) then Recursive_Import (L.Project); end if; L := L.Next; end loop; -- For all the imported sources from project not -- directly imported, check if their projects are -- in table imports. for J in 1 .. Included_Sources.Last loop declare Included : constant Source_Id := Included_Sources.Table (J); begin if not Imports.Get (Included.Project) then -- This source is either directly imported or -- imported from another source that should not be -- imported. Report an error and invalidate the -- compilation. Put ('"'); Put (Get_Name_String (Src_Data.Id.Path.Display_Name)); Put (""" cannot import """); Put (Get_Name_String (Included.Path.Display_Name)); Put_Line (""":"); Put (" """); Put (Get_Name_String (Src_Data.Id.Project.Display_Name)); Put (""" does not directly import project """); Put (Get_Name_String (Included.Project.Display_Name)); Put_Line (""""); Compilation_OK := False; end if; end; end loop; end; end if; end if; if Compilation_OK and Dep_File_OK then Create (Dep_File, Get_Name_String (Src_Data.Id.Dep_Path)); Put (Dep_File, Object_Path.all); Put (Dep_File, ": "); declare S : Src_Access := First_Src; begin while S /= null loop Put (Dep_File, S.File.all); Put (Dep_File, " "); Put (Dep_File, String (S.TS)); if S.Next /= null then Put (Dep_File, " \"); end if; Put_Line (Dep_File, ""); S := S.Next; end loop; Close (Dep_File); end; end if; Purge; return Compilation_OK; end Phase_2_Makefile; ----------------- -- Phase_2_ALI -- ----------------- function Phase_2_ALI (Src_Data : Queue.Source_Info) return Boolean is Compilation_OK : Boolean := True; Text : Text_Buffer_Ptr := Read_Library_Info_From_Full (File_Name_Type (Src_Data.Id.Dep_Path), Src_Data.Id.Dep_TS'Access); The_ALI : ALI.ALI_Id := ALI.No_ALI_Id; Sfile : File_Name_Type; Afile : File_Name_Type; Source_2 : Source_Id; procedure Check_Source (Sfile : File_Name_Type); -- Check if source Sfile is in the same project file as the Src_Data -- source file. Invalidate the compilation if it is not. ------------------ -- Check_Source -- ------------------ procedure Check_Source (Sfile : File_Name_Type) is Source_3 : constant Source_Id := Find_Source (Src_Data.Tree, No_Project, Base_Name => Sfile); begin if Source_3 = No_Source then Put ("source "); Put (Get_Name_String (Sfile)); Put_Line (" is not a source of a project"); Compilation_OK := False; elsif Ultimate_Extending_Project_Of (Source_3.Project) /= Ultimate_Extending_Project_Of (Src_Data.Id.Project) then Put ("sources "); Put (Get_Name_String (Source_3.File)); Put (" and "); Put (Get_Name_String (Src_Data.Id.File)); Put (" belong to different projects: "); Put (Get_Name_String (Source_3.Project.Display_Name)); Put (" and "); Put_Line (Get_Name_String (Src_Data.Id.Project.Display_Name)); Compilation_OK := False; end if; end Check_Source; begin if Text /= null then -- Read the ALI file but read only the necessary lines The_ALI := ALI.Scan_ALI (File_Name_Type (Src_Data.Id.Dep_Path), Text, Ignore_ED => False, Err => True, Read_Lines => "DW"); if The_ALI /= ALI.No_ALI_Id then for J in ALI.ALIs.Table (The_ALI).First_Unit .. ALI.ALIs.Table (The_ALI).Last_Unit loop for K in ALI.Units.Table (J).First_With .. ALI.Units.Table (J).Last_With loop if not ALI.Withs.Table (K).Implicit_With_From_Instantiation then Sfile := ALI.Withs.Table (K).Sfile; -- Skip generics if Sfile /= No_File then -- Look for this source Afile := ALI.Withs.Table (K).Afile; Source_2 := Source_Files_Htable.Get (Src_Data.Tree.Source_Files_HT, Sfile); while Source_2 /= No_Source loop if Is_Compilable (Source_2) and then Source_2.Dep_Name = Afile then case Source_2.Kind is when Spec => null; when Impl => if Is_Subunit (Source_2) then Source_2 := No_Source; end if; when Sep => Source_2 := No_Source; end case; exit; end if; Source_2 := Source_2.Next_With_File_Name; end loop; -- If it is the source of a project that is not the -- project of the source just compiled, check if it -- is allowed to be imported. if Source_2 /= No_Source then if not Project_Extends (Src_Data.Id.Project, Source_2.Project) and then not Project_Extends (Source_2.Project, Src_Data.Id.Project) then if not Indirect_Imports and then not Directly_Imports (Src_Data.Id.Project, Source_2.Project) then -- It is in a project that is not directly -- imported. Report an error and -- invalidate the compilation. Put ("Unit """); Put (Get_Name_String (Src_Data.Id.Unit.Name)); Put (""" cannot import unit """); Put (Get_Name_String (Source_2.Unit.Name)); Put_Line (""":"); Put (" """); Put (Get_Name_String (Src_Data.Id.Project.Display_Name)); Put (""" does not directly" & " import project """); Put (Get_Name_String (Source_2.Project.Display_Name)); Put_Line (""""); Compilation_OK := False; elsif not Source_2.In_Interfaces then -- It is not an interface of its project. -- Report an error and invalidate the -- compilation. Put ("Unit """); Put (Get_Name_String (Src_Data.Id.Unit.Name)); Put (""" cannot import unit """); Put (Get_Name_String (Source_2.Unit.Name)); Put_Line (""":"); Put (" it is not part of the " & "interfaces of its project """); Put (Get_Name_String (Source_2.Project.Display_Name)); Put_Line (""""); Compilation_OK := False; end if; end if; end if; end if; end if; end loop; end loop; if Opt.No_Split_Units then -- Initialized the list of subunits with the unit name Subunits.Init; Subunits.Append (new String'(Get_Name_String (Src_Data.Id.Unit.Name))); -- First check that the spec and the body are in the same -- project. for J in ALI.ALIs.Table (The_ALI).First_Unit .. ALI.ALIs.Table (The_ALI).Last_Unit loop Check_Source (ALI.Units.Table (J).Sfile); end loop; -- Next, check the subunits, if any declare Subunit_Found : Boolean; Already_Found : Boolean; Last : Positive; begin -- Loop until we don't find new subunits loop Subunit_Found := False; for D in ALI.ALIs.Table (The_ALI).First_Sdep .. ALI.ALIs.Table (The_ALI).Last_Sdep loop if ALI.Sdep.Table (D).Subunit_Name /= No_Name then Get_Name_String (ALI.Sdep.Table (D).Subunit_Name); -- First check if we already found this subunit Already_Found := False; for K in 1 .. Subunits.Last loop if Name_Buffer (1 .. Name_Len) = Subunits.Table (K).all then Already_Found := True; exit; end if; end loop; if not Already_Found then -- Find the name of the parent Last := Name_Len - 1; while Last > 1 and then Name_Buffer (Last + 1) /= '.' loop Last := Last - 1; end loop; for J in 1 .. Subunits.Last loop if Subunits.Table (J).all = Name_Buffer (1 .. Last) then -- It is a new subunit, add it o the -- list and check if it is in the right -- project. Subunits.Append (new String' (Name_Buffer (1 .. Name_Len))); Subunit_Found := True; Check_Source (ALI.Sdep.Table (D).Sfile); exit; end if; end loop; end if; end if; end loop; exit when not Subunit_Found; end loop; end; end if; if Compilation_OK and then (Builder_Data (Src_Data.Tree).Closure_Needed or else Src_Data.Closure) then Record_ALI_For (Src_Data, The_ALI); end if; end if; Free (Text); end if; return Compilation_OK; end Phase_2_ALI; -------------------------- -- Set_Options_For_File -- -------------------------- procedure Set_Options_For_File (Id : Source_Id) is Config : Language_Config renames Id.Language.Config; Builder_Options_Instance : constant Builder_Comp_Option_Table_Ref := Builder_Compiling_Options_HTable.Get (Id.Language.Name); Comp_Opt : constant Comp_Option_Table_Ref := Compiling_Options_HTable.Get (Id.Language.Name); List : Name_List_Index; Nam_Nod : Name_Node; First : Boolean; begin Compilation_Options.Last := 0; -- 1a) The leading required switches List := Config.Compiler_Leading_Required_Switches; First := True; while List /= No_Name_List loop Nam_Nod := Project_Tree.Shared.Name_Lists.Table (List); if Nam_Nod.Name /= Empty_String then Add_Option_Internal_Codepeer (Value => new String'(Get_Name_String (Nam_Nod.Name)), To => Compilation_Options, Display => First or Opt.Verbose_Mode); First := False; end if; List := Nam_Nod.Next; end loop; -- 1b) The switches in CodePeer mode if Opt.CodePeer_Mode then -- Replace -x ada with -x adascil declare Cur : Integer := Compilation_Options.Last - 1; begin while Cur > 0 and then Compilation_Options.Options (Cur).all /= "-x" loop Cur := Cur - 1; end loop; if Cur /= 0 then Compilation_Options.Visible (Cur) := True; Compilation_Options.Options (Cur + 1) := new String'("adascil"); Compilation_Options.Visible (Cur + 1) := True; else Add_Option (Value => "-x", To => Compilation_Options, Display => True); Add_Option (Value => "adascil", To => Compilation_Options, Display => True); end if; end; Add_Option (Value => "-gnatcC", To => Compilation_Options, Display => True); end if; -- 2) the compilation switches specified in package Builder -- for all compilers, following "-cargs", if any. for Index in 1 .. All_Language_Builder_Compiling_Options.Last loop Add_Option_Internal_Codepeer (Value => All_Language_Builder_Compiling_Options.Table (Index), To => Compilation_Options, Display => True); end loop; -- 3) the compilation switches specified in package Builder -- for the compiler of the language, following -- -cargs:<language>. if Builder_Options_Instance /= null then for Index in 1 .. Builder_Compiling_Options.Last (Builder_Options_Instance.all) loop Add_Option_Internal_Codepeer (Value => Builder_Options_Instance.Table (Index), To => Compilation_Options, Display => True); end loop; end if; -- 4) The PIC option if it exists, for shared and "static-pic" -- libraries. if Id.Project.Library and then Id.Project.Library_Kind /= Static then List := Config.Compilation_PIC_Option; while List /= No_Name_List loop Nam_Nod := Project_Tree.Shared.Name_Lists.Table (List); Add_Option_Internal_Codepeer (Value => new String'(Get_Name_String (Nam_Nod.Name)), To => Compilation_Options, Display => True); List := Nam_Nod.Next; end loop; end if; -- 5) Compiler'Switches(<source file name>), if it is -- defined, otherwise Compiler'Switches (<language name>), -- if defined. Add_Compilation_Switches (Id); -- 6) the switches specified on the gprbuild command line -- for all compilers, following "-cargs", if any. for Index in 1 .. All_Language_Compiling_Options.Last loop Add_Option_Internal_Codepeer (Value => All_Language_Compiling_Options.Table (Index), To => Compilation_Options, Display => True); end loop; -- 7) the switches specified on the gprbuild command line -- for the compiler of the language, following -- -cargs:<language>. if Comp_Opt /= null then for Index in 1 .. Compiling_Options.Last (Comp_Opt.all) loop Add_Option_Internal_Codepeer (Value => Comp_Opt.Table (Index), To => Compilation_Options, Display => True); end loop; end if; end Set_Options_For_File; ------------------------- -- Check_Switches_File -- ------------------------- function Check_Switches_File (Id : Source_Id) return Boolean is File : Text_IO.File_Type; function Assert_Line (Current : String) return Boolean; -- Return False if Current is not the next line in the switches file ----------------- -- Assert_Line -- ----------------- function Assert_Line (Current : String) return Boolean is Line : String (1 .. 1_000); Last : Natural; begin if End_Of_File (File) then if Opt.Verbosity_Level > Opt.Low then Put_Line (" -> switches file has fewer switches"); end if; Close (File); return False; end if; Get_Line (File, Line, Last); if Line (1 .. Last) /= Current then if Opt.Verbosity_Level > Opt.Low then Put_Line (" -> switches file '" & Get_Name_String (Id.Switches_Path) & "' has different line"); Put_Line (" " & Line (1 .. Last)); Put_Line (" " & Current); end if; Close (File); return False; end if; return True; end Assert_Line; List : Name_List_Index; Nam_Nod : Name_Node; begin Open (File, In_File, Get_Name_String (Id.Switches_Path)); if not Assert_Line (String (Id.Object_TS)) then return True; end if; for Index in 1 .. Compilation_Options.Last loop if not Assert_Line (Compilation_Options.Options (Index).all) then return True; end if; end loop; List := Id.Language.Config.Compiler_Trailing_Required_Switches; while List /= No_Name_List loop Nam_Nod := Project_Tree.Shared.Name_Lists.Table (List); if not Assert_Line (Get_Name_String (Nam_Nod.Name)) then return True; end if; List := Nam_Nod.Next; end loop; if not End_Of_File (File) then if Opt.Verbosity_Level > Opt.Low then Put_Line (" -> switches file has more switches"); end if; Close (File); return True; end if; Close (File); return False; exception when others => if Opt.Verbosity_Level > Opt.Low then Put_Line (" -> no switches file"); end if; return True; end Check_Switches_File; ------------------------ -- Update_Object_Path -- ------------------------ procedure Update_Object_Path (Id : Source_Id; Source_Project : Project_Id) is begin Id.Object_Project := Source_Project; if Id.Object_Project /= Id.Project then if Id.Object /= No_File then Get_Name_String (Id.Object_Project.Object_Directory.Display_Name); Add_Str_To_Name_Buffer (Get_Name_String (Id.Object)); Id.Object_Path := Name_Find; end if; if Id.Dep_Name /= No_File then Get_Name_String (Id.Object_Project.Object_Directory.Display_Name); Add_Str_To_Name_Buffer (Get_Name_String (Id.Dep_Name)); Id.Dep_Path := Name_Find; end if; if Id.Switches /= No_File then Get_Name_String (Id.Object_Project.Object_Directory.Display_Name); Add_Str_To_Name_Buffer (Get_Name_String (Id.Switches)); Id.Switches_Path := Name_Find; end if; end if; end Update_Object_Path; ---------------------------- -- Add_Dependency_Options -- ---------------------------- procedure Add_Dependency_Options (Id : Source_Id) is List : Name_List_Index := Id.Language.Config.Dependency_Option; Node : Name_Node; begin if Id.Language.Config.Dependency_Kind /= None then while List /= No_Name_List loop Node := Project_Tree.Shared.Name_Lists.Table (List); List := Node.Next; if List = No_Name_List then Add_Option (Value => Get_Name_String (Node.Name) & Get_Name_String (Id.Dep_Name), To => Compilation_Options, Display => Opt.Verbose_Mode); else Add_Option (Value => Node.Name, To => Compilation_Options, Display => Opt.Verbose_Mode); end if; end loop; end if; end Add_Dependency_Options; ------------------------------ -- Add_Object_File_Switches -- ------------------------------ procedure Add_Object_File_Switches (Id : Source_Id) is List : Name_List_Index := Id.Language.Config.Object_File_Switches; Node : Name_Node; begin if List /= No_Name_List then loop Node := Project_Tree.Shared.Name_Lists.Table (List); exit when Node.Next = No_Name_List; Add_Option (Node.Name, To => Compilation_Options, Display => Opt.Verbose_Mode or else Id.Index /= 0); List := Node.Next; end loop; Get_Name_String (Node.Name); Add_Str_To_Name_Buffer (Get_Name_String (Id.Object)); Add_Option (Name_Buffer (1 .. Name_Len), To => Compilation_Options, Display => Opt.Verbose_Mode or else Id.Index /= 0); -- Always specify object-file for a multi-unit source file elsif Id.Index /= 0 then Add_Option ("-o", To => Compilation_Options, Display => True); Add_Option (Get_Name_String (Id.Object), To => Compilation_Options, Display => True); end if; end Add_Object_File_Switches; ------------------------------ -- Add_Object_Path_Switches -- ------------------------------ procedure Add_Object_Path_Switches (Id : Source_Id) is List : Name_List_Index := Id.Language.Config.Object_Path_Switches; Node : Name_Node; begin if List /= No_Name_List then if Id.Project.Object_Path_File = No_Path then Create_Object_Path_File (Id.Project, Project_Tree.Shared); end if; while List /= No_Name_List loop Node := Project_Tree.Shared.Name_Lists.Table (List); exit when Node.Next = No_Name_List; Add_Option (Node.Name, To => Compilation_Options, Display => Opt.Verbose_Mode); List := Node.Next; end loop; Get_Name_String (Node.Name); Add_Str_To_Name_Buffer (Get_Name_String (Id.Project.Object_Path_File)); Add_Option (Name_Buffer (1 .. Name_Len), To => Compilation_Options, Display => Opt.Verbose_Mode); end if; end Add_Object_Path_Switches; ------------------------------ -- Add_Config_File_Switches -- ------------------------------ procedure Add_Config_File_Switches (Id : Source_Id; Source_Project : Project_Id) is Config : constant Language_Config := Id.Language.Config; Config_File_Path : Path_Name_Type; begin if Config.Config_File_Switches /= No_Name_List and then (Config.Config_Body /= No_Name or else Config.Config_Body_Index /= No_Name or else Config.Config_Body_Pattern /= No_Name or else Config.Config_Spec /= No_Name or else Config.Config_Spec_Index /= No_Name or else Config.Config_Spec_Pattern /= No_Name) then Create_Config_File (For_Project => Source_Project, Config => Config, Language => Id.Language.Name); if Source_Project.Config_File_Name /= No_Path then Add_Config_File_Switch (Config => Config, Path_Name => Source_Project.Config_File_Name); end if; if not Config.Config_File_Unique then Config_File_Path := Config_File_For (Project => Main_Project, Package_Name => Name_Builder, Attribute_Name => Name_Global_Config_File, Language => Id.Language.Name); if Config_File_Path /= No_Path then Add_Config_File_Switch (Config => Config, Path_Name => Config_File_Path); end if; Config_File_Path := Config_File_For (Project => Source_Project, Package_Name => Name_Compiler, Attribute_Name => Name_Local_Config_File, Language => Id.Language.Name); if Config_File_Path /= No_Path then Add_Config_File_Switch (Config => Config, Path_Name => Config_File_Path); end if; end if; end if; end Add_Config_File_Switches; ------------------------------- -- Add_Mapping_File_Switches -- ------------------------------- function Add_Mapping_File_Switches (Source : Queue.Source_Info; Source_Project : Project_Id) return Path_Name_Type is List : Name_List_Index := Source.Id.Language.Config.Mapping_File_Switches; Node : Name_Node; Mapping_File_Path : Path_Name_Type; begin if List /= No_Name_List then -- Check if there is a temporary mapping file we can use Mapping_File_Path := Mapping_Files_Htable.Get_First (Source.Id.Language.Mapping_Files); if Mapping_File_Path /= No_Path then -- Reuse this temporary mapping file and remove its -- name from the HTable so that it is not reused -- before the compilation terminates. Mapping_Files_Htable.Remove (Source.Id.Language.Mapping_Files, Mapping_File_Path); else -- Create a new temporary mapping file, as there are -- none that can be reused. GPR.Env.Create_Mapping_File (Project => Source_Project, Language => Source.Id.Language.Name, In_Tree => Source.Tree, Name => Mapping_File_Path); end if; while List /= No_Name_List loop Node := Source.Tree.Shared.Name_Lists.Table (List); List := Node.Next; if List /= No_Name_List then Add_Option (Value => Node.Name, To => Compilation_Options, Display => Opt.Verbose_Mode); else Get_Name_String (Node.Name); Add_Str_To_Name_Buffer (Get_Name_String (Mapping_File_Path)); Add_Option (Name_Buffer (1 .. Name_Len), To => Compilation_Options, Display => Opt.Verbose_Mode); end if; end loop; return Mapping_File_Path; else return No_Path; end if; end Add_Mapping_File_Switches; ----------------------------- -- Add_Multi_Unit_Switches -- ----------------------------- procedure Add_Multi_Unit_Switches (Id : Source_Id) is List : Name_List_Index := Id.Language.Config.Multi_Unit_Switches; begin if Id.Index /= 0 and then List /= No_Name_List then declare Index_Img : constant String := Id.Index'Img; Node : Name_Node; begin loop Node := Project_Tree.Shared.Name_Lists.Table (List); exit when Node.Next = No_Name_List; Add_Option (Node.Name, To => Compilation_Options, Display => True); List := Node.Next; end loop; Get_Name_String (Node.Name); Add_Str_To_Name_Buffer (Index_Img (2 .. Index_Img'Last)); Add_Option (Name_Buffer (1 .. Name_Len), To => Compilation_Options, Display => True); end; end if; end Add_Multi_Unit_Switches; --------------------------- -- Add_Trailing_Switches -- --------------------------- procedure Add_Trailing_Switches (Id : Source_Id) is List : Name_List_Index := Id.Language.Config.Compiler_Trailing_Required_Switches; Node : Name_Node; begin while List /= No_Name_List loop Node := Project_Tree.Shared.Name_Lists.Table (List); Add_Option (Node.Name, To => Compilation_Options, Display => Opt.Verbose_Mode); List := Node.Next; end loop; end Add_Trailing_Switches; --------------------------------- -- Add_Name_Of_Source_Switches -- --------------------------------- procedure Add_Name_Of_Source_Switches (Id : Source_Id) is List : Name_List_Index := Id.Language.Config.Source_File_Switches; Node : Name_Node; Source_Path : OS_Lib.String_Access; begin -- Add any source file prefix if List /= No_Name_List then loop Node := Project_Tree.Shared.Name_Lists.Table (List); exit when Node.Next = No_Name_List; Add_Option (Node.Name, To => Compilation_Options, Display => Opt.Verbose_Mode or else Id.Index /= 0); List := Node.Next; end loop; end if; -- Then handle the source file Get_Name_String (Id.Path.Display_Name); -- case Id.Language.Config.Path_Syntax is -- when Canonical => Source_Path := new String'(Name_Buffer (1 .. Name_Len)); -- when Host => -- Source_Path := To_Host_File_Spec (Name_Buffer (1 .. Name_Len)); -- end case; if Node.Name = No_Name then Add_Option_Internal (Source_Path, To => Compilation_Options, Display => True, Simple_Name => not Opt.Verbose_Mode); else Get_Name_String (Node.Name); Add_Option (Name_Buffer (1 .. Name_Len) & Source_Path.all, To => Compilation_Options, Display => True, Simple_Name => not Opt.Verbose_Mode); end if; end Add_Name_Of_Source_Switches; --------------------------------- -- Spawn_Compiler_And_Register -- --------------------------------- procedure Spawn_Compiler_And_Register (Source : Queue.Source_Info; Source_Project : Project_Id; Compiler_Path : String; Mapping_File_Path : Path_Name_Type; Last_Switches_For_File : Integer) is procedure Add_Process (Process : Gprbuild.Compilation.Id; Source : Queue.Source_Info; Source_Project : Project_Id; Mapping_File : Path_Name_Type; Purpose : Process_Purpose; Options : String_List_Access); -- Add compilation process and indicate that the object directory is -- busy. procedure Escape_Path (Options : in out String_List); -- On Windows, duplicate the directory separators ('\') in Options. -- On other platforms, this procedure does nothing. ----------------- -- Add_Process -- ----------------- procedure Add_Process (Process : Gprbuild.Compilation.Id; Source : Queue.Source_Info; Source_Project : Project_Id; Mapping_File : Path_Name_Type; Purpose : Process_Purpose; Options : String_List_Access) is begin Compilation_Htable.Set (Process, (Process, Source, Source_Project, Mapping_File, Purpose, Options)); Outstanding_Compiles := Outstanding_Compiles + 1; Queue.Set_Obj_Dir_Busy (Source.Id.Project.Object_Directory.Name); end Add_Process; ----------------- -- Escape_Path -- ----------------- procedure Escape_Path (Options : in out String_List) is begin if On_Windows then for J in Options'Range loop declare Opt : constant String := Options (J).all; Nopt : String (1 .. Opt'Length * 2); Last : Natural := 0; begin for K in Opt'Range loop Last := Last + 1; Nopt (Last) := Opt (K); if Opt (K) = Directory_Separator then Last := Last + 1; Nopt (Last) := Directory_Separator; end if; end loop; if Last > Opt'Length then -- Do not free the option, as it has been recorded in -- All_Options. Options (J) := new String'(Nopt (1 .. Last)); end if; end; end loop; end if; end Escape_Path; ------------------ -- Get_Language -- ------------------ function Get_Language return String is (if Source.Id.Language /= null then Get_Name_String (Source.Id.Language.Name) else ""); Process : Gprbuild.Compilation.Id; Options : GNAT.OS_Lib.Argument_List_Access; Response_File : Path_Name_Type := No_Path; -- Start of processing of Spawn_Compiler_And_Register begin if not Opt.Quiet_Output then Name_Len := 0; if Opt.Verbose_Mode then Add_Str_To_Name_Buffer (Compiler_Path); for Option in 1 .. Compilation_Options.Last loop Add_Str_To_Name_Buffer (" "); if Compilation_Options.Simple_Name (Option) then Add_Str_To_Name_Buffer (Base_Name (Compilation_Options.Options (Option).all)); else Add_Str_To_Name_Buffer (Compilation_Options.Options (Option).all); end if; end loop; Put_Line (Name_Buffer (1 .. Name_Len)); else Display (Section => GPR.Compile, Command => Get_Name_String (Source.Id.Language.Display_Name), Argument => Get_Name_String (Source.Id.File)); end if; end if; if Source_Project.Config.Max_Command_Line_Length > 0 and then Source.Id.Language.Config.Resp_File_Format = GCC_GNU then declare Arg_Length : Natural := 0; begin for J in 1 .. Compilation_Options.Last loop Arg_Length := Arg_Length + 1 + Compilation_Options.Options (J)'Length; end loop; if Arg_Length > Source_Project.Config.Max_Command_Line_Length then declare use GPR.Tempdir; FD : File_Descriptor; Status : Integer; Closing_Status : Boolean; begin -- On Windows, directory separators ('\') need to be -- doubled in response files, otherwise gcc does not -- take them as directory separators. Escape_Path (Compilation_Options.Options (1 .. Compilation_Options.Last)); Create_Temp_File (FD, Response_File); Record_Temp_File (Shared => Source.Tree.Shared, Path => Response_File); Option_Loop : for J in 1 .. Compilation_Options.Last loop Status := Write (FD, Compilation_Options.Options (J) (1)'Address, Compilation_Options.Options (J)'Length); if Status /= Compilation_Options.Options (J)'Length then Put_Line ("Could not write option """ & Compilation_Options.Options (J).all & """ in response file """ & Get_Name_String (Response_File) & """"); Response_File := No_Path; exit Option_Loop; end if; Status := Write (FD, ASCII.LF'Address, 1); end loop Option_Loop; Close (FD, Closing_Status); if not Closing_Status and then Response_File /= No_Path then Put_Line ("Could not close response file """ & Get_Name_String (Response_File) & """"); Response_File := No_Path; end if; end; if Opt.Verbosity_Level > Opt.Low and then Response_File /= No_Path then Put_Line ("using a response file"); end if; end if; end; end if; Process := Run (Compiler_Path, Compilation_Options.Options (1 .. Compilation_Options.Last), Source_Project, Source => Get_Name_String (Source.Id.File), Language => Get_Language, Dep_Name => (if Source.Id.Dep_Name = No_File then "" else Get_Name_String (Source.Id.Dep_Name)), Obj_Name => (if Source.Id.Object = No_File then "" else Get_Name_String (Source.Id.Object)), Response_File => Response_File); if Last_Switches_For_File >= 0 then Compilation_Options.Last := Last_Switches_For_File; Add_Trailing_Switches (Source.Id); Options := new String_List' (Compilation_Options.Options (1 .. Compilation_Options.Last)); end if; Add_Process (Process => Process, Source => Source, Source_Project => Source_Project, Mapping_File => Mapping_File_Path, Purpose => Compilation, Options => Options); end Spawn_Compiler_And_Register; ------------------------------ -- Get_Compatible_Languages -- ------------------------------ function Get_Compatible_Languages (Lang : Language_Ptr) return Name_Ids is NL : Name_List_Index := Lang.Config.Include_Compatible_Languages; Languages : Name_Ids (1 .. 1 + Length (Project_Tree.Shared.Name_Lists, NL)); Index : Positive := 1; begin Languages (Index) := Lang.Name; while NL /= No_Name_List loop Index := Index + 1; Languages (Index) := Project_Tree.Shared.Name_Lists.Table (NL).Name; NL := Project_Tree.Shared.Name_Lists.Table (NL).Next; end loop; return Languages; end Get_Compatible_Languages; ------------------------------- -- Prepare_Include_Path_File -- ------------------------------- procedure Prepare_Include_Path_File (Data : out Local_Project_Data; Project : Project_Id; Lang : Language_Ptr) is FD : File_Descriptor; Status : Boolean; begin Get_Directories (Project_Tree => Project_Tree, For_Project => Project, Activity => Compilation, Languages => Get_Compatible_Languages (Lang)); GPR.Env.Create_New_Path_File (Shared => Project_Tree.Shared, Path_FD => FD, Path_Name => Data.Include_Path_File); if FD = Invalid_FD then Fail_Program (Project_Tree, "could not create temporary path file"); end if; for Index in 1 .. Directories.Last loop Get_Name_String (Directories.Table (Index)); Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := ASCII.LF; if Write (FD, Name_Buffer (1)'Address, Name_Len) /= Name_Len then Fail_Program (Project_Tree, "disk full when writing include path file"); end if; end loop; Close (FD, Status); if not Status then Fail_Program (Project_Tree, "disk full when writing include path file"); end if; end Prepare_Include_Path_File; ------------------------------------ -- Prepare_Imported_Dirs_Switches -- ------------------------------------ procedure Prepare_Imported_Dirs_Switches (Data : out Local_Project_Data; Project : Project_Id; Lang : Language_Ptr) is Len : constant Natural := Length (Project_Tree.Shared.Name_Lists, Lang.Config.Include_Option); -- Host_Path : OS_Lib.String_Access; Last : Natural := 0; List : Name_List_Index; Nam : Name_Node; begin Get_Directories (Project_Tree => Project_Tree, For_Project => Project, Activity => Compilation, Languages => Get_Compatible_Languages (Lang)); Free (Data.Imported_Dirs_Switches); Data.Imported_Dirs_Switches := new String_List (1 .. Directories.Last * Len); for Index in 1 .. Directories.Last loop List := Lang.Config.Include_Option; while List /= No_Name_List loop Nam := Project_Tree.Shared.Name_Lists.Table (List); exit when Nam.Next = No_Name_List; Last := Last + 1; Data.Imported_Dirs_Switches (Last) := new String'(Get_Name_String (Nam.Name)); List := Nam.Next; end loop; Get_Name_String (Directories.Table (Index)); while Name_Len > 1 and then (Name_Buffer (Name_Len) = Directory_Separator or else Name_Buffer (Name_Len) = '/') loop Name_Len := Name_Len - 1; end loop; Last := Last + 1; -- Concatenate the last switch and the path in a single option -- case Lang.Config.Path_Syntax is -- when Canonical => Data.Imported_Dirs_Switches (Last) := new String' (Get_Name_String (Nam.Name) & Name_Buffer (1 .. Name_Len)); -- when Host => -- Host_Path := To_Host_Dir_Spec -- (Name_Buffer (1 .. Name_Len), False); -- Data.Imported_Dirs_Switches (Last) := new String' -- (Get_Name_String (Nam.Name) & Host_Path.all); -- Free (Host_Path); -- end case; end loop; end Prepare_Imported_Dirs_Switches; ------------------------------ -- Set_Env_For_Include_Dirs -- ------------------------------ procedure Set_Env_For_Include_Dirs (Id : Source_Id; Source_Project : Project_Id) is Data : Local_Project_Data := Local_Projects_HT.Get (Local_Projects, Id.Object_Project); begin -- Prepare (if not already done) the data for Project/Lang. -- All files for a given language are processed sequentially, before -- we switch to the next language, so we are only preparing once per -- language here. if Data.Include_Language /= Id.Language then Free (Data.Include_Path); Free (Data.Imported_Dirs_Switches); Data := No_Local_Project_Data; if Id.Language.Config.Include_Option /= No_Name_List then Prepare_Imported_Dirs_Switches (Data, Id.Object_Project, Id.Language); elsif Id.Language.Config.Include_Path_File /= No_Name then if Id.Language.Config.Mapping_File_Switches = No_Name_List or else Opt.Use_Include_Path_File then Prepare_Include_Path_File (Data, Id.Object_Project, Id.Language); end if; elsif Id.Language.Config.Include_Path /= No_Name then Get_Directories (Project_Tree => Project_Tree, For_Project => Id.Object_Project, Activity => Compilation, Languages => Get_Compatible_Languages (Id.Language)); Data.Include_Path := Create_Path_From_Dirs; end if; Data.Include_Language := Id.Language; Local_Projects_HT.Set (Local_Projects, Id.Object_Project, Data); end if; -- Reset environment variables if they have changed if Id.Object_Project /= Current_Project or else Id.Language /= Current_Language_Ind then Current_Project := Id.Object_Project; Current_Language_Ind := Id.Language; if Data.Include_Path_File /= No_Path then Setenv (Get_Name_String (Id.Language.Config.Include_Path_File), Get_Name_String (Data.Include_Path_File)); elsif Data.Include_Path /= null then Gprbuild.Compilation.Process.Record_Environment (Source_Project, Id.Language.Name, Get_Name_String (Id.Language.Config.Include_Path), Data.Include_Path.all); if Opt.Verbosity_Level > Opt.Low then Put (Get_Name_String (Id.Language.Config.Include_Path)); Put (" = "); Put_Line (Data.Include_Path.all); end if; end if; end if; -- But always set the switches if Data.Imported_Dirs_Switches /= null then for J in Data.Imported_Dirs_Switches'Range loop if Data.Imported_Dirs_Switches (J)'Length > 0 then Add_Option_Internal (Value => Data.Imported_Dirs_Switches (J), To => Compilation_Options, Display => Opt.Verbose_Mode); end if; end loop; end if; end Set_Env_For_Include_Dirs; ----------------------------- -- Process_Project_Phase_1 -- ----------------------------- procedure Process_Project_Phase_1 (Source : Queue.Source_Info) is Id : constant Source_Id := Source.Id; Project_Tree : constant Project_Tree_Ref := Source.Tree; Source_Project : constant Project_Id := Ultimate_Extending_Project_Of (Source.Id.Project); Compilation_Needed : Boolean := True; Last_Switches_For_File : Integer; Mapping_File : Path_Name_Type; The_ALI : ALI.ALI_Id; begin if Always_Compile or else not Source_Project.Externally_Built then Need_To_Compile (Source => Source.Id, Tree => Source.Tree, In_Project => Source_Project, Must_Compile => Compilation_Needed, The_ALI => The_ALI, Object_Check => Object_Checked, Always_Compile => Always_Compile); if Compilation_Needed and then Opt.Keep_Going then -- When in Keep_Going mode first check that we did not already -- tried to compile this source as part of another import of -- the corresponding project file. if Bad_Compilations.Contains (Source.Id) then Compilation_Needed := False; end if; end if; if Compilation_Needed or else Opt.Check_Switches then Set_Options_For_File (Source.Id); if Opt.Check_Switches and then not Compilation_Needed then Compilation_Needed := Check_Switches_File (Source.Id); end if; end if; if Compilation_Needed then -- If Distributed_Mode activated, parse Remote package to -- register and initialize the slaves. if Distributed_Mode and then not Slave_Initialized then begin Gprbuild.Compilation.Slave.Register_Remote_Slaves (Project_Tree, Main_Project); Slave_Initialized := True; exception when E : Constraint_Error => Fail_Program (Project_Tree, Exception_Message (E)); end; end if; Update_Object_Path (Source.Id, Source_Project); Change_To_Object_Directory (Source_Project); -- Record the last recorded option index, to be able to -- write the switches file later. if Id.Language.Config.Object_Generated then Last_Switches_For_File := Compilation_Options.Last; else Last_Switches_For_File := -1; end if; Add_Dependency_Options (Id); Set_Env_For_Include_Dirs (Id, Source_Project); Add_Config_File_Switches (Id, Source_Project); Mapping_File := Add_Mapping_File_Switches (Source, Source_Project); Add_Trailing_Switches (Id); Add_Name_Of_Source_Switches (Id); Add_Object_File_Switches (Id); Add_Multi_Unit_Switches (Id); Add_Object_Path_Switches (Id); Spawn_Compiler_And_Register (Source => Source, Source_Project => Source_Project, Compiler_Path => Get_Compiler_Driver_Path (Project_Tree, Id.Language).all, Mapping_File_Path => Mapping_File, Last_Switches_For_File => Last_Switches_For_File); else Print_Compilation_Outputs (Source.Id); if Builder_Data (Source.Tree).Closure_Needed and then (Id.Language.Config.Dependency_Kind = ALI_File or else Id.Language.Config.Dependency_Kind = ALI_Closure) then Record_ALI_For (Source, The_ALI); else ALI.Initialize_ALI; -- ALI.Util.Initialize_ALI_Source; end if; end if; end if; end Process_Project_Phase_1; -------------------------------- -- Must_Exit_Because_Of_Error -- -------------------------------- function Must_Exit_Because_Of_Error return Boolean is use type Containers.Count_Type; Source_Identity : Queue.Source_Info; Compilation_OK : Boolean; Slave : Unbounded_String; Cur : Bad_Compilations_Set.Cursor; OK : Boolean; begin if not Bad_Compilations.Is_Empty and then not Opt.Keep_Going then while Outstanding_Compiles > 0 loop Await_Compile (Source_Identity, Compilation_OK, Slave); if not Compilation_OK then Bad_Compilations.Insert (Source_Identity.Id, To_String (Slave), Cur, OK); end if; end loop; return True; end if; return False; end Must_Exit_Because_Of_Error; ------------------------------- -- Start_Compile_If_Possible -- ------------------------------- procedure Start_Compile_If_Possible is Found : Boolean; Source : Queue.Source_Info; begin if not Queue.Is_Empty and then Outstanding_Compiles < Get_Maximum_Processes then Queue.Extract (Found, Source); if Found then Initialize_Source_Record (Source.Id); Process_Project_Phase_1 (Source); end if; end if; end Start_Compile_If_Possible; ----------------------------- -- Wait_For_Available_Slot -- ----------------------------- procedure Wait_For_Available_Slot is Source_Identity : Queue.Source_Info; Compilation_OK : Boolean; No_Check : Boolean; Slave : Unbounded_String; use Queue; Cur : Bad_Compilations_Set.Cursor; OK : Boolean; begin if Outstanding_Compiles = Get_Maximum_Processes or else (Queue.Is_Virtually_Empty and then Outstanding_Compiles > 0) then Await_Compile (Source_Identity, Compilation_OK, Slave); if Compilation_OK and then Source_Identity /= Queue.No_Source_Info then -- Check if dependencies are on sources in Interfaces and, -- when --direct-import-only is used, the imported sources -- come from directly withed projects. Imports.Reset; Included_Sources.Set_Last (0); case Source_Identity.Id.Language.Config.Dependency_Kind is when None => null; when Makefile => Compilation_OK := Phase_2_Makefile (Source_Identity); when ALI_File | ALI_Closure => Compilation_OK := Phase_2_ALI (Source_Identity); end case; -- If the compilation was invalidated, delete the compilation -- artifacts. if not Compilation_OK then if Source_Identity.Id.Dep_Path /= No_Path then Delete_File (Get_Name_String (Source_Identity.Id.Dep_Path), No_Check); end if; if Source_Identity.Id.Object_Path /= No_Path then Delete_File (Get_Name_String (Source_Identity.Id.Object_Path), No_Check); end if; if Source_Identity.Id.Switches_Path /= No_Path then Delete_File (Get_Name_String (Source_Identity.Id.Switches_Path), No_Check); end if; end if; end if; if not Compilation_OK then Bad_Compilations.Insert (Source_Identity.Id, To_String (Slave), Cur, OK); end if; end if; end Wait_For_Available_Slot; -- Start of processing for Compilation_Phase begin Outstanding_Compiles := 0; -- Then process each files in the queue (new files might be added to -- the queue as a result). Compilation_Loop : while not Queue.Is_Empty or else Outstanding_Compiles > 0 loop exit Compilation_Loop when Must_Exit_Because_Of_Error; Start_Compile_If_Possible; Wait_For_Available_Slot; if Opt.Display_Compilation_Progress then Put_Line ("completed" & Queue.Processed'Img & " out of" & Queue.Size'Img & " (" & Trim (Source => Int (((Queue.Processed) * 100) / Queue.Size)'Img, Side => Ada.Strings.Left) & "%)..."); end if; end loop Compilation_Loop; -- Release local memory declare Data : Local_Project_Data := Local_Projects_HT.Get_First (Local_Projects); begin while Data /= No_Local_Project_Data loop Free (Data.Include_Path); Free (Data.Imported_Dirs_Switches); Data := Local_Projects_HT.Get_Next (Local_Projects); end loop; Local_Projects_HT.Reset (Local_Projects); end; end Compilation_Phase; --------------------- -- Project_Extends -- --------------------- function Project_Extends (Extending : Project_Id; Extended : Project_Id) return Boolean is Current : Project_Id := Extending; begin loop if Current = No_Project then return False; elsif Current = Extended then return True; end if; Current := Current.Extends; end loop; end Project_Extends; end Gprbuild.Compile;
twdroeger/ada-awa
Ada
13,291
adb
----------------------------------------------------------------------- -- events-tests -- Unit tests for AWA events -- Copyright (C) 2012, 2015, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Log.Loggers; with Util.Measures; with Util.Concurrent.Counters; with EL.Beans; with EL.Expressions; with EL.Contexts.Default; with ASF.Applications; with ASF.Servlets.Faces; with AWA.Applications; with AWA.Applications.Configs; with AWA.Applications.Factory; with AWA.Events.Action_Method; with AWA.Services.Contexts; with AWA.Events.Queues; with AWA.Events.Services; package body AWA.Events.Services.Tests is use Util.Log; Log : constant Loggers.Logger := Loggers.Create ("AWA.Events.Tests"); package Event_Test_4 is new AWA.Events.Definition (Name => "event-test-4"); package Event_Test_1 is new AWA.Events.Definition (Name => "event-test-1"); package Event_Test_3 is new AWA.Events.Definition (Name => "event-test-3"); package Event_Test_2 is new AWA.Events.Definition (Name => "event-test-2"); package Event_Test_5 is new AWA.Events.Definition (Name => "event-test-5"); package Caller is new Util.Test_Caller (Test, "Events.Tests"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Events.Get_Event_Name", Test_Get_Event_Name'Access); Caller.Add_Test (Suite, "Test AWA.Events.Find_Event_Index", Test_Find_Event'Access); Caller.Add_Test (Suite, "Test AWA.Events.Initialize", Test_Initialize'Access); Caller.Add_Test (Suite, "Test AWA.Events.Add_Action", Test_Add_Action'Access); Caller.Add_Test (Suite, "Test AWA.Events.Dispatch_Synchronous", Test_Dispatch_Synchronous'Access); Caller.Add_Test (Suite, "Test AWA.Events.Dispatch_Fifo", Test_Dispatch_Fifo'Access); Caller.Add_Test (Suite, "Test AWA.Events.Dispatch_Persist", Test_Dispatch_Persist'Access); Caller.Add_Test (Suite, "Test AWA.Events.Dispatch_Synchronous_Dyn", Test_Dispatch_Synchronous_Dyn'Access); Caller.Add_Test (Suite, "Test AWA.Events.Dispatch_Synchronous_Raise", Test_Dispatch_Synchronous_Raise'Access); end Add_Tests; package Event_Action_Binding is new AWA.Events.Action_Method.Bind (Bean => Action_Bean, Method => Event_Action, Name => "send"); Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Event_Action_Binding.Proxy'Access); -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Action_Bean; Name : in String) return Util.Beans.Objects.Object is pragma Unreferenced (From, Name); begin return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. -- ------------------------------ overriding procedure Set_Value (From : in out Action_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "priority" then From.Priority := Util.Beans.Objects.To_Integer (Value); elsif Name = "raise_exception" then From.Raise_Exception := Util.Beans.Objects.To_Boolean (Value); end if; end Set_Value; overriding function Get_Method_Bindings (From : in Action_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Array'Access; end Get_Method_Bindings; Action_Exception : exception; Global_Counter : Util.Concurrent.Counters.Counter; procedure Event_Action (From : in out Action_Bean; Event : in AWA.Events.Module_Event'Class) is pragma Unreferenced (Event); begin if From.Raise_Exception then raise Action_Exception with "Raising an exception from the event action bean"; end if; From.Count := From.Count + 1; Util.Concurrent.Counters.Increment (Global_Counter); end Event_Action; function Create_Action_Bean return Util.Beans.Basic.Readonly_Bean_Access is Result : constant Action_Bean_Access := new Action_Bean; begin return Result.all'Access; end Create_Action_Bean; -- ------------------------------ -- Test searching an event name in the definition list. -- ------------------------------ procedure Test_Find_Event (T : in out Test) is begin Util.Tests.Assert_Equals (T, Integer (Event_Test_4.Kind), Integer (Find_Event_Index ("event-test-4")), "Find_Event"); Util.Tests.Assert_Equals (T, Integer (Event_Test_5.Kind), Integer (Find_Event_Index ("event-test-5")), "Find_Event"); Util.Tests.Assert_Equals (T, Integer (Event_Test_1.Kind), Integer (Find_Event_Index ("event-test-1")), "Find_Event"); end Test_Find_Event; -- ------------------------------ -- Test the Get_Event_Type_Name internal operation. -- ------------------------------ procedure Test_Get_Event_Name (T : in out Test) is begin Util.Tests.Assert_Equals (T, "event-test-1", Get_Event_Type_Name (Event_Test_1.Kind).all, "Get_Event_Type_Name"); Util.Tests.Assert_Equals (T, "event-test-2", Get_Event_Type_Name (Event_Test_2.Kind).all, "Get_Event_Type_Name"); Util.Tests.Assert_Equals (T, "event-test-3", Get_Event_Type_Name (Event_Test_3.Kind).all, "Get_Event_Type_Name"); Util.Tests.Assert_Equals (T, "event-test-4", Get_Event_Type_Name (Event_Test_4.Kind).all, "Get_Event_Type_Name"); Util.Tests.Assert_Equals (T, "event-test-5", Get_Event_Type_Name (Event_Test_5.Kind).all, "Get_Event_Type_Name"); end Test_Get_Event_Name; -- ------------------------------ -- Test creation and initialization of event manager. -- ------------------------------ procedure Test_Initialize (T : in out Test) is App : constant AWA.Applications.Application_Access := AWA.Tests.Get_Application; Manager : Event_Manager; begin Manager.Initialize (App.all'Access); T.Assert (Manager.Actions /= null, "Initialization failed"); end Test_Initialize; -- ------------------------------ -- Test adding an action. -- ------------------------------ procedure Test_Add_Action (T : in out Test) is App : constant AWA.Applications.Application_Access := AWA.Tests.Get_Application; Manager : Event_Manager; Ctx : EL.Contexts.Default.Default_Context; Action : constant EL.Expressions.Method_Expression := EL.Expressions.Create_Expression ("#{a.send}", Ctx); Props : EL.Beans.Param_Vectors.Vector; Queue : Queue_Ref; Index : constant Event_Index := Find_Event_Index ("event-test-4"); begin Manager.Initialize (App.all'Access); Queue := AWA.Events.Queues.Create_Queue ("test", "fifo", Props, Ctx); Manager.Add_Queue (Queue); for I in 1 .. 10 loop Manager.Add_Action (Event => "event-test-4", Queue => Queue, Action => Action, Params => Props); Util.Tests.Assert_Equals (T, 1, Integer (Manager.Actions (Index).Queues.Length), "Add_Action failed"); end loop; end Test_Add_Action; -- ------------------------------ -- Test dispatching events -- ------------------------------ procedure Dispatch_Event (T : in out Test; Kind : in Event_Index; Expect_Count : in Natural; Expect_Prio : in Natural) is Factory : AWA.Applications.Factory.Application_Factory; Conf : ASF.Applications.Config; Ctx : aliased EL.Contexts.Default.Default_Context; Path : constant String := Util.Tests.Get_Test_Path ("regtests/config/event-test.xml"); Action : aliased Action_Bean; begin Conf.Set ("database", Util.Tests.Get_Parameter ("database")); declare App : aliased AWA.Tests.Test_Application; S : Util.Measures.Stamp; Faces : aliased ASF.Servlets.Faces.Faces_Servlet; SC : AWA.Services.Contexts.Service_Context; begin App.Initialize (Conf => Conf, Factory => Factory); App.Set_Global ("event_test", Util.Beans.Objects.To_Object (Action'Unchecked_Access, Util.Beans.Objects.STATIC)); SC.Set_Context (App'Unchecked_Access, null); App.Add_Servlet (Name => "faces", Server => Faces'Unchecked_Access); App.Register_Class ("AWA.Events.Tests.Event_Action", Create_Action_Bean'Access); AWA.Applications.Configs.Read_Configuration (App => App, File => Path, Context => Ctx'Unchecked_Access, Override_Context => True); Util.Measures.Report (S, "Initialize AWA application and read config"); App.Start; Util.Measures.Report (S, "Start event tasks"); for I in 1 .. 100 loop declare Event : Module_Event; begin Event.Set_Event_Kind (Kind); Event.Set_Parameter ("prio", "3"); Event.Set_Parameter ("template", "def"); App.Send_Event (Event); end; end loop; Util.Measures.Report (S, "Send 100 events"); -- Wait for the dispatcher to process the events but do not wait more than 10 secs. for I in 1 .. 10_000 loop exit when Action.Count = Expect_Count; delay 0.1; end loop; end; Log.Info ("Action count: {0}", Natural'Image (Action.Count)); Log.Info ("Priority: {0}", Integer'Image (Action.Priority)); Util.Tests.Assert_Equals (T, Expect_Count, Action.Count, "invalid number of calls for the action (global bean)"); Util.Tests.Assert_Equals (T, Expect_Prio, Action.Priority, "prio parameter not transmitted (global bean)"); end Dispatch_Event; -- ------------------------------ -- Test dispatching synchronous event to a global bean. -- ------------------------------ procedure Test_Dispatch_Synchronous (T : in out Test) is begin T.Dispatch_Event (Event_Test_1.Kind, 500, 3); end Test_Dispatch_Synchronous; -- ------------------------------ -- Test dispatching event through a fifo queue. -- ------------------------------ procedure Test_Dispatch_Fifo (T : in out Test) is begin T.Dispatch_Event (Event_Test_2.Kind, 200, 3); end Test_Dispatch_Fifo; -- ------------------------------ -- Test dispatching event through a database queue. -- ------------------------------ procedure Test_Dispatch_Persist (T : in out Test) is begin T.Dispatch_Event (Event_Test_5.Kind, 100, 3); end Test_Dispatch_Persist; -- ------------------------------ -- Test dispatching synchronous event to a dynamic bean (created on demand). -- ------------------------------ procedure Test_Dispatch_Synchronous_Dyn (T : in out Test) is begin T.Dispatch_Event (Event_Test_3.Kind, 0, 0); end Test_Dispatch_Synchronous_Dyn; -- ------------------------------ -- Test dispatching synchronous event to a dynamic bean and raise an exception in the action. -- ------------------------------ procedure Test_Dispatch_Synchronous_Raise (T : in out Test) is begin T.Dispatch_Event (Event_Test_4.Kind, 0, 0); end Test_Dispatch_Synchronous_Raise; end AWA.Events.Services.Tests;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Style_Attributes is pragma Preelaborate; type ODF_Style_Style_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Style_Attribute_Access is access all ODF_Style_Style_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Style_Attributes;
dbanetto/uni
Ada
1,026
ads
with common; use common; package Vehicle with Spark_Mode is type Tank is private; function Initialize (capacity : FuelUnit; current : FuelUnit) return Tank with Pre => capacity >= current; function GetCurrent (this : in Tank) return FuelUnit with Global => null; function GetCapacity (this : in Tank) return FuelUnit with Global => null; function IsFull (this : Tank) return Boolean with Post => IsFull'Result = (GetCurrent (this) = GetCapacity (this)); procedure Fill (this : in out Tank; amount : in out FuelUnit) with Global => null, Pre => not IsFull(this), Post => GetCurrent (this) <= GetCapacity (this) and GetCurrent (this) >= GetCurrent (this'Old) and amount <= amount'Old and amount >= 0 and amount = GetCurrent (this) - GetCurrent (this'Old); private type Tank is record capacity : FuelUnit; current : FuelUnit; end record with Predicate => Tank.capacity >= Tank.current; end Vehicle;
fnarenji/BezierToSTL
Ada
1,420
ads
generic type Element is private; package Liste_Generique is type Liste is limited private; -- une liste est initialement vide -- vide L et libere la memoire correspondante procedure Vider(L : in out Liste); -- insere E en tete de L procedure Insertion_Tete(L : in out Liste ; E : Element); -- insere E en queue de L procedure Insertion_Queue(L : in out Liste ; E : Element); -- appelle Traiter sur chaque element de L, dans l'ordre generic with procedure Traiter(E : in out Element); procedure Parcourir(L : Liste); -- si L = [E1 ; E2 ; ... ; En-1 ; En] -- appelle Traiter sur chaque couple (Ei, Ei+1) pour 0 < i < n generic with procedure Traiter(E1, E2 : in Element); procedure Parcourir_Par_Couples(L : Liste); --fusionne L2 a la fin de L1; en sortie L2 est vide procedure Fusion(L1 : in out Liste ; L2 : in out Liste); -- nombre d'éléments de L function Taille(L : Liste) return Natural; -- requiert Taille(L) /= 0 function Tete(L : Liste) return Element; -- requiert Taille(L) /= 0 function Queue(L : Liste) return Element; private type Cellule; type Pointeur is access Cellule; type Cellule is record Contenu : Element; Suivant : Pointeur; end record; type Liste is record Debut, Fin : Pointeur := null; Taille : Natural := 0; end record; end;
reznikmm/matreshka
Ada
3,516
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Holders.Generic_Floats; package League.Holders.Long_Floats is new League.Holders.Generic_Floats (Long_Float); pragma Preelaborate (League.Holders.Long_Floats);
AdaCore/Ada_Drivers_Library
Ada
19,444
ads
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA -- -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without modification, -- are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form, except as embedded into a Nordic -- Semiconductor ASA integrated circuit in a product or a software update for -- such product, 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 Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from this -- software without specific prior written permission. -- -- 4. This software, with or without modification, must only be used with a -- Nordic Semiconductor ASA integrated circuit. -- -- 5. Any software provided in binary form under this license must not be reverse -- engineered, decompiled, modified and/or disassembled. -- -- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS -- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 spec has been automatically generated from nrf52.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF_SVD.PDM is pragma Preelaborate; --------------- -- Registers -- --------------- -- Enable or disable interrupt for STARTED event type INTEN_STARTED_Field is (-- Disable Disabled, -- Enable Enabled) with Size => 1; for INTEN_STARTED_Field use (Disabled => 0, Enabled => 1); -- Enable or disable interrupt for STOPPED event type INTEN_STOPPED_Field is (-- Disable Disabled, -- Enable Enabled) with Size => 1; for INTEN_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Enable or disable interrupt for END event type INTEN_END_Field is (-- Disable Disabled, -- Enable Enabled) with Size => 1; for INTEN_END_Field use (Disabled => 0, Enabled => 1); -- Enable or disable interrupt type INTEN_Register is record -- Enable or disable interrupt for STARTED event STARTED : INTEN_STARTED_Field := NRF_SVD.PDM.Disabled; -- Enable or disable interrupt for STOPPED event STOPPED : INTEN_STOPPED_Field := NRF_SVD.PDM.Disabled; -- Enable or disable interrupt for END event END_k : INTEN_END_Field := NRF_SVD.PDM.Disabled; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTEN_Register use record STARTED at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; END_k at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Write '1' to Enable interrupt for STARTED event type INTENSET_STARTED_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENSET_STARTED_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Enable interrupt for STARTED event type INTENSET_STARTED_Field_1 is (-- Reset value for the field Intenset_Started_Field_Reset, -- Enable Set) with Size => 1; for INTENSET_STARTED_Field_1 use (Intenset_Started_Field_Reset => 0, Set => 1); -- Write '1' to Enable interrupt for STOPPED event type INTENSET_STOPPED_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENSET_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Enable interrupt for STOPPED event type INTENSET_STOPPED_Field_1 is (-- Reset value for the field Intenset_Stopped_Field_Reset, -- Enable Set) with Size => 1; for INTENSET_STOPPED_Field_1 use (Intenset_Stopped_Field_Reset => 0, Set => 1); -- Write '1' to Enable interrupt for END event type INTENSET_END_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENSET_END_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Enable interrupt for END event type INTENSET_END_Field_1 is (-- Reset value for the field Intenset_End_Field_Reset, -- Enable Set) with Size => 1; for INTENSET_END_Field_1 use (Intenset_End_Field_Reset => 0, Set => 1); -- Enable interrupt type INTENSET_Register is record -- Write '1' to Enable interrupt for STARTED event STARTED : INTENSET_STARTED_Field_1 := Intenset_Started_Field_Reset; -- Write '1' to Enable interrupt for STOPPED event STOPPED : INTENSET_STOPPED_Field_1 := Intenset_Stopped_Field_Reset; -- Write '1' to Enable interrupt for END event END_k : INTENSET_END_Field_1 := Intenset_End_Field_Reset; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENSET_Register use record STARTED at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; END_k at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Write '1' to Disable interrupt for STARTED event type INTENCLR_STARTED_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENCLR_STARTED_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Disable interrupt for STARTED event type INTENCLR_STARTED_Field_1 is (-- Reset value for the field Intenclr_Started_Field_Reset, -- Disable Clear) with Size => 1; for INTENCLR_STARTED_Field_1 use (Intenclr_Started_Field_Reset => 0, Clear => 1); -- Write '1' to Disable interrupt for STOPPED event type INTENCLR_STOPPED_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENCLR_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Disable interrupt for STOPPED event type INTENCLR_STOPPED_Field_1 is (-- Reset value for the field Intenclr_Stopped_Field_Reset, -- Disable Clear) with Size => 1; for INTENCLR_STOPPED_Field_1 use (Intenclr_Stopped_Field_Reset => 0, Clear => 1); -- Write '1' to Disable interrupt for END event type INTENCLR_END_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENCLR_END_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Disable interrupt for END event type INTENCLR_END_Field_1 is (-- Reset value for the field Intenclr_End_Field_Reset, -- Disable Clear) with Size => 1; for INTENCLR_END_Field_1 use (Intenclr_End_Field_Reset => 0, Clear => 1); -- Disable interrupt type INTENCLR_Register is record -- Write '1' to Disable interrupt for STARTED event STARTED : INTENCLR_STARTED_Field_1 := Intenclr_Started_Field_Reset; -- Write '1' to Disable interrupt for STOPPED event STOPPED : INTENCLR_STOPPED_Field_1 := Intenclr_Stopped_Field_Reset; -- Write '1' to Disable interrupt for END event END_k : INTENCLR_END_Field_1 := Intenclr_End_Field_Reset; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENCLR_Register use record STARTED at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; END_k at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Enable or disable PDM module type ENABLE_ENABLE_Field is (-- Disable Disabled, -- Enable Enabled) with Size => 1; for ENABLE_ENABLE_Field use (Disabled => 0, Enabled => 1); -- PDM module enable register type ENABLE_Register is record -- Enable or disable PDM module ENABLE : ENABLE_ENABLE_Field := NRF_SVD.PDM.Disabled; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ENABLE_Register use record ENABLE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Mono or stereo operation type MODE_OPERATION_Field is (-- Sample and store one pair (Left + Right) of 16bit samples per RAM word -- R=[31:16]; L=[15:0] Stereo, -- Sample and store two successive Left samples (16 bit each) per RAM word -- L1=[31:16]; L0=[15:0] Mono) with Size => 1; for MODE_OPERATION_Field use (Stereo => 0, Mono => 1); -- Defines on which PDM_CLK edge Left (or mono) is sampled type MODE_EDGE_Field is (-- Left (or mono) is sampled on falling edge of PDM_CLK Leftfalling, -- Left (or mono) is sampled on rising edge of PDM_CLK Leftrising) with Size => 1; for MODE_EDGE_Field use (Leftfalling => 0, Leftrising => 1); -- Defines the routing of the connected PDM microphones' signals type MODE_Register is record -- Mono or stereo operation OPERATION : MODE_OPERATION_Field := NRF_SVD.PDM.Stereo; -- Defines on which PDM_CLK edge Left (or mono) is sampled EDGE : MODE_EDGE_Field := NRF_SVD.PDM.Leftfalling; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MODE_Register use record OPERATION at 0 range 0 .. 0; EDGE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- Left output gain adjustment, in 0.5 dB steps, around the default module -- gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -19.5 dB -- gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain adjust 0x29 -- +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 +20 dB gain -- adjust type GAINL_GAINL_Field is (-- -20dB gain adjustment (minimum) Mingain, -- 0dB gain adjustment ('2500 RMS' requirement) Defaultgain, -- +20dB gain adjustment (maximum) Maxgain) with Size => 7; for GAINL_GAINL_Field use (Mingain => 0, Defaultgain => 40, Maxgain => 80); -- Left output gain adjustment type GAINL_Register is record -- Left output gain adjustment, in 0.5 dB steps, around the default -- module gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -- -19.5 dB gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain -- adjust 0x29 +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 -- +20 dB gain adjust GAINL : GAINL_GAINL_Field := NRF_SVD.PDM.Defaultgain; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for GAINL_Register use record GAINL at 0 range 0 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Right output gain adjustment, in 0.5 dB steps, around the default module -- gain (see electrical parameters) type GAINR_GAINR_Field is (-- -20dB gain adjustment (minimum) Mingain, -- 0dB gain adjustment ('2500 RMS' requirement) Defaultgain, -- +20dB gain adjustment (maximum) Maxgain) with Size => 8; for GAINR_GAINR_Field use (Mingain => 0, Defaultgain => 40, Maxgain => 80); -- Right output gain adjustment type GAINR_Register is record -- Right output gain adjustment, in 0.5 dB steps, around the default -- module gain (see electrical parameters) GAINR : GAINR_GAINR_Field := NRF_SVD.PDM.Defaultgain; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for GAINR_Register use record GAINR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ------------------------------ -- PSEL cluster's Registers -- ------------------------------ subtype CLK_PSEL_PIN_Field is HAL.UInt5; -- Connection type CLK_CONNECT_Field is (-- Connect Connected, -- Disconnect Disconnected) with Size => 1; for CLK_CONNECT_Field use (Connected => 0, Disconnected => 1); -- Pin number configuration for PDM CLK signal type CLK_PSEL_Register is record -- Pin number PIN : CLK_PSEL_PIN_Field := 16#1F#; -- unspecified Reserved_5_30 : HAL.UInt26 := 16#3FFFFFF#; -- Connection CONNECT : CLK_CONNECT_Field := NRF_SVD.PDM.Disconnected; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CLK_PSEL_Register use record PIN at 0 range 0 .. 4; Reserved_5_30 at 0 range 5 .. 30; CONNECT at 0 range 31 .. 31; end record; subtype DIN_PSEL_PIN_Field is HAL.UInt5; -- Connection type DIN_CONNECT_Field is (-- Connect Connected, -- Disconnect Disconnected) with Size => 1; for DIN_CONNECT_Field use (Connected => 0, Disconnected => 1); -- Pin number configuration for PDM DIN signal type DIN_PSEL_Register is record -- Pin number PIN : DIN_PSEL_PIN_Field := 16#1F#; -- unspecified Reserved_5_30 : HAL.UInt26 := 16#3FFFFFF#; -- Connection CONNECT : DIN_CONNECT_Field := NRF_SVD.PDM.Disconnected; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DIN_PSEL_Register use record PIN at 0 range 0 .. 4; Reserved_5_30 at 0 range 5 .. 30; CONNECT at 0 range 31 .. 31; end record; -- Unspecified type PSEL_Cluster is record -- Pin number configuration for PDM CLK signal CLK : aliased CLK_PSEL_Register; -- Pin number configuration for PDM DIN signal DIN : aliased DIN_PSEL_Register; end record with Size => 64; for PSEL_Cluster use record CLK at 16#0# range 0 .. 31; DIN at 16#4# range 0 .. 31; end record; -------------------------------- -- SAMPLE cluster's Registers -- -------------------------------- subtype MAXCNT_SAMPLE_BUFFSIZE_Field is HAL.UInt15; -- Number of samples to allocate memory for in EasyDMA mode type MAXCNT_SAMPLE_Register is record -- Length of DMA RAM allocation in number of samples BUFFSIZE : MAXCNT_SAMPLE_BUFFSIZE_Field := 16#0#; -- unspecified Reserved_15_31 : HAL.UInt17 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MAXCNT_SAMPLE_Register use record BUFFSIZE at 0 range 0 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; -- Unspecified type SAMPLE_Cluster is record -- RAM address pointer to write samples to with EasyDMA PTR : aliased HAL.UInt32; -- Number of samples to allocate memory for in EasyDMA mode MAXCNT : aliased MAXCNT_SAMPLE_Register; end record with Size => 64; for SAMPLE_Cluster use record PTR at 16#0# range 0 .. 31; MAXCNT at 16#4# range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Pulse Density Modulation (Digital Microphone) Interface type PDM_Peripheral is record -- Starts continuous PDM transfer TASKS_START : aliased HAL.UInt32; -- Stops PDM transfer TASKS_STOP : aliased HAL.UInt32; -- PDM transfer has started EVENTS_STARTED : aliased HAL.UInt32; -- PDM transfer has finished EVENTS_STOPPED : aliased HAL.UInt32; -- The PDM has written the last sample specified by SAMPLE.MAXCNT (or -- the last sample after a STOP task has been received) to Data RAM EVENTS_END : aliased HAL.UInt32; -- Enable or disable interrupt INTEN : aliased INTEN_Register; -- Enable interrupt INTENSET : aliased INTENSET_Register; -- Disable interrupt INTENCLR : aliased INTENCLR_Register; -- PDM module enable register ENABLE : aliased ENABLE_Register; -- PDM clock generator control PDMCLKCTRL : aliased HAL.UInt32; -- Defines the routing of the connected PDM microphones' signals MODE : aliased MODE_Register; -- Left output gain adjustment GAINL : aliased GAINL_Register; -- Right output gain adjustment GAINR : aliased GAINR_Register; -- Unspecified PSEL : aliased PSEL_Cluster; -- Unspecified SAMPLE : aliased SAMPLE_Cluster; end record with Volatile; for PDM_Peripheral use record TASKS_START at 16#0# range 0 .. 31; TASKS_STOP at 16#4# range 0 .. 31; EVENTS_STARTED at 16#100# range 0 .. 31; EVENTS_STOPPED at 16#104# range 0 .. 31; EVENTS_END at 16#108# range 0 .. 31; INTEN at 16#300# range 0 .. 31; INTENSET at 16#304# range 0 .. 31; INTENCLR at 16#308# range 0 .. 31; ENABLE at 16#500# range 0 .. 31; PDMCLKCTRL at 16#504# range 0 .. 31; MODE at 16#508# range 0 .. 31; GAINL at 16#518# range 0 .. 31; GAINR at 16#51C# range 0 .. 31; PSEL at 16#540# range 0 .. 63; SAMPLE at 16#560# range 0 .. 63; end record; -- Pulse Density Modulation (Digital Microphone) Interface PDM_Periph : aliased PDM_Peripheral with Import, Address => PDM_Base; end NRF_SVD.PDM;
jrcarter/Ada_GUI
Ada
10,607
adb
-- -- -- package Strings_Edit.UTF8 Copyright (c) Dmitry A. Kazakov -- -- Implementation Luebeck -- -- Spring, 2005 -- -- -- -- Last revision : 22:44 07 Apr 2016 -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public License as -- -- published by the Free Software Foundation; either version 2 of -- -- the License, or (at your option) any later version. This library -- -- is distributed in the hope that it will be useful, but WITHOUT -- -- ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have -- -- received a copy of the GNU General Public License along with -- -- this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- --____________________________________________________________________-- with Ada.IO_Exceptions; use Ada.IO_Exceptions; package body Strings_Edit.UTF8 is procedure Get ( Source : String; Pointer : in out Integer; Value : out UTF8_Code_Point ) is Accum : UTF8_Code_Point'Base; Code : UTF8_Code_Point'Base; Index : Integer := Pointer; Last : Boolean := False; begin if Index < Source'First then raise Layout_Error; end if; if Index > Source'Last then if Index = Source'Last + 1 then raise End_Error; else raise Layout_Error; end if; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); case Code is when 0..16#7F# => -- 1 byte (ASCII) Value := Code; Pointer := Index + 1; return; when 16#C2#..16#DF# => -- 2 bytes Accum := (Code and 16#1F#) * 2**6; Last := True; when 16#E0# => -- 3 bytes Index := Index + 1; if Index >= Source'Last then raise Data_Error; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); if Code not in 16#A0#..16#BF# then raise Data_Error; end if; Accum := (Code and 16#3F#) * 2**6; Last := True; when 16#E1#..16#EF# => -- 3 bytes Accum := (Code and 16#0F#) * 2**12; when 16#F0# => -- 4 bytes Index := Index + 1; if Index >= Source'Last then raise Data_Error; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); if Code not in 16#90#..16#BF# then raise Data_Error; end if; Accum := (Code and 16#3F#) * 2**12; when 16#F1#..16#F3# => -- 4 bytes Accum := (Code and 16#07#) * 2**18; Index := Index + 1; if Index >= Source'Last then raise Data_Error; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); if Code not in 16#80#..16#BF# then raise Data_Error; end if; Accum := Accum or (Code and 16#3F#) * 2**12; when 16#F4# => -- 4 bytes Accum := (Code and 16#07#) * 2**18; Index := Index + 1; if Index >= Source'Last then raise Data_Error; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); if Code not in 16#80#..16#8F# then raise Data_Error; end if; Accum := Accum or (Code and 16#3F#) * 2**12; when others => raise Data_Error; end case; if not Last then Index := Index + 1; if Index >= Source'Last then raise Data_Error; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); if Code not in 16#80#..16#BF# then raise Data_Error; end if; Accum := Accum or (Code and 16#3F#) * 2**6; end if; Index := Index + 1; if Index > Source'Last then raise Data_Error; end if; Code := UTF8_Code_Point (Character'Pos (Source (Index))); if Code not in 16#80#..16#BF# then raise Data_Error; end if; Value := Accum or (Code and 16#3F#); Pointer := Index + 1; end Get; procedure Get_Backwards ( Source : String; Pointer : in out Integer; Value : out UTF8_Code_Point ) is First : Integer := Pointer; Last : Integer; Result : UTF8_Code_Point; begin if First <= Source'First then if First < Source'First then raise Layout_Error; else raise End_Error; end if; end if; if First > Source'Last + 1 then raise Layout_Error; end if; loop First := First - 1; exit when Character'Pos (Source (First)) not in 16#80#..16#BF#; if First = Source'First then raise Data_Error; end if; end loop; Last := First; Get (Source, Last, Result); if Last /= Pointer then raise Data_Error; end if; Pointer := First; Value := Result; end Get_Backwards; function Image (Value : UTF8_Code_Point) return String is Result : String (1..4); Pointer : Integer := Result'First; begin Put (Result, Pointer, Value); return Result (1..Pointer - 1); end Image; function Length (Source : String) return Natural is Count : Natural := 0; Accum : UTF8_Code_Point; Index : Integer := Source'First; begin while Index <= Source'Last loop Get (Source, Index, Accum); Count := Count + 1; end loop; return Count; end Length; procedure Put ( Destination : in out String; Pointer : in out Integer; Value : UTF8_Code_Point ) is begin if Pointer not in Destination'Range then raise Layout_Error; end if; if Value <= 16#7F# then Destination (Pointer) := Character'Val (Value); Pointer := Pointer + 1; elsif Value <= 16#7FF# then if Pointer >= Destination'Last then raise Layout_Error; end if; Destination (Pointer) := Character'Val (16#C0# or Value / 2**6); Destination (Pointer + 1) := Character'Val (16#80# or (Value and 16#3F#)); Pointer := Pointer + 2; elsif Value <= 16#FFFF# then if 1 >= Destination'Last - Pointer then raise Layout_Error; end if; Destination (Pointer) := Character'Val (16#E0# or Value / 2**12); Destination (Pointer + 1) := Character'Val (16#80# or (Value / 2**6 and 16#3F#)); Destination (Pointer + 2) := Character'Val (16#80# or (Value and 16#3F#)); Pointer := Pointer + 3; else if 2 >= Destination'Last - Pointer then raise Layout_Error; end if; Destination (Pointer) := Character'Val (16#F0# or Value / 2**18); Destination (Pointer + 1) := Character'Val (16#80# or (Value / 2**12 and 16#3F#)); Destination (Pointer + 2) := Character'Val (16#80# or (Value / 2**6 and 16#3F#)); Destination (Pointer + 3) := Character'Val (16#80# or (Value and 16#3F#)); Pointer := Pointer + 4; end if; end Put; procedure Reverse_Put ( Destination : in out String; Pointer : in out Integer; Prefix : String; Position : Natural ) is begin if ( Pointer not in Destination'Range or else Pointer - Destination'First < Prefix'Length ) then raise Layout_Error; end if; Destination (Pointer) := Character'Val (Position); Pointer := Pointer - 1; for Index in reverse Prefix'Range loop Destination (Pointer) := Prefix (Index); Pointer := Pointer - 1; end loop; end Reverse_Put; procedure Skip ( Source : String; Pointer : in out Integer; Count : Natural := 1 ) is begin if Count > 0 then declare Accum : UTF8_Code_Point; Index : Integer := Pointer; begin for Character in 1..Count loop Get (Source, Index, Accum); end loop; Pointer := Index; end; elsif ( Pointer < Source'First or else ( Pointer > Source'Last and then Pointer - 1 > Source'Last ) ) then raise Layout_Error; end if; end Skip; function Value (Source : String) return UTF8_Code_Point is Pointer : Integer := Source'First; Result : UTF8_Code_Point; begin Get (Source, Pointer, Result); if Pointer /= Source'Last + 1 then raise Data_Error; end if; return Result; end Value; end Strings_Edit.UTF8;
charlie5/lace
Ada
200
adb
package body opengl.Surface.privvy is function to_eGL (Self : in Surface.item'Class) return egl.EGLSurface is begin return Self.egl_Surface; end to_eGL; end opengl.Surface.privvy;
zhmu/ananas
Ada
299
adb
-- { dg-do run } -- { dg-options "-O -gnatws" } procedure Discr47 is type Rec (D : Boolean := False) is record case D is when True => null; when False => C : Character; end case; end record; R : Rec; begin if R'Size /= 16 then raise Program_Error; end if; end;
zhmu/ananas
Ada
2,944
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- A D A . R E A L _ T I M E . D E L A Y S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, 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. -- -- -- ------------------------------------------------------------------------------ -- Implements Real_Time.Time absolute delays -- Note: the compiler generates direct calls to this interface, in the -- processing of time types. package Ada.Real_Time.Delays is function To_Duration (T : Real_Time.Time) return Duration; -- Convert Time to Duration procedure Delay_Until (T : Time); -- Delay until Clock has reached (at least) time T, -- or the task is aborted to at least the current ATC nesting level. -- The body of this procedure must perform all the processing -- required for an abort point. end Ada.Real_Time.Delays;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
434
adb
with STM32GD.EXTI; use STM32GD.EXTI; with STM32_SVD.RTC; use STM32_SVD.RTC; package body RTC_IRQ is protected body Handler is procedure IRQ_Handler is begin RTC_Periph.ISR.ALRAF := 0; if External_Interrupt_Pending (EXTI_Line_17) then Set_True (Alarm_Occurred); Clear_External_Interrupt (EXTI_Line_17); end if; end IRQ_Handler; end Handler; end RTC_IRQ;
stcarrez/ada-css
Ada
469
ads
package CSS.Analysis.Parser.Parser_Tokens is subtype yystype is CSS.Analysis.Parser.YYstype; YYLVal, YYVal : YYSType; type Token is (END_OF_INPUT, ERROR, R_PROPERTY, R_DEF_NAME, R_IDENT, R_NAME, R_DEFINE, R_FOLLOW, R_ANY, R_NUM, '(', ')', '{', '}', '[', ']', '=', '|', '!', '?', '#', '+', '*', ',', '/', S); Syntax_Error : exception; end CSS.Analysis.Parser.Parser_Tokens;
reznikmm/matreshka
Ada
4,711
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Combine_Entries_With_Pp_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Combine_Entries_With_Pp_Attribute_Node is begin return Self : Text_Combine_Entries_With_Pp_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Combine_Entries_With_Pp_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Combine_Entries_With_Pp_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Combine_Entries_With_Pp_Attribute, Text_Combine_Entries_With_Pp_Attribute_Node'Tag); end Matreshka.ODF_Text.Combine_Entries_With_Pp_Attributes;
reznikmm/matreshka
Ada
11,505
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.DC; with AMF.DG.Clip_Paths; with AMF.DG.Groups; with AMF.DG.Markers; with AMF.DG.Styles.Collections; with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.DD_Attributes; with AMF.Visitors.DG_Iterators; with AMF.Visitors.DG_Visitors; package body AMF.Internals.DG_Polylines is --------------- -- Get_Point -- --------------- overriding function Get_Point (Self : not null access constant DG_Polyline_Proxy) return AMF.DC.Sequence_Of_DC_Point is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Point (Self.Element); end Get_Point; ---------------------- -- Get_Start_Marker -- ---------------------- overriding function Get_Start_Marker (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Markers.DG_Marker_Access is begin return AMF.DG.Markers.DG_Marker_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Start_Marker (Self.Element))); end Get_Start_Marker; ---------------------- -- Set_Start_Marker -- ---------------------- overriding procedure Set_Start_Marker (Self : not null access DG_Polyline_Proxy; To : AMF.DG.Markers.DG_Marker_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Start_Marker (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Start_Marker; -------------------- -- Get_End_Marker -- -------------------- overriding function Get_End_Marker (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Markers.DG_Marker_Access is begin return AMF.DG.Markers.DG_Marker_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_End_Marker (Self.Element))); end Get_End_Marker; -------------------- -- Set_End_Marker -- -------------------- overriding procedure Set_End_Marker (Self : not null access DG_Polyline_Proxy; To : AMF.DG.Markers.DG_Marker_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_End_Marker (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_End_Marker; -------------------- -- Get_Mid_Marker -- -------------------- overriding function Get_Mid_Marker (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Markers.DG_Marker_Access is begin return AMF.DG.Markers.DG_Marker_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Mid_Marker (Self.Element))); end Get_Mid_Marker; -------------------- -- Set_Mid_Marker -- -------------------- overriding procedure Set_Mid_Marker (Self : not null access DG_Polyline_Proxy; To : AMF.DG.Markers.DG_Marker_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Mid_Marker (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Mid_Marker; --------------- -- Get_Group -- --------------- overriding function Get_Group (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Groups.DG_Group_Access is begin return AMF.DG.Groups.DG_Group_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Group (Self.Element))); end Get_Group; --------------- -- Set_Group -- --------------- overriding procedure Set_Group (Self : not null access DG_Polyline_Proxy; To : AMF.DG.Groups.DG_Group_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Group (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Group; --------------------- -- Get_Local_Style -- --------------------- overriding function Get_Local_Style (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is begin return AMF.DG.Styles.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.DD_Attributes.Internal_Get_Local_Style (Self.Element))); end Get_Local_Style; ---------------------- -- Get_Shared_Style -- ---------------------- overriding function Get_Shared_Style (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is begin return AMF.DG.Styles.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.DD_Attributes.Internal_Get_Shared_Style (Self.Element))); end Get_Shared_Style; ------------------- -- Get_Transform -- ------------------- overriding function Get_Transform (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Sequence_Of_DG_Transform is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Transform (Self.Element); end Get_Transform; ------------------- -- Get_Clip_Path -- ------------------- overriding function Get_Clip_Path (Self : not null access constant DG_Polyline_Proxy) return AMF.DG.Clip_Paths.DG_Clip_Path_Access is begin return AMF.DG.Clip_Paths.DG_Clip_Path_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Clip_Path (Self.Element))); end Get_Clip_Path; ------------------- -- Set_Clip_Path -- ------------------- overriding procedure Set_Clip_Path (Self : not null access DG_Polyline_Proxy; To : AMF.DG.Clip_Paths.DG_Clip_Path_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Clip_Path (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Clip_Path; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant DG_Polyline_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then AMF.Visitors.DG_Visitors.DG_Visitor'Class (Visitor).Enter_Polyline (AMF.DG.Polylines.DG_Polyline_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant DG_Polyline_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then AMF.Visitors.DG_Visitors.DG_Visitor'Class (Visitor).Leave_Polyline (AMF.DG.Polylines.DG_Polyline_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant DG_Polyline_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.DG_Iterators.DG_Iterator'Class then AMF.Visitors.DG_Iterators.DG_Iterator'Class (Iterator).Visit_Polyline (Visitor, AMF.DG.Polylines.DG_Polyline_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.DG_Polylines;
stcarrez/babel
Ada
2,968
ads
----------------------------------------------------------------------- -- babel-Streams-xz -- XZ/LZMA stream management -- Copyright (C) 2014, 2015 Stephane.Carrez -- Written by Stephane.Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- private with Lzma.Base; -- == Compression and Decompression Stream == -- The <tt>Babel.Streams.XZ</tt> package provides a compression decompression stream on top -- of the <tt>LZMA</tt> library. package Babel.Streams.XZ is type Stream_Type is new Babel.Streams.Stream_Type with private; type Stream_Access is access all Stream_Type'Class; -- Set the input stream to decompress. procedure Set_Input (Stream : in out Stream_Type; Input : in Babel.Streams.Stream_Access); -- Set the output stream to write the compressed stream. procedure Set_Output (Stream : in out Stream_Type; Output : in Babel.Streams.Stream_Access); -- Read the data stream as much as possible and return the result in a buffer. -- The buffer is owned by the stream and need not be released. The same buffer may -- or may not be returned by the next <tt>Read</tt> operation. -- A null buffer is returned when the end of the data stream is reached. overriding procedure Read (Stream : in out Stream_Type; Buffer : out Babel.Files.Buffers.Buffer_Access); -- Write the buffer in the data stream. overriding procedure Write (Stream : in out Stream_Type; Buffer : in Babel.Files.Buffers.Buffer_Access); -- Flush the data stream. overriding procedure Flush (Stream : in out Stream_Type); -- Close the data stream. overriding procedure Close (Stream : in out Stream_Type); -- Prepare to read again the data stream from the beginning. overriding procedure Rewind (Stream : in out Stream_Type); private type Stream_Type is new Babel.Streams.Stream_Type with record Input : Babel.Streams.Stream_Access; Output : Babel.Streams.Stream_Access; Context : aliased Lzma.Base.lzma_stream := Lzma.Base.LZMA_STREAM_INIT; Action : Lzma.Base.lzma_action := Lzma.Base.LZMA_RUN; end record; -- Release the stream buffer and the LZMA stream. overriding procedure Finalize (Stream : in out Stream_Type); end Babel.Streams.XZ;
reznikmm/matreshka
Ada
4,717
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Print_Date_Elements; package Matreshka.ODF_Text.Print_Date_Elements is type Text_Print_Date_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Print_Date_Elements.ODF_Text_Print_Date with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Print_Date_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Print_Date_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Print_Date_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Print_Date_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Print_Date_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Print_Date_Elements;
damaki/libkeccak
Ada
10,400
ads
------------------------------------------------------------------------------- -- 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_CSHAKE; with Keccak.Generic_XOF; with Keccak.Generic_Parallel_XOF; with Keccak.Types; -- @summary -- Generic implementation of the ParallelHash algorithm as defined in NIST SP 800-185. -- -- @description -- The purpose of ParallelHash10 is to support the efficient hashing of very long -- strings, by taking advantage of the parallelism available in modern processors. -- ParallelHash provides variable-length output. Changing any input parameter to -- ParallelHash, even the requested output length, will result in unrelated output. -- Like the other functions defined in this document, ParallelHash also supports -- user-selected customization strings. -- -- The block size defines the size of each input block that is processed in parallel. -- It can be any positive value up to Block_Size_Number'Last / 8. Since Block_Size_Number -- is defined as a subtype of Positive, this guaranteeds the maximum block size to -- be at least 4095 bytes when Integer is at least a 16-bit signed type. On most systems -- is likely to be at least 268_435_455 bytes (256 MiB - 1 B) when Integer is a -- 32-bit signed type. -- -- This API is used as follows: -- -- 1 Call Init to initialise a new context. The block size and an optional -- customisation string (for domain separation) are provided here. -- -- 2 Call Update one or more times to input an arbitrary amount of data into -- the ParallelHash context. -- -- 3 Call either Finish or Extract to produce the desired type of output -- (ParallelHash or ParallelHashXOF): -- -- * Finish is used to produce a single output of arbitrary length (ParallelHash). -- The requested output length affects the output. For example, requesting -- a 10-byte output will produce an unrelated hash to requesting a 20-byte -- output. -- -- * Extract can be called one or more times to produce an arbitrary number -- of output bytes (ParallelHashXOF). In this case, the total output length is -- unknown in advance so the output does not change based on the overall length. -- For example, a 10-byte output is the truncated version of a 20-byte output. -- -- @group ParallelHash generic CV_Size_Bytes : Positive; -- Length of the Chaining Values, in bytes. with package CSHAKE_Serial is new Keccak.Generic_CSHAKE (<>); -- This CSHAKE must be configured with NO SUFFIX BITS. -- The Generic_KangarooTwelve implementation takes care of the appropriate -- suffix bits when using this CSHAKE_Serial. with package SHAKE_Serial is new Keccak.Generic_XOF (<>); with package SHAKE_Parallel_2 is new Keccak.Generic_Parallel_XOF (<>); -- This CSHAKE must be configured to add the 3 suffix bits 2#011#. with package SHAKE_Parallel_4 is new Keccak.Generic_Parallel_XOF (<>); -- This CSHAKE must be configured to add the 3 suffix bits 2#011#. with package SHAKE_Parallel_8 is new Keccak.Generic_Parallel_XOF (<>); -- This CSHAKE must be configured to add the 3 suffix bits 2#011#. package Keccak.Generic_Parallel_Hash is -- Assertions to check that the correct parallel instances have -- been provided. pragma Assert (SHAKE_Parallel_2.Num_Parallel_Instances = 2); pragma Assert (SHAKE_Parallel_4.Num_Parallel_Instances = 4); pragma Assert (SHAKE_Parallel_8.Num_Parallel_Instances = 8); type Context is private; type States is (Updating, Extracting, Finished); -- @value Updating When in this state additional data can be input into the -- ParallelHash context. -- -- @value Extracting When in this state, the ParallelHash context can generate -- output bytes by calling the Extract procedure. -- -- @value Finished When in this state the context is finished and no more data -- can be input or output. type Byte_Count is new Long_Long_Integer range 0 .. Long_Long_Integer'Last; subtype Block_Size_Number is Positive range 1 .. Positive'Last / 8; procedure Init (Ctx : out Context; Block_Size : in Block_Size_Number; Customization : in String) with Global => null, Post => State_Of (Ctx) = Updating; -- Initialise the ParallelHash instance. -- -- @param Ctx The context to initialise. -- -- @param Block_Size The block size in bytes for parallel hashing. procedure Update (Ctx : in out Context; Data : in Types.Byte_Array) with Global => null, Pre => (State_Of (Ctx) = Updating and Byte_Count (Data'Length) <= Max_Input_Length (Ctx)), Post => (State_Of (Ctx) = Updating and Num_Bytes_Processed (Ctx) = Num_Bytes_Processed (Ctx'Old) + Byte_Count (Data'Length)); -- Process input bytes with ParallelHash. -- -- This procedure is most efficient when the input Data buffer is -- at least 8 times larger than the ParallelHash block size. -- -- This may be called multiple times to process a large amount of data. -- -- Note that there is an overall limit to the maximum amount of data that -- can be processed with ParallelHash. The maximum input size is returned -- by calling the Max_Input_Length function. -- -- @param Ctx The context to update with new input data. -- -- @param Data The data to process with ParallelHash. procedure Finish (Ctx : in out Context; Data : out Types.Byte_Array) with Global => null, Pre => State_Of (Ctx) = Updating, Post => State_Of (Ctx) = Finished; -- Extract a fixed number of output bytes. -- -- This procedure finalizes the ParallelHash and outputs a fixed number -- of output bytes. The ParallelHash parameter L is the requested output -- length, and is determined by the length of the @Data@ array. -- I.e. Data'Length is used as the ParallelHash parameter L. -- -- After calling this procedure the ParallelHash instance cannot be used -- further. procedure Extract (Ctx : in out Context; Data : out Types.Byte_Array) with Global => null, Pre => State_Of (Ctx) in Updating | Extracting, Post => State_Of (Ctx) = Extracting; -- Extract an arbitrary number of output bytes. -- -- This procedure finalizes the ParallelHash and puts it into XOF mode -- where an arbitary number of bytes can be output. When this parameter -- is called for the first time after inputting data, the value 0 is used -- as the ParallelHash parameter L. -- -- This procedure can be called multiple times to produce any output length. function State_Of (Ctx : in Context) return States with Global => null; function Num_Bytes_Processed (Ctx : in Context) return Byte_Count with Global => null; -- Get the total number of bytes that have been input to the ParllelHash -- instance so far. -- -- This restricts the maximum permitted input length to a maximum of -- Byte_Count'Last bytes. function Max_Input_Length (Ctx : in Context) return Byte_Count with Global => null; -- Gets the maximum number of bytes that may be input into the ParallelHash context. -- -- This value decreases as the context is updated with additional input data. function Block_Size_Of (Ctx : in Context) return Block_Size_Number with Global => null; -- Get the configured block size parameter of the ParallelHash instance. private use type CSHAKE_Serial.States; use type SHAKE_Serial.States; type Context is record Outer_CSHAKE : CSHAKE_Serial.Context; Partial_Block_CSHAKE : SHAKE_Serial.Context; Input_Len : Byte_Count; Block_Size : Block_Size_Number; Partial_Block_Length : Natural; Finished : Boolean; end record with Predicate => Context.Partial_Block_Length < Context.Block_Size; function State_Of (Ctx : in Context) return States is (if (Ctx.Finished or SHAKE_Serial.State_Of (Ctx.Partial_Block_CSHAKE) /= SHAKE_Serial.Updating or CSHAKE_Serial.State_Of (Ctx.Outer_CSHAKE) = CSHAKE_Serial.Ready_To_Extract) then Finished elsif CSHAKE_Serial.State_Of (Ctx.Outer_CSHAKE) = CSHAKE_Serial.Updating then Updating else Extracting); function Num_Bytes_Processed (Ctx : in Context) return Byte_Count is (Ctx.Input_Len); function Max_Input_Length (Ctx : in Context) return Byte_Count is (Byte_Count'Last - Num_Bytes_Processed (Ctx)); function Block_Size_Of (Ctx : in Context) return Block_Size_Number is (Ctx.Block_Size); end Keccak.Generic_Parallel_Hash;
reznikmm/matreshka
Ada
3,704
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Form_Disabled_Attributes is pragma Preelaborate; type ODF_Form_Disabled_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Disabled_Attribute_Access is access all ODF_Form_Disabled_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Disabled_Attributes;
jrmarino/AdaBase
Ada
976
adb
with AdaBase; with Connect; with Ada.Text_IO; procedure Fruit2 is package CON renames Connect; package TIO renames Ada.Text_IO; numrows : AdaBase.Affected_Rows; -- Intentionally broken UPDATE command (calories misspelled) cmd : constant String := "UPDATE fruits set caloriesx = 14 " & "WHERE fruit = 'strawberry'"; begin CON.connect_database; CON.DR.set_trait_error_mode (trait => AdaBase.raise_exception); TIO.Put_Line ("SQL: " & cmd); declare begin numrows := CON.DR.execute (sql => cmd); TIO.Put_Line ("Result: Updated" & numrows'Img & " rows"); CON.DR.rollback; exception when others => TIO.Put_Line ("Error!"); TIO.Put_Line ("Driver message: " & CON.DR.last_driver_message); TIO.Put_Line (" Driver code: " & CON.DR.last_driver_code'Img); TIO.Put_Line (" SQL State: " & CON.DR.last_sql_state); end; CON.DR.disconnect; end Fruit2;
zhmu/ananas
Ada
1,704
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S Y N C H R O N O U S _ T A S K _ C O N T R O L . E D F -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- This unit is not implemented in typical GNAT implementations that lie on -- top of operating systems, because it is infeasible to implement in such -- environments. -- If a target environment provides appropriate support for this package, -- then the Unimplemented_Unit pragma should be removed from this spec and -- an appropriate body provided. package Ada.Synchronous_Task_Control.EDF is pragma Unimplemented_Unit; procedure Suspend_Until_True_And_Set_Deadline (S : in out Suspension_Object; TS : Ada.Real_Time.Time_Span); end Ada.Synchronous_Task_Control.EDF;
godunko/adawebpack
Ada
3,534
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . E X C E P T I O N S -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- -- Version is for use when there are no handlers in the partition (i.e. either -- of Restriction No_Exception_Handlers or No_Exception_Propagation is set). -- This is the WASM version of this package -- XXX GNATLLVM: Raise_Exception is incorrectly inlined in s-fatflt.ads with System; with Ada.Streams; package Ada.Exceptions is pragma Preelaborate; -- In accordance with Ada 2005 AI-362 type Exception_Id is private; pragma Preelaborable_Initialization (Exception_Id); Null_Id : constant Exception_Id; procedure Raise_Exception (E : Exception_Id; Message : String := ""); pragma No_Return (Raise_Exception); -- Unconditionally call __gnat_last_chance_handler. -- Note that the exception is still raised even if E is the null exception -- id. This is a deliberate simplification for this profile (the use of -- Raise_Exception with a null id is very rare in any case, and this way -- we avoid introducing Raise_Exception_Always and we also avoid the if -- test in Raise_Exception). type Exception_Occurrence is limited private; pragma Preelaborable_Initialization (Exception_Occurrence); procedure Reraise_Occurrence (X : Exception_Occurrence); Null_Occurrence : constant Exception_Occurrence; private ------------------ -- Exception_Id -- ------------------ type Exception_Id is access all System.Address; Null_Id : constant Exception_Id := null; -- pragma Inline_Always (Raise_Exception); type Exception_Occurrence is access String; procedure Read_Exception_Occurrence (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out Exception_Occurrence); procedure Write_Exception_Occurrence (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Exception_Occurrence); for Exception_Occurrence'Read use Read_Exception_Occurrence; for Exception_Occurrence'Write use Write_Exception_Occurrence; Null_Occurrence : constant Exception_Occurrence := null; procedure Raise_From_Controlled_Operation (X : Exception_Occurrence); pragma No_Return (Raise_From_Controlled_Operation); pragma Export (Ada, Raise_From_Controlled_Operation, "__gnat_raise_from_controlled_operation"); -- Raise Program_Error, providing information about X (an exception raised -- during a controlled operation) in the exception message. end Ada.Exceptions;
reznikmm/matreshka
Ada
6,886
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.UML.Abstractions; with AMF.Visitors.Standard_Profile_L2_Iterators; with AMF.Visitors.Standard_Profile_L2_Visitors; package body AMF.Internals.Standard_Profile_L2_Refines is -------------------------- -- Get_Base_Abstraction -- -------------------------- overriding function Get_Base_Abstraction (Self : not null access constant Standard_Profile_L2_Refine_Proxy) return AMF.UML.Abstractions.UML_Abstraction_Access is begin return AMF.UML.Abstractions.UML_Abstraction_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Abstraction (Self.Element))); end Get_Base_Abstraction; -------------------------- -- Set_Base_Abstraction -- -------------------------- overriding procedure Set_Base_Abstraction (Self : not null access Standard_Profile_L2_Refine_Proxy; To : AMF.UML.Abstractions.UML_Abstraction_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Abstraction (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Abstraction; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Refine_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Enter_Refine (AMF.Standard_Profile_L2.Refines.Standard_Profile_L2_Refine_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Refine_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Leave_Refine (AMF.Standard_Profile_L2.Refines.Standard_Profile_L2_Refine_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Refine_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class (Iterator).Visit_Refine (Visitor, AMF.Standard_Profile_L2.Refines.Standard_Profile_L2_Refine_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Standard_Profile_L2_Refines;
reznikmm/matreshka
Ada
4,794
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_User_Index_Source_Elements; package Matreshka.ODF_Text.User_Index_Source_Elements is type Text_User_Index_Source_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_User_Index_Source_Elements.ODF_Text_User_Index_Source with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_User_Index_Source_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_User_Index_Source_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_User_Index_Source_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_User_Index_Source_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_User_Index_Source_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.User_Index_Source_Elements;
AdaCore/gpr
Ada
4,405
ads
------------------------------------------------------------------------------ -- -- -- GPR2 PROJECT MANAGER -- -- -- -- Copyright (C) 2019-2023, AdaCore -- -- -- -- This 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. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with GNAT; see file COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ -- This is the root package for the compilation support. It handles the local -- and distributed compilation modes. with Ada.Characters.Latin_1; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; with GNAT.OS_Lib; with GPR2.Time_Stamp; package GPR2.Compilation is Default_Port : constant := 8484; Opts_Sep : constant Character := Ada.Characters.Latin_1.HT; -- Command options separator, that is the separator used for options to be -- passed to the executed command. -- A simple concurrent counter type protected type Shared_Counter (Default : Natural := 0) is function Count return Natural; -- Returns the current counter value procedure Increment; -- Increment by one procedure Decrement; -- Decrement by one procedure Reset; -- Reset counter to 0 entry Wait_Non_Zero; -- Returns when the counter is above zero private Counter : Natural := Default; end Shared_Counter; type Shared_Counter_Access is access Shared_Counter; procedure Set_Env (Env : String; Fail : Boolean; Force : Boolean := False); -- Set environment given an Env variable containing a set of name=value -- separated with Opts_Sep. -- -- name=value[<opts_sep>name=value] -- -- If Fail is true the program will exit if the a format error is detected. -- If Force is set to True the environment will always be set otherwise it -- will be set only if not already set. -- The set of files for a given project (associated with a synchronization -- job). type File_Data is record Path_Name : Ada.Strings.Unbounded.Unbounded_String; Timestamp : Time_Stamp.Data; Is_Executable : Boolean; end record; package File_Data_Set is new Ada.Containers.Vectors (Positive, File_Data); -- Process's Id, shared between Slave and Process children type Remote_Id is mod 2 ** 64; -- Represent a remote process id, this number is unique across all slaves. -- Such number if created by the slaves using a slave id (unique number) -- and a compilation number. Bother numbers are 32bits value: -- -- 63 32 31 0 -- | [slave id] | [compilation number] | type Process_Kind is (Local, Remote); type Id (Kind : Process_Kind := Local) is record case Kind is when Local => Pid : GNAT.OS_Lib.Process_Id; when Remote => R_Pid : Remote_Id; end case; end record; Invalid_Process : constant Id := (Local, Pid => GNAT.OS_Lib.Invalid_Pid); function Image (Pid : Remote_Id) return String; -- Returns the string representation of Pid procedure Check_Local_Process (Process : Id); -- Check that a local process is valid. If not, fail with the errno and -- associated message. private function To_Native_Directory_Separator (Pathname : String) return String with Inline; -- Returns Pathname with native directory separator end GPR2.Compilation;
reznikmm/matreshka
Ada
3,719
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Style_Name_Attributes is pragma Preelaborate; type ODF_Table_Style_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Style_Name_Attribute_Access is access all ODF_Table_Style_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Style_Name_Attributes;
landgraf/nanomsg-ada
Ada
1,833
ads
-- The MIT License (MIT) -- Copyright (c) 2015 Pavel Zhukov <[email protected]> -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. with Nanomsg.Socket; with Nanomsg.Sockopt; package Nanomsg.Pubsub is Nn_Pubsub_Proto : constant := 2; Nn_Pub : constant Protocol_T := Nn_Pubsub_Proto * 16 + 0; Nn_Sub : constant Protocol_T := Nn_Pubsub_Proto * 16 + 1; Nn_Sub_Subscribe : constant Nanomsg.Sockopt.Option_Type_T := 1; Nn_Sub_UnSubscribe : constant Nanomsg.Sockopt.Option_Type_T := 2; procedure Subscribe (Socket : in out Nanomsg.Socket.Socket_T; Topic : in String); procedure Unsubscribe (Socket : in out Nanomsg.Socket.Socket_T; Topuc : in String); end Nanomsg.Pubsub;
reznikmm/matreshka
Ada
3,386
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Core is pragma Pure; end Core;
reznikmm/matreshka
Ada
3,754
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Chart_Error_Upper_Range_Attributes is pragma Preelaborate; type ODF_Chart_Error_Upper_Range_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Error_Upper_Range_Attribute_Access is access all ODF_Chart_Error_Upper_Range_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Error_Upper_Range_Attributes;
BrickBot/Bound-T-H8-300
Ada
6,725
adb
-- Flow.Origins.For_Flow (body) -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- 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. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 20:05:48 $ -- -- $Log: flow-origins-for_flow.adb,v $ -- Revision 1.2 2015/10/24 20:05:48 niklas -- Moved to free licence. -- -- Revision 1.1 2013/12/08 22:05:57 niklas -- BT-CH-0259: Storing value-origin analysis results in execution bounds. -- with Arithmetic; with Flow.Opt; with Flow.Show; with Output; package body Flow.Origins.For_Flow is -- --- Resolving dynamic jumps using "copy initial value" --- transfer functions -- type Origin_Function_T is new Arithmetic.Transfer_Function_T with record Map : Map_Ref; Step : Step_T; end record; -- -- Represents the arithmetic transfer function from the subprogram entry -- up to but not including the source Step of a given dynamic edge, in so -- far as this function preserves initial values of cells or copies -- them to other cells, as shown by the value-origin Map. -- -- Note that the effect of the source Step itself is not included. -- overriding function Is_Initial_Value ( Cell : Storage.Cell_T; From : Storage.Cell_T; Thru : Origin_Function_T) return Boolean; -- overriding function Definition ( Cell : Storage.Cell_T; Thru : Origin_Function_T) return Arithmetic.Expr_Ref; -- -- The result is always a single cell (Is_Initial_Value) or Unknown. -- Origin_Function_T operation bodies -- overriding function Is_Initial_Value ( Cell : Storage.Cell_T; From : Storage.Cell_T; Thru : Origin_Function_T) return Boolean is use type Storage.Cell_T; Origin : Origin_T; -- The origin of the Cell. begin if not Origin_Is_Known (Cell, Thru.Map) then -- This cell is not included in our analysis. return False; else Origin := Origin_Before ( Step => Thru.Step, Cell => Cell, From => Thru.Map); return Origin.Kind = Initial and then Origin.Cell = From; end if; end Is_Initial_Value; function Definition ( Cell : Storage.Cell_T; Thru : Origin_Function_T) return Arithmetic.Expr_Ref is Origin : Origin_T; -- The origin of the Cell. begin if not Origin_Is_Known (Cell, Thru.Map) then -- This cell is not included in our analysis. return Arithmetic.Unknown; else Origin := Origin_Before ( Step => Thru.Step, Cell => Cell, From => Thru.Map); case Origin.Kind is when Initial => return Arithmetic.Expr (Origin.Cell); when others => return Arithmetic.Unknown; end case; end if; end Definition; procedure Resolve_Boundable_Edges (Map : in Map_Ref) is Model : constant Flow.Computation.Model_Handle_T := Flow.Origins.Computation (Under => Map); -- The computation model for this Map. Edges : constant Dynamic_Edge_List_T := Flow.Computation.Unstable_Dynamic_Edges (Model.all); -- All the feasible dynamic edges that are not yet stably -- resolved or stably unresolved. Origin_Function : Origin_Function_T := ( Map => Map, Step => No_Step); -- The cell origins on entry to the source-step of a dynamic jump. -- Initialized with the components that do not depend on the -- particular jump under analysis and null for the other components. Edge : Dynamic_Edge_T; -- One of the Edges. Step : Step_T; -- The source of the Edge. Step_Mark : Output.Nest_Mark_T; -- The locus of the Step. begin for E in Edges'Range loop Edge := Edges(E); if Role (Edge.all) = Boundable_Jump then -- We look only at dynamic jumps. Step := Source (Edge.all); Step_Mark := Output.Nest (Show.Locus ( Step => Step, Source => Symbol_Table (Map))); Origin_Function.Step := Step; -- This specializes the Origin_Function to consider the -- source step of this particular Edge. if Flow.Opt.Trace_Flow_Resolution then Output.Trace ( Locus => Show.Locus ( Edge => Edge.all, Source => Symbol_Table (Map)), Text => "Applying value-origin analysis upon " & Image (Edge.all)); end if; Apply ( Transfer => Origin_Function, Upon => Edge.all, Graph => Flow.Computation.Graph (Computation (Map).all)); Output.Unnest (Step_Mark); end if; end loop; end Resolve_Boundable_Edges; end Flow.Origins.For_Flow;
AaronC98/PlaneSystem
Ada
11,689
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2006-2018, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ -- This is a dummy implementation used when AWS is built without SSL -- support. Every use of this interface will raise the Program_Error -- exception. package body AWS.Net.SSL is type TS_SSL is new System.Address; Error_Message : constant String := "SSL not supported."; ------------------------- -- Abort_DH_Generation -- ------------------------- procedure Abort_DH_Generation is begin Abort_DH_Flag := True; end Abort_DH_Generation; ------------------- -- Accept_Socket -- ------------------- overriding procedure Accept_Socket (Socket : Net.Socket_Type'Class; New_Socket : in out Socket_Type) is begin raise Program_Error with Error_Message; end Accept_Socket; -------------------------- -- Add_Host_Certificate -- -------------------------- procedure Add_Host_Certificate (Config : SSL.Config; Host : String; Certificate_Filename : String; Key_Filename : String := "") is begin null; end Add_Host_Certificate; ------------------------ -- Cipher_Description -- ------------------------ overriding function Cipher_Description (Socket : Socket_Type) return String is begin raise Program_Error with Error_Message; return ""; end Cipher_Description; ------------- -- Ciphers -- ------------- procedure Ciphers (Cipher : not null access procedure (Name : String)) is null; ------------------------- -- Clear_Session_Cache -- ------------------------- procedure Clear_Session_Cache (Config : SSL.Config := Null_Config) is null; ------------- -- Connect -- ------------- overriding procedure Connect (Socket : in out Socket_Type; Host : String; Port : Positive; Wait : Boolean := True; Family : Family_Type := Family_Unspec) is begin raise Program_Error with Error_Message; end Connect; ------------------ -- Do_Handshake -- ------------------ procedure Do_Handshake (Socket : in out Socket_Type) is begin raise Program_Error with Error_Message; end Do_Handshake; ---------- -- Free -- ---------- procedure Free (Key : in out Private_Key) is null; procedure Free (Session : in out Session_Type) is null; overriding procedure Free (Socket : in out Socket_Type) is begin raise Program_Error with Error_Message; end Free; ----------------- -- Generate_DH -- ----------------- procedure Generate_DH is null; ------------------ -- Generate_RSA -- ------------------ procedure Generate_RSA is null; ---------------- -- Initialize -- ---------------- procedure Initialize (Config : in out SSL.Config; Certificate_Filename : String; Security_Mode : Method := TLS; Priorities : String := ""; Ticket_Support : Boolean := False; Key_Filename : String := ""; Exchange_Certificate : Boolean := False; Certificate_Required : Boolean := False; Trusted_CA_Filename : String := ""; CRL_Filename : String := ""; Session_Cache_Size : Natural := 16#4000#) is begin raise Program_Error with Error_Message; end Initialize; ------------------------------- -- Initialize_Default_Config -- ------------------------------- procedure Initialize_Default_Config (Certificate_Filename : String; Security_Mode : Method := TLS; Priorities : String := ""; Ticket_Support : Boolean := False; Key_Filename : String := ""; Exchange_Certificate : Boolean := False; Certificate_Required : Boolean := False; Trusted_CA_Filename : String := ""; CRL_Filename : String := ""; Session_Cache_Size : Natural := 16#4000#) is begin raise Program_Error with Error_Message; end Initialize_Default_Config; ---------- -- Load -- ---------- function Load (Filename : String) return Private_Key is begin raise Program_Error with Error_Message; return (null record); end Load; --------------- -- Log_Error -- --------------- procedure Log_Error (Text : String) is null; ------------- -- Pending -- ------------- overriding function Pending (Socket : Socket_Type) return Stream_Element_Count is begin raise Program_Error with Error_Message; return 0; end Pending; ------------- -- Receive -- ------------- overriding procedure Receive (Socket : Socket_Type; Data : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin raise Program_Error with Error_Message; end Receive; ------------- -- Release -- ------------- procedure Release (Config : in out SSL.Config) is begin raise Program_Error with Error_Message; end Release; ------------------- -- Secure_Client -- ------------------- function Secure_Client (Socket : Net.Socket_Type'Class; Config : SSL.Config := Null_Config; Host : String := "") return Socket_Type is pragma Unreferenced (Socket, Config, Host); S : Socket_Type; begin raise Program_Error with Error_Message; return S; end Secure_Client; ------------------- -- Secure_Server -- ------------------- function Secure_Server (Socket : Net.Socket_Type'Class; Config : SSL.Config := Null_Config) return Socket_Type is pragma Unreferenced (Socket, Config); S : Socket_Type; begin raise Program_Error with Error_Message; return S; end Secure_Server; ---------- -- Send -- ---------- overriding procedure Send (Socket : Socket_Type; Data : Stream_Element_Array; Last : out Stream_Element_Offset) is begin raise Program_Error with Error_Message; end Send; -------------------------- -- Session_Cache_Number -- -------------------------- function Session_Cache_Number (Config : SSL.Config := Null_Config) return Natural is pragma Unreferenced (Config); begin return 0; end Session_Cache_Number; ------------------ -- Session_Data -- ------------------ function Session_Data (Socket : Socket_Type) return Session_Type is pragma Unreferenced (Socket); begin return Null_Session; end Session_Data; ---------------------- -- Session_Id_Image -- ---------------------- function Session_Id_Image (Session : Session_Type) return String is pragma Unreferenced (Session); begin return ""; end Session_Id_Image; function Session_Id_Image (Socket : Socket_Type) return String is pragma Unreferenced (Socket); begin return ""; end Session_Id_Image; -------------------- -- Session_Reused -- -------------------- function Session_Reused (Socket : Socket_Type) return Boolean is pragma Unreferenced (Socket); begin return False; end Session_Reused; ---------------- -- Set_Config -- ---------------- procedure Set_Config (Socket : in out Socket_Type; Config : SSL.Config) is begin raise Program_Error with Error_Message; end Set_Config; --------------- -- Set_Debug -- --------------- procedure Set_Debug (Level : Natural; Output : Debug_Output_Procedure := null) is null; ---------------------------- -- Set_Session_Cache_Size -- ---------------------------- procedure Set_Session_Cache_Size (Size : Natural; Config : SSL.Config := Null_Config) is null; ---------------------- -- Set_Session_Data -- ---------------------- procedure Set_Session_Data (Socket : in out Socket_Type; Data : Session_Type) is null; ------------------------- -- Set_Verify_Callback -- ------------------------- procedure Set_Verify_Callback (Config : in out SSL.Config; Callback : System.Address) is begin raise Program_Error with Error_Message; end Set_Verify_Callback; -------------- -- Shutdown -- -------------- overriding procedure Shutdown (Socket : Socket_Type; How : Shutmode_Type := Shut_Read_Write) is begin raise Program_Error with Error_Message; end Shutdown; --------------- -- Signature -- --------------- function Signature (Ptr : System.Address; Size : Interfaces.C.size_t; Key : Private_Key; Hash : Hash_Method) return Stream_Element_Array is pragma Unreferenced (Ptr, Size, Key, Hash); begin return (1 .. 0 => <>); end Signature; ----------------- -- Socket_Pair -- ----------------- overriding procedure Socket_Pair (S1, S2 : out Socket_Type) is begin raise Program_Error with Error_Message; end Socket_Pair; --------------------------------- -- Start_Parameters_Generation -- --------------------------------- procedure Start_Parameters_Generation (DH : Boolean; Logging : access procedure (Text : String) := null) is null; ------------- -- Version -- ------------- function Version (Build_Info : Boolean := False) return String is pragma Unreferenced (Build_Info); begin return Error_Message; end Version; end AWS.Net.SSL;
reznikmm/gela
Ada
51,494
adb
with Gela.Array_Type_Views; with Gela.Compilations; with Gela.Derived_Type_Views; with Gela.Element_Factories; with Gela.Element_Visiters; with Gela.Elements.Access_To_Object_Definitions; with Gela.Elements.Basic_Declarative_Items; with Gela.Elements.Component_Declarations; with Gela.Elements.Component_Definitions; with Gela.Elements.Composite_Subtype_Indications; with Gela.Elements.Constrained_Array_Definitions; with Gela.Elements.Defining_Character_Literals; with Gela.Elements.Defining_Enumeration_Names; with Gela.Elements.Defining_Identifiers; with Gela.Elements.Derived_Type_Definitions; with Gela.Elements.Discrete_Simple_Expression_Ranges; with Gela.Elements.Discrete_Subtype_Indications; with Gela.Elements.Discriminant_Specifications; with Gela.Elements.Enumeration_Literal_Specifications; with Gela.Elements.Enumeration_Type_Definitions; with Gela.Elements.Floating_Point_Definitions; with Gela.Elements.Formal_Discrete_Type_Definitions; with Gela.Elements.Formal_Object_Declarations; with Gela.Elements.Formal_Signed_Integer_Type_Definitions; with Gela.Elements.Formal_Type_Definitions; with Gela.Elements.Identifiers; with Gela.Elements.Loop_Parameter_Specifications; with Gela.Elements.Number_Declarations; with Gela.Elements.Object_Declarations; with Gela.Elements.Package_Declarations; with Gela.Elements.Parameter_Specifications; with Gela.Elements.Record_Type_Definitions; with Gela.Elements.Scalar_Subtype_Indications; with Gela.Elements.Selected_Components; with Gela.Elements.Selector_Names; with Gela.Elements.Signed_Integer_Type_Definitions; with Gela.Elements.Subtype_Declarations; with Gela.Elements.Subtype_Indication_Or_Access_Definitions; with Gela.Elements.Subtype_Indications; with Gela.Elements.Subtype_Marks; with Gela.Elements.Type_Definitions; with Gela.Elements.Unconstrained_Array_Definitions; with Gela.Environments; with Gela.Plain_Type_Views; with Gela.Profiles.Attributes; with Gela.Profiles.Names; package body Gela.Plain_Type_Managers is Universal_Access_Index : constant Gela.Semantic_Types.Type_View_Index := 1; Universal_Integer_Index : constant Gela.Semantic_Types.Type_View_Index := 2; Universal_Real_Index : constant Gela.Semantic_Types.Type_View_Index := 3; Boolean_Index : constant Gela.Semantic_Types.Type_View_Index := 4; Root_Integer_Index : constant Gela.Semantic_Types.Type_View_Index := 5; Root_Real_Index : constant Gela.Semantic_Types.Type_View_Index := 6; ------------- -- Boolean -- ------------- overriding function Boolean (Self : access Type_Manager) return Gela.Semantic_Types.Type_View_Index is pragma Unreferenced (Self); begin return Boolean_Index; end Boolean; not overriding function Get (Self : access Type_Manager; Category : Gela.Type_Categories.Category_Kinds; Decl : Gela.Elements.Formal_Type_Declarations .Formal_Type_Declaration_Access) return Gela.Semantic_Types.Type_View_Index is use type Gela.Semantic_Types.Type_View_Index; Key : constant Back_Key := (Category, Decl); Pos : constant Back_Maps.Cursor := Self.Back.Find (Key); Result : constant Gela.Semantic_Types.Type_View_Index := Self.Map.Last_Key + 1; begin if Back_Maps.Has_Element (Pos) then return Back_Maps.Element (Pos); end if; Self.Map.Insert (Result, Gela.Plain_Type_Views.Create_Formal_Type (Result, Category, Decl)); Self.Back.Insert (Key, Result); return Result; end Get; --------- -- Get -- --------- not overriding function Get (Self : access Type_Manager; Category : Gela.Type_Categories.Category_Kinds; Decl : Gela.Elements.Full_Type_Declarations .Full_Type_Declaration_Access) return Gela.Semantic_Types.Type_View_Index is use type Gela.Semantic_Types.Type_View_Index; Key : constant Back_Key := (Category, Decl); Pos : constant Back_Maps.Cursor := Self.Back.Find (Key); Result : constant Gela.Semantic_Types.Type_View_Index := Self.Map.Last_Key + 1; Type_View : Gela.Type_Categories.Type_View_Access; begin if Back_Maps.Has_Element (Pos) then return Back_Maps.Element (Pos); end if; if Result in Root_Integer_Index | Root_Real_Index then Type_View := Gela.Plain_Type_Views.Create_Root_Type (Result, Category, Decl); else Type_View := Gela.Plain_Type_Views.Create_Full_Type (Result, Category, Decl); end if; Self.Map.Insert (Result, Type_View); Self.Back.Insert (Key, Result); return Result; end Get; --------- -- Get -- --------- overriding function Get (Self : access Type_Manager; Index : Gela.Semantic_Types.Type_View_Index) return Gela.Types.Type_View_Access is use type Gela.Semantic_Types.Type_View_Index; begin if Index = 0 then return null; else return Gela.Types.Type_View_Access (Self.Map.Element (Index)); end if; end Get; not overriding function Get_Array (Self : access Type_Manager; Category : Gela.Type_Categories.Category_Kinds; Decl : Gela.Elements.Full_Type_Declarations .Full_Type_Declaration_Access; Component : Gela.Types.Type_View_Access; Indexes : Gela.Types.Simple.Discrete_Type_Array) return Gela.Semantic_Types.Type_View_Index is use type Gela.Semantic_Types.Type_View_Index; Key : constant Back_Key := (Category, Decl); Pos : constant Back_Maps.Cursor := Self.Back.Find (Key); Result : constant Gela.Semantic_Types.Type_View_Index := Self.Map.Last_Key + 1; begin if Back_Maps.Has_Element (Pos) then return Back_Maps.Element (Pos); end if; Self.Map.Insert (Result, Gela.Array_Type_Views.Create_Full_Type (Result, Category, Decl, Component, Indexes)); Self.Back.Insert (Key, Result); return Result; end Get_Array; ----------------- -- Get_Derived -- ----------------- not overriding function Get_Derived (Self : access Type_Manager; Parent : Gela.Type_Categories.Type_View_Access; Decl : Gela.Elements.Full_Type_Declarations .Full_Type_Declaration_Access) return Gela.Semantic_Types.Type_View_Index is -- FIXME: Use separate maps for derived types use type Gela.Semantic_Types.Type_View_Index; Key : constant Back_Key := (Parent.Category, Decl); Pos : constant Back_Maps.Cursor := Self.Back.Find (Key); Result : constant Gela.Semantic_Types.Type_View_Index := Self.Map.Last_Key + 1; begin if Back_Maps.Has_Element (Pos) then return Back_Maps.Element (Pos); end if; Self.Map.Insert (Result, Gela.Derived_Type_Views.Create_Derived_Type (Result, Parent, Decl)); Self.Back.Insert (Key, Result); return Result; end Get_Derived; ----------------- -- Get_Profile -- ----------------- overriding function Get_Profile (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Name : Gela.Elements.Defining_Names.Defining_Name_Access) return Gela.Profiles.Profile_Access is Result : Profile_Access; Cursor : constant Profile_Maps.Cursor := Self.Profiles.Find (Name); begin if Profile_Maps.Has_Element (Cursor) then Result := Profile_Maps.Element (Cursor); else Result := new Gela.Profiles.Profile'Class' (Gela.Profiles.Names.Create (Env, Name)); Self.Profiles.Insert (Name, Result); end if; return Gela.Profiles.Profile_Access (Result); end Get_Profile; ----------------- -- Get_Profile -- ----------------- overriding function Get_Profile (Self : access Type_Manager; Tipe : Gela.Semantic_Types.Type_View_Index; Attribute : Gela.Lexical_Types.Symbol) return Gela.Profiles.Profile_Access is Result : Profile_Access; Type_View : constant Gela.Types.Type_View_Access := Self.Get (Tipe); Key : constant Attribute_Key := (Tipe, Attribute); Cursor : constant Attribute_Maps.Cursor := Self.Attributes.Find (Key); begin if Attribute_Maps.Has_Element (Cursor) then Result := Attribute_Maps.Element (Cursor); else case Attribute is when Gela.Lexical_Types.Predefined_Symbols.Ceiling | Gela.Lexical_Types.Predefined_Symbols.Floor | Gela.Lexical_Types.Predefined_Symbols.Fraction | Gela.Lexical_Types.Predefined_Symbols.Machine | Gela.Lexical_Types.Predefined_Symbols.Machine_Rounding | Gela.Lexical_Types.Predefined_Symbols.Model | Gela.Lexical_Types.Predefined_Symbols.Pred | Gela.Lexical_Types.Predefined_Symbols.Rounding | Gela.Lexical_Types.Predefined_Symbols.Succ | Gela.Lexical_Types.Predefined_Symbols.Truncation | Gela.Lexical_Types.Predefined_Symbols.Unbiased_Rounding => Result := new Gela.Profiles.Profile'Class' (Gela.Profiles.Attributes.Create ((1 => Type_View), Type_View)); when Gela.Lexical_Types.Predefined_Symbols.Pos => Result := new Gela.Profiles.Profile'Class' (Gela.Profiles.Attributes.Create ((1 => Type_View), Self.Get (Self.Universal_Integer))); when Gela.Lexical_Types.Predefined_Symbols.Mod_Symbol | Gela.Lexical_Types.Predefined_Symbols.Val => Result := new Gela.Profiles.Profile'Class' (Gela.Profiles.Attributes.Create ((1 => Self.Get (Self.Universal_Integer)), Type_View)); when others => raise Constraint_Error; end case; Self.Attributes.Insert (Key, Result); end if; return Gela.Profiles.Profile_Access (Result); end Get_Profile; ---------- -- Hash -- ---------- function Hash (Key : Back_Key) return Ada.Containers.Hash_Type is use type Ada.Containers.Hash_Type; begin return Key.Decl.Hash + Gela.Type_Categories.Category_Kinds'Pos (Key.Category); end Hash; ---------- -- Hash -- ---------- function Hash (Self : Gela.Elements.Defining_Names.Defining_Name_Access) return Ada.Containers.Hash_Type is begin return Self.Hash; end Hash; ---------- -- Hash -- ---------- function Hash (Self : Gela.Elements.Root_Type_Definitions. Root_Type_Definition_Access) return Ada.Containers.Hash_Type is begin return Self.Hash; end Hash; ---------- -- Hash -- ---------- function Hash (Value : Attribute_Key) return Ada.Containers.Hash_Type is use type Ada.Containers.Hash_Type; begin return Ada.Containers.Hash_Type (Value.Tipe) * 2017 + Gela.Lexical_Types.Symbol'Pos (Value.Attribute); end Hash; ---------------- -- Initialize -- ---------------- package S renames Standard; procedure Initialize (Self : access Type_Manager; Standard : Gela.Elements.Element_Access) is procedure Create (Category : Gela.Type_Categories.Category_Kinds; Index : Gela.Semantic_Types.Type_View_Index); procedure Find_Type (Symbol : Gela.Lexical_Types.Symbol; Category : Gela.Type_Categories.Category_Kinds; Expect : Gela.Semantic_Types.Type_View_Index); Comp : constant Gela.Compilations.Compilation_Access := Standard.Enclosing_Compilation; Factory : constant Gela.Element_Factories.Element_Factory_Access := Comp.Factory; procedure Create (Category : Gela.Type_Categories.Category_Kinds; Index : Gela.Semantic_Types.Type_View_Index) is Id : Gela.Elements.Defining_Identifiers.Defining_Identifier_Access; Def : Gela.Elements.Root_Type_Definitions .Root_Type_Definition_Access; Node : Gela.Elements.Full_Type_Declarations .Full_Type_Declaration_Access; begin Id := Factory.Defining_Identifier (Identifier_Token => 0); Def := Factory.Root_Type_Definition (0); Self.Roots.Insert (Def, Index); Node := Factory.Full_Type_Declaration (Type_Token => 0, Names => Id, Discriminant_Part => null, Is_Token => 0, Type_Declaration_View => Gela.Elements.Type_Definitions.Type_Definition_Access (Def), Aspect_Specifications => Factory.Aspect_Specification_Sequence, Semicolon_Token => 0); Self.Map.Insert (Index, Gela.Plain_Type_Views.Create_Full_Type (Index, Category, Node)); end Create; --------------- -- Find_Type -- --------------- procedure Find_Type (Symbol : Gela.Lexical_Types.Symbol; Category : Gela.Type_Categories.Category_Kinds; Expect : Gela.Semantic_Types.Type_View_Index) is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Stop : S.Boolean := False; Result : Gela.Semantic_Types.Type_View_Index := 0; end record; overriding procedure Full_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access); end Visiters; package body Visiters is overriding procedure Full_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access) is use type Gela.Lexical_Types.Symbol; Identifier : constant Gela.Elements.Defining_Identifiers .Defining_Identifier_Access := Node.Names; Name : constant Gela.Elements.Defining_Names.Defining_Name_Access := Gela.Elements.Defining_Names.Defining_Name_Access (Identifier); Token : constant Gela.Lexical_Types.Token := Comp.Get_Token (Identifier.Identifier_Token); begin if Token.Symbol = Symbol then Self.Stop := True; Self.Result := Initialize.Self.Get (Category => Category, Decl => Node); if Category in Gela.Type_Categories.A_Boolean then Initialize.Self.Boolean := Name; end if; end if; end Full_Type_Declaration; end Visiters; use type Gela.Semantic_Types.Type_View_Index; Seq : constant Gela.Elements.Basic_Declarative_Items .Basic_Declarative_Item_Sequence_Access := Gela.Elements.Package_Declarations .Package_Declaration_Access (Standard) .Visible_Part_Declarative_Items; Cursor : Gela.Elements.Basic_Declarative_Items .Basic_Declarative_Item_Sequence_Cursor := Seq.First; Visiter : aliased Visiters.Visiter; begin while Cursor.Has_Element and not Visiter.Stop loop Cursor.Element.Visit (Visiter); Cursor.Next; end loop; pragma Assert (Visiter.Result = Expect); end Find_Type; use Gela.Type_Categories; begin Create (An_Universal_Access, Universal_Access_Index); Create (An_Universal_Integer, Universal_Integer_Index); Create (An_Universal_Real, Universal_Real_Index); Find_Type (Gela.Lexical_Types.Predefined_Symbols.Boolean, Gela.Type_Categories.A_Boolean, Boolean_Index); Find_Type (Gela.Lexical_Types.Predefined_Symbols.Root_Integer, Gela.Type_Categories.A_Signed_Integer, Root_Integer_Index); Find_Type (Gela.Lexical_Types.Predefined_Symbols.Root_Real, Gela.Type_Categories.A_Float_Point, Root_Real_Index); end Initialize; ------------------ -- Root_Integer -- ------------------ overriding function Root_Integer (Self : access Type_Manager) return Gela.Semantic_Types.Type_View_Index is pragma Unreferenced (Self); begin return Root_Integer_Index; end Root_Integer; --------------- -- Root_Real -- --------------- overriding function Root_Real (Self : access Type_Manager) return Gela.Semantic_Types.Type_View_Index is pragma Unreferenced (Self); begin return Root_Real_Index; end Root_Real; ------------------ -- Type_By_Name -- ------------------ overriding function Type_By_Name (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Node : Gela.Elements.Defining_Names.Defining_Name_Access) return Gela.Semantic_Types.Type_View_Index is ES : constant Gela.Environments.Environment_Set_Access := Self.Context.Environment_Set; Completions : constant Gela.Environments.Completion_List := ES.Completions (Env, Node); Decl : Gela.Elements.Element_Access; begin if Completions.Length > 0 then Decl := Completions.Data (1).Enclosing_Element; else Decl := Node.Enclosing_Element; end if; return Self.Type_From_Declaration (Env, Decl); end Type_By_Name; --------------------------- -- Type_From_Declaration -- --------------------------- overriding function Type_From_Declaration (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Node : Gela.Elements.Element_Access) return Gela.Semantic_Types.Type_View_Index is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Result : Gela.Semantic_Types.Type_View_Index := 0; Boolean : Gela.Elements.Defining_Names.Defining_Name_Access; end record; overriding procedure Access_To_Object_Definition (Self : in out Visiter; Node : not null Gela.Elements.Access_To_Object_Definitions. Access_To_Object_Definition_Access); overriding procedure Constrained_Array_Definition (Self : in out Visiter; Node : not null Gela.Elements.Constrained_Array_Definitions. Constrained_Array_Definition_Access); overriding procedure Derived_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Derived_Type_Definitions. Derived_Type_Definition_Access); overriding procedure Enumeration_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Enumeration_Type_Definitions. Enumeration_Type_Definition_Access); overriding procedure Floating_Point_Definition (Self : in out Visiter; Node : not null Gela.Elements.Floating_Point_Definitions. Floating_Point_Definition_Access); overriding procedure Formal_Discrete_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Formal_Discrete_Type_Definitions. Formal_Discrete_Type_Definition_Access); overriding procedure Formal_Signed_Integer_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements. Formal_Signed_Integer_Type_Definitions. Formal_Signed_Integer_Type_Definition_Access); overriding procedure Formal_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Formal_Type_Declarations. Formal_Type_Declaration_Access); overriding procedure Full_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access); overriding procedure Record_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Record_Type_Definitions. Record_Type_Definition_Access); overriding procedure Root_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Root_Type_Definitions. Root_Type_Definition_Access); overriding procedure Signed_Integer_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Signed_Integer_Type_Definitions. Signed_Integer_Type_Definition_Access); overriding procedure Subtype_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Subtype_Declarations. Subtype_Declaration_Access); overriding procedure Unconstrained_Array_Definition (Self : in out Visiter; Node : not null Gela.Elements.Unconstrained_Array_Definitions. Unconstrained_Array_Definition_Access); end Visiters; package Is_Char_Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Found : Standard.Boolean := False; end record; overriding procedure Defining_Character_Literal (Self : in out Visiter; Node : not null Gela.Elements.Defining_Character_Literals. Defining_Character_Literal_Access); end Is_Char_Visiters; ---------------------- -- Is_Char_Visiters -- ---------------------- package body Is_Char_Visiters is overriding procedure Defining_Character_Literal (Self : in out Visiter; Node : not null Gela.Elements.Defining_Character_Literals. Defining_Character_Literal_Access) is pragma Unreferenced (Node); begin Self.Found := True; end Defining_Character_Literal; end Is_Char_Visiters; -------------- -- Visiters -- -------------- package body Visiters is overriding procedure Access_To_Object_Definition (Self : in out Visiter; Node : not null Gela.Elements.Access_To_Object_Definitions. Access_To_Object_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Variable_Access, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); end Access_To_Object_Definition; overriding procedure Derived_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Derived_Type_Definitions. Derived_Type_Definition_Access) is use type Gela.Semantic_Types.Type_View_Index; Parent : constant Gela.Elements.Subtype_Indications. Subtype_Indication_Access := Node.Parent_Subtype_Indication; Tipe : constant Gela.Semantic_Types.Type_View_Index := Type_From_Declaration.Self.Type_From_Subtype_Indication (Env, Parent); Type_View : Gela.Type_Categories.Type_View_Access; begin if Tipe /= 0 then Type_View := Gela.Type_Categories.Type_View_Access (Type_From_Declaration.Self.Get (Tipe)); Self.Result := Type_From_Declaration.Self.Get_Derived (Parent => Type_View, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); end if; end Derived_Type_Definition; overriding procedure Enumeration_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Enumeration_Type_Definitions. Enumeration_Type_Definition_Access) is Enum : Gela.Elements.Defining_Enumeration_Names. Defining_Enumeration_Name_Access; Enums : constant Gela.Elements.Enumeration_Literal_Specifications. Enumeration_Literal_Specification_Sequence_Access := Node.Enumeration_Literal_Declarations; Cursor : Gela.Elements.Enumeration_Literal_Specifications. Enumeration_Literal_Specification_Sequence_Cursor := Enums.First; V : Is_Char_Visiters.Visiter; begin while Cursor.Has_Element loop Enum := Cursor.Element.Names; Enum.Visit (V); exit when V.Found; Cursor.Next; end loop; if V.Found then Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Character, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); else Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.An_Other_Enum, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); end if; end Enumeration_Type_Definition; overriding procedure Floating_Point_Definition (Self : in out Visiter; Node : not null Gela.Elements.Floating_Point_Definitions. Floating_Point_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Float_Point, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); end Floating_Point_Definition; overriding procedure Formal_Discrete_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Formal_Discrete_Type_Definitions. Formal_Discrete_Type_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.An_Other_Enum, Decl => Gela.Elements.Formal_Type_Declarations. Formal_Type_Declaration_Access (Node.Enclosing_Element)); end Formal_Discrete_Type_Definition; overriding procedure Formal_Signed_Integer_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements. Formal_Signed_Integer_Type_Definitions. Formal_Signed_Integer_Type_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Signed_Integer, Decl => Gela.Elements.Formal_Type_Declarations. Formal_Type_Declaration_Access (Node.Enclosing_Element)); end Formal_Signed_Integer_Type_Definition; overriding procedure Formal_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Formal_Type_Declarations. Formal_Type_Declaration_Access) is View : constant Gela.Elements.Formal_Type_Definitions. Formal_Type_Definition_Access := Node.Type_Declaration_View; begin View.Visit (Self); end Formal_Type_Declaration; --------------------------- -- Full_Type_Declaration -- --------------------------- overriding procedure Full_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access) is use type Gela.Elements.Defining_Names.Defining_Name_Access; Name : constant Gela.Elements.Defining_Names.Defining_Name_Access := Gela.Elements.Defining_Names.Defining_Name_Access (Node.Names); View : constant Gela.Elements.Type_Definitions. Type_Definition_Access := Node.Type_Declaration_View; begin if Name = Self.Boolean then Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Boolean, Decl => Node); else View.Visit (Self); end if; end Full_Type_Declaration; ---------------------------- -- Record_Type_Definition -- ---------------------------- overriding procedure Record_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Record_Type_Definitions. Record_Type_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Untagged_Record, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); end Record_Type_Definition; -------------------------- -- Root_Type_Definition -- -------------------------- overriding procedure Root_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Root_Type_Definitions. Root_Type_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Roots.Element (Node); end Root_Type_Definition; overriding procedure Signed_Integer_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Signed_Integer_Type_Definitions. Signed_Integer_Type_Definition_Access) is begin Self.Result := Type_From_Declaration.Self.Get (Category => Gela.Type_Categories.A_Signed_Integer, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element)); end Signed_Integer_Type_Definition; overriding procedure Subtype_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Subtype_Declarations. Subtype_Declaration_Access) is Indication : constant Gela.Elements.Subtype_Indications. Subtype_Indication_Access := Node.Type_Declaration_View; begin Self.Result := Type_From_Declaration.Self.Type_From_Subtype_Indication (Env, Indication); end Subtype_Declaration; overriding procedure Unconstrained_Array_Definition (Self : in out Visiter; Node : not null Gela.Elements.Unconstrained_Array_Definitions. Unconstrained_Array_Definition_Access) is use type Gela.Type_Categories.Category_Kinds; Component : constant Gela.Elements.Component_Definitions. Component_Definition_Access := Node.Array_Component_Definition; Component_Type : constant Gela.Semantic_Types.Type_View_Index := Type_From_Declaration.Self.Type_Of_Object_Declaration (Env, Gela.Elements.Element_Access (Component)); Component_Type_View : constant Gela.Types.Type_View_Access := Type_From_Declaration.Self.Get (Component_Type); Index_Seq : constant Gela.Elements.Subtype_Marks. Subtype_Mark_Sequence_Access := Node.Index_Subtype_Definitions; Indexes : Gela.Types.Simple.Discrete_Type_Array (1 .. Index_Seq.Length); begin declare Index : Positive := 1; Cursor : Gela.Elements.Subtype_Marks .Subtype_Mark_Sequence_Cursor := Index_Seq.First; begin while Cursor.Has_Element loop Indexes (Index) := Gela.Types.Simple.Discrete_Type_Access (Type_From_Declaration.Self.Get (Type_From_Declaration.Self.Type_From_Subtype_Mark (Env, Cursor.Element))); Index := Index + 1; Cursor.Next; end loop; end; if Component_Type_View.Assigned and then Component_Type_View.Is_Character then Self.Result := Type_From_Declaration.Self.Get_Array (Category => Gela.Type_Categories.A_String, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element), Component => Component_Type_View, Indexes => Indexes); else Self.Result := Type_From_Declaration.Self.Get_Array (Category => Gela.Type_Categories.An_Other_Array, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element), Component => Component_Type_View, Indexes => Indexes); end if; end Unconstrained_Array_Definition; overriding procedure Constrained_Array_Definition (Self : in out Visiter; Node : not null Gela.Elements.Constrained_Array_Definitions. Constrained_Array_Definition_Access) is use type Gela.Type_Categories.Category_Kinds; Component : constant Gela.Elements.Component_Definitions. Component_Definition_Access := Node.Array_Component_Definition; Component_Type : constant Gela.Semantic_Types.Type_View_Index := Type_From_Declaration.Self.Type_Of_Object_Declaration (Env, Gela.Elements.Element_Access (Component)); Component_Type_View : constant Gela.Types.Type_View_Access := Type_From_Declaration.Self.Get (Component_Type); Index_Seq : constant Gela.Elements.Discrete_Subtype_Definitions. Discrete_Subtype_Definition_Sequence_Access := Node.Discrete_Subtype_Definitions; Indexes : Gela.Types.Simple.Discrete_Type_Array (1 .. Index_Seq.Length); begin if Node.Env_In in 0 then -- FIXME Drop this when generic instance issue is resolved return; end if; declare Index : Positive := 1; Element : Gela.Elements.Discrete_Subtype_Definitions .Discrete_Subtype_Definition_Access; Cursor : Gela.Elements.Discrete_Subtype_Definitions .Discrete_Subtype_Definition_Sequence_Cursor := Index_Seq.First; begin while Cursor.Has_Element loop Element := Cursor.Element; Indexes (Index) := Gela.Types.Simple.Discrete_Type_Access (Type_From_Declaration.Self.Get (Type_From_Declaration.Self.Type_From_Discrete_Subtype (Element.Env_In, Element))); Index := Index + 1; Cursor.Next; end loop; end; if Component_Type_View.Assigned and then Component_Type_View.Is_Character then Self.Result := Type_From_Declaration.Self.Get_Array (Category => Gela.Type_Categories.A_String, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element), Component => Component_Type_View, Indexes => Indexes); else Self.Result := Type_From_Declaration.Self.Get_Array (Category => Gela.Type_Categories.An_Other_Array, Decl => Gela.Elements.Full_Type_Declarations. Full_Type_Declaration_Access (Node.Enclosing_Element), Component => Component_Type_View, Indexes => Indexes); end if; end Constrained_Array_Definition; end Visiters; V : Visiters.Visiter := (0, Self.Boolean); begin Node.Visit (V); return V.Result; end Type_From_Declaration; -------------------------------- -- Type_From_Discrete_Subtype -- -------------------------------- overriding function Type_From_Discrete_Subtype (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Node : access Gela.Elements.Discrete_Subtype_Definitions. Discrete_Subtype_Definition'Class) return Gela.Semantic_Types.Type_View_Index is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Result : Gela.Semantic_Types.Type_View_Index := 0; end record; overriding procedure Discrete_Simple_Expression_Range (Self : in out Visiter; Node : not null Gela.Elements.Discrete_Simple_Expression_Ranges. Discrete_Simple_Expression_Range_Access); overriding procedure Discrete_Subtype_Indication (Self : in out Visiter; Node : not null Gela.Elements.Discrete_Subtype_Indications. Discrete_Subtype_Indication_Access); end Visiters; package body Visiters is overriding procedure Discrete_Simple_Expression_Range (Self : in out Visiter; Node : not null Gela.Elements.Discrete_Simple_Expression_Ranges. Discrete_Simple_Expression_Range_Access) is begin Self.Result := Node.Type_Index; end Discrete_Simple_Expression_Range; overriding procedure Discrete_Subtype_Indication (Self : in out Visiter; Node : not null Gela.Elements.Discrete_Subtype_Indications. Discrete_Subtype_Indication_Access) is begin Self.Result := Type_From_Discrete_Subtype.Self. Type_From_Subtype_Mark (Env, Node.Subtype_Mark); end Discrete_Subtype_Indication; end Visiters; V : Visiters.Visiter; begin Node.Visit (V); return V.Result; end Type_From_Discrete_Subtype; overriding function Type_From_Subtype_Indication (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Node : access Gela.Elements.Object_Definitions.Object_Definition'Class) return Gela.Semantic_Types.Type_View_Index is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Result : Gela.Semantic_Types.Type_View_Index := 0; end record; overriding procedure Composite_Subtype_Indication (Self : in out Visiter; Node : not null Gela.Elements.Composite_Subtype_Indications. Composite_Subtype_Indication_Access); overriding procedure Scalar_Subtype_Indication (Self : in out Visiter; Node : not null Gela.Elements.Scalar_Subtype_Indications. Scalar_Subtype_Indication_Access); end Visiters; -------------- -- Visiters -- -------------- package body Visiters is overriding procedure Composite_Subtype_Indication (Self : in out Visiter; Node : not null Gela.Elements.Composite_Subtype_Indications. Composite_Subtype_Indication_Access) is begin Self.Result := Type_From_Subtype_Indication.Self. Type_From_Subtype_Mark (Env, Node.Subtype_Mark); end Composite_Subtype_Indication; overriding procedure Scalar_Subtype_Indication (Self : in out Visiter; Node : not null Gela.Elements.Scalar_Subtype_Indications. Scalar_Subtype_Indication_Access) is begin Self.Result := Type_From_Subtype_Indication.Self. Type_From_Subtype_Mark (Env, Node.Subtype_Mark); end Scalar_Subtype_Indication; end Visiters; V : Visiters.Visiter := (Result => 0); begin Node.Visit (V); return V.Result; end Type_From_Subtype_Indication; ---------------------------- -- Type_From_Subtype_Mark -- ---------------------------- overriding function Type_From_Subtype_Mark (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Node : access Gela.Elements.Subtype_Mark_Or_Access_Definitions. Subtype_Mark_Or_Access_Definition'Class) return Gela.Semantic_Types.Type_View_Index is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Result : Gela.Semantic_Types.Type_View_Index := 0; end record; overriding procedure Identifier (Self : in out Visiter; Node : not null Gela.Elements.Identifiers.Identifier_Access); overriding procedure Selected_Component (Self : in out Visiter; Node : not null Gela.Elements.Selected_Components. Selected_Component_Access); end Visiters; package body Visiters is overriding procedure Identifier (Self : in out Visiter; Node : not null Gela.Elements.Identifiers.Identifier_Access) is View : Gela.Elements.Subtype_Marks.Subtype_Mark_Access; Defining_Name : constant Gela.Elements.Defining_Names. Defining_Name_Access := Node.Defining_Name; begin if not Defining_Name.Assigned then return; end if; View := Gela.Elements.Subtype_Marks.Subtype_Mark_Access (Defining_Name.Corresponding_View); if View.Assigned then Self.Result := Type_From_Subtype_Mark.Self. Type_From_Subtype_Mark (Env, View); else Self.Result := Type_From_Subtype_Mark.Self.Type_By_Name (Env, Defining_Name); end if; end Identifier; overriding procedure Selected_Component (Self : in out Visiter; Node : not null Gela.Elements.Selected_Components. Selected_Component_Access) is Selector : constant Gela.Elements.Selector_Names. Selector_Name_Access := Node.Selector; begin Selector.Visit (Self); end Selected_Component; end Visiters; V : Visiters.Visiter; begin Node.Visit (V); return V.Result; end Type_From_Subtype_Mark; -------------------------------- -- Type_Of_Object_Declaration -- -------------------------------- overriding function Type_Of_Object_Declaration (Self : access Type_Manager; Env : Gela.Semantic_Types.Env_Index; Node : Gela.Elements.Element_Access) return Gela.Semantic_Types.Type_View_Index is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Result : Gela.Semantic_Types.Type_View_Index := 0; end record; overriding procedure Component_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Component_Declarations. Component_Declaration_Access); overriding procedure Component_Definition (Self : in out Visiter; Node : not null Gela.Elements.Component_Definitions. Component_Definition_Access); overriding procedure Discriminant_Specification (Self : in out Visiter; Node : not null Gela.Elements.Discriminant_Specifications. Discriminant_Specification_Access); overriding procedure Enumeration_Literal_Specification (Self : in out Visiter; Node : not null Gela.Elements.Enumeration_Literal_Specifications. Enumeration_Literal_Specification_Access); overriding procedure Formal_Object_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Formal_Object_Declarations. Formal_Object_Declaration_Access); overriding procedure Loop_Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Loop_Parameter_Specifications. Loop_Parameter_Specification_Access); overriding procedure Number_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Number_Declarations. Number_Declaration_Access); overriding procedure Object_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Object_Declarations. Object_Declaration_Access); overriding procedure Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Parameter_Specifications. Parameter_Specification_Access); end Visiters; package body Visiters is overriding procedure Component_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Component_Declarations. Component_Declaration_Access) is X : constant Gela.Elements.Component_Definitions. Component_Definition_Access := Node.Object_Declaration_Subtype; begin X.Visit (Self); end Component_Declaration; overriding procedure Component_Definition (Self : in out Visiter; Node : not null Gela.Elements.Component_Definitions. Component_Definition_Access) is X : constant Gela.Elements.Subtype_Indication_Or_Access_Definitions .Subtype_Indication_Or_Access_Definition_Access := Node.Component_Subtype_Indication; begin Self.Result := Type_Of_Object_Declaration.Self.Type_From_Subtype_Indication (Env, Gela.Elements.Object_Definitions.Object_Definition_Access (X)); end Component_Definition; overriding procedure Discriminant_Specification (Self : in out Visiter; Node : not null Gela.Elements.Discriminant_Specifications. Discriminant_Specification_Access) is X : constant Gela.Elements.Subtype_Mark_Or_Access_Definitions. Subtype_Mark_Or_Access_Definition_Access := Node.Object_Declaration_Subtype; begin Self.Result := Type_Of_Object_Declaration.Self.Type_From_Subtype_Mark (Env, X); end Discriminant_Specification; overriding procedure Enumeration_Literal_Specification (Self : in out Visiter; Node : not null Gela.Elements.Enumeration_Literal_Specifications. Enumeration_Literal_Specification_Access) is Def : constant Gela.Elements.Element_Access := Node.Enclosing_Element; Decl : constant Gela.Elements.Element_Access := Def.Enclosing_Element; begin Self.Result := Type_Of_Object_Declaration.Self. Type_From_Declaration (Env, Decl); end Enumeration_Literal_Specification; overriding procedure Formal_Object_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Formal_Object_Declarations. Formal_Object_Declaration_Access) is X : constant Gela.Elements.Subtype_Mark_Or_Access_Definitions. Subtype_Mark_Or_Access_Definition_Access := Node.Object_Declaration_Subtype; begin Self.Result := Type_Of_Object_Declaration.Self.Type_From_Subtype_Mark (Env, X); end Formal_Object_Declaration; overriding procedure Loop_Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Loop_Parameter_Specifications. Loop_Parameter_Specification_Access) is begin Self.Result := Type_Of_Object_Declaration.Self.Type_From_Discrete_Subtype (Env, Node.Specification_Subtype_Definition); end Loop_Parameter_Specification; overriding procedure Number_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Number_Declarations. Number_Declaration_Access) is pragma Unreferenced (Node); begin -- FIXME! Self.Result := Type_Of_Object_Declaration.Self.Universal_Integer; end Number_Declaration; overriding procedure Object_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Object_Declarations. Object_Declaration_Access) is X : constant Gela.Elements.Object_Definitions. Object_Definition_Access := Node.Object_Declaration_Subtype; begin Self.Result := Type_Of_Object_Declaration.Self.Type_From_Subtype_Indication (Env, X); end Object_Declaration; overriding procedure Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Parameter_Specifications. Parameter_Specification_Access) is X : constant Gela.Elements.Subtype_Mark_Or_Access_Definitions. Subtype_Mark_Or_Access_Definition_Access := Node.Object_Declaration_Subtype; begin Self.Result := Type_Of_Object_Declaration.Self.Type_From_Subtype_Mark (Env, X); end Parameter_Specification; end Visiters; V : Visiters.Visiter; begin Node.Visit (V); return V.Result; end Type_Of_Object_Declaration; ---------------------- -- Universal_Access -- ---------------------- overriding function Universal_Access (Self : access Type_Manager) return Gela.Semantic_Types.Type_View_Index is pragma Unreferenced (Self); begin return Universal_Access_Index; end Universal_Access; ----------------------- -- Universal_Integer -- ----------------------- overriding function Universal_Integer (Self : access Type_Manager) return Gela.Semantic_Types.Type_View_Index is pragma Unreferenced (Self); begin return Universal_Integer_Index; end Universal_Integer; -------------------- -- Universal_Real -- -------------------- overriding function Universal_Real (Self : access Type_Manager) return Gela.Semantic_Types.Type_View_Index is pragma Unreferenced (Self); begin return Universal_Real_Index; end Universal_Real; end Gela.Plain_Type_Managers;
Tim-Tom/project-euler
Ada
58
ads
package Problem_43 is procedure Solve; end Problem_43;
Gabriel-Degret/adalib
Ada
8,781
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- 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.Strings.Wide_Wide_Maps; package Ada.Strings.Wide_Wide_Fixed is pragma Preelaborate (Wide_Wide_Fixed); -- "Copy" procedure for strings of possibly different lengths procedure Move (Source : in Wide_Wide_String; Target : out Wide_Wide_String; Drop : in Truncation := Error; Justify : in Alignment := Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); -- Search subprograms function Index (Source : in Wide_Wide_String; Pattern : in Wide_Wide_String; From : in Positive; Going : in Direction := Forward; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Index (Source : in Wide_Wide_String; Pattern : in Wide_Wide_String; From : in Positive; Going : in Direction := Forward; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Index (Source : in Wide_Wide_String; Pattern : in Wide_Wide_String; Going : in Direction := Forward; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Index (Source : in Wide_Wide_String; Pattern : in Wide_Wide_String; Going : in Direction := Forward; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Index (Source : in Wide_Wide_String; Set : in Wide_Wide_Maps.Wide_Wide_Character_Set; From : in Positive; Test : in Membership := Inside; Going : in Direction := Forward) return Natural; function Index (Source : in Wide_Wide_String; Set : in Wide_Wide_Maps.Wide_Wide_Character_Set; Test : in Membership := Inside; Going : in Direction := Forward) return Natural; function Index_Non_Blank (Source : in Wide_Wide_String; From : in Positive; Going : in Direction := Forward) return Natural; function Index_Non_Blank (Source : in Wide_Wide_String; Going : in Direction := Forward) return Natural; function Count (Source : in Wide_Wide_String; Pattern : in Wide_Wide_String; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Count (Source : in Wide_Wide_String; Pattern : in Wide_Wide_String; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Count (Source : in Wide_Wide_String; Set : in Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural; procedure Find_Token (Source : in Wide_Wide_String; Set : in Wide_Wide_Maps.Wide_Wide_Character_Set; Test : in Membership; First : out Positive; Last : out Natural); -- Wide_Wide_String translation subprograms function Translate (Source : in Wide_Wide_String; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping) return Wide_Wide_String; procedure Translate (Source : in out Wide_Wide_String; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping); function Translate (Source : in Wide_Wide_String; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Wide_Wide_String; procedure Translate (Source : in out Wide_Wide_String; Mapping : in Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function); -- Wide_Wide_String transformation subprograms function Replace_Slice (Source : in Wide_Wide_String; Low : in Positive; High : in Natural; By : in Wide_Wide_String) return Wide_Wide_String; procedure Replace_Slice (Source : in out Wide_Wide_String; Low : in Positive; High : in Natural; By : in Wide_Wide_String; Drop : in Truncation := Error; Justify : in Alignment := Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); function Insert (Source : in Wide_Wide_String; Before : in Positive; New_Item : in Wide_Wide_String) return Wide_Wide_String; procedure Insert (Source : in out Wide_Wide_String; Before : in Positive; New_Item : in Wide_Wide_String; Drop : in Truncation := Error); function Overwrite (Source : in Wide_Wide_String; Position : in Positive; New_Item : in Wide_Wide_String) return Wide_Wide_String; procedure Overwrite (Source : in out Wide_Wide_String; Position : in Positive; New_Item : in Wide_Wide_String; Drop : in Truncation := Right); function Delete (Source : in Wide_Wide_String; From : in Positive; Through : in Natural) return Wide_Wide_String; procedure Delete (Source : in out Wide_Wide_String; From : in Positive; Through : in Natural; Justify : in Alignment := Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); -- Wide_Wide_String selector subprograms function Trim (Source : in Wide_Wide_String; Side : in Trim_End) return Wide_Wide_String; procedure Trim (Source : in out Wide_Wide_String; Side : in Trim_End; Justify : in Alignment := Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); function Trim (Source : in Wide_Wide_String; Left : in Wide_Wide_Maps.Wide_Wide_Character_Set; Right : in Wide_Wide_Maps.Wide_Wide_Character_Set) return Wide_Wide_String; procedure Trim (Source : in out Wide_Wide_String; Left : in Wide_Wide_Maps.Wide_Wide_Character_Set; Right : in Wide_Wide_Maps.Wide_Wide_Character_Set; Justify : in Alignment := Strings.Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); function Head (Source : in Wide_Wide_String; Count : in Natural; Pad : in Wide_Wide_Character := Wide_Wide_Space) return Wide_Wide_String; procedure Head (Source : in out Wide_Wide_String; Count : in Natural; Justify : in Alignment := Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); function Tail (Source : in Wide_Wide_String; Count : in Natural; Pad : in Wide_Wide_Character := Wide_Wide_Space) return Wide_Wide_String; procedure Tail (Source : in out Wide_Wide_String; Count : in Natural; Justify : in Alignment := Left; Pad : in Wide_Wide_Character := Wide_Wide_Space); -- Wide_Wide_String constructor functions function "*" (Left : in Natural; Right : in Wide_Wide_Character) return Wide_Wide_String; function "*" (Left : in Natural; Right : in Wide_Wide_String) return Wide_Wide_String; end Ada.Strings.Wide_Wide_Fixed;
DrenfongWong/tkm-rpc
Ada
1,138
adb
with Tkmrpc.Servers.Ike; with Tkmrpc.Results; with Tkmrpc.Request.Ike.Cc_Check_Ca.Convert; with Tkmrpc.Response.Ike.Cc_Check_Ca.Convert; package body Tkmrpc.Operation_Handlers.Ike.Cc_Check_Ca is ------------------------------------------------------------------------- procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is Specific_Req : Request.Ike.Cc_Check_Ca.Request_Type; Specific_Res : Response.Ike.Cc_Check_Ca.Response_Type; begin Specific_Res := Response.Ike.Cc_Check_Ca.Null_Response; Specific_Req := Request.Ike.Cc_Check_Ca.Convert.From_Request (S => Req); if Specific_Req.Data.Cc_Id'Valid and Specific_Req.Data.Ca_Id'Valid then Servers.Ike.Cc_Check_Ca (Result => Specific_Res.Header.Result, Cc_Id => Specific_Req.Data.Cc_Id, Ca_Id => Specific_Req.Data.Ca_Id); Res := Response.Ike.Cc_Check_Ca.Convert.To_Response (S => Specific_Res); else Res.Header.Result := Results.Invalid_Parameter; end if; end Handle; end Tkmrpc.Operation_Handlers.Ike.Cc_Check_Ca;
onox/orka
Ada
800
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2022 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.Logging.Default is new Orka.Logging.Generic_Logger (Orka.Logging.Default_Module); pragma Preelaborate (Orka.Logging.Default);
RREE/ada-util
Ada
7,495
adb
----------------------------------------------------------------------- -- util-dates-tests - Test for dates -- Copyright (C) 2018, 2019, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Dates.ISO8601; package body Util.Dates.Tests is package Caller is new Util.Test_Caller (Test, "Dates"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Dates.ISO8601.Image", Test_ISO8601_Image'Access); Caller.Add_Test (Suite, "Test Util.Dates.ISO8601.Value", Test_ISO8601_Value'Access); Caller.Add_Test (Suite, "Test Util.Dates.ISO8601.Value (Errors)", Test_ISO8601_Error'Access); Caller.Add_Test (Suite, "Test Util.Dates.Is_Same_Day", Test_Is_Same_Day'Access); Caller.Add_Test (Suite, "Test Util.Dates.Get_Day_Count", Test_Get_Day_Count'Access); end Add_Tests; -- ------------------------------ -- Test converting a date in ISO8601. -- ------------------------------ procedure Test_ISO8601_Image (T : in out Test) is T1 : constant Ada.Calendar.Time := Ada.Calendar.Formatting.Time_Of (1980, 1, 2, 10, 30, 23); begin Util.Tests.Assert_Equals (T, "1980-01-02", ISO8601.Image (T1), "Invalid Image"); Util.Tests.Assert_Equals (T, "1980", ISO8601.Image (T1, ISO8601.YEAR), "Invalid Image (YEAR precision)"); Util.Tests.Assert_Equals (T, "1980-01", ISO8601.Image (T1, ISO8601.MONTH), "Invalid Image (MONTH precision)"); Util.Tests.Assert_Equals (T, "1980-01-02", ISO8601.Image (T1, ISO8601.DAY), "Invalid Image (DAY precision)"); Util.Tests.Assert_Equals (T, "1980-01-02T10", ISO8601.Image (T1, ISO8601.HOUR), "Invalid Image (DAY precision)"); Util.Tests.Assert_Equals (T, "1980-01-02T10:30", ISO8601.Image (T1, ISO8601.MINUTE), "Invalid Image (MINUTE precision)"); Util.Tests.Assert_Equals (T, "1980-01-02T10:30:23", ISO8601.Image (T1, ISO8601.SECOND), "Invalid Image (SECOND precision)"); end Test_ISO8601_Image; -- ------------------------------ -- Test converting a string in ISO8601 into a date. -- ------------------------------ procedure Test_ISO8601_Value (T : in out Test) is Date : Ada.Calendar.Time; begin Date := ISO8601.Value ("1980"); Util.Tests.Assert_Equals (T, "1980-01-01", ISO8601.Image (Date)); Date := ISO8601.Value ("1980-02"); Util.Tests.Assert_Equals (T, "1980-02", ISO8601.Image (Date, ISO8601.MONTH)); Date := ISO8601.Value ("1980-03-04"); Util.Tests.Assert_Equals (T, "1980-03-04", ISO8601.Image (Date)); Date := ISO8601.Value ("1980-03-04"); Util.Tests.Assert_Equals (T, "1980-03-04", ISO8601.Image (Date)); Date := ISO8601.Value ("1980-12-31"); Util.Tests.Assert_Equals (T, "1980-12-31", ISO8601.Image (Date)); Date := ISO8601.Value ("19801231"); Util.Tests.Assert_Equals (T, "1980-12-31", ISO8601.Image (Date)); Date := ISO8601.Value ("1980-12-31T11:23"); Util.Tests.Assert_Equals (T, "1980-12-31T11:23", ISO8601.Image (Date, ISO8601.MINUTE)); Date := ISO8601.Value ("1980-12-31T11:23:34"); Util.Tests.Assert_Equals (T, "1980-12-31T11:23:34", ISO8601.Image (Date, ISO8601.SECOND)); Date := ISO8601.Value ("1980-12-31T11:23:34.123"); Util.Tests.Assert_Equals (T, "1980-12-31T11:23:34.123+00:00", ISO8601.Image (Date, ISO8601.SUBSECOND)); Date := ISO8601.Value ("1980-12-31T11:23:34.123+04:30"); -- The date was normalized in GMT Util.Tests.Assert_Equals (T, "1980-12-31T06:53:34.123+00:00", ISO8601.Image (Date, ISO8601.SUBSECOND)); end Test_ISO8601_Value; -- ------------------------------ -- Test value convertion errors. -- ------------------------------ procedure Test_ISO8601_Error (T : in out Test) is procedure Check (Date : in String); procedure Check (Date : in String) is begin declare Unused : constant Ada.Calendar.Time := ISO8601.Value (Date); begin T.Fail ("No exception raised for " & Date); end; exception when Constraint_Error => null; end Check; begin Check (""); Check ("1980-"); Check ("1980:02:03"); Check ("1980-02-03u33:33"); Check ("1980-02-03u33"); Check ("1980-13-44"); Check ("1980-12-00"); Check ("1980-12-03T25:34"); Check ("1980-12-03T10x34"); Check ("1980-12-03T10:34p"); Check ("1980-12-31T11:23:34123"); Check ("1980-12-31T11:23:34,1"); Check ("1980-12-31T11:23:34,12"); Check ("1980-12-31T11:23:34x123"); Check ("1980-12-31T11:23:34.1234"); Check ("1980-12-31T11:23:34Zp"); Check ("1980-12-31T11:23:34+2"); Check ("1980-12-31T11:23:34+23x"); Check ("1980-12-31T11:23:34+99"); Check ("1980-12-31T11:23:34+10:0"); Check ("1980-12-31T11:23:34+10:03x"); end Test_ISO8601_Error; -- ------------------------------ -- Test Is_Same_Day operation. -- ------------------------------ procedure Test_Is_Same_Day (T : in out Test) is procedure Check (D1, D2 : in String; Same_Day : in Boolean); procedure Check (D1, D2 : in String; Same_Day : in Boolean) is T1 : constant Ada.Calendar.Time := ISO8601.Value (D1); T2 : constant Ada.Calendar.Time := ISO8601.Value (D2); begin T.Assert (Same_Day = Is_Same_Day (T1, T2), "Invalid Is_Same_Day for " & D1 & " " & D2); T.Assert (Same_Day = Is_Same_Day (T2, T1), "Invalid Is_Same_Day for " & D2 & " " & D1); end Check; begin Check ("1980-12-31T11:23:34.123", "1980-12-31T10:23:34.123", True); Check ("1980-12-31T11:23:34.123", "1980-12-30T10:23:34.123", False); Check ("1980-12-31T00:00:00", "1980-12-31T23:59:59", True); end Test_Is_Same_Day; -- ------------------------------ -- Test Get_Day_Count operation. -- ------------------------------ procedure Test_Get_Day_Count (T : in out Test) is begin Util.Tests.Assert_Equals (T, 366, Natural (Get_Day_Count (2020))); Util.Tests.Assert_Equals (T, 365, Natural (Get_Day_Count (1983))); Util.Tests.Assert_Equals (T, 366, Natural (Get_Day_Count (2000))); Util.Tests.Assert_Equals (T, 365, Natural (Get_Day_Count (2001))); end Test_Get_Day_Count; end Util.Dates.Tests;
RREE/ada-util
Ada
8,752
adb
----------------------------------------------------------------------- -- util-log-appenders -- Log appenders -- Copyright (C) 2001 - 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar.Formatting; with Ada.Strings; with Ada.Strings.Fixed; with Ada.Unchecked_Deallocation; with Util.Strings.Transforms; package body Util.Log.Appenders is use Ada; use Ada.Finalization; Appender_Factories : Appender_Factory_Access; -- ------------------------------ -- Get the log level that triggers display of the log events -- ------------------------------ function Get_Level (Self : in Appender) return Level_Type is begin return Self.Level; end Get_Level; -- ------------------------------ -- Set the log level. -- ------------------------------ procedure Set_Level (Self : in out Appender; Name : in String; Properties : in Util.Properties.Manager; Level : in Level_Type) is Prop_Name : constant String := "appender." & Name & ".level"; begin if Properties.Exists (Prop_Name) then Self.Level := Get_Level (Properties.Get (Prop_Name), Level); else Self.Level := Level; end if; end Set_Level; procedure Set_Level (Self : in out Appender; Level : in Level_Type) is begin Self.Level := Level; end Set_Level; -- ------------------------------ -- Set the log layout format. -- ------------------------------ procedure Set_Layout (Self : in out Appender; Name : in String; Properties : in Util.Properties.Manager; Layout : in Layout_Type) is use Ada.Strings; use Util.Strings.Transforms; Prop_Name : constant String := "appender." & Name & ".layout"; begin if Properties.Exists (Prop_Name) then declare Value : constant String := To_Lower_Case (Fixed.Trim (Properties.Get (Prop_Name), Both)); begin if Value = "message" then Self.Layout := MESSAGE; elsif Value = "level-message" then Self.Layout := LEVEL_MESSAGE; elsif Value = "date-level-message" or Value = "level-date-message" then Self.Layout := DATE_LEVEL_MESSAGE; else Self.Layout := FULL; end if; end; else Self.Layout := Layout; end if; end Set_Layout; procedure Set_Layout (Self : in out Appender; Layout : in Layout_Type) is begin Self.Layout := Layout; end Set_Layout; -- ------------------------------ -- Format the event into a string -- ------------------------------ function Format (Self : in Appender'Class; Date : in Ada.Calendar.Time; Level : in Level_Type; Logger : in String) return String is begin case Self.Layout is when MESSAGE => return ""; when LEVEL_MESSAGE => return Get_Level_Name (Level) & ": "; when DATE_LEVEL_MESSAGE => return "[" & Calendar.Formatting.Image (Date) & "] " & Get_Level_Name (Level) & ": "; when FULL => return "[" & Calendar.Formatting.Image (Date) & "] " & Get_Level_Name (Level) & " - " & Logger & " - : "; end case; end Format; overriding procedure Append (Self : in out List_Appender; Message : in Util.Strings.Builders.Builder; Date : in Ada.Calendar.Time; Level : in Level_Type; Logger : in String) is begin for I in 1 .. Self.Count loop Self.Appenders (I).Append (Message, Date, Level, Logger); end loop; end Append; -- ------------------------------ -- Flush the log events. -- ------------------------------ overriding procedure Flush (Self : in out List_Appender) is begin for I in 1 .. Self.Count loop Self.Appenders (I).Flush; end loop; end Flush; -- ------------------------------ -- Add the appender to the list. -- ------------------------------ procedure Add_Appender (Self : in out List_Appender; Object : in Appender_Access) is begin if Self.Count < Self.Appenders'Last then Self.Count := Self.Count + 1; Self.Appenders (Self.Count) := Object; end if; end Add_Appender; -- ------------------------------ -- Create a list appender and configure it according to the properties -- ------------------------------ function Create_List_Appender (Name : in String) return List_Appender_Access is Result : constant List_Appender_Access := new List_Appender '(Limited_Controlled with Length => Name'Length, Name => Name, others => <>); begin return Result; end Create_List_Appender; -- ------------------------------ -- Find an appender with a given name from the list of appenders. -- Returns null if there is no such appender. -- ------------------------------ function Find_Appender (List : in Appender_List; Name : in String) return Appender_Access is Appender : Appender_Access := List.First; begin while Appender /= null loop if Appender.Name = Name then return Appender; end if; Appender := Appender.Next; end loop; return null; end Find_Appender; -- ------------------------------ -- Add the appender to the list of appenders. -- ------------------------------ procedure Add_Appender (List : in out Appender_List; Appender : in Appender_Access) is begin Appender.Next := List.First; List.First := Appender; end Add_Appender; -- ------------------------------ -- Clear the list of appenders. -- ------------------------------ procedure Clear (List : in out Appender_List) is procedure Free is new Ada.Unchecked_Deallocation (Object => Appender'Class, Name => Appender_Access); Appender : Appender_Access; begin loop Appender := List.First; exit when Appender = null; List.First := Appender.Next; Free (Appender); end loop; end Clear; -- ------------------------------ -- Register the factory handler to create an appender instance. -- ------------------------------ procedure Register (Into : in Appender_Factory_Access; Name : in String; Create : in Factory_Access) is begin Into.Name := Name; Into.Factory := Create; Into.Next_Factory := Appender_Factories; Appender_Factories := Into; end Register; -- ------------------------------ -- Create an appender instance with a factory with the given name. -- ------------------------------ function Create (Name : in String; Config : in Util.Properties.Manager; Default : in Level_Type) return Appender_Access is Prop_Name : constant String := "appender." & Name; Appender_Type : constant String := Config.Get (Prop_Name, "console"); Factory : Appender_Factory_Access := Appender_Factories; begin while Factory /= null loop if Factory.Name = Appender_Type then return Factory.Factory (Name, Config, Default); end if; Factory := Factory.Next_Factory; end loop; Factory := Appender_Factories; if Factory /= null then return Factory.Factory (Name, Config, Default); end if; return null; end Create; end Util.Log.Appenders;
AdaCore/gpr
Ada
212
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with GPR2.KB; with Ada.Text_IO; procedure Main is begin Ada.Text_IO.Put_Line (String (GPR2.KB.Default_Target)); end Main;
reznikmm/matreshka
Ada
4,081
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Extrusion_Brightness_Attributes; package Matreshka.ODF_Draw.Extrusion_Brightness_Attributes is type Draw_Extrusion_Brightness_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Extrusion_Brightness_Attributes.ODF_Draw_Extrusion_Brightness_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Extrusion_Brightness_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Extrusion_Brightness_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Extrusion_Brightness_Attributes;
reznikmm/slimp
Ada
1,777
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with League.Text_Codecs; with Slim.Message_Visiters; package body Slim.Messages.META is ---------- -- Read -- ---------- overriding function Read (Data : not null access League.Stream_Element_Vectors .Stream_Element_Vector) return META_Message is Value : constant Ada.Streams.Stream_Element_Array := Data.To_Stream_Element_Array; Last : Ada.Streams.Stream_Element_Offset := 0; begin for J in reverse Value'Range loop if Value (J) not in 0 then Last := J; exit; end if; end loop; return Result : META_Message do Result.Value := League.Text_Codecs.Codec_For_Application_Locale.Decode (Value (Value'First .. Last)); end return; end Read; ----------- -- Value -- ----------- not overriding function Value (Self : META_Message) return League.Strings.Universal_String is begin return Self.Value; end Value; ----------- -- Visit -- ----------- overriding procedure Visit (Self : not null access META_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class) is begin Visiter.META (Self); end Visit; ----------- -- Write -- ----------- overriding procedure Write (Self : META_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector) is begin Tag := "META"; Data := League.Text_Codecs.Codec_For_Application_Locale.Encode (Self.Value); end Write; end Slim.Messages.META;
onox/orka
Ada
1,637
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.Rendering.Buffers.Mapped.Unsynchronized is pragma Preelaborate; type Unsynchronized_Mapped_Buffer is new Mapped_Buffer with private; function Create_Buffer (Kind : Orka.Types.Element_Type; Length : Positive; Mode : IO_Mode) return Unsynchronized_Mapped_Buffer with Post => Create_Buffer'Result.Length = Length; procedure Map (Object : in out Unsynchronized_Mapped_Buffer) with Pre => not Object.Mapped, Post => Object.Mapped; procedure Unmap (Object : in out Unsynchronized_Mapped_Buffer) with Pre => Object.Mapped, Post => not Object.Mapped; function Mapped (Object : in out Unsynchronized_Mapped_Buffer) return Boolean; function Buffer (Object : in out Unsynchronized_Mapped_Buffer) return Buffers.Buffer with Pre => not Object.Mapped; private type Unsynchronized_Mapped_Buffer is new Mapped_Buffer with null record; end Orka.Rendering.Buffers.Mapped.Unsynchronized;
AdaCore/langkit
Ada
532
ads
with Langkit_Support.Adalog.Main_Support; package Support is use Langkit_Support.Adalog.Main_Support.Solver_Ifc; use Langkit_Support.Adalog.Main_Support.Refs; type Pred is new N_Predicate_Type with null record; overriding function Call (Dummy : Pred; Vals : Value_Array) return Boolean is (Vals (1) = Vals (2) * 2); overriding function Image (Dummy : Pred) return String is ("Is_Double_Of"); Pred_Singleton : constant Pred := (N => 2, Cache_Set => False, Ref_Count => 1, others => <>); end Support;
Componolit/libsparkcrypto
Ada
8,213
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- @author Alexander Senier -- @date 2019-01-21 -- -- Copyright (C) 2018-2019 Componolit GmbH -- 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 nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.HMAC_SHA256; with LSC.Internal.HMAC_SHA384; with LSC.Internal.HMAC_SHA512; with LSC.Internal.SHA256; with LSC.Internal.SHA512; with LSC.Internal.Convert_HMAC; with LSC.SHA2_Generic; package body LSC.SHA2.HMAC_Generic is ----------------- -- HMAC_SHA256 -- ----------------- function HMAC_SHA256 (Key : Key_Type; Message : Message_Type) return Hash_Type is subtype KIT is Key_Index_Type; subtype Internal_Key_Index is Key_Index_Type range KIT'First .. KIT'Val (KIT'Pos (KIT'First) + 31); subtype Internal_Key_Type is Key_Type (Internal_Key_Index); function Hash_Key is new LSC.SHA2_Generic.Hash_SHA256 (Key_Index_Type, Key_Elem_Type, Key_Type, Internal_Key_Index, Key_Elem_Type, Internal_Key_Type); function HMAC_Internal is new Internal.Convert_HMAC.HMAC_Generic (Block_Len => Internal.SHA256.Block_Size / 8, Hash_Len => 32, Key_Index_Type => Key_Index_Type, Key_Elem_Type => Key_Elem_Type, Key_Type => Key_Type, Message_Index_Type => Message_Index_Type, Message_Elem_Type => Message_Elem_Type, Message_Type => Message_Type, Hash_Index_Type => Hash_Index_Type, Hash_Elem_Type => Hash_Elem_Type, Hash_Type => Hash_Type, Internal_Context_Type => Internal.HMAC_SHA256.Context_Type, Internal_Block_Type => Internal.SHA256.Block_Type, Internal_Block_Length_Type => Internal.SHA256.Block_Length_Type, Internal_Hash_Type => Internal.SHA256.SHA256_Hash_Type, Context_Init => Internal.HMAC_SHA256.Context_Init, Context_Update => Internal.HMAC_SHA256.Context_Update, Context_Finalize => Internal.HMAC_SHA256.Context_Finalize, Get_Auth => Internal.HMAC_SHA256.Get_Prf, Hash_Key => Hash_Key); begin return HMAC_Internal (Key, Message); end HMAC_SHA256; ----------------- -- HMAC_SHA384 -- ----------------- function HMAC_SHA384 (Key : Key_Type; Message : Message_Type) return Hash_Type is subtype KIT is Key_Index_Type; subtype Internal_Key_Index is Key_Index_Type range KIT'First .. KIT'Val (KIT'Pos (KIT'First) + 47); subtype Internal_Key_Type is Key_Type (Internal_Key_Index); function Hash_Key is new LSC.SHA2_Generic.Hash_SHA384 (Key_Index_Type, Key_Elem_Type, Key_Type, Internal_Key_Index, Key_Elem_Type, Internal_Key_Type); function Hash_Key_SHA384 (Key : Key_Type) return Internal_Key_Type is (Hash_Key (Key)); function HMAC_Internal is new Internal.Convert_HMAC.HMAC_Generic (Block_Len => 128, Hash_Len => 48, Key_Index_Type => Key_Index_Type, Key_Elem_Type => Key_Elem_Type, Key_Type => Key_Type, Message_Index_Type => Message_Index_Type, Message_Elem_Type => Message_Elem_Type, Message_Type => Message_Type, Hash_Index_Type => Hash_Index_Type, Hash_Elem_Type => Hash_Elem_Type, Hash_Type => Hash_Type, Internal_Context_Type => Internal.HMAC_SHA384.Context_Type, Internal_Block_Type => Internal.SHA512.Block_Type, Internal_Block_Length_Type => Internal.SHA512.Block_Length_Type, Internal_Hash_Type => Internal.SHA512.SHA384_Hash_Type, Context_Init => Internal.HMAC_SHA384.Context_Init, Context_Update => Internal.HMAC_SHA384.Context_Update, Context_Finalize => Internal.HMAC_SHA384.Context_Finalize, Get_Auth => Internal.HMAC_SHA384.Get_Prf, Hash_Key => Hash_Key_SHA384); begin return HMAC_Internal (Key, Message); end HMAC_SHA384; ----------------- -- HMAC_SHA512 -- ----------------- function HMAC_SHA512 (Key : Key_Type; Message : Message_Type) return Hash_Type is subtype KIT is Key_Index_Type; subtype Internal_Key_Index is Key_Index_Type range KIT'First .. KIT'Val (KIT'Pos (KIT'First) + 63); subtype Internal_Key_Type is Key_Type (Internal_Key_Index); function Hash_Key is new LSC.SHA2_Generic.Hash_SHA512 (Key_Index_Type, Key_Elem_Type, Key_Type, Internal_Key_Index, Key_Elem_Type, Internal_Key_Type); function Hash_Key_SHA512 (Key : Key_Type) return Internal_Key_Type is (Hash_Key (Key)); function HMAC_Internal is new Internal.Convert_HMAC.HMAC_Generic (Block_Len => 128, Hash_Len => 64, Key_Index_Type => Key_Index_Type, Key_Elem_Type => Key_Elem_Type, Key_Type => Key_Type, Message_Index_Type => Message_Index_Type, Message_Elem_Type => Message_Elem_Type, Message_Type => Message_Type, Hash_Index_Type => Hash_Index_Type, Hash_Elem_Type => Hash_Elem_Type, Hash_Type => Hash_Type, Internal_Context_Type => Internal.HMAC_SHA512.Context_Type, Internal_Block_Type => Internal.SHA512.Block_Type, Internal_Block_Length_Type => Internal.SHA512.Block_Length_Type, Internal_Hash_Type => Internal.SHA512.SHA512_Hash_Type, Context_Init => Internal.HMAC_SHA512.Context_Init, Context_Update => Internal.HMAC_SHA512.Context_Update, Context_Finalize => Internal.HMAC_SHA512.Context_Finalize, Get_Auth => Internal.HMAC_SHA512.Get_Prf, Hash_Key => Hash_Key_SHA512); begin return HMAC_Internal (Key, Message); end HMAC_SHA512; end LSC.SHA2.HMAC_Generic;
faelys/natools
Ada
1,150
adb
with Interfaces; use Interfaces; package body Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds is P : constant array (0 .. 5) of Natural := (1, 2, 5, 11, 12, 15); T1 : constant array (0 .. 5) of Unsigned_8 := (3, 35, 48, 42, 15, 1); T2 : constant array (0 .. 5) of Unsigned_8 := (30, 30, 25, 29, 48, 10); G : constant array (0 .. 60) of Unsigned_8 := (0, 0, 0, 0, 0, 22, 0, 0, 12, 11, 0, 0, 0, 0, 0, 0, 13, 5, 0, 26, 17, 0, 0, 6, 9, 0, 0, 0, 0, 10, 0, 24, 0, 0, 0, 0, 7, 6, 28, 16, 23, 0, 0, 4, 28, 7, 21, 0, 8, 1, 9, 2, 0, 1, 5, 29, 0, 0, 3, 19, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 61; F2 := (F2 + Natural (T2 (K)) * J) mod 61; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 30; end Hash; end Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds;
charlie5/lace
Ada
1,356
ads
with float_Math, c_math_c.Vector_2, c_math_c.Vector_3, c_math_c.Matrix_3x3, c_math_c.Matrix_4x4, Interfaces; package c_math_C.Conversion -- -- Provide a set of conversion utilities. -- is package Math renames float_Math; use Interfaces; function "+" (Self : in Integer) return C.int; function "+" (Self : in C.int) return Integer; function "+" (Self : in math .Real) return c_math_c.Real; function "+" (Self : in c_math_c.Real) return math .Real; function "+" (Self : in math .Vector_2) return c_math_c.Vector_2.item; function "+" (Self : in c_math_c.Vector_2.item) return math .Vector_2; function "+" (Self : in math .Vector_3) return c_math_c.Vector_3.item; function "+" (Self : in c_math_c.Vector_3.item) return math .Vector_3; function "+" (Self : in math .Matrix_3x3) return c_math_c.Matrix_3x3.item; function "+" (Self : in c_math_c.Matrix_3x3.item) return math .Matrix_3x3; function "+" (Self : in math .Matrix_4x4) return c_math_c.Matrix_4x4.item; function "+" (Self : in c_math_c.Matrix_4x4.item) return math .Matrix_4x4; function to_Math (Self : in c_math_c.Matrix_4x4.item) return math.Matrix_4x4 renames "+"; end c_math_C.Conversion;
onox/orka
Ada
1,197
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package GL.Types.Colors is pragma Preelaborate; type Color_Index is (R, G, B, A); subtype Component is Single range 0.0 .. 1.0; type Color is array (Color_Index) of aliased Component with Convention => C; type Enabled_Color is array (Color_Index) of Boolean with Convention => C; ----------------------------------------------------------------------------- type Border_Color is (Transparent_Black, Opaque_Black, Opaque_White); -- Table 15 of the Vulkan specification end GL.Types.Colors;
albinjal/ada_basic
Ada
692
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams; procedure Using_Text_Streams is Input, Output : File_Type; Buffer : Character; begin Open (File => Input, Mode => In_File, Name => "REG.BIN"); Create (File => Output, Mode => Out_File, Name => "BSSSSS.txt"); loop Buffer := Character'Input (Stream (Input)); Character'Write (Stream (Output), Buffer); end loop; Close (Input); Close (Output); exception when End_Error => if Is_Open(Input) then Close (Input); end if; if Is_Open(Output) then Close (Output); end if; end Using_Text_Streams;
Rodeo-McCabe/orka
Ada
2,566
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 - 2014 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Types; private with GL.Low_Level; package GL.Rasterization is pragma Preelaborate; use GL.Types; type Polygon_Mode_Type is (Point, Line, Fill); procedure Set_Polygon_Mode (Value : Polygon_Mode_Type); function Polygon_Mode return Polygon_Mode_Type; procedure Set_Polygon_Offset (Factor, Units : Single; Clamp : Single := 0.0); -- Offset the depth values of a polygon -- -- If Clamp /= 0.0 then the resulting offset is clamped. function Polygon_Offset_Factor return Single; function Polygon_Offset_Units return Single; function Polygon_Offset_Clamp return Single; ----------------------------------------------------------------------------- -- Culling -- ----------------------------------------------------------------------------- -- Enable culling by enabling Cull_Face in package GL.Toggles type Orientation is (Clockwise, Counter_Clockwise); type Face_Selector is (Front, Back, Front_And_Back); procedure Set_Front_Face (Face : Orientation); function Front_Face return Orientation; procedure Set_Cull_Face (Selector : Face_Selector); function Cull_Face return Face_Selector; private for Polygon_Mode_Type use (Point => 16#1B00#, Line => 16#1B01#, Fill => 16#1B02#); for Polygon_Mode_Type'Size use Low_Level.Enum'Size; ----------------------------------------------------------------------------- for Orientation use (Clockwise => 16#0900#, Counter_Clockwise => 16#0901#); for Orientation'Size use Low_Level.Enum'Size; for Face_Selector use (Front => 16#0404#, Back => 16#0405#, Front_And_Back => 16#0408#); for Face_Selector'Size use Low_Level.Enum'Size; end GL.Rasterization;
reznikmm/spawn
Ada
4,663
adb
-- -- Copyright (C) 2018-2021, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with Ada.Text_IO; with Ada.Streams; with Spawn.Processes; with Spawn.String_Vectors; with Glib.Application; procedure Spawn_Glib_Test is procedure Activate_Callback (Application : access Glib.Application.Gapplication_Record'Class); package Listeners is type Listener is new Spawn.Processes.Process_Listener with record Stopped : Boolean := False; App : Glib.Application.Gapplication; end record; overriding procedure Standard_Output_Available (Self : in out Listener); overriding procedure Standard_Error_Available (Self : in out Listener); overriding procedure Standard_Input_Available (Self : in out Listener); -- Called once when it's possible to write data again. overriding procedure Started (Self : in out Listener); overriding procedure Finished (Self : in out Listener; Exit_Status : Spawn.Processes.Process_Exit_Status; Exit_Code : Spawn.Processes.Process_Exit_Code); overriding procedure Error_Occurred (Self : in out Listener; Process_Error : Integer); end Listeners; P : Spawn.Processes.Process; L : aliased Listeners.Listener; package body Listeners is overriding procedure Standard_Output_Available (Self : in out Listener) is pragma Unreferenced (Self); use type Ada.Streams.Stream_Element_Offset; Data : Ada.Streams.Stream_Element_Array (1 .. 16); Last : Ada.Streams.Stream_Element_Count; begin Ada.Text_IO.Put_Line ("Standard_Output_Available"); loop P.Read_Standard_Output (Data, Last); exit when Last in 0; for X of Data (1 .. Last) loop Ada.Text_IO.Put (Character'Val (X)); end loop; if Last >= 2 and then Character'Val (Data (1)) = 'O' and then Character'Val (Data (2)) = 'K' then P.Close_Standard_Input; end if; end loop; end Standard_Output_Available; overriding procedure Standard_Error_Available (Self : in out Listener) is pragma Unreferenced (Self); begin Ada.Text_IO.Put_Line ("Standard_Error_Available"); end Standard_Error_Available; overriding procedure Standard_Input_Available (Self : in out Listener) is pragma Unreferenced (Self); Data : constant Ada.Streams.Stream_Element_Array := (1 => Character'Pos ('O'), 2 => Character'Pos ('K'), 3 => 10); Last : Ada.Streams.Stream_Element_Count; begin Ada.Text_IO.Put_Line ("Standard_Input_Available"); P.Write_Standard_Input (Data, Last); end Standard_Input_Available; overriding procedure Started (Self : in out Listener) is pragma Unreferenced (Self); begin Ada.Text_IO.Put_Line ("Started"); end Started; overriding procedure Finished (Self : in out Listener; Exit_Status : Spawn.Processes.Process_Exit_Status; Exit_Code : Spawn.Processes.Process_Exit_Code) is begin Ada.Text_IO.Put_Line ("Finished" & (Exit_Code'Img)); Self.Stopped := True; Self.App.Release; end Finished; overriding procedure Error_Occurred (Self : in out Listener; Process_Error : Integer) is pragma Unreferenced (Self); begin Ada.Text_IO.Put_Line ("Error_Occurred:" & (Process_Error'Img)); end Error_Occurred; end Listeners; ----------------------- -- Activate_Callback -- ----------------------- procedure Activate_Callback (Application : access Glib.Application.Gapplication_Record'Class) is Args : Spawn.String_Vectors.UTF_8_String_Vector; begin L.App := Application.all'Access; Application.Hold; Args.Append ("/tmp/aaa.txt"); -- P.Set_Program ("/bin/echo"); P.Set_Program ("/usr/bin/tee"); P.Set_Arguments (Args); P.Set_Working_Directory ("/tmp"); P.Set_Listener (L'Unchecked_Access); P.Start; end Activate_Callback; App : constant Glib.Application.Gapplication := Glib.Application.Gapplication_New (Flags => Glib.Application.G_Application_Flags_None); X : Glib.Gint; pragma Unreferenced (X); begin App.On_Activate (Activate_Callback'Unrestricted_Access); X := App.Run; end Spawn_Glib_Test;
reznikmm/spawn
Ada
1,120
ads
-- -- Copyright (C) 2022, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- private with Ada.Containers.Hashed_Maps; package Spawn.Polls.POSIX_Polls is type POSIX_Poll is new Poll with private; private type Info is record Events : Watch_Event_Set; Listener : Listener_Access; end record; function Hash (V : Descriptor) return Ada.Containers.Hash_Type is (Ada.Containers.Hash_Type'Mod (V)); package Info_Maps is new Ada.Containers.Hashed_Maps (Descriptor, Info, Hash, Interfaces.C."="); type POSIX_Poll is new Poll with record Initialized : Boolean := False; Map : Info_Maps.Map; end record; overriding function Is_Initialized (Self : POSIX_Poll) return Boolean; overriding procedure Initialize (Self : out POSIX_Poll); overriding procedure Watch (Self : in out POSIX_Poll; Value : Descriptor; Events : Watch_Event_Set; Listener : Listener_Access := null); overriding procedure Wait (Self : in out POSIX_Poll; Timeout : Duration); end Spawn.Polls.POSIX_Polls;
GLADORG/glad-cli
Ada
1,008
ads
with AAA.Strings; private with GNAT.Strings; package Commands.Create is type Command is new Commands.Command with private; overriding function Name (Cmd : Command) return CLIC.Subcommand.Identifier is ("new"); overriding procedure Execute (Cmd : in out Command; Args : AAA.Strings.Vector); overriding function Long_Description (Cmd : Command) return AAA.Strings.Vector is (AAA.Strings.Empty_Vector.Append ("Creates a new directory and runs glad init in it.") .New_Line ); overriding procedure Setup_Switches (Cmd : in out Command; Config : in out CLIC.Subcommand.Switches_Configuration); overriding function Short_Description (Cmd : Command) return String is ("Creates a new directory and runs glad init in it."); overriding function Usage_Custom_Parameters (Cmd : Command) return String is ("[-dry-run]"); private type Command is new Commands.Command with record Dry_Run : aliased Boolean := False; end record; end Commands.Create;
alvaromb/Compilemon
Ada
1,622
ads
with Decls.Dgenerals, Semantica, Decls.Dtdesc, Ada.Sequential_Io, Ada.Text_Io, Decls.D_Taula_De_Noms, Semantica.Ctipus, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps; use Decls.Dgenerals, Semantica, Decls.Dtdesc, Decls.D_Taula_De_Noms, Semantica.Ctipus, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps; package Semantica.Declsc3a is --taula procediments procedure Nouproc (Tp : in out T_Procs; Idp : out num_proc); function Consulta (Tp : in T_Procs; Idp : in num_proc) return Info_Proc; function Consulta (Tv : in T_Vars; Idv : in num_var) return Info_Var; procedure Modif_Descripcio (Tv : in out T_Vars; Idv : in num_var; Iv : in Info_Var); procedure Novavar (Tv : in out T_Vars; Idpr : in num_proc; Idv : out num_var); procedure Novaconst (Tv : in out T_Vars; Vc : in Valor; Tsub : in tipussubjacent; Idpr : in num_proc; Idc : out num_var); --Taula d'etiquetes function Nova_Etiq return num_Etiq; function Etiqueta (Ipr : in Info_Proc) return String; --Fitxers procedure Crea_Fitxer (Nom_Fitxer : in String); procedure Obrir_Fitxer (Nom_Fitxer : in String); procedure Tanca_Fitxer; procedure Llegir_Fitxer (Instruccio : out c3a); procedure Escriure_Fitxer (Instruccio : in c3a); function Fi_Fitxer return Boolean; private package Fitxer_Seq is new Ada.Sequential_Io(c3a); use Fitxer_Seq; F3as : Fitxer_Seq.File_Type; F3at : Ada.Text_Io.File_Type; end Semantica.Declsc3a;
reznikmm/matreshka
Ada
7,235
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides several constants for x86 and x86_64 platform. ------------------------------------------------------------------------------ with Interfaces; with Matreshka.Internals.Utf16; with Matreshka.SIMD.Intel; private package Matreshka.Internals.Strings.Constants is pragma Preelaborate; use type Interfaces.Integer_16; Terminator_Mask_32 : constant array (Matreshka.Internals.Utf16.Utf16_String_Index range 0 .. 1) of Interfaces.Unsigned_32 := (0 => 16#0000_0000#, 1 => 16#0000_FFFF#); -- This mask is used to set unused components of the element to zero on -- 32-bits platforms. Terminator_Mask_64 : constant array (Matreshka.Internals.Utf16.Utf16_String_Index range 0 .. 3) of Interfaces.Unsigned_64 := (0 => 16#0000_0000_0000_0000#, 1 => 16#0000_0000_0000_FFFF#, 2 => 16#0000_0000_FFFF_FFFF#, 3 => 16#0000_FFFF_FFFF_FFFF#); -- This mask is used to set unused components of the element to zero on -- 64-bits platforms. Terminator_Mask_x86_64 : constant array (Matreshka.Internals.Utf16.Utf16_String_Index range 0 .. 7) of Matreshka.SIMD.Intel.v8hi := (0 => ( others => 0), 1 => (1 => -1, others => 0), 2 => (1 .. 2 => -1, others => 0), 3 => (1 .. 3 => -1, others => 0), 4 => (1 .. 4 => -1, others => 0), 5 => (1 .. 5 => -1, others => 0), 6 => (1 .. 6 => -1, others => 0), 7 => (1 .. 7 => -1, others => 0)); -- This mask is used to set unused components of the element to zero on -- x86_64 platforms. Terminator_Mask_AVX : constant array (Matreshka.Internals.Utf16.Utf16_String_Index range 0 .. 15) of Matreshka.SIMD.Intel.v16hi := (0 => ( others => 0), 1 => (1 => -1, others => 0), 2 => (1 .. 2 => -1, others => 0), 3 => (1 .. 3 => -1, others => 0), 4 => (1 .. 4 => -1, others => 0), 5 => (1 .. 5 => -1, others => 0), 6 => (1 .. 6 => -1, others => 0), 7 => (1 .. 7 => -1, others => 0), 8 => (1 .. 8 => -1, others => 0), 9 => (1 .. 9 => -1, others => 0), 10 => (1 .. 10 => -1, others => 0), 11 => (1 .. 11 => -1, others => 0), 12 => (1 .. 12 => -1, others => 0), 13 => (1 .. 13 => -1, others => 0), 14 => (1 .. 14 => -1, others => 0), 15 => (1 .. 15 => -1, others => 0)); -- This mask is used to set unused components of the element to zero on -- platforms where AVX instruction set is supported. Surrogate_Kind_Mask_x86_64 : constant Matreshka.SIMD.Intel.v8hi := (others => -1_024); -- FC00 Masked_High_Surrogate_x86_64 : constant Matreshka.SIMD.Intel.v8hi := (others => -10_240); -- D800 Masked_Low_Surrogate_x86_64 : constant Matreshka.SIMD.Intel.v8hi := (others => -9_216); -- DC00 -- Mask and constants to detect surrogate characters in vector. To detect -- surrogate mask should be applied to vector and result should be compared -- with corresponding constant to detect high or low surrogates in vector. Surrogate_Kind_Mask_AVX : constant Matreshka.SIMD.Intel.v16hi := (others => -1_024); -- FC00 Masked_High_Surrogate_AVX : constant Matreshka.SIMD.Intel.v16hi := (others => -10_240); -- D800 Masked_Low_Surrogate_AVX : constant Matreshka.SIMD.Intel.v16hi := (others => -9_216); -- DC00 -- Mask and constants to detect surrogate characters in vector. To detect -- surrogate mask should be applied to vector and result should be compared -- with corresponding constant to detect high or low surrogates in vector. end Matreshka.Internals.Strings.Constants;
apple-oss-distributions/old_ncurses
Ada
3,783
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Form_Demo.Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms; generic with function My_Driver (Frm : Form; K : Key_Code; Pan : Panel) return Boolean; package Sample.Form_Demo.Handler is procedure Drive_Me (F : in Form; Lin : in Line_Position; Col : in Column_Position; Title : in String := ""); -- Position the menu at the given point and drive it. procedure Drive_Me (F : in Form; Title : in String := ""); -- Center menu and drive it. end Sample.Form_Demo.Handler;
persan/AdaYaml
Ada
735
adb
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Directories; with Ada.Direct_IO; package body Utils is function File_Content (Path : String) return String is File_Size : constant Natural := Natural (Ada.Directories.Size (Path)); subtype File_String is String (1 .. File_Size); package File_String_IO is new Ada.Direct_IO (File_String); File : File_String_IO.File_Type; begin File_String_IO.Open (File, File_String_IO.In_File, Path); return Contents : File_String do File_String_IO.Read (File, Contents); File_String_IO.Close (File); end return; end File_Content; end Utils;
charlie5/aIDE
Ada
4,980
adb
with AdaM.Comment, AdaM.raw_Source, AdaM.a_Type.enumeration_type, Glib, Glib.Error, Glib.Object, Gtk.Builder, Gtk.Handlers, Pango.Font; with Ada.Text_IO; use Ada.Text_IO; package body aIDE.Palette.of_source_entities is use Glib, Glib.Error, Glib.Object, Gtk.Builder, Gtk.Button, Gtk.Window; -- Events -- procedure on_raw_source_Button_clicked (the_Button : access Gtk_Button_Record'Class; Self : in aIDE.Palette.of_source_entities.view) is pragma Unreferenced (the_Button); new_Source : constant AdaM.raw_Source.view := AdaM.raw_Source.new_Source; begin Self.Target.append (new_Source.all'Access); Self.Top.Hide; Self.Invoked_by.freshen; end on_raw_source_Button_clicked; procedure on_comment_Button_clicked (the_Button : access Gtk_Button_Record'Class; Self : in aIDE.Palette.of_source_entities.view) is pragma Unreferenced (the_Button); new_Comment : constant AdaM.Comment.view := AdaM.Comment.new_Comment; begin Self.Target.append (new_Comment.all'Access); Self.Top.Hide; Self.Invoked_by.freshen; end on_comment_Button_clicked; procedure on_enumeration_type_Button_clicked (the_Button : access Gtk_Button_Record'Class; Self : in aIDE.Palette.of_source_entities.view) is pragma Unreferenced (the_Button); new_Enumeration : constant AdaM.a_Type.enumeration_type.view := AdaM.a_Type.enumeration_type.new_Type (""); begin Self.Target.append (new_Enumeration.all'Access); Self.Top.Hide; Self.Invoked_by.freshen; end on_enumeration_type_Button_clicked; package Button_Callbacks is new Gtk.Handlers.User_Callback (Gtk_Button_Record, aIDE.Palette.of_source_entities.view); -- Forge -- function to_source_entities_Palette return View is Self : constant Palette.of_source_entities.view := new Palette.of_source_entities.item; the_Builder : Gtk_Builder; Error : aliased GError; Result : Guint; pragma Unreferenced (Result); begin gtk_New (the_Builder); Result := the_Builder.add_from_File ("glade/source_entity_options.glade", Error'Access); if Error /= null then Put_Line ("Error: 'adam.Palette.of_source_Entities' ~ " & Get_Message (Error)); Error_Free (Error); end if; Self.Top := gtk_Window (the_Builder.get_Object ("top_Window")); Self.new_type_Frame := gtk_Frame (the_Builder.get_Object ("new_type_Frame")); Self.raw_source_Button := gtk_Button (the_Builder.get_Object ("raw_source_Button")); Self.comment_Button := gtk_Button (the_Builder.get_Object ("comment_Button")); Self.enumeration_type_Button := gtk_Button (the_Builder.get_Object ("new_enumeration_Button")); Self.close_Button := gtk_Button (the_Builder.get_Object ("close_Button")); Button_Callbacks.connect (Self.raw_source_Button, "clicked", on_raw_source_Button_clicked'Access, Self); Button_Callbacks.connect (Self.comment_Button, "clicked", on_comment_Button_clicked'Access, Self); Button_Callbacks.connect (Self.enumeration_type_Button, "clicked", on_enumeration_type_Button_clicked'Access, Self); Self.Top.modify_Font (Font_Desc => Pango.Font.From_String ("Courier 10")); Self.freshen; return Self; end to_source_entities_Palette; -- Attributes -- function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget is begin return gtk.Widget.Gtk_Widget (Self.Top); end top_Widget; procedure show (Self : in out Item; Invoked_by : in aIDE.Editor.view; -- Target : in AdaM.Source.Entities_view; Target : in AdaM.Entity.Entities_view; Allowed : in Filter) is begin Self.Invoked_by := Invoked_by; Self.Target := Target; case Allowed is when declare_Region => Self.new_type_Frame.show; when begin_Region => Self.new_type_Frame.hide; end case; Self.Top.show; end show; procedure freshen (Self : in out Item) is begin null; end freshen; end aIDE.Palette.of_source_entities;
VitalijBondarenko/Formatted_Output_NG
Ada
6,714
ads
------------------------------------------------------------------------------ -- -- -- Copyright (c) 2016-2022 Vitalii Bondarenko <[email protected]> -- -- -- ------------------------------------------------------------------------------ -- -- -- The MIT License (MIT) -- -- -- -- 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.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; package Formatted_Output is type Format_Type is private; Empty_Format : constant Format_Type; function To_String (Fmt : Format_Type) return String; -- Convert formatted string to fixed-length string. -- Example: -- Send_To_Terminal (To_String (+"Hello %s\n" & "world")); function "-" (Fmt : Format_Type) return String renames Formatted_Output.To_String; -- Convert formatted string to fixed-length string. function To_Format (Fmt_String : String) return Format_Type; -- Converts String to Format_Type. function "+" (Fmt_String : String) return Format_Type renames Formatted_Output.To_Format; -- Converts String to Format_Type. function "&" (Fmt : Format_Type; Value : String) return Format_Type; -- Replaces leftmost formatting sequence in Fmt with formatted Value -- string, then returns Fmt. Raises exception Format_Error when invalid -- string formatting sequence is found or no formatting sequence found -- at all. -- -- Escape sequences in format strings: -- \n line feed -- \r carriage return -- \b backspace -- \t horizontal tab -- \f form feed -- -- Format sequences for strings: -- -- %[flags][<width>]s -- -- Flag characters can be: -- + The converted value is to be right adjusted on the field boundary. -- (This is default.) -- - The converted value is to be left adjusted on the field boundary. -- (The default is right justification.) -- * The converted value is to be center adjusted on the field boundary. -- (The default is right justification.) -- -- <width> is decimal number specifying minimal field width. procedure Put (Fmt : Format_Type); -- Puts formatted string to console using Ada.Text_IO -- Defined as Ada.Text_IO.Put (To_String (Fmt)); -- Example: -- Put (+"%s %s %s\n" & "Just" & "a" & "test"); procedure Put (File : File_Type; Fmt : Format_Type); -- Puts formatted string to file using Ada.Text_IO -- Defined as Ada.Text_IO.Put (File, To_String (Fmt)); procedure Put_Line (Fmt : Format_Type); -- Puts formatted string to console using Ada.Text_IO procedure Put_Line (File : File_Type; Fmt : Format_Type); -- Puts formatted string to file using Ada.Text_IO Format_Error : exception; -- Format_Error exception raised when bad format detected Filler : constant Character := ' '; -- Filling character, used when padding strings private type Format_Type is new Ada.Strings.Unbounded.Unbounded_String; Empty_Format : constant Format_Type := To_Unbounded_String (""); Maximal_Item_Length : constant := 255; function Scan_To_Percent_Sign (Fmt : Format_Type) return Integer; -- Scans string to the first occurence of percent sign ignoring the double -- percent, returns index of the found sign or zero, if no percent sign is -- found function Decimal_Point_Character return String; function Thousands_Sep_Character return String; Ada_Dec_Point_Character : constant String := "."; Ada_Sep_Character : constant String := "_"; type Digit_Grouping is (None, Ada_Grouping_Style, NLS_Grouping_Style); type Base_Style_Kind is (None, C_Base_Style, Ada_Base_Style); function Separate_Digit_Groups (Text_Value : String; Separator : String; Group_Size : Integer) return String; -- Separate the digit groups for the image without base or decimal value. -- -- Text_Value : Image of the value as a string without leading and trailing -- spaces. -- Separator : The character used to separate groups of digits. -- Group_Size : Size of the group of digits. -- function Separate_Based_Digit_Groups -- (Text_Value : String; -- Separator : String; -- Group_Size : Integer) return String; -- -- Separate the digit groups for the image with base. -- -- -- -- Text_Value : Image of the value as a string without leading and trailing -- -- spaces. -- -- Separator : The character used to separate groups of digits. -- -- Group_Size : Size of the group of digits. function Set_Leading_Zero (Img : String) return String; function Set_Leading_Zero (Img : String; Separator : String; Group_Size : Integer) return String; end Formatted_Output;
reznikmm/matreshka
Ada
3,542
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package OPM.Factories is pragma Pure; type Abstract_Factory is limited interface; type Factory_Access is access all Abstract_Factory'Class with Storage_Size => 0; end OPM.Factories;
strenkml/EE368
Ada
96
ads
with Memory.Super; package Memory.Super_Writes is new Memory.Super(Long_Integer, Get_Writes);
AdaCore/libadalang
Ada
97
adb
package body Foo is package body Bar is procedure Baz is null; end Bar; end Foo;
reznikmm/matreshka
Ada
3,878
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis; with Engines.Contexts; with League.Strings; package Properties.Expressions.Pos_Array_Aggregate is function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String; function Typed_Array_Initialize (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String; end Properties.Expressions.Pos_Array_Aggregate;
RREE/build-avr-ada-toolchain
Ada
3,259
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . P A R A M E T E R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2013, 2016-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. -- -- -- ------------------------------------------------------------------------------ -- This package defines some system dependent parameters for GNAT. These -- are values that are referenced by the runtime library and are therefore -- relevant to the target machine. -- This is the AVR version by AVR-Ada of the package package System.Parameters is pragma Pure; pragma No_Elaboration_Code_All; -- type Size_Type is new Integer; type Size_Type is range -(2 ** (Integer'(Standard'Address_Size) - 1)) .. +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1; Unspecified_Size : constant Size_Type := Size_Type'First; -- Type used to provide task storage size to runtime Runtime_Default_Sec_Stack_Size : constant Size_Type := 256; -- The run-time chosen default size for secondary stacks that may be -- overridden by the user with the use of binder -D switch. -- The GCC-9 binder generates references. end System.Parameters;
AdaCore/Ada-IntelliJ
Ada
149
ads
package @_Project_Name_@ is pragma Pure; Host : constant String := "@_host_@"; Port : constant := @_port_@; end @_Project_Name_@;
Fabien-Chouteau/GESTE
Ada
22,973
ads
pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_SDL_stdinc_h; with System; with Interfaces.C.Extensions; with Interfaces.C.Strings; limited with SDL_SDL_rwops_h; package SDL_SDL_video_h is SDL_ALPHA_OPAQUE : constant := 255; -- ../include/SDL/SDL_video.h:44 SDL_ALPHA_TRANSPARENT : constant := 0; -- ../include/SDL/SDL_video.h:45 -- unsupported macro: SDL_Colour SDL_Color SDL_SWSURFACE : constant := 16#00000000#; -- ../include/SDL/SDL_video.h:131 SDL_HWSURFACE : constant := 16#00000001#; -- ../include/SDL/SDL_video.h:132 SDL_ASYNCBLIT : constant := 16#00000004#; -- ../include/SDL/SDL_video.h:133 SDL_ANYFORMAT : constant := 16#10000000#; -- ../include/SDL/SDL_video.h:138 SDL_HWPALETTE : constant := 16#20000000#; -- ../include/SDL/SDL_video.h:139 SDL_DOUBLEBUF : constant := 16#40000000#; -- ../include/SDL/SDL_video.h:140 SDL_FULLSCREEN : constant := 16#80000000#; -- ../include/SDL/SDL_video.h:141 SDL_OPENGL : constant := 16#00000002#; -- ../include/SDL/SDL_video.h:142 SDL_OPENGLBLIT : constant := 16#0000000A#; -- ../include/SDL/SDL_video.h:143 SDL_RESIZABLE : constant := 16#00000010#; -- ../include/SDL/SDL_video.h:144 SDL_NOFRAME : constant := 16#00000020#; -- ../include/SDL/SDL_video.h:145 SDL_HWACCEL : constant := 16#00000100#; -- ../include/SDL/SDL_video.h:150 SDL_SRCCOLORKEY : constant := 16#00001000#; -- ../include/SDL/SDL_video.h:151 SDL_RLEACCELOK : constant := 16#00002000#; -- ../include/SDL/SDL_video.h:152 SDL_RLEACCEL : constant := 16#00004000#; -- ../include/SDL/SDL_video.h:153 SDL_SRCALPHA : constant := 16#00010000#; -- ../include/SDL/SDL_video.h:154 SDL_PREALLOC : constant := 16#01000000#; -- ../include/SDL/SDL_video.h:155 -- arg-macro: function SDL_MUSTLOCK (surface) -- return surface.offset or else ((surface.flags and (SDL_HWSURFACEorSDL_ASYNCBLITorSDL_RLEACCEL)) /= 0); SDL_YV12_OVERLAY : constant := 16#32315659#; -- ../include/SDL/SDL_video.h:200 SDL_IYUV_OVERLAY : constant := 16#56555949#; -- ../include/SDL/SDL_video.h:201 SDL_YUY2_OVERLAY : constant := 16#32595559#; -- ../include/SDL/SDL_video.h:202 SDL_UYVY_OVERLAY : constant := 16#59565955#; -- ../include/SDL/SDL_video.h:203 SDL_YVYU_OVERLAY : constant := 16#55595659#; -- ../include/SDL/SDL_video.h:204 SDL_LOGPAL : constant := 16#01#; -- ../include/SDL/SDL_video.h:252 SDL_PHYSPAL : constant := 16#02#; -- ../include/SDL/SDL_video.h:253 -- unsupported macro: SDL_AllocSurface SDL_CreateRGBSurface -- arg-macro: procedure SDL_LoadBMP (file) -- SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) -- arg-macro: procedure SDL_SaveBMP (surface, file) -- SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) -- unsupported macro: SDL_BlitSurface SDL_UpperBlit type SDL_Rect is record x : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_video.h:51 y : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_video.h:51 w : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_video.h:52 h : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_video.h:52 end record; pragma Convention (C_Pass_By_Copy, SDL_Rect); -- ../include/SDL/SDL_video.h:50 type SDL_Color is record r : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:56 g : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:57 b : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:58 unused : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:59 end record; pragma Convention (C_Pass_By_Copy, SDL_Color); -- ../include/SDL/SDL_video.h:55 type SDL_Palette is record ncolors : aliased int; -- ../include/SDL/SDL_video.h:64 colors : access SDL_Color; -- ../include/SDL/SDL_video.h:65 end record; pragma Convention (C_Pass_By_Copy, SDL_Palette); -- ../include/SDL/SDL_video.h:63 type SDL_PixelFormat is record palette : access SDL_Palette; -- ../include/SDL/SDL_video.h:71 BitsPerPixel : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:72 BytesPerPixel : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:73 Rloss : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:74 Gloss : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:75 Bloss : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:76 Aloss : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:77 Rshift : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:78 Gshift : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:79 Bshift : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:80 Ashift : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:81 Rmask : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:82 Gmask : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:83 Bmask : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:84 Amask : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:85 colorkey : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:88 alpha : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_video.h:90 end record; pragma Convention (C_Pass_By_Copy, SDL_PixelFormat); -- ../include/SDL/SDL_video.h:70 type SDL_Surface is record flags : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:97 format : access SDL_PixelFormat; -- ../include/SDL/SDL_video.h:98 w : aliased int; -- ../include/SDL/SDL_video.h:99 h : aliased int; -- ../include/SDL/SDL_video.h:99 pitch : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_video.h:100 pixels : System.Address; -- ../include/SDL/SDL_video.h:101 offset : aliased int; -- ../include/SDL/SDL_video.h:102 hwdata : System.Address; -- ../include/SDL/SDL_video.h:105 clip_rect : aliased SDL_Rect; -- ../include/SDL/SDL_video.h:108 unused1 : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:109 locked : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:112 map : System.Address; -- ../include/SDL/SDL_video.h:115 format_version : aliased unsigned; -- ../include/SDL/SDL_video.h:118 refcount : aliased int; -- ../include/SDL/SDL_video.h:121 end record; pragma Convention (C_Pass_By_Copy, SDL_Surface); -- ../include/SDL/SDL_video.h:96 -- skipped empty struct private_hwdata -- skipped empty struct SDL_BlitMap type SDL_blit is access function (arg1 : access SDL_Surface; arg2 : access SDL_Rect; arg3 : access SDL_Surface; arg4 : access SDL_Rect) return int; pragma Convention (C, SDL_blit); -- ../include/SDL/SDL_video.h:166 type SDL_VideoInfo is record hw_available : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:172 wm_available : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:173 UnusedBits1 : Extensions.Unsigned_6; -- ../include/SDL/SDL_video.h:174 UnusedBits2 : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:175 blit_hw : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:176 blit_hw_CC : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:177 blit_hw_A : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:178 blit_sw : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:179 blit_sw_CC : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:180 blit_sw_A : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:181 blit_fill : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:182 UnusedBits3 : aliased unsigned_short; -- ../include/SDL/SDL_video.h:183 video_mem : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:184 vfmt : access SDL_PixelFormat; -- ../include/SDL/SDL_video.h:185 current_w : aliased int; -- ../include/SDL/SDL_video.h:186 current_h : aliased int; -- ../include/SDL/SDL_video.h:187 end record; pragma Convention (C_Pass_By_Copy, SDL_VideoInfo); pragma Pack (SDL_VideoInfo); -- ../include/SDL/SDL_video.h:171 type SDL_Overlay is record format : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:209 w : aliased int; -- ../include/SDL/SDL_video.h:210 h : aliased int; -- ../include/SDL/SDL_video.h:210 planes : aliased int; -- ../include/SDL/SDL_video.h:211 pitches : access SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_video.h:212 pixels : System.Address; -- ../include/SDL/SDL_video.h:213 hwfuncs : System.Address; -- ../include/SDL/SDL_video.h:217 hwdata : System.Address; -- ../include/SDL/SDL_video.h:218 hw_overlay : Extensions.Unsigned_1; -- ../include/SDL/SDL_video.h:223 UnusedBits : Extensions.Unsigned_31; -- ../include/SDL/SDL_video.h:224 end record; pragma Convention (C_Pass_By_Copy, SDL_Overlay); pragma Pack (SDL_Overlay); -- ../include/SDL/SDL_video.h:208 -- skipped empty struct private_yuvhwfuncs -- skipped empty struct private_yuvhwdata type SDL_GLattr is (SDL_GL_RED_SIZE, SDL_GL_GREEN_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_DEPTH_SIZE, SDL_GL_STENCIL_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ACCUM_GREEN_SIZE, SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_STEREO, SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES, SDL_GL_ACCELERATED_VISUAL, SDL_GL_SWAP_CONTROL); pragma Convention (C, SDL_GLattr); -- ../include/SDL/SDL_video.h:248 function SDL_VideoInit (driver_name : Interfaces.C.Strings.chars_ptr; flags : SDL_SDL_stdinc_h.Uint32) return int; -- ../include/SDL/SDL_video.h:275 pragma Import (C, SDL_VideoInit, "SDL_VideoInit"); procedure SDL_VideoQuit; -- ../include/SDL/SDL_video.h:276 pragma Import (C, SDL_VideoQuit, "SDL_VideoQuit"); function SDL_VideoDriverName (namebuf : Interfaces.C.Strings.chars_ptr; maxlen : int) return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_video.h:284 pragma Import (C, SDL_VideoDriverName, "SDL_VideoDriverName"); function SDL_GetVideoSurface return access SDL_Surface; -- ../include/SDL/SDL_video.h:292 pragma Import (C, SDL_GetVideoSurface, "SDL_GetVideoSurface"); function SDL_GetVideoInfo return System.Address; -- ../include/SDL/SDL_video.h:300 pragma Import (C, SDL_GetVideoInfo, "SDL_GetVideoInfo"); function SDL_VideoModeOK (width : int; height : int; bpp : int; flags : SDL_SDL_stdinc_h.Uint32) return int; -- ../include/SDL/SDL_video.h:313 pragma Import (C, SDL_VideoModeOK, "SDL_VideoModeOK"); function SDL_ListModes (format : access SDL_PixelFormat; flags : SDL_SDL_stdinc_h.Uint32) return System.Address; -- ../include/SDL/SDL_video.h:324 pragma Import (C, SDL_ListModes, "SDL_ListModes"); function SDL_SetVideoMode (width : int; height : int; bpp : int; flags : SDL_SDL_stdinc_h.Uint32) return access SDL_Surface; -- ../include/SDL/SDL_video.h:384 pragma Import (C, SDL_SetVideoMode, "SDL_SetVideoMode"); procedure SDL_UpdateRects (screen : access SDL_Surface; numrects : int; rects : access SDL_Rect); -- ../include/SDL/SDL_video.h:394 pragma Import (C, SDL_UpdateRects, "SDL_UpdateRects"); procedure SDL_UpdateRect (screen : access SDL_Surface; x : SDL_SDL_stdinc_h.Sint32; y : SDL_SDL_stdinc_h.Sint32; w : SDL_SDL_stdinc_h.Uint32; h : SDL_SDL_stdinc_h.Uint32); -- ../include/SDL/SDL_video.h:400 pragma Import (C, SDL_UpdateRect, "SDL_UpdateRect"); function SDL_Flip (screen : access SDL_Surface) return int; -- ../include/SDL/SDL_video.h:414 pragma Import (C, SDL_Flip, "SDL_Flip"); function SDL_SetGamma (red : float; green : float; blue : float) return int; -- ../include/SDL/SDL_video.h:424 pragma Import (C, SDL_SetGamma, "SDL_SetGamma"); function SDL_SetGammaRamp (red : access SDL_SDL_stdinc_h.Uint16; green : access SDL_SDL_stdinc_h.Uint16; blue : access SDL_SDL_stdinc_h.Uint16) return int; -- ../include/SDL/SDL_video.h:438 pragma Import (C, SDL_SetGammaRamp, "SDL_SetGammaRamp"); function SDL_GetGammaRamp (red : access SDL_SDL_stdinc_h.Uint16; green : access SDL_SDL_stdinc_h.Uint16; blue : access SDL_SDL_stdinc_h.Uint16) return int; -- ../include/SDL/SDL_video.h:449 pragma Import (C, SDL_GetGammaRamp, "SDL_GetGammaRamp"); function SDL_SetColors (surface : access SDL_Surface; colors : access SDL_Color; firstcolor : int; ncolors : int) return int; -- ../include/SDL/SDL_video.h:466 pragma Import (C, SDL_SetColors, "SDL_SetColors"); function SDL_SetPalette (surface : access SDL_Surface; flags : int; colors : access SDL_Color; firstcolor : int; ncolors : int) return int; -- ../include/SDL/SDL_video.h:485 pragma Import (C, SDL_SetPalette, "SDL_SetPalette"); function SDL_MapRGB (format : access SDL_PixelFormat; r : SDL_SDL_stdinc_h.Uint8; g : SDL_SDL_stdinc_h.Uint8; b : SDL_SDL_stdinc_h.Uint8) return SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:492 pragma Import (C, SDL_MapRGB, "SDL_MapRGB"); function SDL_MapRGBA (format : System.Address; r : SDL_SDL_stdinc_h.Uint8; g : SDL_SDL_stdinc_h.Uint8; b : SDL_SDL_stdinc_h.Uint8; a : SDL_SDL_stdinc_h.Uint8) return SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_video.h:499 pragma Import (C, SDL_MapRGBA, "SDL_MapRGBA"); procedure SDL_GetRGB (pixel : SDL_SDL_stdinc_h.Uint32; fmt : System.Address; r : access SDL_SDL_stdinc_h.Uint8; g : access SDL_SDL_stdinc_h.Uint8; b : access SDL_SDL_stdinc_h.Uint8); -- ../include/SDL/SDL_video.h:506 pragma Import (C, SDL_GetRGB, "SDL_GetRGB"); procedure SDL_GetRGBA (pixel : SDL_SDL_stdinc_h.Uint32; fmt : System.Address; r : access SDL_SDL_stdinc_h.Uint8; g : access SDL_SDL_stdinc_h.Uint8; b : access SDL_SDL_stdinc_h.Uint8; a : access SDL_SDL_stdinc_h.Uint8); -- ../include/SDL/SDL_video.h:513 pragma Import (C, SDL_GetRGBA, "SDL_GetRGBA"); function SDL_CreateRGBSurface (flags : SDL_SDL_stdinc_h.Uint32; width : int; height : int; depth : int; Rmask : SDL_SDL_stdinc_h.Uint32; Gmask : SDL_SDL_stdinc_h.Uint32; Bmask : SDL_SDL_stdinc_h.Uint32; Amask : SDL_SDL_stdinc_h.Uint32) return access SDL_Surface; -- ../include/SDL/SDL_video.h:553 pragma Import (C, SDL_CreateRGBSurface, "SDL_CreateRGBSurface"); function SDL_CreateRGBSurfaceFrom (pixels : System.Address; width : int; height : int; depth : int; pitch : int; Rmask : SDL_SDL_stdinc_h.Uint32; Gmask : SDL_SDL_stdinc_h.Uint32; Bmask : SDL_SDL_stdinc_h.Uint32; Amask : SDL_SDL_stdinc_h.Uint32) return access SDL_Surface; -- ../include/SDL/SDL_video.h:557 pragma Import (C, SDL_CreateRGBSurfaceFrom, "SDL_CreateRGBSurfaceFrom"); procedure SDL_FreeSurface (surface : access SDL_Surface); -- ../include/SDL/SDL_video.h:560 pragma Import (C, SDL_FreeSurface, "SDL_FreeSurface"); function SDL_LockSurface (surface : access SDL_Surface) return int; -- ../include/SDL/SDL_video.h:580 pragma Import (C, SDL_LockSurface, "SDL_LockSurface"); procedure SDL_UnlockSurface (surface : access SDL_Surface); -- ../include/SDL/SDL_video.h:581 pragma Import (C, SDL_UnlockSurface, "SDL_UnlockSurface"); function SDL_LoadBMP_RW (src : access SDL_SDL_rwops_h.SDL_RWops; freesrc : int) return access SDL_Surface; -- ../include/SDL/SDL_video.h:589 pragma Import (C, SDL_LoadBMP_RW, "SDL_LoadBMP_RW"); function SDL_SaveBMP_RW (surface : access SDL_Surface; dst : access SDL_SDL_rwops_h.SDL_RWops; freedst : int) return int; -- ../include/SDL/SDL_video.h:599 pragma Import (C, SDL_SaveBMP_RW, "SDL_SaveBMP_RW"); function SDL_SetColorKey (surface : access SDL_Surface; flag : SDL_SDL_stdinc_h.Uint32; key : SDL_SDL_stdinc_h.Uint32) return int; -- ../include/SDL/SDL_video.h:615 pragma Import (C, SDL_SetColorKey, "SDL_SetColorKey"); function SDL_SetAlpha (surface : access SDL_Surface; flag : SDL_SDL_stdinc_h.Uint32; alpha : SDL_SDL_stdinc_h.Uint8) return int; -- ../include/SDL/SDL_video.h:633 pragma Import (C, SDL_SetAlpha, "SDL_SetAlpha"); function SDL_SetClipRect (surface : access SDL_Surface; rect : System.Address) return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_video.h:647 pragma Import (C, SDL_SetClipRect, "SDL_SetClipRect"); procedure SDL_GetClipRect (surface : access SDL_Surface; rect : access SDL_Rect); -- ../include/SDL/SDL_video.h:654 pragma Import (C, SDL_GetClipRect, "SDL_GetClipRect"); function SDL_ConvertSurface (src : access SDL_Surface; fmt : access SDL_PixelFormat; flags : SDL_SDL_stdinc_h.Uint32) return access SDL_Surface; -- ../include/SDL/SDL_video.h:668 pragma Import (C, SDL_ConvertSurface, "SDL_ConvertSurface"); function SDL_UpperBlit (src : access SDL_Surface; srcrect : access SDL_Rect; dst : access SDL_Surface; dstrect : access SDL_Rect) return int; -- ../include/SDL/SDL_video.h:748 pragma Import (C, SDL_UpperBlit, "SDL_UpperBlit"); function SDL_LowerBlit (src : access SDL_Surface; srcrect : access SDL_Rect; dst : access SDL_Surface; dstrect : access SDL_Rect) return int; -- ../include/SDL/SDL_video.h:754 pragma Import (C, SDL_LowerBlit, "SDL_LowerBlit"); function SDL_FillRect (dst : access SDL_Surface; dstrect : access SDL_Rect; color : SDL_SDL_stdinc_h.Uint32) return int; -- ../include/SDL/SDL_video.h:767 pragma Import (C, SDL_FillRect, "SDL_FillRect"); function SDL_DisplayFormat (surface : access SDL_Surface) return access SDL_Surface; -- ../include/SDL/SDL_video.h:781 pragma Import (C, SDL_DisplayFormat, "SDL_DisplayFormat"); function SDL_DisplayFormatAlpha (surface : access SDL_Surface) return access SDL_Surface; -- ../include/SDL/SDL_video.h:795 pragma Import (C, SDL_DisplayFormatAlpha, "SDL_DisplayFormatAlpha"); function SDL_CreateYUVOverlay (width : int; height : int; format : SDL_SDL_stdinc_h.Uint32; display : access SDL_Surface) return access SDL_Overlay; -- ../include/SDL/SDL_video.h:807 pragma Import (C, SDL_CreateYUVOverlay, "SDL_CreateYUVOverlay"); function SDL_LockYUVOverlay (overlay : access SDL_Overlay) return int; -- ../include/SDL/SDL_video.h:811 pragma Import (C, SDL_LockYUVOverlay, "SDL_LockYUVOverlay"); procedure SDL_UnlockYUVOverlay (overlay : access SDL_Overlay); -- ../include/SDL/SDL_video.h:812 pragma Import (C, SDL_UnlockYUVOverlay, "SDL_UnlockYUVOverlay"); function SDL_DisplayYUVOverlay (overlay : access SDL_Overlay; dstrect : access SDL_Rect) return int; -- ../include/SDL/SDL_video.h:820 pragma Import (C, SDL_DisplayYUVOverlay, "SDL_DisplayYUVOverlay"); procedure SDL_FreeYUVOverlay (overlay : access SDL_Overlay); -- ../include/SDL/SDL_video.h:823 pragma Import (C, SDL_FreeYUVOverlay, "SDL_FreeYUVOverlay"); function SDL_GL_LoadLibrary (path : Interfaces.C.Strings.chars_ptr) return int; -- ../include/SDL/SDL_video.h:837 pragma Import (C, SDL_GL_LoadLibrary, "SDL_GL_LoadLibrary"); function SDL_GL_GetProcAddress (proc : Interfaces.C.Strings.chars_ptr) return System.Address; -- ../include/SDL/SDL_video.h:842 pragma Import (C, SDL_GL_GetProcAddress, "SDL_GL_GetProcAddress"); function SDL_GL_SetAttribute (attr : SDL_GLattr; value : int) return int; -- ../include/SDL/SDL_video.h:847 pragma Import (C, SDL_GL_SetAttribute, "SDL_GL_SetAttribute"); function SDL_GL_GetAttribute (attr : SDL_GLattr; value : access int) return int; -- ../include/SDL/SDL_video.h:858 pragma Import (C, SDL_GL_GetAttribute, "SDL_GL_GetAttribute"); procedure SDL_GL_SwapBuffers; -- ../include/SDL/SDL_video.h:863 pragma Import (C, SDL_GL_SwapBuffers, "SDL_GL_SwapBuffers"); procedure SDL_GL_UpdateRects (numrects : int; rects : access SDL_Rect); -- ../include/SDL/SDL_video.h:870 pragma Import (C, SDL_GL_UpdateRects, "SDL_GL_UpdateRects"); procedure SDL_GL_Lock; -- ../include/SDL/SDL_video.h:871 pragma Import (C, SDL_GL_Lock, "SDL_GL_Lock"); procedure SDL_GL_Unlock; -- ../include/SDL/SDL_video.h:872 pragma Import (C, SDL_GL_Unlock, "SDL_GL_Unlock"); procedure SDL_WM_SetCaption (title : Interfaces.C.Strings.chars_ptr; icon : Interfaces.C.Strings.chars_ptr); -- ../include/SDL/SDL_video.h:885 pragma Import (C, SDL_WM_SetCaption, "SDL_WM_SetCaption"); procedure SDL_WM_GetCaption (title : System.Address; icon : System.Address); -- ../include/SDL/SDL_video.h:889 pragma Import (C, SDL_WM_GetCaption, "SDL_WM_GetCaption"); procedure SDL_WM_SetIcon (icon : access SDL_Surface; mask : access SDL_SDL_stdinc_h.Uint8); -- ../include/SDL/SDL_video.h:897 pragma Import (C, SDL_WM_SetIcon, "SDL_WM_SetIcon"); function SDL_WM_IconifyWindow return int; -- ../include/SDL/SDL_video.h:904 pragma Import (C, SDL_WM_IconifyWindow, "SDL_WM_IconifyWindow"); function SDL_WM_ToggleFullScreen (surface : access SDL_Surface) return int; -- ../include/SDL/SDL_video.h:921 pragma Import (C, SDL_WM_ToggleFullScreen, "SDL_WM_ToggleFullScreen"); subtype SDL_GrabMode is unsigned; SDL_GRAB_QUERY : constant SDL_GrabMode := -1; SDL_GRAB_OFF : constant SDL_GrabMode := 0; SDL_GRAB_ON : constant SDL_GrabMode := 1; SDL_GRAB_FULLSCREEN : constant SDL_GrabMode := 2; -- ../include/SDL/SDL_video.h:928 function SDL_WM_GrabInput (mode : SDL_GrabMode) return SDL_GrabMode; -- ../include/SDL/SDL_video.h:937 pragma Import (C, SDL_WM_GrabInput, "SDL_WM_GrabInput"); function SDL_SoftStretch (src : access SDL_Surface; srcrect : access SDL_Rect; dst : access SDL_Surface; dstrect : access SDL_Rect) return int; -- ../include/SDL/SDL_video.h:942 pragma Import (C, SDL_SoftStretch, "SDL_SoftStretch"); end SDL_SDL_video_h;
OneWingedShark/Byron
Ada
8,246
adb
with Lexington, Byron.Internals.Expressions.Instances, System.Address_To_Access_Conversions, Ada.Tags.Generic_Dispatching_Constructor; WITH -- DEBUGGING Debug.Functions, Ada.Exceptions.Traceback; Package Body Byron.Internals.Parslets is Procedure DEBUG( Msg : Wide_Wide_String ) renames Debug_Package.Put_Line; Function DEBUG( Msg : Wide_Wide_String ) return Boolean is begin return Result : constant Boolean := True do Debug( Msg ); end return; end DEBUG; Function Create(Tokens : aliased Lexington.Token_Vector_Pkg.Vector) return Parser is ( Parser'(Stream => new Lexington.Token_Vector_Pkg.Vector'(Tokens), others => <>) ); Package Parser_Conversions is new System.Address_To_Access_Conversions ( Object => Parser ); -- Make creates an Infix-parselet from the given tag and parser. Function MAKE_PARSLET is new Ada.Tags.Generic_Dispatching_Constructor( T => Abstract_Parslet, Parameters => Parser, Constructor => Create ); -- Make creates an Infix-parselet from the given tag and parser. Function Make is new Ada.Tags.Generic_Dispatching_Constructor( T => Infix, Parameters => Parser, Constructor => Create ); -- Make creates a Prefix-parselet from the given tag and parser. Function Make is new Ada.Tags.Generic_Dispatching_Constructor( T => Prefix, Parameters => Parser, Constructor => Create ); -- Create is a wrapper to Make, presenting a better interface to the public. Function Create( Parser : in out Parslets.Parser; Tag : in Ada.Tags.Tag ) return Infix'Class is ( Make(Tag, Parser_Conversions.To_Pointer(Parser'Address)) ); Function Create( Parser : in out Parslets.Parser; Tag : in Ada.Tags.Tag ) return Prefix'Class is ( Make(Tag, Parser_Conversions.To_Pointer(Parser'Address)) ); Procedure Register( Parser : in out Parslets.Parser; Token : in Aux.Token_ID; Tag : in Ada.Tags.Tag; Infix : in Boolean ) is -- Returns True when the set of interface-ancestors of Tag contain -- Ancestor_Tag and Flase when it does not. Function Check_Tag( Tag, Ancestor_Tag : Ada.Tags.Tag ) return Boolean is Use Ada.Tags; Ancestors : Tag_Array renames Interface_Ancestor_Tags(Tag); Begin Return Result : Boolean := (for some Item of Ancestors => Item = Ancestor_Tag); End Check_Tag; Procedure Check_Tag( Ancestor_Tag : Ada.Tags.Tag ) is This : String renames Ada.Tags.Expanded_Name(Tag); Ancestor : String renames Ada.Tags.Expanded_Name(Ancestor_Tag); Begin declare Pragma Assert( Check_Tag(Tag, Ancestor_Tag), "Could not register: " & This & " does not implement " & Ancestor ); begin null; end; exception when others => Null; End Check_Tag; Begin Check_Tag(if Infix then Parslets.Infix'Tag else Parslets.Prefix'Tag); if Infix then Parser.InFix_Parslets.Insert(Key => Token, New_Item => Tag); else Parser.Prefix_Parslets.Insert(Key => Token, New_Item => Tag); end if; End Register; -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Function Last( Input : Parser ) Return Aux.Token is -- (Input.Stream.All(Input.Current_Index)); -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- Function Parse( Parser : in out Parslets.Parser; Precedence : in Natural := 0 ) return PE.Expression'Class is Next : Aux.Token renames Consume(Parser); Next_ID : Aux.Token_ID renames Aux.Token_Pkg.ID(Next); use PE; begin -- DEBUG( "Parsing Token:" & Aux.Token_Pkg.Print(Next) ); Debug("AAAAA"); if not Parser.Prefix_Parslets.Contains( Next_ID ) then DEBUG( Aux.Token_ID'Wide_Wide_Image(Next_ID) & "" ); end if; declare use Expressions.Instances; Next_Tag : Ada.Tags.Tag renames Parser.Prefix_Parslets(Next_ID); Prefix_Parselet : Prefix'Class renames Create(Parser, Next_Tag); Count : Positive:= Positive'First; --Parser.Prefix_Parslets(Next_ID); Left : Holder := "+"(Prefix_Parselet.Parse(Parser, Next)); -- access Expression'Class := new Expression'Class'(Prefix_Parselet.Parse(Parser, Next)); begin Debug("BBBBB"); Debug("Precdence:" & Integer'Wide_Wide_Image(Parslets.Precedence(Parser))); while (Precedence < Parslets.Precedence(Parser)) loop DEBUG( Positive'Wide_Wide_Image( Count ) ); Count:= Count + 1; declare Tk : Aux.Token renames Consume(Parser); Tk_ID : Aux.Token_ID renames Aux.Token_Pkg.ID( Tk ); Tag : Ada.Tags.Tag renames Parser.Infix_Parslets(Tk_ID); Infix_Parselet : Infix'Class renames Create(Parser, Tag); begin Left:= +Infix_Parselet.Parse(Parser, Left.Element, Tk); -- new Expression'Class'(Infix_Parselet.Parse( Parser, Left.all, Tk )); end; end loop; return Result : PE.Expression'Class := +Left do Debug("CCCCC"); declare SS : Aux.Token renames Consume(Parser); begin null; end; end return; -- Exception -- when E : Constraint_Error => -- raise Constraint_Error with -- Ada.Exceptions.Exception_Message(E) & -- " -- Key: " & Aux.Token_ID'Image(Next_ID); end; exception when E : others => DEBUG("XXXXX -- " & Ada.Exceptions.Wide_Wide_Exception_Name(E)); DEBUG( Msg => Aux.Token_Pkg.Print(Next) ); Ada.Exceptions.Reraise_Occurrence( E ); end Parse; Function Match(Parser : in out Parslets.Parser; Expected : in Aux.Token_ID ) return Boolean is Next : Aux.Token renames Look_Ahead(Parser, 0); use type Aux.Token_ID; Begin if Aux.Token_Pkg.ID(Next) /= Expected then return False; else declare Item : constant Aux.Token := Consume(Parser); begin return True; end; end if; End Match; Function Consume(Parser : in out Parslets.Parser; Expected : in Aux.Token_ID ) Return Aux.Token is use all type Aux.Token_ID; Item : Token renames Look_Ahead(Parser, 0); Begin if Aux.Token_Pkg.ID(Item) /= Expected then declare Use Aux, Aux.Token_Pkg; Res_ID : Token_ID renames ID(Item); Exp_Img : String renames Token_ID'Image(Expected); Res_Img : String renames Token_ID'Image(Res_ID); begin Raise Program_Error with Exp_Img &" expected, but "& Res_Img &" was found."; end; end if; Return Consume(Parser); End Consume; Function Consume(Parser : in out Parslets.Parser) Return Aux.Token is Begin Look_Ahead(Parser, 0); return Result : constant Aux.Token:= Parser.Buffer.Last_Element do Parser.Buffer.Delete_Last; end return; End Consume; Function Look_Ahead(Parser : in out Parslets.Parser; Distance : Natural ) return Aux.Token is Begin Look_Ahead(Parser, Distance); Return Parser.Buffer( Parser.Buffer.First_Index + Distance ); End Look_Ahead; Function Look_Ahead(Parser : in out Parslets.Parser; Distance : Natural ) return Aux.Token_ID is ( Aux.Token_Pkg.ID( Look_Ahead(Parser, Distance) ) ); Procedure Look_Ahead(Parser : in out Parslets.Parser; Distance : Natural ) is Begin while (Distance >= Natural(Parser.Buffer.Length)) loop Parser.Buffer.Append( Next_Token(Parser) ); end loop; End Look_Ahead; Function Next_Token(Input : in out Parser) return Aux.Token is Begin if Input.Stream.Is_Empty then Return Aux.Null_Token; else Return Token : Constant Aux.Token := Input.Stream.First_Element do Input.Stream.All.Delete_First; End Return; end if; End Next_Token; Function Precedence(Parser : in out Parslets.Parser) return Natural is Next_Type : Aux.Token_ID renames Look_Ahead(Parser, 0); Begin Return (if Parser.Infix_Parslets.Contains( Next_Type ) then Infix'Class'(Create(Parser,Parser.Infix_Parslets(Next_Type))).Precedence else 0 ); End Precedence; End Byron.Internals.Parslets;
tj800x/SPARKNaCl
Ada
4,196
ads
with SPARKNaCl.Core; with SPARKNaCl.Stream; package SPARKNaCl.Cryptobox with SPARK_Mode => On is -------------------------------------------------------- -- Public Key Authenticated Encryption - "Crypto Box" -- -------------------------------------------------------- -- Limited, so no assignment or comparison, and always -- pass-by-reference. type Secret_Key is limited private; type Public_Key is limited private; Plaintext_Zero_Bytes : constant := 32; Ciphertext_Zero_Bytes : constant := 16; -- Key generation procedure Keypair (PK : out Public_Key; SK : out Secret_Key) with Global => Random.Entropy; function Construct (K : in Bytes_32) return Secret_Key with Global => null; function Construct (K : in Bytes_32) return Public_Key with Global => null; function Serialize (K : in Secret_Key) return Bytes_32 with Global => null; function Serialize (K : in Public_Key) return Bytes_32 with Global => null; -- Sanitization procedure Sanitize (K : out Secret_Key) with Global => null; procedure Sanitize (K : out Public_Key) with Global => null; -- Precomputation procedure BeforeNM (K : out Core.Salsa20_Key; PK : in Public_Key; SK : in Secret_Key) with Global => null; -- Postcomputation for Create procedure AfterNM (C : out Byte_Seq; Status : out Boolean; M : in Byte_Seq; N : in Stream.HSalsa20_Nonce; K : in Core.Salsa20_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and C'Last = M'Last and M'Length >= 32) and then Equal (M (0 .. 31), Zero_Bytes_32), Post => Equal (C (0 .. 15), Zero_Bytes_16); -- Postcomputation for Open procedure Open_AfterNM (M : out Byte_Seq; -- Output plaintext Status : out Boolean; C : in Byte_Seq; -- Input ciphertext N : in Stream.HSalsa20_Nonce; K : in Core.Salsa20_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and M'Last = C'Last and C'Length >= 32) and then Equal (C (0 .. 15), Zero_Bytes_16), Post => Equal (M (0 .. 31), Zero_Bytes_32); -- Top-level all-in-one Create operation procedure Create (C : out Byte_Seq; Status : out Boolean; M : in Byte_Seq; N : in Stream.HSalsa20_Nonce; Recipient_PK : in Public_Key; Sender_SK : in Secret_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and C'Last = M'Last and M'Length >= 32) and then Equal (M (0 .. 31), Zero_Bytes_32), Post => Equal (C (0 .. 15), Zero_Bytes_16); -- Top-level all-in-one Open operation procedure Open (M : out Byte_Seq; Status : out Boolean; C : in Byte_Seq; N : in Stream.HSalsa20_Nonce; Sender_PK : in Public_Key; Recipient_SK : in Secret_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and M'Last = C'Last and C'Length >= 32) and then Equal (C (0 .. 15), Zero_Bytes_16), Post => Equal (M (0 .. 31), Zero_Bytes_32); private -- Note - also limited types here in the full view to ensure -- no assignment and pass-by-reference in the body. type Secret_Key is limited record F : Bytes_32; end record; type Public_Key is limited record F : Bytes_32; end record; end SPARKNaCl.Cryptobox;
zhmu/ananas
Ada
262
adb
-- { dg-do run } procedure Discr55 is type Rec (C : Character) is record case C is when 'Z' .. Character'Val (128) => I : Integer; when others => null; end case; end record; R : Rec ('Z'); begin R.I := 0; end;
reznikmm/matreshka
Ada
6,760
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Dr3d.Scene_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Dr3d_Scene_Element_Node is begin return Self : Dr3d_Scene_Element_Node do Matreshka.ODF_Dr3d.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Dr3d_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Dr3d_Scene_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Dr3d_Scene (ODF.DOM.Dr3d_Scene_Elements.ODF_Dr3d_Scene_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Dr3d_Scene_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Scene_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Dr3d_Scene_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Dr3d_Scene (ODF.DOM.Dr3d_Scene_Elements.ODF_Dr3d_Scene_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Dr3d_Scene_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Dr3d_Scene (Visitor, ODF.DOM.Dr3d_Scene_Elements.ODF_Dr3d_Scene_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Dr3d_URI, Matreshka.ODF_String_Constants.Scene_Element, Dr3d_Scene_Element_Node'Tag); end Matreshka.ODF_Dr3d.Scene_Elements;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Db_Query_Collection_Elements is pragma Preelaborate; type ODF_Db_Query_Collection is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Db_Query_Collection_Access is access all ODF_Db_Query_Collection'Class with Storage_Size => 0; end ODF.DOM.Db_Query_Collection_Elements;
reznikmm/gela
Ada
403
ads
package Gela.Elements.Set_Enclosing is pragma Preelaborate; type Element is limited interface; type Element_Access is access all Element'Class; for Element_Access'Storage_Size use 0; not overriding procedure Set_Enclosing_Element (Self : in out Element; Value : Gela.Elements.Element_Access) is abstract; -- Set upper element to Value. end Gela.Elements.Set_Enclosing;
OneWingedShark/Byron
Ada
410
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); With Byron.Internals.SPARK.Element; Generic with Package Input is New Element(<>); with Package Output is New Element(<>); with Function Translation_Function(Item : Input.Element_Type) return Output.Element_Type; Function Byron.Internals.SPARK.Translation(X: Input.Element_Type) return Output.Element_Type with SPARK_Mode => On, Pure_Function;
AdaCore/gpr
Ada
51,746
adb
-- -- Copyright (C) 2019-2023, AdaCore -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with Ada.Exceptions; use Ada.Exceptions; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System; with Gpr_Parser_Support.Slocs; use Gpr_Parser_Support.Slocs; with Gpr_Parser_Support.Token_Data_Handlers; use Gpr_Parser_Support.Token_Data_Handlers; with Gpr_Parser.Common; use Gpr_Parser.Common; with Gpr_Parser.Implementation; with Gpr_Parser.Lexer_Implementation; use Gpr_Parser.Lexer_Implementation; with Gpr_Parser.Unparsing_Implementation; use Gpr_Parser.Unparsing_Implementation; package body Gpr_Parser.Rewriting_Implementation is function Convert is new Ada.Unchecked_Conversion (Rewriting_Handle, Rewriting_Handle_Pointer); function Convert is new Ada.Unchecked_Conversion (Rewriting_Handle_Pointer, Rewriting_Handle); procedure Pre_Check (Value : Boolean; Msg : String); -- Raise a Precondition_Failure exception with the given message -- if the Value is False. --------------- -- Pre_Check -- --------------- procedure Pre_Check (Value : Boolean; Msg : String) is begin if not Value then raise Precondition_Failure with Msg; end if; end Pre_Check; function Handle (Context : Internal_Context) return Rewriting_Handle is (Convert (Get_Rewriting_Handle (Context))); function Context (Handle : Rewriting_Handle) return Internal_Context is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Handle.Context; end Context; function Allocate (Kind : Gpr_Node_Kind_Type; Context : Rewriting_Handle; Unit_Handle : Unit_Rewriting_Handle; Parent_Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle with Pre => Context /= No_Rewriting_Handle and then (Unit_Handle = No_Unit_Rewriting_Handle or else Unit_Handle.Context_Handle = Context) and then (Parent_Handle = No_Node_Rewriting_Handle or else Parent_Handle.Context_Handle = Context); function Allocate (Node : Bare_Gpr_Node; Context : Rewriting_Handle; Unit_Handle : Unit_Rewriting_Handle; Parent_Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle with Pre => Context /= No_Rewriting_Handle and then (Unit_Handle = No_Unit_Rewriting_Handle or else Unit_Handle.Context_Handle = Context) and then (Parent_Handle = No_Node_Rewriting_Handle or else Parent_Handle.Context_Handle = Context); -- Allocate a handle for Node and register it in Unit_Handle's map procedure Expand_Children (Node : Node_Rewriting_Handle) with Pre => Node /= No_Node_Rewriting_Handle; -- If Node.Children.Kind is Unexpanded, populate Node's list of Children to -- mimic the related bare AST node. Otherwise, do nothing. procedure Free_Handles (Handle : in out Rewriting_Handle); -- Free all resources tied to Handle. This also releases the rewriting -- handle singleton in Handle's Context. procedure Tie (Handle, Parent : Node_Rewriting_Handle; Unit : Unit_Rewriting_Handle); -- Tie the node represented by handle so that either: -- -- * it is the root of Unit (Parent is null); -- * it is a child of Parent (Unit is null). -- -- Do nothing if Handle is null. procedure Untie (Handle : Node_Rewriting_Handle); -- Untie the node represented by Handle. Do nothing if Handle is null. --------------------- -- Start_Rewriting -- --------------------- function Start_Rewriting (Context : Internal_Context) return Rewriting_Handle is begin Pre_Check (Handle (Context) = No_Rewriting_Handle, "Handle (Context) must be null"); if Context.File_Reader /= null then raise Precondition_Failure with "tree rewriting forbidden with a file reader"; end if; declare Result : constant Rewriting_Handle := new Rewriting_Handle_Type' (Context => Context, Units => <>, Pool => Create, New_Nodes => <>); begin Result.New_Nodes := Nodes_Pools.Create (Result.Pool); Set_Rewriting_Handle (Context, Convert (Result)); return Result; end; end Start_Rewriting; --------------------- -- Abort_Rewriting -- --------------------- procedure Abort_Rewriting (Handle : in out Rewriting_Handle) is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); Free_Handles (Handle); end Abort_Rewriting; ----------- -- Apply -- ----------- function Apply (Handle : in out Rewriting_Handle) return Apply_Result is type Processed_Unit_Record is record Unit : Internal_Unit; New_Data : Reparsed_Unit; end record; type Processed_Unit is access Processed_Unit_Record; procedure Free is new Ada.Unchecked_Deallocation (Processed_Unit_Record, Processed_Unit); package Processed_Unit_Vectors is new Ada.Containers.Vectors (Positive, Processed_Unit); Units : Processed_Unit_Vectors.Vector; Result : Apply_Result := (Success => True); begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); -- Try to reparse all units that were potentially modified for Unit_Handle of Handle.Units loop declare PU : constant Processed_Unit := new Processed_Unit_Record' (Unit => Unit_Handle.Unit, New_Data => <>); Input : Internal_Lexer_Input := (Kind => Bytes_Buffer, Charset => <>, Read_BOM => False, Bytes => System.Null_Address, Bytes_Count => 0); Bytes : String_Access; function Error_Result return Apply_Result is ((Success => False, Unit => PU.Unit, Diagnostics => <>)); begin Units.Append (PU); -- Reparse (i.e. unparse and then parse) this rewritten unit begin Bytes := Unparse (Create_Abstract_Node (Unit_Handle.Root), PU.Unit, Preserve_Formatting => True, As_Unit => True); exception when Exc : Malformed_Tree_Error => Result := Error_Result; Append (Result.Diagnostics, No_Source_Location_Range, To_Text (Exception_Message (Exc))); exit; end; Input.Charset := Unit_Handle.Unit.Charset; Input.Bytes := Bytes.all'Address; Input.Bytes_Count := Bytes.all'Length; Do_Parsing (PU.Unit, Input, PU.New_Data); Free (Bytes); -- If there is a parsing error, abort the rewriting process if not PU.New_Data.Diagnostics.Is_Empty then Result := Error_Result; Result.Diagnostics.Move (PU.New_Data.Diagnostics); Destroy (PU.New_Data); exit; end if; end; end loop; -- If all reparsing went fine, actually replace the AST nodes all over -- the context and free all resources associated to Handle. if Result.Success then for PU of Units loop Update_After_Reparse (PU.Unit, PU.New_Data); end loop; Free_Handles (Handle); end if; -- Clean-up our local resources and return for PU of Units loop Free (PU); end loop; return Result; end Apply; ------------------ -- Unit_Handles -- ------------------ function Unit_Handles (Handle : Rewriting_Handle) return Unit_Rewriting_Handle_Array is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); declare Count : constant Natural := Natural (Handle.Units.Length); Result : Unit_Rewriting_Handle_Array (1 .. Count); I : Positive := 1; begin for Unit of Handle.Units loop Result (I) := Unit; I := I + 1; end loop; return Result; end; end Unit_Handles; ------------ -- Handle -- ------------ function Handle (Unit : Internal_Unit) return Unit_Rewriting_Handle is begin Pre_Check (Handle (Context (Unit)) /= No_Rewriting_Handle, "Handle (Context (Unit)) should not be null"); Pre_Check (not Has_Diagnostics (Unit), "Unit must not have diagnostics"); declare use Unit_Maps; Context : constant Internal_Context := Unit.Context; Context_Handle : constant Rewriting_Handle := Handle (Context); Filename : constant Unbounded_String := To_Unbounded_String (Get_Filename (Unit)); Cur : constant Cursor := Context_Handle.Units.Find (Filename); begin if Cur /= No_Element then return Element (Cur); end if; declare Result : constant Unit_Rewriting_Handle := new Unit_Rewriting_Handle_Type'(Context_Handle => Context_Handle, Unit => Unit, Root => <>, Nodes => <>); begin Context_Handle.Units.Insert (Filename, Result); Result.Root := Handle (Root (Unit)); return Result; end; end; end Handle; ---------- -- Unit -- ---------- function Unit (Handle : Unit_Rewriting_Handle) return Internal_Unit is begin Pre_Check (Handle /= No_Unit_Rewriting_Handle, "Handle should not be null"); return Handle.Unit; end Unit; ---------- -- Root -- ---------- function Root (Handle : Unit_Rewriting_Handle) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Unit_Rewriting_Handle, "Handle should not be null"); return Handle.Root; end Root; -------------- -- Set_Root -- -------------- procedure Set_Root (Handle : Unit_Rewriting_Handle; Root : Node_Rewriting_Handle) is begin Pre_Check (Handle /= No_Unit_Rewriting_Handle, "Handle should not be null"); Pre_Check (Root = No_Node_Rewriting_Handle or else not Tied (Root), "Root must not be tied to another rewriting context."); Untie (Handle.Root); Handle.Root := Root; Tie (Root, No_Node_Rewriting_Handle, Handle); end Set_Root; ------------- -- Unparse -- ------------- function Unparse (Handle : Unit_Rewriting_Handle) return Unbounded_Text_Type is begin Pre_Check (Handle /= No_Unit_Rewriting_Handle, "Handle should not be null"); return Unparsing_Implementation.Unparse (Node => Create_Abstract_Node (Handle.Root), Unit => Handle.Unit, Preserve_Formatting => True, As_Unit => True); end Unparse; ------------ -- Handle -- ------------ function Handle (Node : Bare_Gpr_Node) return Node_Rewriting_Handle is begin Pre_Check (Handle (Context (Node.Unit)) /= No_Rewriting_Handle, "Handle (Context (Node.Unit)) should not be null"); Pre_Check (not Has_Diagnostics (Node.Unit), "Node.Unit must not have diagnostics"); if Node = null then return No_Node_Rewriting_Handle; end if; declare use Node_Maps; Unit_Handle : constant Unit_Rewriting_Handle := Handle (Node.Unit); Cur : constant Cursor := Unit_Handle.Nodes.Find (Node); begin -- If we have already built a handle for this node, just return it if Cur /= No_Element then return Element (Cur); -- Otherwise, if this node has a parent, make sure this parent has -- its own handle, then expand its children. This last must create -- the handle we are supposed to return. elsif Node.Parent /= null then Expand_Children (Handle (Node.Parent)); return Element (Unit_Handle.Nodes.Find (Node)); end if; -- Otherwise, we are dealing with the root node: just create its -- rewriting handle. return Allocate (Node, Unit_Handle.Context_Handle, Unit_Handle, No_Node_Rewriting_Handle); end; end Handle; ---------- -- Node -- ---------- function Node (Handle : Node_Rewriting_Handle) return Bare_Gpr_Node is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return Handle.Node; end Node; ------------- -- Context -- ------------- function Context (Handle : Node_Rewriting_Handle) return Rewriting_Handle is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return Handle.Context_Handle; end Context; ------------- -- Unparse -- ------------- function Unparse (Handle : Node_Rewriting_Handle) return Text_Type is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return To_Wide_Wide_String (Unparsing_Implementation.Unparse (Create_Abstract_Node (Handle), Unit => null, Preserve_Formatting => True, As_Unit => False)); end Unparse; -------------- -- Allocate -- -------------- function Allocate (Kind : Gpr_Node_Kind_Type; Context : Rewriting_Handle; Unit_Handle : Unit_Rewriting_Handle; Parent_Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle is Tied : constant Boolean := Unit_Handle /= No_Unit_Rewriting_Handle; begin return new Node_Rewriting_Handle_Type' (Context_Handle => Context, Node => null, Parent => Parent_Handle, Kind => Kind, Tied => Tied, Root_Of => (if Tied and then Parent_Handle = No_Node_Rewriting_Handle then Unit_Handle else No_Unit_Rewriting_Handle), Children => Unexpanded_Children); end Allocate; -------------- -- Allocate -- -------------- function Allocate (Node : Bare_Gpr_Node; Context : Rewriting_Handle; Unit_Handle : Unit_Rewriting_Handle; Parent_Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle is Result : constant Node_Rewriting_Handle := Allocate (Node.Kind, Context, Unit_Handle, Parent_Handle); begin Result.Node := Node; if Result.Tied then Unit_Handle.Nodes.Insert (Node, Result); end if; return Result; end Allocate; --------------------- -- Expand_Children -- --------------------- procedure Expand_Children (Node : Node_Rewriting_Handle) is Children : Node_Children renames Node.Children; begin -- If this handle has already be expanded, there is nothing to do if Children.Kind /= Unexpanded then return; end if; -- Otherwise, expand to the appropriate children form: token node or -- regular one. declare N : constant Bare_Gpr_Node := Node.Node; Unit_Handle : constant Unit_Rewriting_Handle := Handle (N.Unit); begin if Is_Token_Node (N) then Children := (Kind => Expanded_Token_Node, Text => To_Unbounded_Wide_Wide_String (Text (N))); else Children := (Kind => Expanded_Regular, Vector => <>); declare Count : constant Natural := Children_Count (N); begin Children.Vector.Reserve_Capacity (Ada.Containers.Count_Type (Count)); for I in 1 .. Count loop declare Child : constant Bare_Gpr_Node := Implementation.Child (N, I); begin Children.Vector.Append ((if Child = null then null else Allocate (Child, Unit_Handle.Context_Handle, Unit_Handle, Node))); end; end loop; end; end if; end; end Expand_Children; ------------------ -- Free_Handles -- ------------------ procedure Free_Handles (Handle : in out Rewriting_Handle) is procedure Free is new Ada.Unchecked_Deallocation (Rewriting_Handle_Type, Rewriting_Handle); procedure Free is new Ada.Unchecked_Deallocation (Unit_Rewriting_Handle_Type, Unit_Rewriting_Handle); procedure Free is new Ada.Unchecked_Deallocation (Node_Rewriting_Handle_Type, Node_Rewriting_Handle); Ctx : constant Internal_Context := Context (Handle); begin -- Free all resources tied to Handle for Unit of Handle.Units loop for Node of Unit.Nodes loop Free (Node); end loop; Free (Unit); end loop; for Node of Handle.New_Nodes loop declare N : Node_Rewriting_Handle := Node; begin Free (N); end; end loop; Free (Handle.Pool); Free (Handle); -- Release the rewriting handle singleton for its context Set_Rewriting_Handle (Ctx, Convert (Handle)); end Free_Handles; --------- -- Tie -- --------- procedure Tie (Handle, Parent : Node_Rewriting_Handle; Unit : Unit_Rewriting_Handle) is begin if Handle /= No_Node_Rewriting_Handle then Handle.Parent := Parent; Handle.Tied := True; if Parent = No_Node_Rewriting_Handle then Handle.Root_Of := Unit; end if; end if; end Tie; ----------- -- Untie -- ----------- procedure Untie (Handle : Node_Rewriting_Handle) is begin if Handle /= No_Node_Rewriting_Handle then Handle.Parent := No_Node_Rewriting_Handle; Handle.Tied := False; Handle.Root_Of := No_Unit_Rewriting_Handle; end if; end Untie; ---------- -- Kind -- ---------- function Kind (Handle : Node_Rewriting_Handle) return Gpr_Node_Kind_Type is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return Handle.Kind; end Kind; ---------- -- Tied -- ---------- function Tied (Handle : Node_Rewriting_Handle) return Boolean is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return Handle.Tied; end Tied; ------------ -- Parent -- ------------ function Parent (Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return Handle.Parent; end Parent; -------------------- -- Children_Count -- -------------------- function Children_Count (Handle : Node_Rewriting_Handle) return Natural is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); return (case Handle.Children.Kind is when Unexpanded => Children_Count (Handle.Node), when Expanded_Regular => Natural (Handle.Children.Vector.Length), when Expanded_Token_Node => 0); end Children_Count; ----------- -- Child -- ----------- function Child (Handle : Node_Rewriting_Handle; Index : Positive) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); if Index > Children_Count (Handle) then raise Precondition_Failure with "Invalid index " & Index'Image & ": Handle has " & Children_Count (Handle)'Image & " children"; end if; -- If this handle represents an already existing node, make sure it is -- expanded so we have a handle to return. Expand_Children (Handle); return Handle.Children.Vector.Element (Index); end Child; --------------- -- Set_Child -- --------------- procedure Set_Child (Handle : Node_Rewriting_Handle; Index : Positive; Child : Node_Rewriting_Handle) is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); if Index > Children_Count (Handle) then raise Precondition_Failure with "Invalid index " & Index'Image & ": Handle has " & Children_Count (Handle)'Image & " children"; end if; Pre_Check (Child = No_Node_Rewriting_Handle or else not Tied (Child), "Child must not be tied to another rewriting context."); -- If this handle represents an already existing node, make sure it is -- expanded so that its children vector can be modified. Expand_Children (Handle); declare Child_Slot : Node_Rewriting_Handle renames Handle.Children.Vector.Reference (Index); begin -- Untie the child to be replaced if it exists Untie (Child_Slot); -- Tie the new child if it exists Tie (Child, Handle, No_Unit_Rewriting_Handle); Child_Slot := Child; end; end Set_Child; ---------- -- Text -- ---------- function Text (Handle : Node_Rewriting_Handle) return Text_Type is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); Pre_Check (Is_Token_Node (Kind (Handle)), "Expected a token node. Got " & Kind (Handle)'Image); case Handle.Children.Kind is when Unexpanded => if Is_Token_Node (Handle.Kind) then return Text (Handle.Node); else raise Program_Error; end if; when Expanded_Regular => return (raise Program_Error); when Expanded_Token_Node => return To_Wide_Wide_String (Handle.Children.Text); end case; end Text; -------------- -- Set_Text -- -------------- procedure Set_Text (Handle : Node_Rewriting_Handle; Text : Text_Type) is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); Pre_Check (Is_Token_Node (Kind (Handle)), "Expected a token node. Got " & Kind (Handle)'Image); -- Make sure Handle is expanded so we have a Text field to override Expand_Children (Handle); Handle.Children.Text := To_Unbounded_Wide_Wide_String (Text); end Set_Text; ------------- -- Replace -- ------------- procedure Replace (Handle, New_Node : Node_Rewriting_Handle) is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); Pre_Check (Tied (Handle), "Handle must be tied to an analysis unit."); Pre_Check (New_Node = No_Node_Rewriting_Handle or else not Tied (New_Node), "New_Node must not be tied to another rewriting context."); if Handle = New_Node then return; end if; if Handle.Root_Of = No_Unit_Rewriting_Handle then -- If Handle is not the root node of its owning unit, go replace it -- in its parent's children list. declare Parent : Node_Rewriting_Handle renames Handle.Parent; Index : Natural := 0; begin for I in 1 .. Children_Count (Parent) loop if Child (Parent, I) = Handle then Index := I; exit; end if; end loop; pragma Assert (Index > 0); Set_Child (Parent, Index, New_Node); end; else -- Otherwise, replace it as a root node Set_Root (Handle.Root_Of, New_Node); end if; end Replace; ------------------ -- Insert_Child -- ------------------ procedure Insert_Child (Handle : Node_Rewriting_Handle; Index : Positive; Child : Node_Rewriting_Handle) is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); Pre_Check (Is_List_Node (Kind (Handle)), "Expected a list node. Got " & Kind (Handle)'Image); if Index > Children_Count (Handle) + 1 then raise Precondition_Failure with "Invalid index " & Index'Image & ": Handle has " & Children_Count (Handle)'Image & " children"; end if; Pre_Check (Child = No_Node_Rewriting_Handle or else not Tied (Child), "Child must not be tied to another rewriting context."); -- First, just create room for the new node and let Set_Child take care -- of tiding Child to Handle's tree. Expand_Children (Handle); Handle.Children.Vector.Insert (Index, No_Node_Rewriting_Handle); Set_Child (Handle, Index, Child); end Insert_Child; ------------------ -- Append_Child -- ------------------ procedure Append_Child (Handle : Node_Rewriting_Handle; Child : Node_Rewriting_Handle) is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); Pre_Check (Is_List_Node (Kind (Handle)), "Expected a list node. Got " & Kind (Handle)'Image); Pre_Check (Child = No_Node_Rewriting_Handle or else not Tied (Child), "Child must not be tied to another rewriting context."); Insert_Child (Handle, Children_Count (Handle) + 1, Child); end Append_Child; ------------------ -- Remove_Child -- ------------------ procedure Remove_Child (Handle : Node_Rewriting_Handle; Index : Positive) is begin Pre_Check (Handle /= No_Node_Rewriting_Handle, "Handle should not be null"); Pre_Check (Is_List_Node (Kind (Handle)), "Expected a list node. Got " & Kind (Handle)'Image); if Index > Children_Count (Handle) + 1 then raise Precondition_Failure with "Invalid index " & Index'Image & ": Handle has " & Children_Count (Handle)'Image & " children"; end if; -- First, let Set_Child take care of untiding the child to remove, and -- then actually remove the corresponding children list slot. Set_Child (Handle, Index, No_Node_Rewriting_Handle); Handle.Children.Vector.Delete (Index); end Remove_Child; ----------- -- Clone -- ----------- function Clone (Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle is Result : Node_Rewriting_Handle; begin if Handle = No_Node_Rewriting_Handle then return Handle; end if; -- Make sure the original handle is expanded so we can iterate on it Expand_Children (Handle); -- If the input handle is associated to a node, so should be the cloned -- handle, so that its formatting is copied as well. Result := (if Handle.Node = null then Allocate (Handle.Kind, Handle.Context_Handle, No_Unit_Rewriting_Handle, No_Node_Rewriting_Handle) else Allocate (Handle.Node, Handle.Context_Handle, No_Unit_Rewriting_Handle, No_Node_Rewriting_Handle)); Nodes_Pools.Append (Handle.Context_Handle.New_Nodes, Result); -- Recursively clone children case Handle.Children.Kind is when Unexpanded => raise Program_Error; when Expanded_Token_Node => Result.Children := (Kind => Expanded_Token_Node, Text => Handle.Children.Text); when Expanded_Regular => Result.Children := (Kind => Expanded_Regular, Vector => <>); Result.Children.Vector.Reserve_Capacity (Handle.Children.Vector.Length); for I in 1 .. Handle.Children.Vector.Last_Index loop Result.Children.Vector.Append (Clone (Handle.Children.Vector.Element (I))); end loop; end case; return Result; end Clone; ----------------- -- Create_Node -- ----------------- function Create_Node (Handle : Rewriting_Handle; Kind : Gpr_Node_Kind_Type) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); Pre_Check (not Is_Error_Node (Kind), "Expected a non-error node. Got " & Kind'Image); if Is_Token_Node (Kind) then return Create_Token_Node (Handle, Kind, ""); else declare Count : constant Integer := Kind_To_Node_Children_Count (Kind); Children : constant Node_Rewriting_Handle_Array (1 .. Count) := (others => No_Node_Rewriting_Handle); begin return Create_Regular_Node (Handle, Kind, Children); end; end if; end Create_Node; ----------------------- -- Create_Token_Node -- ----------------------- function Create_Token_Node (Handle : Rewriting_Handle; Kind : Gpr_Node_Kind_Type; Text : Text_Type) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); Pre_Check (Is_Token_Node (Kind), "Expected a token node. Got " & Kind'Image); declare Result : constant Node_Rewriting_Handle := Allocate (Kind, Handle, No_Unit_Rewriting_Handle, No_Node_Rewriting_Handle); begin Result.Children := (Kind => Expanded_Token_Node, Text => To_Unbounded_Wide_Wide_String (Text)); Nodes_Pools.Append (Handle.New_Nodes, Result); return Result; end; end Create_Token_Node; ------------------------- -- Create_Regular_Node -- ------------------------- function Create_Regular_Node (Handle : Rewriting_Handle; Kind : Gpr_Node_Kind_Type; Children : Node_Rewriting_Handle_Array) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); Pre_Check (not Is_Token_Node (Kind), "Expected a token node. Got " & Kind'Image); Pre_Check (not Is_Error_Node (Kind), "Expected a non-error node. Got " & Kind'Image); for One_Child of Children loop Pre_Check (One_Child = No_Node_Rewriting_Handle or else not Tied (One_Child), "One_Child must not be tied to another rewriting context."); end loop; declare Result : Node_Rewriting_Handle := Allocate (Kind, Handle, No_Unit_Rewriting_Handle, No_Node_Rewriting_Handle); begin Result.Children := (Kind => Expanded_Regular, Vector => <>); Result.Children.Vector.Reserve_Capacity (Children'Length); for C of Children loop Result.Children.Vector.Append (C); if C /= No_Node_Rewriting_Handle then Tie (C, Result, No_Unit_Rewriting_Handle); end if; end loop; Nodes_Pools.Append (Handle.New_Nodes, Result); return Result; end; end Create_Regular_Node; -------------------------- -- Create_From_Template -- -------------------------- function Create_From_Template (Handle : Rewriting_Handle; Template : Text_Type; Arguments : Node_Rewriting_Handle_Array; Rule : Grammar_Rule) return Node_Rewriting_Handle is type State_Type is ( Default, -- Default state: no meta character being processed Open_Brace, -- The previous character is a open brace: the current one -- determines what it means. Close_Brace -- The previous character is a closing brace: the current one must be -- another closing brace. ); Buffer : Unbounded_Wide_Wide_String; State : State_Type := Default; Next_Arg : Positive := Arguments'First; begin for One_Argument of Arguments loop Pre_Check (One_Argument = No_Node_Rewriting_Handle or else Context (One_Argument) = Handle, "One_Argument should be associated to rewriting context Handle."); end loop; -- Interpret the template looping over its characters with a state -- machine. for C of Template loop case State is when Default => case C is when '{' => State := Open_Brace; when '}' => State := Close_Brace; when others => Append (Buffer, C); end case; when Open_Brace => case C is when '{' => State := Default; Append (Buffer, C); when '}' => State := Default; if Next_Arg in Arguments'Range then declare Unparsed_Arg : constant Wide_Wide_String := Unparse (Arguments (Next_Arg)); begin Next_Arg := Next_Arg + 1; Append (Buffer, Unparsed_Arg); end; else raise Template_Args_Error with "not enough arguments provided"; end if; when others => raise Template_Format_Error with "standalone ""{"" character"; end case; when Close_Brace => case C is when '}' => State := Default; Append (Buffer, C); when others => raise Template_Format_Error with "standalone ""}"" character"; end case; end case; end loop; -- Make sure that there is no standalone metacharacter at the end of the -- template. case State is when Default => null; when Open_Brace => raise Template_Format_Error with "standalone ""{"" character"; when Close_Brace => raise Template_Format_Error with "standalone ""}"" character"; end case; -- Make sure all given arguments were consumed if Next_Arg in Arguments'Range then raise Template_Args_Error with "too many arguments provided"; end if; -- Now parse the resulting buffer and create the corresponding tree of -- nodes. declare Context : constant Internal_Context := Rewriting_Implementation.Context (Handle); Unit : constant Internal_Unit := Templates_Unit (Context); Reparsed : Reparsed_Unit; Text : constant Text_Type := To_Wide_Wide_String (Buffer); Input : constant Internal_Lexer_Input := (Kind => Text_Buffer, Text => Text'Address, Text_Count => Text'Length); function Transform (Node : Bare_Gpr_Node; Parent : Node_Rewriting_Handle) return Node_Rewriting_Handle; -- Turn a node from the Reparsed unit into a recursively expanded -- node rewriting handle. --------------- -- Transform -- --------------- function Transform (Node : Bare_Gpr_Node; Parent : Node_Rewriting_Handle) return Node_Rewriting_Handle is Result : Node_Rewriting_Handle; begin if Node = null then return No_Node_Rewriting_Handle; end if; -- Allocate the handle for Node, and don't forget to remove the -- backlink to Node itself as it exists only temporarily for -- template instantiation. Also, track the newly allocated node -- so that it is freed correctly upon destruction of the -- rewriting context. Result := Allocate (Node, Handle, No_Unit_Rewriting_Handle, Parent); Result.Node := null; Nodes_Pools.Append (Handle.New_Nodes, Result); if Is_Token_Node (Node) then declare Index : constant Natural := Natural (Node.Token_Start_Index); Data : constant Stored_Token_Data := Reparsed.TDH.Tokens.Get (Index); Text : constant Text_Type := Reparsed.TDH.Source_Buffer (Data.Source_First .. Data.Source_Last); begin Result.Children := (Kind => Expanded_Token_Node, Text => To_Unbounded_Wide_Wide_String (Text)); end; else declare Count : constant Natural := Children_Count (Node); begin Result.Children := (Kind => Expanded_Regular, Vector => <>); Result.Children.Vector.Reserve_Capacity (Ada.Containers.Count_Type (Count)); for I in 1 .. Count loop Result.Children.Vector.Append (Transform (Child (Node, I), Result)); end loop; end; end if; return Result; end Transform; begin Set_Rule (Unit, Rule); Do_Parsing (Unit, Input, Reparsed); if not Reparsed.Diagnostics.Is_Empty then Destroy (Reparsed); raise Template_Instantiation_Error; end if; declare Result : constant Node_Rewriting_Handle := Transform (Reparsed.Ast_Root, No_Node_Rewriting_Handle); begin Destroy (Reparsed); return Result; end; end; end Create_From_Template; function Create_Attribute_Decl (Handle : Rewriting_Handle ; Attribute_Decl_F_Attr_Name : Node_Rewriting_Handle ; Attribute_Decl_F_Attr_Index : Node_Rewriting_Handle ; Attribute_Decl_F_Expr : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Attribute_Decl, (1 => Attribute_Decl_F_Attr_Name, 2 => Attribute_Decl_F_Attr_Index, 3 => Attribute_Decl_F_Expr)); end; function Create_Attribute_Reference (Handle : Rewriting_Handle ; Attribute_Reference_F_Attribute_Name : Node_Rewriting_Handle ; Attribute_Reference_F_Attribute_Index : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Attribute_Reference, (1 => Attribute_Reference_F_Attribute_Name, 2 => Attribute_Reference_F_Attribute_Index)); end; function Create_Builtin_Function_Call (Handle : Rewriting_Handle ; Builtin_Function_Call_F_Function_Name : Node_Rewriting_Handle ; Builtin_Function_Call_F_Parameters : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Builtin_Function_Call, (1 => Builtin_Function_Call_F_Function_Name, 2 => Builtin_Function_Call_F_Parameters)); end; function Create_Case_Construction (Handle : Rewriting_Handle ; Case_Construction_F_Var_Ref : Node_Rewriting_Handle ; Case_Construction_F_Items : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Case_Construction, (1 => Case_Construction_F_Var_Ref, 2 => Case_Construction_F_Items)); end; function Create_Case_Item (Handle : Rewriting_Handle ; Case_Item_F_Choice : Node_Rewriting_Handle ; Case_Item_F_Decls : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Case_Item, (1 => Case_Item_F_Choice, 2 => Case_Item_F_Decls)); end; function Create_Compilation_Unit (Handle : Rewriting_Handle ; Compilation_Unit_F_Project : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Compilation_Unit, (1 => Compilation_Unit_F_Project)); end; function Create_Prefix (Handle : Rewriting_Handle ; Prefix_F_Prefix : Node_Rewriting_Handle ; Prefix_F_Suffix : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Prefix, (1 => Prefix_F_Prefix, 2 => Prefix_F_Suffix)); end; function Create_Package_Decl (Handle : Rewriting_Handle ; Package_Decl_F_Pkg_Name : Node_Rewriting_Handle ; Package_Decl_F_Pkg_Spec : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Package_Decl, (1 => Package_Decl_F_Pkg_Name, 2 => Package_Decl_F_Pkg_Spec)); end; function Create_Package_Extension (Handle : Rewriting_Handle ; Package_Extension_F_Extended_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Package_Extension, (1 => Package_Extension_F_Extended_Name)); end; function Create_Package_Renaming (Handle : Rewriting_Handle ; Package_Renaming_F_Renamed_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Package_Renaming, (1 => Package_Renaming_F_Renamed_Name)); end; function Create_Package_Spec (Handle : Rewriting_Handle ; Package_Spec_F_Extension : Node_Rewriting_Handle ; Package_Spec_F_Decls : Node_Rewriting_Handle ; Package_Spec_F_End_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Package_Spec, (1 => Package_Spec_F_Extension, 2 => Package_Spec_F_Decls, 3 => Package_Spec_F_End_Name)); end; function Create_Project (Handle : Rewriting_Handle ; Project_F_Context_Clauses : Node_Rewriting_Handle ; Project_F_Project_Decl : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Project, (1 => Project_F_Context_Clauses, 2 => Project_F_Project_Decl)); end; function Create_Project_Declaration (Handle : Rewriting_Handle ; Project_Declaration_F_Qualifier : Node_Rewriting_Handle ; Project_Declaration_F_Project_Name : Node_Rewriting_Handle ; Project_Declaration_F_Extension : Node_Rewriting_Handle ; Project_Declaration_F_Decls : Node_Rewriting_Handle ; Project_Declaration_F_End_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Project_Declaration, (1 => Project_Declaration_F_Qualifier, 2 => Project_Declaration_F_Project_Name, 3 => Project_Declaration_F_Extension, 4 => Project_Declaration_F_Decls, 5 => Project_Declaration_F_End_Name)); end; function Create_Project_Extension (Handle : Rewriting_Handle ; Project_Extension_F_Is_All : Node_Rewriting_Handle ; Project_Extension_F_Path_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Project_Extension, (1 => Project_Extension_F_Is_All, 2 => Project_Extension_F_Path_Name)); end; function Create_String_Literal_At (Handle : Rewriting_Handle ; String_Literal_At_F_Str_Lit : Node_Rewriting_Handle ; String_Literal_At_F_At_Lit : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_String_Literal_At, (1 => String_Literal_At_F_Str_Lit, 2 => String_Literal_At_F_At_Lit)); end; function Create_Terms (Handle : Rewriting_Handle ; Terms_F_Terms : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Terms, (1 => Terms_F_Terms)); end; function Create_Type_Reference (Handle : Rewriting_Handle ; Type_Reference_F_Var_Type_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Type_Reference, (1 => Type_Reference_F_Var_Type_Name)); end; function Create_Typed_String_Decl (Handle : Rewriting_Handle ; Typed_String_Decl_F_Type_Id : Node_Rewriting_Handle ; Typed_String_Decl_F_String_Literals : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Typed_String_Decl, (1 => Typed_String_Decl_F_Type_Id, 2 => Typed_String_Decl_F_String_Literals)); end; function Create_Variable_Decl (Handle : Rewriting_Handle ; Variable_Decl_F_Var_Name : Node_Rewriting_Handle ; Variable_Decl_F_Var_Type : Node_Rewriting_Handle ; Variable_Decl_F_Expr : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Variable_Decl, (1 => Variable_Decl_F_Var_Name, 2 => Variable_Decl_F_Var_Type, 3 => Variable_Decl_F_Expr)); end; function Create_Variable_Reference (Handle : Rewriting_Handle ; Variable_Reference_F_Variable_Name : Node_Rewriting_Handle ; Variable_Reference_F_Attribute_Ref : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_Variable_Reference, (1 => Variable_Reference_F_Variable_Name, 2 => Variable_Reference_F_Attribute_Ref)); end; function Create_With_Decl (Handle : Rewriting_Handle ; With_Decl_F_Is_Limited : Node_Rewriting_Handle ; With_Decl_F_Path_Names : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin Pre_Check (Handle /= No_Rewriting_Handle, "Handle should not be null"); return Create_Regular_Node (Handle, Gpr_With_Decl, (1 => With_Decl_F_Is_Limited, 2 => With_Decl_F_Path_Names)); end; end Gpr_Parser.Rewriting_Implementation;
sungyeon/drake
Ada
16,963
ads
pragma License (Unrestricted); -- generalized unit of Ada.Strings.Fixed generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; Space : Character_Type; package Ada.Strings.Generic_Functions is pragma Preelaborate; -- "Copy" procedure for strings of possibly different lengths procedure Move ( Source : String_Type; Target : out String_Type; Drop : Truncation := Error; Justify : Alignment := Left; Pad : Character_Type := Space); -- Search subprograms -- extended -- Character searching. function Index_Element ( Source : String_Type; Pattern : Character_Type; From : Positive; Going : Direction := Forward) return Natural; function Index_Element ( Source : String_Type; Pattern : Character_Type; Going : Direction := Forward) return Natural; pragma Inline (Index_Element); -- extended -- Forward or backward only version. function Index_Element_Forward ( Source : String_Type; Pattern : Character_Type) return Natural; function Index_Element_Backward ( Source : String_Type; Pattern : Character_Type) return Natural; function Index ( Source : String_Type; Pattern : String_Type; From : Positive; Going : Direction := Forward) return Natural; pragma Inline (Index); function Index ( Source : String_Type; Pattern : String_Type; Going : Direction := Forward) return Natural; pragma Inline (Index); -- extended -- Forward or backward only version. function Index_Forward (Source : String_Type; Pattern : String_Type) return Natural; function Index_Backward (Source : String_Type; Pattern : String_Type) return Natural; function Index_Non_Blank ( Source : String_Type; From : Positive; Going : Direction := Forward) return Natural; pragma Inline (Index_Non_Blank); function Index_Non_Blank ( Source : String_Type; Going : Direction := Forward) return Natural; pragma Inline (Index_Non_Blank); -- extended -- Forward or backward only version. function Index_Non_Blank_Forward ( Source : String_Type; Blank : Character_Type := Space) return Natural; function Index_Non_Blank_Backward ( Source : String_Type; Blank : Character_Type := Space) return Natural; function Count ( Source : String_Type; Pattern : String_Type) return Natural; -- String transformation subprograms function Replace_Slice ( Source : String_Type; Low : Positive; High : Natural; By : String_Type) return String_Type; procedure Replace_Slice ( Source : in out String_Type; Low : Positive; High : Natural; By : String_Type; Drop : Truncation := Error; Justify : Alignment := Left; Pad : Character_Type := Space); -- extended -- Copying, for Bounded_String and Unbounded_String. procedure Replace_Slice ( Source : String_Type; Low : Positive; High : Natural; By : String_Type; Target : out String_Type; Target_Last : out Natural); -- extended -- Destructive, for Bounded_String and Unbounded_String. procedure Replace_Slice ( Source : in out String_Type; Last : in out Natural; Low : Positive; High : Natural; By : String_Type); function Insert ( Source : String_Type; Before : Positive; New_Item : String_Type) return String_Type; procedure Insert ( Source : in out String_Type; Before : Positive; New_Item : String_Type; Drop : Truncation := Error); -- extended -- Copying, for Bounded_String and Unbounded_String. procedure Insert ( Source : String_Type; Before : Positive; New_Item : String_Type; Target : out String_Type; Target_Last : out Natural); -- extended -- Destructive, for Bounded_String and Unbounded_String. procedure Insert ( Source : in out String_Type; Last : in out Natural; Before : Positive; New_Item : String_Type); function Overwrite ( Source : String_Type; Position : Positive; New_Item : String_Type) return String_Type; procedure Overwrite ( Source : in out String_Type; Position : Positive; New_Item : String_Type; Drop : Truncation := Right); -- Note: Overwrite is danger in drake, -- because the trailing element of any multi-byte character is possible -- to be left at Source (Position + New_Item'Length). function Delete ( Source : String_Type; From : Positive; Through : Natural) return String_Type; procedure Delete ( Source : in out String_Type; From : Positive; Through : Natural; Justify : Alignment := Left; Pad : Character_Type := Space); -- extended -- Copying, for Bounded_String and Unbounded_String. procedure Delete ( Source : String_Type; From : Positive; Through : Natural; Target : out String_Type; Target_Last : out Natural); -- extended -- Destructive, for Bounded_String and Unbounded_String. procedure Delete ( Source : in out String_Type; Last : in out Natural; From : Positive; Through : Natural); -- String selector subprograms function Trim ( Source : String_Type; Side : Trim_End; Blank : Character_Type := Space) -- additional return String_Type; procedure Trim ( Source : in out String_Type; Side : Trim_End; Justify : Alignment := Left; Pad : Character_Type := Space); -- extended -- Explicit blank. (default parameter is wrong for CXA4025) procedure Trim ( Source : in out String_Type; Side : Trim_End; Blank : Character_Type; Justify : Alignment := Left; Pad : Character_Type := Space); -- extended -- No copying. procedure Trim ( Source : String_Type; Side : Trim_End; Blank : Character_Type := Space; First : out Positive; Last : out Natural); function Head ( Source : String_Type; Count : Natural; Pad : Character_Type := Space) return String_Type; procedure Head ( Source : in out String_Type; Count : Natural; Justify : Alignment := Left; Pad : Character_Type := Space); -- extended -- Copying, for Bounded_String and Unbounded_String. procedure Head ( Source : String_Type; Count : Natural; Pad : Character_Type := Space; Target : out String_Type; Target_Last : out Natural); -- extended -- Destructive, for Bounded_String and Unbounded_String. procedure Head ( Source : in out String_Type; Last : in out Natural; Count : Natural; Pad : Character_Type := Space); function Tail ( Source : String_Type; Count : Natural; Pad : Character_Type := Space) return String_Type; procedure Tail ( Source : in out String_Type; Count : Natural; Justify : Alignment := Left; Pad : Character_Type := Space); -- extended -- Copying, for Bounded_String and Unbounded_String. procedure Tail ( Source : String_Type; Count : Natural; Pad : Character_Type := Space; Target : out String_Type; Target_Last : out Natural); -- String constructor functions function "*" (Left : Natural; Right : Character_Type) return String_Type; function "*" (Left : Natural; Right : String_Type) return String_Type; generic Expanding : Natural; with procedure Put ( Value : Wide_Wide_Character; Item : out String_Type; Last : out Natural); with procedure Get ( Item : String_Type; Last : out Natural; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean); with procedure Get_Reverse ( Item : String_Type; First : out Positive; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean); type Character_Set is private; with function Is_In ( Element : Wide_Wide_Character; Set : Character_Set) return Boolean; type Character_Mapping is private; with function Value ( Map : Character_Mapping; Element : Wide_Wide_Character) return Wide_Wide_Character; package Generic_Maps is -- Search subprograms function Index ( Source : String_Type; Pattern : String_Type; From : Positive; Going : Direction := Forward; Mapping : Character_Mapping) return Natural; pragma Inline (Index); function Index ( Source : String_Type; Pattern : String_Type; Going : Direction := Forward; Mapping : Character_Mapping) return Natural; pragma Inline (Index); -- extended -- Forward or backward only version. function Index_Forward ( Source : String_Type; Pattern : String_Type; Mapping : Character_Mapping) return Natural; function Index_Backward ( Source : String_Type; Pattern : String_Type; Mapping : Character_Mapping) return Natural; function Index ( Source : String_Type; Pattern : String_Type; From : Positive; Going : Direction := Forward; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural; pragma Inline (Index); function Index ( Source : String_Type; Pattern : String_Type; Going : Direction := Forward; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural; pragma Inline (Index); -- extended -- Forward or backward only version. function Index_Forward ( Source : String_Type; Pattern : String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural; function Index_Backward ( Source : String_Type; Pattern : String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural; function Index_Element ( Source : String_Type; Pattern : String_Type; From : Positive; Going : Direction := Forward; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural; pragma Inline (Index_Element); function Index_Element ( Source : String_Type; Pattern : String_Type; Going : Direction := Forward; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural; pragma Inline (Index_Element); -- extended -- Forward or backward only version. function Index_Element_Forward ( Source : String_Type; Pattern : String_Type; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural; function Index_Element_Backward ( Source : String_Type; Pattern : String_Type; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural; function Index ( Source : String_Type; Set : Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural; pragma Inline (Index); function Index ( Source : String_Type; Set : Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural; pragma Inline (Index); -- extended -- Forward or backward only version. function Index_Forward ( Source : String_Type; Set : Character_Set; Test : Membership := Inside) return Natural; function Index_Backward ( Source : String_Type; Set : Character_Set; Test : Membership := Inside) return Natural; function Count ( Source : String_Type; Pattern : String_Type; Mapping : Character_Mapping) return Natural; function Count ( Source : String_Type; Pattern : String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural; function Count_Element ( Source : String_Type; Pattern : String_Type; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural; function Count ( Source : String_Type; Set : Character_Set) return Natural; procedure Find_Token ( Source : String_Type; Set : Character_Set; From : Positive; Test : Membership; First : out Positive; Last : out Natural); procedure Find_Token ( Source : String_Type; Set : Character_Set; Test : Membership; First : out Positive; Last : out Natural); -- extended -- Only First or only Last. function Find_Token_Last ( Source : String_Type; Set : Character_Set; Test : Membership) return Natural; function Find_Token_First ( Source : String_Type; Set : Character_Set; Test : Membership) return Positive; -- String translation subprograms function Translate ( Source : String_Type; Mapping : Character_Mapping) return String_Type; procedure Translate ( Source : in out String_Type; Mapping : Character_Mapping; Drop : Truncation := Error; -- additional Justify : Alignment := Left; -- additional Pad : Character_Type := Space); -- additional -- extended -- For Bounded_String and Unbounded_String. procedure Translate ( Source : String_Type; Mapping : Character_Mapping; Target : out String_Type; Target_Last : out Natural); function Translate ( Source : String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return String_Type; procedure Translate ( Source : in out String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character; Drop : Truncation := Error; -- additional Justify : Alignment := Left; -- additional Pad : Character_Type := Space); -- additional -- extended -- For Bounded_String and Unbounded_String. procedure Translate ( Source : String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character; Target : out String_Type; Target_Last : out Natural); function Translate_Element ( Source : String_Type; Mapping : not null access function (From : Character_Type) return Character_Type) return String_Type; procedure Translate_Element ( Source : in out String_Type; Mapping : not null access function (From : Character_Type) return Character_Type); -- extended -- For Bounded_String and Unbounded_String. procedure Translate_Element ( Source : String_Type; Mapping : not null access function (From : Character_Type) return Character_Type; Target : out String_Type); -- String selector subprograms function Trim ( Source : String_Type; Left : Character_Set; Right : Character_Set) return String_Type; procedure Trim ( Source : in out String_Type; Left : Character_Set; Right : Character_Set; Justify : Alignment := Strings.Left; Pad : Character_Type := Space); -- extended -- No copying. procedure Trim ( Source : String_Type; Left : Character_Set; Right : Character_Set; First : out Positive; Last : out Natural); end Generic_Maps; end Ada.Strings.Generic_Functions;
HeisenbugLtd/open_weather_map_api
Ada
866
adb
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); with Open_Weather_Map.Application; -------------------------------------------------------------------------------- -- Main_OWM_Test -------------------------------------------------------------------------------- procedure Main_OWM_Test is App : Open_Weather_Map.Application.T; begin App.Initialize; App.Run; App.Shutdown; pragma Unreferenced (App); end Main_OWM_Test;
sparre/Ada-2012-Examples
Ada
791
adb
with Ada.Text_IO; with Classes.Parent; with Classes.Child; procedure Classes.Example is function Random return Parent.Class; function Random return Parent.Class is Result : Child.Instance; begin Result.Set (Name => "Lea"); Result.Set (Age => 6); return Result; end Random; begin declare use Ada.Text_IO; Item : constant Parent.Class := Random; begin if Item in Child.Class then declare View : Child.Instance renames Child.Instance (Item); begin Put_Line (View.Name & " is " & Child.Years'Image (View.Age) & " years old."); end; else Put_Line ("We don't know the age of " & Item.Name & "."); end if; end; end Classes.Example;
helgeanl/vigilant-pancake
Ada
4,003
adb
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random; use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random; procedure exercise8 is Count_Failed : exception; -- Exception to be raised when counting fails Gen : Generator; -- Random number generator protected type Transaction_Manager (N : Positive) is entry Finished; entry Wait_Until_Aborted; procedure Signal_Abort; private Finished_Gate_Open : Boolean := False; Aborted : Boolean := False; end Transaction_Manager; protected body Transaction_Manager is entry Finished when Finished_Gate_Open or Finished'Count = N is begin ------------------------------------------ -- PART 3: Complete the exit protocol here ------------------------------------------ if Finished'Count = N-1 then -- First one in let all in Finished_Gate_Open := True; end if; if Finished'Count = 0 then -- Last one close the door Finished_Gate_Open := False; end if; end Finished; ------------------------------------------ -- Exercise 8: PART 2: Create the entry ------------------------------------------ entry Wait_Until_Aborted when Aborted is count_worker : Integer := 0; begin count_worker = count_worker +1; if count_worker = 3 then -- Reset when last one is finished Aborted := False; count_worker := 0; end if; end Wait_Until_Aborted; procedure Signal_Abort is begin Aborted := True; end Signal_Abort; end Transaction_Manager; function Unreliable_Slow_Add (x : Integer) return Integer is Error_Rate : Constant := 0.15; -- (between 0 and 1) return_value : Integer := 0; begin ------------------------------------------- -- PART 1: Create the transaction work here ------------------------------------------- -- compare Random(Gen) with Error_Rate and do: if Random(Gen) > Error_Rate then ---- The intended behaviour: delay Duration(Random(Gen)*4.0); -- Work takes 4-ish seconds return_value := x + 10; return return_value; else ---- The faulty behaviour: delay Duration(Random(Gen)*0.5); -- Work takes up to half a second Put_Line("-- ** Exception was raised **"); raise Count_Failed; -- Error, raise exception end if; end Unreliable_Slow_Add; task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager); task body Transaction_Worker is Num : Integer := Initial; Prev : Integer := Num; Round_Num : Integer := 0; begin Put_Line ("Worker" & Integer'Image(Initial) & " started"); loop Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num)); Round_Num := Round_Num + 1; ------------------------------------------ -- Exercise 8: PART 1: Select-Then-Abort ------------------------------------------ select Manager.Wait_Until_Aborted; -- eg. X.Entry_Call; -- code that is run when the triggering_alternative has triggered -- (forward ER code goes here) Num := Num + 5; then abort begin Num := Unreliable_Slow_Add (Num); -- Add Num +10 exception -- Start of exception handlers when Count_Failed => Put_Line("-- Exceptiopn Worker " & Integer'Image(Initial)); Manager.Signal_Abort; end; end select; Manager.Finished; Put_Line ("-- Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num)); Prev := Num; delay 0.5; end loop; end Transaction_Worker; Manager : aliased Transaction_Manager (3); Worker_1 : Transaction_Worker (0, Manager'Access); Worker_2 : Transaction_Worker (1, Manager'Access); Worker_3 : Transaction_Worker (2, Manager'Access); begin Reset(Gen); -- Seed the random number generator end exercise8;
zhmu/ananas
Ada
150
adb
package body Array38_Pkg is function F (Data : Array_Type) return Value_Type is begin return Value_Type'First; end; end Array38_Pkg;
stahta01/emulator_8080
Ada
336
ads
with Emulator_8080.Processor; private with GNAT.Sockets; package Emulator_8080.Vram_Sender is procedure Initialize(Port : in Natural; Ip_Address : in String); procedure Close; procedure Send_Vram(Vram : in Emulator_8080.Processor.Vram_Type); private Sender_Socket : GNAT.Sockets.Socket_Type; end Emulator_8080.Vram_Sender;
charlie5/aIDE
Ada
1,251
ads
with Ada.Containers.Vectors, Ada.Streams; private with AdaM.Declaration.of_package; package AdaM.use_Clause.for_package is type Item is new use_Clause.item with private; -- View -- type View is access all Item'Class; procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; -- Vector -- package Vectors is new ada.Containers.Vectors (Positive, View); subtype Vector is Vectors.Vector; -- Forge -- function new_Subprogram return use_Clause.for_package.view; procedure free (Self : in out use_Clause.for_package.view); overriding procedure destruct (Self : in out use_Clause.for_package.item); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; private type Item is new use_Clause.item with record Packages : Declaration.of_package.vector; end record; end AdaM.use_Clause.for_package;
AdaCore/libadalang
Ada
236
adb
with Ada.Text_IO; use Ada.Text_IO; procedure A is function "+" (X : Integer) return Integer is begin Put_Line ("Hello"); return X; end "+"; X : Boolean; begin X := (+1) > 0; pragma Test_Statement; end A;
Letractively/ada-el
Ada
2,330
adb
----------------------------------------------------------------------- -- methods -- Example of Method_Expression -- Copyright (C) 2010 Free Software Foundation, Inc. -- Written by Stephane Carrez ([email protected]) -- -- This file is part of ASF. -- -- This program is free software; you can redistribute it and/or -- modify it under the terms of the GNU General Public License as -- published by the Free Software Foundation; either version 2, -- or (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; see the file COPYING. If not, write to -- the Free Software Foundation, 59 Temple Place - Suite 330, -- Boston, MA 02111-1307, USA. ----------------------------------------------------------------------- with EL.Expressions; with EL.Objects; with EL.Contexts.Default; with EL.Methods; with EL.Methods.Func_String; with Ada.Text_IO; with Bean; procedure Methods is use Bean; use EL.Methods; Joe : Person_Access := Create_Person ("Joe", "Smith", 12); Bill : Person_Access := Create_Person ("Bill", "Johnson", 42); Ctx : EL.Contexts.Default.Default_Context; Method : EL.Expressions.Method_Expression; procedure Evaluate (Ctx : EL.Contexts.ELContext'Class; Msg : in String) is Result : constant String := Func_String.Execute (Method, Msg, Ctx); begin Ada.Text_IO.Put_Line ("#{user.print} returned: " & Result); end Evaluate; begin -- Get a method expression to invoke 'print' on the 'user' bean. -- The method expression does not know anything about 'user' (Joe or Bill). Method := EL.Expressions.Create_Expression ("#{user.print}", Ctx); -- Bind the context to 'Joe' and evaluate. Ctx.Set_Variable ("user", Joe); Evaluate (Ctx, "This is Joe"); -- Bind the context to 'Bill' and evaluate. Ctx.Set_Variable ("user", Bill); Evaluate (Ctx, "This is Bill"); Free (Joe); Free (Bill); end Methods;
yluo39github/MachineLearningSAT
Ada
13,182
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: test.adb,v 1.1 2008/12/11 02:41:27 xulin730 Exp $ -- The program has a few aims. -- 1. Test ZLib.Ada95 thick binding functionality. -- 2. Show the example of use main functionality of the ZLib.Ada95 binding. -- 3. Build this program automatically compile all ZLib.Ada95 packages under -- GNAT Ada95 compiler. with ZLib.Streams; with Ada.Streams.Stream_IO; with Ada.Numerics.Discrete_Random; with Ada.Text_IO; with Ada.Calendar; procedure Test is use Ada.Streams; use Stream_IO; ------------------------------------ -- Test configuration parameters -- ------------------------------------ File_Size : Count := 100_000; Continuous : constant Boolean := False; Header : constant ZLib.Header_Type := ZLib.Default; -- ZLib.None; -- ZLib.Auto; -- ZLib.GZip; -- Do not use Header other then Default in ZLib versions 1.1.4 -- and older. Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; Init_Random : constant := 10; -- End -- In_File_Name : constant String := "testzlib.in"; -- Name of the input file Z_File_Name : constant String := "testzlib.zlb"; -- Name of the compressed file. Out_File_Name : constant String := "testzlib.out"; -- Name of the decompressed file. File_In : File_Type; File_Out : File_Type; File_Back : File_Type; File_Z : ZLib.Streams.Stream_Type; Filter : ZLib.Filter_Type; Time_Stamp : Ada.Calendar.Time; procedure Generate_File; -- Generate file of spetsified size with some random data. -- The random data is repeatable, for the good compression. procedure Compare_Streams (Left, Right : in out Root_Stream_Type'Class); -- The procedure compearing data in 2 streams. -- It is for compare data before and after compression/decompression. procedure Compare_Files (Left, Right : String); -- Compare files. Based on the Compare_Streams. procedure Copy_Streams (Source, Target : in out Root_Stream_Type'Class; Buffer_Size : in Stream_Element_Offset := 1024); -- Copying data from one stream to another. It is for test stream -- interface of the library. procedure Data_In (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); -- this procedure is for generic instantiation of -- ZLib.Generic_Translate. -- reading data from the File_In. procedure Data_Out (Item : in Stream_Element_Array); -- this procedure is for generic instantiation of -- ZLib.Generic_Translate. -- writing data to the File_Out. procedure Stamp; -- Store the timestamp to the local variable. procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); -- Print the time statistic with the message. procedure Translate is new ZLib.Generic_Translate (Data_In => Data_In, Data_Out => Data_Out); -- This procedure is moving data from File_In to File_Out -- with compression or decompression, depend on initialization of -- Filter parameter. ------------------- -- Compare_Files -- ------------------- procedure Compare_Files (Left, Right : String) is Left_File, Right_File : File_Type; begin Open (Left_File, In_File, Left); Open (Right_File, In_File, Right); Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); Close (Left_File); Close (Right_File); end Compare_Files; --------------------- -- Compare_Streams -- --------------------- procedure Compare_Streams (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) is Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); Left_Last, Right_Last : Stream_Element_Offset; begin loop Read (Left, Left_Buffer, Left_Last); Read (Right, Right_Buffer, Right_Last); if Left_Last /= Right_Last then Ada.Text_IO.Put_Line ("Compare error :" & Stream_Element_Offset'Image (Left_Last) & " /= " & Stream_Element_Offset'Image (Right_Last)); raise Constraint_Error; elsif Left_Buffer (0 .. Left_Last) /= Right_Buffer (0 .. Right_Last) then Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); raise Constraint_Error; end if; exit when Left_Last < Left_Buffer'Last; end loop; end Compare_Streams; ------------------ -- Copy_Streams -- ------------------ procedure Copy_Streams (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; Buffer_Size : in Stream_Element_Offset := 1024) is Buffer : Stream_Element_Array (1 .. Buffer_Size); Last : Stream_Element_Offset; begin loop Read (Source, Buffer, Last); Write (Target, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Copy_Streams; ------------- -- Data_In -- ------------- procedure Data_In (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Read (File_In, Item, Last); end Data_In; -------------- -- Data_Out -- -------------- procedure Data_Out (Item : in Stream_Element_Array) is begin Write (File_Out, Item); end Data_Out; ------------------- -- Generate_File -- ------------------- procedure Generate_File is subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); Gen : Random_Elements.Generator; Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; Buffer_Count : constant Count := File_Size / Buffer'Length; -- Number of same buffers in the packet. Density : constant Count := 30; -- from 0 to Buffer'Length - 2; procedure Fill_Buffer (J, D : in Count); -- Change the part of the buffer. ----------------- -- Fill_Buffer -- ----------------- procedure Fill_Buffer (J, D : in Count) is begin for K in 0 .. D loop Buffer (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) := Random_Elements.Random (Gen); end loop; end Fill_Buffer; begin Random_Elements.Reset (Gen, Init_Random); Create (File_In, Out_File, In_File_Name); Fill_Buffer (1, Buffer'Length - 2); for J in 1 .. Buffer_Count loop Write (File_In, Buffer); Fill_Buffer (J, Density); end loop; -- fill remain size. Write (File_In, Buffer (1 .. Stream_Element_Offset (File_Size - Buffer'Length * Buffer_Count))); Flush (File_In); Close (File_In); end Generate_File; --------------------- -- Print_Statistic -- --------------------- procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is use Ada.Calendar; use Ada.Text_IO; package Count_IO is new Integer_IO (ZLib.Count); Curr_Dur : Duration := Clock - Time_Stamp; begin Put (Msg); Set_Col (20); Ada.Text_IO.Put ("size ="); Count_IO.Put (Data_Size, Width => Stream_IO.Count'Image (File_Size)'Length); Put_Line (" duration =" & Duration'Image (Curr_Dur)); end Print_Statistic; ----------- -- Stamp -- ----------- procedure Stamp is begin Time_Stamp := Ada.Calendar.Clock; end Stamp; begin Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); loop Generate_File; for Level in ZLib.Compression_Level'Range loop Ada.Text_IO.Put_Line ("Level =" & ZLib.Compression_Level'Image (Level)); -- Test generic interface. Open (File_In, In_File, In_File_Name); Create (File_Out, Out_File, Z_File_Name); Stamp; -- Deflate using generic instantiation. ZLib.Deflate_Init (Filter => Filter, Level => Level, Strategy => Strategy, Header => Header); Translate (Filter); Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); ZLib.Close (Filter); Close (File_In); Close (File_Out); Open (File_In, In_File, Z_File_Name); Create (File_Out, Out_File, Out_File_Name); Stamp; -- Inflate using generic instantiation. ZLib.Inflate_Init (Filter, Header => Header); Translate (Filter); Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); ZLib.Close (Filter); Close (File_In); Close (File_Out); Compare_Files (In_File_Name, Out_File_Name); -- Test stream interface. -- Compress to the back stream. Open (File_In, In_File, In_File_Name); Create (File_Back, Out_File, Z_File_Name); Stamp; ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.Out_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => True, Level => Level, Strategy => Strategy, Header => Header); Copy_Streams (Source => Stream (File_In).all, Target => File_Z); -- Flushing internal buffers to the back stream. ZLib.Streams.Flush (File_Z, ZLib.Finish); Print_Statistic ("Write compress", ZLib.Streams.Write_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_In); Close (File_Back); -- Compare reading from original file and from -- decompression stream. Open (File_In, In_File, In_File_Name); Open (File_Back, In_File, Z_File_Name); ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.In_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => True, Header => Header); Stamp; Compare_Streams (Stream (File_In).all, File_Z); Print_Statistic ("Read decompress", ZLib.Streams.Read_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_In); Close (File_Back); -- Compress by reading from compression stream. Open (File_Back, In_File, In_File_Name); Create (File_Out, Out_File, Z_File_Name); ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.In_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => False, Level => Level, Strategy => Strategy, Header => Header); Stamp; Copy_Streams (Source => File_Z, Target => Stream (File_Out).all); Print_Statistic ("Read compress", ZLib.Streams.Read_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_Out); Close (File_Back); -- Decompress to decompression stream. Open (File_In, In_File, Z_File_Name); Create (File_Back, Out_File, Out_File_Name); ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.Out_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => False, Header => Header); Stamp; Copy_Streams (Source => Stream (File_In).all, Target => File_Z); Print_Statistic ("Write decompress", ZLib.Streams.Write_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_In); Close (File_Back); Compare_Files (In_File_Name, Out_File_Name); end loop; Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); exit when not Continuous; File_Size := File_Size + 1; end loop; end Test;
AdaCore/libadalang
Ada
421
ads
-- Check that the size for constrained arrays is correctly reported as -- unsupported when it still depend on a value computed at runtime. package Pkg is function Compute_Something return Integer with Import; Upper_Bound : constant Integer := Compute_Something; type Bool_Array is array (Natural range 1 .. Upper_Bound) of Boolean; type Rec_Type is record BA : Bool_Array; end record; end Pkg;
reznikmm/matreshka
Ada
4,761
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Draw_Floating_Frame_Elements; package Matreshka.ODF_Draw.Floating_Frame_Elements is type Draw_Floating_Frame_Element_Node is new Matreshka.ODF_Draw.Abstract_Draw_Element_Node and ODF.DOM.Draw_Floating_Frame_Elements.ODF_Draw_Floating_Frame with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Draw_Floating_Frame_Element_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Floating_Frame_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Draw_Floating_Frame_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Draw_Floating_Frame_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Draw_Floating_Frame_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Draw.Floating_Frame_Elements;
reznikmm/matreshka
Ada
4,809
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Office_Automatic_Styles_Elements; package Matreshka.ODF_Office.Automatic_Styles_Elements is type Office_Automatic_Styles_Element_Node is new Matreshka.ODF_Office.Abstract_Office_Element_Node and ODF.DOM.Office_Automatic_Styles_Elements.ODF_Office_Automatic_Styles with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Office_Automatic_Styles_Element_Node; overriding function Get_Local_Name (Self : not null access constant Office_Automatic_Styles_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Office_Automatic_Styles_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Office_Automatic_Styles_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Office_Automatic_Styles_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Office.Automatic_Styles_Elements;
AdaCore/training_material
Ada
1,428
ads
with Radar_Internals; package Devices.Radars is type Event_T is record Object : Radar_Internals.Object_Type_T; Status : Radar_Internals.Object_Status_T; end record; protected Radar is entry Wait_Event (Event : out Event_T); -- Wait for the next radar event procedure Ping (Object : Radar_Internals.Object_Type_T); -- Ping an object, indicating it has been detected procedure Mark (Object : Radar_Internals.Object_Type_T); -- Mark an object, following it more closely. Only detected objects can be marked. procedure Lost (Object : Radar_Internals.Object_Type_T); -- Indicate that the object is out of range of the radar procedure Rotate; -- Rotate the radar by an arbitrary amount function Angle return Radar_Internals.Angle_Degrees_T; -- Current radar angle private --$ line question -- TODO: Fill in any needed objects --$ begin answer New_Event : Boolean := False; Event : Event_T; Rotation : Radar_Internals.Angle_Degrees_T; --$ end answer end Radar; task Radar_Detect is -- This task is in charge of detecting the objects and updating the radar accordingly end Radar_Detect; task Radar_Rotate is -- This task is in charge of cyclically rotating the radar end Radar_Rotate; end Devices.Radars;
zhmu/ananas
Ada
178
ads
-- { dg-excess-errors "cannot generate code" } package Concat1_Pkg is function Id_For (Name : String) return Natural; function Image_Of return String; end Concat1_Pkg;
reznikmm/matreshka
Ada
3,675
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Attributes.Style.Tab_Stop_Distance is type ODF_Style_Tab_Stop_Distance is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_Style_Tab_Stop_Distance is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.Style.Tab_Stop_Distance;
sebsgit/textproc
Ada
640
ads
with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; package GpuComponentLabelingTests is type TestCase is new AUnit.Test_Cases.Test_Case with null record; procedure Register_Tests(T: in out TestCase); function Name(T: TestCase) return Message_String; procedure initOpenCL(T: in out Test_Cases.Test_Case'Class); procedure testCreateContext(T: in out Test_Cases.Test_Case'Class); procedure testDetection(T: in out Test_Cases.Test_Case'Class); procedure testFullPipeline(T: in out Test_Cases.Test_Case'Class); procedure cleanup(T: in out Test_Cases.Test_Case'Class); end GpuComponentLabelingTests;
reznikmm/matreshka
Ada
4,376
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2009-2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Text_IO; with League.Application; with League.Strings.Debug; procedure Additional_Normalization_Test is use League.Strings; use League.Strings.Debug; S : Universal_String := To_Universal_String (Wide_Wide_Character'Val (16#0FB2#) & Wide_Wide_Character'Val (16#0591#) & Wide_Wide_Character'Val (16#0F81#) & Wide_Wide_Character'Val (16#0061#)); D : Universal_String := S.To_NFD; E : Universal_String := To_Universal_String (Wide_Wide_Character'Val (16#0FB2#) & Wide_Wide_Character'Val (16#0F71#) & Wide_Wide_Character'Val (16#0F80#) & Wide_Wide_Character'Val (16#0591#) & Wide_Wide_Character'Val (16#0061#)); begin if D /= E then Ada.Text_IO.Put_Line ("S => " & Debug_Image (S)); Ada.Text_IO.Put_Line ("NFD (S) => " & Debug_Image (D)); Ada.Text_IO.Put_Line ("Expected => " & Debug_Image (E)); raise Program_Error; end if; end Additional_Normalization_Test;
optikos/oasis
Ada
752
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Lexical_Elements is ----------- -- First -- ----------- function First (Self : Lexical_Element_Vector'Class) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Element (Self.First_Index); end First; ---------- -- Last -- ---------- function Last (Self : Lexical_Element_Vector'Class) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Element (Self.Last_Index); end Last; end Program.Lexical_Elements;
AdaCore/libadalang
Ada
363
adb
-- Check that p_base_types on classwide types returns an empty set, and that -- p_base_type is None. procedure Test is type I is interface; type T is tagged null record; type U is new I and T with null record; --% node.p_base_types() --% node.p_classwide_type.p_base_types() --% node.p_classwide_type.p_base_type() begin null; end Test;