repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
thorstel/Advent-of-Code-2018
Ada
1,723
adb
with Ada.Text_IO; use Ada.Text_IO; -- https://en.wikipedia.org/wiki/Summed-area_table procedure Day11 is -- Puzzle Input Serial_Number : constant Integer := 9445; function Power_Level (X, Y : Integer) return Integer is (((((((X + 10) * Y) + Serial_Number) * (X + 10)) / 100) mod 10) - 5); Sums : array (Natural range 0 .. 300, Natural range 0 .. 300) of Integer := (others => (others => 0)); Max_X : Natural := 0; Max_Y : Natural := 0; Max_Size : Natural := 0; Max_Power : Integer := Integer'First; begin -- Setup area table for Y in 1 .. 300 loop for X in 1 .. 300 loop Sums (X, Y) := Power_Level (X, Y) + Sums (X, Y - 1) + Sums (X - 1, Y ) - Sums (X - 1, Y - 1); end loop; end loop; for Size in 1 .. 300 loop for Y in Size .. 300 loop for X in Size .. 300 loop declare Power : constant Integer := Sums (X, Y ) - Sums (X, Y - Size) - Sums (X - Size, Y ) + Sums (X - Size, Y - Size); begin if Power > Max_Power then Max_X := X; Max_Y := Y; Max_Size := Size; Max_Power := Power; end if; end; end loop; end loop; end loop; Put_Line ("Part 2 =" & Natural'Image (Max_X - Max_Size + 1) & "," & Natural'Image (Max_Y - Max_Size + 1) & "," & Natural'Image (Max_Size)); end Day11;
reznikmm/matreshka
Ada
4,671
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.Capitalize_Entries_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Capitalize_Entries_Attribute_Node is begin return Self : Text_Capitalize_Entries_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_Capitalize_Entries_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Capitalize_Entries_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Capitalize_Entries_Attribute, Text_Capitalize_Entries_Attribute_Node'Tag); end Matreshka.ODF_Text.Capitalize_Entries_Attributes;
vpodzime/ada-util
Ada
1,225
ads
----------------------------------------------------------------------- -- basic properties -- Basic types properties -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010 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.Properties.Discrete; package Util.Properties.Basic is pragma Elaborate_Body; -- Get/Set boolean properties. package Boolean_Property is new Util.Properties.Discrete (Boolean); -- Get/Set integer properties. package Integer_Property is new Util.Properties.Discrete (Integer); end Util.Properties.Basic;
stcarrez/ada-awa
Ada
1,858
ads
----------------------------------------------------------------------- -- awa-storages-tests -- Unit tests for storages module -- Copyright (C) 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.Tests; with AWA.Tests; package AWA.Storages.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with record Folder_Ident : Ada.Strings.Unbounded.Unbounded_String; end record; -- Get some access on the wiki page as anonymous users. procedure Verify_Anonymous (T : in out Test; Page : in String; Title : in String); -- Verify that the wiki lists contain the given page. procedure Verify_List_Contains (T : in out Test; Page : in String); -- Test access to the wiki as anonymous user. procedure Test_Anonymous_Access (T : in out Test); -- Test creation of document by simulating web requests. procedure Test_Create_Document (T : in out Test); -- Test getting a document which does not exist. procedure Test_Missing_Document (T : in out Test); end AWA.Storages.Tests;
reznikmm/matreshka
Ada
4,741
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_Fo.Hyphenation_Remain_Char_Count_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Hyphenation_Remain_Char_Count_Attribute_Node is begin return Self : Fo_Hyphenation_Remain_Char_Count_Attribute_Node do Matreshka.ODF_Fo.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Fo_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Fo_Hyphenation_Remain_Char_Count_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Hyphenation_Remain_Char_Count_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Fo_URI, Matreshka.ODF_String_Constants.Hyphenation_Remain_Char_Count_Attribute, Fo_Hyphenation_Remain_Char_Count_Attribute_Node'Tag); end Matreshka.ODF_Fo.Hyphenation_Remain_Char_Count_Attributes;
zhmu/ananas
Ada
7,014
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . D I M . F L O A T _ I O -- -- -- -- S p e c -- -- -- -- Copyright (C) 2011-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides output routines for float dimensioned types. All Put -- routines are modeled after those in package Ada.Text_IO.Float_IO with the -- addition of an extra default parameter. All Put_Dim_Of routines -- output the dimension of Item in a symbolic manner. -- Parameter Symbol may be used in the following manner (all the examples are -- based on the MKS system of units defined in package System.Dim.Mks): -- type Mks_Type is new Long_Long_Float -- with -- Dimension_System => ( -- (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'), -- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'), -- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'), -- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'), -- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => '@'), -- (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'), -- (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J')); -- Case 1. A value is supplied for Symbol -- * Put : The string appears as a suffix of Item -- * Put_Dim_Of : The string appears alone -- Obj : Mks_Type := 2.6; -- Put (Obj, 1, 1, 0, " dimensionless"); -- Put_Dim_Of (Obj, "dimensionless"); -- The corresponding outputs are: -- $2.6 dimensionless -- $dimensionless -- Case 2. No value is supplied for Symbol and Item is dimensionless -- * Put : Item appears without a suffix -- * Put_Dim_Of : the output is [] -- Obj : Mks_Type := 2.6; -- Put (Obj, 1, 1, 0); -- Put_Dim_Of (Obj); -- The corresponding outputs are: -- $2.6 -- $[] -- Case 3. No value is supplied for Symbol and Item has a dimension -- * Put : If the type of Item is a dimensioned subtype whose -- symbol is not empty, then the symbol appears as a suffix. -- Otherwise, a new string is created and appears as a -- suffix of Item. This string results in the successive -- concatenations between each unit symbol raised by its -- corresponding dimension power from the dimensions of Item. -- * Put_Dim_Of : The output is a new string resulting in the successive -- concatenations between each dimension symbol raised by its -- corresponding dimension power from the dimensions of Item. -- subtype Length is Mks_Type -- with -- Dimension => ('m', -- Meter => 1, -- others => 0); -- Obj : Length := 2.3 * dm; -- Put (Obj, 1, 2, 0); -- Put_Dim_Of (Obj); -- The corresponding outputs are: -- $0.23 m -- $[L] -- subtype Random is Mks_Type -- with -- Dimension => ( -- Meter => 3, -- Candela => -1, -- others => 0); -- Obj : Random := 5.0; -- Put (Obj); -- Put_Dim_Of (Obj); -- The corresponding outputs are: -- $5.0 m**3.cd**(-1) -- $[l**3.J**(-1)] -- Put (3.3 * km * dm * min, 5, 1, 0); -- Put_Dim_Of (3.3 * km * dm * min); -- The corresponding outputs are: -- $19800.0 m**2.s -- $[L**2.T] with Ada.Text_IO; use Ada.Text_IO; generic type Num_Dim_Float is digits <>; package System.Dim.Float_IO is Default_Fore : Field := 2; Default_Aft : Field := Num_Dim_Float'Digits - 1; Default_Exp : Field := 3; procedure Put (File : File_Type; Item : Num_Dim_Float; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp; Symbol : String := ""); procedure Put (Item : Num_Dim_Float; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp; Symbol : String := ""); procedure Put (To : out String; Item : Num_Dim_Float; Aft : Field := Default_Aft; Exp : Field := Default_Exp; Symbol : String := ""); procedure Put_Dim_Of (File : File_Type; Item : Num_Dim_Float; Symbol : String := ""); procedure Put_Dim_Of (Item : Num_Dim_Float; Symbol : String := ""); procedure Put_Dim_Of (To : out String; Item : Num_Dim_Float; Symbol : String := ""); pragma Inline (Put); pragma Inline (Put_Dim_Of); function Image (Item : Num_Dim_Float; Aft : Field := Default_Aft; Exp : Field := Default_Exp; Symbol : String := "") return String; end System.Dim.Float_IO;
amondnet/openapi-generator
Ada
13,460
adb
-- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- -- The version of the OpenAPI document: 1.0.0 -- -- -- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. package body Samples.Petstore.Models is pragma Style_Checks ("-bmrIu"); pragma Warnings (Off, "*use clause for package*"); use Swagger.Streams; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Samples.Petstore.Models.ApiResponse_Type) is begin Into.Start_Entity (Name); if not Value.Code.Is_Null then Into.Write_Entity ("code", Value.Code); end if; if not Value.P_Type.Is_Null then Into.Write_Entity ("type", Value.P_Type); end if; if not Value.Message.Is_Null then Into.Write_Entity ("message", Value.Message); end if; Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Samples.Petstore.Models.ApiResponse_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "code", Value.Code); Swagger.Streams.Deserialize (Object, "type", Value.P_Type); Swagger.Streams.Deserialize (Object, "message", Value.Message); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : in out ApiResponse_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Samples.Petstore.Models.ApiResponse_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Samples.Petstore.Models.Category_Type) is begin Into.Start_Entity (Name); if not Value.Id.Is_Null then Into.Write_Entity ("id", Value.Id); end if; if not Value.Name.Is_Null then Into.Write_Entity ("name", Value.Name); end if; Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Samples.Petstore.Models.Category_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "name", Value.Name); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : in out Category_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Samples.Petstore.Models.Category_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Samples.Petstore.Models.Order_Type) is begin Into.Start_Entity (Name); if not Value.Id.Is_Null then Into.Write_Entity ("id", Value.Id); end if; if not Value.Pet_Id.Is_Null then Into.Write_Entity ("petId", Value.Pet_Id); end if; if not Value.Quantity.Is_Null then Into.Write_Entity ("quantity", Value.Quantity); end if; if not Value.Ship_Date.Is_Null then Into.Write_Entity ("shipDate", Value.Ship_Date); end if; if not Value.Status.Is_Null then Into.Write_Entity ("status", Value.Status); end if; if not Value.Complete.Is_Null then Into.Write_Entity ("complete", Value.Complete); end if; Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Samples.Petstore.Models.Order_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "petId", Value.Pet_Id); Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity); Swagger.Streams.Deserialize (Object, "shipDate", Value.Ship_Date); Swagger.Streams.Deserialize (Object, "status", Value.Status); Swagger.Streams.Deserialize (Object, "complete", Value.Complete); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : in out Order_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Samples.Petstore.Models.Order_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Samples.Petstore.Models.Tag_Type) is begin Into.Start_Entity (Name); if not Value.Id.Is_Null then Into.Write_Entity ("id", Value.Id); end if; if not Value.Name.Is_Null then Into.Write_Entity ("name", Value.Name); end if; Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Samples.Petstore.Models.Tag_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "name", Value.Name); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : in out Tag_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Samples.Petstore.Models.Tag_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Samples.Petstore.Models.User_Type) is begin Into.Start_Entity (Name); if not Value.Id.Is_Null then Into.Write_Entity ("id", Value.Id); end if; if not Value.Username.Is_Null then Into.Write_Entity ("username", Value.Username); end if; if not Value.First_Name.Is_Null then Into.Write_Entity ("firstName", Value.First_Name); end if; if not Value.Last_Name.Is_Null then Into.Write_Entity ("lastName", Value.Last_Name); end if; if not Value.Email.Is_Null then Into.Write_Entity ("email", Value.Email); end if; if not Value.Password.Is_Null then Into.Write_Entity ("password", Value.Password); end if; if not Value.Phone.Is_Null then Into.Write_Entity ("phone", Value.Phone); end if; if not Value.User_Status.Is_Null then Into.Write_Entity ("userStatus", Value.User_Status); end if; Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Samples.Petstore.Models.User_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "username", Value.Username); Swagger.Streams.Deserialize (Object, "firstName", Value.First_Name); Swagger.Streams.Deserialize (Object, "lastName", Value.Last_Name); Swagger.Streams.Deserialize (Object, "email", Value.Email); Swagger.Streams.Deserialize (Object, "password", Value.Password); Swagger.Streams.Deserialize (Object, "phone", Value.Phone); Swagger.Streams.Deserialize (Object, "userStatus", Value.User_Status); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : in out User_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Samples.Petstore.Models.User_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Samples.Petstore.Models.Pet_Type) is begin Into.Start_Entity (Name); if not Value.Id.Is_Null then Into.Write_Entity ("id", Value.Id); end if; Serialize (Into, "category", Value.Category); Into.Write_Entity ("name", Value.Name); Serialize (Into, "photoUrls", Value.Photo_Urls); Serialize (Into, "tags", Value.Tags); if not Value.Status.Is_Null then Into.Write_Entity ("status", Value.Status); end if; Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Samples.Petstore.Models.Pet_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Deserialize (Object, "category", Value.Category); Swagger.Streams.Deserialize (Object, "name", Value.Name); Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls); Deserialize (Object, "tags", Value.Tags); Swagger.Streams.Deserialize (Object, "status", Value.Status); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : in out Pet_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Samples.Petstore.Models.Pet_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; end Samples.Petstore.Models;
zhmu/ananas
Ada
2,531
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . S T R I N G S . B O U N D E D . H A S H -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with System.String_Hash; function Ada.Strings.Bounded.Hash (Key : Bounded.Bounded_String) return Containers.Hash_Type is use Ada.Containers; function Hash_Fun is new System.String_Hash.Hash (Character, String, Hash_Type); begin return Hash_Fun (Bounded.To_String (Key)); end Ada.Strings.Bounded.Hash;
charlie5/lace
Ada
1,051
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with c_math_c; with c_math_c.Vector_3; with interfaces.C; package box2d_c.b2d_ray_Collision is -- Item -- type Item is record near_Object : access box2d_c.Object; hit_Fraction : aliased c_math_c.Real; Normal_world : aliased c_math_c.Vector_3.Item; Site_world : aliased c_math_c.Vector_3.Item; end record; -- Items -- type Items is array (interfaces.C.Size_t range <>) of aliased box2d_c.b2d_ray_Collision.Item; -- Pointer -- type Pointer is access all box2d_c.b2d_ray_Collision.Item; -- Pointers -- type Pointers is array (interfaces.C.Size_t range <>) of aliased box2d_c.b2d_ray_Collision.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all box2d_c.b2d_ray_Collision.Pointer; function construct return box2d_c.b2d_ray_Collision.Item; private pragma Import (C, construct, "Ada_new_b2d_ray_Collision"); end box2d_c.b2d_ray_Collision;
zhmu/ananas
Ada
4,375
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R E A M S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package Ada.Streams is pragma Pure; type Root_Stream_Type is abstract tagged limited private; pragma Preelaborable_Initialization (Root_Stream_Type); type Stream_Element is mod 2 ** Standard'Storage_Unit; type Stream_Element_Offset is new Long_Long_Integer; -- Stream_Element_Offset needs 64 bits to accommodate large stream files. -- However, rather than make this explicitly 64-bits we derive from -- Long_Long_Integer. In normal usage this will have the same effect. -- But in the case of CodePeer with a target configuration file with a -- maximum integer size of 32, it allows analysis of this unit. subtype Stream_Element_Count is Stream_Element_Offset range 0 .. Stream_Element_Offset'Last; type Stream_Element_Array is array (Stream_Element_Offset range <>) of aliased Stream_Element; procedure Read (Stream : in out Root_Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is abstract; procedure Write (Stream : in out Root_Stream_Type; Item : Stream_Element_Array) is abstract; private type Root_Stream_Type is abstract tagged limited null record; -- Stream attributes for Stream_Element_Array: trivially call the -- corresponding stream primitive for the whole array, instead of doing -- so element by element. procedure Read_SEA (S : access Root_Stream_Type'Class; V : out Stream_Element_Array); procedure Write_SEA (S : access Root_Stream_Type'Class; V : Stream_Element_Array); for Stream_Element_Array'Read use Read_SEA; for Stream_Element_Array'Write use Write_SEA; end Ada.Streams;
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.Form_Spin_Button_Attributes is pragma Preelaborate; type ODF_Form_Spin_Button_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Spin_Button_Attribute_Access is access all ODF_Form_Spin_Button_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Spin_Button_Attributes;
optikos/oasis
Ada
286
ads
with Anagram.Grammars; with Program.Parsers.Nodes; private procedure Program.Parsers.On_Reduce_2001 (Self : access Parse_Context; Prod : Anagram.Grammars.Production_Index; Nodes : in out Program.Parsers.Nodes.Node_Array); pragma Preelaborate (Program.Parsers.On_Reduce_2001);
stcarrez/hyperion
Ada
2,354
ads
-- Hyperion API -- Hyperion Monitoring API The monitoring agent is first registered so that the server knows it as well as its security key. Each host are then registered by a monitoring agent. -- ------------ EDIT NOTE ------------ -- This file was generated with swagger-codegen. You can modify it to implement -- the server. After you modify this file, you should add the following line -- to the .swagger-codegen-ignore file: -- -- src/hyperion-rest-servers.ads -- -- Then, you can drop this edit note comment. -- ------------ EDIT NOTE ------------ with Swagger.Servers; with Hyperion.Rest.Models; with Hyperion.Rest.Skeletons; package Hyperion.Rest.Servers is use Hyperion.Rest.Models; type Server_Type is limited new Hyperion.Rest.Skeletons.Server_Type with null record; -- Register a monitoring agent -- Register a new monitoring agent in the system overriding procedure Register_Agent (Server : in out Server_Type; Name : in Swagger.UString; Ip : in Swagger.UString; Agent_Key : in Swagger.UString; Result : out Hyperion.Rest.Models.Agent_Type; Context : in out Swagger.Servers.Context_Type); -- Create a host -- Register a new host in the monitoring system overriding procedure Create_Host (Server : in out Server_Type; Name : in Swagger.UString; Ip : in Swagger.UString; Host_Key : in Swagger.UString; Agent_Key : in Swagger.UString; Agent_Id : in Integer; Result : out Hyperion.Rest.Models.Host_Type; Context : in out Swagger.Servers.Context_Type); -- Get information about the host -- Provide information about the host procedure Get_Host (Server : in out Server_Type; Host_Id : in Swagger.Long; Result : out Hyperion.Rest.Models.Host_Type; Context : in out Swagger.Servers.Context_Type); -- Get information about the host datasets -- The datasets describes and gives access to the monitored data. overriding procedure Get_Datasets (Server : in out Server_Type; Host_Id : in Swagger.Long; Result : out Hyperion.Rest.Models.Dataset_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type); procedure Register (Server : in out Swagger.Servers.Application_Type'Class); end Hyperion.Rest.Servers;
reznikmm/matreshka
Ada
12,156
adb
-- -- TITLE: package body Error_Report_File -- Output the code which allows users to see what the error token was. -- This is for non-correctable errors. -- Also in this package: The declaration of user actions for correctable -- (continuable) errors. -- -- LANGUAGE: -- Ada -- -- PERSONNEL: -- AUTHOR: Benjamin Hurwitz -- DATE: Jul 27 1990 -- -- OVERVIEW: -- Parse the last section of the .y file, looking for -- %report_continuable_error and the related procedures. From these, -- generate procedure bodies which will be called from yyparse when -- there is an error which has been corrected. Since the errors get -- corrected, yyerror does not get called. -- with Ada.Characters.Handling; with Ada.Strings.Unbounded; with Ayacc_File_Names, Text_IO, Source_File; use Ayacc_File_Names, Text_IO; package body Error_Report_File is use Ada.Characters.Handling; use Ada.Strings.Unbounded; function "+" (Item : String) return Unbounded_String renames To_Unbounded_String; function "+" (Item : Unbounded_String) return String renames To_String; max_line_length : constant integer := 370; The_File : File_Type; -- Where the error report goes Text : String(1..max_line_length); -- Current line from source file Length : Natural := 1; -- and its length -- types of lines found in the continuable error report section type user_defined_thing is (with_thing, use_thing, init_thing, report_thing, finish_thing, line_thing, eof_thing); -------------------- -- get_next_thing -- -------------------- -- -- TITLE: -- Get Next Thing : Classify a line of text from the user defined error -- report section of the .y file -- -- OVERVIEW: -- Read one line of the .y file, classifying it. -- In the case of a %use or %with line, set the global variables Text and -- Length to the tail of the line after the %use or %with. -- ................................................... procedure get_next_thing (thing : in out user_defined_thing) is with_string : constant string := "%WITH"; use_string : constant string := "%USE"; init_string : constant string := "%INITIALIZE_ERROR_REPORT"; finish_string : constant string:= "%TERMINATE_ERROR_REPORT"; report_string : constant string:= "%REPORT_ERROR"; temp : Unbounded_String; begin if thing = eof_thing or else Source_File.is_end_of_file then thing := eof_thing; return; end if; Source_File.Read_Line (Text, Length); if length >= use_string'length then temp := +text (1..use_string'length); if To_Upper (+temp) = use_string then thing := use_thing; length := length - use_string'length; text(1..length) := text((use_string'length + 1) .. length + use_string'length); return; end if; end if; if length >= with_string'length then temp := +text(1..with_string'length); if To_Upper (+temp) = with_string then thing := with_thing; length := length - with_string'length; text(1..length) := text((with_string'length + 1) .. length + with_string'length); return; end if; end if; if length >= init_string'length then temp := +text(1..init_string'length); if To_Upper (+temp) = init_string then thing := init_thing; return; end if; end if; if length >= finish_string'length then temp := +text(1..finish_string'length); if To_Upper (+temp) = finish_string then thing := finish_thing; return; end if; end if; if length >= report_string'length then temp := +text(1..report_string'length); if To_Upper (+temp) = report_string then thing := report_thing; return; end if; end if; thing := line_thing; end get_next_thing; -- -- TITLE: procedure Write_Line -- Write out a line to the Error Report generated ada file. -- -- OVERVIEW: -- -- ................................................... procedure Write_Line(S: in String) is begin Put_Line(The_File, S); end Write_Line; -- -- TITLE: -- Write the body of one of the user-defined procedures -- -- OVERVIEW: -- If User is True it means the user is defining the procedure body. So -- copy it from the source file. Otherwise provide a null body. -- ................................................... procedure write_thing(user : in boolean; thing : in out user_defined_thing) is begin if user then loop get_next_thing(thing); exit when thing /= line_thing; Write_Line(Text(1..length)); end loop; else Write_Line("begin"); Write_Line(" null;"); Write_Line("end;"); end if; Write_Line(""); end write_thing; -- -- TITLE: -- Write the error report initialization function -- -- OVERVIEW: -- Write the header & then then body -- ................................................... procedure write_init(user : in boolean; thing : in out user_defined_thing) is begin Write_Line("procedure Initialize_User_Error_Report is"); write_thing(user, thing); end write_init; -- -- TITLE: -- Write the error report completion function -- -- OVERVIEW: -- Write the header & then then body -- ................................................... procedure write_finish(user : in boolean; thing : in out user_defined_thing) is begin Write_Line("procedure Terminate_User_Error_Report is"); write_thing(user, thing); end write_finish; -- -- TITLE: -- Write the error report function -- -- OVERVIEW: -- Write out the header with signature and then the body. -- ................................................... procedure write_report(user : in boolean; thing : in out user_defined_thing) is begin Write_Line("procedure Report_Continuable_Error "); Write_Line(" (Line_Number : in Natural;"); Write_Line(" Offset : in Natural;"); Write_Line(" Finish : in Natural;"); Write_Line(" Message : in String;"); Write_Line(" Error : in Boolean) is"); write_thing(user, thing); end write_report; -- -- TITLE: procedure Write_File -- Create & open the Error_Report file, dump its contents. -- -- PERSONNEL: -- AUTHOR: Benjamin Hurwitz -- DATE: Mar 11 1990 -- -- OVERVIEW: -- The file being created will be used to report errors which yyparse -- encounters. Some of them it can correct, and some it cannot. -- There are different mechanisms for reporting each of these. There -- is default reporting of corrected errors; messages are written -- into the .lis file (Put, Put_Line). Also, -- the user can define his/her own error reporting of correctable errors -- in the last section of the .y file. If so, we here construct the -- error report file so as to use these procedures. -- Also in this package are variables and routines to -- manipulate error information which the user can call from yyerror, -- the procedure called when a non-correctable error is encountered. -- The things generated which vary with runs of Ayacc is the names -- of the Ada units, the packages With'ed and Used by the generated -- error report package body and the bodies of the user-defined error report -- routines for continuable errors. -- -- NOTES: -- This procedure is exported from the package. -- -- SUBPROGRAM BODY: -- procedure Write_File is current_thing : user_defined_thing := line_thing; wrote_init : boolean := false; wrote_finish : boolean := false; wrote_report : boolean := false; begin Create(The_File, Out_File, Get_Error_Report_File_Name & "ds"); Write_Line("package " & Error_Report_Unit_Name & " is"); Write_Line(""); Write_Line(" Syntax_Error : Exception;"); Write_Line(" Syntax_Warning : Exception;"); Write_Line(" Total_Errors : Natural := 0; -- number of syntax errors found." ); Write_Line(" Total_Warnings : Natural := 0; -- number of syntax warnings found." ); Write_Line(" "); Write_Line(" procedure Report_Continuable_Error(Line_Number : in Natural;"); Write_Line(" Offset : in Natural;"); Write_Line(" Finish : in Natural;"); Write_Line(" Message : in String;"); Write_Line(" Error : in Boolean);"); Write_Line(""); Write_Line(" procedure Initialize_Output;"); Write_Line(""); Write_Line(" procedure Finish_Output;"); Write_Line(""); Write_Line(" procedure Put(S: in String);"); Write_Line(""); Write_Line(" procedure Put(C: in Character);"); Write_Line(""); Write_Line(" procedure Put_Line(S: in String);"); Write_Line(""); Write_Line("end " & Error_Report_Unit_Name & ";"); Close(The_File); Create(The_File, Out_File, Get_Error_Report_File_Name & "db"); Write_Line("with Text_IO;"); -- Get %with's & %use's from source file loop get_next_thing(current_thing); if current_thing = with_thing then Write_Line("With " & text(1..length)); elsif current_thing = use_thing then Write_Line("Use " & text(1..length)); elsif current_thing = line_thing then null; else exit; end if; end loop; Write_Line(""); Write_Line("package body " & Error_Report_Unit_Name & " is"); Write_Line(""); Write_Line(" The_File : Text_io.File_Type;"); Write_Line(""); -- Get user declarations of error reporting procedures from source file while(current_thing /= eof_thing) loop if current_thing = init_thing then Write_init(true, current_thing); wrote_init := true; elsif current_thing = finish_thing then Write_finish(true, current_thing); wrote_finish := true; elsif current_thing = report_thing then Write_report(true, current_thing); wrote_report := true; else get_next_thing(current_thing); end if; end loop; if not wrote_init then Write_init(false, current_thing); end if; if not wrote_finish then Write_finish(false, current_thing); end if; if not wrote_report then Write_report(false, current_thing); end if; Write_Line(""); Write_Line(" procedure Initialize_Output is"); Write_Line(" begin"); Write_Line(" Text_io.Create(The_File, Text_io.Out_File, " & '"' & Get_Listing_File_Name & '"' & ");"); Write_Line(" initialize_user_error_report;"); Write_Line(" end Initialize_Output;"); Write_Line(""); Write_Line(" procedure Finish_Output is"); Write_Line(" begin"); Write_Line(" Text_io.Close(The_File);"); Write_Line(" terminate_user_error_report;"); Write_Line(" end Finish_Output;"); Write_Line(""); Write_Line(" procedure Put(S: in String) is"); Write_Line(" begin"); Write_Line(" Text_io.put(The_File, S);"); Write_Line(" end Put;"); Write_Line(""); Write_Line(" procedure Put(C: in Character) is"); Write_Line(" begin"); Write_Line(" Text_io.put(The_File, C);"); Write_Line(" end Put;"); Write_Line(""); Write_Line(" procedure Put_Line(S: in String) is"); Write_Line(" begin"); Write_Line(" Text_io.put_Line(The_File, S);"); Write_Line(" end Put_Line;"); Write_Line(""); Write_Line(""); Write_Line("end " & Error_Report_Unit_Name & ";"); Close(The_File); end Write_File; -- ................................................... begin null; end Error_Report_File;
charlie5/cBound
Ada
1,329
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with xcb.xcb_glx_generic_error_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_bad_pixmap_error_t is -- Item -- subtype Item is xcb.xcb_glx_generic_error_t.Item; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_bad_pixmap_error_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_bad_pixmap_error_t.Item, Element_Array => xcb.xcb_glx_bad_pixmap_error_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_bad_pixmap_error_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_bad_pixmap_error_t.Pointer, Element_Array => xcb.xcb_glx_bad_pixmap_error_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_bad_pixmap_error_t;
zhmu/ananas
Ada
184
adb
-- { dg-do run } with Text_IO; use Text_IO; with Generic_Inst6_I2; procedure Generic_Inst6 is begin if Generic_Inst6_I2.Check /= 49 then raise Program_Error; end if; end;
persan/AdaYaml
Ada
1,342
ads
with GNAT.Sockets.Connection_State_Machine.HTTP_Server; with GNAT.Sockets.Server; package Yaml.Servers is package HTTP renames GNAT.Sockets.Connection_State_Machine.HTTP_Server; package Server renames GNAT.Sockets.Server; type Yaml_Factory (Request_Length : Positive; Input_Size : Server.Buffer_Length; Output_Size : Server.Buffer_Length; Max_Connections : Positive) is new Server.Connections_Factory with null record; type Yaml_Client is new HTTP.HTTP_Client with null record; pragma Warnings (Off, "formal parameter ""From"" is not referenced"); overriding function Create (Factory : access Yaml_Factory; Listener : access Server.Connections_Server'Class; From : GNAT.Sockets.Sock_Addr_Type) return Server.Connection_Ptr is (new Yaml_Client (Listener => Listener.all'Unchecked_Access, Request_Length => Factory.Request_Length, Input_Size => Factory.Input_Size, Output_Size => Factory.Output_Size)); pragma Warnings (On, "formal parameter ""From"" is not referenced"); overriding procedure Do_Get (Client : in out Yaml_Client); end Yaml.Servers;
onox/orka
Ada
3,990
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Drawing; package body Orka.Rendering.Drawing is procedure Draw (Mode : GL.Types.Connection_Mode; Offset, Count : Natural; Instances : Positive := 1) is begin GL.Drawing.Draw_Arrays (Mode, Offset => Size (Offset), Count => Size (Count), Instances => Size (Instances)); end Draw; procedure Draw_Indexed (Mode : GL.Types.Connection_Mode; Index_Buffer : Buffers.Buffer; Offset, Count : Natural; Instances : Positive := 1) is use all type Rendering.Buffers.Buffer_Target; begin Index_Buffer.Bind (Index); GL.Drawing.Draw_Elements (Mode, Count => Size (Count), Index_Kind => Orka.Types.Convert (Index_Buffer.Kind), Index_Offset => Offset, Instances => Size (Instances)); end Draw_Indexed; ----------------------------------------------------------------------------- procedure Draw_Indirect (Mode : GL.Types.Connection_Mode; Buffer : Buffers.Buffer; Offset, Count : Natural) is use all type Rendering.Buffers.Buffer_Target; begin Buffer.Bind (Draw_Indirect); GL.Drawing.Draw_Multiple_Arrays_Indirect (Mode, Count => Size (Count), Offset => Size (Offset)); end Draw_Indirect; procedure Draw_Indirect (Mode : GL.Types.Connection_Mode; Buffer : Buffers.Buffer) is begin Draw_Indirect (Mode, Buffer, Offset => 0, Count => Buffer.Length); end Draw_Indirect; procedure Draw_Indirect (Mode : GL.Types.Connection_Mode; Buffer, Count : Buffers.Buffer) is use all type Rendering.Buffers.Buffer_Target; begin Buffer.Bind (Draw_Indirect); Count.Bind (Parameter); GL.Drawing.Draw_Multiple_Arrays_Indirect_Count (Mode, Size (Buffer.Length)); end Draw_Indirect; ----------------------------------------------------------------------------- procedure Draw_Indexed_Indirect (Mode : GL.Types.Connection_Mode; Index_Buffer : Buffers.Buffer; Buffer : Buffers.Buffer; Offset, Count : Natural) is use all type Rendering.Buffers.Buffer_Target; begin Index_Buffer.Bind (Index); Buffer.Bind (Draw_Indirect); GL.Drawing.Draw_Multiple_Elements_Indirect (Mode, Orka.Types.Convert (Index_Buffer.Kind), Count => Size (Count), Offset => Size (Offset)); end Draw_Indexed_Indirect; procedure Draw_Indexed_Indirect (Mode : GL.Types.Connection_Mode; Index_Buffer : Buffers.Buffer; Buffer : Buffers.Buffer) is begin Draw_Indexed_Indirect (Mode, Index_Buffer, Buffer, Offset => 0, Count => Buffer.Length); end Draw_Indexed_Indirect; procedure Draw_Indexed_Indirect (Mode : GL.Types.Connection_Mode; Index_Buffer : Buffers.Buffer; Buffer, Count : Buffers.Buffer) is use all type Rendering.Buffers.Buffer_Target; begin Index_Buffer.Bind (Index); Buffer.Bind (Draw_Indirect); Count.Bind (Parameter); GL.Drawing.Draw_Multiple_Elements_Indirect_Count (Mode, Orka.Types.Convert (Index_Buffer.Kind), Size (Buffer.Length)); end Draw_Indexed_Indirect; end Orka.Rendering.Drawing;
AdaCore/Ada_Drivers_Library
Ada
3,406
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with STM32.Device; use STM32.Device; with STM32.ADC; use STM32.ADC; package body ADC_Interrupt_Handling is protected body VBat_Reader is ------------- -- Voltage -- ------------- function Voltage return UInt32 is Result : UInt32; begin Result := ((Counts * VBat_Bridge_Divisor) * ADC_Supply_Voltage) / 16#FFF#; -- 16#FFF# because we are using 12-bit conversion resolution return Result; end Voltage; ----------------- -- IRQ_Handler -- ----------------- procedure IRQ_Handler is begin if Status (VBat.ADC.all, Regular_Channel_Conversion_Complete) then if Interrupt_Enabled (VBat.ADC.all, Regular_Channel_Conversion_Complete) then Clear_Interrupt_Pending (VBat.ADC.all, Regular_Channel_Conversion_Complete); Counts := UInt32 (Conversion_Value (VBat.ADC.all)); end if; end if; end IRQ_Handler; end VBat_Reader; end ADC_Interrupt_Handling;
reznikmm/matreshka
Ada
4,600
ads
------------------------------------------------------------------------------ -- -- -- 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. ------------------------------------------------------------------------------ package AMF.Internals.Tables.Standard_Profile_L3_Metamodel.Objects is procedure Initialize; private procedure Initialize_1 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_2 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_3 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_4 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_5 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_6 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_7 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_8 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_9 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_10 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_11 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_12 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_13 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_14 (Extent : AMF.Internals.AMF_Extent); procedure Initialize_15 (Extent : AMF.Internals.AMF_Extent); end AMF.Internals.Tables.Standard_Profile_L3_Metamodel.Objects;
reznikmm/matreshka
Ada
3,963
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.Chart_Deep_Attributes; package Matreshka.ODF_Chart.Deep_Attributes is type Chart_Deep_Attribute_Node is new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node and ODF.DOM.Chart_Deep_Attributes.ODF_Chart_Deep_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Chart_Deep_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Deep_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Chart.Deep_Attributes;
AdaCore/libadalang
Ada
90
ads
package Foo.Bar is end Foo.Bar; pragma Convention (Java, Foo.Bar); pragma Test_Statement;
wildeee/safADA
Ada
150
adb
With Ada.Text_IO; Use Ada.Text_IO; Procedure HelloWorld is begin Put("Programacao em Ada!"); New_Line; Put_Line("Hello World!!"); end HelloWorld;
ohenley/ada-util
Ada
2,576
adb
----------------------------------------------------------------------- -- util-beans-objects-datasets-tests -- Unit tests for dataset beans -- Copyright (C) 2013, 2015, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; package body Util.Beans.Objects.Datasets.Tests is package Caller is new Util.Test_Caller (Test, "Objects.Datasets"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Beans.Objects.Datasets", Test_Fill_Dataset'Access); end Add_Tests; -- Test the creation, initialization and retrieval of dataset content. procedure Test_Fill_Dataset (T : in out Test) is procedure Fill (Row : in out Object_Array); Set : Dataset; procedure Fill (Row : in out Object_Array) is begin Row (Row'First) := To_Object (String '("john")); Row (Row'First + 1) := To_Object (String '("[email protected]")); Row (Row'First + 2) := To_Object (Set.Get_Count); end Fill; begin Set.Add_Column ("name"); Set.Add_Column ("email"); Set.Add_Column ("age"); for I in 1 .. 100 loop Set.Append (Fill'Access); end loop; Util.Tests.Assert_Equals (T, 100, Set.Get_Count, "Invalid number of rows"); for I in 1 .. 100 loop Set.Set_Row_Index (I); declare R : constant Object := Set.Get_Row; begin T.Assert (not Is_Null (R), "Row is null"); Util.Tests.Assert_Equals (T, "john", To_String (Get_Value (R, "name")), "Invalid 'name' attribute"); Util.Tests.Assert_Equals (T, I, To_Integer (Get_Value (R, "age")), "Invalid 'age' attribute"); end; end loop; end Test_Fill_Dataset; end Util.Beans.Objects.Datasets.Tests;
sparre/Ada-2012-Examples
Ada
1,031
ads
package Variant_Records is type Word_Sizes is range 8 .. 64 with Static_Predicate => Word_Sizes in 8 | 16 | 32 | 64; type Data_8_Bit is mod 2 ** 8 with Size => 8; type Data_16_Bit is mod 2 ** 16 with Size => 16; type Data_32_Bit is mod 2 ** 32 with Size => 32; type Data_64_Bit is mod 2 ** 64 with Size => 64; type Array_8_Bit is array (Positive range <>) of Data_8_Bit; type Array_16_Bit is array (Positive range <>) of Data_16_Bit; type Array_32_Bit is array (Positive range <>) of Data_32_Bit; type Array_64_Bit is array (Positive range <>) of Data_64_Bit; type Data_Array (Word_Size : Word_Sizes; Length : Natural) is record case Word_Size is when 8 => Data_8 : Array_8_Bit (1 .. Length); when 16 => Data_16 : Array_16_Bit (1 .. Length); when 32 => Data_32 : Array_32_Bit (1 .. Length); when 64 => Data_64 : Array_64_Bit (1 .. Length); end case; end record; end Variant_Records;
luk9400/nsi
Ada
136
adb
with Ada.Text_IO; with Square_Root; procedure Main is begin Ada.Text_IO.Put_Line (Square_Root.Sqrt(2.0, 0.00001)'Image); end Main;
reznikmm/matreshka
Ada
13,861
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Packageable_Elements; with AMF.UML.Dependencies.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Observations.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.String_Expressions; with AMF.UML.Template_Parameters; with AMF.UML.Time_Expressions; with AMF.UML.Types; with AMF.UML.Value_Specifications; with AMF.Visitors; package AMF.Internals.UML_Time_Expressions is type UML_Time_Expression_Proxy is limited new AMF.Internals.UML_Packageable_Elements.UML_Packageable_Element_Proxy and AMF.UML.Time_Expressions.UML_Time_Expression with null record; overriding function Get_Expr (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access; -- Getter of TimeExpression::expr. -- -- The value of the time expression. overriding procedure Set_Expr (Self : not null access UML_Time_Expression_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access); -- Setter of TimeExpression::expr. -- -- The value of the time expression. overriding function Get_Observation (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Observations.Collections.Set_Of_UML_Observation; -- Getter of TimeExpression::observation. -- -- Refers to the time and duration observations that are involved in expr. overriding function Get_Type (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Types.UML_Type_Access; -- Getter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding procedure Set_Type (Self : not null access UML_Time_Expression_Proxy; To : AMF.UML.Types.UML_Type_Access); -- Setter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding function Get_Client_Dependency (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Time_Expression_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Time_Expression_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Time_Expression_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Time_Expression_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Boolean_Value (Self : not null access constant UML_Time_Expression_Proxy) return AMF.Optional_Boolean; -- Operation ValueSpecification::booleanValue. -- -- The query booleanValue() gives a single Boolean value when one can be -- computed. overriding function Integer_Value (Self : not null access constant UML_Time_Expression_Proxy) return AMF.Optional_Integer; -- Operation ValueSpecification::integerValue. -- -- The query integerValue() gives a single Integer value when one can be -- computed. overriding function Is_Compatible_With (Self : not null access constant UML_Time_Expression_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ValueSpecification::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. In addition, -- for ValueSpecification, the type must be conformant with the type of -- the specified parameterable element. overriding function Is_Computable (Self : not null access constant UML_Time_Expression_Proxy) return Boolean; -- Operation ValueSpecification::isComputable. -- -- The query isComputable() determines whether a value specification can -- be computed in a model. This operation cannot be fully defined in OCL. -- A conforming implementation is expected to deliver true for this -- operation for all value specifications that it can compute, and to -- compute all of those for which the operation is true. A conforming -- implementation is expected to be able to compute the value of all -- literals. overriding function Is_Null (Self : not null access constant UML_Time_Expression_Proxy) return Boolean; -- Operation ValueSpecification::isNull. -- -- The query isNull() returns true when it can be computed that the value -- is null. overriding function Real_Value (Self : not null access constant UML_Time_Expression_Proxy) return AMF.Optional_Real; -- Operation ValueSpecification::realValue. -- -- The query realValue() gives a single Real value when one can be -- computed. overriding function String_Value (Self : not null access constant UML_Time_Expression_Proxy) return AMF.Optional_String; -- Operation ValueSpecification::stringValue. -- -- The query stringValue() gives a single String value when one can be -- computed. overriding function Unlimited_Value (Self : not null access constant UML_Time_Expression_Proxy) return AMF.Optional_Unlimited_Natural; -- Operation ValueSpecification::unlimitedValue. -- -- The query unlimitedValue() gives a single UnlimitedNatural value when -- one can be computed. overriding function All_Owning_Packages (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Time_Expression_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Time_Expression_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Template_Parameter (Self : not null access constant UML_Time_Expression_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding procedure Enter_Element (Self : not null access constant UML_Time_Expression_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Time_Expression_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Time_Expression_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Time_Expressions;
optikos/oasis
Ada
4,260
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Expressions; with Program.Lexical_Elements; with Program.Elements.Type_Conversions; with Program.Element_Visitors; package Program.Nodes.Type_Conversions is pragma Preelaborate; type Type_Conversion is new Program.Nodes.Node and Program.Elements.Type_Conversions.Type_Conversion and Program.Elements.Type_Conversions.Type_Conversion_Text with private; function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Operand : not null Program.Elements.Expressions .Expression_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Type_Conversion; type Implicit_Type_Conversion is new Program.Nodes.Node and Program.Elements.Type_Conversions.Type_Conversion with private; function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Operand : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Type_Conversion with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Type_Conversion is abstract new Program.Nodes.Node and Program.Elements.Type_Conversions.Type_Conversion with record Subtype_Mark : not null Program.Elements.Expressions.Expression_Access; Operand : not null Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : aliased in out Base_Type_Conversion'Class); overriding procedure Visit (Self : not null access Base_Type_Conversion; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Subtype_Mark (Self : Base_Type_Conversion) return not null Program.Elements.Expressions.Expression_Access; overriding function Operand (Self : Base_Type_Conversion) return not null Program.Elements.Expressions.Expression_Access; overriding function Is_Type_Conversion_Element (Self : Base_Type_Conversion) return Boolean; overriding function Is_Expression_Element (Self : Base_Type_Conversion) return Boolean; type Type_Conversion is new Base_Type_Conversion and Program.Elements.Type_Conversions.Type_Conversion_Text with record Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Type_Conversion_Text (Self : aliased in out Type_Conversion) return Program.Elements.Type_Conversions.Type_Conversion_Text_Access; overriding function Left_Bracket_Token (Self : Type_Conversion) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Right_Bracket_Token (Self : Type_Conversion) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Type_Conversion is new Base_Type_Conversion with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Type_Conversion_Text (Self : aliased in out Implicit_Type_Conversion) return Program.Elements.Type_Conversions.Type_Conversion_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Type_Conversion) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Type_Conversion) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Type_Conversion) return Boolean; end Program.Nodes.Type_Conversions;
glencornell/ada-object-framework
Ada
5,626
adb
-- Copyright (C) 2020 Glen Cornell <[email protected]> -- -- This program is free software: you can redistribute it and/or -- modify it under the terms of the GNU General Public License as -- published by the Free Software Foundation, either version 3 of the -- License, or (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see -- <http://www.gnu.org/licenses/>. package body Aof.Core.Objects is use type Object_List.Cursor; use type Ada.Strings.Unbounded.Unbounded_String; function Get_Name (This : in Object'Class) return String is begin return Ada.Strings.Unbounded.To_String(This.Name.Get); end; procedure Set_Name (This : in out Object'Class; Name : in String) is begin This.Name.Set(Ada.Strings.Unbounded.To_Unbounded_String(Name)); end; function Get_Parent (This : in Object'Class) return Access_Object is begin return This.Parent; end; procedure Set_Parent (This : in out Object'Class; Parent : in not null Access_Object) is This_Ptr : Access_Object := This'Unchecked_Access; begin -- If the parent is found in this objects list of children(recursively), then fail if This.Contains(Parent) or This_Ptr = Parent then raise Circular_Reference_Exception; end if; -- unlink this from its existing parent if This.Parent /= null then This.Parent.Delete_Child(This_Ptr); end if; -- add the object "This" to the "Children" container belonging -- to the object "Parent" Parent.Children.Append(New_Item => This_Ptr); This.Parent := Parent; end; function Get_Children (This : in Object'Class) return Object_List.List is begin return This.Children; end; function Find_Child (This : in Object'Class; Name : in Ada.Strings.Unbounded.Unbounded_String; Options : in Find_Child_Options := Find_Children_Recursively) return Access_Object is begin for Obj of This.Children loop if Name = Obj.Name.Get then return Obj; end if; if Options = Find_Children_Recursively then return Obj.Find_Child(Name, Options); end if; end loop; return null; end; function Find_Child (This : in Object'Class; Name : in String; Options : in Find_Child_Options := Find_Children_Recursively) return Access_Object is The_Name : constant Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.To_Unbounded_String(Name); begin return This.Find_Child(The_Name, Options); end; function Find_Children (This : in Object'Class; Name : in Ada.Strings.Unbounded.Unbounded_String; Options : in Find_Child_Options := Find_Children_Recursively) return Object_List.List is Obj_List : Object_List.List; begin for Obj of This.Children loop if Name = Obj.Name.Get then Obj_List.Append(Obj); end if; if Options = Find_Children_Recursively then declare Children : Object_List.List := Obj.Find_Children(Name, Options); begin Obj_List.Splice(Before => Object_List.No_Element, Source => Children); end; end if; end loop; return Obj_List; end; function Find_Children (This : in Object'Class; Name : in String; Options : in Find_Child_Options := Find_Children_Recursively) return Object_List.List is The_Name : constant Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.To_Unbounded_String(Name); begin return This.Find_Children(The_Name, Options); end; procedure Iterate (This : in Access_Object; Options : in Find_Child_Options := Find_Children_Recursively) is begin for Child of This.Children loop if Options = Find_Children_Recursively then Iterate(This => Child, Options => Options); end if; Proc(Child); end loop; end; function Contains (This : in out Object'Class; Child : in not null Access_Object) return Boolean is This_Ptr : constant Access_Object := This'Unchecked_Access; Obj : Access_Object := Child.Parent; begin while Obj /= null loop if Obj = This_Ptr then return True; end if; Obj := Obj.Parent; end loop; return False; end; procedure Delete_Child (This : in out Object'Class; Child : in out not null Access_Object; Options : in Find_Child_Options := Find_Children_Recursively) is I : Object_List.Cursor := This.Children.First; Obj : Access_Object := null; begin loop Obj := Object_List.Element(I); if Obj = Child then Obj.Parent := null; This.Children.Delete(I); return; end if; if Options = Find_Children_Recursively then Obj.Delete_Child(Child, Options); end if; exit when I = This.Children.Last; I := Object_List.Next(I); end loop; end; procedure Finalize (This : in out Public_Part) is begin This.Destroyed.Emit(This'Unchecked_Access); end Finalize; procedure Finalize (This : in out Object) is begin -- TODO: delete all children? null; end Finalize; end Aof.Core.Objects;
AdaCore/libadalang
Ada
614
ads
package Primitives is type T is abstract tagged null record; function Create_T return T is abstract; function Create_T (I : Integer) return T is abstract; -- Primitives that has no controlling parameter procedure Print (Value : T) is abstract; -- Simple case procedure Print (Prefix : String; Value : T) is abstract; -- Controlling parameter is not first procedure Print (Previous : T; Value : T) is abstract; -- Two controlling arguments function "<" (Left, Right : T) return Boolean is abstract; -- Two controlling arguments in the same param spec end Primitives;
reznikmm/matreshka
Ada
7,320
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.Illustration_Index_Entry_Template_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Illustration_Index_Entry_Template_Element_Node is begin return Self : Text_Illustration_Index_Entry_Template_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Illustration_Index_Entry_Template_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_Text_Illustration_Index_Entry_Template (ODF.DOM.Text_Illustration_Index_Entry_Template_Elements.ODF_Text_Illustration_Index_Entry_Template_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 Text_Illustration_Index_Entry_Template_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Illustration_Index_Entry_Template_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Illustration_Index_Entry_Template_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_Text_Illustration_Index_Entry_Template (ODF.DOM.Text_Illustration_Index_Entry_Template_Elements.ODF_Text_Illustration_Index_Entry_Template_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 Text_Illustration_Index_Entry_Template_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_Text_Illustration_Index_Entry_Template (Visitor, ODF.DOM.Text_Illustration_Index_Entry_Template_Elements.ODF_Text_Illustration_Index_Entry_Template_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.Text_URI, Matreshka.ODF_String_Constants.Illustration_Index_Entry_Template_Element, Text_Illustration_Index_Entry_Template_Element_Node'Tag); end Matreshka.ODF_Text.Illustration_Index_Entry_Template_Elements;
tum-ei-rcs/StratoX
Ada
15,013
ads
-- This spec has been automatically generated from STM32F429x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with HAL; with System; package STM32_SVD.DAC is pragma Preelaborate; --------------- -- Registers -- --------------- ----------------- -- CR_Register -- ----------------- subtype CR_TSEL1_Field is HAL.UInt3; subtype CR_WAVE1_Field is HAL.UInt2; subtype CR_MAMP1_Field is HAL.UInt4; subtype CR_TSEL2_Field is HAL.UInt3; subtype CR_WAVE2_Field is HAL.UInt2; subtype CR_MAMP2_Field is HAL.UInt4; -- control register type CR_Register is record -- DAC channel1 enable EN1 : Boolean := False; -- DAC channel1 output buffer disable BOFF1 : Boolean := False; -- DAC channel1 trigger enable TEN1 : Boolean := False; -- DAC channel1 trigger selection TSEL1 : CR_TSEL1_Field := 16#0#; -- DAC channel1 noise/triangle wave generation enable WAVE1 : CR_WAVE1_Field := 16#0#; -- DAC channel1 mask/amplitude selector MAMP1 : CR_MAMP1_Field := 16#0#; -- DAC channel1 DMA enable DMAEN1 : Boolean := False; -- DAC channel1 DMA Underrun Interrupt enable DMAUDRIE1 : Boolean := False; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- DAC channel2 enable EN2 : Boolean := False; -- DAC channel2 output buffer disable BOFF2 : Boolean := False; -- DAC channel2 trigger enable TEN2 : Boolean := False; -- DAC channel2 trigger selection TSEL2 : CR_TSEL2_Field := 16#0#; -- DAC channel2 noise/triangle wave generation enable WAVE2 : CR_WAVE2_Field := 16#0#; -- DAC channel2 mask/amplitude selector MAMP2 : CR_MAMP2_Field := 16#0#; -- DAC channel2 DMA enable DMAEN2 : Boolean := False; -- DAC channel2 DMA underrun interrupt enable DMAUDRIE2 : Boolean := False; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record EN1 at 0 range 0 .. 0; BOFF1 at 0 range 1 .. 1; TEN1 at 0 range 2 .. 2; TSEL1 at 0 range 3 .. 5; WAVE1 at 0 range 6 .. 7; MAMP1 at 0 range 8 .. 11; DMAEN1 at 0 range 12 .. 12; DMAUDRIE1 at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; EN2 at 0 range 16 .. 16; BOFF2 at 0 range 17 .. 17; TEN2 at 0 range 18 .. 18; TSEL2 at 0 range 19 .. 21; WAVE2 at 0 range 22 .. 23; MAMP2 at 0 range 24 .. 27; DMAEN2 at 0 range 28 .. 28; DMAUDRIE2 at 0 range 29 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ---------------------- -- SWTRIGR_Register -- ---------------------- -------------------- -- SWTRIGR.SWTRIG -- -------------------- -- SWTRIGR_SWTRIG array type SWTRIGR_SWTRIG_Field_Array is array (1 .. 2) of Boolean with Component_Size => 1, Size => 2; -- Type definition for SWTRIGR_SWTRIG type SWTRIGR_SWTRIG_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SWTRIG as a value Val : HAL.UInt2; when True => -- SWTRIG as an array Arr : SWTRIGR_SWTRIG_Field_Array; end case; end record with Unchecked_Union, Size => 2; for SWTRIGR_SWTRIG_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- software trigger register type SWTRIGR_Register is record -- Write-only. DAC channel1 software trigger SWTRIG : SWTRIGR_SWTRIG_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SWTRIGR_Register use record SWTRIG at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ---------------------- -- DHR12R1_Register -- ---------------------- subtype DHR12R1_DACC1DHR_Field is HAL.UInt12; -- channel1 12-bit right-aligned data holding register type DHR12R1_Register is record -- DAC channel1 12-bit right-aligned data DACC1DHR : DHR12R1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12R1_Register use record DACC1DHR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ---------------------- -- DHR12L1_Register -- ---------------------- subtype DHR12L1_DACC1DHR_Field is HAL.UInt12; -- channel1 12-bit left aligned data holding register type DHR12L1_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- DAC channel1 12-bit left-aligned data DACC1DHR : DHR12L1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12L1_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC1DHR at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; --------------------- -- DHR8R1_Register -- --------------------- subtype DHR8R1_DACC1DHR_Field is HAL.Byte; -- channel1 8-bit right aligned data holding register type DHR8R1_Register is record -- DAC channel1 8-bit right-aligned data DACC1DHR : DHR8R1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR8R1_Register use record DACC1DHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ---------------------- -- DHR12R2_Register -- ---------------------- subtype DHR12R2_DACC2DHR_Field is HAL.UInt12; -- channel2 12-bit right aligned data holding register type DHR12R2_Register is record -- DAC channel2 12-bit right-aligned data DACC2DHR : DHR12R2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12R2_Register use record DACC2DHR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ---------------------- -- DHR12L2_Register -- ---------------------- subtype DHR12L2_DACC2DHR_Field is HAL.UInt12; -- channel2 12-bit left aligned data holding register type DHR12L2_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- DAC channel2 12-bit left-aligned data DACC2DHR : DHR12L2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12L2_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC2DHR at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; --------------------- -- DHR8R2_Register -- --------------------- subtype DHR8R2_DACC2DHR_Field is HAL.Byte; -- channel2 8-bit right-aligned data holding register type DHR8R2_Register is record -- DAC channel2 8-bit right-aligned data DACC2DHR : DHR8R2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR8R2_Register use record DACC2DHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ---------------------- -- DHR12RD_Register -- ---------------------- subtype DHR12RD_DACC1DHR_Field is HAL.UInt12; subtype DHR12RD_DACC2DHR_Field is HAL.UInt12; -- Dual DAC 12-bit right-aligned data holding register type DHR12RD_Register is record -- DAC channel1 12-bit right-aligned data DACC1DHR : DHR12RD_DACC1DHR_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- DAC channel2 12-bit right-aligned data DACC2DHR : DHR12RD_DACC2DHR_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12RD_Register use record DACC1DHR at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; DACC2DHR at 0 range 16 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ---------------------- -- DHR12LD_Register -- ---------------------- subtype DHR12LD_DACC1DHR_Field is HAL.UInt12; subtype DHR12LD_DACC2DHR_Field is HAL.UInt12; -- DUAL DAC 12-bit left aligned data holding register type DHR12LD_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- DAC channel1 12-bit left-aligned data DACC1DHR : DHR12LD_DACC1DHR_Field := 16#0#; -- unspecified Reserved_16_19 : HAL.UInt4 := 16#0#; -- DAC channel2 12-bit left-aligned data DACC2DHR : DHR12LD_DACC2DHR_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12LD_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC1DHR at 0 range 4 .. 15; Reserved_16_19 at 0 range 16 .. 19; DACC2DHR at 0 range 20 .. 31; end record; --------------------- -- DHR8RD_Register -- --------------------- subtype DHR8RD_DACC1DHR_Field is HAL.Byte; subtype DHR8RD_DACC2DHR_Field is HAL.Byte; -- DUAL DAC 8-bit right aligned data holding register type DHR8RD_Register is record -- DAC channel1 8-bit right-aligned data DACC1DHR : DHR8RD_DACC1DHR_Field := 16#0#; -- DAC channel2 8-bit right-aligned data DACC2DHR : DHR8RD_DACC2DHR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR8RD_Register use record DACC1DHR at 0 range 0 .. 7; DACC2DHR at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ------------------- -- DOR1_Register -- ------------------- subtype DOR1_DACC1DOR_Field is HAL.UInt12; -- channel1 data output register type DOR1_Register is record -- Read-only. DAC channel1 data output DACC1DOR : DOR1_DACC1DOR_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOR1_Register use record DACC1DOR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------- -- DOR2_Register -- ------------------- subtype DOR2_DACC2DOR_Field is HAL.UInt12; -- channel2 data output register type DOR2_Register is record -- Read-only. DAC channel2 data output DACC2DOR : DOR2_DACC2DOR_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOR2_Register use record DACC2DOR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ----------------- -- SR_Register -- ----------------- -- status register type SR_Register is record -- unspecified Reserved_0_12 : HAL.UInt13 := 16#0#; -- DAC channel1 DMA underrun flag DMAUDR1 : Boolean := False; -- unspecified Reserved_14_28 : HAL.UInt15 := 16#0#; -- DAC channel2 DMA underrun flag DMAUDR2 : Boolean := False; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record Reserved_0_12 at 0 range 0 .. 12; DMAUDR1 at 0 range 13 .. 13; Reserved_14_28 at 0 range 14 .. 28; DMAUDR2 at 0 range 29 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Digital-to-analog converter type DAC_Peripheral is record -- control register CR : CR_Register; -- software trigger register SWTRIGR : SWTRIGR_Register; -- channel1 12-bit right-aligned data holding register DHR12R1 : DHR12R1_Register; -- channel1 12-bit left aligned data holding register DHR12L1 : DHR12L1_Register; -- channel1 8-bit right aligned data holding register DHR8R1 : DHR8R1_Register; -- channel2 12-bit right aligned data holding register DHR12R2 : DHR12R2_Register; -- channel2 12-bit left aligned data holding register DHR12L2 : DHR12L2_Register; -- channel2 8-bit right-aligned data holding register DHR8R2 : DHR8R2_Register; -- Dual DAC 12-bit right-aligned data holding register DHR12RD : DHR12RD_Register; -- DUAL DAC 12-bit left aligned data holding register DHR12LD : DHR12LD_Register; -- DUAL DAC 8-bit right aligned data holding register DHR8RD : DHR8RD_Register; -- channel1 data output register DOR1 : DOR1_Register; -- channel2 data output register DOR2 : DOR2_Register; -- status register SR : SR_Register; end record with Volatile; for DAC_Peripheral use record CR at 0 range 0 .. 31; SWTRIGR at 4 range 0 .. 31; DHR12R1 at 8 range 0 .. 31; DHR12L1 at 12 range 0 .. 31; DHR8R1 at 16 range 0 .. 31; DHR12R2 at 20 range 0 .. 31; DHR12L2 at 24 range 0 .. 31; DHR8R2 at 28 range 0 .. 31; DHR12RD at 32 range 0 .. 31; DHR12LD at 36 range 0 .. 31; DHR8RD at 40 range 0 .. 31; DOR1 at 44 range 0 .. 31; DOR2 at 48 range 0 .. 31; SR at 52 range 0 .. 31; end record; -- Digital-to-analog converter DAC_Periph : aliased DAC_Peripheral with Import, Address => DAC_Base; end STM32_SVD.DAC;
reznikmm/matreshka
Ada
8,226
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- 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$ ------------------------------------------------------------------------------ with League.Strings; with League.String_Vectors; with Matreshka.XML_Schema.AST.Types; with Matreshka.XML_Schema.Object_Lists; with XML.Schema; package Matreshka.XML_Schema.AST.Simple_Types is pragma Preelaborate; type Simple_Type_Definition_Node is new Matreshka.XML_Schema.AST.Types.Type_Definition_Node with record -- Properties: -- Annotations : Types.Annotation_Lists.List; -- {annotations} -- A sequence of Annotation components. Name : League.Strings.Universal_String; -- {name} -- An xs:NCName value. Optional. Target_Namespace : League.Strings.Universal_String; -- {target namespace} -- An xs:anyURI value. Optional. Context : Matreshka.XML_Schema.AST.Node_Access; -- {context} -- Required if {name} is ·absent·, otherwise must be ·absent·. -- -- Either an Attribute Declaration, an Element Declaration, a Complex -- Type Definition, or a Simple Type Definition. Facets : Types.Facet_Sets.List; -- {facets} -- A set of Constraining Facet components. -- -- {fundamental facets} -- A set of Fundamental Facet components. -- Variety : Simple_Type_Variety; -- {variety} -- One of {atomic, list, union}. Required for all Simple Type -- Definitions except ·xs:anySimpleType·, in which it is ·absent·. -- Simple_Type_Definition : Matreshka.XML_Schema.AST.Simple_Type_Definition_Access; -- {primitive type definition} -- A Simple Type Definition component. With one exception, required if -- {variety} is atomic, otherwise must be ·absent·. The exception is -- ·xs:anyAtomicType·, whose {primitive type definition} is ·absent·. -- -- If non-·absent·, must be a primitive definition. -- Item_Type_Definition : Matreshka.XML_Schema.AST.Simple_Type_Definition_Access; -- {item type definition} -- A Simple Type Definition component. Required if {variety} is list, -- otherwise must be ·absent·. -- -- The value of this property must be a primitive or ordinary simple -- type definition with {variety} = atomic, or an ordinary simple type -- definition with {variety} = union whose basic members are all atomic; -- the value must not itself be a list type (have {variety} = list) or -- have any basic members which are list types. -- Member_Type_Definitions : Object_Lists.Object_List_Access; -- {member type definitions} -- A sequence of primitive or ordinary Simple Type Definition -- components. -- -- Must be present (but may be empty) if {variety} is union, otherwise -- must be ·absent·. -- -- The sequence may contain any primitive or ordinary simple type -- definition, but must not contain any special type definitions. -- Internal data. Restriction_Base : Matreshka.XML_Schema.AST.Qualified_Name; -- restriction/@base Member_Types : Matreshka.XML_Schema.AST.Qualified_Name_Vector; -- union/@memberTypes Item_Type : Matreshka.XML_Schema.AST.Qualified_Name; -- list/@itemType Lexical_Enumeration : League.String_Vectors.Universal_String_Vector; -- List of enumeration literals end record; overriding function Get_Type_Category (Self : Simple_Type_Definition_Node) return XML.Schema.Type_Category; overriding procedure Enter_Node (Self : not null access Simple_Type_Definition_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding function Get_Name (Self : not null access Simple_Type_Definition_Node) return League.Strings.Universal_String; overriding function Get_Target_Namespace (Self : not null access Simple_Type_Definition_Node) return League.Strings.Universal_String; overriding procedure Leave_Node (Self : not null access Simple_Type_Definition_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Node (Self : not null access Simple_Type_Definition_Node; Iterator : in out Matreshka.XML_Schema.Visitors.Abstract_Iterator'Class; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end Matreshka.XML_Schema.AST.Simple_Types;
AdaCore/libadalang
Ada
148
adb
procedure Bar (X : Sub) is procedure Baz (X : Sub) is separate; begin null; end Bar; --% node.p_enclosing_compilation_unit.p_imported_units()
zhmu/ananas
Ada
307
ads
with Aspect1_Vectors_2D; generic with package Position_2d_Pkg is new Aspect1_Vectors_2D (<>); with package Speed_2d_Pkg is new Aspect1_Vectors_2D (<>); package Aspect1_Horizontal is function Theta_D(s: Position_2d_Pkg.Vect2; nzv: Speed_2d_Pkg.Nz_vect2) return float; end Aspect1_Horizontal;
AdaCore/libadalang
Ada
211
adb
procedure Test_Subp_Renaming is procedure Foo (A : Float) is null; procedure Foo (A : Integer) is null; procedure Bar (I : Float) renames Foo; begin null; end Test_Subp_Renaming; pragma Test_Block;
zhmu/ananas
Ada
52,926
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- L I B -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines for accessing and outputting the library -- information. It contains the routine to load subsidiary units. with Alloc; with Namet; use Namet; with Table; with Types; use Types; with GNAT.HTable; package Lib is type Unit_Ref_Table is array (Pos range <>) of Unit_Number_Type; -- Type to hold list of indirect references to unit number table type Compiler_State_Type is (Parsing, Analyzing); Compiler_State : Compiler_State_Type; -- Indicates current state of compilation. This is used to implement the -- function In_Extended_Main_Source_Unit. Parsing_Main_Extended_Source : Boolean := False; -- Set True if we are currently parsing a file that is part of the main -- extended source (the main unit, its spec, or one of its subunits). This -- flag to implement In_Extended_Main_Source_Unit. Analysing_Subunit_Of_Main : Boolean := False; -- Set to True when analyzing a subunit of the main source. When True, if -- the subunit is preprocessed and -gnateG is specified, then the -- preprocessed file (.prep) is written. -------------------------------------------- -- General Approach to Library Management -- -------------------------------------------- -- As described in GNote #1, when a unit is compiled, all its subsidiary -- units are recompiled, including the following: -- (a) Corresponding spec for a body -- (b) Parent spec of a child library spec -- (c) With'ed specs -- (d) Parent body of a subunit -- (e) Subunits corresponding to any specified stubs -- (f) Bodies of inlined subprograms that are called -- (g) Bodies of generic subprograms or packages that are instantiated -- (h) Bodies of packages containing either of the above two items -- (i) Specs and bodies of runtime units -- (j) Parent specs for with'ed child library units -- If a unit is being compiled only for syntax checking, then no subsidiary -- units are loaded, the syntax check applies only to the main unit, -- i.e. the one contained in the source submitted to the library. -- If a unit is being compiled for syntax and semantic checking, then only -- cases (a)-(d) loads are performed, since the full semantic checking can -- be carried out without needing (e)-(i) loads. In this case no object -- file, or library information file, is generated, so the missing units -- do not affect the results. -- Specifications of library subprograms, subunits, and generic specs -- and bodies, can only be compiled in syntax/semantic checking mode, -- since no code is ever generated directly for these units. In the case -- of subunits, only the compilation of the ultimate parent unit generates -- actual code. If a subunit is submitted to the compiler in syntax/ -- semantic checking mode, the parent (or parents in the nested case) are -- semantically checked only up to the point of the corresponding stub. -- If code is being generated, then all the above units are required, -- although the need for bodies of inlined procedures can be suppressed -- by the use of a switch that sets the mode to ignore pragma Inline -- statements. -- The two main sections of the front end, Par and Sem, are recursive. -- Compilation proceeds unit by unit making recursive calls as necessary. -- The process is controlled from the GNAT main program, which makes calls -- to Par and Sem sequence for the main unit. -- Par parses the given unit, and then, after the parse is complete, uses -- the Par.Load subprogram to load all its subsidiary units in categories -- (a)-(d) above, installing pointers to the loaded units in the parse -- tree, as described in a later section of this spec. If any of these -- required units is missing, a fatal error is signalled, so that no -- attempt is made to run Sem in such cases, since it is assumed that -- too many cascaded errors would result, and the confusion would not -- be helpful. -- Following the call to Par on the main unit, the entire tree of required -- units is thus loaded, and Sem is called on the main unit. The parameter -- passed to Sem is the unit to be analyzed. The visibility table, which -- is a single global structure, starts out containing only the entries -- for the visible entities in Standard. Every call to Sem establishes a -- new scope stack table, pushing an entry for Standard on entry to provide -- the proper initial scope environment. -- Sem first proceeds to perform semantic analysis on the currently loaded -- units as follows: -- In the case of a body (case (a) above), Sem analyzes the corresponding -- spec, using a recursive call to Sem. As is always expected to be the -- case with calls to Sem, any entities installed in the visibility table -- are removed on exit from Sem, so that these entities have to be -- reinstalled on return to continue the analysis of the body which of -- course needs visibility of these entities. -- -- In the case of the parent of a child spec (case (b) above), a similar -- call is made to Sem to analyze the parent. Again, on return, the -- entities from the analyzed parent spec have to be installed in the -- visibility table of the caller (the child unit), which must have -- visibility to the entities in its parent spec. -- For with'ed specs (case (c) above), a recursive call to Sem is made -- to analyze each spec in turn. After all the spec's have been analyzed, -- but not till that point, the entities from all the with'ed units are -- reinstalled in the visibility table so that the caller can proceed -- with the analysis of the unit doing the with's with the necessary -- entities made either potentially use visible or visible by selection -- as needed. -- Case (d) arises when Sem is passed a subunit to analyze. This means -- that the main unit is a subunit, and the unit passed to Sem is either -- the main unit, or one of its ancestors that is still a subunit. Since -- analysis must start at the top of the tree, Sem essentially cancels -- the current call by immediately making a call to analyze the parent -- (when this call is finished it immediately returns, so logically this -- call is like a goto). The subunit will then be analyzed at the proper -- time as described for the stub case. Note that we also turn off the -- indication that code should be generated in this case, since the only -- time we generate code for subunits is when compiling the main parent. -- Case (e), subunits corresponding to stubs, are handled as the stubs -- are encountered. There are three sub-cases: -- If the subunit has already been loaded, then this means that the -- main unit was a subunit, and we are back on our way down to it -- after following the initial processing described for case (d). -- In this case we analyze this particular subunit, as described -- for the case where we are generating code, but when we get back -- we are all done, since the rest of the parent is irrelevant. To -- get out of the parent, we raise the exception Subunit_Found, which -- is handled at the outer level of Sem. -- The cases where the subunit has not already been loaded correspond -- to cases where the main unit was a parent. In this case the action -- depends on whether or not we are generating code. If we are not -- generating code, then this is the case where we can simply ignore -- the subunit, since in checking mode we don't even want to insist -- that the subunit exist, much less waste time checking it. -- If we are generating code, then we need to load and analyze -- all subunits. This is achieved with a call to Lib.Load to load -- and parse the unit, followed by processing that installs the -- context clause of the subunit, analyzes the subunit, and then -- removes the context clause (from the visibility chains of the -- parent). Note that we do *not* do a recursive call to Sem in -- this case, precisely because we need to do the analysis of the -- subunit with the current visibility table and scope stack. -- Case (f) applies only to subprograms for which a pragma Inline is -- given, providing that the compiler is operating in the mode where -- pragma Inline's are activated. When the expander encounters a call -- to such a subprogram, it loads the body of the subprogram if it has -- not already been loaded, and calls Sem to process it. -- Case (g) is similar to case (f), except that the body of a generic -- is unconditionally required, regardless of compiler mode settings. -- As in the subprogram case, when the expander encounters a generic -- instantiation, it loads the generic body of the subprogram if it -- has not already been loaded, and calls Sem to process it. -- Case (h) arises when a package contains either an inlined subprogram -- which is called, or a generic which is instantiated. In this case the -- body of the package must be loaded and analyzed with a call to Sem. -- Case (i) is handled by adding implicit with clauses to the context -- clauses of all units that potentially reference the relevant runtime -- entities. Note that since we have the full set of units available, -- the parser can always determine the set of runtime units that is -- needed. These with clauses do not have associated use clauses, so -- all references to the entities must be by selection. Once the with -- clauses have been added, subsequent processing is as for normal -- with clauses. -- Case (j) is also handled by adding appropriate implicit with clauses -- to any unit that withs a child unit. Again there is no use clause, -- and subsequent processing proceeds as for an explicit with clause. -- Sem thus completes the loading of all required units, except those -- required for inline subprogram bodies or inlined generics. If any -- of these load attempts fails, then the expander will not be called, -- even if code was to be generated. If the load attempts all succeed -- then the expander is called, though the attempt to generate code may -- still fail if an error occurs during a load attempt for an inlined -- body or a generic body. ------------------------------------------- -- Special Handling of Subprogram Bodies -- ------------------------------------------- -- A subprogram body (in an adb file) may stand for both a spec and a body. -- A simple model (and one that was adopted through version 2.07) is simply -- to assume that such an adb file acts as its own spec if no ads file is -- is present. -- However, this is not correct. RM 10.1.4(4) requires that such a body -- act as a spec unless a subprogram declaration of the same name is -- already present. The correct interpretation of this in GNAT library -- terms is to ignore an existing ads file of the same name unless this -- ads file contains a subprogram declaration with the same name. -- If there is an ads file with a unit other than a subprogram declaration -- with the same name, then a fatal message is output, noting that this -- irrelevant file must be deleted before the body can be compiled. See -- ACVC test CA1020D to see how this processing is required. ----------------- -- Global Data -- ----------------- Current_Sem_Unit : Unit_Number_Type := Main_Unit; -- Unit number of unit currently being analyzed/expanded. This is set when -- ever a new unit is entered, saving and restoring the old value, so that -- it always reflects the unit currently being analyzed. The initial value -- of Main_Unit ensures that a proper value is set initially, and in -- particular for analysis of configuration pragmas in gnat.adc. Main_Unit_Entity : Entity_Id; -- Entity of main unit, same as Cunit_Entity (Main_Unit) except where -- Main_Unit is a body with a separate spec, in which case it is the -- entity for the spec. ----------------- -- Units Table -- ----------------- -- The units table has an entry for each unit (source file) read in by the -- current compilation. The table is indexed by the unit number value. -- The first entry in the table, subscript Main_Unit, is for the main file. -- Each entry in this units table contains the following data. -- Cunit -- Pointer to the N_Compilation_Unit node. Initially set to Empty by -- Lib.Load, and then reset to the required node by the parser when -- the unit is parsed. -- Cunit_Entity -- Pointer to the entity node for the compilation unit. Initially set -- to Empty by Lib.Load, and then reset to the required entity by the -- parser when the unit is parsed. -- Dependency_Num -- This is the number of the unit within the generated dependency -- lines (D lines in the ALI file) which are sorted into alphabetical -- order. The number is ones origin, so a value of 2 refers to the -- second generated D line. The Dependency_Num values are set as the -- D lines are generated, and are used to generate proper unit -- references in the generated xref information and SCO output. -- Dynamic_Elab -- A flag indicating if this unit was compiled with dynamic elaboration -- checks specified (as the result of using the -gnatE compilation -- option or a pragma Elaboration_Checks (Dynamic)). -- Error_Location -- This is copied from the Sloc field of the Enode argument passed -- to Load_Unit. It refers to the enclosing construct which caused -- this unit to be loaded, e.g. most typically the with clause that -- referenced the unit, and is used for error handling in Par.Load. -- Expected_Unit -- This is the expected unit name for a file other than the main unit, -- since these are cases where we load the unit using Lib.Load and we -- know the unit that is expected. It must be the same as Unit_Name -- if it is set (see test in Par.Load). Expected_Unit is set to -- No_Name for the main unit. -- Fatal_Error -- A flag that is initialized to None and gets set to Error if a fatal -- error occurs during the processing of a unit. A fatal error is one -- defined as serious enough to stop the next phase of the compiler -- from running (i.e. fatal error during parsing stops semantics, -- fatal error during semantics stops code generation). Note that -- currently, errors of any kind cause Fatal_Error to be set, but -- eventually perhaps only errors labeled as fatal errors should be -- this severe if we decide to try Sem on sources with minor errors. -- There are three settings (see declaration of Fatal_Type). -- Generate_Code -- This flag is set True for all units in the current file for which -- code is to be generated. This includes the unit explicitly compiled, -- together with its specification, and any subunits. -- Has_RACW -- A Boolean flag, initially set to False when a unit entry is created, -- and set to True if the unit defines a remote access to class wide -- (RACW) object. This is used for controlling generation of the RA -- attribute in the ali file. -- Ident_String -- N_String_Literal node from a valid pragma Ident that applies to -- this unit. If no Ident pragma applies to the unit, then Empty. -- Is_Predefined_Renaming -- True if this unit is a predefined renaming, as in "Text_IO renames -- Ada.Text_IO"). -- Is_Internal_Unit -- Same as In_Predefined_Unit, except units in the GNAT hierarchy are -- included. -- Is_Predefined_Unit -- True if this unit is predefined (i.e. part of the Ada, System, or -- Interface hierarchies, or Is_Predefined_Renaming). Note that units -- in the GNAT hierarchy are not considered predefined. -- Loading -- A flag that is used to catch circular WITH dependencies. It is set -- True when an entry is initially created in the file table, and set -- False when the load is completed, or ends with an error. -- Main_Priority -- This field is used to indicate the priority of a possible main -- program, as set by a pragma Priority. A value of -1 indicates -- that the default priority is to be used (and is also used for -- entries that do not correspond to possible main programs). -- Main_CPU -- This field is used to indicate the affinity of a possible main -- program, as set by a pragma CPU. A value of -1 indicates -- that the default affinity is to be used (and is also used for -- entries that do not correspond to possible main programs). -- Munit_Index -- The index of the unit within the file for multiple unit per file -- mode. Set to zero in normal single unit per file mode. -- No_Elab_Code_All -- A flag set when a pragma or aspect No_Elaboration_Code_All applies -- to the unit. This is used to implement the transitive WITH rules -- (and for no other purpose). -- OA_Setting -- This is a character field containing L if Optimize_Alignment mode -- was set locally, and O/T/S for Off/Time/Space default if not. -- Primary_Stack_Count -- The number of primary stacks belonging to tasks defined within the -- unit that have no Storage_Size specified when the either restriction -- No_Implicit_Heap_Allocations or No_Implicit_Task_Allocations is -- active. Only used by the binder to generate stacks for these tasks -- at bind time. -- Sec_Stack_Count -- The number of secondary stacks belonging to tasks defined within the -- unit that have no Secondary_Stack_Size specified when the either -- the No_Implicit_Heap_Allocations or No_Implicit_Task_Allocations -- restrictions are active. Only used by the binder to generate stacks -- for these tasks at bind time. -- Serial_Number -- This field holds a serial number used by New_Internal_Name to -- generate unique temporary numbers on a unit by unit basis. The -- only access to this field is via the Increment_Serial_Number -- routine which increments the current value and returns it. This -- serial number is separate for each unit. -- Source_Index -- The index in the source file table of the corresponding source file. -- Set when the entry is created by a call to Lib.Load and then cannot -- be changed. -- Unit_File_Name -- The name of the source file containing the unit. Set when the entry -- is created by a call to Lib.Load, and then cannot be changed. -- Unit_Name -- The name of the unit. Initialized to No_Name by Lib.Load, and then -- set by the parser when the unit is parsed to the unit name actually -- found in the file (which should, in the absence of errors) be the -- same name as Expected_Unit. -- Version -- This field holds the version of the unit, which is computed as -- the exclusive or of the checksums of this unit, and all its -- semantically dependent units. Access to the version number field -- is not direct, but is done through the routines described below. -- When a unit table entry is created, this field is initialized to -- the checksum of the corresponding source file. Version_Update is -- then called to reflect the contributions of any unit on which this -- unit is semantically dependent. -- The units table is reset to empty at the start of the compilation of -- each main unit by Lib.Initialize. Entries are then added by calls to -- the Lib.Load procedure. The following subprograms are used to access -- and modify entries in the Units table. Individual entries are accessed -- using a unit number value which ranges from Main_Unit (the first entry, -- which is always for the current main unit) to Last_Unit. Default_Main_Priority : constant Int := -1; -- Value used in Main_Priority field to indicate default main priority Default_Main_CPU : constant Int := -1; -- Value used in Main_CPU field to indicate default main affinity -- The following defines settings for the Fatal_Error field type Fatal_Type is ( None, -- No error detected for this unit Error_Detected, -- Fatal error detected that prevents moving to the next phase. For -- example, a fatal error during parsing inhibits semantic analysis. Error_Ignored); -- A fatal error was detected, but we are in Try_Semantics mode (as set -- by -gnatq or -gnatQ). This does not stop the compiler from proceding, -- but tools can use this status (e.g. ASIS looking at the generated -- tree) to know that a fatal error was detected. function Cunit (U : Unit_Number_Type) return Node_Id; function Cunit_Entity (U : Unit_Number_Type) return Entity_Id; function Dependency_Num (U : Unit_Number_Type) return Nat; function Dynamic_Elab (U : Unit_Number_Type) return Boolean; function Error_Location (U : Unit_Number_Type) return Source_Ptr; function Expected_Unit (U : Unit_Number_Type) return Unit_Name_Type; function Fatal_Error (U : Unit_Number_Type) return Fatal_Type; function Generate_Code (U : Unit_Number_Type) return Boolean; function Ident_String (U : Unit_Number_Type) return Node_Id; function Has_RACW (U : Unit_Number_Type) return Boolean; function Is_Predefined_Renaming (U : Unit_Number_Type) return Boolean; function Is_Internal_Unit (U : Unit_Number_Type) return Boolean; function Is_Predefined_Unit (U : Unit_Number_Type) return Boolean; function Loading (U : Unit_Number_Type) return Boolean; function Main_CPU (U : Unit_Number_Type) return Int; function Main_Priority (U : Unit_Number_Type) return Int; function Munit_Index (U : Unit_Number_Type) return Nat; function No_Elab_Code_All (U : Unit_Number_Type) return Boolean; function OA_Setting (U : Unit_Number_Type) return Character; function Primary_Stack_Count (U : Unit_Number_Type) return Int; function Sec_Stack_Count (U : Unit_Number_Type) return Int; function Source_Index (U : Unit_Number_Type) return Source_File_Index; function Unit_File_Name (U : Unit_Number_Type) return File_Name_Type; function Unit_Name (U : Unit_Number_Type) return Unit_Name_Type; -- Get value of named field from given units table entry -- WARNING: There is a matching C declaration of a few subprograms in fe.h procedure Set_Cunit (U : Unit_Number_Type; N : Node_Id); procedure Set_Cunit_Entity (U : Unit_Number_Type; E : Entity_Id); procedure Set_Dynamic_Elab (U : Unit_Number_Type; B : Boolean := True); procedure Set_Error_Location (U : Unit_Number_Type; W : Source_Ptr); procedure Set_Fatal_Error (U : Unit_Number_Type; V : Fatal_Type); procedure Set_Generate_Code (U : Unit_Number_Type; B : Boolean := True); procedure Set_Has_RACW (U : Unit_Number_Type; B : Boolean := True); procedure Set_Ident_String (U : Unit_Number_Type; N : Node_Id); procedure Set_Loading (U : Unit_Number_Type; B : Boolean := True); procedure Set_Main_CPU (U : Unit_Number_Type; P : Int); procedure Set_No_Elab_Code_All (U : Unit_Number_Type; B : Boolean := True); procedure Set_Main_Priority (U : Unit_Number_Type; P : Int); procedure Set_OA_Setting (U : Unit_Number_Type; C : Character); procedure Set_Unit_Name (U : Unit_Number_Type; N : Unit_Name_Type); -- Set value of named field for given units table entry. Note that we -- do not have an entry for each possible field, since some of the fields -- can only be set by specialized interfaces (defined below). function Compilation_Switches_Last return Nat; -- Return the count of stored compilation switches procedure Disable_Switch_Storing; -- Disable registration of switches by Store_Compilation_Switch. Used to -- avoid registering switches added automatically by the gcc driver at the -- end of the command line. function Earlier_In_Extended_Unit (S1 : Source_Ptr; S2 : Source_Ptr) return Boolean; -- Given two Sloc values for which In_Same_Extended_Unit is true, determine -- if S1 appears before S2. Returns True if S1 appears before S2, and False -- otherwise. The result is undefined if S1 and S2 are not in the same -- extended unit. Note: this routine will not give reliable results if -- called after Sprint has been called with -gnatD set. function Earlier_In_Extended_Unit (N1 : Node_Or_Entity_Id; N2 : Node_Or_Entity_Id) return Boolean; -- Same as above, but the inputs denote nodes or entities procedure Enable_Switch_Storing; -- Enable registration of switches by Store_Compilation_Switch. Used to -- avoid registering switches added automatically by the gcc driver at the -- beginning of the command line. function Entity_Is_In_Main_Unit (E : Entity_Id) return Boolean; -- Returns True if the entity E is declared in the main unit, or, in -- its corresponding spec, or one of its subunits. Entities declared -- within generic instantiations return True if the instantiation is -- itself "in the main unit" by this definition. Otherwise False. function Exact_Source_Name (Loc : Source_Ptr) return String; -- Return name of entity at location Loc exactly as written in the source. -- This includes copying the wide character encodings exactly as they were -- used in the source, so the caller must be aware of the possibility of -- such encodings. function Get_Compilation_Switch (N : Pos) return String_Ptr; -- Return the Nth stored compilation switch, or null if less than N -- switches have been stored. Used by back ends written in Ada. function Generic_May_Lack_ALI (Unum : Unit_Number_Type) return Boolean; -- Generic units must be separately compiled. Since we always use -- macro substitution for generics, the resulting object file is a dummy -- one with no code, but the ALI file has the normal form, and we need -- this ALI file so that the binder can work out a correct order of -- elaboration. -- -- However, ancient versions of GNAT used to not generate code or ALI -- files for generic units, and this would yield complex order of -- elaboration issues. These were fixed in GNAT 3.10. The support for not -- compiling language-defined library generics was retained nonetheless -- to facilitate bootstrap. Specifically, it is convenient to have -- the same list of files to be compiled for all stages. So, if the -- bootstrap compiler does not generate code for a given file, then -- the stage1 compiler (and binder) also must deal with the case of -- that file not being compiled. The predicate Generic_May_Lack_ALI is -- True for those generic units for which missing ALI files are allowed. function Get_Cunit_Unit_Number (N : Node_Id) return Unit_Number_Type; -- Return unit number of the unit whose N_Compilation_Unit node is the -- one passed as an argument. This must always succeed since the node -- could not have been built without making a unit table entry. function Get_Cunit_Entity_Unit_Number (E : Entity_Id) return Unit_Number_Type; -- Return unit number of the unit whose compilation unit spec entity is -- the one passed as an argument. This must always succeed since the -- entity could not have been built without making a unit table entry. function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type; pragma Inline (Get_Source_Unit); function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type; -- Return unit number of file identified by given source pointer value. -- This call must always succeed, since any valid source pointer value -- belongs to some previously loaded module. If the given source pointer -- value is within an instantiation, this function returns the unit number -- of the template, i.e. the unit containing the source code corresponding -- to the given Source_Ptr value. The version taking a Node_Id argument, N, -- simply applies the function to Sloc (N). function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type; pragma Inline (Get_Code_Unit); function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type; -- This is like Get_Source_Unit, except that in the instantiation case, -- it uses the location of the top level instantiation, rather than the -- template, so it returns the unit number containing the code that -- corresponds to the node N, or the source location S. function Get_Top_Level_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type; pragma Inline (Get_Code_Unit); function Get_Top_Level_Code_Unit (S : Source_Ptr) return Unit_Number_Type; -- This is like Get_Code_Unit, except that in the case of subunits, it -- returns the top-level unit to which the subunit belongs instead of -- the subunit. -- -- Note: for nodes and slocs in declarations of library-level instances of -- generics these routines wrongly return the unit number corresponding to -- the body of the instance. In effect, locations of SPARK references in -- ALI files are bogus. However, fixing this is not worth the effort, since -- these references are only used for debugging. function In_Extended_Main_Code_Unit (N : Node_Or_Entity_Id) return Boolean; -- Return True if the node is in the generated code of the extended main -- unit, defined as the main unit, its specification (if any), and all -- its subunits (considered recursively). Units for which this enquiry -- returns True are those for which code will be generated. Nodes from -- instantiations are included in the extended main unit for this call. -- If the main unit is itself a subunit, then the extended main code unit -- includes its parent unit, and the parent unit spec if it is separate. -- -- This routine (and the following three routines) all return False if -- Sloc (N) is No_Location or Standard_Location. In an earlier version, -- they returned True for Standard_Location, but this was odd, and some -- archeology indicated that this was done for the sole benefit of the -- call in Restrict.Check_Restriction_No_Dependence, so we have moved -- the special case check to that routine. This avoids some difficulties -- with some other calls that malfunctioned with the odd return of True. -- WARNING: There is a matching C declaration of this subprogram in fe.h function In_Extended_Main_Code_Unit (Loc : Source_Ptr) return Boolean; -- Same function as above, but argument is a source pointer rather -- than a node. function In_Extended_Main_Source_Unit (N : Node_Or_Entity_Id) return Boolean; -- Return True if the node is in the source text of the extended main -- unit, defined as the main unit, its specification (if any), and all -- its subunits (considered recursively). Units for which this enquiry -- returns True are those for which code will be generated. This differs -- from In_Extended_Main_Code_Unit only in that instantiations are not -- included for the purposes of this call. If the main unit is itself -- a subunit, then the extended main source unit includes its parent unit, -- and the parent unit spec if it is separate. function In_Extended_Main_Source_Unit (Loc : Source_Ptr) return Boolean; -- Same function as above, but argument is a source pointer function In_Predefined_Unit (N : Node_Or_Entity_Id) return Boolean; -- Returns True if the given node or entity appears within the source text -- of a predefined unit (i.e. within Ada, Interfaces, System or within one -- of the descendant packages of one of these three packages). function In_Predefined_Unit (S : Source_Ptr) return Boolean; pragma Inline (In_Predefined_Unit); -- Same function as above but argument is a source pointer function In_Internal_Unit (N : Node_Or_Entity_Id) return Boolean; function In_Internal_Unit (S : Source_Ptr) return Boolean; pragma Inline (In_Internal_Unit); -- Same as In_Predefined_Unit, except units in the GNAT hierarchy are -- included. function In_Predefined_Renaming (N : Node_Or_Entity_Id) return Boolean; function In_Predefined_Renaming (S : Source_Ptr) return Boolean; pragma Inline (In_Predefined_Renaming); -- Returns True if N or S is in a predefined renaming unit function In_Same_Code_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean; pragma Inline (In_Same_Code_Unit); -- Determines if the two nodes or entities N1 and N2 are in the same -- code unit, the criterion being that Get_Code_Unit yields the same -- value for each argument. function In_Same_Extended_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean; pragma Inline (In_Same_Extended_Unit); -- Determines if two nodes or entities N1 and N2 are in the same -- extended unit, where an extended unit is defined as a unit and all -- its subunits (considered recursively, i.e. subunits of subunits are -- included). Returns true if S1 and S2 are in the same extended unit -- and False otherwise. function In_Same_Extended_Unit (S1, S2 : Source_Ptr) return Boolean; pragma Inline (In_Same_Extended_Unit); -- Determines if the two source locations S1 and S2 are in the same -- extended unit, where an extended unit is defined as a unit and all -- its subunits (considered recursively, i.e. subunits of subunits are -- included). Returns true if S1 and S2 are in the same extended unit -- and False otherwise. function In_Same_Source_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean; pragma Inline (In_Same_Source_Unit); -- Determines if the two nodes or entities N1 and N2 are in the same -- source unit, the criterion being that Get_Source_Unit yields the -- same value for each argument. procedure Increment_Primary_Stack_Count (Increment : Int); -- Increment the Primary_Stack_Count field for the current unit by -- Increment. procedure Increment_Sec_Stack_Count (Increment : Int); -- Increment the Sec_Stack_Count field for the current unit by Increment function Increment_Serial_Number return Nat; -- Increment Serial_Number field for current unit, and return the -- incremented value. procedure Initialize; -- Initialize internal tables function Is_Loaded (Uname : Unit_Name_Type) return Boolean; -- Determines if unit with given name is already loaded, i.e. there is -- already an entry in the file table with this unit name for which the -- corresponding file was found and parsed. Note that the Fatal_Error value -- of this entry must be checked before proceeding with further processing. function Last_Unit return Unit_Number_Type; -- Unit number of last allocated unit procedure List (File_Names_Only : Boolean := False); -- Lists units in active library (i.e. generates output consisting of a -- sorted listing of the units represented in File table, except for the -- main unit). If File_Names_Only is set to True, then the list includes -- only file names, and no other information. Otherwise the unit name and -- time stamp are also output. File_Names_Only also restricts the list to -- exclude any predefined files. procedure Lock; -- Lock internal tables before calling back end function Num_Units return Nat; -- Number of units currently in unit table procedure Remove_Unit (U : Unit_Number_Type); -- Remove unit U from unit table. Currently this is effective only if U is -- the last unit currently stored in the unit table. procedure Replace_Linker_Option_String (S : String_Id; Match_String : String); -- Replace an existing Linker_Option if the prefix Match_String matches, -- otherwise call Store_Linker_Option_String. procedure Store_Compilation_Switch (Switch : String); -- Called to register a compilation switch, either front-end or back-end, -- which may influence the generated output file(s). Switch is the text of -- the switch to store (except that -fRTS gets changed back to --RTS). procedure Store_Linker_Option_String (S : String_Id); -- This procedure is called to register the string from a pragma -- Linker_Option. The argument is the Id of the string to register. procedure Store_Note (N : Node_Id); -- This procedure is called to register a pragma N for which a notes -- entry is required. procedure Synchronize_Serial_Number (SN : Nat); -- This function increments the Serial_Number field for the current unit -- up to SN if it is initially lower and does nothing otherwise. This is -- used in situations where one path of control increments serial numbers -- and the other path does not and it is important to keep serial numbers -- synchronized in the two cases (e.g. when the references in a package -- and a client must be kept consistent). procedure Unlock; -- Unlock internal tables, in cases where the back end needs to modify them function Version_Get (U : Unit_Number_Type) return Word_Hex_String; -- Returns the version as a string with 8 hex digits (upper case letters) procedure Version_Referenced (S : String_Id); -- This routine is called from Exp_Attr to register the use of a Version -- or Body_Version attribute. The argument is the external name used to -- access the version string. procedure Write_Unit_Info (Unit_Num : Unit_Number_Type; Item : Node_Id; Prefix : String := ""; Withs : Boolean := False); -- Print out debugging information about the unit. Prefix precedes the rest -- of the printout. If Withs is True, we print out units with'ed by this -- unit (not counting limited withs). --------------------------------------------------------------- -- Special Handling for Restriction_Set (No_Dependence) Case -- --------------------------------------------------------------- -- If we have a Restriction_Set attribute for No_Dependence => unit, -- and the unit is not given in a No_Dependence restriction that we -- can see, the attribute will return False. -- We have to ensure in this case that the binder will reject any attempt -- to set a No_Dependence restriction in some other unit in the partition. -- If the unit is in the semantic closure, then of course it is properly -- WITH'ed by someone, and the binder will do this job automatically as -- part of its normal processing. -- But if the unit is not in the semantic closure, we must make sure the -- binder knows about it. The use of the Restriction_Set attribute giving -- a result of False does not mean of itself that we have to include the -- unit in the partition. So what we do is to generate a with (W) line in -- the ali file (with no file name information), but no corresponding D -- (dependency) line. This is recognized by the binder as meaning "Don't -- let anyone specify No_Dependence for this unit, but you don't have to -- include it if there is no real W line for the unit". -- The following table keeps track of relevant units. It is used in the -- Lib.Writ circuit for outputting With lines to output the special with -- line with RA if the unit is not in the semantic closure. package Restriction_Set_Dependences is new Table.Table ( Table_Component_Type => Unit_Name_Type, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 10, Table_Increment => 100, Table_Name => "Restriction_Attribute_Dependences"); private pragma Inline (Cunit); pragma Inline (Cunit_Entity); pragma Inline (Dependency_Num); pragma Inline (Fatal_Error); pragma Inline (Generate_Code); pragma Inline (Has_RACW); pragma Inline (Increment_Primary_Stack_Count); pragma Inline (Increment_Sec_Stack_Count); pragma Inline (Increment_Serial_Number); pragma Inline (Is_Internal_Unit); pragma Inline (Is_Loaded); pragma Inline (Is_Predefined_Renaming); pragma Inline (Is_Predefined_Unit); pragma Inline (Loading); pragma Inline (Main_CPU); pragma Inline (Main_Priority); pragma Inline (Munit_Index); pragma Inline (No_Elab_Code_All); pragma Inline (OA_Setting); pragma Inline (Primary_Stack_Count); pragma Inline (Set_Cunit); pragma Inline (Set_Cunit_Entity); pragma Inline (Set_Fatal_Error); pragma Inline (Set_Generate_Code); pragma Inline (Set_Has_RACW); pragma Inline (Sec_Stack_Count); pragma Inline (Set_Loading); pragma Inline (Set_Main_CPU); pragma Inline (Set_Main_Priority); pragma Inline (Set_No_Elab_Code_All); pragma Inline (Set_OA_Setting); pragma Inline (Set_Unit_Name); pragma Inline (Source_Index); pragma Inline (Unit_File_Name); pragma Inline (Unit_Name); -- The Units Table type Unit_Record is record Unit_File_Name : File_Name_Type; Unit_Name : Unit_Name_Type; Munit_Index : Nat; Expected_Unit : Unit_Name_Type; Source_Index : Source_File_Index; Cunit : Node_Id; Cunit_Entity : Entity_Id; Dependency_Num : Int; Ident_String : Node_Id; Main_Priority : Int; Main_CPU : Int; Primary_Stack_Count : Int; Sec_Stack_Count : Int; Serial_Number : Nat; Version : Word; Error_Location : Source_Ptr; Fatal_Error : Fatal_Type; Generate_Code : Boolean; Has_RACW : Boolean; Dynamic_Elab : Boolean; No_Elab_Code_All : Boolean; Filler : Boolean; Loading : Boolean; OA_Setting : Character; Is_Predefined_Renaming : Boolean; Is_Internal_Unit : Boolean; Is_Predefined_Unit : Boolean; Filler2 : Boolean; end record; -- The following representation clause ensures that the above record -- has no holes. We do this so that when instances of this record are -- written by Tree_Gen, we do not write uninitialized values to the file. for Unit_Record use record Unit_File_Name at 0 range 0 .. 31; Unit_Name at 4 range 0 .. 31; Munit_Index at 8 range 0 .. 31; Expected_Unit at 12 range 0 .. 31; Source_Index at 16 range 0 .. 31; Cunit at 20 range 0 .. 31; Cunit_Entity at 24 range 0 .. 31; Dependency_Num at 28 range 0 .. 31; Ident_String at 32 range 0 .. 31; Main_Priority at 36 range 0 .. 31; Main_CPU at 40 range 0 .. 31; Primary_Stack_Count at 44 range 0 .. 31; Sec_Stack_Count at 48 range 0 .. 31; Serial_Number at 52 range 0 .. 31; Version at 56 range 0 .. 31; Error_Location at 60 range 0 .. 31; Fatal_Error at 64 range 0 .. 7; Generate_Code at 65 range 0 .. 7; Has_RACW at 66 range 0 .. 7; Dynamic_Elab at 67 range 0 .. 7; No_Elab_Code_All at 68 range 0 .. 7; Filler at 69 range 0 .. 7; OA_Setting at 70 range 0 .. 7; Loading at 71 range 0 .. 7; Is_Predefined_Renaming at 72 range 0 .. 7; Is_Internal_Unit at 73 range 0 .. 7; Is_Predefined_Unit at 74 range 0 .. 7; Filler2 at 75 range 0 .. 7; end record; for Unit_Record'Size use 76 * 8; -- This ensures that we did not leave out any fields package Units is new Table.Table ( Table_Component_Type => Unit_Record, Table_Index_Type => Unit_Number_Type, Table_Low_Bound => Main_Unit, Table_Initial => Alloc.Units_Initial, Table_Increment => Alloc.Units_Increment, Table_Name => "Units"); -- The following table records a mapping between a name and the entry in -- the units table whose Unit_Name is this name. It is used to speed up -- the Is_Loaded function, whose original implementation (linear search) -- could account for 2% of the time spent in the front end. When the unit -- is an instance of a generic, the unit might get duplicated in the unit -- table - see Make_Instance_Unit for more information. Note that, in -- the case of source files containing multiple units, the units table may -- temporarily contain two entries with the same Unit_Name during parsing, -- which means that the mapping must be to the first entry in the table. Unit_Name_Table_Size : constant := 257; -- Number of headers in hash table subtype Unit_Name_Header_Num is Integer range 0 .. Unit_Name_Table_Size - 1; -- Range of headers in hash table function Unit_Name_Hash (Id : Unit_Name_Type) return Unit_Name_Header_Num; -- Simple hash function for Unit_Name_Types package Unit_Names is new GNAT.Htable.Simple_HTable (Header_Num => Unit_Name_Header_Num, Element => Unit_Number_Type, No_Element => No_Unit, Key => Unit_Name_Type, Hash => Unit_Name_Hash, Equal => "="); procedure Init_Unit_Name (U : Unit_Number_Type; N : Unit_Name_Type); pragma Inline (Init_Unit_Name); -- Both set the Unit_Name for the given units table entry and register a -- mapping between this name and the entry. -- The following table stores strings from pragma Linker_Option lines type Linker_Option_Entry is record Option : String_Id; -- The string for the linker option line Unit : Unit_Number_Type; -- The unit from which the linker option comes end record; package Linker_Option_Lines is new Table.Table ( Table_Component_Type => Linker_Option_Entry, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => Alloc.Linker_Option_Lines_Initial, Table_Increment => Alloc.Linker_Option_Lines_Increment, Table_Name => "Linker_Option_Lines"); -- The following table stores references to pragmas that generate Notes package Notes is new Table.Table ( Table_Component_Type => Node_Id, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => Alloc.Notes_Initial, Table_Increment => Alloc.Notes_Increment, Table_Name => "Notes"); -- The following table records the compilation switches used to compile -- the main unit. The table includes only switches. It excludes -o -- switches as well as artifacts of the gcc/gnat1 interface such as -- -quiet, or -dumpbase. -- This table is set as part of the compiler argument scanning in -- Back_End. It can also be reset in -gnatc mode from the data in an -- existing ali file. package Compilation_Switches is new Table.Table ( Table_Component_Type => String_Ptr, Table_Index_Type => Nat, Table_Low_Bound => 1, Table_Initial => 30, Table_Increment => 100, Table_Name => "Compilation_Switches"); Load_Msg_Sloc : Source_Ptr; -- Location for placing error messages (a token in the main source text) -- This is set from Sloc (Enode) by Load only in the case where this Sloc -- is in the main source file. This ensures that not found messages and -- circular dependency messages reference the original with in this source. type Load_Stack_Entry is record Unit_Number : Unit_Number_Type; With_Node : Node_Id; end record; -- The Load_Stack table contains a list of unit numbers (indexes into the -- unit table) of units being loaded on a single dependency chain, and a -- flag to indicate whether this unit is loaded through a limited_with -- clause. The First entry is the main unit. The second entry, if present -- is a unit on which the first unit depends, etc. This stack is used to -- generate error messages showing the dependency chain if a file is not -- found, or whether a true circular dependency exists. The Load_Unit -- function makes an entry in this table when it is called, and removes -- the entry just before it returns. package Load_Stack is new Table.Table ( Table_Component_Type => Load_Stack_Entry, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => Alloc.Load_Stack_Initial, Table_Increment => Alloc.Load_Stack_Increment, Table_Name => "Load_Stack"); procedure Sort (Tbl : in out Unit_Ref_Table); -- This procedure sorts the given unit reference table in order of -- ascending unit names, where the ordering relation is as described -- by the comparison routines provided by package Uname. -- The Version_Ref table records Body_Version and Version attribute -- references. The entries are simply the strings for the external -- names that correspond to the referenced values. package Version_Ref is new Table.Table ( Table_Component_Type => String_Id, Table_Index_Type => Nat, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Version_Ref"); end Lib;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 1 0 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 10 package System.Pack_10 is pragma Preelaborate; Bits : constant := 10; type Bits_10 is mod 2 ** Bits; for Bits_10'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_10 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_10 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_10 (Arr : System.Address; N : Natural; E : Bits_10; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_10 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_10 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_10 (Arr : System.Address; N : Natural; E : Bits_10; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_10;
reznikmm/matreshka
Ada
3,400
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- 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$ ------------------------------------------------------------------------------ package League.JSON is pragma Pure; end League.JSON;
stcarrez/ada-asf
Ada
1,024
ads
----------------------------------------------------------------------- -- asf-servlets-measures -- Performance measurement servlet -- Copyright (C) 2018 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 Servlet.Core.Measures; package ASF.Servlets.Measures renames Servlet.Core.Measures; pragma Obsolescent ("use the 'Servlet.Core.Measures' package");
AdaDoom3/bare_bones
Ada
3,276
adb
-- -*- Mode: Ada -*- -- Filename : multiboot.adb -- Description : Provides access to the multiboot information from GRUB -- Legacy and GRUB 2. -- Author : Luke A. Guest -- Created On : Sat Jun 16 12:27:30 2012 -- Licence : See LICENCE in the root directory. with System.Address_To_Access_Conversions; with Ada.Unchecked_Conversion; package body Multiboot is function Get_Symbols_Variant return Symbols_Variant is begin if Info.Flags.Symbol_Table and not Info.Flags.Section_Header_Table then return Aout; elsif not Info.Flags.Symbol_Table and Info.Flags.Section_Header_Table then return ELF; else raise Program_Error; end if; end Get_Symbols_Variant; -- This forward declaration is to keep GNAT happy. function Unsigned_32_To_Entry_Access (Addr : Unsigned_32) return Memory_Map_Entry_Access; function To_Address is new Ada.Unchecked_Conversion (Source => Unsigned_32, Target => System.Address); function To_Unsigned_32 is new Ada.Unchecked_Conversion (Source => System.Address, Target => Unsigned_32); package Convert is new System.Address_To_Access_Conversions (Object => Memory_Map_Entry_Access); function To_Entry_Access is new Ada.Unchecked_Conversion (Source => Convert.Object_Pointer, Target => Memory_Map_Entry_Access); function To_Object_Pointer is new Ada.Unchecked_Conversion (Source => Memory_Map_Entry_Access, Target => Convert.Object_Pointer); function Unsigned_32_To_Entry_Access (Addr : Unsigned_32) return Memory_Map_Entry_Access is begin return To_Entry_Access (Convert.To_Pointer (To_Address (Addr))); end Unsigned_32_To_Entry_Access; function First_Memory_Map_Entry return Memory_Map_Entry_Access is begin if not Info.Flags.BIOS_Memory_Map then return null; end if; if Info.Memory_Map.Addr = 0 then return null; end if; return Unsigned_32_To_Entry_Access (Info.Memory_Map.Addr); end First_Memory_Map_Entry; function Next_Memory_Map_Entry (Current : Memory_Map_Entry_Access) return Memory_Map_Entry_Access is Current_Addr : constant Unsigned_32 := To_Unsigned_32 (Convert.To_Address (To_Object_Pointer (Current))); Next_Addr : Unsigned_32 := Unsigned_32'First; begin if Current_Addr >= Info.Memory_Map.Addr + Info.Memory_Map.Length then return null; end if; Next_Addr := Current_Addr + Current.Size + (Unsigned_32'Size / System.Storage_Unit); return Unsigned_32_To_Entry_Access (Next_Addr); end Next_Memory_Map_Entry; package APM_Table_Convert is new System.Address_To_Access_Conversions (Object => APM_Table_Access); function To_APM_Table_Access is new Ada.Unchecked_Conversion (Source => APM_Table_Convert.Object_Pointer, Target => APM_Table_Access); function Get_APM_Table return APM_Table_Access is begin if not Info.Flags.APM_Table then return null; end if; return To_APM_Table_Access (APM_Table_Convert.To_Pointer (Info.APM)); end Get_APM_Table; end Multiboot;
sungyeon/drake
Ada
14,040
adb
with System.Native_Time; with C.sys.time; with C.sys.types; package body System.Native_Calendar is -- use type C.signed_int; -- use type C.signed_long; -- tm_gmtoff -- use type C.sys.types.time_t; Diff : constant := 5680281600.0; -- seconds from 1970-01-01 (0 of POSIX time) -- to 2150-01-01 (0 of Ada time) function To_Time (T : C.sys.types.time_t) return Duration; function To_Time (T : C.sys.types.time_t) return Duration is begin return System.Native_Time.To_Duration (T) - Diff; end To_Time; procedure Fixup ( T : in out C.sys.types.time_t; Current : Second_Number'Base; Expected : Second_Number); procedure Fixup ( T : in out C.sys.types.time_t; Current : Second_Number'Base; Expected : Second_Number) is use type C.sys.types.time_t; begin if (Current + 59) rem 60 = Expected then -- or else (Current = 60 and Expected = 59) T := T - 1; else pragma Assert ( (Current + 1) rem 60 = Expected or else (Current = 60 and then Expected = 0)); T := T + 1; end if; end Fixup; function Is_Leap_Second (T : Duration) return Boolean; function Is_Leap_Second (T : Duration) return Boolean is Aliased_T : aliased C.sys.types.time_t := To_Native_Time (T).tv_sec; tm : aliased C.time.struct_tm; tm_r : access C.time.struct_tm; begin tm_r := C.time.gmtime_r (Aliased_T'Access, tm'Access); return tm_r /= null and then Second_Number'Base (tm_r.tm_sec) = 60; end Is_Leap_Second; -- implementation function To_Native_Time (T : Duration) return Native_Time is begin return System.Native_Time.To_timespec (T + Diff); end To_Native_Time; function To_Time (T : Native_Time) return Duration is begin return System.Native_Time.To_Duration (T) - Diff; end To_Time; function Clock return Native_Time is use type C.signed_int; Result : aliased C.sys.time.struct_timeval; R : C.signed_int; begin R := C.sys.time.gettimeofday (Result'Access, null); if R < 0 then raise Program_Error; -- ??? end if; return System.Native_Time.To_timespec (Result); end Clock; procedure Split ( Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Seconds : out Day_Duration; Leap_Second : out Boolean; Time_Zone : Time_Offset; Error : out Boolean) is use type C.sys.types.time_t; timespec : aliased C.time.struct_timespec := To_Native_Time (Date); Buffer : aliased C.time.struct_tm := (others => <>); -- uninitialized tm : access C.time.struct_tm; begin tm := C.time.gmtime_r (timespec.tv_sec'Access, Buffer'Access); Error := tm = null; if not Error then declare Second : constant Second_Number'Base := Second_Number'Base (tm.tm_sec); begin -- Leap_Second is always calculated as GMT Leap_Second := Second >= 60; -- other units are calculated by Time_Zone if Time_Zone /= 0 then timespec.tv_sec := timespec.tv_sec + C.sys.types.time_t (Time_Zone) * 60; tm := C.time.gmtime_r (timespec.tv_sec'Access, Buffer'Access); Error := tm = null; if not Error and then not Leap_Second and then Second_Number'Base (tm.tm_sec) /= Second then -- Time_Zone is passed over some leap time Fixup (timespec.tv_sec, Current => Second_Number'Base (tm.tm_sec), Expected => Second); tm := C.time.gmtime_r (timespec.tv_sec'Access, Buffer'Access); Error := tm = null; pragma Assert ( Error or else Second_Number'Base (tm.tm_sec) = Second); end if; end if; end; if not Error then Year := Integer (tm.tm_year) + 1900; Month := Integer (tm.tm_mon) + 1; Day := Day_Number (tm.tm_mday); -- truncate to day tm.tm_hour := 0; tm.tm_min := 0; tm.tm_sec := 0; declare Truncated_Time : C.sys.types.time_t; begin Truncated_Time := C.time.timegm (tm); Error := Truncated_Time = -1; if not Error then timespec.tv_sec := timespec.tv_sec - Truncated_Time; if Leap_Second and then Time_Zone <= 0 then timespec.tv_sec := timespec.tv_sec - 1; end if; Seconds := System.Native_Time.To_Duration (timespec); end if; end; end if; end if; end Split; procedure Split ( Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Sub_Second : out Second_Duration; Leap_Second : out Boolean; Day_of_Week : out Day_Name; Time_Zone : Time_Offset; Error : out Boolean) is use type C.sys.types.time_t; timespec : aliased C.time.struct_timespec := To_Native_Time (Date); Buffer : aliased C.time.struct_tm := (others => <>); -- uninitialized tm : access C.time.struct_tm; begin tm := C.time.gmtime_r (timespec.tv_sec'Access, Buffer'Access); Error := tm = null; if not Error then -- Second, Sub_Second and Leap_Second are always calculated as GMT if Second_Number'Base (tm.tm_sec) >= 60 then Second := 59; Leap_Second := True; else Second := Second_Number (tm.tm_sec); Leap_Second := False; end if; Sub_Second := Duration'Fixed_Value ( System.Native_Time.Nanosecond_Number (timespec.tv_nsec)); -- other units are calculated by Time_Zone if Time_Zone /= 0 then if Leap_Second and then Time_Zone < 0 then timespec.tv_sec := timespec.tv_sec - 1; end if; timespec.tv_sec := timespec.tv_sec + C.sys.types.time_t (Time_Zone) * 60; tm := C.time.gmtime_r (timespec.tv_sec'Access, Buffer'Access); Error := tm = null; if not Error and then not Leap_Second and then Second_Number'Base (tm.tm_sec) /= Second then -- Time_Zone is passed over some leap time Fixup (timespec.tv_sec, Current => Second_Number'Base (tm.tm_sec), Expected => Second); tm := C.time.gmtime_r (timespec.tv_sec'Access, Buffer'Access); Error := tm = null; pragma Assert ( Error or else Second_Number'Base (tm.tm_sec) = Second); end if; end if; if not Error then Year := Integer (tm.tm_year) + 1900; Month := Integer (tm.tm_mon) + 1; Day := Day_Number (tm.tm_mday); Hour := Hour_Number (tm.tm_hour); Minute := Minute_Number (tm.tm_min); Day_of_Week := (Integer (tm.tm_wday) + 6) rem 7; -- Day_Name starts from Monday end if; end if; end Split; procedure Time_Of ( Year : Year_Number; Month : Month_Number; Day : Day_Number; Seconds : Day_Duration; Leap_Second : Boolean; Time_Zone : Time_Offset; Result : out Time; Error : out Boolean) is use type C.sys.types.time_t; sec : C.sys.types.time_t; Sub_Second : Second_Duration; tm : aliased C.time.struct_tm := ( tm_sec => 0, tm_min => 0, tm_hour => 0, tm_mday => C.signed_int (Day), tm_mon => C.signed_int (Month_Number'Base (Month) - 1), tm_year => C.signed_int (Year_Number'Base (Year) - 1900), tm_wday => 0, tm_yday => 0, tm_isdst => 0, tm_gmtoff => 0, tm_zone => null); time : aliased C.sys.types.time_t; begin time := C.time.timegm (tm'Access); Error := time = -1; if not Error then declare Seconds_timespec : constant C.time.struct_timespec := System.Native_Time.To_timespec (Seconds); begin sec := Seconds_timespec.tv_sec; Sub_Second := Duration'Fixed_Value (Seconds_timespec.tv_nsec); end; time := time + sec; if Time_Zone /= 0 then time := time - C.sys.types.time_t (Time_Zone * 60); if not Leap_Second then declare Second : constant Second_Number := Second_Number'Base (sec) rem 60; tm_r : access C.time.struct_tm; begin tm_r := C.time.gmtime_r (time'Access, tm'Access); -- reuse tm Error := tm_r = null; if not Error and then Second_Number'Base (tm_r.tm_sec) /= Second then -- Time_Zone is passed over some leap time Fixup (time, Current => Second_Number'Base (tm_r.tm_sec), Expected => Second); end if; end; end if; end if; end if; -- UNIX time starts until 1970, Year_Number stats unitl 1901... if Error then -- to pass negative UNIX time (?) if Year = 1901 and then Month = 1 and then Day = 1 then Result := -7857734400.0; -- first day in Time Error := False; end if; else Result := To_Time (time); end if; if not Error then Result := Result + Sub_Second; if Leap_Second then if Time_Zone <= 0 then Result := Result + 1.0; end if; -- checking Error := not Is_Leap_Second (Result); end if; end if; end Time_Of; procedure Time_Of ( Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Sub_Second : Second_Duration; Leap_Second : Boolean; Time_Zone : Time_Offset; Result : out Time; Error : out Boolean) is use type C.sys.types.time_t; tm : aliased C.time.struct_tm := ( tm_sec => C.signed_int (Second), tm_min => C.signed_int (Minute), tm_hour => C.signed_int (Hour), tm_mday => C.signed_int (Day), tm_mon => C.signed_int (Month_Number'Base (Month) - 1), tm_year => C.signed_int (Year_Number'Base (Year) - 1900), tm_wday => 0, tm_yday => 0, tm_isdst => 0, tm_gmtoff => 0, tm_zone => null); time : aliased C.sys.types.time_t; begin time := C.time.timegm (tm'Access); Error := time = -1; if not Error and then Time_Zone /= 0 then time := time - C.sys.types.time_t (Time_Zone * 60); if not Leap_Second then declare tm_r : access C.time.struct_tm; begin tm_r := C.time.gmtime_r (time'Access, tm'Access); -- reuse tm Error := tm_r = null; if not Error and then Second_Number'Base (tm_r.tm_sec) /= Second then -- Time_Zone is passed over some leap time Fixup (time, Current => Second_Number'Base (tm_r.tm_sec), Expected => Second); end if; end; end if; end if; -- UNIX time starts until 1970, Year_Number stats unitl 1901... if Error then -- to pass negative UNIX time (?) if Year = 1901 and then Month = 1 and then Day = 1 then Result := -7857734400.0 -- first day in Time + Duration (((Hour * 60 + Minute) * 60) + Second); Error := False; end if; else Result := To_Time (time); end if; if not Error then Result := Result + Sub_Second; if Leap_Second then if Time_Zone <= 0 then Result := Result + 1.0; end if; -- checking Error := not Is_Leap_Second (Result); end if; end if; end Time_Of; procedure UTC_Time_Offset ( Date : Time; Time_Zone : out Time_Offset; Error : out Boolean) is use type C.signed_long; -- tm_gmtoff -- FreeBSD does not have timezone variable GMT_Time : aliased constant Native_Time := To_Native_Time (Duration (Date)); Local_TM_Buf : aliased C.time.struct_tm; Local_TM : access C.time.struct_tm; begin Local_TM := C.time.localtime_r ( GMT_Time.tv_sec'Access, Local_TM_Buf'Access); Error := Local_TM = null; if not Error then Time_Zone := Time_Offset (Local_TM.tm_gmtoff / 60); end if; end UTC_Time_Offset; procedure Simple_Delay_Until (T : Native_Time) is Timeout_T : constant Duration := System.Native_Time.To_Duration (T); Current_T : constant Duration := System.Native_Time.To_Duration (Clock); D : Duration; begin if Timeout_T > Current_T then D := Timeout_T - Current_T; else D := 0.0; -- always calling Delay_For for abort checking end if; System.Native_Time.Delay_For (D); end Simple_Delay_Until; procedure Delay_Until (T : Native_Time) is begin Delay_Until_Hook.all (T); end Delay_Until; end System.Native_Calendar;
JeremyGrosser/clock3
Ada
590
ads
package Str is pragma Pure; function Find (S : String; C : Character) return Natural; function Find_Number (S : String) return Natural; function To_Natural (S : String; Base : Positive := 10) return Natural; function Split (S : String; Delimiter : Character; Skip : Natural) return String; function Strip (S : String; C : Character) return String; function Starts_With (S : String; Prefix : String) return Boolean; end Str;
melwyncarlo/ProjectEuler
Ada
824
adb
with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A014 is use Ada.Integer_Text_IO; N_Count : Integer := 1E5; Max_Count : Integer := 0; Max_Count_Number : Integer := 0; I_Count : Integer; N : Long_Integer; begin while N_Count < 1E6 loop I_Count := 0; N := Long_Integer (N_Count); while N /= 1 loop if (N mod Long_Integer (2)) = 0 then N := N / 2; else N := (3 * N) + 1; end if; I_Count := I_Count + 1; end loop; I_Count := I_Count + 1; if I_Count > Max_Count then Max_Count := I_Count; Max_Count_Number := N_Count; end if; N_Count := N_Count + 1; end loop; Put (Max_Count_Number, Width => 0); end A014;
gusthoff/fixed_types
Ada
3,209
ads
------------------------------------------------------------------------------- -- -- FIXED TYPES -- -- Fixed_Short & Fixed_Sat_Short definitions -- -- The MIT License (MIT) -- -- Copyright (c) 2015 Gustavo A. Hoffmann -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and / -- or sell copies of the Software, and to permit persons to whom the Software -- is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -- IN THE SOFTWARE. ------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; package Fixed_Types.Short is Fixed_Depth : constant Positive := 16; type Fixed_Short is delta 1.0 / 2.0 ** (Fixed_Depth - 1) range -1.0 .. 1.0 with Size => Fixed_Depth; type Fixed_Sat_Short is new Fixed_Short; pragma Suppress (Overflow_Check, on => Fixed_Short); pragma Suppress (Range_Check, on => Fixed_Short); -- pragma Suppress (All_checks, on => Fixed_Short); type Fixed_Integer_Short is range -2**(Fixed_Depth - 1) .. 2**(Fixed_Depth - 1) - 1 with Size => Fixed_Depth; type Modular_Short is mod 2 ** Fixed_Depth with Size => Fixed_Depth; function To_Fixed_Integer_Short is new Ada.Unchecked_Conversion (Fixed_Short, Fixed_Integer_Short); function To_Fixed_Integer_Short is new Ada.Unchecked_Conversion (Fixed_Sat_Short, Fixed_Integer_Short); function To_Fixed_Short is new Ada.Unchecked_Conversion (Fixed_Integer_Short, Fixed_Short); function To_Fixed_Sat_Short is new Ada.Unchecked_Conversion (Fixed_Integer_Short, Fixed_Sat_Short); function Fixed_Short_To_Mod_Short is new Ada.Unchecked_Conversion (Fixed_Short, Modular_Short); function Fixed_Sat_Short_To_Mod_Short is new Ada.Unchecked_Conversion (Fixed_Sat_Short, Modular_Short); overriding function "abs" (A : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "+" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "-" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "-" (A : Fixed_Sat_Short) return Fixed_Sat_Short; not overriding function "*" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "*" (A : Fixed_Sat_Short; B : Integer) return Fixed_Sat_Short; end Fixed_Types.Short;
AdaCore/Ada_Drivers_Library
Ada
11,604
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with STM32.GPIO; with STM32.Device; with STM32_SVD.RCC; with STM32_SVD.SYSCFG; with STM32_SVD.Ethernet; use STM32_SVD.Ethernet; with STM32.SDRAM; with Ada.Real_Time; with Ada.Interrupts.Names; with Ada.Unchecked_Conversion; package body STM32.Eth is type Rx_Desc_Range is mod 16; type Rx_Desc_Array is array (Rx_Desc_Range) of Rx_Desc_Type; type Rx_Desc_Arr_Ptr is access Rx_Desc_Array; type Rx_Buffer is array (Natural range 0 .. 1023) of Unsigned_8; type Rx_Buffer_Array is array (Rx_Desc_Range) of Rx_Buffer; type Rx_Buffer_Arr_Ptr is access Rx_Buffer_Array; Rx_Descs : Rx_Desc_Arr_Ptr; Rx_Buffs : Rx_Buffer_Arr_Ptr; procedure Init_Rx_Desc (I : Rx_Desc_Range); --------------------- -- Initialize_RMII -- --------------------- procedure Initialize_RMII is use STM32.GPIO; use STM32.Device; use STM32_SVD.RCC; begin -- Enable GPIO clocks Enable_Clock (GPIO_A); Enable_Clock (GPIO_C); Enable_Clock (GPIO_G); -- Enable SYSCFG clock RCC_Periph.APB2ENR.SYSCFGEN := True; -- Select RMII (before enabling the clocks) STM32_SVD.SYSCFG.SYSCFG_Periph.PMC.MII_RMII_SEL := True; Configure_Alternate_Function (PA1, GPIO_AF_ETH_11); -- RMII_REF_CLK Configure_Alternate_Function (PA2, GPIO_AF_ETH_11); -- RMII_MDIO Configure_Alternate_Function (PA7, GPIO_AF_ETH_11); -- RMII_CRS_DV Configure_Alternate_Function (PC1, GPIO_AF_ETH_11); -- RMII_MDC Configure_Alternate_Function (PC4, GPIO_AF_ETH_11); -- RMII_RXD0 Configure_Alternate_Function (PC5, GPIO_AF_ETH_11); -- RMII_RXD1 Configure_Alternate_Function (PG2, GPIO_AF_ETH_11); -- RMII_RXER Configure_Alternate_Function (PG11, GPIO_AF_ETH_11); -- RMII_TX_EN Configure_Alternate_Function (PG13, GPIO_AF_ETH_11); -- RMII_TXD0 Configure_Alternate_Function (PG14, GPIO_AF_ETH_11); -- RMII_TXD1 Configure_IO (PA1, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PA2, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PA7, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PC1, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PC4, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PC5, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PG2, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PG11, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PG13, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); Configure_IO (PG14, (Mode_AF, Push_Pull, Speed_100MHz, Floating)); -- Enable clocks RCC_Periph.AHB1ENR.ETHMACEN := True; RCC_Periph.AHB1ENR.ETHMACTXEN := True; RCC_Periph.AHB1ENR.ETHMACRXEN := True; RCC_Periph.AHB1ENR.ETHMACPTPEN := True; -- Reset RCC_Periph.AHB1RSTR.ETHMACRST := True; RCC_Periph.AHB1RSTR.ETHMACRST := False; -- Software reset Ethernet_DMA_Periph.DMABMR.SR := True; while Ethernet_DMA_Periph.DMABMR.SR loop null; end loop; end Initialize_RMII; -------------- -- Read_MMI -- -------------- procedure Read_MMI (Reg : UInt5; Val : out UInt16) is use Ada.Real_Time; Pa : constant UInt5 := 0; Cr : UInt3; begin case STM32.Device.System_Clock_Frequencies.HCLK is when 20e6 .. 35e6 - 1 => Cr := 2#010#; when 35e6 .. 60e6 - 1 => Cr := 2#011#; when 60e6 .. 100e6 - 1 => Cr := 2#000#; when 100e6 .. 150e6 - 1 => Cr := 2#001#; when 150e6 .. 216e6 => Cr := 2#100#; when others => raise Constraint_Error; end case; Ethernet_MAC_Periph.MACMIIAR := (PA => Pa, MR => Reg, CR => Cr, MW => False, MB => True, others => <>); loop exit when not Ethernet_MAC_Periph.MACMIIAR.MB; delay until Clock + Milliseconds (1); end loop; Val := Ethernet_MAC_Periph.MACMIIDR.TD; end Read_MMI; ------------------ -- Init_Rx_Desc -- ------------------ procedure Init_Rx_Desc (I : Rx_Desc_Range) is function W is new Ada.Unchecked_Conversion (Address, UInt32); Last : constant Boolean := I = Rx_Desc_Range'Last; begin Rx_Descs (I) := (Rdes0 => (Own => 1, others => <>), Rdes1 => (Dic => 0, Rbs2 => 0, Rer => (if Last then 1 else 0), Rch => 1, Rbs => Rx_Buffer'Length, others => <>), Rdes2 => W (Rx_Buffs (I)'Address), Rdes3 => W (Rx_Descs (I + 1)'Address)); end Init_Rx_Desc; procedure Init_Mac is function To_Rx_Desc_Arr_Ptr is new Ada.Unchecked_Conversion (System.Address, Rx_Desc_Arr_Ptr); function To_Rx_Buffer_Arr_Ptr is new Ada.Unchecked_Conversion (System.Address, Rx_Buffer_Arr_Ptr); function W is new Ada.Unchecked_Conversion (Address, UInt32); Desc_Addr : Address; begin -- FIXME: check speed, full duplex Ethernet_MAC_Periph.MACCR := (CSTF => True, WD => False, JD => False, IFG => 2#100#, CSD => False, FES => True, ROD => True, LM => False, DM => True, IPCO => False, RD => False, APCS => True, BL => 2#10#, DC => True, TE => False, RE => False, others => <>); Ethernet_MAC_Periph.MACFFR := (RA => True, others => <>); Ethernet_MAC_Periph.MACHTHR := 0; Ethernet_MAC_Periph.MACHTLR := 0; Ethernet_MAC_Periph.MACFCR := (PT => 0, ZQPD => False, PLT => 0, UPFD => False, RFCE => True, TFCE => True, FCB => False, others => <>); Ethernet_MAC_Periph.MACVLANTR := (VLANTC => False, VLANTI => 0, others => <>); Ethernet_MAC_Periph.MACPMTCSR := (WFFRPR => False, GU => False, WFR => False, MPR => False, WFE => False, MPE => False, PD => False, others => <>); Desc_Addr := STM32.SDRAM.Reserve (Amount => Rx_Desc_Array'Size / 8); Rx_Descs := To_Rx_Desc_Arr_Ptr (Desc_Addr); Ethernet_DMA_Periph.DMARDLAR := W (Desc_Addr); Desc_Addr := STM32.SDRAM.Reserve (Amount => Rx_Buffer_Array'Size / 8); Rx_Buffs := To_Rx_Buffer_Arr_Ptr (Desc_Addr); for I in Rx_Desc_Range loop Init_Rx_Desc (I); end loop; Ethernet_DMA_Periph.DMABMR := (SR => False, DA => False, DSL => 0, EDFE => False, PBL => 4, RTPR => 0, FB => True, RDP => 4, USP => True, FPM => False, AAB => False, MB => False, others => <>); end Init_Mac; protected Sync is entry Wait_Packet; procedure Start_Rx; procedure Interrupt; pragma Attach_Handler (Interrupt, Ada.Interrupts.Names.ETH_Interrupt); private Rx_Pkt : Boolean := False; -- First descriptor of the last received packet. Last_Rx : Rx_Desc_Range; -- Descriptor for the next packet to be received. Next_Rx : Rx_Desc_Range; end Sync; protected body Sync is procedure Start_Rx is begin -- Make as if last packet received was in last descriptor. Last_Rx := Rx_Desc_Range'Last; Next_Rx := Rx_Desc_Range'First; Rx_Descs (Last_Rx).Rdes0.Own := 0; Rx_Descs (Last_Rx).Rdes0.Ls := 1; -- Assume the RxDMA is ok. Ethernet_MAC_Periph.MACCR.RE := True; Ethernet_DMA_Periph.DMAIER.RIE := True; Ethernet_DMA_Periph.DMAIER.NISE := True; Ethernet_DMA_Periph.DMAOMR.SR := True; Ethernet_DMA_Periph.DMARPDR := 1; end Start_Rx; entry Wait_Packet when Rx_Pkt is begin -- Set OWN to last rx descs. loop -- The previous packet is owned by the software. pragma Assert (Rx_Descs (Last_Rx).Rdes0.Own = 0); -- Refill desc. Init_Rx_Desc (Last_Rx); Last_Rx := Last_Rx + 1; exit when Last_Rx = Next_Rx; end loop; -- As we got an interrupt, the next descriptor should be for us. pragma Assert (Rx_Descs (Last_Rx).Rdes0.Own = 0); Last_Rx := Next_Rx; -- Find Next Rx. loop exit when Rx_Descs (Next_Rx).Rdes0.Ls = 1; Next_Rx := Next_Rx + 1; end loop; Next_Rx := Next_Rx + 1; if Rx_Descs (Next_Rx).Rdes0.Own = 1 then -- Have to wait if no packets after the current one. Rx_Pkt := False; end if; end Wait_Packet; procedure Interrupt is begin Ethernet_DMA_Periph.DMASR.RS := True; Rx_Pkt := True; end Interrupt; end Sync; procedure Start_Rx is begin Sync.Start_Rx; end Start_Rx; procedure Wait_Packet is begin Sync.Wait_Packet; end Wait_Packet; end STM32.Eth;
annexi-strayline/ASAP-Simple_HTTP
Ada
17,757
adb
------------------------------------------------------------------------------ -- -- -- Simple HTTP -- -- -- -- Basic HTTP 1.1 support for API endpoints -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2021, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ separate (Simple_HTTP.RFC_3986.URI_Parser) procedure Parse_Authority (URI : in URI_String; Default_Port: in Port_Number := 80; Valid : out Boolean; userinfo : out URI_String; host : out URI_String; port : out Port_Number) is Sequence_Length: constant Natural := Length (URI); function URI_Element (Source: URI_String := URI; Index : Positive) return Character renames URI_Strings.Element; procedure Convert_Port (Low, High: in Positive; Result : out Port_Number; OK : out Boolean); procedure Probe_End (From : in Positive; Result: out Positive; OK : out Boolean); -- Attempts to find the end of the authority component, starting at From. -- If an invalid character appears, OK is set to False, otherwise, Result -- is set to the character representing the last character of the authority -- component function Valid_Userinfo (Low, High: Positive) return Boolean; function Valid_Host (Low, High: Positive) return Boolean; procedure Set_Empty; procedure Set_Invalid; ---------------------------------------------------------------------- procedure Convert_Port (Low, High: in Positive; Result : out Port_Number; OK : out Boolean) is Port_String: constant String := Slice (Source => URI, Low => Low, High => High); begin if (for some C of Port_String => not Is_digit (C)) then -- Not a number! OK := False; return; end if; Result := Port_Number'Value (Port_String); OK := True; exception when others => OK := False; return; end; ---------------------------------------------------------------------- procedure Probe_End (From : in Positive; Result: out Positive; OK : out Boolean) is Authority_Termination_Set: constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set ("/?#"); Mark: constant Natural := Index (Source => URI, Set => Authority_Termination_Set, From => From); begin if Mark /= 0 then if Mark = From then Result := Mark; else Result := Mark - 1; end if; OK := URI_Element (Index => Mark) = '/'; else Result := Sequence_Length; OK := True; end if; end Probe_End; ---------------------------------------------------------------------- function Valid_Userinfo (Low, High: Positive) return Boolean is function Valid_Char (Item: in Character) return Boolean is (Is_unreserved (Item) or else Is_sub_delim (Item) or else (Item in Escape_Preamble | ':')); begin for I in Low .. High loop if not Valid_Char (URI_Element (Index => I)) then return False; end if; end loop; return True; end Valid_Userinfo; ---------------------------------------------------------------------- function Valid_Host (Low, High: Positive) return Boolean is -- This is quite a bit more involved than userinfo.. function Valid_IP_Literal return Boolean; function Valid_IPv4_Address return Boolean; function Valid_Reg_Name return Boolean; ------------------------------------------------------------ function Valid_IP_Literal return Boolean is -- We're not going to recognize "IPvFuture". If that is ever one -- day a thing, we can add that here. So far we're expecting only -- an IPv6 address in square-brackets begin -- The shortest possible IPv6 addres is "::", so we need at least -- 4 characters for this to have any chance of working, since it -- must also be enclosed in "[]" -- -- Conversely, the longest address is -- "0000:0000:0000:0000:0000:0000:0000:0000" (39) + "[]" (2) = 41 -- -- We cannot see more than one occurance of consecutive '::' if High - Low not in 3 .. 40 or else URI_Element (Index => Low) /= '[' or else URI_Element (Index => High) /= ']' then return False; end if; -- This is a lazy check, we're really trying to exclude things that -- are obviously not IPv6. The rest can be left up to the stack, as -- we can be sure we're not going to have something insane declare E: Character; Colon_Count : Natural := 0; Digit_Count : Natural := 0; Consecutive_Colons: Boolean := False; begin for I in Low + 1 .. High - 1 loop E := URI_Element (Index => I); if E = ':' then Digit_Count := 0; Colon_Count := Colon_Count + 1; if Colon_Count >= 7 then -- Too many colons to be valid return False; elsif URI_Element (Index => Low - 1) = ':' then if Consecutive_Colons then -- There shall only be one case of "::" per IPv6 -- address return False; else Consecutive_Colons := True; end if; end if; elsif E in Hex.Hex_Character then if Digit_Count = 4 then -- Too many hex digits return False; else Digit_Count := Digit_Count + 1; end if; else return False; end if; end loop; -- There should be at least two ':', but no more than 7. if Colon_Count not in 2 .. 7 then return False; end if; end; -- Everything checks-out return True; end Valid_IP_Literal; ------------------------------------------------------------ function Valid_IPv4_Address return Boolean is -- Significantly simpler than IPv6. We expect four numbers -- that are not more than 3 characters long, separated by -- '.', and nothing else. -- -- We won't be pedantic about the values - like "999.999.999.999" E: Character; Period_Count: Natural := 0; Octet_Digits: String (1 .. 3) := " "; Octet_Place : Natural := 0; begin -- Longest is 255.255.255.255 = 15, -- Shortest is 0.0.0.0 = 7 if High - Low not in 6 .. 14 then return False; end if; for I in Low .. High loop E := URI_Element (Index => I); if E = '.' then if Period_Count >= 3 then -- There has already been three '.', this is too much return False; elsif Octet_Place < 1 then -- This would mean there was no number preceeding this '.'. -- That is not ok. return False; elsif Natural'Value (Octet_Digits(1 .. Octet_Place)) not in 0 .. 255 then -- The numeric value of the preceeding octet is not valid. return False; else Period_Count := Period_Count + 1; Octet_Place := 1; Octet_Digits := " "; end if; elsif Is_digit (E) then if Octet_Place >= 3 then -- Too many digits! return False; else Octet_Place := Octet_Place + 1; Octet_Digits(Octet_Place) := E; end if; end if; end loop; return True; end Valid_IPv4_Address; ------------------------------------------------------------ function Valid_Reg_Name return Boolean is E: Character; begin if High - Low < 1 then return False; end if; for I in Low .. High loop E := URI_Element (Index => I); if not (Is_unreserved (E) or else E = '%' or else Is_sub_delim (E)) then return False; end if; end loop; return True; end Valid_Reg_Name; ------------------------------------------------------------ begin return Valid_IP_Literal or else Valid_IPv4_Address or else Valid_Reg_Name; end Valid_Host; ---------------------------------------------------------------------- procedure Set_Empty is begin userinfo := Null_Bounded_String; host := Null_Bounded_String; port := Default_Port; end; ---------------------------------------------------------------------- procedure Set_Invalid is begin Set_Empty; Valid := False; end; ---------------------------------------------------------------------- User_Start, User_End, Host_Start, Host_End, Port_Start, Port_End: Natural; begin if Sequence_Length = 0 then Set_Empty; Valid := True; return; end if; -- We expect to find "//" that must preceed the heir part, which exists -- if the authority component exists. If we don't find "//" then we -- can assume there is no authority at all User_Start := Index (Source => URI, Pattern => "//", From => 1); if User_Start = 0 then Set_Empty; Valid := True; return; else User_Start := User_Start + 2; end if; if User_Start > Sequence_Length then Set_Invalid; return; end if; -- userinfo part. -- User_End := Index (Source => URI, Pattern => "@", From => User_Start); if User_End = 0 then userinfo := Null_Bounded_String; Host_Start := User_Start; elsif User_End = 1 then -- invalid Set_Invalid; return; else Host_Start := User_End + 1; User_End := User_End - 1; if not Valid_Userinfo (Low => 1, High => User_End) then Set_Invalid; return; end if; userinfo := Bounded_Slice (Source => URI, Low => 1, High => User_End); if Host_Start > Sequence_Length then -- We can't have just a user part! Set_Invalid; return; end if; end if; -- host part -- Host_End := Index (Source => URI, Pattern => ":", From => Host_Start); if Host_End = 0 then -- This just means no port part. But we still need to find the start of -- the path, if any. Note that a path component *must* follow the -- authority. That means if we get this far, we expect to find '/', or -- the end. If we find any intervening '?' or '#', it is invalid Port_Start := 0; declare OK: Boolean; begin Probe_End (From => Host_Start, Result => Host_End, OK => OK); if not OK then Set_Invalid; return; end if; end; elsif Host_End = Sequence_Length then -- No port component, which is OK Port_Start := 0; Host_End := Host_End - 1; elsif Host_End = Host_Start then -- No host at all. Not ok. Set_Invalid; return; else -- We have a ':' that has something (should be a port number) following -- it Port_Start := Host_End + 1; Host_End := Host_End - 1; end if; pragma Assert (Host_End > Host_Start); if not Valid_Host (Low => Host_Start, High => Host_End) then Set_Invalid; return; else host := Bounded_Slice (Source => URI, Low => Host_Start, High => Host_End); end if; -- port component (if any) -- if Port_Start > 0 then declare OK: Boolean; begin Probe_End (From => Port_Start, Result => Port_End, OK => OK); if not OK then Set_Invalid; return; end if; end; if Port_End = Port_Start then port := Default_Port; else Port_End := Port_End - 1; declare Port_OK: Boolean; begin Convert_Port (Low => Port_Start, High => Port_End, Result => port, OK => Port_OK); if not Port_OK then Set_Invalid; return; end if; end; end if; end if; -- If we got this far, everything looks good Valid := True; end Parse_Authority;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 2 0 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 20 package System.Pack_20 is pragma Preelaborate; Bits : constant := 20; type Bits_20 is mod 2 ** Bits; for Bits_20'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_20 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_20 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_20 (Arr : System.Address; N : Natural; E : Bits_20; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_20 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_20 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_20 (Arr : System.Address; N : Natural; E : Bits_20; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_20;
reznikmm/matreshka
Ada
7,718
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- 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 Matreshka.DOM_Nodes.Attributes; with Matreshka.DOM_Nodes.Elements; with Matreshka.DOM_Nodes.Texts; with XML.DOM.Documents.Internals; with XML.DOM.Visitors; package body Matreshka.DOM_Nodes.Documents is ------------ -- Create -- ------------ overriding function Create (The_Type : not null access Document_Type) return Document_Node is begin return Self : Document_Node; end Create; ---------------------- -- Create_Attribute -- ---------------------- not overriding function Create_Attribute (Self : not null access Abstract_Document; Namespace_URI : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String) return not null Matreshka.DOM_Nodes.Attribute_Access is begin return Result : constant not null Matreshka.DOM_Nodes.Attribute_Access := new Matreshka.DOM_Nodes.Attributes.Attribute_V2_Node do declare Node : Matreshka.DOM_Nodes.Attributes.Attribute_V2_Node renames Matreshka.DOM_Nodes.Attributes.Attribute_V2_Node (Result.all); begin Matreshka.DOM_Nodes.Attributes.Initialize (Node'Access, Self, Namespace_URI, Qualified_Name); end; end return; end Create_Attribute; -------------------- -- Create_Element -- -------------------- not overriding function Create_Element (Self : not null access Abstract_Document; Namespace_URI : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String) return not null Matreshka.DOM_Nodes.Element_Access is begin return Result : constant not null Matreshka.DOM_Nodes.Element_Access := new Matreshka.DOM_Nodes.Elements.Element_V2_Node do declare Node : Matreshka.DOM_Nodes.Elements.Element_V2_Node renames Matreshka.DOM_Nodes.Elements.Element_V2_Node (Result.all); begin Matreshka.DOM_Nodes.Elements.Initialize (Node'Access, Self, Namespace_URI, Qualified_Name); end; end return; end Create_Element; ----------------- -- Create_Text -- ----------------- not overriding function Create_Text (Self : not null access Abstract_Document; Data : League.Strings.Universal_String) return not null Matreshka.DOM_Nodes.Text_Access is begin return Result : constant not null Matreshka.DOM_Nodes.Text_Access := new Matreshka.DOM_Nodes.Texts.Text_Node do Matreshka.DOM_Nodes.Texts.Initialize (Result, Self, Data); end return; end Create_Text; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access Abstract_Document; Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out Standard.XML.DOM.Visitors.Traverse_Control) is begin Visitor.Enter_Document (Standard.XML.DOM.Documents.Internals.Create (Matreshka.DOM_Nodes.Document_Access (Self)), Control); end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access Abstract_Document; Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out Standard.XML.DOM.Visitors.Traverse_Control) is begin Visitor.Leave_Document (Standard.XML.DOM.Documents.Internals.Create (Matreshka.DOM_Nodes.Document_Access (Self)), Control); end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access Abstract_Document; Iterator : in out Standard.XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out Standard.XML.DOM.Visitors.Traverse_Control) is begin Iterator.Visit_Document (Visitor, Standard.XML.DOM.Documents.Internals.Create (Matreshka.DOM_Nodes.Document_Access (Self)), Control); end Visit_Element; end Matreshka.DOM_Nodes.Documents;
MinimSecure/unum-sdk
Ada
892
adb
-- Copyright 2011-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Pck; use Pck; procedure Foo is type Char_Enum_Type is ('A', 'B', 'C', 'D', 'E'); Char : Char_Enum_Type := 'D'; begin Do_Nothing (Char'Address); -- STOP end Foo;
sungyeon/drake
Ada
34
adb
../machine-pc-freebsd/s-nareti.adb
stcarrez/ada-util
Ada
10,188
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2005-2018, 2020, 2021, 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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are -- -- granted additional permissions described in the GCC Runtime Library -- -- Exception, version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- ------------------------------------------------------------------------------ pragma Ada_2012; pragma License (GPL); with AWS.Messages; with AWS.Net.Buffered; with AWS.Translator; with AWS.Client.HTTP_Utils; with AWS.Utils; package body AWS.Client.Ext is procedure Do_Options (Connection : in out HTTP_Connection; Result : out Response.Data; URI : String := No_Data; Headers : Header_List := Empty_Header_List) is begin Send_Request (Connection, OPTIONS, Result, URI, No_Content, Headers); end Do_Options; function Do_Options (URL : String; User : String := No_Data; Pwd : String := No_Data; Proxy : String := No_Data; Proxy_User : String := No_Data; Proxy_Pwd : String := No_Data; Timeouts : Timeouts_Values := No_Timeout; Headers : Header_List := Empty_Header_List; User_Agent : String := Default.User_Agent) return Response.Data is Connection : HTTP_Connection; Result : Response.Data; begin Create (Connection, URL, User, Pwd, Proxy, Proxy_User, Proxy_Pwd, Persistent => False, Timeouts => Timeouts, User_Agent => User_Agent); Do_Options (Connection, Result, Headers => Headers); Close (Connection); return Result; exception when others => Close (Connection); raise; end Do_Options; procedure Do_Patch (Connection : in out HTTP_Connection; Result : out Response.Data; URI : String := No_Data; Data : String; Headers : Header_List := Empty_Header_List) is begin Send_Request (Connection, PATCH, Result, URI, Translator.To_Stream_Element_Array (Data), Headers); end Do_Patch; function Do_Patch (URL : String; Data : String; User : String := No_Data; Pwd : String := No_Data; Proxy : String := No_Data; Proxy_User : String := No_Data; Proxy_Pwd : String := No_Data; Timeouts : Timeouts_Values := No_Timeout; Headers : Header_List := Empty_Header_List; User_Agent : String := Default.User_Agent) return Response.Data is Connection : HTTP_Connection; Result : Response.Data; begin Create (Connection, URL, User, Pwd, Proxy, Proxy_User, Proxy_Pwd, Persistent => False, Timeouts => Timeouts, User_Agent => User_Agent); Do_Patch (Connection, Result, Data => Data, Headers => Headers); Close (Connection); return Result; exception when others => Close (Connection); raise; end Do_Patch; function Do_Delete (URL : String; Data : String; User : String := No_Data; Pwd : String := No_Data; Proxy : String := No_Data; Proxy_User : String := No_Data; Proxy_Pwd : String := No_Data; Timeouts : Timeouts_Values := No_Timeout; Headers : Header_List := Empty_Header_List; User_Agent : String := Default.User_Agent) return Response.Data is Connection : HTTP_Connection; Result : Response.Data; begin Create (Connection, URL, User, Pwd, Proxy, Proxy_User, Proxy_Pwd, Persistent => False, Timeouts => Timeouts, User_Agent => User_Agent); Do_Delete (Connection, Result, Data, Headers => Headers); Close (Connection); return Result; exception when others => Close (Connection); raise; end Do_Delete; procedure Do_Delete (Connection : in out HTTP_Connection; Result : out Response.Data; Data : String; URI : String := No_Data; Headers : Header_List := Empty_Header_List) is begin Send_Request (Connection, DELETE, Result, URI, Translator.To_Stream_Element_Array (Data), Headers); end Do_Delete; procedure Send_Header (Socket : Net.Socket_Type'Class; Headers : AWS.Headers.List; End_Block : Boolean := False); -- Send all header lines in Headers list to the socket function Get_Line (Headers : AWS.Headers.List; N : Positive) return String; -------------- -- Get_Line -- -------------- function Get_Line (Headers : AWS.Headers.List; N : Positive) return String is Pair : constant AWS.Headers.Element := AWS.Headers.Get (Headers, N); begin if Pair.Name = "" then return ""; elsif Pair.Name = Messages.Get_Token or else Pair.Name = Messages.Post_Token or else Pair.Name = Messages.Put_Token or else Pair.Name = Messages.Head_Token or else Pair.Name = Messages.Delete_Token or else Pair.Name = Messages.Connect_Token or else Pair.Name = "OPTIONS" or else Pair.Name = "PATCH" or else Pair.Name = AWS.HTTP_Version then -- And header line return To_String (Pair.Name & " " & Pair.Value); else return To_String (Pair.Name & ": " & Pair.Value); end if; end Get_Line; ----------------- -- Send_Header -- ----------------- procedure Send_Header (Socket : Net.Socket_Type'Class; Headers : AWS.Headers.List; End_Block : Boolean := False) is begin for J in 1 .. AWS.Headers.Count (Headers) loop Net.Buffered.Put_Line (Socket, Get_Line (Headers, J)); end loop; if End_Block then Net.Buffered.New_Line (Socket); Net.Buffered.Flush (Socket); end if; end Send_Header; ------------------ -- Send_Request -- ------------------ procedure Send_Request (Connection : in out HTTP_Connection; Kind : Method_Kind; Result : out Response.Data; URI : String; Data : Stream_Element_Array := No_Content; Headers : Header_List := Empty_Header_List) is use Ada.Real_Time; Stamp : constant Time := Clock; Try_Count : Natural := Connection.Retry; Auth_Attempts : Auth_Attempts_Count := (others => 2); Auth_Is_Over : Boolean; begin Retry : loop begin HTTP_Utils.Open_Set_Common_Header (Connection, Method_Kind'Image (Kind), URI, Headers); -- If there is some data to send if Data'Length > 0 then HTTP_Utils.Set_Header (Connection.F_Headers, Messages.Content_Length_Token, AWS.Utils.Image (Natural (Data'Length))); end if; Send_Header (Connection.Socket.all, Connection.F_Headers, End_Block => True); -- Send message body if Data'Length > 0 then Net.Buffered.Write (Connection.Socket.all, Data); end if; HTTP_Utils.Get_Response (Connection, Result, Get_Body => Kind /= HEAD and then not Connection.Streaming); HTTP_Utils.Decrement_Authentication_Attempt (Connection, Auth_Attempts, Auth_Is_Over); if Auth_Is_Over then return; elsif Kind /= HEAD and then Connection.Streaming then HTTP_Utils.Read_Body (Connection, Result, Store => False); end if; exception when E : Net.Socket_Error | HTTP_Utils.Connection_Error => Error_Processing (Connection, Try_Count, Result, Method_Kind'Image (Kind), E, Stamp); exit Retry when not Response.Is_Empty (Result); end; end loop Retry; end Send_Request; end AWS.Client.Ext;
reznikmm/matreshka
Ada
4,632
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_Style.Line_Spacing_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Line_Spacing_Attribute_Node is begin return Self : Style_Line_Spacing_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Line_Spacing_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Line_Spacing_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Line_Spacing_Attribute, Style_Line_Spacing_Attribute_Node'Tag); end Matreshka.ODF_Style.Line_Spacing_Attributes;
reznikmm/matreshka
Ada
4,958
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013-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$ ------------------------------------------------------------------------------ package body XML.SAX.Output_Destinations.Strings is ----------- -- Clear -- ----------- procedure Clear (Self : in out String_Output_Destination) is begin Self.Text.Clear; end Clear; ------------------ -- Get_Encoding -- ------------------ overriding function Get_Encoding (Self : String_Output_Destination) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return League.Strings.To_Universal_String ("utf-8"); end Get_Encoding; -------------- -- Get_Text -- -------------- function Get_Text (Self : String_Output_Destination) return League.Strings.Universal_String is begin return Self.Text; end Get_Text; --------- -- Put -- --------- overriding procedure Put (Self : in out String_Output_Destination; Text : League.Strings.Universal_String) is begin Self.Text.Append (Text); end Put; --------- -- Put -- --------- overriding procedure Put (Self : in out String_Output_Destination; Char : League.Characters.Universal_Character) is begin Self.Text.Append (Char); end Put; --------- -- Put -- --------- overriding procedure Put (Self : in out String_Output_Destination; Char : Wide_Wide_Character) is begin Self.Text.Append (Char); end Put; --------- -- Put -- --------- overriding procedure Put (Self : in out String_Output_Destination; Text : Wide_Wide_String) is begin Self.Text.Append (Text); end Put; end XML.SAX.Output_Destinations.Strings;
AaronC98/PlaneSystem
Ada
33,060
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2017, 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/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Containers.Ordered_Maps; with Ada.Exceptions; with Ada.Real_Time; with Ada.Streams.Stream_IO; with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Unchecked_Deallocation; with AWS.Containers.Key_Value; with AWS.Default; with AWS.Utils.Streams; package body AWS.Session is use Ada.Exceptions; use Ada.Streams; use Ada.Strings.Unbounded; SID_Prefix : constant String := "SID-"; Private_Key_Length : constant := 10; -- Length of the string used for the private key Check_Interval : Duration := Default.Session_Cleanup_Interval; -- Check for obsolete section interval Lifetime : Real_Time.Time_Span := Real_Time.To_Time_Span (Default.Session_Lifetime); -- A session is obsolete if not used after Session_Lifetime seconds Kind_Code : constant array (Value_Kind) of Character := (Int => 'I', Real => 'R', Bool => 'B', Str => 'S', User => 'U'); package Key_Value renames Containers.Key_Value; type Key_Value_Set_Access is access Key_Value.Map; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Key_Value.Map, Key_Value_Set_Access); -- table of session ID type Session_Node is record Created_Stamp : Calendar.Time; Private_Key : String (1 .. Private_Key_Length); Time_Stamp : Real_Time.Time; Root : Key_Value_Set_Access; end record; package Session_Set is new Ada.Containers.Ordered_Maps (Id, Session_Node); procedure Get_Node (Sessions : in out Session_Set.Map; SID : Id; Node : out Session_Node; Found : out Boolean); -- Returns Node for specified SID, if found update the timestamp for -- this node and set Found to True, otherwise set Found to False. Max_Expired : constant := 50; type Expired_SID_Array is array (1 .. Max_Expired) of Id; -- Used by the task cleaner to get expired session from database function V_Kind (K : Character) return Value_Kind; -- Return the value kind for K (encoding in the string) ---------------------- -- Session Callback -- ---------------------- Session_Callback : Callback := null; -------------- -- Database -- -------------- protected Database is entry Add_Session (SID : Id); -- Add a new session ID into the database function Creation_Stamp (SID : Id) return Calendar.Time; -- Returns the creation date for this session function Private_Key (SID : Id) return String; -- Returns the session's private key entry New_Session (SID : out Id); -- Add a new session SID into the database entry Delete_Session (SID : Id); -- Removes session SID from the database entry Delete_If_Empty (SID : Id; Removed : out Boolean); -- Removes session SID only if there is no key/value pairs function Session_Exist (SID : Id) return Boolean; -- Returns True if session SID exist in the database function Session_Has_Expired (SID : Id) return Boolean; -- Returns True if session SID has exceeded its lifetime function Length return Natural; -- Returns number of sessions in database function Length (SID : Id) return Natural; -- Returns number of key/value pairs in session SID procedure Touch_Session (SID : Id); -- Updates the session Time_Stamp to current time. Does nothing if SID -- does not exist. procedure Key_Exist (SID : Id; Key : String; Result : out Boolean); -- Result is set to True if Key_Name exist in session SID procedure Get_Value (SID : Id; Key : String; Value : out Unbounded_String); -- Value is set with the value associated with the key Key_Name in -- session SID. entry Set_Value (SID : Id; Key, Value : String); -- Add the pair key/value into the session SID entry Remove_Key (SID : Id; Key : String); -- Removes Key from the session SID -- -- Unsafe routines. These are only to be used by iterators -- procedure Destroy; -- Release all memory associated with the database procedure Prepare_Expired_SID (Expired_SID : out Expired_SID_Array; Last : out Natural); -- Checks for expired data and put them into the Expired_SID set. -- The data will be removed later by the cleaner task. -- This is used only in the cleaner task. procedure Lock_And_Get_Sessions (First : out Session_Set.Cursor); -- Increment Lock by 1, all entries modifying data are locked. Routines -- reading values from the database can still be called (Key_Exist, -- Get_Value, Session_Exist). Returns the Sessions tree first position. procedure Lock_And_Get_Session (SID : Id; Node : out Session_Node; Found : out Boolean); -- Increment Lock by 1, all entries modifying data are locked. Routines -- reading values from the database can still be called (Key_Exist, -- Get_Value, Session_Exist). Returns the Session node. procedure Unlock; -- Decrement Lock by 1, unlock all entries when Lock return to 0 private Lock_Counter : Natural := 0; Sessions : Session_Set.Map; Remove_Mark : Id := No_Session; end Database; ------------- -- Cleaner -- ------------- task body Cleaner is use type Calendar.Time; Next_Run : Calendar.Time := Calendar.Clock + Check_Interval; L_SC : Callback with Atomic; -- Local pointer to the session callback procedure. This is to ensure -- that there is no race condition and that the code below will not -- crash if SC pointer is changed. Expired_SID : Expired_SID_Array; E_Index : Natural; begin Clean_Dead_Sessions : loop select accept Stop; exit Clean_Dead_Sessions; or accept Force; or delay until Next_Run; end select; Database.Prepare_Expired_SID (Expired_SID, E_Index); L_SC := Session_Callback; -- Use Session_Callback copy as we don't want the value to change -- between the test and the call to the session callback routine. for K in 1 .. E_Index loop if L_SC /= null then -- Run the session's callback routine, we catch all exceptions -- here as we do not want to fail. begin L_SC.all (Expired_SID (K)); exception when E : others => Text_IO.Put_Line (Text_IO.Current_Error, "Delete session callback error : " & Exception_Information (E)); end; end if; -- Now we can delete the session data Database.Delete_Session (Expired_SID (K)); end loop; if E_Index = Max_Expired and then Check_Interval > 1.0 then -- Too many expired session, we should run next expiration check -- faster. Next_Run := Next_Run + 1.0; else Next_Run := Next_Run + Check_Interval; end if; end loop Clean_Dead_Sessions; Database.Destroy; exception when E : others => Text_IO.Put_Line (Text_IO.Current_Error, "Unrecoverable Error: Cleaner Task bug detected " & Exception_Information (E)); end Cleaner; ----------- -- Clear -- ----------- procedure Clear is begin Database.Destroy; end Clear; ------------ -- Create -- ------------ function Create return Id is New_Id : Id; begin Database.New_Session (New_Id); return New_Id; end Create; -------------------- -- Creation_Stamp -- -------------------- function Creation_Stamp (SID : Id) return Calendar.Time is begin return Database.Creation_Stamp (SID); end Creation_Stamp; --------------------- -- Cleaner_Control -- --------------------- protected body Cleaner_Control is ------------------ -- Server_Count -- ------------------ function Server_Count return Natural is begin return S_Count; end Server_Count; ----------- -- Start -- ----------- procedure Start (Check_Interval : Duration; Lifetime : Duration) is begin S_Count := S_Count + 1; if S_Count = 1 then Session.Check_Interval := Start.Check_Interval; Session.Lifetime := Real_Time.To_Time_Span (Start.Lifetime); Cleaner_Task := new Cleaner; end if; end Start; ---------- -- Stop -- ---------- procedure Stop (Need_Release : out Boolean) is begin S_Count := S_Count - 1; if S_Count = 0 then Need_Release := True; else Need_Release := False; end if; end Stop; end Cleaner_Control; -------------- -- Database -- -------------- protected body Database is ----------------- -- Add_Session -- ----------------- entry Add_Session (SID : Id) when Lock_Counter = 0 is New_Node : Session_Node; Cursor : Session_Set.Cursor; Success : Boolean; begin New_Node := (Created_Stamp => Calendar.Clock, Time_Stamp => Real_Time.Clock, Private_Key => Utils.Random_String (Private_Key_Length), Root => new Key_Value.Map); Sessions.Insert (SID, New_Node, Cursor, Success); if not Success then Unchecked_Free (New_Node.Root); end if; end Add_Session; -------------------- -- Creation_Stamp -- -------------------- function Creation_Stamp (SID : Id) return Calendar.Time is Cursor : constant Session_Set.Cursor := Sessions.Find (SID); begin if Session_Set.Has_Element (Cursor) then return Session_Set.Element (Cursor).Created_Stamp; else return Calendar.Clock; end if; end Creation_Stamp; --------------------- -- Delete_If_Empty -- --------------------- entry Delete_If_Empty (SID : Id; Removed : out Boolean) when Lock_Counter = 0 is use type Ada.Containers.Count_Type; Cursor : Session_Set.Cursor := Sessions.Find (SID); Node : Session_Node; begin if Session_Set.Has_Element (Cursor) then Node := Session_Set.Element (Cursor); Removed := Node.Root.Length = 0; if Removed then Unchecked_Free (Node.Root); Sessions.Delete (Cursor); end if; else Removed := False; end if; end Delete_If_Empty; -------------------- -- Delete_Session -- -------------------- entry Delete_Session (SID : Id) when Lock_Counter = 0 is Cursor : Session_Set.Cursor := Sessions.Find (SID); Node : Session_Node; begin if Session_Set.Has_Element (Cursor) then Node := Session_Set.Element (Cursor); Unchecked_Free (Node.Root); Sessions.Delete (Cursor); end if; end Delete_Session; ------------- -- Destroy -- ------------- procedure Destroy is begin for Item of Sessions loop Unchecked_Free (Item.Root); end loop; Session_Set.Clear (Sessions); end Destroy; --------------- -- Get_Value -- --------------- procedure Get_Value (SID : Id; Key : String; Value : out Unbounded_String) is Node : Session_Node; Found : Boolean; begin Value := Null_Unbounded_String; Get_Node (Sessions, SID, Node, Found); if Found then declare Cursor : constant Key_Value.Cursor := Key_Value.Find (Node.Root.all, Key); begin if Key_Value.Has_Element (Cursor) then Value := To_Unbounded_String (Key_Value.Element (Cursor)); end if; end; end if; end Get_Value; --------------- -- Key_Exist -- --------------- procedure Key_Exist (SID : Id; Key : String; Result : out Boolean) is Node : Session_Node; begin Get_Node (Sessions, SID, Node, Result); if Result then Result := Key_Value.Contains (Node.Root.all, Key); end if; end Key_Exist; ------------ -- Length -- ------------ function Length return Natural is begin return Natural (Sessions.Length); end Length; function Length (SID : Id) return Natural is C : constant Session_Set.Cursor := Sessions.Find (SID); begin if Session_Set.Has_Element (C) then return Natural (Session_Set.Element (C).Root.Length); else return 0; end if; end Length; -------------------------- -- Lock_And_Get_Session -- -------------------------- procedure Lock_And_Get_Session (SID : Id; Node : out Session_Node; Found : out Boolean) is C : constant Session_Set.Cursor := Sessions.Find (SID); begin Lock_Counter := Lock_Counter + 1; Found := Session_Set.Has_Element (C); if Found then Node := Session_Set.Element (C); end if; end Lock_And_Get_Session; --------------------------- -- Lock_And_Get_Sessions -- --------------------------- procedure Lock_And_Get_Sessions (First : out Session_Set.Cursor) is begin Lock_Counter := Lock_Counter + 1; First := Database.Sessions.First; end Lock_And_Get_Sessions; ----------------- -- New_Session -- ----------------- entry New_Session (SID : out Id) when Lock_Counter = 0 is New_Node : constant Session_Node := (Created_Stamp => Calendar.Clock, Time_Stamp => Real_Time.Clock, Private_Key => Utils.Random_String (Private_Key_Length), Root => new Key_Value.Map); Cursor : Session_Set.Cursor; Success : Boolean; begin Generate_UID : loop Utils.Random_String (String (SID)); Sessions.Insert (SID, New_Node, Cursor, Success); exit Generate_UID when Success; end loop Generate_UID; end New_Session; ------------------------- -- Prepare_Expired_SID -- ------------------------- procedure Prepare_Expired_SID (Expired_SID : out Expired_SID_Array; Last : out Natural) is use type Real_Time.Time; Now : constant Real_Time.Time := Real_Time.Clock; Cursor : Session_Set.Cursor; Node : Session_Node; begin Last := 0; if Remove_Mark = No_Session then Cursor := Sessions.First; else -- Try to continue iteration over container Cursor := Sessions.Find (Remove_Mark); Remove_Mark := No_Session; if not Session_Set.Has_Element (Cursor) then Cursor := Sessions.First; end if; end if; while Session_Set.Has_Element (Cursor) loop Node := Session_Set.Element (Cursor); if Node.Time_Stamp + Lifetime < Now then Last := Last + 1; Expired_SID (Last) := Session_Set.Key (Cursor); if Last = Expired_SID'Last then -- No more space in the expired mailbox, quit now Session_Set.Next (Cursor); if Session_Set.Has_Element (Cursor) then Remove_Mark := Session_Set.Key (Cursor); end if; exit; end if; end if; Session_Set.Next (Cursor); end loop; end Prepare_Expired_SID; ----------------- -- Private_Key -- ----------------- function Private_Key (SID : Id) return String is Cursor : constant Session_Set.Cursor := Sessions.Find (SID); begin if Session_Set.Has_Element (Cursor) then return Session_Set.Element (Cursor).Private_Key; else -- Must not be null as used as a key for an HMAC return ".!."; end if; end Private_Key; ------------ -- Remove -- ------------ entry Remove_Key (SID : Id; Key : String) when Lock_Counter = 0 is Node : Session_Node; Found : Boolean; begin Get_Node (Sessions, SID, Node, Found); if Found then Key_Value.Exclude (Node.Root.all, Key); end if; end Remove_Key; ------------------- -- Session_Exist -- ------------------- function Session_Exist (SID : Id) return Boolean is begin return Sessions.Contains (SID); end Session_Exist; ------------------------- -- Session_Has_Expired -- ------------------------- function Session_Has_Expired (SID : Id) return Boolean is use type Real_Time.Time; Cursor : constant Session_Set.Cursor := Sessions.Find (SID); begin -- Do not use Get_Node, since that would update the timestamp if Session_Set.Has_Element (Cursor) then return Session_Set.Element (Cursor).Time_Stamp + Lifetime < Real_Time.Clock; end if; return False; end Session_Has_Expired; --------------- -- Set_Value -- --------------- entry Set_Value (SID : Id; Key, Value : String) when Lock_Counter = 0 is Node : Session_Node; Found : Boolean; begin Get_Node (Sessions, SID, Node, Found); if Found then Key_Value.Include (Node.Root.all, Key, Value); end if; end Set_Value; ------------------- -- Touch_Session -- ------------------- procedure Touch_Session (SID : Id) is Node : Session_Node; Found : Boolean; begin Get_Node (Sessions, SID, Node, Found); end Touch_Session; ------------ -- Unlock -- ------------ procedure Unlock is begin Lock_Counter := Lock_Counter - 1; end Unlock; end Database; ------------ -- Delete -- ------------ procedure Delete (SID : Id) is begin Database.Delete_Session (SID); end Delete; --------------------- -- Delete_If_Empty -- --------------------- function Delete_If_Empty (SID : Id) return Boolean is Removed : Boolean; begin Database.Delete_If_Empty (SID, Removed); return Removed; end Delete_If_Empty; ----------- -- Exist -- ----------- function Exist (SID : Id) return Boolean is begin return Database.Session_Exist (SID); end Exist; function Exist (SID : Id; Key : String) return Boolean is Result : Boolean; begin Database.Key_Exist (SID, Key, Result); return Result; end Exist; ----------------------- -- For_Every_Session -- ----------------------- procedure For_Every_Session is use type Calendar.Time; use type Real_Time.Time; Now_Monoton : constant Real_Time.Time := Real_Time.Clock; Now_Calendar : constant Calendar.Time := Calendar.Clock; Cursor : Session_Set.Cursor; Order : Positive := 1; Quit : Boolean := False; begin Database.Lock_And_Get_Sessions (Cursor); while Session_Set.Has_Element (Cursor) loop Action (Order, Session_Set.Key (Cursor), Now_Calendar - Real_Time.To_Duration (Now_Monoton - Session_Set.Element (Cursor).Time_Stamp), Quit); exit when Quit; Order := Order + 1; Session_Set.Next (Cursor); end loop; Database.Unlock; exception when others => Database.Unlock; raise; end For_Every_Session; ---------------------------- -- For_Every_Session_Data -- ---------------------------- procedure For_Every_Session_Data (SID : Id) is procedure For_Every_Data (Node : Session_Node); -- Iterate through all Key/Value pairs Node : Session_Node; Order : Positive := 1; Quit : Boolean := False; Found : Boolean; -------------------- -- For_Every_Data -- -------------------- procedure For_Every_Data (Node : Session_Node) is begin for Cursor in Node.Root.Iterate loop declare Value : constant String := Key_Value.Element (Cursor); begin Action (Order, Key_Value.Key (Cursor), Value (Value'First + 1 .. Value'Last), V_Kind (Value (Value'First)), Quit); end; exit when Quit; Order := Order + 1; end loop; end For_Every_Data; begin Database.Lock_And_Get_Session (SID, Node, Found); if Found then For_Every_Data (Node); end if; Database.Unlock; exception when others => Database.Unlock; raise; end For_Every_Session_Data; ------------------ -- Generic_Data -- ------------------ package body Generic_Data is --------- -- Get -- --------- function Get (SID : Id; Key : String) return Data is Result : constant String := Get (SID, Key); Str : aliased Utils.Streams.Strings; Value : Data; begin if Result = "" then return Null_Data; else Utils.Streams.Open (Str, Result); Data'Read (Str'Access, Value); return Value; end if; end Get; --------- -- Set -- --------- procedure Set (SID : Id; Key : String; Value : Data) is Str : aliased Utils.Streams.Strings; begin Data'Write (Str'Access, Value); Database.Set_Value (SID, Key, Kind_Code (User) & Utils.Streams.Value (Str'Access)); end Set; end Generic_Data; --------- -- Get -- --------- function Get (SID : Id; Key : String) return String is Value : Unbounded_String; begin Database.Get_Value (SID, Key, Value); if Length (Value) > 1 then return Slice (Value, 2, Length (Value)); else return ""; end if; end Get; function Get (SID : Id; Key : String) return Integer is Value : constant String := Get (SID, Key); begin return Integer'Value (Value); exception when Constraint_Error => return 0; end Get; function Get (SID : Id; Key : String) return Float is Value : constant String := Get (SID, Key); begin return Float'Value (Value); exception when Constraint_Error => return 0.0; end Get; function Get (SID : Id; Key : String) return Boolean is begin return Get (SID, Key) = "T"; end Get; ------------------ -- Get_Lifetime -- ------------------ function Get_Lifetime return Duration is begin return Real_Time.To_Duration (Lifetime); end Get_Lifetime; -------------- -- Get_Node -- -------------- procedure Get_Node (Sessions : in out Session_Set.Map; SID : Id; Node : out Session_Node; Found : out Boolean) is Cursor : constant Session_Set.Cursor := Sessions.Find (SID); procedure Process (Key : Id; Item : in out Session_Node); ------------- -- Process -- ------------- procedure Process (Key : Id; Item : in out Session_Node) is pragma Unreferenced (Key); begin Item.Time_Stamp := Real_Time.Clock; Node := Item; end Process; begin Found := Session_Set.Has_Element (Cursor); if Found then Session_Set.Update_Element (Sessions, Cursor, Process'Access); end if; end Get_Node; ----------------- -- Has_Expired -- ----------------- function Has_Expired (SID : Id) return Boolean is begin return Database.Session_Has_Expired (SID); end Has_Expired; ----------- -- Image -- ----------- function Image (SID : Id) return String is begin return SID_Prefix & String (SID); end Image; ------------ -- Length -- ------------ function Length return Natural is begin return Database.Length; end Length; function Length (SID : Id) return Natural is begin return Database.Length (SID); end Length; ---------- -- Load -- ---------- procedure Load (File_Name : String) is use Ada.Streams.Stream_IO; File : File_Type; Stream_Ptr : Stream_Access; begin Open (File, Name => File_Name, Mode => In_File); Stream_Ptr := Stream (File); while not End_Of_File (File) loop declare SID : constant Id := Id'Input (Stream_Ptr); Key_Value_Size : Natural; begin Database.Add_Session (SID); Key_Value_Size := Natural'Input (Stream_Ptr); for I in 1 .. Key_Value_Size loop declare Key : constant String := String'Input (Stream_Ptr); Value : constant String := String'Input (Stream_Ptr); begin Database.Set_Value (SID, Key, Value); end; end loop; end; end loop; Close (File); end Load; ----------------- -- Private_Key -- ----------------- function Private_Key (SID : Id) return String is begin return Database.Private_Key (SID); end Private_Key; ------------ -- Remove -- ------------ procedure Remove (SID : Id; Key : String) is begin Database.Remove_Key (SID, Key); end Remove; ---------- -- Save -- ---------- procedure Save (File_Name : String) is use Ada.Streams.Stream_IO; File : File_Type; Stream_Ptr : Stream_Access; Position : Session_Set.Cursor; procedure Process_Session; ------------- -- Process -- ------------- procedure Process_Session is Node : constant Session_Node := Session_Set.Element (Position); Key_Value_Size : constant Natural := Natural (Key_Value.Length (Node.Root.all)); begin if Key_Value_Size > 0 then Id'Output (Stream_Ptr, Session_Set.Key (Position)); Natural'Output (Stream_Ptr, Key_Value_Size); for Cursor in Node.Root.Iterate loop String'Output (Stream_Ptr, Key_Value.Key (Cursor)); String'Output (Stream_Ptr, Key_Value.Element (Cursor)); end loop; end if; end Process_Session; begin Create (File, Name => File_Name); Database.Lock_And_Get_Sessions (First => Position); begin Stream_Ptr := Stream (File); while Session_Set.Has_Element (Position) loop Process_Session; Session_Set.Next (Position); end loop; exception when others => -- Never leave this block without releasing the database lock Database.Unlock; raise; end; Database.Unlock; Close (File); end Save; ------------------ -- Server_Count -- ------------------ function Server_Count return Natural is begin return Cleaner_Control.Server_Count; end Server_Count; --------- -- Set -- --------- procedure Set (SID : Id; Key : String; Value : String) is begin Database.Set_Value (SID, Key, Kind_Code (Str) & Value); end Set; procedure Set (SID : Id; Key : String; Value : Integer) is V : constant String := Integer'Image (Value); begin if V (1) = ' ' then Database.Set_Value (SID, Key, Kind_Code (Int) & V (2 .. V'Last)); else Database.Set_Value (SID, Key, Kind_Code (Int) & V); end if; end Set; procedure Set (SID : Id; Key : String; Value : Float) is V : constant String := Float'Image (Value); begin if V (1) = ' ' then Database.Set_Value (SID, Key, Kind_Code (Real) & V (2 .. V'Last)); else Database.Set_Value (SID, Key, Kind_Code (Real) & V); end if; end Set; procedure Set (SID : Id; Key : String; Value : Boolean) is V : Character; begin if Value then V := 'T'; else V := 'F'; end if; Database.Set_Value (SID, Key, Kind_Code (Bool) & V); end Set; ------------------ -- Set_Callback -- ------------------ procedure Set_Callback (Callback : Session.Callback) is begin Session_Callback := Callback; end Set_Callback; ------------------ -- Set_Lifetime -- ------------------ procedure Set_Lifetime (Seconds : Duration) is begin Lifetime := Real_Time.To_Time_Span (Seconds); end Set_Lifetime; ----------- -- Touch -- ----------- procedure Touch (SID : Id) is begin Database.Touch_Session (SID); end Touch; ------------ -- V_Kind -- ------------ function V_Kind (K : Character) return Value_Kind is begin case K is when 'I' => return Int; when 'S' => return Str; when 'R' => return Real; when 'B' => return Bool; when 'U' => return User; when others => raise Constraint_Error; end case; end V_Kind; ----------- -- Value -- ----------- function Value (SID : String) return Id is begin if SID'Length /= Id'Length + SID_Prefix'Length or else (SID'Length > SID_Prefix'Length and then SID (SID'First .. SID'First + SID_Prefix'Length - 1) /= SID_Prefix) then return No_Session; else return Id (SID (SID'First + SID_Prefix'Length .. SID'Last)); end if; end Value; end AWS.Session;
AdaCore/libadalang
Ada
314
adb
with Vector; procedure Main is package Int_Vector is new Vector (Integer); package Int_Vector_2 is new Vector (Integer); V, V2 : Int_Vector.Vector; B : Integer; begin Int_Vector.Append (V, B); pragma Test_Statement; B := Int_Vector.Append (V, 12); pragma Test_Statement; end Main;
AdaCore/libadalang
Ada
110
adb
procedure Test_Target is A : Integer := 0; begin A := @ + 1; pragma Test_Statement; end Test_Target;
mirror/ncurses
Ada
3,073
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright 2020 Thomas E. Dickey -- -- Copyright 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.2 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ procedure getch_test;
stcarrez/ada-keystore
Ada
4,148
ads
----------------------------------------------------------------------- -- akt-filesystem -- Fuse filesystem operations -- Copyright (C) 2019, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; with Fuse.Main; with Keystore.Files; package AKT.Filesystem is type User_Data_Type is record Wallet : access Keystore.Files.Wallet_File; Direct_IO : Boolean := False; end record; pragma Warnings (Off, "* bits of * unused"); type Stream_Element_Array is array (Positive range <>) of Ada.Streams.Stream_Element; package Fuse_Keystore is new Fuse.Main (Element_Type => Ada.Streams.Stream_Element, Element_Array => Stream_Element_Array, User_Data_Type => User_Data_Type); pragma Warnings (On, "* bits of * unused"); private use Fuse_Keystore; function GetAttr (Path : in String; St_Buf : access System.Stat_Type) return System.Error_Type; function MkDir (Path : in String; Mode : in System.St_Mode_Type) return System.Error_Type; function Unlink (Path : in String) return System.Error_Type; function RmDir (Path : in String) return System.Error_Type; function Create (Path : in String; Mode : in System.St_Mode_Type; Fi : access System.File_Info_Type) return System.Error_Type; function Open (Path : in String; Fi : access System.File_Info_Type) return System.Error_Type; function Release (Path : in String; Fi : access System.File_Info_Type) return System.Error_Type; function Read (Path : in String; Buffer : access Buffer_Type; Size : in out Natural; Offset : in Natural; Fi : access System.File_Info_Type) return System.Error_Type; function Write (Path : in String; Buffer : access Buffer_Type; Size : in out Natural; Offset : in Natural; Fi : access System.File_Info_Type) return System.Error_Type; function ReadDir (Path : in String; Filler : access procedure (Name : String; St_Buf : System.Stat_Access; Offset : Natural); Offset : in Natural; Fi : access System.File_Info_Type) return System.Error_Type; function Truncate (Path : in String; Size : in Natural) return System.Error_Type; package Keystore_Truncate is new Fuse_Keystore.Truncate; package Keystore_GetAttr is new Fuse_Keystore.GetAttr; package Keystore_MkDir is new Fuse_Keystore.MkDir; package Keystore_Unlink is new Fuse_Keystore.Unlink; package Keystore_RmDir is new Fuse_Keystore.RmDir; package Keystore_Create is new Fuse_Keystore.Create; package Keystore_Open is new Fuse_Keystore.Open; package Keystore_Release is new Fuse_Keystore.Release; package Keystore_Read is new Fuse_Keystore.Read; package Keystore_Write is new Fuse_Keystore.Write; package Keystore_ReadDir is new Fuse_Keystore.ReadDir; end AKT.Filesystem;
darkestkhan/xdg
Ada
8,716
adb
------------------------------------------------------------------------------ -- EMAIL: <[email protected]> -- -- License: ISC License (see COPYING file) -- -- -- -- Copyright © 2014 - 2015 darkestkhan -- ------------------------------------------------------------------------------ -- Permission to use, copy, modify, and/or distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- The software is provided "as is" and the author disclaims all warranties -- -- with regard to this software including all implied warranties of -- -- merchantability and fitness. In no event shall the author be liable for -- -- any special, direct, indirect, or consequential damages or any damages -- -- whatsoever resulting from loss of use, data or profits, whether in an -- -- action of contract, negligence or other tortious action, arising out of -- -- or in connection with the use or performance of this software. -- ------------------------------------------------------------------------------ with Ada.Directories; with Ada.Environment_Variables; private with XDG.Defaults; package body XDG is ---------------------------------------------------------------------------- package EV renames Ada.Environment_Variables; -- Directory separator is different for Windows and UNIX so use appropriate -- one. Sep: constant Character := XDG.Defaults.Separator; ---------------------------------------------------------------------------- generic Variable: String; Default : String; function Get_Home return String; function Get_Home return String is Home: constant String := EV.Value ("HOME"); begin if EV.Exists (Variable) then declare Value: constant String := EV.Value (Variable); begin if Value (Value'Last) = Sep then return Value; else return Value & Sep; end if; end; else if Home (Home'Last) = Sep then return Home & Default; else return Home & Sep & Default; end if; end if; end Get_Home; function Get_Data_Home is new Get_Home ("XDG_DATA_HOME", XDG.Defaults.Home); function Get_Config_Home is new Get_Home ("XDG_CONFIG_HOME", XDG.Defaults.Config); function Get_Cache_Home is new Get_Home ("XDG_CACHE_HOME", XDG.Defaults.Cache); function Data_Home return String renames Get_Data_Home; function Config_Home return String renames Get_Config_Home; function Cache_Home return String renames Get_Cache_Home; function Runtime_Dir return String is begin if EV.Exists ("XDG_RUNTIME_DIR") then declare Value: constant String := EV.Value ("XDG_RUNTIME_DIR"); begin if Value (Value'Last) = Sep then return Value; else return Value & Sep; end if; end; else return ""; end if; end Runtime_Dir; function Data_Dirs return String is begin if EV.Exists ("XDG_DATA_DIRS") then return EV.Value ("XDG_DATA_DIRS"); else return XDG.Defaults.Data_Dirs; end if; end Data_Dirs; function Config_Dirs return String is begin if EV.Exists ("XDG_CONFIG_DIRS") then return EV.Value ("XDG_CONFIG_DIRS"); else return XDG.Defaults.Config_Dirs; end if; end Config_Dirs; ---------------------------------------------------------------------------- generic with function XDG_Path return String; function XDG_Home (Directory: in String) return String; function XDG_Home (Directory: in String) return String is Path: constant String := XDG_Path; begin if Path (Path'Last) = Sep then if Directory (Directory'Last) = Sep then return Path & Directory; else return Path & Directory & Sep; end if; else if Directory (Directory'Last) = Sep then return Path & Sep & Directory; else return Path & Sep & Directory & Sep; end if; end if; end XDG_Home; function Data_Home_Path is new XDG_Home (Data_Home); function Config_Home_Path is new XDG_Home (Config_Home); function Cache_Home_Path is new XDG_Home (Cache_Home); function Data_Home (Directory: in String) return String renames Data_Home_Path; function Config_Home (Directory: in String) return String renames Config_Home_Path; function Cache_Home (Directory: in String) return String renames Cache_Home_Path; function Runtime_Dir (Directory: in String) return String is Path: constant String := Runtime_Dir; begin if Path'Length = 0 then raise No_Runtime_Dir; elsif Directory (Directory'Last) = Sep then return Path & Directory; else return Path & Directory & Sep; end if; end Runtime_Dir; ---------------------------------------------------------------------------- generic with function XDG_Path (Directory: in String) return String; procedure Create_Home (Directory: in String); procedure Create_Home (Directory: in String) is package AD renames Ada.Directories; Path: constant String := XDG_Path (Directory); begin AD.Create_Path (Path); end Create_Home; procedure Create_Data is new Create_Home (Data_Home); procedure Create_Config is new Create_Home (Config_Home); procedure Create_Cache is new Create_Home (Cache_Home); procedure Create_Runtime is new Create_Home (Runtime_Dir); procedure Create_Data_Home (Directory: in String) renames Create_Data; procedure Create_Config_Home (Directory: in String) renames Create_Config; procedure Create_Cache_Home (Directory: in String) renames Create_Cache; procedure Create_Runtime_Dir (Directory: in String) renames Create_Runtime; ---------------------------------------------------------------------------- generic with function XDG_Path (Directory: in String) return String; procedure Delete_Home (Directory: in String; Empty_Only: in Boolean := True); procedure Delete_Home (Directory: in String; Empty_Only: in Boolean := True) is package AD renames Ada.Directories; Path: constant String := XDG_Path (Directory); begin if Empty_Only then AD.Delete_Directory (Path); else AD.Delete_Tree (Path); end if; end Delete_Home; procedure Delete_Data is new Delete_Home (Data_Home); procedure Delete_Config is new Delete_Home (Config_Home); procedure Delete_Cache is new Delete_Home (Cache_Home); procedure Delete_Runtime is new Delete_Home (Runtime_Dir); procedure Delete_Data_Home ( Directory : in String; Empty_Only: in Boolean := True ) renames Delete_Data; procedure Delete_Config_Home ( Directory : in String; Empty_Only: in Boolean := True ) renames Delete_Config; procedure Delete_Cache_Home ( Directory : in String; Empty_Only: in Boolean := True ) renames Delete_Cache; procedure Delete_Runtime_Dir ( Directory : in String; Empty_Only: in Boolean := True ) renames Delete_Runtime; ---------------------------------------------------------------------------- generic with function XDG_Home (Directory: in String) return String; function Check_Home (Directory: in String) return Boolean; function Check_Home (Directory: in String) return Boolean is package AD renames Ada.Directories; use type AD.File_Kind; Path: constant String := XDG_Home (Directory); begin if AD.Exists (Path) and then AD.Kind (Path) /= AD.Directory then return False; else return True; end if; end Check_Home; function Check_Data_Home is new Check_Home (Data_Home); function Check_Config_Home is new Check_Home (Config_Home); function Check_Cache_Home is new Check_Home (Cache_Home); function Check_Runtime_Dir is new Check_Home (Runtime_Dir); function Is_Valid_Data_Home (Directory: in String) return Boolean renames Check_Data_Home; function Is_Valid_Config_Home (Directory: in String) return Boolean renames Check_Config_Home; function Is_Valid_Cache_Home (Directory: in String) return Boolean renames Check_Cache_Home; function Is_Valid_Runtime_Dir (Directory: in String) return Boolean renames Check_Runtime_Dir; ---------------------------------------------------------------------------- end XDG;
reznikmm/matreshka
Ada
4,688
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_Style.Snap_To_Layout_Grid_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Snap_To_Layout_Grid_Attribute_Node is begin return Self : Style_Snap_To_Layout_Grid_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Snap_To_Layout_Grid_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Snap_To_Layout_Grid_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Snap_To_Layout_Grid_Attribute, Style_Snap_To_Layout_Grid_Attribute_Node'Tag); end Matreshka.ODF_Style.Snap_To_Layout_Grid_Attributes;
stcarrez/mat
Ada
1,615
adb
----------------------------------------------------------------------- -- mat-main -- Main program -- Copyright (C) 2014, 2015, 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.IO_Exceptions; with Ada.Command_Line; with GNAT.Command_Line; with MAT.Commands; with MAT.Targets; with MAT.Consoles.Text; procedure MAT.Main is Target : MAT.Targets.Target_Type; Console : aliased MAT.Consoles.Text.Console_Type; begin MAT.Configure_Logs (Debug => False, Dump => False, Verbose => False); Target.Console (Console'Unchecked_Access); Target.Initialize_Options; MAT.Commands.Initialize_Files (Target); Target.Start; Target.Interactive; Target.Stop; exception when GNAT.Command_Line.Exit_From_Command_Line | GNAT.Command_Line.Invalid_Switch => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Ada.IO_Exceptions.End_Error | MAT.Targets.Usage_Error => Target.Stop; end MAT.Main;
persan/AdaYaml
Ada
29,019
adb
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Yaml.Lexer.Evaluation; package body Yaml.Lexer is ----------------------------------------------------------------------------- -- Initialization and buffer handling -- ----------------------------------------------------------------------------- procedure Basic_Init (L : in out Instance; Pool : Text.Pool.Reference) is begin L.State := Outside_Doc'Access; L.Flow_Depth := 0; L.Annotation_Depth := 0; L.Line_Start_State := Outside_Doc'Access; L.Json_Enabling_State := After_Token'Access; L.Pool := Pool; L.Proposed_Indentation := -1; end Basic_Init; procedure Init (L : in out Instance; Input : Source.Pointer; Pool : Text.Pool.Reference; Initial_Buffer_Size : Positive := Default_Initial_Buffer_Size) is begin L.Init (Input, Initial_Buffer_Size); Basic_Init (L, Pool); L.Cur := Next (L); end Init; procedure Init (L : in out Instance; Input : String; Pool : Text.Pool.Reference) is begin L.Init (Input); Basic_Init (L, Pool); L.Cur := Next (L); end Init; ----------------------------------------------------------------------------- -- interface and utilities ----------------------------------------------------------------------------- function Escaped (S : String) return String is Ret : String (1 .. S'Length * 4 + 2) := (1 => '"', others => <>); Retpos : Positive := 2; procedure Add_Escape_Sequence (C : Character) with Inline is begin Ret (Retpos .. Retpos + 1) := "\" & C; Retpos := Retpos + 2; end Add_Escape_Sequence; begin for C of S loop case C is when Line_Feed => Add_Escape_Sequence ('l'); when Carriage_Return => Add_Escape_Sequence ('c'); when '"' | ''' | '\' => Add_Escape_Sequence (C); when Character'Val (9) => Add_Escape_Sequence ('t'); when Character'Val (0) .. Character'Val (8) | Character'Val (11) | Character'Val (12) | Character'Val (14) .. Character'Val (31) => Add_Escape_Sequence ('x'); declare type Byte is range 0 .. 255; Charpos : constant Byte := Character'Pos (C); begin Ret (Retpos .. Retpos + 1) := (Character'Val (Charpos / 16 + Character'Pos ('0'))) & (Character'Val (Charpos mod 16 + Character'Pos ('0'))); Retpos := Retpos + 2; end; when others => Ret (Retpos) := C; Retpos := Retpos + 1; end case; end loop; Ret (Retpos) := '"'; return Ret (1 .. Retpos); end Escaped; function Escaped (C : Character) return String is (Escaped ("" & C)); function Escaped (C : Text.Reference) return String is (Escaped (C.Value)); function Next_Is_Plain_Safe (L : Instance) return Boolean is (case L.Buffer (L.Pos) is when Space_Or_Line_End => False, when Flow_Indicator => L.Flow_Depth + L.Annotation_Depth = 0, when ')' => L.Annotation_Depth = 0, when others => True); function Next_Token (L : in out Instance) return Token is Ret : Token; begin loop exit when L.State.all (L, Ret); end loop; return Ret; end Next_Token; function Short_Lexeme (L : Instance) return String is (L.Buffer (L.Token_Start .. L.Pos - 2)); function Full_Lexeme (L : Instance) return String is (L.Buffer (L.Token_Start - 1 .. L.Pos - 2)); procedure Start_Token (L : in out Instance) is begin L.Token_Start := L.Pos; L.Token_Start_Mark := Cur_Mark (L); end Start_Token; function Cur_Mark (L : Instance; Offset : Integer := -1) return Mark is ((Line => L.Cur_Line, Column => L.Pos + 1 - L.Line_Start + Offset, Index => L.Prev_Lines_Chars + L.Pos + 1 - L.Line_Start + Offset)); function Current_Content (L : Instance) return Text.Reference is (L.Value); function Escaped_Current (L : Instance) return String is (Escaped (L.Value)); function Current_Indentation (L : Instance) return Indentation_Type is (L.Pos - L.Line_Start - 1); function Recent_Indentation (L : Instance) return Indentation_Type is (L.Indentation); function Last_Scalar_Was_Multiline (L : Instance) return Boolean is (L.Seen_Multiline); function Recent_Start_Mark (L : Instance) return Mark is (L.Token_Start_Mark); -- to be called whenever a '-' is read as first character in a line. this -- function checks for whether this is a directives end marker ('---'). if -- yes, the lexer position is updated to be after the marker. function Is_Directives_End (L : in out Instance) return Boolean is Peek : Positive := L.Pos; begin if L.Buffer (Peek) = '-' then Peek := Peek + 1; if L.Buffer (Peek) = '-' then Peek := Peek + 1; if L.Buffer (Peek) in Space_Or_Line_End then L.Pos := Peek; L.Cur := Next (L); return True; end if; end if; end if; return False; end Is_Directives_End; -- similar to Hyphen_Line_Type, this function checks whether, when a line -- begin with a '.', that line contains a document end marker ('...'). if -- yes, the lexer position is updated to be after the marker. function Is_Document_End (L : in out Instance) return Boolean is Peek : Positive := L.Pos; begin if L.Buffer (Peek) = '.' then Peek := Peek + 1; if L.Buffer (Peek) = '.' then Peek := Peek + 1; if L.Buffer (Peek) in Space_Or_Line_End then L.Pos := Peek; L.Cur := Next (L); return True; end if; end if; end if; return False; end Is_Document_End; function Start_Line (L : in out Instance) return Line_Start_Kind is begin case L.Cur is when '-' => return (if Is_Directives_End (L) then Directives_End_Marker else Content); when '.' => return (if Is_Document_End (L) then Document_End_Marker else Content); when others => while L.Cur = ' ' loop L.Cur := Next (L); end loop; return (case L.Cur is when '#' => Comment, when Line_Feed | Carriage_Return => Newline, when End_Of_Input => Stream_End, when others => Content); end case; end Start_Line; ----------------------------------------------------------------------------- -- Tokenization -- ----------------------------------------------------------------------------- function Outside_Doc (L : in out Instance; T : out Token) return Boolean is begin case L.Cur is when '%' => Start_Token (L); loop L.Cur := Next (L); exit when L.Cur in Space_Or_Line_End; end loop; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => <>); declare Name : constant String := Short_Lexeme (L); begin if Name = "YAML" then L.State := Yaml_Version'Access; T.Kind := Yaml_Directive; return True; elsif Name = "TAG" then L.State := Tag_Shorthand'Access; T.Kind := Tag_Directive; return True; else L.State := Unknown_Directive'Access; T.Kind := Unknown_Directive; return True; end if; end; when '-' => Start_Token (L); if Is_Directives_End (L) then L.State := After_Token'Access; T.Kind := Directives_End; else L.State := Indentation_Setting_Token'Access; T.Kind := Indentation; end if; T.Start_Pos := L.Token_Start_Mark; T.End_Pos := Cur_Mark (L); L.Indentation := -1; L.Line_Start_State := Line_Start'Access; return True; when '.' => Start_Token (L); if Is_Document_End (L) then L.State := Expect_Line_End'Access; T.Kind := Document_End; else L.State := Indentation_Setting_Token'Access; L.Line_Start_State := Line_Start'Access; L.Indentation := -1; T.Kind := Indentation; end if; T.Start_Pos := L.Token_Start_Mark; T.End_Pos := Cur_Mark (L); return True; when others => Start_Token (L); while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur in Comment_Or_Line_End then L.State := Expect_Line_End'Access; return False; end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Indentation); L.Indentation := -1; L.State := Indentation_Setting_Token'Access; L.Line_Start_State := Line_Start'Access; return True; end case; end Outside_Doc; function Yaml_Version (L : in out Instance; T : out Token) return Boolean is procedure Read_Numeric_Subtoken is begin if not (L.Cur in Digit) then raise Lexer_Error with "Illegal character in YAML version string: " & Escaped (L.Cur); end if; loop L.Cur := Next (L); exit when not (L.Cur in Digit); end loop; end Read_Numeric_Subtoken; begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; Start_Token (L); Read_Numeric_Subtoken; if L.Cur /= '.' then raise Lexer_Error with "Illegal character in YAML version string: " & Escaped (L.Cur); end if; L.Cur := Next (L); Read_Numeric_Subtoken; if not (L.Cur in Space_Or_Line_End) then raise Lexer_Error with "Illegal character in YAML version string: " & Escaped (L.Cur); end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Directive_Param); L.State := Expect_Line_End'Access; return True; end Yaml_Version; function Tag_Shorthand (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur /= '!' then raise Lexer_Error with "Illegal character, tag shorthand must start with ""!"":" & Escaped (L.Cur); end if; Start_Token (L); L.Cur := Next (L); if L.Cur /= ' ' then while L.Cur in Tag_Shorthand_Char loop L.Cur := Next (L); end loop; if L.Cur /= '!' then if L.Cur in Space_Or_Line_End then raise Lexer_Error with "Tag shorthand must end with ""!""."; else raise Lexer_Error with "Illegal character in tag shorthand: " & Escaped (L.Cur); end if; end if; L.Cur := Next (L); if L.Cur /= ' ' then raise Lexer_Error with "Missing space after tag shorthand"; end if; end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Tag_Handle); L.State := At_Tag_Uri'Access; return True; end Tag_Shorthand; function At_Tag_Uri (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; Start_Token (L); if L.Cur = '<' then raise Lexer_Error with "Illegal character in tag prefix: " & Escaped (L.Cur); end if; Evaluation.Read_URI (L, False); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Suffix); L.State := Expect_Line_End'Access; return True; end At_Tag_Uri; function Unknown_Directive (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur in Comment_Or_Line_End then L.State := Expect_Line_End'Access; return False; end if; Start_Token (L); loop L.Cur := Next (L); exit when L.Cur in Space_Or_Line_End; end loop; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Directive_Param); return True; end Unknown_Directive; procedure End_Line (L : in out Instance) is begin loop case L.Cur is when Line_Feed => Handle_LF (L); L.Cur := L.Next; L.State := L.Line_Start_State; exit; when Carriage_Return => Handle_CR (L); L.Cur := L.Next; L.State := L.Line_Start_State; exit; when End_Of_Input => L.State := Stream_End'Access; exit; when '#' => loop L.Cur := Next (L); exit when L.Cur in Line_End; end loop; when others => null; -- forbidden by precondition end case; end loop; end End_Line; function Expect_Line_End (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if not (L.Cur in Comment_Or_Line_End) then raise Lexer_Error with "Unexpected character (expected line end): " & Escaped (L.Cur); end if; End_Line (L); return False; end Expect_Line_End; function Stream_End (L : in out Instance; T : out Token) return Boolean is begin Start_Token (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Stream_End); return True; end Stream_End; function Line_Start (L : in out Instance; T : out Token) return Boolean is begin case Start_Line (L) is when Directives_End_Marker => return Line_Dir_End (L, T); when Document_End_Marker => return Line_Doc_End (L, T); when Comment | Newline => End_Line (L); return False; when Stream_End => L.State := Stream_End'Access; return False; when Content => return Line_Indentation (L, T); end case; end Line_Start; function Flow_Line_Start (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); Indent : Natural; begin case L.Cur is when '-' => if Is_Directives_End (L) then raise Lexer_Error with "Directives end marker before end of flow content"; else Indent := 0; end if; when '.' => if Is_Document_End (L) then raise Lexer_Error with "Document end marker before end of flow content"; else Indent := 0; end if; when others => while L.Cur = ' ' loop L.Cur := Next (L); end loop; Indent := L.Pos - L.Line_Start - 1; end case; if Indent <= L.Indentation then raise Lexer_Error with "Too few indentation spaces (must surpass surrounding block element)" & L.Indentation'Img; end if; L.State := Inside_Line'Access; return False; end Flow_Line_Start; function Flow_Line_Indentation (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); begin if L.Pos - L.Line_Start - 1 < L.Indentation then raise Lexer_Error with "Too few indentation spaces (must surpass surrounding block element)"; end if; L.State := Inside_Line'Access; return False; end Flow_Line_Indentation; procedure Check_Indicator_Char (L : in out Instance; Kind : Token_Kind; T : out Token) is begin if Next_Is_Plain_Safe (L) then Evaluation.Read_Plain_Scalar (L, T); else Start_Token (L); L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); L.State := Before_Indentation_Setting_Token'Access; end if; end Check_Indicator_Char; procedure Enter_Flow_Collection (L : in out Instance; T : out Token; Kind : Token_Kind) is begin Start_Token (L); if L.Flow_Depth + L.Annotation_Depth = 0 then L.Json_Enabling_State := After_Json_Enabling_Token'Access; L.Line_Start_State := Flow_Line_Start'Access; L.Proposed_Indentation := -1; end if; L.Flow_Depth := L.Flow_Depth + 1; L.State := After_Token'Access; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); end Enter_Flow_Collection; procedure Leave_Flow_Collection (L : in out Instance; T : out Token; Kind : Token_Kind) is begin Start_Token (L); if L.Flow_Depth = 0 then raise Lexer_Error with "No flow collection to leave!"; end if; L.Flow_Depth := L.Flow_Depth - 1; if L.Flow_Depth + L.Annotation_Depth = 0 then L.Json_Enabling_State := After_Token'Access; L.Line_Start_State := Line_Start'Access; end if; L.State := L.Json_Enabling_State; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); end Leave_Flow_Collection; procedure Read_Namespace (L : in out Instance; T : out Token; NS_Char : Character; Kind : Token_Kind) with Pre => L.Cur = NS_Char is begin Start_Token (L); L.Cur := Next (L); if L.Cur = '<' then raise Lexer_Error with "Verbatim URIs not supported in YAML 1.3"; else -- we need to scan for a possible second NS_Char in case this is not a -- primary tag handle. We must lookahead here because there may be -- URI characters in the suffix that are not allowed in the handle. declare Handle_End : Positive := L.Token_Start; begin loop if L.Buffer (Handle_End) in Space_Or_Line_End | Flow_Indicator | Annotation_Param_Indicator then Handle_End := L.Token_Start; L.Pos := L.Pos - 1; exit; elsif L.Buffer (Handle_End) = NS_Char then Handle_End := Handle_End + 1; exit; else Handle_End := Handle_End + 1; end if; end loop; while L.Pos < Handle_End loop L.Cur := Next (L); if not (L.Cur in Tag_Shorthand_Char | NS_Char) then raise Lexer_Error with "Illegal character in tag handle: " & Escaped (L.Cur); end if; end loop; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); L.State := At_Suffix'Access; end; end if; end Read_Namespace; procedure Read_Anchor_Name (L : in out Instance) is begin Start_Token (L); loop L.Cur := Next (L); exit when not (L.Cur in Ascii_Char | Digit | '-' | '_'); end loop; if not (L.Cur in Space_Or_Line_End | Flow_Indicator | ')') then raise Lexer_Error with "Illegal character in anchor: " & Escaped (L.Cur); elsif L.Pos = L.Token_Start + 1 then raise Lexer_Error with "Anchor name must not be empty"; end if; L.State := After_Token'Access; end Read_Anchor_Name; function Inside_Line (L : in out Instance; T : out Token) return Boolean is begin case L.Cur is when ':' => Check_Indicator_Char (L, Map_Value_Ind, T); if T.Kind = Map_Value_Ind and then L.Proposed_Indentation /= -1 then -- necessary in the case of an empty scalar with node props -- in an implicit block map key L.Indentation := L.Proposed_Indentation; L.Proposed_Indentation := -1; end if; return True; when '?' => Check_Indicator_Char (L, Map_Key_Ind, T); return True; when '-' => Check_Indicator_Char (L, Seq_Item_Ind, T); return True; when Comment_Or_Line_End => End_Line (L); return False; when '"' => Evaluation.Read_Double_Quoted_Scalar (L, T); L.State := L.Json_Enabling_State; return True; when ''' => Evaluation.Read_Single_Quoted_Scalar (L, T); L.State := L.Json_Enabling_State; return True; when '>' | '|' => if L.Flow_Depth + L.Annotation_Depth > 0 then Evaluation.Read_Plain_Scalar (L, T); else Evaluation.Read_Block_Scalar (L, T); end if; return True; when '{' => Enter_Flow_Collection (L, T, Flow_Map_Start); return True; when '}' => Leave_Flow_Collection (L, T, Flow_Map_End); return True; when '[' => Enter_Flow_Collection (L, T, Flow_Seq_Start); return True; when ']' => Leave_Flow_Collection (L, T, Flow_Seq_End); return True; when ')' => Start_Token (L); if L.Annotation_Depth > 0 then L.Annotation_Depth := L.Annotation_Depth - 1; if L.Flow_Depth + L.Annotation_Depth = 0 then L.Json_Enabling_State := After_Token'Access; L.Line_Start_State := Line_Start'Access; end if; L.State := After_Token'Access; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Params_End); else Evaluation.Read_Plain_Scalar (L, T); end if; return True; when ',' => Start_Token (L); L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Flow_Separator); L.State := After_Token'Access; return True; when '!' => Read_Namespace (L, T, '!', Tag_Handle); return True; when '&' => Read_Anchor_Name (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Anchor); return True; when '*' => Read_Anchor_Name (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Alias); return True; when '@' => Read_Namespace (L, T, '@', Annotation_Handle); return True; when '`' => raise Lexer_Error with "Reserved characters cannot start a plain scalar."; when others => Evaluation.Read_Plain_Scalar (L, T); return True; end case; end Inside_Line; function Indentation_Setting_Token (L : in out Instance; T : out Token) return Boolean is Cached_Indentation : constant Natural := L.Pos - L.Line_Start - 1; begin return Ret : constant Boolean := Inside_Line (L, T) do if Ret and then L.Flow_Depth + L.Annotation_Depth = 0 then if T.Kind in Node_Property_Kind then L.Proposed_Indentation := Cached_Indentation; else L.Indentation := Cached_Indentation; end if; end if; end return; end Indentation_Setting_Token; function After_Token (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur in Comment_Or_Line_End then End_Line (L); else L.State := Inside_Line'Access; end if; return False; end After_Token; function Before_Indentation_Setting_Token (L : in out Instance; T : out Token) return Boolean is begin if After_Token (L, T) then null; end if; if L.State = Inside_Line'Access then L.State := Indentation_Setting_Token'Access; end if; return False; end Before_Indentation_Setting_Token; function After_Json_Enabling_Token (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; loop case L.Cur is when ':' => Start_Token (L); L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Map_Value_Ind); L.State := After_Token'Access; return True; when '#' | Carriage_Return | Line_Feed => End_Line (L); if Flow_Line_Start (L, T) then null; end if; when End_Of_Input => L.State := Stream_End'Access; return False; when others => L.State := Inside_Line'Access; return False; end case; end loop; end After_Json_Enabling_Token; function Line_Indentation (L : in out Instance; T : out Token) return Boolean is begin T := (Start_Pos => (Line => L.Cur_Line, Column => 1, Index => L.Prev_Lines_Chars), End_Pos => Cur_Mark (L), Kind => Indentation); L.State := Indentation_Setting_Token'Access; return True; end Line_Indentation; function Line_Dir_End (L : in out Instance; T : out Token) return Boolean is begin T := (Start_Pos => (Line => L.Cur_Line, Column => 1, Index => L.Prev_Lines_Chars), End_Pos => Cur_Mark (L), Kind => Directives_End); L.State := After_Token'Access; L.Indentation := -1; L.Proposed_Indentation := -1; return True; end Line_Dir_End; -- similar to Indentation_After_Plain_Scalar, but used for a document end -- marker ending a plain scalar. function Line_Doc_End (L : in out Instance; T : out Token) return Boolean is begin T := (Start_Pos => (Line => L.Cur_Line, Column => 1, Index => L.Prev_Lines_Chars), End_Pos => Cur_Mark (L), Kind => Document_End); L.State := Expect_Line_End'Access; L.Line_Start_State := Outside_Doc'Access; return True; end Line_Doc_End; function At_Suffix (L : in out Instance; T : out Token) return Boolean is begin Start_Token (L); while L.Cur in Suffix_Char loop L.Cur := Next (L); end loop; L.Value := L.Pool.From_String (L.Full_Lexeme); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Suffix); L.State := After_Suffix'Access; return True; end At_Suffix; function After_Suffix (L : in out Instance; T : out Token) return Boolean is begin L.State := After_Token'Access; if L.Cur = '(' then Start_Token (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Params_Start); L.Annotation_Depth := L.Annotation_Depth + 1; L.Proposed_Indentation := -1; L.Cur := Next (L); return True; else return False; end if; end After_Suffix; end Yaml.Lexer;
burratoo/Acton
Ada
862
ads
------------------------------------------------------------------------------------------ -- -- -- OAKLAND COMPONENTS -- -- -- -- OAKLAND -- -- -- -- Copyright (C) 2011-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ package Oakland with Pure is end Oakland;
apple-oss-distributions/old_ncurses
Ada
3,412
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address -- -- -- -- 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 ------------------------------------------------------------------------------ package Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address is pragma Preelaborate (Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address); type Internet_V4_Address_Field is new Field_Type with null record; procedure Set_Field_Type (Fld : in Field; Typ : in Internet_V4_Address_Field); pragma Inline (Set_Field_Type); end Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address;
reznikmm/matreshka
Ada
3,801
adb
------------------------------------------------------------------------------ -- -- -- 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 ODF.Constants; package body Matreshka.ODF_Attributes.Style.Distance_Before_Sep is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Distance_Before_Sep_Node) return League.Strings.Universal_String is begin return ODF.Constants.Distance_Before_Sep_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Distance_Before_Sep;
MinimSecure/unum-sdk
Ada
1,360
adb
-- Copyright 2015-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Bar; use Bar; procedure Foo_O224_021 is O1 : constant Object_Type := Get_Str ("Foo"); procedure Child1 is O2 : constant Object_Type := Get_Str ("Foo"); function Child2 (S : String) return Boolean is -- STOP begin for C of S loop Do_Nothing (C); if C = 'o' then return True; end if; end loop; return False; end Child2; R : Boolean; begin R := Child2 ("Foo"); R := Child2 ("Bar"); R := Child2 ("Foobar"); end Child1; begin Child1; end Foo_O224_021;
MinimSecure/unum-sdk
Ada
868
adb
-- Copyright 2015-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Reprod; use Reprod; procedure Reprod_Main is O : Obj_T (Len => 1); begin O.Data := (others => (I => 1)); Do_Nothing (O); end Reprod_Main;
stcarrez/ada-awa
Ada
1,164
ads
----------------------------------------------------------------------- -- awa-modules-get -- Get a specific module instance -- Copyright (C) 2011 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. ----------------------------------------------------------------------- -- The <b>Get</b> function is an helper that retrieves a given module -- instance from the current application. generic type Module_Type is new Module with private; type Module_Type_Access is access all Module_Type'Class; Name : String; function AWA.Modules.Get return Module_Type_Access;
tum-ei-rcs/StratoX
Ada
4,317
adb
-- Project: StratoX -- System: Stratosphere Balloon Flight Controller -- Author: Martin Becker ([email protected]) with FAT_Filesystem; use FAT_Filesystem; with FAT_Filesystem.Directories; use FAT_Filesystem.Directories; with FAT_Filesystem.Directories.Files; use FAT_Filesystem.Directories.Files; with Media_Reader.SDCard; use Media_Reader.SDCard; -- @summary top-level package for reading/writing to SD card -- minimal package with pointer stuff package body SDLog with SPARK_Mode => Off is SD_Controller : aliased SDCard_Controller; -- limited type FS : FAT_Filesystem_Access := null; -- pointer fh_log : FAT_Filesystem.Directories.Files.File_Handle; ----------- -- Close -- ----------- procedure Close is begin Close (FS); log_open := False; end Close; ---------- -- Init -- ---------- procedure Init is Status : FAT_Filesystem.Status_Code; begin SD_Initialized := False; log_open := False; SD_Controller.Initialize; if not SD_Controller.Card_Present then Error_State := True; return; else Error_State := False; end if; FS := Open (SD_Controller'Unchecked_Access, Status); if Status /= OK then Error_State := True; return; else SD_Initialized := True; end if; end Init; ------------------- -- Start_Logfile -- ------------------- -- creates a new directory within root, that is named -- after the build. procedure Start_Logfile (dirname : String; filename : String; ret : out Boolean) is Hnd_Root : Directory_Handle; Status : Status_Code; Log_Dir : Directory_Entry; Log_Hnd : Directory_Handle; begin ret := False; if (not SD_Initialized) or Error_State then return; end if; if Open_Root_Directory (FS, Hnd_Root) /= OK then Error_State := True; return; end if; -- 1. create log directory Status := Make_Directory (Parent => Hnd_Root, newname => dirname, D_Entry => Log_Dir); if Status /= OK and then Status /= Already_Exists then return; end if; Close (Hnd_Root); Status := Open (E => Log_Dir, Dir => Log_Hnd); if Status /= OK then return; end if; -- 2. create log file Status := File_Create (Parent => Log_Hnd, newname => filename, File => fh_log); if Status /= OK then return; end if; ret := True; log_open := True; end Start_Logfile; --------------- -- Flush_Log -- --------------- procedure Flush_Log is begin if not log_open then return; end if; declare Status : Status_Code := File_Flush (fh_log); pragma Unreferenced (Status); begin null; end; end Flush_Log; --------------- -- Write_Log -- --------------- procedure Write_Log (Data : FAT_Filesystem.Directories.Files.File_Data; n_written : out Integer) is begin if not log_open then n_written := -1; return; end if; declare DISCARD : Status_Code; begin n_written := File_Write (File => fh_log, Data => Data, Status => DISCARD); end; end Write_Log; procedure Write_Log (S : String; n_written : out Integer) is d : File_Data renames To_File_Data (S); begin Write_Log (d, n_written); end Write_Log; ------------------ -- To_File_Data -- ------------------ function To_File_Data (S : String) return FAT_Filesystem.Directories.Files.File_Data is d : File_Data (1 .. S'Length); idx : Unsigned_16 := d'First; begin -- FIXME: inefficient for k in S'Range loop d (idx) := Character'Pos (S (k)); idx := idx + 1; end loop; return d; -- this throws an exception. end To_File_Data; function Is_Open return Boolean is (log_open); function Logsize return Unsigned_32 is (File_Size (fh_log)); end SDLog;
AdaCore/Ada_Drivers_Library
Ada
13,130
ads
-- This spec has been automatically generated from STM32F46_79x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.GPIO is pragma Preelaborate; --------------- -- Registers -- --------------- -- MODER array element subtype MODER_Element is HAL.UInt2; -- MODER array type MODER_Field_Array is array (0 .. 15) of MODER_Element with Component_Size => 2, Size => 32; -- GPIO port mode register type MODER_Register (As_Array : Boolean := False) is record case As_Array is when False => -- MODER as a value Val : HAL.UInt32; when True => -- MODER as an array Arr : MODER_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for MODER_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- OTYPER_OT array type OTYPER_OT_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for OTYPER_OT type OTYPER_OT_Field (As_Array : Boolean := False) is record case As_Array is when False => -- OT as a value Val : HAL.UInt16; when True => -- OT as an array Arr : OTYPER_OT_Field_Array; end case; end record with Unchecked_Union, Size => 16; for OTYPER_OT_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port output type register type OTYPER_Register is record -- Port x configuration bits (y = 0..15) OT : OTYPER_OT_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTYPER_Register use record OT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- OSPEEDR array element subtype OSPEEDR_Element is HAL.UInt2; -- OSPEEDR array type OSPEEDR_Field_Array is array (0 .. 15) of OSPEEDR_Element with Component_Size => 2, Size => 32; -- GPIO port output speed register type OSPEEDR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- OSPEEDR as a value Val : HAL.UInt32; when True => -- OSPEEDR as an array Arr : OSPEEDR_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OSPEEDR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- PUPDR array element subtype PUPDR_Element is HAL.UInt2; -- PUPDR array type PUPDR_Field_Array is array (0 .. 15) of PUPDR_Element with Component_Size => 2, Size => 32; -- GPIO port pull-up/pull-down register type PUPDR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PUPDR as a value Val : HAL.UInt32; when True => -- PUPDR as an array Arr : PUPDR_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for PUPDR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- IDR array type IDR_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for IDR type IDR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- IDR as a value Val : HAL.UInt16; when True => -- IDR as an array Arr : IDR_Field_Array; end case; end record with Unchecked_Union, Size => 16; for IDR_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port input data register type IDR_Register is record -- Read-only. Port input data (y = 0..15) IDR : IDR_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IDR_Register use record IDR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- ODR array type ODR_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for ODR type ODR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- ODR as a value Val : HAL.UInt16; when True => -- ODR as an array Arr : ODR_Field_Array; end case; end record with Unchecked_Union, Size => 16; for ODR_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port output data register type ODR_Register is record -- Port output data (y = 0..15) ODR : ODR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ODR_Register use record ODR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- BSRR_BS array type BSRR_BS_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for BSRR_BS type BSRR_BS_Field (As_Array : Boolean := False) is record case As_Array is when False => -- BS as a value Val : HAL.UInt16; when True => -- BS as an array Arr : BSRR_BS_Field_Array; end case; end record with Unchecked_Union, Size => 16; for BSRR_BS_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- BSRR_BR array type BSRR_BR_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for BSRR_BR type BSRR_BR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- BR as a value Val : HAL.UInt16; when True => -- BR as an array Arr : BSRR_BR_Field_Array; end case; end record with Unchecked_Union, Size => 16; for BSRR_BR_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port bit set/reset register type BSRR_Register is record -- Write-only. Port x set bit y (y= 0..15) BS : BSRR_BS_Field := (As_Array => False, Val => 16#0#); -- Write-only. Port x set bit y (y= 0..15) BR : BSRR_BR_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BSRR_Register use record BS at 0 range 0 .. 15; BR at 0 range 16 .. 31; end record; -- LCKR_LCK array type LCKR_LCK_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for LCKR_LCK type LCKR_LCK_Field (As_Array : Boolean := False) is record case As_Array is when False => -- LCK as a value Val : HAL.UInt16; when True => -- LCK as an array Arr : LCKR_LCK_Field_Array; end case; end record with Unchecked_Union, Size => 16; for LCKR_LCK_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port configuration lock register type LCKR_Register is record -- Port x lock bit y (y= 0..15) LCK : LCKR_LCK_Field := (As_Array => False, Val => 16#0#); -- Port x lock bit y (y= 0..15) LCKK : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LCKR_Register use record LCK at 0 range 0 .. 15; LCKK at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; -- AFRL array element subtype AFRL_Element is HAL.UInt4; -- AFRL array type AFRL_Field_Array is array (0 .. 7) of AFRL_Element with Component_Size => 4, Size => 32; -- GPIO alternate function low register type AFRL_Register (As_Array : Boolean := False) is record case As_Array is when False => -- AFRL as a value Val : HAL.UInt32; when True => -- AFRL as an array Arr : AFRL_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for AFRL_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- AFRH array element subtype AFRH_Element is HAL.UInt4; -- AFRH array type AFRH_Field_Array is array (8 .. 15) of AFRH_Element with Component_Size => 4, Size => 32; -- GPIO alternate function high register type AFRH_Register (As_Array : Boolean := False) is record case As_Array is when False => -- AFRH as a value Val : HAL.UInt32; when True => -- AFRH as an array Arr : AFRH_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for AFRH_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- General-purpose I/Os type GPIO_Peripheral is record -- GPIO port mode register MODER : aliased MODER_Register; -- GPIO port output type register OTYPER : aliased OTYPER_Register; -- GPIO port output speed register OSPEEDR : aliased OSPEEDR_Register; -- GPIO port pull-up/pull-down register PUPDR : aliased PUPDR_Register; -- GPIO port input data register IDR : aliased IDR_Register; -- GPIO port output data register ODR : aliased ODR_Register; -- GPIO port bit set/reset register BSRR : aliased BSRR_Register; -- GPIO port configuration lock register LCKR : aliased LCKR_Register; -- GPIO alternate function low register AFRL : aliased AFRL_Register; -- GPIO alternate function high register AFRH : aliased AFRH_Register; end record with Volatile; for GPIO_Peripheral use record MODER at 16#0# range 0 .. 31; OTYPER at 16#4# range 0 .. 31; OSPEEDR at 16#8# range 0 .. 31; PUPDR at 16#C# range 0 .. 31; IDR at 16#10# range 0 .. 31; ODR at 16#14# range 0 .. 31; BSRR at 16#18# range 0 .. 31; LCKR at 16#1C# range 0 .. 31; AFRL at 16#20# range 0 .. 31; AFRH at 16#24# range 0 .. 31; end record; -- General-purpose I/Os GPIOA_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020000#); -- General-purpose I/Os GPIOB_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020400#); -- General-purpose I/Os GPIOC_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020800#); -- General-purpose I/Os GPIOD_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020C00#); -- General-purpose I/Os GPIOE_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021000#); -- General-purpose I/Os GPIOF_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021400#); -- General-purpose I/Os GPIOG_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021800#); -- General-purpose I/Os GPIOH_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021C00#); -- General-purpose I/Os GPIOI_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40022000#); -- General-purpose I/Os GPIOJ_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40022400#); -- General-purpose I/Os GPIOK_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40022800#); end STM32_SVD.GPIO;
stcarrez/ada-asf
Ada
4,904
adb
----------------------------------------------------------------------- -- components-root -- ASF Root View Component -- Copyright (C) 2010, 2011, 2012, 2018 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.Unchecked_Deallocation; with ASF.Components.Base; with ASF.Components.Core.Views; package body ASF.Components.Root is -- ------------------------------ -- Get the root node of the view. -- ------------------------------ function Get_Root (UI : in UIViewRoot) return access Base.UIComponent'Class is begin if UI.Root = null then return null; elsif UI.Root.Meta = null then return UI.Root.View; else return UI.Root.Meta; end if; end Get_Root; -- ------------------------------ -- Set the root node of the view. -- ------------------------------ procedure Set_Root (UI : in out UIViewRoot; Root : access Base.UIComponent'Class; Name : in String) is begin if UI.Root /= null then Finalize (UI); end if; UI.Root := new Root_Holder '(Ref_Counter => 1, Len => Name'Length, View => Root, Meta => null, Name => Name); end Set_Root; -- ------------------------------ -- Set the metadata component of the view. -- ------------------------------ procedure Set_Meta (UI : in out UIViewRoot) is Node : access Base.UIComponent'Class; begin if UI.Root /= null then Node := UI.Root.View; UI.Root.Meta := Node.Get_Facet (Core.Views.METADATA_FACET_NAME); if UI.Root.Meta = null then declare Iter : Base.Cursor := Base.First (Node.all); begin while Base.Has_Element (Iter) loop UI.Root.Meta := Base.Element (Iter).Get_Facet (Core.Views.METADATA_FACET_NAME); exit when UI.Root.Meta /= null; Base.Next (Iter); end loop; end; end if; end if; end Set_Meta; -- ------------------------------ -- Returns True if the view has a metadata component. -- ------------------------------ function Has_Meta (UI : in UIViewRoot) return Boolean is begin return UI.Root /= null and then UI.Root.Meta /= null; end Has_Meta; -- ------------------------------ -- Get the view identifier. -- ------------------------------ function Get_View_Id (UI : in UIViewRoot) return String is begin return UI.Root.Name; end Get_View_Id; -- ------------------------------ -- Create an identifier for a component. -- ------------------------------ procedure Create_Unique_Id (UI : in out UIViewRoot; Id : out Natural) is begin UI.Last_Id := UI.Last_Id + 1; Id := UI.Last_Id; end Create_Unique_Id; -- ------------------------------ -- Increment the reference counter. -- ------------------------------ overriding procedure Adjust (Object : in out UIViewRoot) is begin if Object.Root /= null then Object.Root.Ref_Counter := Object.Root.Ref_Counter + 1; end if; end Adjust; Empty : ASF.Components.Base.UIComponent; -- ------------------------------ -- Free the memory held by the component tree. -- ------------------------------ overriding procedure Finalize (Object : in out UIViewRoot) is procedure Free is new Ada.Unchecked_Deallocation (Object => Root_Holder, Name => Root_Holder_Access); begin if Object.Root /= null then Object.Root.Ref_Counter := Object.Root.Ref_Counter - 1; if Object.Root.Ref_Counter = 0 then declare C : ASF.Components.Base.UIComponent_Access := Object.Root.View.all'Unchecked_Access; begin ASF.Components.Base.Steal_Root_Component (Empty, C); end; Free (Object.Root); end if; end if; end Finalize; end ASF.Components.Root;
reznikmm/matreshka
Ada
4,712
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_Style.Border_Line_Width_Left_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Border_Line_Width_Left_Attribute_Node is begin return Self : Style_Border_Line_Width_Left_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Border_Line_Width_Left_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Border_Line_Width_Left_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Border_Line_Width_Left_Attribute, Style_Border_Line_Width_Left_Attribute_Node'Tag); end Matreshka.ODF_Style.Border_Line_Width_Left_Attributes;
optikos/oasis
Ada
7,730
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Formal_Derived_Type_Definitions; with Program.Element_Visitors; package Program.Nodes.Formal_Derived_Type_Definitions is pragma Preelaborate; type Formal_Derived_Type_Definition is new Program.Nodes.Node and Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition and Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition_Text with private; function Create (Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access; Limited_Token : Program.Lexical_Elements.Lexical_Element_Access; Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access; New_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; And_Token : Program.Lexical_Elements.Lexical_Element_Access; Progenitors : Program.Elements.Expressions .Expression_Vector_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Private_Token : Program.Lexical_Elements.Lexical_Element_Access) return Formal_Derived_Type_Definition; type Implicit_Formal_Derived_Type_Definition is new Program.Nodes.Node and Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition with private; function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Progenitors : Program.Elements.Expressions .Expression_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Abstract : Boolean := False; Has_Limited : Boolean := False; Has_Synchronized : Boolean := False; Has_With_Private : Boolean := False) return Implicit_Formal_Derived_Type_Definition with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Formal_Derived_Type_Definition is abstract new Program.Nodes.Node and Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition with record Subtype_Mark : not null Program.Elements.Expressions.Expression_Access; Progenitors : Program.Elements.Expressions.Expression_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Formal_Derived_Type_Definition'Class); overriding procedure Visit (Self : not null access Base_Formal_Derived_Type_Definition; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Subtype_Mark (Self : Base_Formal_Derived_Type_Definition) return not null Program.Elements.Expressions.Expression_Access; overriding function Progenitors (Self : Base_Formal_Derived_Type_Definition) return Program.Elements.Expressions.Expression_Vector_Access; overriding function Is_Formal_Derived_Type_Definition_Element (Self : Base_Formal_Derived_Type_Definition) return Boolean; overriding function Is_Formal_Type_Definition_Element (Self : Base_Formal_Derived_Type_Definition) return Boolean; overriding function Is_Definition_Element (Self : Base_Formal_Derived_Type_Definition) return Boolean; type Formal_Derived_Type_Definition is new Base_Formal_Derived_Type_Definition and Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition_Text with record Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access; Limited_Token : Program.Lexical_Elements.Lexical_Element_Access; Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access; New_Token : not null Program.Lexical_Elements .Lexical_Element_Access; And_Token : Program.Lexical_Elements.Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Private_Token : Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Formal_Derived_Type_Definition_Text (Self : aliased in out Formal_Derived_Type_Definition) return Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition_Text_Access; overriding function Abstract_Token (Self : Formal_Derived_Type_Definition) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Limited_Token (Self : Formal_Derived_Type_Definition) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Synchronized_Token (Self : Formal_Derived_Type_Definition) return Program.Lexical_Elements.Lexical_Element_Access; overriding function New_Token (Self : Formal_Derived_Type_Definition) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function And_Token (Self : Formal_Derived_Type_Definition) return Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Formal_Derived_Type_Definition) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Private_Token (Self : Formal_Derived_Type_Definition) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_Abstract (Self : Formal_Derived_Type_Definition) return Boolean; overriding function Has_Limited (Self : Formal_Derived_Type_Definition) return Boolean; overriding function Has_Synchronized (Self : Formal_Derived_Type_Definition) return Boolean; overriding function Has_With_Private (Self : Formal_Derived_Type_Definition) return Boolean; type Implicit_Formal_Derived_Type_Definition is new Base_Formal_Derived_Type_Definition with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_Abstract : Boolean; Has_Limited : Boolean; Has_Synchronized : Boolean; Has_With_Private : Boolean; end record; overriding function To_Formal_Derived_Type_Definition_Text (Self : aliased in out Implicit_Formal_Derived_Type_Definition) return Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; overriding function Has_Abstract (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; overriding function Has_Limited (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; overriding function Has_Synchronized (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; overriding function Has_With_Private (Self : Implicit_Formal_Derived_Type_Definition) return Boolean; end Program.Nodes.Formal_Derived_Type_Definitions;
twdroeger/ada-awa
Ada
6,227
ads
----------------------------------------------------------------------- -- awa-images-modules -- Image management module -- Copyright (C) 2012, 2016, 2018 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 ASF.Applications; with AWA.Modules; with AWA.Storages.Models; with AWA.Storages.Services; with AWA.Images.Models; with AWA.Jobs.Services; with AWA.Jobs.Modules; with AWA.Images.Servlets; with ADO; private with EL.Expressions; -- == Image Module == -- The <tt>Image_Module</tt> type represents the image module. An instance of the image -- module must be declared and registered when the application is created and initialized. -- The image module is associated with the image service which provides and implements -- the image management operations. -- -- When the image module is initialized, it registers itself as a listener to the storage -- module to be notified when a storage file is created, updated or removed. When a file -- is added, it looks at the file type and extracts the image information if the storage file -- is an image. -- -- @include-config images.xml package AWA.Images.Modules is NAME : constant String := "images"; PARAM_THUMBNAIL_COMMAND : constant String := "thumbnail_command"; -- Job worker procedure to identify an image and generate its thumnbnail. procedure Thumbnail_Worker (Job : in out AWA.Jobs.Services.Abstract_Job_Type'Class); package Thumbnail_Job_Definition is new AWA.Jobs.Services.Work_Definition (Thumbnail_Worker'Access); type Image_Module is new AWA.Modules.Module and AWA.Storages.Services.Listener with private; type Image_Module_Access is access all Image_Module'Class; -- Initialize the image module. overriding procedure Initialize (Plugin : in out Image_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config); -- Configures the module after its initialization and after having read its XML configuration. overriding procedure Configure (Plugin : in out Image_Module; Props : in ASF.Applications.Config); -- The `On_Create` procedure is called by `Notify_Create` to notify the creation of the item. overriding procedure On_Create (Instance : in Image_Module; Item : in AWA.Storages.Models.Storage_Ref'Class); -- The `On_Update` procedure is called by `Notify_Update` to notify the update of the item. overriding procedure On_Update (Instance : in Image_Module; Item : in AWA.Storages.Models.Storage_Ref'Class); -- The `On_Delete` procedure is called by `Notify_Delete` to notify the deletion of the item. overriding procedure On_Delete (Instance : in Image_Module; Item : in AWA.Storages.Models.Storage_Ref'Class); -- Create a thumbnail job for the image. procedure Make_Thumbnail_Job (Plugin : in Image_Module; Image : in AWA.Images.Models.Image_Ref'Class); -- Thumbnail job to identify the image dimension and produce a thumbnail. procedure Do_Thumbnail_Job (Plugin : in Image_Module; Job : in out AWA.Jobs.Services.Abstract_Job_Type'Class); -- Get the image module instance associated with the current application. function Get_Image_Module return Image_Module_Access; -- Returns true if the storage file has an image mime type. function Is_Image (File : in AWA.Storages.Models.Storage_Ref'Class) return Boolean; procedure Create_Thumbnail (Service : in Image_Module; Source : in String; Into : in String; Width : in out Natural; Height : in out Natural); -- Build a thumbnail for the image identified by the Id. procedure Build_Thumbnail (Service : in Image_Module; Id : in ADO.Identifier); -- Save the data object contained in the <b>Data</b> part element into the -- target storage represented by <b>Into</b>. procedure Create_Image (Plugin : in Image_Module; File : in AWA.Storages.Models.Storage_Ref'Class); -- Deletes the storage instance. procedure Delete_Image (Service : in Image_Module; File : in AWA.Storages.Models.Storage_Ref'Class); -- Scale the image dimension. procedure Scale (Width : in Natural; Height : in Natural; To_Width : in out Natural; To_Height : in out Natural); -- Get the dimension represented by the string. The string has one of the following -- formats: -- original -> Width, Height := Natural'Last -- default -> Width, Height := 0 -- <width>x -> Width := <width>, Height := 0 -- x<height> -> Width := 0, Height := <height> -- <width>x<height> -> Width := <width>, Height := <height> procedure Get_Sizes (Dimension : in String; Width : out Natural; Height : out Natural); private type Image_Module is new AWA.Modules.Module and AWA.Storages.Services.Listener with record Thumbnail_Command : EL.Expressions.Expression; Job_Module : AWA.Jobs.Modules.Job_Module_Access; Image_Servlet : aliased AWA.Images.Servlets.Image_Servlet; end record; end AWA.Images.Modules;
BrickBot/Bound-T-H8-300
Ada
3,584
ads
-- Options.Interval_Valued (decl) -- -- Options with values of type Storage.Bounds.Interval_T. -- -- 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 19:36:51 $ -- -- $Log: options-interval_valued.ads,v $ -- Revision 1.2 2015/10/24 19:36:51 niklas -- Moved to free licence. -- -- Revision 1.1 2011-10-18 20:17:07 niklas -- First version, for Toy ALF export. -- with Storage.Bounds; package Options.Interval_Valued is type Option_T is new Options.Option_T with record Default : Storage.Bounds.Interval_T := Storage.Bounds.Universal_Interval; Value : Storage.Bounds.Interval_T := Storage.Bounds.Universal_Interval; end record; -- -- An option that has a default value and a current value, -- both of which are intervals of integer values. -- If the Value is Universal_Interval the option can be -- considered unset (since Universal_Interval puts no -- constraint on a value). -- -- Options of this kind are not enumerable. overriding function Type_And_Default (Option : access Option_T) return String; overriding procedure Reset (Option : access Option_T); -- -- Option.Value := Universal_Interval. overriding procedure Set ( Option : access Option_T; Value : in String); -- -- Option.Value is set to the interval presented in the Value, -- which has the approximate syntax <min, optional> .. <max, optional>. -- Thus ".." represents the universal interval. function Set (Value : Storage.Bounds.Interval_T) return Option_T; -- -- Constructs an option that is Set to the given Value, -- which is also the Default value. function Value_Of (Option : Option_T) return Storage.Bounds.Interval_T; -- -- The Value of the Option. end Options.Interval_Valued;
AdaCore/libadalang
Ada
284
adb
procedure Test is package P is type T is tagged null record; procedure Proc (X : access T) is null; end P; package Q is type U is new P.T with null record; end Q; Obj : aliased Q.U; begin Q.Proc (Obj'Access); pragma Test_Statement; end Test;
francesco-bongiovanni/ewok-kernel
Ada
4,866
adb
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- #if CONFIG_KERNEL_DOMAIN with ewok.tasks; #end if; package body ewok.perm with spark_mode => on is function dmashm_is_granted (from : in t_real_task_id; to : in t_real_task_id) return boolean is begin -- Assertion on the statically built com_dmashm_perm: -- a task is not allowed to declare a DMA_SHM to itself -- This assertion is a DMA_SHM matrix sanitation pragma Assert (for all x in t_real_task_id => (not ewok.perm_auto.com_dmashm_perm(x,x))); return ewok.perm_auto.com_dmashm_perm (from, to); end dmashm_is_granted; function ipc_is_granted (from : in t_real_task_id; to : in t_real_task_id) return boolean is begin -- Assertion on the statically built com_ipc_perm: -- a task is not allowed to declare an IPC channel to itself -- This assertion is an IPC matrix sanitation pragma Assert (for all x in t_real_task_id => (not ewok.perm_auto.com_ipc_perm(x,x))); return ewok.perm_auto.com_ipc_perm (from, to); end ipc_is_granted; #if CONFIG_KERNEL_DOMAIN function is_same_domain (from : in t_real_task_id; to : in t_real_task_id) return boolean with Spark_Mode => Off -- implies tasks.get_domain() to be Spark compatible is begin return (ewok.tasks.get_domain(from) = ewok.tasks.get_domain(to)); end is_same_domain; #end if; function ressource_is_granted (perm_name : in t_perm_name; task_id : in applications.t_real_task_id) return boolean is begin -- is there some assertion checking that some ressources tuples are -- forbidden case perm_name is when PERM_RES_DEV_DMA => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_DMA = 1; when PERM_RES_DEV_CRYPTO_USR => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 1 or ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3; when PERM_RES_DEV_CRYPTO_CFG => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 2 or ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3; when PERM_RES_DEV_CRYPTO_FULL => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3; when PERM_RES_DEV_BUSES => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_BUS = 1; when PERM_RES_DEV_EXTI => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_EXTI = 1; when PERM_RES_DEV_TIM => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_TIM = 1; when PERM_RES_TIM_GETMILLI => return ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 0; when PERM_RES_TIM_GETMICRO => return ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 1; when PERM_RES_TIM_GETCYCLE => return ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 2; when PERM_RES_TSK_FISR => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_FISR = 1; when PERM_RES_TSK_FIPC => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_FIPC = 1; when PERM_RES_TSK_RESET => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_RESET = 1; when PERM_RES_TSK_UPGRADE => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_UPGRADE = 1; when PERM_RES_MEM_DYNAMIC_MAP => return ewok.perm_auto.ressource_perm_register_tab(task_id).MEM_DYNAMIC_MAP = 1; end case; end ressource_is_granted; end ewok.perm;
stcarrez/babel
Ada
1,581
ads
----------------------------------------------------------------------- -- babel-files-signatures -- Signatures calculation -- Copyright (C) 2014, 2015, 2016 Stephane.Carrez -- Written by Stephane.Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Babel.Files; with Babel.Files.Buffers; with Babel.Files.Maps; with Babel.Streams.Refs; package Babel.Files.Signatures is -- Compute the SHA1 signature of the data stored in the buffer. procedure Sha1 (Buffer : in Babel.Files.Buffers.Buffer; Result : out Util.Encoders.SHA1.Hash_Array); -- Compute the SHA1 signature of the file stream. procedure Sha1 (Stream : in Babel.Streams.Refs.Stream_Ref; Result : out Util.Encoders.SHA1.Hash_Array); -- Write the SHA1 checksum for the files stored in the map. procedure Save_Checksum (Path : in String; Files : in Babel.Files.Maps.File_Map); end Babel.Files.Signatures;
zhmu/ananas
Ada
67
ads
generic package Elab6_Pkg is procedure Call_Ent; end Elab6_Pkg;
AdaCore/libadalang
Ada
283
adb
procedure Test is package Pkg is type Str is null record with String_Literal => To_Str; function To_Str (X : Wide_Wide_String) return Str is (null record); end Pkg; X : Pkg.Str := "Helloooo"; pragma Test_Statement; begin null; end Test;
zhmu/ananas
Ada
5,280
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . E X P O N R -- -- -- -- B o d y -- -- -- -- Copyright (C) 2021-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Note that the reason for treating exponents in the range 0 .. 4 specially -- is to ensure identical results with the static expansion in the case of a -- compile-time known exponent in this range; similarly, the use 'Machine is -- to avoid unwanted extra precision in the results. -- For a negative exponent, we compute the result as per RM 4.5.6(11/3): -- Left ** Right = 1.0 / (Left ** (-Right)) -- Note that the case of Left being zero is not special, it will simply result -- in a division by zero at the end, yielding a correctly signed infinity, or -- possibly raising an overflow exception. -- Note on overflow: this coding assumes that the target generates infinities -- with standard IEEE semantics. If this is not the case, then the code for -- negative exponents may raise Constraint_Error, which is in keeping with the -- implementation permission given in RM 4.5.6(12). with System.Double_Real; function System.Exponr (Left : Num; Right : Integer) return Num is package Double_Real is new System.Double_Real (Num); use type Double_Real.Double_T; subtype Double_T is Double_Real.Double_T; -- The double floating-point type subtype Safe_Negative is Integer range Integer'First + 1 .. -1; -- The range of safe negative exponents function Expon (Left : Num; Right : Natural) return Num; -- Routine used if Right is greater than 4 ----------- -- Expon -- ----------- function Expon (Left : Num; Right : Natural) return Num is Result : Double_T := Double_Real.To_Double (1.0); Factor : Double_T := Double_Real.To_Double (Left); Exp : Natural := Right; begin -- We use the standard logarithmic approach, Exp gets shifted right -- testing successive low order bits and Factor is the value of the -- base raised to the next power of 2. If the low order bit or Exp -- is set, multiply the result by this factor. loop if Exp rem 2 /= 0 then Result := Result * Factor; exit when Exp = 1; end if; Exp := Exp / 2; Factor := Double_Real.Sqr (Factor); end loop; return Double_Real.To_Single (Result); end Expon; begin case Right is when 0 => return 1.0; when 1 => return Left; when 2 => return Num'Machine (Left * Left); when 3 => return Num'Machine (Left * Left * Left); when 4 => declare Sqr : constant Num := Num'Machine (Left * Left); begin return Num'Machine (Sqr * Sqr); end; when Safe_Negative => return Num'Machine (1.0 / Exponr (Left, -Right)); when Integer'First => return Num'Machine (1.0 / (Exponr (Left, Integer'Last) * Left)); when others => return Num'Machine (Expon (Left, Right)); end case; end System.Exponr;
rtice3/AdaFractalLib
Ada
2,229
ads
with Ada.Synchronous_Barriers; use Ada.Synchronous_Barriers; with System; with Computation_Type; with Image_Types; generic with package CT is new Computation_Type (<>); with package IT is new Image_Types (<>); with procedure Calculate_Pixel (Re : CT.Real; Im : CT.Real; Z_Escape : out CT.Real; Iter_Escape : out Natural); Task_Pool_Size : Natural; package Fractal is use CT; use IT; procedure Init (Viewport : Viewport_Info); procedure Set_Size (Viewport : Viewport_Info); procedure Calculate_Image (Buffer : not null Buffer_Access); -- procedure Increment_Frame; function Get_Buffer_Size return Buffer_Offset; procedure Calculate_Row (Y : ImgHeight; Idx : Buffer_Offset; Buffer : not null Buffer_Access); private Real_Distance_Unzoomed : constant Real := To_Real (4); type Complex_Coordinate is record Re : Real; Im : Real; end record; S_Width : ImgWidth; S_Height : ImgHeight; S_Zoom : ImgZoom; S_Center : Complex_Coordinate; S_Step : Complex_Coordinate; S_Max : Complex_Coordinate; S_Min : Complex_Coordinate; -- S_Frame_Counter : Color := Color'First; -- S_Cnt_Up : Boolean := True; procedure Calculate_Bounds; procedure Calculate_Step; -- procedure Calculate_Pixel_Color (Z_Escape : Real; -- Iter_Escape : Natural; -- Px : out Pixel); function Get_Coordinate (X : ImgWidth; Y : ImgHeight) return Complex_Coordinate; function Get_Coordinate (Coord : Coordinate) return Complex_Coordinate is (Get_Coordinate (X => Coord.X, Y => Coord.Y)); function Get_Width return ImgWidth is (S_Width); function Get_Height return ImgHeight is (S_Height); function Get_Buffer_Size return Buffer_Offset is (Buffer_Offset (S_Width * S_Height * (Pixel'Size / 8))); end Fractal;
zhmu/ananas
Ada
417
adb
-- { dg-do run } procedure Fixedpnt7 is type F1 is delta 1.0 range -2.0**63 .. 0.0 with Small => 1.0; type F2 is delta 4.0 range 0.0 .. 2.0**64 with Small => 4.0; type D is delta 1.0 digits 18; XX : constant := -2.0**63; YY : constant := 2.0**64; X : F1 := XX; Y : F2 := YY; U : D := D'Round(X / Y); begin if U /= -1.0 then raise Program_Error; end if; end Fixedpnt7;
optikos/oasis
Ada
9,428
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Parameter_Specifications; with Program.Elements.Expressions; with Program.Elements.Aspect_Specifications; with Program.Elements.Formal_Procedure_Declarations; with Program.Element_Visitors; package Program.Nodes.Formal_Procedure_Declarations is pragma Preelaborate; type Formal_Procedure_Declaration is new Program.Nodes.Node and Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration and Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration_Text with private; function Create (With_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Procedure_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Is_Token : Program.Lexical_Elements.Lexical_Element_Access; Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Subprogram_Default : Program.Elements.Expressions.Expression_Access; Box_Token : Program.Lexical_Elements.Lexical_Element_Access; With_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Formal_Procedure_Declaration; type Implicit_Formal_Procedure_Declaration is new Program.Nodes.Node and Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration with private; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Subprogram_Default : Program.Elements.Expressions.Expression_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Abstract : Boolean := False; Has_Null : Boolean := False; Has_Box : Boolean := False) return Implicit_Formal_Procedure_Declaration with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Formal_Procedure_Declaration is abstract new Program.Nodes.Node and Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration with record Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Subprogram_Default : Program.Elements.Expressions.Expression_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Formal_Procedure_Declaration'Class); overriding procedure Visit (Self : not null access Base_Formal_Procedure_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Name (Self : Base_Formal_Procedure_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; overriding function Parameters (Self : Base_Formal_Procedure_Declaration) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; overriding function Subprogram_Default (Self : Base_Formal_Procedure_Declaration) return Program.Elements.Expressions.Expression_Access; overriding function Aspects (Self : Base_Formal_Procedure_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; overriding function Is_Formal_Procedure_Declaration_Element (Self : Base_Formal_Procedure_Declaration) return Boolean; overriding function Is_Declaration_Element (Self : Base_Formal_Procedure_Declaration) return Boolean; type Formal_Procedure_Declaration is new Base_Formal_Procedure_Declaration and Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration_Text with record With_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Procedure_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Is_Token : Program.Lexical_Elements.Lexical_Element_Access; Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Box_Token : Program.Lexical_Elements.Lexical_Element_Access; With_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Formal_Procedure_Declaration_Text (Self : aliased in out Formal_Procedure_Declaration) return Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration_Text_Access; overriding function With_Token (Self : Formal_Procedure_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Procedure_Token (Self : Formal_Procedure_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Left_Bracket_Token (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Right_Bracket_Token (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Is_Token (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Abstract_Token (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Null_Token (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Box_Token (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token_2 (Self : Formal_Procedure_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Formal_Procedure_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_Abstract (Self : Formal_Procedure_Declaration) return Boolean; overriding function Has_Null (Self : Formal_Procedure_Declaration) return Boolean; overriding function Has_Box (Self : Formal_Procedure_Declaration) return Boolean; type Implicit_Formal_Procedure_Declaration is new Base_Formal_Procedure_Declaration with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_Abstract : Boolean; Has_Null : Boolean; Has_Box : Boolean; end record; overriding function To_Formal_Procedure_Declaration_Text (Self : aliased in out Implicit_Formal_Procedure_Declaration) return Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Formal_Procedure_Declaration) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Formal_Procedure_Declaration) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Formal_Procedure_Declaration) return Boolean; overriding function Has_Abstract (Self : Implicit_Formal_Procedure_Declaration) return Boolean; overriding function Has_Null (Self : Implicit_Formal_Procedure_Declaration) return Boolean; overriding function Has_Box (Self : Implicit_Formal_Procedure_Declaration) return Boolean; end Program.Nodes.Formal_Procedure_Declarations;
opec2019/opec
Ada
15,819
ads
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $ with Interfaces.C.Strings; with System; private package ZLib.Thin is -- From zconf.h MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 -- zconf.h:105 MAX_WBITS : constant := 15; -- zconf.h:115 -- 32K LZ77 window -- zconf.h:115 SEEK_SET : constant := 8#0000#; -- zconf.h:244 -- Seek from beginning of file. -- zconf.h:244 SEEK_CUR : constant := 1; -- zconf.h:245 -- Seek from current position. -- zconf.h:245 SEEK_END : constant := 2; -- zconf.h:246 -- Set file pointer to EOF plus "offset" -- zconf.h:246 type Byte is new Interfaces.C.unsigned_char; -- 8 bits -- zconf.h:214 type UInt is new Interfaces.C.unsigned; -- 16 bits or more -- zconf.h:216 type Int is new Interfaces.C.int; type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more -- zconf.h:217 subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; type ULong_Access is access ULong; type Int_Access is access Int; subtype Voidp is System.Address; -- zconf.h:232 subtype Byte_Access is Voidp; Nul : constant Voidp := System.Null_Address; -- end from zconf Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 -- zlib.h:125 Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 -- will be reOpecd, use -- Z_SYNC_FLUSH instead -- zlib.h:126 Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 -- zlib.h:127 Z_FULL_FLUSH : constant := 3; -- zlib.h:128 -- zlib.h:128 Z_FINISH : constant := 4; -- zlib.h:129 -- zlib.h:129 Z_OK : constant := 8#0000#; -- zlib.h:132 -- zlib.h:132 Z_STREAM_END : constant := 1; -- zlib.h:133 -- zlib.h:133 Z_NEED_DICT : constant := 2; -- zlib.h:134 -- zlib.h:134 Z_ERRNO : constant := -1; -- zlib.h:135 -- zlib.h:135 Z_STREAM_ERROR : constant := -2; -- zlib.h:136 -- zlib.h:136 Z_DATA_ERROR : constant := -3; -- zlib.h:137 -- zlib.h:137 Z_MEM_ERROR : constant := -4; -- zlib.h:138 -- zlib.h:138 Z_BUF_ERROR : constant := -5; -- zlib.h:139 -- zlib.h:139 Z_VERSION_ERROR : constant := -6; -- zlib.h:140 -- zlib.h:140 Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 -- zlib.h:145 Z_BEST_SPEED : constant := 1; -- zlib.h:146 -- zlib.h:146 Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 -- zlib.h:147 Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 -- zlib.h:148 Z_FILTERED : constant := 1; -- zlib.h:151 -- zlib.h:151 Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 -- zlib.h:152 Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 -- zlib.h:153 Z_BINARY : constant := 8#0000#; -- zlib.h:156 -- zlib.h:156 Z_ASCII : constant := 1; -- zlib.h:157 -- zlib.h:157 Z_UNKNOWN : constant := 2; -- zlib.h:158 -- zlib.h:158 Z_DEFLATED : constant := 8; -- zlib.h:161 -- zlib.h:161 Z_NULL : constant := 8#0000#; -- zlib.h:164 -- for initializing zalloc, zfree, opaque -- zlib.h:164 type gzFile is new Voidp; -- zlib.h:646 type Z_Stream is private; type Z_Streamp is access all Z_Stream; -- zlib.h:89 type alloc_func is access function (Opaque : Voidp; Items : UInt; Size : UInt) return Voidp; -- zlib.h:63 type free_func is access procedure (opaque : Voidp; address : Voidp); function zlibVersion return Chars_Ptr; function Deflate (strm : Z_Streamp; flush : Int) return Int; function DeflateEnd (strm : Z_Streamp) return Int; function Inflate (strm : Z_Streamp; flush : Int) return Int; function InflateEnd (strm : Z_Streamp) return Int; function deflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; -- zlib.h:478 function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 function deflateParams (strm : Z_Streamp; level : Int; strategy : Int) return Int; -- zlib.h:506 function inflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; -- zlib.h:548 function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 function compress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; -- zlib.h:601 function compress2 (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong; level : Int) return Int; -- zlib.h:615 function uncompress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; function gzsetparams (file : gzFile; level : Int; strategy : Int) return Int; function gzread (file : gzFile; buf : Voidp; len : UInt) return Int; function gzwrite (file : in gzFile; buf : in Voidp; len : in UInt) return Int; function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; function gzgets (file : gzFile; buf : Chars_Ptr; len : Int) return Chars_Ptr; function gzputc (file : gzFile; char : Int) return Int; function gzgetc (file : gzFile) return Int; function gzflush (file : gzFile; flush : Int) return Int; function gzseek (file : gzFile; offset : Int; whence : Int) return Int; function gzrewind (file : gzFile) return Int; function gztell (file : gzFile) return Int; function gzeof (file : gzFile) return Int; function gzclose (file : gzFile) return Int; function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; function adler32 (adler : ULong; buf : Byte_Access; len : UInt) return ULong; function crc32 (crc : ULong; buf : Byte_Access; len : UInt) return ULong; function deflateInit (strm : Z_Streamp; level : Int; version : Chars_Ptr; stream_size : Int) return Int; function deflateInit2 (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int; version : Chars_Ptr; stream_size : Int) return Int; function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int; pragma Inline (Deflate_Init); function inflateInit (strm : Z_Streamp; version : Chars_Ptr; stream_size : Int) return Int; function inflateInit2 (strm : in Z_Streamp; windowBits : in Int; version : in Chars_Ptr; stream_size : in Int) return Int; function inflateBackInit (strm : in Z_Streamp; windowBits : in Int; window : in Byte_Access; version : in Chars_Ptr; stream_size : in Int) return Int; -- Size of window have to be 2**windowBits. function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; pragma Inline (Inflate_Init); function zError (err : Int) return Chars_Ptr; function inflateSyncPoint (z : Z_Streamp) return Int; function get_crc_table return ULong_Access; -- Interface to the available fields of the z_stream structure. -- The application must update next_in and avail_in when avail_in has -- dropped to zero. It must update next_out and avail_out when avail_out -- has dropped to zero. The application must initialize zalloc, zfree and -- opaque before calling the init function. procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_In); procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_Out); procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func); pragma Inline (Set_Mem_Func); function Last_Error_Message (Strm : in Z_Stream) return String; pragma Inline (Last_Error_Message); function Avail_Out (Strm : in Z_Stream) return UInt; pragma Inline (Avail_Out); function Avail_In (Strm : in Z_Stream) return UInt; pragma Inline (Avail_In); function Total_In (Strm : in Z_Stream) return ULong; pragma Inline (Total_In); function Total_Out (Strm : in Z_Stream) return ULong; pragma Inline (Total_Out); function inflateCopy (dest : in Z_Streamp; Source : in Z_Streamp) return Int; function compressBound (Source_Len : in ULong) return ULong; function deflateBound (Strm : in Z_Streamp; Source_Len : in ULong) return ULong; function gzungetc (C : in Int; File : in gzFile) return Int; function zlibCompileFlags return ULong; private type Z_Stream is record -- zlib.h:68 Next_In : Voidp := Nul; -- next input byte Avail_In : UInt := 0; -- number of bytes available at next_in Total_In : ULong := 0; -- total nb of input bytes read so far Next_Out : Voidp := Nul; -- next output byte should be put there Avail_Out : UInt := 0; -- remaining free space at next_out Total_Out : ULong := 0; -- total nb of bytes output so far msg : Chars_Ptr; -- last error message, NULL if no error state : Voidp; -- not visible by applications zalloc : alloc_func := null; -- used to allocate the internal state zfree : free_func := null; -- used to free the internal state opaque : Voidp; -- private data object passed to -- zalloc and zfree data_type : Int; -- best guess about the data type: -- ascii or binary adler : ULong; -- adler32 value of the uncompressed -- data reserved : ULong; -- reserved for future use end record; pragma Convention (C, Z_Stream); pragma Import (C, zlibVersion, "zlibVersion"); pragma Import (C, Deflate, "deflate"); pragma Import (C, DeflateEnd, "deflateEnd"); pragma Import (C, Inflate, "inflate"); pragma Import (C, InflateEnd, "inflateEnd"); pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); pragma Import (C, deflateCopy, "deflateCopy"); pragma Import (C, deflateReset, "deflateReset"); pragma Import (C, deflateParams, "deflateParams"); pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); pragma Import (C, inflateSync, "inflateSync"); pragma Import (C, inflateReset, "inflateReset"); pragma Import (C, compress, "compress"); pragma Import (C, compress2, "compress2"); pragma Import (C, uncompress, "uncompress"); pragma Import (C, gzopen, "gzopen"); pragma Import (C, gzdopen, "gzdopen"); pragma Import (C, gzsetparams, "gzsetparams"); pragma Import (C, gzread, "gzread"); pragma Import (C, gzwrite, "gzwrite"); pragma Import (C, gzprintf, "gzprintf"); pragma Import (C, gzputs, "gzputs"); pragma Import (C, gzgets, "gzgets"); pragma Import (C, gzputc, "gzputc"); pragma Import (C, gzgetc, "gzgetc"); pragma Import (C, gzflush, "gzflush"); pragma Import (C, gzseek, "gzseek"); pragma Import (C, gzrewind, "gzrewind"); pragma Import (C, gztell, "gztell"); pragma Import (C, gzeof, "gzeof"); pragma Import (C, gzclose, "gzclose"); pragma Import (C, gzerror, "gzerror"); pragma Import (C, adler32, "adler32"); pragma Import (C, crc32, "crc32"); pragma Import (C, deflateInit, "deflateInit_"); pragma Import (C, inflateInit, "inflateInit_"); pragma Import (C, deflateInit2, "deflateInit2_"); pragma Import (C, inflateInit2, "inflateInit2_"); pragma Import (C, zError, "zError"); pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); pragma Import (C, get_crc_table, "get_crc_table"); -- since zlib 1.2.0: pragma Import (C, inflateCopy, "inflateCopy"); pragma Import (C, compressBound, "compressBound"); pragma Import (C, deflateBound, "deflateBound"); pragma Import (C, gzungetc, "gzungetc"); pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); pragma Import (C, inflateBackInit, "inflateBackInit_"); -- I stopped binding the inflateBack routines, becouse realize that -- it does not support zlib and gzip headers for now, and have no -- symmetric deflateBack routines. -- ZLib-Ada is symmetric regarding deflate/inflate data transformation -- and has a similar generic callback interface for the -- deflate/inflate transformation based on the regular Deflate/Inflate -- routines. -- pragma Import (C, inflateBack, "inflateBack"); -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); end ZLib.Thin;
zhmu/ananas
Ada
437
ads
package Discr41 is type Vector is array (Positive range <>) of Long_Float; type Date is record LF : Long_Float := 0.0; end record; type Date_Vector is array (Positive range <>) of Date; type Rec (D : Natural) is record B1 : Boolean := False; DL : Date_Vector (1 .. D); VL : Vector (1 .. D) := (others => 0.0); B2 : Boolean := True; end record; function F return Rec; end Discr41;
sudoadminservices/bugbountyservices
Ada
1,880
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "ZETAlytics" type = "api" function start() setratelimit(5) end function check() local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local resp local vurl = buildurl(domain, c.key) -- Check if the response data is in the graph database if (cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(domain, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return end if (cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(domain, resp) end end local d = json.decode(resp) if (d == nil or #(d.results) == 0) then return end for i, r in pairs(d.results) do sendnames(ctx, r.qname) end end function buildurl(domain, key) return "https://zonecruncher.com/api/v1/subdomains?q=" .. domain .. "&token=" .. key end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end local found = {} for i, v in pairs(names) do if found[v] == nil then newname(ctx, v) found[v] = true end end end
reznikmm/matreshka
Ada
3,699
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.Draw_Placing_Attributes is pragma Preelaborate; type ODF_Draw_Placing_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Placing_Attribute_Access is access all ODF_Draw_Placing_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Placing_Attributes;
reznikmm/matreshka
Ada
36,502
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Classifiers; with AMF.String_Collections; with AMF.UML.Classifier_Template_Parameters; with AMF.UML.Classifiers.Collections; with AMF.UML.Collaboration_Uses.Collections; with AMF.UML.Communication_Paths; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Element_Imports.Collections; with AMF.UML.Elements.Collections; with AMF.UML.Features.Collections; with AMF.UML.Generalization_Sets.Collections; with AMF.UML.Generalizations.Collections; with AMF.UML.Named_Elements.Collections; with AMF.UML.Namespaces; with AMF.UML.Package_Imports.Collections; with AMF.UML.Packageable_Elements.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements.Collections; with AMF.UML.Properties.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.Redefinable_Template_Signatures; with AMF.UML.String_Expressions; with AMF.UML.Substitutions.Collections; with AMF.UML.Template_Bindings.Collections; with AMF.UML.Template_Parameters; with AMF.UML.Template_Signatures; with AMF.UML.Types.Collections; with AMF.UML.Use_Cases.Collections; with AMF.Visitors; package AMF.Internals.UML_Communication_Paths is type UML_Communication_Path_Proxy is limited new AMF.Internals.UML_Classifiers.UML_Classifier_Proxy and AMF.UML.Communication_Paths.UML_Communication_Path with null record; overriding function Get_End_Type (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Types.Collections.Ordered_Set_Of_UML_Type; -- Getter of Association::endType. -- -- References the classifiers that are used as types of the ends of the -- association. overriding function Get_Is_Derived (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Getter of Association::isDerived. -- -- Specifies whether the association is derived from other model elements -- such as other associations or constraints. overriding procedure Set_Is_Derived (Self : not null access UML_Communication_Path_Proxy; To : Boolean); -- Setter of Association::isDerived. -- -- Specifies whether the association is derived from other model elements -- such as other associations or constraints. overriding function Get_Member_End (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property; -- Getter of Association::memberEnd. -- -- Each end represents participation of instances of the classifier -- connected to the end in links of the association. overriding function Get_Navigable_Owned_End (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property; -- Getter of Association::navigableOwnedEnd. -- -- The navigable ends that are owned by the association itself. overriding function Get_Owned_End (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property; -- Getter of Association::ownedEnd. -- -- The ends that are owned by the association itself. overriding function Get_Related_Element (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of Relationship::relatedElement. -- -- Specifies the elements related by the Relationship. overriding function Get_Attribute (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property; -- Getter of Classifier::attribute. -- -- Refers to all of the Properties that are direct (i.e. not inherited or -- imported) attributes of the classifier. overriding function Get_Collaboration_Use (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use; -- Getter of Classifier::collaborationUse. -- -- References the collaboration uses owned by the classifier. overriding function Get_Feature (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature; -- Getter of Classifier::feature. -- -- Specifies each feature defined in the classifier. -- Note that there may be members of the Classifier that are of the type -- Feature but are not included in this association, e.g. inherited -- features. overriding function Get_General (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of Classifier::general. -- -- Specifies the general Classifiers for this Classifier. -- References the general classifier in the Generalization relationship. overriding function Get_Generalization (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization; -- Getter of Classifier::generalization. -- -- Specifies the Generalization relationships for this Classifier. These -- Generalizations navigaten to more general classifiers in the -- generalization hierarchy. overriding function Get_Inherited_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Classifier::inheritedMember. -- -- Specifies all elements inherited by this classifier from the general -- classifiers. overriding function Get_Is_Abstract (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Getter of Classifier::isAbstract. -- -- If true, the Classifier does not provide a complete declaration and can -- typically not be instantiated. An abstract classifier is intended to be -- used by other classifiers e.g. as the target of general -- metarelationships or generalization relationships. overriding function Get_Is_Final_Specialization (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Getter of Classifier::isFinalSpecialization. -- -- If true, the Classifier cannot be specialized by generalization. Note -- that this property is preserved through package merge operations; that -- is, the capability to specialize a Classifier (i.e., -- isFinalSpecialization =false) must be preserved in the resulting -- Classifier of a package merge operation where a Classifier with -- isFinalSpecialization =false is merged with a matching Classifier with -- isFinalSpecialization =true: the resulting Classifier will have -- isFinalSpecialization =false. overriding procedure Set_Is_Final_Specialization (Self : not null access UML_Communication_Path_Proxy; To : Boolean); -- Setter of Classifier::isFinalSpecialization. -- -- If true, the Classifier cannot be specialized by generalization. Note -- that this property is preserved through package merge operations; that -- is, the capability to specialize a Classifier (i.e., -- isFinalSpecialization =false) must be preserved in the resulting -- Classifier of a package merge operation where a Classifier with -- isFinalSpecialization =false is merged with a matching Classifier with -- isFinalSpecialization =true: the resulting Classifier will have -- isFinalSpecialization =false. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access; -- Getter of Classifier::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access); -- Setter of Classifier::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Owned_Use_Case (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case; -- Getter of Classifier::ownedUseCase. -- -- References the use cases owned by this classifier. overriding function Get_Powertype_Extent (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set; -- Getter of Classifier::powertypeExtent. -- -- Designates the GeneralizationSet of which the associated Classifier is -- a power type. overriding function Get_Redefined_Classifier (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of Classifier::redefinedClassifier. -- -- References the Classifiers that are redefined by this Classifier. overriding function Get_Representation (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access; -- Getter of Classifier::representation. -- -- References a collaboration use which indicates the collaboration that -- represents this classifier. overriding procedure Set_Representation (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access); -- Setter of Classifier::representation. -- -- References a collaboration use which indicates the collaboration that -- represents this classifier. overriding function Get_Substitution (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution; -- Getter of Classifier::substitution. -- -- References the substitutions that are owned by this Classifier. overriding function Get_Template_Parameter (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access; -- Getter of Classifier::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access); -- Setter of Classifier::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Use_Case (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case; -- Getter of Classifier::useCase. -- -- The set of use cases for which this Classifier is the subject. overriding function Get_Element_Import (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import; -- Getter of Namespace::elementImport. -- -- References the ElementImports owned by the Namespace. overriding function Get_Imported_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Getter of Namespace::importedMember. -- -- References the PackageableElements that are members of this Namespace -- as a result of either PackageImports or ElementImports. overriding function Get_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::member. -- -- A collection of NamedElements identifiable within the Namespace, either -- by being owned or by being introduced by importing or inheritance. overriding function Get_Owned_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::ownedMember. -- -- A collection of NamedElements owned by the Namespace. overriding function Get_Owned_Rule (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Namespace::ownedRule. -- -- Specifies a set of Constraints owned by this Namespace. overriding function Get_Package_Import (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import; -- Getter of Namespace::packageImport. -- -- References the PackageImports owned by the Namespace. overriding function Get_Client_Dependency (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Communication_Path_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Package (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Packages.UML_Package_Access; -- Getter of Type::package. -- -- Specifies the owning package of this classifier, if any. overriding procedure Set_Package (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Packages.UML_Package_Access); -- Setter of Type::package. -- -- Specifies the owning package of this classifier, if any. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Template_Signatures.UML_Template_Signature_Access; -- Getter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Communication_Path_Proxy; To : AMF.UML.Template_Signatures.UML_Template_Signature_Access); -- Setter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Template_Binding (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding; -- Getter of TemplateableElement::templateBinding. -- -- The optional bindings from this element to templates. overriding function Get_Is_Leaf (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Communication_Path_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function End_Type (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Types.Collections.Ordered_Set_Of_UML_Type; -- Operation Association::endType. -- -- endType is derived from the types of the member ends. overriding function All_Features (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature; -- Operation Classifier::allFeatures. -- -- The query allFeatures() gives all of the features in the namespace of -- the classifier. In general, through mechanisms such as inheritance, -- this will be a larger set than feature. overriding function Conforms_To (Self : not null access constant UML_Communication_Path_Proxy; Other : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean; -- Operation Classifier::conformsTo. -- -- The query conformsTo() gives true for a classifier that defines a type -- that conforms to another. This is used, for example, in the -- specification of signature conformance for operations. overriding function General (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Operation Classifier::general. -- -- The general classifiers are the classifiers referenced by the -- generalization relationships. overriding function Has_Visibility_Of (Self : not null access constant UML_Communication_Path_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access) return Boolean; -- Operation Classifier::hasVisibilityOf. -- -- The query hasVisibilityOf() determines whether a named element is -- visible in the classifier. By default all are visible. It is only -- called when the argument is something owned by a parent. overriding function Inherit (Self : not null access constant UML_Communication_Path_Proxy; Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inherit. -- -- The query inherit() defines how to inherit a set of elements. Here the -- operation is defined to inherit them all. It is intended to be -- redefined in circumstances where inheritance is affected by -- redefinition. -- The inherit operation is overridden to exclude redefined properties. overriding function Inheritable_Members (Self : not null access constant UML_Communication_Path_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inheritableMembers. -- -- The query inheritableMembers() gives all of the members of a classifier -- that may be inherited in one of its descendants, subject to whatever -- visibility restrictions apply. overriding function Inherited_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inheritedMember. -- -- The inheritedMember association is derived by inheriting the -- inheritable members of the parents. -- The inheritedMember association is derived by inheriting the -- inheritable members of the parents. overriding function Is_Template (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Operation Classifier::isTemplate. -- -- The query isTemplate() returns whether this templateable element is -- actually a template. overriding function May_Specialize_Type (Self : not null access constant UML_Communication_Path_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean; -- Operation Classifier::maySpecializeType. -- -- The query maySpecializeType() determines whether this classifier may -- have a generalization relationship to classifiers of the specified -- type. By default a classifier may specialize classifiers of the same or -- a more general type. It is intended to be redefined by classifiers that -- have different specialization constraints. overriding function Exclude_Collisions (Self : not null access constant UML_Communication_Path_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::excludeCollisions. -- -- The query excludeCollisions() excludes from a set of -- PackageableElements any that would not be distinguishable from each -- other in this namespace. overriding function Get_Names_Of_Member (Self : not null access constant UML_Communication_Path_Proxy; Element : AMF.UML.Named_Elements.UML_Named_Element_Access) return AMF.String_Collections.Set_Of_String; -- Operation Namespace::getNamesOfMember. -- -- The query getNamesOfMember() takes importing into account. It gives -- back the set of names that an element would have in an importing -- namespace, either because it is owned, or if not owned then imported -- individually, or if not individually then from a package. -- The query getNamesOfMember() gives a set of all of the names that a -- member would have in a Namespace. In general a member can have multiple -- names in a Namespace if it is imported more than once with different -- aliases. The query takes account of importing. It gives back the set of -- names that an element would have in an importing namespace, either -- because it is owned, or if not owned then imported individually, or if -- not individually then from a package. overriding function Import_Members (Self : not null access constant UML_Communication_Path_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importMembers. -- -- The query importMembers() defines which of a set of PackageableElements -- are actually imported into the namespace. This excludes hidden ones, -- i.e., those which have names that conflict with names of owned members, -- and also excludes elements which would have the same name when imported. overriding function Imported_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importedMember. -- -- The importedMember property is derived from the ElementImports and the -- PackageImports. References the PackageableElements that are members of -- this Namespace as a result of either PackageImports or ElementImports. overriding function Members_Are_Distinguishable (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Operation Namespace::membersAreDistinguishable. -- -- The Boolean query membersAreDistinguishable() determines whether all of -- the namespace's members are distinguishable within it. overriding function Owned_Member (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Namespace::ownedMember. -- -- Missing derivation for Namespace::/ownedMember : NamedElement overriding function All_Owning_Packages (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Communication_Path_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Conforms_To (Self : not null access constant UML_Communication_Path_Proxy; Other : AMF.UML.Types.UML_Type_Access) return Boolean; -- Operation Type::conformsTo. -- -- The query conformsTo() gives true for a type that conforms to another. -- By default, two types do not conform to each other. This query is -- intended to be redefined for specific conformance situations. overriding function Is_Compatible_With (Self : not null access constant UML_Communication_Path_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Communication_Path_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding function Parameterable_Elements (Self : not null access constant UML_Communication_Path_Proxy) return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element; -- Operation TemplateableElement::parameterableElements. -- -- The query parameterableElements() returns the set of elements that may -- be used as the parametered elements for a template parameter of this -- templateable element. By default, this set includes all the owned -- elements. Subclasses may override this operation if they choose to -- restrict the set of parameterable elements. overriding function Is_Consistent_With (Self : not null access constant UML_Communication_Path_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two RedefinableElements -- in a context in which redefinition is possible, whether redefinition -- would be logically consistent. By default, this is false; this -- operation must be overridden for subclasses of RedefinableElement to -- define the consistency conditions. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Communication_Path_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding procedure Enter_Element (Self : not null access constant UML_Communication_Path_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Communication_Path_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Communication_Path_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Communication_Paths;
charlie5/lace
Ada
3,106
adb
with freetype.Face, freeType_C.Binding; package body freetype.charMap is use freeType_C; ----------- -- Utility -- function to_characterCode (From : in Character) return characterCode is begin return Character'Pos (From) + 1; end to_characterCode; --------- -- Forge -- function to_charMap (parent_Face : access Face.item'Class) return Item is use freetype_c.Binding; use type FT_int; Self : Item; begin Self.ftFace := parent_Face.freetype_Face; Self.Err := 0; if FT_Face_Get_charmap (Self.ftFace) = null then if FT_Face_Get_num_charmaps (Self.ftFace) = 0 then Self.Err := 16#96#; return Self; end if; Self.Err := FT_Set_Charmap (Self.ftFace, FT_Face_Get_charmap_at (Self.ftFace, 0)); end if; Self.ftEncoding := FT_Face_Get_charmap (Self.ftFace).Encoding; for i in characterCode'(1) .. max_Precomputed loop Self.charIndexCache (i) := FT_Get_Char_Index (Self.ftFace, FT_ULong (i - 1)); end loop; return Self; end to_charMap; procedure destruct (Self : in out Item) is begin Self.charMap.clear; end destruct; -------------- -- Attributes -- function Encoding (Self : in Item) return FT_Encoding is begin return Self.ftEncoding; end Encoding; function CharMap (Self : access Item; Encoding : in FT_Encoding) return Boolean is use freeType_C.Binding; use type FT_Encoding, FT_Error; begin if Self.ftEncoding = Encoding then Self.Err := 0; return True; end if; Self.Err := FT_Select_Charmap (Self.ftFace, Encoding); if Self.Err = 0 then Self.ftEncoding := Encoding; Self.charMap.clear; end if; return Self.Err = 0; end CharMap; function GlyphListIndex (Self : in Item; Character : in CharacterCode) return GlyphIndex is begin return Self.charMap.Element (Character); exception when Constraint_Error => return -1; end GlyphListIndex; function FontIndex (Self : in Item; Character : in characterCode) return GlyphIndex is use freeType_C.Binding; begin if Character < max_Precomputed then return GlyphIndex (Self.charIndexCache (Character)); end if; return GlyphIndex (FT_Get_Char_Index (Self.ftFace, Character)); end FontIndex; procedure insertIndex (Self : in out Item; Character : in characterCode; containerIndex : in ada.Containers.Count_type) is begin Self.charMap.insert (Character, GlyphIndex (containerIndex)); end insertIndex; function Error (Self : in Item) return FT_Error is begin return Self.Err; end Error; end freetype.charMap;
faelys/natools
Ada
26,223
adb
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Ada.Calendar.Formatting; with Ada.Calendar.Time_Zones; with Ada.Characters.Handling; with Ada.Containers.Indefinite_Doubly_Linked_Lists; with Ada.Directories; with Ada.Text_IO; with GNAT.Perfect_Hash_Generators; package body Natools.Static_Hash_Maps is package String_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (String); procedure Add_Categorization (Path : in String; Categorization : in Package_Categorization); function File_Name (Package_Name : in String) return String; -- Convert a package name into a file name, the GNAT way function Image (Pos : Natural) return String; -- Trimmed image, for suffix construction function Image (Offset : Ada.Calendar.Time_Zones.Time_Offset) return String; procedure Put_Categorization (Output : in Ada.Text_IO.File_Type; Categorization : in Package_Categorization; Name : in String := ""); procedure Write_Map_Body (Map : in Map_Description; Prefix : in String; File : in Ada.Text_IO.File_Type); procedure Write_Map_Hash_Package (Map : in Map_Description); procedure Write_Map_Private_Spec (Map : in Map_Description; Prefix : in String; File : in Ada.Text_IO.File_Type); procedure Write_Map_Public_Spec (Map : in Map_Description; File : in Ada.Text_IO.File_Type); procedure Write_Map_With (Map : in Map_Description; File : in Ada.Text_IO.File_Type); -- Output fragments relevant for the given map procedure Write_Package (Pkg : in Map_Package; Spec_File, Body_File : in Ada.Text_IO.File_Type; Test : in Boolean := False); -- Output a complete map package procedure Write_Test (Map : in Map_Description; Prefix : in String; File : in Ada.Text_IO.File_Type); -- Output test loop for the hash function ------------------------ -- Package Generators -- ------------------------ procedure Add_Categorization (Path : in String; Categorization : in Package_Categorization) is File : Ada.Text_IO.File_Type; Matches : Natural := 0; Contents : String_Lists.List; begin if Categorization = Default_Categorization then return; end if; Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Path); while not Ada.Text_IO.End_Of_File (File) loop Contents.Append (Ada.Text_IO.Get_Line (File)); end loop; Ada.Text_IO.Close (File); Ada.Text_IO.Open (File, Ada.Text_IO.Out_File, Path); for Line of Contents loop Ada.Text_IO.Put_Line (File, Line); if Line'Length >= 8 and then Line (Line'First .. Line'First + 7) = "package " and then Line (Line'Last - 2 .. Line'Last) = " is" then Matches := Matches + 1; Put_Categorization (File, Categorization); end if; end loop; Ada.Text_IO.Close (File); pragma Assert (Matches = 1); end Add_Categorization; function File_Name (Package_Name : in String) return String is Result : String := Ada.Characters.Handling.To_Lower (Package_Name); begin for I in Result'Range loop if Result (I) = '.' then Result (I) := '-'; end if; end loop; return Result; end File_Name; function Image (Pos : Natural) return String is Result : constant String := Natural'Image (Pos); begin pragma Assert (Result (Result'First) = ' '); return Result (Result'First + 1 .. Result'Last); end Image; function Image (Offset : Ada.Calendar.Time_Zones.Time_Offset) return String is use type Ada.Calendar.Time_Zones.Time_Offset; H : constant Natural := Natural (abs Offset) / 60; M : constant Natural := Natural (abs Offset) mod 60; Sign : Character := '+'; begin if Offset < 0 then Sign := '-'; end if; return String'(1 => Sign, 2 => Character'Val (48 + H / 10), 3 => Character'Val (48 + H mod 10), 4 => Character'Val (48 + M / 10), 5 => Character'Val (48 + M mod 10)); end Image; procedure Put_Categorization (Output : in Ada.Text_IO.File_Type; Categorization : in Package_Categorization; Name : in String := "") is function Prefix return String; function Suffix return String; function Prefix return String is begin if Name = "" then return " pragma "; else return "pragma "; end if; end Prefix; function Suffix return String is begin if Name = "" then return ""; else return " (" & Name & ')'; end if; end Suffix; begin case Categorization is when Pure => Ada.Text_IO.Put_Line (Output, Prefix & "Pure" & Suffix & ';'); when Preelaborate => Ada.Text_IO.Put_Line (Output, Prefix & "Preelaborate" & Suffix & ';'); when Default_Categorization => null; end case; end Put_Categorization; procedure Write_Map_Body (Map : in Map_Description; Prefix : in String; File : in Ada.Text_IO.File_Type) is begin if Map.Indefinite then Ada.Text_IO.Put_Line (File, " function " & Prefix & "_Elements (Hash : " & Prefix & "_Hash)"); Ada.Text_IO.Put_Line (File, " return " & To_String (Map.Element_Type) & " is"); Ada.Text_IO.Put_Line (File, " begin"); Ada.Text_IO.Put_Line (File, " case Hash is"); declare Pos : Natural := 0; Cursor : Node_Lists.Cursor := Map.Nodes.First; begin while Node_Lists.Has_Element (Cursor) loop Ada.Text_IO.Put_Line (File, " when " & Image (Pos) & " =>"); Ada.Text_IO.Put_Line (File, " return " & To_String (Node_Lists.Element (Cursor).Name) & ';'); Node_Lists.Next (Cursor); Pos := Pos + 1; end loop; end; Ada.Text_IO.Put_Line (File, " end case;"); Ada.Text_IO.Put_Line (File, " end " & Prefix & "_Elements;"); Ada.Text_IO.New_Line (File); end if; Ada.Text_IO.Put_Line (File, " function " & To_String (Map.Function_Name) & " (Key : String) return " & To_String (Map.Element_Type) & " is"); Ada.Text_IO.Put_Line (File, " N : constant Natural"); Ada.Text_IO.Put_Line (File, " := " & To_String (Map.Hash_Package_Name) & ".Hash (Key);"); Ada.Text_IO.Put_Line (File, " begin"); Ada.Text_IO.Put_Line (File, " if " & Prefix & "_Keys (N).all = Key then"); Ada.Text_IO.Put_Line (File, " return " & Prefix & "_Elements (N);"); Ada.Text_IO.Put_Line (File, " else"); if To_String (Map.Not_Found) /= "" then Ada.Text_IO.Put_Line (File, " return " & To_String (Map.Not_Found) & ';'); else Ada.Text_IO.Put_Line (File, " raise Constraint_Error " & "with ""Key """""" & Key & """""" not in map"";"); end if; Ada.Text_IO.Put_Line (File, " end if;"); Ada.Text_IO.Put_Line (File, " end " & To_String (Map.Function_Name) & ';'); end Write_Map_Body; procedure Write_Map_Hash_Package (Map : in Map_Description) is Seed : Natural := 2; NK : constant Float := Float (Map.Nodes.Length); NV : Natural := Natural (Map.Nodes.Length) * 2 + 1; Cursor : Node_Lists.Cursor := Map.Nodes.First; begin while Node_Lists.Has_Element (Cursor) loop GNAT.Perfect_Hash_Generators.Insert (To_String (Node_Lists.Element (Cursor).Key)); Node_Lists.Next (Cursor); end loop; loop begin GNAT.Perfect_Hash_Generators.Initialize (Seed, Float (NV) / NK); GNAT.Perfect_Hash_Generators.Compute; exit; exception when GNAT.Perfect_Hash_Generators.Too_Many_Tries => null; end; Seed := Seed * NV; begin GNAT.Perfect_Hash_Generators.Initialize (Seed, Float (NV) / NK); GNAT.Perfect_Hash_Generators.Compute; exit; exception when GNAT.Perfect_Hash_Generators.Too_Many_Tries => null; end; NV := NV + 1; Seed := NV; end loop; GNAT.Perfect_Hash_Generators.Produce (To_String (Map.Hash_Package_Name)); GNAT.Perfect_Hash_Generators.Finalize; exception when others => GNAT.Perfect_Hash_Generators.Finalize; raise; end Write_Map_Hash_Package; procedure Write_Map_Private_Spec (Map : in Map_Description; Prefix : in String; File : in Ada.Text_IO.File_Type) is Last : constant Natural := Positive (Map.Nodes.Length) - 1; Pos : Natural; Cursor : Node_Lists.Cursor; begin Pos := 0; Cursor := Map.Nodes.First; while Node_Lists.Has_Element (Cursor) loop Ada.Text_IO.Put_Line (File, " " & Prefix & "_Key_" & Image (Pos) & " : aliased constant String := """ & To_String (Node_Lists.Element (Cursor).Key) & """;"); Pos := Pos + 1; Node_Lists.Next (Cursor); end loop; Ada.Text_IO.Put_Line (File, " " & Prefix & "_Keys : constant array (0 .. " & Image (Last) & ") of access constant String"); Pos := 0; Cursor := Map.Nodes.First; while Node_Lists.Has_Element (Cursor) loop if Pos = 0 then Ada.Text_IO.Put (File, " := ("); else Ada.Text_IO.Put (File, " "); end if; Ada.Text_IO.Put (File, Prefix & "_Key_" & Image (Pos) & "'Access"); if Pos = Last then Ada.Text_IO.Put_Line (File, ");"); else Ada.Text_IO.Put_Line (File, ","); end if; Pos := Pos + 1; Node_Lists.Next (Cursor); end loop; if Map.Indefinite then Ada.Text_IO.Put_Line (File, " subtype " & Prefix & "_Hash is Natural range 0 .. " & Image (Last) & ';'); Ada.Text_IO.Put_Line (File, " function " & Prefix & "_Elements (Hash : " & Prefix & "_Hash)"); Ada.Text_IO.Put_Line (File, " return " & To_String (Map.Element_Type) & ';'); else Ada.Text_IO.Put_Line (File, " " & Prefix & "_Elements : constant array (0 .. " & Image (Last) & ") of " & To_String (Map.Element_Type)); Pos := 0; Cursor := Map.Nodes.First; while Node_Lists.Has_Element (Cursor) loop if Pos = 0 then Ada.Text_IO.Put (File, " := ("); else Ada.Text_IO.Put (File, " "); end if; Ada.Text_IO.Put (File, To_String (Node_Lists.Element (Cursor).Name)); if Pos = Last then Ada.Text_IO.Put_Line (File, ");"); else Ada.Text_IO.Put_Line (File, ","); end if; Pos := Pos + 1; Node_Lists.Next (Cursor); end loop; end if; end Write_Map_Private_Spec; procedure Write_Map_Public_Spec (Map : in Map_Description; File : in Ada.Text_IO.File_Type) is begin Ada.Text_IO.Put_Line (File, " function " & To_String (Map.Function_Name) & " (Key : String) return " & To_String (Map.Element_Type) & ';'); end Write_Map_Public_Spec; procedure Write_Map_With (Map : in Map_Description; File : in Ada.Text_IO.File_Type) is begin Ada.Text_IO.Put_Line (File, "with " & To_String (Map.Hash_Package_Name) & ';'); end Write_Map_With; procedure Write_Package (Pkg : in Map_Package; Spec_File, Body_File : in Ada.Text_IO.File_Type; Test : in Boolean := False) is type Stage is (Hash_Package, Public_Spec, Private_Spec, Body_With, Body_Contents, Test_Body); Current_Stage : Stage; Map_Pos : Natural := 0; procedure Process (Element : in Map_Description); procedure Query (Cursor : in Map_Lists.Cursor); procedure Process (Element : in Map_Description) is Prefix : constant String := "Map_" & Image (Map_Pos + 1); begin case Current_Stage is when Hash_Package => Write_Map_Hash_Package (Element); Add_Categorization (Ada.Directories.Compose ("", File_Name (To_String (Element.Hash_Package_Name)), "ads"), Pkg.Categorization); when Public_Spec => Write_Map_Public_Spec (Element, Spec_File); when Private_Spec => Ada.Text_IO.New_Line (Spec_File); Write_Map_Private_Spec (Element, Prefix, Spec_File); when Body_With => Write_Map_With (Element, Body_File); when Body_Contents => Ada.Text_IO.New_Line (Body_File); Write_Map_Body (Element, Prefix, Body_File); Ada.Text_IO.New_Line (Body_File); when Test_Body => Write_Test (Element, Prefix, Body_File); Ada.Text_IO.New_Line (Body_File); end case; Map_Pos := Map_Pos + 1; end Process; procedure Query (Cursor : in Map_Lists.Cursor) is begin Map_Lists.Query_Element (Cursor, Process'Access); end Query; begin Current_Stage := Hash_Package; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Write_Headers : declare Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; Offset : constant Ada.Calendar.Time_Zones.Time_Offset := Ada.Calendar.Time_Zones.UTC_Time_Offset (Now); Header : constant String := "-- Generated at " & Ada.Calendar.Formatting.Image (Now, False, Offset) & ' ' & Image (Offset) & " by Natools.Static_Hash_Maps"; Description : constant String := To_String (Pkg.Description); begin Ada.Text_IO.Put_Line (Spec_File, Header); Ada.Text_IO.Put_Line (Body_File, Header); if Description'Length > 0 then Ada.Text_IO.Put_Line (Spec_File, "-- " & Description); Ada.Text_IO.Put_Line (Body_File, "-- " & Description); end if; Ada.Text_IO.New_Line (Spec_File); Ada.Text_IO.New_Line (Body_File); end Write_Headers; if Test then declare Name : constant String := To_String (Pkg.Name) & '.' & To_String (Pkg.Test_Child); begin Ada.Text_IO.Put_Line (Spec_File, "function " & Name); Ada.Text_IO.Put_Line (Spec_File, " return Boolean;"); Put_Categorization (Spec_File, Pkg.Categorization, Name); Current_Stage := Body_With; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Ada.Text_IO.Put_Line (Body_File, "function " & Name); Ada.Text_IO.Put_Line (Body_File, " return Boolean is"); Ada.Text_IO.Put_Line (Body_File, "begin"); Current_Stage := Test_Body; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Ada.Text_IO.Put_Line (Body_File, " return True;"); Ada.Text_IO.Put_Line (Body_File, "end " & Name & ';'); end; return; end if; if Pkg.Priv then Ada.Text_IO.Put (Spec_File, "private "); end if; Ada.Text_IO.Put_Line (Spec_File, "package " & To_String (Pkg.Name) & " is"); Put_Categorization (Spec_File, Pkg.Categorization); Ada.Text_IO.New_Line (Spec_File); declare Declarations : constant String := To_String (Pkg.Extra_Declarations); begin if Declarations'Length > 0 then Ada.Text_IO.Put_Line (Spec_File, Declarations); Ada.Text_IO.New_Line (Spec_File); end if; end; Current_Stage := Public_Spec; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Ada.Text_IO.New_Line (Spec_File); Ada.Text_IO.Put_Line (Spec_File, "private"); Current_Stage := Private_Spec; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Ada.Text_IO.New_Line (Spec_File); Ada.Text_IO.Put_Line (Spec_File, "end " & To_String (Pkg.Name) & ';'); Current_Stage := Body_With; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Ada.Text_IO.New_Line (Body_File); Ada.Text_IO.Put_Line (Body_File, "package body " & To_String (Pkg.Name) & " is"); Current_Stage := Body_Contents; Map_Pos := 0; Pkg.Maps.Iterate (Query'Access); Ada.Text_IO.Put_Line (Body_File, "end " & To_String (Pkg.Name) & ';'); end Write_Package; procedure Write_Test (Map : in Map_Description; Prefix : in String; File : in Ada.Text_IO.File_Type) is Key_Array_Name : constant String := Prefix & "_Keys"; begin Ada.Text_IO.Put_Line (File, " for I in " & Key_Array_Name & "'Range loop"); Ada.Text_IO.Put_Line (File, " if " & To_String (Map.Hash_Package_Name) & ".Hash"); Ada.Text_IO.Put_Line (File, " (" & Key_Array_Name & " (I).all) /= I"); Ada.Text_IO.Put_Line (File, " then"); Ada.Text_IO.Put_Line (File, " return False;"); Ada.Text_IO.Put_Line (File, " end if;"); Ada.Text_IO.Put_Line (File, " end loop;"); end Write_Test; ------------------------------- -- Key-Name Pair Constructor -- ------------------------------- function Node (Key, Name : String) return Map_Node is begin return (Key => Hold (Key), Name => Hold (Name)); end Node; --------------------------------- -- Map Description Subprograms -- --------------------------------- procedure Reset (Self : out Map_Description) is begin Self := (Element_Type => Hold (""), Hash_Package_Name => Hold (""), Function_Name => Hold (""), Not_Found => Hold (""), Nodes => Node_Lists.Empty_List, Indefinite => False); end Reset; procedure Insert (Self : in out Map_Description; Key : in String; Element_Name : in String) is begin Self.Nodes.Append (Node (Key, Element_Name)); end Insert; procedure Set_Definite (Self : in out Map_Description) is begin Self.Indefinite := False; end Set_Definite; procedure Set_Element_Type (Self : in out Map_Description; Name : in String) is begin Self.Element_Type := Hold (Name); end Set_Element_Type; procedure Set_Function_Name (Self : in out Map_Description; Name : in String) is begin Self.Function_Name := Hold (Name); end Set_Function_Name; procedure Set_Hash_Package_Name (Self : in out Map_Description; Name : in String) is begin Self.Hash_Package_Name := Hold (Name); end Set_Hash_Package_Name; procedure Set_Indefinite (Self : in out Map_Description; Indefinite : in Boolean := True) is begin Self.Indefinite := Indefinite; end Set_Indefinite; procedure Set_Not_Found (Self : in out Map_Description; Name : in String) is begin Self.Not_Found := Hold (Name); end Set_Not_Found; function Map (Element_Type : String; Nodes : Node_Array; Hash_Package_Name : String := ""; Function_Name : String := "Element"; Not_Found : String := ""; Indefinite : Boolean := False) return Map_Description is Result : Map_Description := (Element_Type => Hold (Element_Type), Hash_Package_Name => Hold (Hash_Package_Name), Function_Name => Hold (Function_Name), Not_Found => Hold (Not_Found), Nodes => Node_Lists.Empty_List, Indefinite => Indefinite); begin for I in Nodes'Range loop Result.Nodes.Append (Nodes (I)); end loop; return Result; end Map; ---------------------------- -- Map Package Primitives -- ---------------------------- procedure Open (Self : in out Map_Package; Name : in String; Private_Child : in Boolean := False) is begin Self.Name := Hold (Name); Self.Description := Hold (""); Self.Priv := Private_Child; Self.Maps.Clear; end Open; procedure Close (Self : in out Map_Package) is begin Self.Name := Hold (""); Self.Maps.Clear; end Close; procedure Set_Categorization (Self : in out Map_Package; Categorization : in Package_Categorization) is begin Self.Categorization := Categorization; end Set_Categorization; procedure Set_Description (Self : in out Map_Package; Description : in String) is begin Self.Description := Hold (Description); end Set_Description; procedure Set_Extra_Declarations (Self : in out Map_Package; Declarations : in String) is begin Self.Extra_Declarations := Hold (Declarations); end Set_Extra_Declarations; procedure Set_Private_Child (Self : in out Map_Package; Private_Child : in Boolean := True) is begin Self.Priv := Private_Child; end Set_Private_Child; procedure Set_Test_Child (Self : in out Map_Package; Test_Child : in String) is begin Self.Test_Child := Hold (Test_Child); end Set_Test_Child; procedure Add_Map (Self : in out Map_Package; Map : in Map_Description) is begin if To_String (Self.Name) = "" then raise Constraint_Error with "Add_Map on non-opened static hash map package"; end if; Self.Maps.Append (Map); end Add_Map; procedure Commit (Self : in out Map_Package) is begin if To_String (Self.Name) = "" then raise Constraint_Error with "Commit on static hash map package without a name"; end if; if Self.Maps.Is_Empty then raise Constraint_Error with "Commit on static hash map package without any map"; end if; declare Package_Name : constant String := To_String (Self.Name); Base_Name : constant String := File_Name (Package_Name); Spec_File, Body_File : Ada.Text_IO.File_Type; begin Ada.Text_IO.Create (File => Spec_File, Name => Ada.Directories.Compose ("", Base_Name, "ads")); Ada.Text_IO.Create (File => Body_File, Name => Ada.Directories.Compose ("", Base_Name, "adb")); Write_Package (Self, Spec_File, Body_File); Ada.Text_IO.Close (Spec_File); Ada.Text_IO.Close (Body_File); end; if To_String (Self.Test_Child) /= "" then declare Unit_Name : constant String := To_String (Self.Name) & '.' & To_String (Self.Test_Child); Base_Name : constant String := File_Name (Unit_Name); Spec_File, Body_File : Ada.Text_IO.File_Type; begin Ada.Text_IO.Create (File => Spec_File, Name => Ada.Directories.Compose ("", Base_Name, "ads")); Ada.Text_IO.Create (File => Body_File, Name => Ada.Directories.Compose ("", Base_Name, "adb")); Write_Package (Self, Spec_File, Body_File, Test => True); Ada.Text_IO.Close (Spec_File); Ada.Text_IO.Close (Body_File); end; end if; end Commit; ------------------------- -- Combined Procedures -- ------------------------- procedure Generate_Package (Name : in String; Single_Map : in Map_Description; Private_Child : in Boolean := False) is Object : Map_Package; begin Open (Object, Name, Private_Child); Add_Map (Object, Single_Map); Commit (Object); end Generate_Package; procedure Generate_Package (Name : in String; Maps : in Map_Array; Private_Child : in Boolean := False) is Object : Map_Package; begin Open (Object, Name, Private_Child); for I in Maps'Range loop Add_Map (Object, Maps (I)); end loop; Commit (Object); end Generate_Package; end Natools.Static_Hash_Maps;
Spohn/LegendOfZelba
Ada
5,427
adb
with ada.integer_text_io; use ada.integer_text_io; with ada.text_io; use ada.text_io; package body NPC_PC is ------------------------------- -- Name: Jon Spohn -- David Rogina -- Hero and Enemy stats Package ------------------------------- -------------------------------------- --Procedures and functions to set and --get Hero's stats -------------------------------------- --Set X,Y coordinates of Hero procedure SetHeroCoord( X: in integer; Y: in integer; Hero : in out HeroClass) is begin Hero.HeroX := X; Hero.HeroY := y; end SetHeroCoord; ---------------------------------------------------------------------- --Set Health of Hero procedure SetHeroHealth( H : in integer; Hero : in out HeroClass) is begin Hero.Health := Hero.Health - H; end SetHeroHealth; ---------------------------------------------------------------------- --Set Armor of Hero procedure SetHeroArmor( A : in integer; Hero : in out HeroClass) is begin Hero.Armor := Hero.Armor + A; end SetHeroArmor; ---------------------------------------------------------------------- --Set strength of hero procedure SetHeroStrength( S : in integer; Hero : in out HeroClass) is begin Hero.Strength := Hero.Strength + S; end SetHeroStrength; ---------------------------------------------------------------------- --Get X coordinate of Hero function GetHeroX(Hero : in HeroClass) return integer is begin return Hero.HeroX; end GetHeroX; ---------------------------------------------------------------------- --Get Y coordinate of Hero function GetHeroY(Hero : in HeroClass) return integer is begin return Hero.HeroY; end GetHeroY; ---------------------------------------------------------------------- --Get the health of the Hero function GetHeroH(Hero : in HeroClass) return integer is begin return Hero.Health; end GetHeroH; ---------------------------------------------------------------------- --Get armor for Hero function GetHeroA(Hero : in HeroClass) return integer is begin return Hero.Armor; end GetHeroA; ---------------------------------------------------------------------- --Get strength of Hero function GetHeroS(Hero : in HeroClass) return integer is begin return Hero.Strength; end GetHeroS; ---------------------------------------------------------------------- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -------------------------------------- --Procedures and functions to set and --get Enemy's stats -------------------------------------- --Set Enemy's coordinates on map procedure SetEnemyCoord( X: in integer; Y: in integer; Enemy : in out EnemyClass) is begin Enemy.EnemyX := X; Enemy.EnemyY := y; end SetEnemyCoord; ---------------------------------------------------------------------- --Set Enemy's health procedure SetEnemyHealth( H : in integer; Enemy : in out EnemyClass) is begin Enemy.Health := Enemy.Health - H; end SetEnemyHealth; ---------------------------------------------------------------------- --Set Enemy's armor procedure SetEnemyArmor( A : in integer; Enemy : in out EnemyClass) is begin Enemy.Armor := Enemy.Armor + A; end SetEnemyArmor; ---------------------------------------------------------------------- --Set Enemy's Strength procedure SetEnemyStrength( S : in integer; Enemy : in out EnemyClass) is begin Enemy.Strength := Enemy.Strength + S; end SetEnemyStrength; ---------------------------------------------------------------------- --Get Enemy's X coordinate function GetEnemyX(Enemy : in EnemyClass) return integer is begin return Enemy.EnemyX; end GetEnemyX; ---------------------------------------------------------------------- --Get Enemy's Y coordinate function GetEnemyY(Enemy : in EnemyClass) return integer is begin return Enemy.EnemyY; end GetEnemyY; ---------------------------------------------------------------------- --Get Enemy's Health function GetEnemyH(Enemy : in EnemyClass) return integer is begin return Enemy.Health; end GetEnemyH; ---------------------------------------------------------------------- --Get Enemy's Armor function GetEnemyA(Enemy : in EnemyClass) return integer is begin return Enemy.Armor; end GetEnemyA; ---------------------------------------------------------------------- --Get Enemy's Strength function GetEnemyS(Enemy : in EnemyClass) return integer is begin return Enemy.Strength; end GetEnemyS; ---------------------------------------------------------------------- --View Stats of Hero procedure viewstats(Hero: in HeroClass) is test: character; begin new_line; put("Your Current Health is: "); put(item=>Hero.Health, width=> 1); new_line; put("Your Current Armor is: "); put(item=>Hero.Armor, width=> 1); new_line; put("Your Current Strength is: "); put(item=>Hero.Strength, width=> 1); new_line; put("Enter in any key to continue"); get(test); end viewstats; end NPC_PC;
zhmu/ananas
Ada
4,904
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . A D D R E S S _ O P E R A T I O N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides arithmetic and logical operations on type Address. -- It is intended for use by other packages in the System hierarchy. For -- applications requiring this capability, see System.Storage_Elements or -- the operations introduced in System.Aux_DEC; -- The reason we need this package is that arithmetic operations may not -- be available in the case where type Address is non-private and the -- operations have been made abstract in the spec of System (to avoid -- inappropriate use by applications programs). In addition, the logical -- operations may not be available if type Address is a signed integer. package System.Address_Operations is pragma Pure; -- The semantics of the arithmetic operations are those that apply to -- a modular type with the same length as Address, i.e. they provide -- twos complement wrap around arithmetic treating the address value -- as an unsigned value, with no overflow checking. -- Note that we do not use the infix names for these operations to -- avoid problems with ambiguities coming from declarations in package -- Standard (which may or may not be visible depending on the exact -- form of the declaration of type System.Address). -- For addition, subtraction, and multiplication, the effect of overflow -- is 2's complement wrapping (as though the type Address were unsigned). -- For division and modulus operations, the caller is responsible for -- ensuring that the Right argument is non-zero, and the effect of the -- call is not specified if a zero argument is passed. function AddA (Left, Right : Address) return Address; function SubA (Left, Right : Address) return Address; function MulA (Left, Right : Address) return Address; function DivA (Left, Right : Address) return Address; function ModA (Left, Right : Address) return Address; -- The semantics of the logical operations are those that apply to -- a modular type with the same length as Address, i.e. they provide -- bit-wise operations on all bits of the value (including the sign -- bit if Address is a signed integer type). function AndA (Left, Right : Address) return Address; function OrA (Left, Right : Address) return Address; pragma Inline_Always (AddA); pragma Inline_Always (SubA); pragma Inline_Always (MulA); pragma Inline_Always (DivA); pragma Inline_Always (ModA); pragma Inline_Always (AndA); pragma Inline_Always (OrA); end System.Address_Operations;
stcarrez/ada-wiki
Ada
18,577
adb
----------------------------------------------------------------------- -- Render Tests - Unit tests for AWA Wiki rendering -- Copyright (C) 2013, 2016, 2020, 2021, 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 Ada.Text_IO; with Ada.Wide_Wide_Text_IO; with Ada.Directories; with Util.Measures; with Wiki.Strings; with Wiki.Render.Wiki; with Wiki.Render.Html; with Wiki.Render.Text; with Wiki.Filters.Html; with Wiki.Filters.TOC; with Wiki.Filters.Autolink; with Wiki.Filters.Variables; with Wiki.Filters.Collectors; with Wiki.Plugins.Templates; with Wiki.Plugins.Conditions; with Wiki.Plugins.Variables; with Wiki.Streams.Text_IO; with Wiki.Streams.Html.Text_IO; with Wiki.Documents; with Wiki.Parsers; package body Wiki.Tests is use Ada.Strings.Unbounded; -- ------------------------------ -- Test rendering a wiki text in HTML or text. -- ------------------------------ procedure Test_Render (T : in out Test) is use Ada.Directories; Result_File : constant String := To_String (T.Result); Dir : constant String := Containing_Directory (Result_File); Doc : Wiki.Documents.Document; Engine : Wiki.Parsers.Parser; Toc_Filter : aliased Wiki.Filters.TOC.TOC_Filter; Html_Filter : aliased Wiki.Filters.Html.Html_Filter_Type; Var_Filter : aliased Wiki.Filters.Variables.Variable_Filter; Auto_Filter : aliased Wiki.Filters.Autolink.Autolink_Filter; Words : aliased Wiki.Filters.Collectors.Word_Collector_Type; Links : aliased Wiki.Filters.Collectors.Link_Collector_Type; Images : aliased Wiki.Filters.Collectors.Image_Collector_Type; Template : aliased Wiki.Plugins.Templates.File_Template_Plugin; Condition : aliased Wiki.Plugins.Conditions.Condition_Plugin; Variables : aliased Wiki.Plugins.Variables.Variable_Plugin; List_Vars : aliased Wiki.Plugins.Variables.List_Variable_Plugin; Input : aliased Wiki.Streams.Text_IO.File_Input_Stream; Output : aliased Wiki.Streams.Html.Text_IO.Html_Output_Stream; type Test_Factory is new Wiki.Plugins.Plugin_Factory with null record; -- Find a plugin knowing its name. overriding function Find (Factory : in Test_Factory; Name : in String) return Wiki.Plugins.Wiki_Plugin_Access; overriding function Find (Factory : in Test_Factory; Name : in String) return Wiki.Plugins.Wiki_Plugin_Access is pragma Unreferenced (Factory); begin if Name in "if" | "else" | "elsif" | "end" then return Condition'Unchecked_Access; elsif Name = "set" then return Variables'Unchecked_Access; elsif Name = "list" then return List_Vars'Unchecked_Access; else return Template.Find (Name); end if; end Find; Local_Factory : aliased Test_Factory; Has_Collector : constant Boolean := Length (T.Collect) > 0; begin if not Exists (Dir) then Create_Path (Dir); end if; Input.Open (Path => To_String (T.File), Form => "WCEM=8"); Output.Create (Result_File, "WCEM=8"); Template.Set_Template_Path (Containing_Directory (To_String (T.File))); Condition.Append ("public", ""); Condition.Append ("user", "admin"); declare Time : Util.Measures.Stamp; begin Engine.Set_Syntax (T.Source); Engine.Set_Plugin_Factory (Local_Factory'Unchecked_Access); if Has_Collector then Engine.Add_Filter (Words'Unchecked_Access); Engine.Add_Filter (Links'Unchecked_Access); Engine.Add_Filter (Images'Unchecked_Access); end if; Engine.Add_Filter (Toc_Filter'Unchecked_Access); Engine.Add_Filter (Auto_Filter'Unchecked_Access); Engine.Add_Filter (Html_Filter'Unchecked_Access); Engine.Add_Filter (Var_Filter'Unchecked_Access); Engine.Parse (Input'Unchecked_Access, Doc); Var_Filter.Add_Variable (String '("file"), Wiki.Strings.To_WString (To_String (T.Name))); Util.Measures.Report (Time, "Parse " & To_String (T.Name)); if T.Source = Wiki.SYNTAX_HTML or else T.Is_Cvt then declare Renderer : aliased Wiki.Render.Wiki.Wiki_Renderer; begin Renderer.Set_Output_Stream (Output'Unchecked_Access, T.Format); Renderer.Render (Doc); Output.Close; Util.Measures.Report (Time, "Render Wiki " & To_String (T.Name)); end; elsif T.Is_Html then declare Renderer : aliased Wiki.Render.Html.Html_Renderer; begin Renderer.Set_Output_Stream (Output'Unchecked_Access); Renderer.Set_Render_TOC (True); Renderer.Set_No_Newline (False); Renderer.Render (Doc); Output.Close; Util.Measures.Report (Time, "Render HTML " & To_String (T.Name)); end; else declare Renderer : aliased Wiki.Render.Text.Text_Renderer; begin Renderer.Set_Output_Stream (Output'Unchecked_Access); Renderer.Render (Doc); Output.Close; Util.Measures.Report (Time, "Render Text " & To_String (T.Name)); end; end if; end; Input.Close; Util.Tests.Assert_Equal_Files (T => T, Expect => To_String (T.Expect), Test => Result_File, Message => "Render"); if Has_Collector then declare procedure Print (Pos : in Wiki.Filters.Collectors.Cursor); Path : constant String := To_String (T.Collect); Dir : constant String := Containing_Directory (Path); File : Ada.Wide_Wide_Text_IO.File_Type; procedure Print (Pos : in Wiki.Filters.Collectors.Cursor) is use Wiki.Filters.Collectors; Word : constant Wiki.Strings.WString := WString_Maps.Key (Pos); Count : constant Natural := WString_Maps.Element (Pos); begin Ada.Wide_Wide_Text_IO.Put (File, Word); Ada.Wide_Wide_Text_IO.Put_Line (File, Natural'Wide_Wide_Image (Count)); end Print; begin if not Exists (Dir) then Create_Path (Dir); end if; Ada.Wide_Wide_Text_IO.Create (File, Ada.Wide_Wide_Text_IO.Out_File, Path); Ada.Wide_Wide_Text_IO.Put_Line (File, "== Words =="); Words.Iterate (Print'Access); Ada.Wide_Wide_Text_IO.Put_Line (File, "== Links =="); Links.Iterate (Print'Access); Ada.Wide_Wide_Text_IO.Put_Line (File, "== Images =="); Images.Iterate (Print'Access); Ada.Wide_Wide_Text_IO.Close (File); Util.Tests.Assert_Equal_Files (T => T, Expect => To_String (T.Expect_Collect), Test => Path, Message => "Collect"); end; end if; end Test_Render; -- ------------------------------ -- Test case name -- ------------------------------ overriding function Name (T : in Test) return Util.Tests.Message_String is begin if T.Source = Wiki.SYNTAX_HTML then return Util.Tests.Format ("Test IMPORT " & To_String (T.Name)); elsif T.Is_Html then return Util.Tests.Format ("Test HTML " & To_String (T.Name)); else return Util.Tests.Format ("Test TEXT " & To_String (T.Name)); end if; end Name; -- ------------------------------ -- Perform the test. -- ------------------------------ overriding procedure Run_Test (T : in out Test) is begin T.Test_Render; end Run_Test; procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is use Ada.Directories; procedure Add_Import_Tests; procedure Add_Wiki_Tests; procedure Add_Convert_Tests; function Create_Test (Name : in String; Path : in String; Format : in Wiki.Wiki_Syntax; Prefix : in String; Collect : in String; Is_Html : in Boolean) return Test_Case_Access; Result_Dir : constant String := ""; Expect_Dir : constant String := "regtests/expect"; Expect_Path : constant String := Util.Tests.Get_Path (Expect_Dir); Result_Path : constant String := Util.Tests.Get_Test_Path (Result_Dir); Search : Search_Type; Filter : constant Filter_Type := (others => True); Ent : Directory_Entry_Type; function Create_Test (Name : in String; Path : in String; Format : in Wiki.Wiki_Syntax; Prefix : in String; Collect : in String; Is_Html : in Boolean) return Test_Case_Access is Tst : Test_Case_Access; begin Tst := new Test; Tst.Is_Html := Is_Html; Tst.Name := To_Unbounded_String (Name); Tst.File := To_Unbounded_String (Path); Tst.Expect := To_Unbounded_String (Expect_Path & Prefix & Name); Tst.Result := To_Unbounded_String (Result_Path & Prefix & Name); if Collect'Length > 0 then Tst.Collect := To_Unbounded_String (Result_Path & Collect & Name); Tst.Expect_Collect := To_Unbounded_String (Expect_Path & Collect & Name); end if; Tst.Format := Format; Tst.Source := Format; return Tst; end Create_Test; procedure Add_Wiki_Tests is Dir : constant String := "regtests/files/wiki"; Path : constant String := Util.Tests.Get_Path (Dir); begin if Kind (Path) /= Directory then Ada.Text_IO.Put_Line ("Cannot read test directory: " & Path); end if; Start_Search (Search, Directory => Path, Pattern => "*.*", Filter => Filter); while More_Entries (Search) loop Get_Next_Entry (Search, Ent); declare Simple : constant String := Simple_Name (Ent); Ext : constant String := Ada.Directories.Extension (Simple); Tst : Test_Case_Access; Format : Wiki.Wiki_Syntax; begin if Simple /= "." and then Simple /= ".." and then Simple /= ".svn" and then Simple (Simple'Last) /= '~' then if Ext = "wiki" then Format := Wiki.SYNTAX_GOOGLE; elsif Ext = "dotclear" then Format := Wiki.SYNTAX_DOTCLEAR; elsif Ext = "creole" then Format := Wiki.SYNTAX_CREOLE; elsif Ext = "phpbb" then Format := Wiki.SYNTAX_PHPBB; elsif Ext = "mediawiki" then Format := Wiki.SYNTAX_MEDIA_WIKI; elsif Ext = "markdown" then Format := Wiki.SYNTAX_MARKDOWN; elsif Ext = "textile" then Format := Wiki.SYNTAX_TEXTILE; else Format := Wiki.SYNTAX_MARKDOWN; end if; Tst := Create_Test (Simple, Path & "/" & Simple, Format, "/wiki-html/", "/wiki-collect/", True); Suite.Add_Test (Tst.all'Access); Tst := Create_Test (Simple, Path & "/" & Simple, Format, "/wiki-txt/", "", False); Suite.Add_Test (Tst.all'Access); end if; end; end loop; end Add_Wiki_Tests; procedure Add_Import_Tests is Dir : constant String := "regtests/files/html"; Path : constant String := Util.Tests.Get_Path (Dir); begin if Kind (Path) /= Directory then Ada.Text_IO.Put_Line ("Cannot read test directory: " & Path); end if; Start_Search (Search, Directory => Path, Pattern => "*.*", Filter => Filter); while More_Entries (Search) loop Get_Next_Entry (Search, Ent); declare Simple : constant String := Simple_Name (Ent); Name : constant String := Base_Name (Simple); Tst : Test_Case_Access; begin if Simple /= "." and then Simple /= ".." and then Simple /= ".svn" and then Simple (Simple'Last) /= '~' then for Syntax in Wiki.Wiki_Syntax'Range loop case Syntax is when Wiki.SYNTAX_CREOLE => Tst := Create_Test (Name & ".creole", Path & "/" & Simple, Syntax, "/wiki-import/", "", True); when Wiki.SYNTAX_DOTCLEAR => Tst := Create_Test (Name & ".dotclear", Path & "/" & Simple, Syntax, "/wiki-import/", "", True); when Wiki.SYNTAX_MEDIA_WIKI => Tst := Create_Test (Name & ".mediawiki", Path & "/" & Simple, Syntax, "/wiki-import/", "", True); when Wiki.SYNTAX_MARKDOWN => Tst := Create_Test (Name & ".markdown", Path & "/" & Simple, Syntax, "/wiki-import/", "", True); when others => Tst := null; end case; if Tst /= null then Tst.Source := Wiki.SYNTAX_HTML; Suite.Add_Test (Tst.all'Access); end if; end loop; end if; end; end loop; end Add_Import_Tests; procedure Add_Convert_Tests is Dir : constant String := "regtests/files/convert"; Path : constant String := Util.Tests.Get_Path (Dir); begin if Kind (Path) /= Directory then Ada.Text_IO.Put_Line ("Cannot read test directory: " & Path); end if; Start_Search (Search, Directory => Path, Pattern => "*.*", Filter => Filter); while More_Entries (Search) loop Get_Next_Entry (Search, Ent); declare Simple : constant String := Simple_Name (Ent); Ext : constant String := Ada.Directories.Extension (Simple); Name : constant String := Base_Name (Simple); Tst : Test_Case_Access; Format : Wiki.Wiki_Syntax; begin if Simple /= "." and then Simple /= ".." and then Simple /= ".svn" and then Simple (Simple'Last) /= '~' then if Ext = "wiki" then Format := Wiki.SYNTAX_GOOGLE; elsif Ext = "dotclear" then Format := Wiki.SYNTAX_DOTCLEAR; elsif Ext = "creole" then Format := Wiki.SYNTAX_CREOLE; elsif Ext = "phpbb" then Format := Wiki.SYNTAX_PHPBB; elsif Ext = "mediawiki" then Format := Wiki.SYNTAX_MEDIA_WIKI; elsif Ext = "markdown" then Format := Wiki.SYNTAX_MARKDOWN; else Format := Wiki.SYNTAX_MARKDOWN; end if; for Syntax in Wiki.Wiki_Syntax'Range loop case Syntax is when Wiki.SYNTAX_CREOLE => Tst := Create_Test (Name & ".creole", Path & "/" & Simple, Syntax, "/wiki-convert/", "", True); when Wiki.SYNTAX_DOTCLEAR => Tst := Create_Test (Name & ".dotclear", Path & "/" & Simple, Syntax, "/wiki-convert/", "", True); when Wiki.SYNTAX_MEDIA_WIKI => Tst := Create_Test (Name & ".mediawiki", Path & "/" & Simple, Syntax, "/wiki-convert/", "", True); when Wiki.SYNTAX_MARKDOWN => Tst := Create_Test (Name & ".markdown", Path & "/" & Simple, Syntax, "/wiki-convert/", "", True); when Wiki.SYNTAX_TEXTILE => Tst := Create_Test (Name & ".textile", Path & "/" & Simple, Syntax, "/wiki-convert/", "", True); when others => Tst := null; end case; if Tst /= null then Tst.Is_Cvt := True; Tst.Source := Format; Suite.Add_Test (Tst.all'Access); end if; end loop; end if; end; end loop; end Add_Convert_Tests; begin Add_Wiki_Tests; Add_Import_Tests; Add_Convert_Tests; end Add_Tests; end Wiki.Tests;
reznikmm/gela
Ada
2,859
ads
-- This package provides Compilation_Unit_Factory interface and its methods. with Gela.Compilation_Units; with Gela.Elements.Compilation_Unit_Bodies; with Gela.Elements.Compilation_Unit_Declarations; with Gela.Elements.Subunits; with Gela.Lexical_Types; package Gela.Compilation_Unit_Factories is pragma Preelaborate; type Compilation_Unit_Factory is limited interface; -- This constructor object to create compilation units type Compilation_Unit_Factory_Access is access all Compilation_Unit_Factory'Class; for Compilation_Unit_Factory_Access'Storage_Size use 0; not overriding function Create_Library_Unit_Declaration (Self : in out Compilation_Unit_Factory; Parent : Gela.Compilation_Units.Library_Package_Declaration_Access; Name : Gela.Lexical_Types.Symbol; Node : Gela.Elements.Compilation_Unit_Declarations. Compilation_Unit_Declaration_Access) return Gela.Compilation_Units.Library_Unit_Declaration_Access is abstract; -- Create library unit declaration with given Name and Parent. -- Parent is null for Standard package only. not overriding function Create_Subprogram_Without_Declaration (Self : in out Compilation_Unit_Factory; Parent : Gela.Compilation_Units.Library_Package_Declaration_Access; Name : Gela.Lexical_Types.Symbol; Node : Gela.Elements.Compilation_Unit_Bodies. Compilation_Unit_Body_Access) return Gela.Compilation_Units.Library_Unit_Body_Access is abstract; -- Create library unit body without declaration with given Name/Parent. -- Parent is null for Standard package only. not overriding function Create_Library_Unit_Body (Self : in out Compilation_Unit_Factory; Declaration : Gela.Compilation_Units.Library_Unit_Declaration_Access; Name : Gela.Lexical_Types.Symbol; Node : Gela.Elements.Compilation_Unit_Bodies. Compilation_Unit_Body_Access) return Gela.Compilation_Units.Library_Unit_Body_Access is abstract; -- Create library unit body with Declaration and given Name. not overriding function Create_Subunit (Self : in out Compilation_Unit_Factory; Parent : Gela.Compilation_Units.Library_Unit_Body_Access; Name : Gela.Lexical_Types.Symbol; Node : Gela.Elements.Subunits.Subunit_Access) return Gela.Compilation_Units.Subunit_Access is abstract; -- Create subunit of Parent body library unit. not overriding function Create_Subunit (Self : in out Compilation_Unit_Factory; Parent : Gela.Compilation_Units.Subunit_Access; Name : Gela.Lexical_Types.Symbol; Node : Gela.Elements.Subunits.Subunit_Access) return Gela.Compilation_Units.Subunit_Access is abstract; -- Create subunit of Parent subunit. end Gela.Compilation_Unit_Factories;
DrenfongWong/tkm-rpc
Ada
1,038
ads
with Tkmrpc.Types; with Tkmrpc.Operations.Ike; package Tkmrpc.Response.Ike.Cc_Check_Ca is Data_Size : constant := 0; Padding_Size : constant := Response.Body_Size - Data_Size; subtype Padding_Range is Natural range 1 .. Padding_Size; subtype Padding_Type is Types.Byte_Sequence (Padding_Range); type Response_Type is record Header : Response.Header_Type; Padding : Padding_Type; end record; for Response_Type use record Header at 0 range 0 .. (Response.Header_Size * 8) - 1; Padding at Response.Header_Size + Data_Size range 0 .. (Padding_Size * 8) - 1; end record; for Response_Type'Size use Response.Response_Size * 8; Null_Response : constant Response_Type := Response_Type' (Header => Response.Header_Type'(Operation => Operations.Ike.Cc_Check_Ca, Result => Results.Invalid_Operation, Request_Id => 0), Padding => Padding_Type'(others => 0)); end Tkmrpc.Response.Ike.Cc_Check_Ca;
Fabien-Chouteau/shoot-n-loot
Ada
358
ads
-- Shoot'n'loot -- Copyright (c) 2020 Fabien Chouteau with GESTE; package Player is procedure Spawn; procedure Move (Pt : GESTE.Pix_Point); function Position return GESTE.Pix_Point; function Is_Alive return Boolean; procedure Update; procedure Jump; procedure Fire; procedure Move_Left; procedure Move_Right; end Player;
sebsgit/textproc
Ada
8,131
adb
with AUnit.Assertions; use AUnit.Assertions; with Ada.Text_IO; with Ada.Strings.Unbounded; with Ada.Containers; with TrainingData; with PixelArray; with MathUtils; with NeuralNet; with NNClassifier; with Timer; with ImageIO; with CSV; use Ada.Containers; use MathUtils.Float_Vec; package body TrainingSetTests is procedure Register_Tests (T: in out TestCase) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, testDataGenerator'Access, "float vec generator"); Register_Routine (T, testTrainInputMNIST'Access, "NN train on MNIST"); Register_Routine (T, testTrainInputImages'Access, "NN train on local image data"); end Register_Tests; function Name(T: TestCase) return Test_String is begin return Format("Training Set Tests"); end Name; procedure testDataGenerator(T : in out Test_Cases.Test_Case'Class) is image: PixelArray.ImagePlane; output: MathUtils.Vector; expectedValues: MathUtils.Vector; begin image.assign(PixelArray.allocate(16, 16)); for x in 0 .. 15 loop for y in 0 .. 15 loop image.set(x, y, PixelArray.Pixel((x + 1) * (y + 1) - 1)); expectedValues.Append(Float(image.get(x, y)) / 255.0); end loop; end loop; output := TrainingData.toDataVector(image); Assert(output.Length = 16 * 16, "data length"); Assert(output = expectedValues, ""); end testDataGenerator; function oneHotEncode(label: Natural; labelCount: Positive) return MathUtils.Vector with Pre => label < labelCount is result: MathUtils.Vector; begin result.Set_Length(Ada.Containers.Count_Type(labelCount)); for x of result loop x := 0.0; end loop; result(label + 1) := 1.0; return result; end oneHotEncode; procedure loadMNistData(input, validation: in out TrainingData.Set) is reader: CSV.Reader := CSV.open("../training_set/mnist_train_small.csv"); trainSetSize: constant Positive := 1350; testSetSize: constant Positive := 250; procedure load(s: in out TrainingData.Set; cnt: in Positive) with Post => s.size >= cnt is i: Positive := 1; vec: MathUtils.Vector; label: Natural; begin while i <= cnt loop vec := reader.next; label := Natural(vec.Element(1)); vec.Delete_First; for v of vec loop v := v / 255.0; end loop; Assert(Positive(vec.Length) = TrainingData.blockArea, "wrong size of input, expected: " & TrainingData.blockArea'Image & ", got: " & vec.Length'Image); s.add(label, vec); i := i + 1; end loop; end load; begin load(input, trainSetSize); load(validation, testSetSize); end loadMNistData; procedure saveToFile(data: MathUtils.Vector; path: String) with Pre => Positive(data.Length) = TrainingData.blockArea is image: PixelArray.ImagePlane := PixelArray.allocate(width => TrainingData.blockSize, height => TrainingData.blockSize); saveResult: Boolean; begin for y in 0 .. image.height - 1 loop for x in 0 .. image.width - 1 loop declare id: constant Positive := y * image.width + x + 1; begin image.set(x => x, y => y, px => PixelArray.Pixel(255.0 * data(id))); end; end loop; end loop; saveResult := ImageIO.save(filename => path, image => image); end saveToFile; function Get_Index_Of_Max(vec: in MathUtils.Vector) return Natural is result: Positive := vec.First_Index; begin for i in vec.First_Index + 1 .. vec.Last_Index loop if vec(i) > vec(result) then result := i; end if; end loop; return result; end Get_Index_Of_Max; procedure testTrainInputMNIST(T : in out Test_Cases.Test_Case'Class) is set: TrainingData.Set; validationSet: TrainingData.Set; config: NeuralNet.Config(1); dnn: NNClassifier.DNN(config.size + 1); tm: Timer.T; pred: MathUtils.Vector; di: Positive := 1; index_of_max: Positive := 1; failedPredictions: Natural := 0; begin loadMNistData(set, validationSet); Assert(set.size > 10, "not enough train data: " & set.size'Image); Assert(validationSet.size > 10, "not enough test data: " & validationSet.size'Image); config.act := NeuralNet.LOGISTIC; config.inputSize := TrainingData.blockArea; config.lr := 0.7; config.sizes := (1 => 32); dnn := NNClassifier.create(config => config, numberOfClasses => 10); Ada.Text_IO.Put_Line("Train the model..."); tm := Timer.start; dnn.train(data => set.values, labels => set.labels); tm.report; Ada.Text_IO.Put_Line("Inference..."); tm.reset; for lab of validationSet.labels loop -- MathUtils.print(validationSet.values.data(di)); pred := dnn.classify(validationSet.values.data(di)); index_of_max := Get_Index_Of_Max(pred); if index_of_max /= lab + 1 then failedPredictions := failedPredictions + 1; end if; di := di + 1; end loop; tm.report; declare acc: Float; begin acc := Float(validationSet.size - failedPredictions) / Float(validationSet.size); Ada.Text_IO.Put_Line("Model accuracy: " & acc'Image); -- require > 75% accuracy Assert(acc > 0.75, "total: " & validationSet.size'Image & ", failed: " & failedPredictions'Image); end; end testTrainInputMNIST; procedure testTrainInputImages(T : in out Test_Cases.Test_Case'Class) is set: TrainingData.Set; validationSet: TrainingData.Set; config: NeuralNet.Config(1); dnn: NNClassifier.DNN(config.size + 1); tm: Timer.T; pred: MathUtils.Vector; di: Positive := 1; index_of_max: Positive := 1; failedPredictions: Natural := 0; begin Ada.Text_IO.Put_Line("Load training set..."); tm := Timer.start; set.loadFrom(Ada.Strings.Unbounded.To_Unbounded_String("../training_set/")); tm.report; validationSet.loadFrom(Ada.Strings.Unbounded.To_Unbounded_String("../training_set_test_cases/")); tm.report; Assert(set.size > 10, "not enough train data: " & set.size'Image); Assert(validationSet.size > 10, "not enough test data: " & validationSet.size'Image); config.act := NeuralNet.LOGISTIC; config.inputSize := TrainingData.blockArea; config.lr := 0.7; config.sizes := (1 => 32); dnn := NNClassifier.create(config => config, numberOfClasses => 10); Ada.Text_IO.Put_Line("Train the model..."); tm.reset; -- TODO: remove the loop when there is more train data for i in 0 .. 2 loop dnn.train(data => set.values, labels => set.labels); end loop; tm.report; Ada.Text_IO.Put_Line("Inference..."); tm.reset; for lab of validationSet.labels loop -- MathUtils.print(validationSet.values.data(di)); pred := dnn.classify(validationSet.values.data(di)); index_of_max := Get_Index_Of_Max(pred); if index_of_max /= (lab + 1) then failedPredictions := failedPredictions + 1; end if; di := di + 1; end loop; tm.report; declare acc: Float; begin acc := Float(validationSet.size - failedPredictions) / Float(validationSet.size); Ada.Text_IO.Put_Line("Model accuracy: " & acc'Image); -- require > 75% accuracy Assert(acc > 0.75, "total: " & validationSet.size'Image & ", failed: " & failedPredictions'Image); end; end testTrainInputImages; end TrainingSetTests;
AdaCore/gpr
Ada
3,999
adb
-- -- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with GPR2.Containers; with GPR2.Context; with GPR2.Log; with GPR2.Path_Name; with GPR2.Project.Attribute; with GPR2.Project.Attribute.Set; with GPR2.Project.Registry; with GPR2.Project.Registry.Attribute; with GPR2.Project.Registry.Pack; with GPR2.Project.Tree; with GPR2.Source_Reference; with GPR2.Source_Reference.Value; procedure Main is Tree1 : GPR2.Project.Tree.Object; Tree2 : GPR2.Project.Tree.Object; Context : GPR2.Context.Object; use GPR2; Library_Options : GPR2.Containers.Source_Value_List; Linker_Options : GPR2.Containers.Source_Value_List; procedure Print_Attributes (Tree : GPR2.Project.Tree.Object; Name : GPR2.Q_Attribute_Id) is Attributes : GPR2.Project.Attribute.Set.Object; use GPR2; Header : String := (if Name.Pack = Project_Level_Scope then Image (Name.Attr) else Image (Name.Pack) & "." & Image (Name.Attr)); begin Attributes := Tree.Root_Project.Attributes (Name, With_Defaults => False, With_Config => False); for A of Attributes loop declare Attribute : GPR2.Project.Attribute.Object := A; use GPR2.Project.Registry.Attribute; begin Ada.Text_IO.Put (Header); if Attribute.Has_Index then Ada.Text_IO.Put ( "(" & Attribute.Index.Text & ")"); end if; Ada.Text_IO.Put ("="); if Attribute.Kind = GPR2.Project.Registry.Attribute.Single then Ada.Text_IO.Put (""""); Ada.Text_IO.Put (String (Attribute.Value.Text)); Ada.Text_IO.Put (""""); else declare Separator : Boolean := False; Value : GPR2.Source_Reference.Value.Object; begin Ada.Text_IO.Put ("("); for V of Attribute.Values loop Value := V; if Separator then Ada.Text_IO.Put (","); end if; Separator := True; Ada.Text_IO.Put (""""); Ada.Text_IO.Put (String (Value.Text)); Ada.Text_IO.Put (""""); end loop; Ada.Text_IO.Put (")"); end; end if; Ada.Text_IO.Put_Line (""); end; end loop; end Print_Attributes; begin Tree1.Load_Autoconf (Filename => GPR2.Path_Name.Create_File (GPR2.Project.Ensure_Extension ("prj/lib2"), GPR2.Path_Name.No_Resolution), Context => Context); Library_Options := Tree1.Root_Project.Attribute (Name => GPR2.Project.Registry.Attribute.Library_Options).Values; Tree2.Load_Autoconf (Filename => GPR2.Path_Name.Create_File (GPR2.Project.Ensure_Extension ("inst/share/gpr/lib2"), GPR2.Path_Name.No_Resolution), Context => Context); Linker_Options := Tree2.Root_Project.Attribute (Name => GPR2.Project.Registry.Attribute.Linker.Linker_Options).Values; for Library_Option of Library_Options loop declare Found : Boolean := False; begin for Linker_Option of Linker_Options loop if Linker_Option.Text = Library_Option.Text then Found := True; exit; end if; end loop; if not Found then Print_Attributes (Tree => Tree1, Name => GPR2.Project.Registry.Attribute.Library_Options); Print_Attributes (Tree => Tree2, Name => GPR2.Project.Registry.Attribute.Linker.Linker_Options); return; end if; end; end loop; Ada.Text_IO.Put_Line ("OK"); end Main;