repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
AdaCore/Ada_Drivers_Library
Ada
3,596
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with NRF_SVD.RTC; with HAL; use HAL; package nRF.RTC is type RTC_Events is (Tick_Event, Overflow_Event, Compare_0_Event, Compare_1_Event, Compare_2_Event, Compare_3_Event); type Compare_Channel is range 0 .. 3; type Real_Time_Counter (Periph : not null access NRF_SVD.RTC.RTC_Peripheral) is private; procedure Start (This : Real_Time_Counter); procedure Stop (This : Real_Time_Counter); procedure Clear (This : Real_Time_Counter); procedure Set_Prescaler (This : Real_Time_Counter; Prescaler : UInt12); function Counter (This : Real_Time_Counter) return UInt24; procedure Set_Compare (This : Real_Time_Counter; Compare : Compare_Channel; Value : UInt24); function Event (This : Real_Time_Counter; Evt : RTC_Events) return Event_Type; procedure Enable_Event (This : Real_Time_Counter; Evt : RTC_Events); procedure Disable_Event (This : Real_Time_Counter; Evt : RTC_Events); private type Real_Time_Counter (Periph : not null access NRF_SVD.RTC.RTC_Peripheral) is null record; end nRF.RTC;
stcarrez/ada-awa
Ada
1,135
ads
----------------------------------------------------------------------- -- awa-changelogs-tests -- Tests for changelogs -- Copyright (C) 2014 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.Changelogs.Modules.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with null record; procedure Test_Add_Log (T : in out Test); end AWA.Changelogs.Modules.Tests;
msrLi/portingSources
Ada
882
adb
-- Copyright 2007-2014 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/>. package body Defs is function F1 (S : Struct1) return Integer is begin return s.x; -- Set breakpoint marker here. end F1; end Defs;
reznikmm/matreshka
Ada
4,806
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015-2016, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This servlet can be used to return static resources - content of files -- in deployment directory. ------------------------------------------------------------------------------ private with League.Calendars; private with League.Strings; private with Servlet.Generic_Servlets; private with Servlet.HTTP_Requests; private with Servlet.HTTP_Responses; with Servlet.HTTP_Servlets; package AWFC.Static_Resource_Servlets is type Static_Resource_Servlet is new Servlet.HTTP_Servlets.HTTP_Servlet with private; type Static_Resource_Servlet_Access is access all Static_Resource_Servlet'Class; private type Static_Resource_Servlet is new Servlet.HTTP_Servlets.HTTP_Servlet with null record; overriding procedure Do_Get (Self : in out Static_Resource_Servlet; Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class; Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class); overriding function Get_Last_Modified (Self : in out Static_Resource_Servlet; Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class) return League.Calendars.Date_Time; overriding function Get_Servlet_Info (Self : Static_Resource_Servlet) return League.Strings.Universal_String; overriding function Instantiate (Parameters : not null access Servlet.Generic_Servlets.Instantiation_Parameters'Class) return Static_Resource_Servlet; end AWFC.Static_Resource_Servlets;
zhmu/ananas
Ada
270
adb
with Text_IO; use Text_IO; package body Opt87_Pkg is procedure Print (Msg : String; Location : String) is Final_Msg : constant String := Ascii.Cr & "info: " & Msg & " (" & Location & ")" & Ascii.Cr; begin Put_Line (Final_Msg); end; end Opt87_Pkg;
coopht/axmpp
Ada
6,875
adb
------------------------------------------------------------------------------ -- -- -- AXMPP Project -- -- -- -- XMPP Library for Ada -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2016, Alexander Basov <[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 Alexander Basov, 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 XMPP.Versions is use type League.Strings.Universal_String; -------------- -- Create -- -------------- function Create return XMPP_Version_Access is begin return new XMPP_Version; end Create; ---------------- -- Get_Kind -- ---------------- overriding function Get_Kind (Self : XMPP_Version) return Object_Kind is pragma Unreferenced (Self); begin return XMPP.Version; end Get_Kind; ---------------- -- Get_Name -- ---------------- not overriding function Get_Name (Self : XMPP_Version) return League.Strings.Universal_String is begin return Self.Name; end Get_Name; -------------- -- Get_OS -- -------------- not overriding function Get_OS (Self : XMPP_Version) return League.Strings.Universal_String is begin return Self.OS; end Get_OS; ------------------- -- Get_Version -- ------------------- not overriding function Get_Version (Self : XMPP_Version) return League.Strings.Universal_String is begin return Self.Version; end Get_Version; ----------------- -- Serialize -- ----------------- overriding procedure Serialize (Self : XMPP_Version; Writer : in out XML.SAX.Pretty_Writers.XML_Pretty_Writer'Class) is begin Self.Start_IQ (Writer); Writer.Start_Prefix_Mapping (Namespace_URI => Version_URI); Writer.Start_Element (Namespace_URI => Version_URI, Local_Name => Query_Element); -- Name Writer.Start_Element (Qualified_Name => Name_Element); Writer.Characters (Self.Name); Writer.End_Element (Qualified_Name => Name_Element); -- Version Writer.Start_Element (Qualified_Name => Version_Element); Writer.Characters (Self.Version); Writer.End_Element (Qualified_Name => Version_Element); -- OS if not Self.OS.Is_Empty then Writer.Start_Element (Qualified_Name => OS_Element); Writer.Characters (Self.OS); Writer.End_Element (Qualified_Name => OS_Element); end if; Writer.End_Element (Namespace_URI => Version_URI, Local_Name => Query_Element); Writer.End_Prefix_Mapping; Self.End_IQ (Writer); end Serialize; ------------------- -- Set_Content -- ------------------- overriding procedure Set_Content (Self : in out XMPP_Version; Parameter : League.Strings.Universal_String; Value : League.Strings.Universal_String) is begin if Parameter = League.Strings.To_Universal_String ("name") then Self.Name := Value; elsif Parameter = League.Strings.To_Universal_String ("os") then Self.OS := Value; elsif Parameter = League.Strings.To_Universal_String ("version") then Self.Version := Value; end if; end Set_Content; ---------------- -- Set_Name -- ---------------- not overriding procedure Set_Name (Self : in out XMPP_Version; Name : League.Strings.Universal_String) is begin Self.Name := Name; end Set_Name; -------------- -- Set_OS -- -------------- not overriding procedure Set_OS (Self : in out XMPP_Version; OS : League.Strings.Universal_String) is begin Self.OS := OS; end Set_OS; ------------------- -- Set_Version -- ------------------- not overriding procedure Set_Version (Self : in out XMPP_Version; Version : League.Strings.Universal_String) is begin Self.Version := Version; end Set_Version; end XMPP.Versions;
OneWingedShark/Byron
Ada
1,312
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); With Ada.Characters.Wide_Wide_Latin_1, Lexington.Aux, Ada.Containers; -- This package contains the interface for the Expression-class of objects. Package Byron.Internals.Expressions with Pure is -- The root interface for the Expression-ype. Type Expression is interface; -- A classwide function that calls the instance's own To_String subprogram. Function "+"( Object : Expression'Class ) return Wide_Wide_String with Inline; -- To_String returns the result of the object's Print function, prepended -- with a string consisting of 'Level' number of Tabs. Function To_String( Object : Expression'Class; Level : Natural := 0 ) return Wide_Wide_String; -- The actual type's subprogram returning its string-representation. Function Print ( Object : Expression; Level : Ada.Containers.Count_Type := 0 ) return Wide_Wide_String is abstract; Private Function "+"( Object : Expression'Class ) return Wide_Wide_String is ( Object.To_String ); Package WWL renames Ada.Characters.Wide_Wide_Latin_1; EOL : constant Wide_Wide_String := (WWL.CR, WWL.LF); TAB : Wide_Wide_Character renames WWL.HT; End Byron.Internals.Expressions;
stcarrez/ada-util
Ada
11,145
adb
----------------------------------------------------------------------- -- util-beans-objects-datasets -- Datasets -- Copyright (C) 2013, 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.Unchecked_Deallocation; package body Util.Beans.Objects.Datasets is procedure Free is new Ada.Unchecked_Deallocation (Object => Object_Array, Name => Object_Array_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Dataset_Array, Name => Dataset_Array_Access); -- ------------------------------ -- Get the number of elements in the list. -- ------------------------------ overriding function Get_Count (From : in Dataset) return Natural is begin return From.Count; end Get_Count; -- ------------------------------ -- Set the current row index. Valid row indexes start at 1. -- ------------------------------ overriding procedure Set_Row_Index (From : in out Dataset; Index : in Natural) is begin From.Current_Pos := Index; From.Current.Data := From.Data (Index); end Set_Row_Index; -- ------------------------------ -- Get the element at the current row index. -- ------------------------------ overriding function Get_Row (From : in Dataset) return Util.Beans.Objects.Object is begin return From.Row; end Get_Row; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Dataset; Name : in String) return Util.Beans.Objects.Object is begin if Name = "count" then return Util.Beans.Objects.To_Object (From.Count); elsif Name = "rowIndex" then return Util.Beans.Objects.To_Object (From.Current_Pos); else return Util.Beans.Objects.Null_Object; end if; end Get_Value; -- ------------------------------ -- Get an iterator to iterate starting with the first element. -- ------------------------------ overriding function First (From : in Dataset) return Iterators.Proxy_Iterator_Access is Iter : constant Dataset_Iterator_Access := new Dataset_Iterator; begin Iter.Current_Pos := 1; Iter.Current.Map := From.Current.Map; if From.Count > 0 then Iter.Current.Data := From.Data (1); end if; return Iter.all'Access; end First; -- ------------------------------ -- Get an iterator to iterate starting with the last element. -- ------------------------------ overriding function Last (From : in Dataset) return Iterators.Proxy_Iterator_Access is Iter : constant Dataset_Iterator_Access := new Dataset_Iterator; begin Iter.Current_Pos := From.Count; Iter.Current.Map := From.Current.Map; if From.Count > 0 then Iter.Current.Data := From.Data (From.Count); end if; return Iter.all'Access; end Last; -- ------------------------------ -- Append a row in the dataset and call the fill procedure to populate -- the row content. -- ------------------------------ procedure Append (Into : in out Dataset; Fill : not null access procedure (Data : in out Object_Array)) is Data : constant Object_Array_Access := new Object_Array (1 .. Into.Columns); begin if Into.Data = null then Into.Data := new Dataset_Array (1 .. 10); elsif Into.Count >= Into.Data'Length then declare -- Sun's Java ArrayList use a 2/3 grow factor. -- Python's array use 8/9. Grow : constant Positive := Into.Count + (Into.Count * 2) / 3; Set : constant Dataset_Array_Access := new Dataset_Array (1 .. Grow); begin Set (Into.Data'Range) := Into.Data.all; Free (Into.Data); Into.Data := Set; end; end if; Into.Count := Into.Count + 1; Into.Data (Into.Count) := Data; Fill (Data.all); end Append; -- ------------------------------ -- Add a column to the dataset. If the position is not specified, -- the column count is incremented and the name associated with the last column. -- Raises Invalid_State exception if the dataset contains some rows, -- ------------------------------ procedure Add_Column (Into : in out Dataset; Name : in String; Pos : in Natural := 0) is Col : Positive; begin if Into.Count /= 0 then raise Invalid_State with "The dataset contains some rows."; end if; if Pos = 0 then Col := Into.Columns + 1; else Col := Pos; end if; Into.Map.Insert (Name, Col); if Into.Columns < Col then Into.Columns := Col; end if; end Add_Column; -- ------------------------------ -- Clear the content of the dataset. -- ------------------------------ procedure Clear (Set : in out Dataset) is begin for I in 1 .. Set.Count loop Free (Set.Data (I)); end loop; Set.Count := 0; Set.Current_Pos := 0; Set.Current.Data := null; end Clear; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Row; Name : in String) return Util.Beans.Objects.Object is Pos : constant Dataset_Map.Cursor := From.Map.Find (Name); begin if From.Data /= null and then Dataset_Map.Has_Element (Pos) then return From.Data (Dataset_Map.Element (Pos)); else return Null_Object; end if; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. -- ------------------------------ overriding procedure Set_Value (From : in out Row; Name : in String; Value : in Util.Beans.Objects.Object) is Pos : constant Dataset_Map.Cursor := From.Map.Find (Name); begin if From.Data /= null and then Dataset_Map.Has_Element (Pos) then From.Data (Dataset_Map.Element (Pos)) := Value; end if; end Set_Value; -- ------------------------------ -- Get an iterator to iterate starting with the first element. -- ------------------------------ overriding function First (From : in Row) return Iterators.Proxy_Iterator_Access is Iter : constant Row_Iterator_Access := new Row_Iterator; begin Iter.Pos := From.Map.First; Iter.Data := From.Data; return Iter.all'Access; end First; -- ------------------------------ -- Get an iterator to iterate starting with the last element. -- ------------------------------ overriding function Last (From : in Row) return Iterators.Proxy_Iterator_Access is pragma Unreferenced (From); begin return null; end Last; -- ------------------------------ -- Initialize the dataset and the row bean instance. -- ------------------------------ overriding procedure Initialize (Set : in out Dataset) is begin Set.Row := To_Object (Value => Set.Current'Unchecked_Access, Storage => STATIC); Set.Current.Map := Set.Map'Unchecked_Access; end Initialize; -- ------------------------------ -- Release the dataset storage. -- ------------------------------ overriding procedure Finalize (Set : in out Dataset) is begin Set.Clear; Free (Set.Data); end Finalize; -- ------------------------------ -- Initialize the dataset and the row bean instance. -- ------------------------------ overriding procedure Initialize (Iter : in out Dataset_Iterator) is begin Iter.Row := To_Object (Value => Iter.Current'Unchecked_Access, Storage => STATIC); end Initialize; function Get_Dataset is new Util.Beans.Objects.Iterators.Get_Bean (Dataset, Dataset_Access); overriding function Has_Element (Iter : in Dataset_Iterator) return Boolean is List : constant Dataset_Access := Get_Dataset (Iter); begin return List /= null and then Iter.Current_Pos /= 0 and then Iter.Current_Pos <= List.Count; end Has_Element; overriding procedure Next (Iter : in out Dataset_Iterator) is List : constant Dataset_Access := Get_Dataset (Iter); begin if List /= null and then Iter.Current_Pos <= List.Count then Iter.Current_Pos := Iter.Current_Pos + 1; if Iter.Current_Pos <= List.Count then Iter.Current.Data := List.Data (Iter.Current_Pos); end if; end if; end Next; overriding procedure Previous (Iter : in out Dataset_Iterator) is List : constant Dataset_Access := Get_Dataset (Iter); begin if List /= null and then Iter.Current_Pos > 0 then Iter.Current_Pos := Iter.Current_Pos - 1; if Iter.Current_Pos > 0 then Iter.Current.Data := List.Data (Iter.Current_Pos); end if; end if; end Previous; overriding function Element (Iter : in Dataset_Iterator) return Object is begin return Iter.Row; end Element; overriding procedure Initialize (Iter : in out Row_Iterator) is begin null; end Initialize; overriding function Has_Element (Iter : in Row_Iterator) return Boolean is begin return Dataset_Map.Has_Element (Iter.Pos); end Has_Element; overriding procedure Next (Iter : in out Row_Iterator) is begin Dataset_Map.Next (Iter.Pos); end Next; overriding procedure Previous (Iter : in out Row_Iterator) is begin null; end Previous; overriding function Element (Iter : in Row_Iterator) return Object is begin return Iter.Data (Dataset_Map.Element (Iter.Pos)); end Element; overriding function Key (Iter : in Row_Iterator) return String is begin return Dataset_Map.Key (Iter.Pos); end Key; end Util.Beans.Objects.Datasets;
AdaCore/gpr
Ada
26
ads
package Pkg2 is end Pkg2;
zhmu/ananas
Ada
503
ads
package Class_Wide4_Pkg is type Conditional_Interface is limited interface; type Data_Object is tagged null record; function Is_Valid (This : in Conditional_Interface) return Boolean is abstract; procedure Do_Stuff (This : in out Conditional_Interface) is abstract with Pre'Class => This.Is_Valid; procedure Do_Stuff_Access (This : not null access Conditional_Interface) is abstract with Pre'Class => This.Is_Valid; end Class_Wide4_Pkg;
stcarrez/ada-util
Ada
4,548
adb
----------------------------------------------------------------------- -- util-beans-objects-maps -- Object maps -- Copyright (C) 2010, 2011, 2012, 2017, 2018, 2019, 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. ----------------------------------------------------------------------- package body Util.Beans.Objects.Maps is -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Map_Bean; Name : in String) return Object is Pos : constant Cursor := From.Find (Name); begin if Has_Element (Pos) then return Element (Pos); else return Null_Object; end if; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- If the map contains the given name, the value changed. -- Otherwise name is added to the map and the value associated with it. -- ------------------------------ overriding procedure Set_Value (From : in out Map_Bean; Name : in String; Value : in Object) is begin From.Include (Name, Value); end Set_Value; -- ------------------------------ -- Get an iterator to iterate starting with the first element. -- ------------------------------ overriding function First (From : in Map_Bean) return Iterators.Proxy_Iterator_Access is Iter : constant Map_Iterator_Access := new Map_Iterator; begin Iter.Pos := From.First; return Iter.all'Access; end First; -- ------------------------------ -- Get an iterator to iterate starting with the last element. -- ------------------------------ overriding function Last (From : in Map_Bean) return Iterators.Proxy_Iterator_Access is pragma Unreferenced (From); begin return null; end Last; -- ------------------------------ -- Iterate over the members of the map. -- ------------------------------ procedure Iterate (From : in Object; Process : not null access procedure (Name : in String; Item : in Object)) is procedure Process_One (Pos : in Maps.Cursor); procedure Process_One (Pos : in Maps.Cursor) is begin Process (Maps.Key (Pos), Maps.Element (Pos)); end Process_One; Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (From); begin if Bean /= null and then Bean.all in Util.Beans.Objects.Maps.Map_Bean'Class then Map_Bean'Class (Bean.all).Iterate (Process_One'Access); end if; end Iterate; -- ------------------------------ -- Create an object that contains a <tt>Map_Bean</tt> instance. -- ------------------------------ function Create return Object is M : constant Map_Bean_Access := new Map_Bean; begin return To_Object (Value => M, Storage => DYNAMIC); end Create; function Get_Map is new Util.Beans.Objects.Iterators.Get_Bean (Map_Bean, Map_Bean_Access); overriding function Has_Element (Iter : in Map_Iterator) return Boolean is Map : constant Map_Bean_Access := Get_Map (Iter); begin return Map /= null and then Has_Element (Iter.Pos); end Has_Element; overriding procedure Next (Iter : in out Map_Iterator) is begin Next (Iter.Pos); end Next; overriding procedure Previous (Iter : in out Map_Iterator) is begin null; end Previous; overriding function Element (Iter : in Map_Iterator) return Object is begin return Element (Iter.Pos); end Element; overriding function Key (Iter : in Map_Iterator) return String is begin return Key (Iter.Pos); end Key; end Util.Beans.Objects.Maps;
reznikmm/matreshka
Ada
6,862
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_Number.Fraction_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Number_Fraction_Element_Node is begin return Self : Number_Fraction_Element_Node do Matreshka.ODF_Number.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Number_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Number_Fraction_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_Number_Fraction (ODF.DOM.Number_Fraction_Elements.ODF_Number_Fraction_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 Number_Fraction_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Fraction_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Number_Fraction_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_Number_Fraction (ODF.DOM.Number_Fraction_Elements.ODF_Number_Fraction_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 Number_Fraction_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_Number_Fraction (Visitor, ODF.DOM.Number_Fraction_Elements.ODF_Number_Fraction_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.Number_URI, Matreshka.ODF_String_Constants.Fraction_Element, Number_Fraction_Element_Node'Tag); end Matreshka.ODF_Number.Fraction_Elements;
Tim-W-James/Ada-Reference-Code
Ada
88
adb
with Ada.Text_IO; use Ada.Text_IO; procedure practice is begin null; end practice;
MinimSecure/unum-sdk
Ada
927
ads
-- Copyright 2012-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 System; package Pck is type Color is (Black, Red, Green, Blue, White); type Full_Table is array (Color) of Boolean; pragma Pack (Full_Table); procedure Do_Nothing (A : System.Address); end Pck;
reznikmm/coroutines
Ada
553
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Calendar.Formatting; with Ada.Text_IO; with Coroutines.Timeouts; procedure Timeout_Proc is begin Ada.Text_IO.Put_Line (Ada.Calendar.Formatting.Image (Ada.Calendar.Clock)); Coroutines.Yield (Coroutines.Timeouts.Timeout (5.0)); Ada.Text_IO.Put_Line (Ada.Calendar.Formatting.Image (Ada.Calendar.Clock)); end Timeout_Proc;
stcarrez/ada-awa
Ada
14,585
adb
----------------------------------------------------------------------- -- awa-tags-beans -- Beans for the tags module -- Copyright (C) 2013 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 ADO.Queries; with ADO.Statements; with ADO.Sessions.Entities; package body AWA.Tags.Beans is -- ------------------------------ -- Compare two tags on their count and name. -- ------------------------------ function "<" (Left, Right : in AWA.Tags.Models.Tag_Info) return Boolean is use type Ada.Strings.Unbounded.Unbounded_String; begin if Left.Count = Right.Count then return Left.Tag < Right.Tag; else return Left.Count > Right.Count; end if; end "<"; -- ------------------------------ -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. -- ------------------------------ overriding procedure Set_Value (From : in out Tag_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "entity_type" then From.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "permission" then From.Permission := Util.Beans.Objects.To_Unbounded_String (Value); end if; end Set_Value; -- ------------------------------ -- Set the entity type (database table) onto which the tags are associated. -- ------------------------------ procedure Set_Entity_Type (Into : in out Tag_List_Bean; Table : in ADO.Schemas.Class_Mapping_Access) is begin Into.Entity_Type := Ada.Strings.Unbounded.To_Unbounded_String (Table.Table.all); end Set_Entity_Type; -- ------------------------------ -- Set the permission to check before removing or adding a tag on the entity. -- ------------------------------ procedure Set_Permission (Into : in out Tag_List_Bean; Permission : in String) is begin Into.Permission := Ada.Strings.Unbounded.To_Unbounded_String (Permission); end Set_Permission; -- ------------------------------ -- Load the tags associated with the given database identifier. -- ------------------------------ procedure Load_Tags (Into : in out Tag_List_Bean; Session : in ADO.Sessions.Session; For_Entity_Id : in ADO.Identifier) is use ADO.Sessions.Entities; Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type); Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type); Query : ADO.Queries.Context; begin Query.Set_Query (AWA.Tags.Models.Query_Tag_List); Query.Bind_Param ("entity_type", Kind); Query.Bind_Param ("entity_id", For_Entity_Id); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query); begin Stmt.Execute; while Stmt.Has_Elements loop Into.List.Append (Util.Beans.Objects.To_Object (Stmt.Get_String (0))); Stmt.Next; end loop; end; end Load_Tags; -- ------------------------------ -- Set the list of tags to add. -- ------------------------------ procedure Set_Added (Into : in out Tag_List_Bean; Tags : in Util.Strings.Vectors.Vector) is begin Into.Added := Tags; end Set_Added; -- ------------------------------ -- Set the list of tags to remove. -- ------------------------------ procedure Set_Deleted (Into : in out Tag_List_Bean; Tags : in Util.Strings.Vectors.Vector) is begin Into.Deleted := Tags; end Set_Deleted; -- ------------------------------ -- Update the tags associated with the tag entity represented by <tt>For_Entity_Id</tt>. -- The list of tags defined by <tt>Set_Deleted</tt> are removed first and the list of -- tags defined by <tt>Set_Added</tt> are associated with the database entity. -- ------------------------------ procedure Update_Tags (From : in Tag_List_Bean; For_Entity_Id : in ADO.Identifier) is use type AWA.Tags.Modules.Tag_Module_Access; Entity_Type : constant String := Ada.Strings.Unbounded.To_String (From.Entity_Type); Service : AWA.Tags.Modules.Tag_Module_Access := From.Module; begin if Service = null then Service := AWA.Tags.Modules.Get_Tag_Module; end if; Service.Update_Tags (Id => For_Entity_Id, Entity_Type => Entity_Type, Permission => Ada.Strings.Unbounded.To_String (From.Permission), Added => From.Added, Deleted => From.Deleted); end Update_Tags; -- ------------------------------ -- Create the tag list bean instance. -- ------------------------------ function Create_Tag_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access is Result : constant Tag_List_Bean_Access := new Tag_List_Bean; begin Result.Module := Module; return Result.all'Access; end Create_Tag_List_Bean; -- ------------------------------ -- Search the tags that match the search string. -- ------------------------------ procedure Search_Tags (Into : in out Tag_Search_Bean; Session : in ADO.Sessions.Session; Search : in String) is use ADO.Sessions.Entities; Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type); Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type); Query : ADO.Queries.Context; begin Query.Set_Query (AWA.Tags.Models.Query_Tag_Search); Query.Bind_Param ("entity_type", Kind); Query.Bind_Param ("search", Search & "%"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query); begin Stmt.Execute; while Stmt.Has_Elements loop Into.List.Append (Util.Beans.Objects.To_Object (Stmt.Get_String (0))); Stmt.Next; end loop; end; end Search_Tags; -- ------------------------------ -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. -- ------------------------------ overriding procedure Set_Value (From : in out Tag_Search_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "entity_type" then From.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "search" then declare Session : constant ADO.Sessions.Session := From.Module.Get_Session; begin From.Search_Tags (Session, Util.Beans.Objects.To_String (Value)); end; end if; end Set_Value; -- ------------------------------ -- Set the entity type (database table) onto which the tags are associated. -- ------------------------------ procedure Set_Entity_Type (Into : in out Tag_Search_Bean; Table : in ADO.Schemas.Class_Mapping_Access) is begin Into.Entity_Type := Ada.Strings.Unbounded.To_Unbounded_String (Table.Table.all); end Set_Entity_Type; -- ------------------------------ -- Create the tag search bean instance. -- ------------------------------ function Create_Tag_Search_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access is Result : constant Tag_Search_Bean_Access := new Tag_Search_Bean; begin Result.Module := Module; return Result.all'Access; end Create_Tag_Search_Bean; -- ------------------------------ -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. -- ------------------------------ overriding procedure Set_Value (From : in out Tag_Info_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "entity_type" then From.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value); declare Session : ADO.Sessions.Session := From.Module.Get_Session; begin From.Load_Tags (Session); end; end if; end Set_Value; -- ------------------------------ -- Load the list of tags. -- ------------------------------ procedure Load_Tags (Into : in out Tag_Info_List_Bean; Session : in out ADO.Sessions.Session) is use ADO.Sessions.Entities; Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type); Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type); Query : ADO.Queries.Context; begin Query.Set_Query (AWA.Tags.Models.Query_Tag_List_All); Query.Bind_Param ("entity_type", Kind); AWA.Tags.Models.List (Into, Session, Query); end Load_Tags; -- ------------------------------ -- Create the tag info list bean instance. -- ------------------------------ function Create_Tag_Info_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access is Result : constant Tag_Info_List_Bean_Access := new Tag_Info_List_Bean; begin Result.Module := Module; return Result.all'Access; end Create_Tag_Info_List_Bean; -- ------------------------------ -- Get the list of tags associated with the given entity. -- Returns null if the entity does not have any tag. -- ------------------------------ function Get_Tags (From : in Entity_Tag_Map; For_Entity : in ADO.Identifier) return Util.Beans.Lists.Strings.List_Bean_Access is Pos : constant Entity_Tag_Maps.Cursor := From.Tags.Find (For_Entity); begin if Entity_Tag_Maps.Has_Element (Pos) then return Entity_Tag_Maps.Element (Pos); else return null; end if; end Get_Tags; -- ------------------------------ -- Get the list of tags associated with the given entity. -- Returns a null object if the entity does not have any tag. -- ------------------------------ function Get_Tags (From : in Entity_Tag_Map; For_Entity : in ADO.Identifier) return Util.Beans.Objects.Object is Pos : constant Entity_Tag_Maps.Cursor := From.Tags.Find (For_Entity); begin if Entity_Tag_Maps.Has_Element (Pos) then return Util.Beans.Objects.To_Object (Value => Entity_Tag_Maps.Element (Pos).all'Access, Storage => Util.Beans.Objects.STATIC); else return Util.Beans.Objects.Null_Object; end if; end Get_Tags; -- ------------------------------ -- Load the list of tags associated with a list of entities. -- ------------------------------ procedure Load_Tags (Into : in out Entity_Tag_Map; Session : in out ADO.Sessions.Session'Class; Entity_Type : in String; List : in ADO.Utils.Identifier_Vector) is Query : ADO.Queries.Context; Kind : ADO.Entity_Type; begin Into.Clear; if List.Is_Empty then return; end if; Kind := ADO.Sessions.Entities.Find_Entity_Type (Session, Entity_Type); Query.Set_Query (AWA.Tags.Models.Query_Tag_List_For_Entities); Query.Bind_Param ("entity_id_list", List); Query.Bind_Param ("entity_type", Kind); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query); Id : ADO.Identifier; List : Util.Beans.Lists.Strings.List_Bean_Access; Pos : Entity_Tag_Maps.Cursor; begin Stmt.Execute; while Stmt.Has_Elements loop Id := Stmt.Get_Identifier (0); Pos := Into.Tags.Find (Id); if not Entity_Tag_Maps.Has_Element (Pos) then List := new Util.Beans.Lists.Strings.List_Bean; Into.Tags.Insert (Id, List); else List := Entity_Tag_Maps.Element (Pos); end if; List.List.Append (Stmt.Get_String (1)); Stmt.Next; end loop; end; end Load_Tags; -- ------------------------------ -- Release the list of tags. -- ------------------------------ procedure Clear (List : in out Entity_Tag_Map) is procedure Free is new Ada.Unchecked_Deallocation (Object => Util.Beans.Lists.Strings.List_Bean'Class, Name => Util.Beans.Lists.Strings.List_Bean_Access); Pos : Entity_Tag_Maps.Cursor; Tags : Util.Beans.Lists.Strings.List_Bean_Access; begin loop Pos := List.Tags.First; exit when not Entity_Tag_Maps.Has_Element (Pos); Tags := Entity_Tag_Maps.Element (Pos); List.Tags.Delete (Pos); Free (Tags); end loop; end Clear; -- ------------------------------ -- Release the list of tags. -- ------------------------------ overriding procedure Finalize (List : in out Entity_Tag_Map) is begin List.Clear; end Finalize; end AWA.Tags.Beans;
Aldmors/coinapi-sdk
Ada
6,365
adb
-- OEML _ REST API -- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. <br/> This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a> <br/><br/> Implemented Standards: * [HTTP1.0](https://datatracker.ietf.org/doc/html/rfc1945) * [HTTP1.1](https://datatracker.ietf.org/doc/html/rfc2616) * [HTTP2.0](https://datatracker.ietf.org/doc/html/rfc7540) -- -- The version of the OpenAPI document: v1 -- Contact: [email protected] -- -- NOTE: This package is auto generated by OpenAPI-Generator 5.2.1. -- https://openapi-generator.tech -- Do not edit the class manually. pragma Warnings (Off, "*is not referenced"); with Swagger.Streams; package body .Clients is pragma Style_Checks ("-mr"); -- Get balances -- Get current currency balance from all or single exchange. procedure V_1Balances_Get (Client : in out Client_Type; Exchange_Id : in Swagger.Nullable_UString; Result : out .Models.Balance_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICTION_JSON)); URI.Add_Param ("exchange_id", Exchange_Id); URI.Set_Path ("/v1/balances"); Client.Call (Swagger.Clients.GET, URI, Reply); .Models.Deserialize (Reply, "", Result); end V_1Balances_Get; -- Cancel all orders request -- This request cancels all open orders on single specified exchange. procedure V_1Orders_Cancel_All_Post (Client : in out Client_Type; Order_Cancel_All_Request_Type : in .Models.OrderCancelAllRequest_Type; Result : out .Models.MessageReject_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICTION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); .Models.Serialize (Req.Stream, "", Order_Cancel_All_Request_Type); URI.Set_Path ("/v1/orders/cancel/all"); Client.Call (Swagger.Clients.POST, URI, Req, Reply); .Models.Deserialize (Reply, "", Result); end V_1Orders_Cancel_All_Post; -- Cancel order request -- Request cancel for an existing order. The order can be canceled using the `client_order_id` or `exchange_order_id`. procedure V_1Orders_Cancel_Post (Client : in out Client_Type; Order_Cancel_Single_Request_Type : in .Models.OrderCancelSingleRequest_Type; Result : out .Models.OrderExecutionReport_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICTION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); .Models.Serialize (Req.Stream, "", Order_Cancel_Single_Request_Type); URI.Set_Path ("/v1/orders/cancel"); Client.Call (Swagger.Clients.POST, URI, Req, Reply); .Models.Deserialize (Reply, "", Result); end V_1Orders_Cancel_Post; -- Get open orders -- Get last execution reports for open orders across all or single exchange. procedure V_1Orders_Get (Client : in out Client_Type; Exchange_Id : in Swagger.Nullable_UString; Result : out .Models.OrderExecutionReport_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICTION_JSON)); URI.Add_Param ("exchange_id", Exchange_Id); URI.Set_Path ("/v1/orders"); Client.Call (Swagger.Clients.GET, URI, Reply); .Models.Deserialize (Reply, "", Result); end V_1Orders_Get; -- Send new order -- This request creating new order for the specific exchange. procedure V_1Orders_Post (Client : in out Client_Type; Order_New_Single_Request_Type : in .Models.OrderNewSingleRequest_Type; Result : out .Models.OrderExecutionReport_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICTION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); .Models.Serialize (Req.Stream, "", Order_New_Single_Request_Type); URI.Set_Path ("/v1/orders"); Client.Call (Swagger.Clients.POST, URI, Req, Reply); .Models.Deserialize (Reply, "", Result); end V_1Orders_Post; -- Get order execution report -- Get the last order execution report for the specified order. The requested order does not need to be active or opened. procedure V_1Orders_Status_Client_Order_Id_Get (Client : in out Client_Type; Client_Order_Id : in Swagger.UString; Result : out .Models.OrderExecutionReport_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/v1/orders/status/{client_order_id}"); URI.Set_Path_Param ("client_order_id", Client_Order_Id); Client.Call (Swagger.Clients.GET, URI, Reply); .Models.Deserialize (Reply, "", Result); end V_1Orders_Status_Client_Order_Id_Get; -- Get open positions -- Get current open positions across all or single exchange. procedure V_1Positions_Get (Client : in out Client_Type; Exchange_Id : in Swagger.Nullable_UString; Result : out .Models.Position_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICTION_JSON)); URI.Add_Param ("exchange_id", Exchange_Id); URI.Set_Path ("/v1/positions"); Client.Call (Swagger.Clients.GET, URI, Reply); .Models.Deserialize (Reply, "", Result); end V_1Positions_Get; end .Clients;
peterfrankjohnson/kernel
Ada
535
adb
with Console; use Console; with Types; use Types; with CPU; use CPU; package body Device.PCI is procedure Detect is PCIPort1 : Word := 16#CF8#; PCIPort2 : Word := 16#CFA#; PCIPort3 : Word := 16#CFC#; Data : Double := 16#80000000# + (0 * 2048) + 0; begin CPU.OutputByte (PCIPort1, 0); CPU.OutputByte (PCIPort2, 0); CPU.OutputDouble (PCIPort1, Data); Data := CPU.InputDouble (PCIPort3); Console.Put (Integer'Image (Integer (Data)), 1, 20); end Detect; end Device.PCI;
reznikmm/matreshka
Ada
3,615
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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Link_End_Datas.Hash is new AMF.Elements.Generic_Hash (UML_Link_End_Data, UML_Link_End_Data_Access);
stcarrez/ada-util
Ada
2,466
adb
----------------------------------------------------------------------- -- events.tests -- Unit tests for event channels -- Copyright (C) 2009, 2010, 2011, 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.Unchecked_Deallocation; with Util.Test_Caller; package body Util.Events.Channels.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Events.Channels"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Events.Channels.Post_Event", Test_Post_Event'Access); end Add_Tests; overriding procedure Receive_Event (Sub : in out Test; Item : in Event'Class) is pragma Unreferenced (Item); begin Sub.Count := Sub.Count + 1; end Receive_Event; procedure Test_Post_Event (T : in out Test) is procedure Free is new Ada.Unchecked_Deallocation (Object => Channel'Class, Name => Channel_Access); C : Channel_Access := Create ("test", "direct"); E : Event; T1 : aliased Test; T2 : aliased Test; begin C.Post (E); Assert_Equals (T, "test", C.Get_Name, "Invalid channel name"); C.Subscribe (T1'Unchecked_Access); C.Post (E); Assert_Equals (T, 1, T1.Count, "Invalid number of received events"); Assert_Equals (T, 0, T2.Count, "Invalid number of events"); C.Subscribe (T2'Unchecked_Access); C.Post (E); C.Unsubscribe (T1'Unchecked_Access); C.Post (E); Assert_Equals (T, 2, T1.Count, "Invalid number of received events"); Assert_Equals (T, 2, T2.Count, "Invalid number of events"); Free (C); end Test_Post_Event; end Util.Events.Channels.Tests;
stcarrez/ada-asf
Ada
10,223
ads
----------------------------------------------------------------------- -- asf -- XHTML Reader -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2017, 2018, 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 Sax.Exceptions; with Sax.Locators; with Sax.Readers; with Sax.Attributes; with Unicode.CES; with Input_Sources; with EL.Contexts; with EL.Contexts.Default; with ASF.Factory; private with EL.Functions; private with Util.Strings.Maps; package ASF.Views.Nodes.Reader is Parsing_Error : exception; type Xhtml_Reader is new Sax.Readers.Reader with private; overriding procedure Warning (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class); overriding procedure Error (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class); overriding procedure Fatal_Error (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class); overriding procedure Set_Document_Locator (Handler : in out Xhtml_Reader; Loc : in out Sax.Locators.Locator); overriding procedure Start_Document (Handler : in out Xhtml_Reader); overriding procedure End_Document (Handler : in out Xhtml_Reader); overriding procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader; Prefix : in Unicode.CES.Byte_Sequence; URI : in Unicode.CES.Byte_Sequence); overriding procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader; Prefix : in Unicode.CES.Byte_Sequence); overriding procedure Start_Element (Handler : in out Xhtml_Reader; Namespace_URI : in Unicode.CES.Byte_Sequence := ""; Local_Name : in Unicode.CES.Byte_Sequence := ""; Qname : in Unicode.CES.Byte_Sequence := ""; Atts : in Sax.Attributes.Attributes'Class); overriding procedure End_Element (Handler : in out Xhtml_Reader; Namespace_URI : in Unicode.CES.Byte_Sequence := ""; Local_Name : in Unicode.CES.Byte_Sequence := ""; Qname : in Unicode.CES.Byte_Sequence := ""); overriding procedure Characters (Handler : in out Xhtml_Reader; Ch : in Unicode.CES.Byte_Sequence); overriding procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader; Ch : in Unicode.CES.Byte_Sequence); overriding procedure Processing_Instruction (Handler : in out Xhtml_Reader; Target : in Unicode.CES.Byte_Sequence; Data : in Unicode.CES.Byte_Sequence); overriding procedure Skipped_Entity (Handler : in out Xhtml_Reader; Name : in Unicode.CES.Byte_Sequence); overriding procedure Start_Cdata (Handler : in out Xhtml_Reader); overriding procedure End_Cdata (Handler : in out Xhtml_Reader); overriding function Resolve_Entity (Handler : Xhtml_Reader; Public_Id : Unicode.CES.Byte_Sequence; System_Id : Unicode.CES.Byte_Sequence) return Input_Sources.Input_Source_Access; overriding procedure Start_DTD (Handler : in out Xhtml_Reader; Name : Unicode.CES.Byte_Sequence; Public_Id : Unicode.CES.Byte_Sequence := ""; System_Id : Unicode.CES.Byte_Sequence := ""); -- Get the root node that was created upon parsing of the XHTML file. function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access; -- Set the XHTML reader to ignore or not the white spaces. -- When set to True, the ignorable white spaces will not be kept. procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader; Value : in Boolean); -- Set the XHTML reader to escape or not the unknown tags. -- When set to True, the tags which are not recognized will be -- emitted as a raw text component and they will be escaped using -- the XML escape rules. procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader; Value : in Boolean); -- Set the XHTML reader to ignore empty lines. procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader; Value : in Boolean); -- Parse an XML stream, and calls the appropriate SAX callbacks for each -- event. -- This is not re-entrant: you can not call Parse with the same Parser -- argument in one of the SAX callbacks. This has undefined behavior. procedure Parse (Parser : in out Xhtml_Reader; Name : in ASF.Views.File_Info_Access; Input : in out Input_Sources.Input_Source'Class; Factory : access ASF.Factory.Component_Factory; Context : in EL.Contexts.ELContext_Access); private -- Collect the text for an EL expression. The EL expression starts -- with either '#{' or with '${' and ends with the matching '}'. -- If the <b>Value</b> string does not contain the whole EL expression -- the <b>Expr_Buffer</b> stored in the reader is used to collect -- that expression. procedure Collect_Expression (Handler : in out Xhtml_Reader); -- Collect the raw-text in a buffer. The text must be flushed -- when a new element is started or when an exiting element is closed. procedure Collect_Text (Handler : in out Xhtml_Reader; Value : in Unicode.CES.Byte_Sequence); use EL.Functions; -- use ASF.Components.Factory; package NS_Mapping renames Util.Strings.Maps; -- Skip indicates the number of frames to skip in the saved locations -- stack type NS_Function_Mapper is new Function_Mapper with record Mapping : NS_Mapping.Map; Mapper : Function_Mapper_Access; Factory : access ASF.Factory.Component_Factory; end record; -- Find the function knowing its name. overriding function Get_Function (Mapper : NS_Function_Mapper; Namespace : String; Name : String) return Function_Access; -- Bind a name to a function in the given namespace. overriding procedure Set_Function (Mapper : in out NS_Function_Mapper; Namespace : in String; Name : in String; Func : in Function_Access); -- Find the create function in bound to the name in the given namespace. -- Returns null if no such binding exist. function Find (Mapper : in NS_Function_Mapper; Namespace : in String; Name : in String) return ASF.Views.Nodes.Binding_Type; procedure Set_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String; URI : in String); -- Remove the namespace prefix binding. procedure Remove_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String); type Element_Context is record Parent : Tag_Node_Access; Text : Boolean; Has_Content : Boolean; end record; type Element_Context_Access is access all Element_Context; type Element_Context_Array is array (Natural range <>) of aliased Element_Context; type Element_Context_Array_Access is access all Element_Context_Array; type Text_State is (NO_CONTENT, HAS_CONTENT, PARSE_EXPR); type Xhtml_Reader is new Sax.Readers.Reader with record Locator : Sax.Locators.Locator; Root : Tag_Node_Access; Text : Text_Tag_Node_Access; Current : Element_Context_Access; ELContext : EL.Contexts.ELContext_Access; Functions : aliased NS_Function_Mapper; Context : aliased EL.Contexts.Default.Default_Context; Stack : Element_Context_Array_Access; Stack_Pos : Natural := 0; -- The line and file information. Line : Line_Info; State : Text_State := NO_CONTENT; Default_State : Text_State := NO_CONTENT; -- Current expression buffer (See Collect_Expression) Expr_Buffer : Unbounded_String; -- Some pending white spaces to append to the current text. Spaces : Unbounded_String; -- When not empty, the 'xmlns' attribute to insert in the element. The XML Sax parser -- notifies us about 'xmlns' attributes through the Start_Prefix_Mapping operation. -- When the default namespace with empty prefix is found, we have to add the corresponding -- attribute in Start_Element so that it is written in the facelet tree. Add_NS : Unbounded_String; -- Whether the unknown tags are escaped using XML escape rules. Escape_Unknown_Tags : Boolean := True; -- Whether white spaces can be ignored. Ignore_White_Spaces : Boolean := True; -- Whether empty lines should be ignored (when white spaces are kept). Ignore_Empty_Lines : Boolean := True; end record; end ASF.Views.Nodes.Reader;
reznikmm/matreshka
Ada
4,001
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.Dr3d_Projection_Attributes; package Matreshka.ODF_Dr3d.Projection_Attributes is type Dr3d_Projection_Attribute_Node is new Matreshka.ODF_Dr3d.Abstract_Dr3d_Attribute_Node and ODF.DOM.Dr3d_Projection_Attributes.ODF_Dr3d_Projection_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Dr3d_Projection_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Dr3d_Projection_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Dr3d.Projection_Attributes;
zhmu/ananas
Ada
6,246
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 6 9 -- -- -- -- B o d y -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Unsigned_Types; package body System.Pack_69 is subtype Bit_Order is System.Bit_Order; Reverse_Bit_Order : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order)); subtype Ofs is System.Storage_Elements.Storage_Offset; subtype Uns is System.Unsigned_Types.Unsigned; subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7; use type System.Storage_Elements.Storage_Offset; use type System.Unsigned_Types.Unsigned; type Cluster is record E0, E1, E2, E3, E4, E5, E6, E7 : Bits_69; end record; for Cluster use record E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1; E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1; E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1; E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1; E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1; E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1; E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1; E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1; end record; for Cluster'Size use Bits * 8; for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment, 1 + 1 * Boolean'Pos (Bits mod 2 = 0) + 2 * Boolean'Pos (Bits mod 4 = 0)); -- Use maximum possible alignment, given the bit field size, since this -- will result in the most efficient code possible for the field. type Cluster_Ref is access Cluster; type Rev_Cluster is new Cluster with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_Cluster_Ref is access Rev_Cluster; ------------ -- Get_69 -- ------------ function Get_69 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_69 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end Get_69; ------------ -- Set_69 -- ------------ procedure Set_69 (Arr : System.Address; N : Natural; E : Bits_69; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end Set_69; end System.Pack_69;
sungyeon/drake
Ada
36
adb
../machine-apple-darwin/s-natcre.adb
ytomino/xml-ada
Ada
3,351
adb
with Ada.Command_Line; with Ada.Directories; with Ada.Environment_Variables; with Ada.Streams.Stream_IO; with Ada.Strings.Unbounded; with Ada.Text_IO; with Serialization.XML; with XML.Streams; procedure test_serialize is Verbose : Boolean := False; procedure Put (Item : in String) is begin if Verbose then Ada.Text_IO.Put (Item); end if; end Put; procedure New_Line is begin if Verbose then Ada.Text_IO.New_Line; end if; end New_Line; Test_File_Name : constant String := Ada.Directories.Compose ( Ada.Environment_Variables.Value ("TMPDIR", Default => "/tmp"), "test_serialize.xml"); type Nested_Map is record A : Integer; end record; procedure IO ( S : not null access Serialization.Serializer; Name : String; Var : in out Nested_Map) is procedure Process is begin Serialization.IO (S, "A", Var.A); end Process; begin Serialization.IO (S, Name, Process'Access); end IO; type T is record X : Ada.Strings.Unbounded.Unbounded_String; Y : Boolean; Z : Nested_Map; end record; procedure IO (S : not null access Serialization.Serializer; Var : in out T) is procedure Process is begin Serialization.IO (S, "X", Var.X); Serialization.IO (S, "Y", Var.Y); IO (S, "Z", Var.Z); end Process; begin Serialization.IO (S, Process'Access); end IO; Root_Tag : constant String := "ROOT-TAG"; Data : T := ( X => Ada.Strings.Unbounded.To_Unbounded_String ("XYZ"), Y => True, Z => (A => 100)); begin -- options for I in 1 .. Ada.Command_Line.Argument_Count loop declare A : constant String := Ada.Command_Line.Argument (I); begin if A = "--verbose" then Verbose := True; else Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "unknown option: " & A); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); return; end if; end; end loop; -- writer declare W : aliased XML.Writer := XML.Create (Put'Access); begin IO (Serialization.XML.Writing (W'Access, Root_Tag).Serializer, Data); XML.Finish (W); end; declare File : Ada.Streams.Stream_IO.File_Type; begin Ada.Streams.Stream_IO.Create (File, Name => Test_File_Name); declare W : aliased XML.Writer := XML.Streams.Create (Ada.Streams.Stream_IO.Stream (File)); begin Put ("Writing..."); IO (Serialization.XML.Writing (W'Access, Root_Tag).Serializer, Data); XML.Finish (W); Put (" ok"); New_Line; end; Ada.Streams.Stream_IO.Close (File); end; -- reader declare File : Ada.Streams.Stream_IO.File_Type; Data2 : T := ( X => Ada.Strings.Unbounded.Null_Unbounded_String, Y => False, Z => (A => 0)); begin Ada.Streams.Stream_IO.Open (File, Ada.Streams.Stream_IO.In_File, Name => Test_File_Name); declare R : aliased XML.Reader := XML.Streams.Create (Ada.Streams.Stream_IO.Stream (File)); begin Put ("Reading..."); IO (Serialization.XML.Reading (R'Access, Root_Tag).Serializer, Data2); XML.Finish (R); Put (" ok"); New_Line; end; Ada.Streams.Stream_IO.Close (File); declare W : aliased XML.Writer := XML.Create (Put'Access); begin IO (Serialization.XML.Writing (W'Access, Root_Tag).Serializer, Data2); XML.Finish (W); end; if Data2 /= Data then raise Program_Error; end if; end; -- finish Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok"); end test_serialize;
charlie5/cBound
Ada
1,515
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with xcb.xcb_render_spanfix_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_spanfix_iterator_t is -- Item -- type Item is record data : access xcb.xcb_render_spanfix_t.Item; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_spanfix_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_spanfix_iterator_t.Item, Element_Array => xcb.xcb_render_spanfix_iterator_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_render_spanfix_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_spanfix_iterator_t.Pointer, Element_Array => xcb.xcb_render_spanfix_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_spanfix_iterator_t;
reznikmm/matreshka
Ada
4,158
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2018, 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 test checks encoding of an emoji character in UTF-8. ------------------------------------------------------------------------------ with Ada.Streams; with League.Strings; with League.Text_Codecs; procedure Text_492 is use type Ada.Streams.Stream_Element_Array; Line : constant Wide_Wide_String := (1 => Wide_Wide_Character'Val (16#1F60A#)); -- 😊 Text : constant League.Strings.Universal_String := League.Strings.To_Universal_String (Line); UTF8 : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec (League.Strings.To_Universal_String ("utf-8")); Raw : constant Ada.Streams.Stream_Element_Array := UTF8.Encode (Text).To_Stream_Element_Array; begin if Raw /= (16#F0#, 16#9F#, 16#98#, 16#8A#) then raise Program_Error; end if; end Text_492;
jscparker/math_packages
Ada
9,356
adb
-- Test hessenberg decomposition of real valued square matrices. with Ada.Numerics.Generic_elementary_functions; with Hessenberg; with Test_Matrices; with Text_IO; use Text_IO; procedure hess_tst_1 is type Real is digits 15; --type Real is digits 18; --Desired_Size_Of_Matrix : constant := 2291; --Desired_Size_Of_Matrix : constant := 1024; --Desired_Size_Of_Matrix : constant := 478; --Desired_Size_Of_Matrix : constant := 254; --Desired_Size_Of_Matrix : constant := 160; Desired_Size_Of_Matrix : constant := 137; --Desired_Size_Of_Matrix : constant := 87; --Desired_Size_Of_Matrix : constant := 95; pragma Assert (Desired_Size_Of_Matrix < 2**24 and Desired_Size_Of_Matrix > 1); -- Next: make sure Matrix_Storage_Size is never odd, and never a power of 2. -- -- This doesn't help for small matrices (Size < 128 on some machines). -- -- But odd sizes and power of 2 sizes are a performance disaster on more -- than one Intel processor if matrix is too large for certain Cache sizes. -- Lapack, compiled by gfortran, seems to have similar problems. type Unsigned_32 is mod 2**32; Padding_0 : constant Unsigned_32 := 2 + Desired_Size_Of_Matrix mod 2; Storage_0 : constant Unsigned_32 := Padding_0 + Desired_Size_Of_Matrix; Power_of_2_Tst : constant Unsigned_32 := Storage_0 and (Storage_0 - 1); More_Padding : constant Unsigned_32 := 2 * (1 / (1 + Power_of_2_Tst)); -- Power_of_2_Tst = 0 iff Storage = 2**n. More_Padding = 2 iff Storage = 2**n Matrix_Storage_Size : constant Integer := Integer (Storage_0 + More_Padding); -- the test matrix is square-shaped matrix on: Index x Index. -- eg Hilbert's matrix is a square matrix with unique elements on the range -- Index'First .. Index'Last. However, you have the option or using any -- diagonal sub-block of the matrix defined by Index x Index subtype Index is Integer range 0 .. Matrix_Storage_Size-1; Starting_Col : constant Index := Index'First; Final_Col : constant Index := Starting_Col + Desired_Size_Of_Matrix - 1; -- You have the option or using any diagonal sub-block -- of the matrix defined by Index x Index. Since it's square, the -- corners of this diagonal sub-block are defined by the 2 numbers -- defined above, Starting_Col and Final_Col. type Matrix is array(Index, Index) of Real; pragma Convention (Fortran, Matrix); -- use Convention Fortran. Can be twice as fast as Ada convention. -- package math is new Ada.Numerics.Generic_Elementary_Functions (Real); -- use math; package Hessen is new Hessenberg (Real, Index, Matrix); -- use Hessen; -- Create a package of test matrices: package Square_Matrices is new Test_Matrices (Real, Index, Matrix); use Square_Matrices; package rio is new Float_IO(Real); use rio; --subtype Real_e is Real; -- general case, works fine type Real_e is digits 18; -- 18 ok on intel package Math_e is new Ada.Numerics.Generic_Elementary_Functions (Real_e); use Math_e; type Matrix_e is array(Index, Index) of Real_e; Min_Exp_e : constant Integer := Real_e'Machine_Emin; Min_Allowed_Real_e : constant Real_e := 2.0**(Min_Exp_e - Min_Exp_e/16); -- Q * H * Q' function Product (Q, H : in Matrix; Starting_Col : in Index; Final_Col : in Index) return Matrix_e is E, Result : Matrix_e := (others => (others => 0.0)); Sum : Real_e; begin for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop Sum := +0.0; for k in Starting_Col .. Final_Col loop Sum := Sum + Real_e (Q(Row, k)) * Real_e (H(k, Col)); end loop; E (Row, Col) := Sum; end loop; end loop; for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop Sum := +0.0; for k in Starting_Col .. Final_Col loop Sum := Sum + E(Row, k) * Real_e (Q(Col, k)); -- Q_transpose end loop; Result (Row, Col) := Sum; if Sum'valid = false then put ("!!!!"); end if; end loop; end loop; return Result; end Product; -------------------- -- Frobenius_Norm -- -------------------- function Frobenius_Norm (A : in Matrix_e; Starting_Col : in Index; Final_Col : in Index) return Real_e is Max_A_Val : Real_e := +0.0; Sum, Scaling, tmp : Real_e := +0.0; begin Max_A_Val := +0.0; for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop if Max_A_Val < Abs A(Row, Col) then Max_A_Val := Abs A(Row, Col); end if; end loop; end loop; Max_A_Val := Max_A_Val + Min_Allowed_Real_e; Scaling := +1.0 / Max_A_Val; Sum := +0.0; for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop tmp := Scaling * A(Row, Col); Sum := Sum + tmp * tmp; end loop; end loop; return Sqrt (Sum) * Max_A_Val; end Frobenius_Norm; ---------------------------- -- Error_in_Decomposition -- ---------------------------- -- rough estimate, relative err. procedure Error_in_Decomposition (A : in Matrix; -- A_true U, H : in Matrix; Starting_Col : in Index; Final_Col : in Index; Max_Error : out Real) is Err : Real_e := 0.0; eA, D : Matrix_e; begin D := Product (U, H, Starting_Col, Final_Col); -- D = U * H * U' -- reuse D as D = A - U * H * U' for r in Starting_Col .. Final_Col loop for c in Starting_Col .. Final_Col loop eA(r, c) := Real_e (A(r, c)); D(r, c) := D(r, c) - eA(r, c); end loop; end loop; -- Want Err = ||A - U * H * U'|| / ||A||: Err := Frobenius_Norm (D, Starting_Col, Final_Col) / (Frobenius_Norm (eA, Starting_Col, Final_Col) + Min_Allowed_Real_e); Max_Error := Real (Err); end Error_in_Decomposition; ----------- -- Pause -- ----------- procedure Pause (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9 : string := "") is Continue : Character := ' '; begin new_line; if S0 /= "" then put_line (S0); end if; if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; if S8 /= "" then put_line (S8); end if; if S9 /= "" then put_line (S9); end if; new_line; begin put ("Type a character to continue: "); get_immediate (Continue); exception when others => null; end; end pause; x, Max_Error : Real := 0.0; A_true, A : Matrix := (others => (others => 0.0)); U : Matrix := (others => (others => 0.0)); N : constant Integer := Integer(Final_Col) - Integer(Starting_Col) + 1; begin Pause( "Testing Hessenberg decomposition of matrix A.", "Error is estimated by measuring", " ", " ||Q * A_hessenberg * Q' - A|| / ||A||", " ", "where ||M|| is the norm of matrix M. If 15 digit Reals are used and if", "all goes well, then expect the error to be a few parts per 10**15." ); new_line(2); put ("More padding = "); put (Unsigned_32'Image(more_padding)); new_line(2); put ("Testing Hessenberg on the following"); put (Integer'Image (N)); put (" x"); put (Integer'Image (N)); put (" matrices:"); new_line(1); for Chosen_Matrix in Matrix_Id loop --for Chosen_Matrix in pas_fib .. pas_fib loop --for Chosen_Matrix in vandermonde .. companion_0 loop --for Chosen_Matrix in vandermonde .. vandermonde loop --for Chosen_Matrix in companion_1 .. companion_1 loop --for Chosen_Matrix in clustered .. clustered loop --for Chosen_Matrix in fiedler_1 .. fiedler_1 loop --for Chosen_Matrix in laguerre .. laguerre loop Square_Matrices.Init_Matrix (A, Chosen_Matrix, Starting_Col, Final_Col); --Transpose (A); for r in Starting_Col .. Final_Col loop for c in Starting_Col .. Final_Col loop A(r, c) := A(r, c) + 1.123e-7; end loop; end loop; A_true := A; -- Save original A -- A_hess = Q_tr * A_true * Q. -- -- A_true = Q * A_hess * Q_tr. Hessen.Upper_Hessenberg (A => A, -- A is replaced with: A_hessenberg Q => U, -- A_true = U * A_hessenberg * U_transpose Starting_Col => Starting_Col, Final_Col => Final_Col, Initial_Q => Hessen.Identity); x := x + A(1,1) + U(1,1); Error_in_Decomposition (A_true, U, A, -- A should be hess by now Starting_Col, Final_Col, Max_Error); new_line; put ("Error in decomposition ~"); put (Max_Error); put (" for matrix "); put (Matrix_id'Image(Chosen_Matrix)); end loop; new_line; put (x); end hess_tst_1;
reznikmm/matreshka
Ada
4,001
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.Smil_Accumulate_Attributes; package Matreshka.ODF_Smil.Accumulate_Attributes is type Smil_Accumulate_Attribute_Node is new Matreshka.ODF_Smil.Abstract_Smil_Attribute_Node and ODF.DOM.Smil_Accumulate_Attributes.ODF_Smil_Accumulate_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Smil_Accumulate_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Smil_Accumulate_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Smil.Accumulate_Attributes;
wildbartty/dumb
Ada
514
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Latin_1; with Ada.Calendar; use Ada.Calendar; with Gnat.Calendar.Time_Io; procedure Dumb is Start : Time := clock; Finish : Time; Total : Duration; begin for I in Long_Integer range 0 .. 2**32 loop if I mod 1000000 = 0 then Ada.Text_IO.Put_line(I'Image); end if; end loop; Finish := Clock; Total := Finish - Start; Ada.Text_Io.Put_Line("It took " & Total'image & " seconds to run the Dumb™ benchmark"); end Dumb;
reznikmm/matreshka
Ada
3,953
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.Meta_Date_Attributes; package Matreshka.ODF_Meta.Date_Attributes is type Meta_Date_Attribute_Node is new Matreshka.ODF_Meta.Abstract_Meta_Attribute_Node and ODF.DOM.Meta_Date_Attributes.ODF_Meta_Date_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Meta_Date_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Meta_Date_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Meta.Date_Attributes;
melwyncarlo/ProjectEuler
Ada
1,599
adb
with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A018 is use Ada.Integer_Text_IO; Triangle : array (Integer range 1 .. 15, Integer range 1 .. 15) of Integer := ((75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (17, 47, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (18, 35, 87, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (20, 4, 82, 47, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (19, 1, 23, 75, 3, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0), (88, 2, 77, 73, 7, 63, 67, 0, 0, 0, 0, 0, 0, 0, 0), (99, 65, 4, 28, 6, 16, 70, 92, 0, 0, 0, 0, 0, 0, 0), (41, 41, 26, 56, 83, 40, 80, 70, 33, 0, 0, 0, 0, 0, 0), (41, 48, 72, 33, 47, 32, 37, 16, 94, 29, 0, 0, 0, 0, 0), (53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14, 0, 0, 0, 0), (70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57, 0, 0, 0), (91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48, 0, 0), (63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31, 0), (4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23)); begin for I in reverse 1 .. 14 loop for J in 1 .. I loop if Triangle (I + 1, J) >= Triangle (I + 1, J + 1) then Triangle (I, J) := Triangle (I, J) + Triangle (I + 1, J); else Triangle (I, J) := Triangle (I, J) + Triangle (I + 1, J + 1); end if; end loop; end loop; Put (Triangle (1, 1), Width => 0); end A018;
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.Font_Family_Generic_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Font_Family_Generic_Attribute_Node is begin return Self : Style_Font_Family_Generic_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_Font_Family_Generic_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Font_Family_Generic_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Font_Family_Generic_Attribute, Style_Font_Family_Generic_Attribute_Node'Tag); end Matreshka.ODF_Style.Font_Family_Generic_Attributes;
fnarenji/BoiteMaker
Ada
531
ads
package halfbox_info is type halfbox_info_t is record -- longueur de la demi boite length : integer; -- largeur de la demi boite width : integer; -- hauteur de la demi boite height : integer; -- epaisseur des planches thickness : integer; -- longueur des queues queue_length : integer; end record; function to_string (halfbox_info : halfbox_info_t) return string; end halfbox_info;
zhmu/ananas
Ada
19,227
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S -- -- -- -- B o d y -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Aux_Generic_Float; package body Ada.Numerics.Generic_Complex_Types is package Aux is new Ada.Numerics.Aux_Generic_Float (Real); subtype R is Real'Base; Two_Pi : constant R := R (2.0) * Pi; Half_Pi : constant R := Pi / R (2.0); --------- -- "*" -- --------- function "*" (Left, Right : Complex) return Complex is Scale : constant R := R (R'Machine_Radix) ** ((R'Machine_Emax - 1) / 2); -- In case of overflow, scale the operands by the largest power of the -- radix (to avoid rounding error), so that the square of the scale does -- not overflow itself. X : R; Y : R; begin X := Left.Re * Right.Re - Left.Im * Right.Im; Y := Left.Re * Right.Im + Left.Im * Right.Re; -- If either component overflows, try to scale (skip in fast math mode) if not Standard'Fast_Math then -- Note that the test below is written as a negation. This is to -- account for the fact that X and Y may be NaNs, because both of -- their operands could overflow. Given that all operations on NaNs -- return false, the test can only be written thus. if not (abs (X) <= R'Last) then pragma Annotate (CodePeer, Intentional, "test always false", "test for infinity"); X := Scale**2 * ((Left.Re / Scale) * (Right.Re / Scale) - (Left.Im / Scale) * (Right.Im / Scale)); end if; if not (abs (Y) <= R'Last) then pragma Annotate (CodePeer, Intentional, "test always false", "test for infinity"); Y := Scale**2 * ((Left.Re / Scale) * (Right.Im / Scale) + (Left.Im / Scale) * (Right.Re / Scale)); end if; end if; return (X, Y); end "*"; function "*" (Left, Right : Imaginary) return Real'Base is begin return -(R (Left) * R (Right)); end "*"; function "*" (Left : Complex; Right : Real'Base) return Complex is begin return Complex'(Left.Re * Right, Left.Im * Right); end "*"; function "*" (Left : Real'Base; Right : Complex) return Complex is begin return (Left * Right.Re, Left * Right.Im); end "*"; function "*" (Left : Complex; Right : Imaginary) return Complex is begin return Complex'(-(Left.Im * R (Right)), Left.Re * R (Right)); end "*"; function "*" (Left : Imaginary; Right : Complex) return Complex is begin return Complex'(-(R (Left) * Right.Im), R (Left) * Right.Re); end "*"; function "*" (Left : Imaginary; Right : Real'Base) return Imaginary is begin return Left * Imaginary (Right); end "*"; function "*" (Left : Real'Base; Right : Imaginary) return Imaginary is begin return Imaginary (Left * R (Right)); end "*"; ---------- -- "**" -- ---------- function "**" (Left : Complex; Right : Integer) return Complex is Result : Complex := (1.0, 0.0); Factor : Complex := Left; Exp : Integer := 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. For positive exponents we -- multiply the result by this factor, for negative exponents, we -- divide by this factor. if Exp >= 0 then -- For a positive exponent, if we get a constraint error during -- this loop, it is an overflow, and the constraint error will -- simply be passed on to the caller. while Exp /= 0 loop if Exp rem 2 /= 0 then Result := Result * Factor; end if; Factor := Factor * Factor; Exp := Exp / 2; end loop; return Result; else -- Exp < 0 then -- For the negative exponent case, a constraint error during this -- calculation happens if Factor gets too large, and the proper -- response is to return 0.0, since what we essentially have is -- 1.0 / infinity, and the closest model number will be zero. begin while Exp /= 0 loop if Exp rem 2 /= 0 then Result := Result * Factor; end if; Factor := Factor * Factor; Exp := Exp / 2; end loop; return R'(1.0) / Result; exception when Constraint_Error => return (0.0, 0.0); end; end if; end "**"; function "**" (Left : Imaginary; Right : Integer) return Complex is M : constant R := R (Left) ** Right; begin case Right mod 4 is when 0 => return (M, 0.0); when 1 => return (0.0, M); when 2 => return (-M, 0.0); when 3 => return (0.0, -M); when others => raise Program_Error; end case; end "**"; --------- -- "+" -- --------- function "+" (Right : Complex) return Complex is begin return Right; end "+"; function "+" (Left, Right : Complex) return Complex is begin return Complex'(Left.Re + Right.Re, Left.Im + Right.Im); end "+"; function "+" (Right : Imaginary) return Imaginary is begin return Right; end "+"; function "+" (Left, Right : Imaginary) return Imaginary is begin return Imaginary (R (Left) + R (Right)); end "+"; function "+" (Left : Complex; Right : Real'Base) return Complex is begin return Complex'(Left.Re + Right, Left.Im); end "+"; function "+" (Left : Real'Base; Right : Complex) return Complex is begin return Complex'(Left + Right.Re, Right.Im); end "+"; function "+" (Left : Complex; Right : Imaginary) return Complex is begin return Complex'(Left.Re, Left.Im + R (Right)); end "+"; function "+" (Left : Imaginary; Right : Complex) return Complex is begin return Complex'(Right.Re, R (Left) + Right.Im); end "+"; function "+" (Left : Imaginary; Right : Real'Base) return Complex is begin return Complex'(Right, R (Left)); end "+"; function "+" (Left : Real'Base; Right : Imaginary) return Complex is begin return Complex'(Left, R (Right)); end "+"; --------- -- "-" -- --------- function "-" (Right : Complex) return Complex is begin return (-Right.Re, -Right.Im); end "-"; function "-" (Left, Right : Complex) return Complex is begin return (Left.Re - Right.Re, Left.Im - Right.Im); end "-"; function "-" (Right : Imaginary) return Imaginary is begin return Imaginary (-R (Right)); end "-"; function "-" (Left, Right : Imaginary) return Imaginary is begin return Imaginary (R (Left) - R (Right)); end "-"; function "-" (Left : Complex; Right : Real'Base) return Complex is begin return Complex'(Left.Re - Right, Left.Im); end "-"; function "-" (Left : Real'Base; Right : Complex) return Complex is begin return Complex'(Left - Right.Re, -Right.Im); end "-"; function "-" (Left : Complex; Right : Imaginary) return Complex is begin return Complex'(Left.Re, Left.Im - R (Right)); end "-"; function "-" (Left : Imaginary; Right : Complex) return Complex is begin return Complex'(-Right.Re, R (Left) - Right.Im); end "-"; function "-" (Left : Imaginary; Right : Real'Base) return Complex is begin return Complex'(-Right, R (Left)); end "-"; function "-" (Left : Real'Base; Right : Imaginary) return Complex is begin return Complex'(Left, -R (Right)); end "-"; --------- -- "/" -- --------- function "/" (Left, Right : Complex) return Complex is a : constant R := Left.Re; b : constant R := Left.Im; c : constant R := Right.Re; d : constant R := Right.Im; begin if c = 0.0 and then d = 0.0 then raise Constraint_Error; else return Complex'(Re => ((a * c) + (b * d)) / (c ** 2 + d ** 2), Im => ((b * c) - (a * d)) / (c ** 2 + d ** 2)); end if; end "/"; function "/" (Left, Right : Imaginary) return Real'Base is begin return R (Left) / R (Right); end "/"; function "/" (Left : Complex; Right : Real'Base) return Complex is begin return Complex'(Left.Re / Right, Left.Im / Right); end "/"; function "/" (Left : Real'Base; Right : Complex) return Complex is a : constant R := Left; c : constant R := Right.Re; d : constant R := Right.Im; begin return Complex'(Re => (a * c) / (c ** 2 + d ** 2), Im => -((a * d) / (c ** 2 + d ** 2))); end "/"; function "/" (Left : Complex; Right : Imaginary) return Complex is a : constant R := Left.Re; b : constant R := Left.Im; d : constant R := R (Right); begin return (b / d, -(a / d)); end "/"; function "/" (Left : Imaginary; Right : Complex) return Complex is b : constant R := R (Left); c : constant R := Right.Re; d : constant R := Right.Im; begin return (Re => b * d / (c ** 2 + d ** 2), Im => b * c / (c ** 2 + d ** 2)); end "/"; function "/" (Left : Imaginary; Right : Real'Base) return Imaginary is begin return Imaginary (R (Left) / Right); end "/"; function "/" (Left : Real'Base; Right : Imaginary) return Imaginary is begin return Imaginary (-(Left / R (Right))); end "/"; --------- -- "<" -- --------- function "<" (Left, Right : Imaginary) return Boolean is begin return R (Left) < R (Right); end "<"; ---------- -- "<=" -- ---------- function "<=" (Left, Right : Imaginary) return Boolean is begin return R (Left) <= R (Right); end "<="; --------- -- ">" -- --------- function ">" (Left, Right : Imaginary) return Boolean is begin return R (Left) > R (Right); end ">"; ---------- -- ">=" -- ---------- function ">=" (Left, Right : Imaginary) return Boolean is begin return R (Left) >= R (Right); end ">="; ----------- -- "abs" -- ----------- function "abs" (Right : Imaginary) return Real'Base is begin return abs R (Right); end "abs"; -------------- -- Argument -- -------------- function Argument (X : Complex) return Real'Base is a : constant R := X.Re; b : constant R := X.Im; arg : R; begin if b = 0.0 then if a >= 0.0 then return 0.0; else return R'Copy_Sign (Pi, b); end if; elsif a = 0.0 then if b >= 0.0 then return Half_Pi; else return -Half_Pi; end if; else arg := Aux.Atan (abs (b / a)); if a > 0.0 then if b > 0.0 then return arg; else -- b < 0.0 return -arg; end if; else -- a < 0.0 if b >= 0.0 then return Pi - arg; else -- b < 0.0 return -(Pi - arg); end if; end if; end if; exception when Constraint_Error => if b > 0.0 then return Half_Pi; else return -Half_Pi; end if; end Argument; function Argument (X : Complex; Cycle : Real'Base) return Real'Base is begin if Cycle > 0.0 then return Argument (X) * Cycle / Two_Pi; else raise Argument_Error; end if; end Argument; ---------------------------- -- Compose_From_Cartesian -- ---------------------------- function Compose_From_Cartesian (Re, Im : Real'Base) return Complex is begin return (Re, Im); end Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real'Base) return Complex is begin return (Re, 0.0); end Compose_From_Cartesian; function Compose_From_Cartesian (Im : Imaginary) return Complex is begin return (0.0, R (Im)); end Compose_From_Cartesian; ------------------------ -- Compose_From_Polar -- ------------------------ function Compose_From_Polar ( Modulus, Argument : Real'Base) return Complex is begin if Modulus = 0.0 then return (0.0, 0.0); else return (Modulus * Aux.Cos (Argument), Modulus * Aux.Sin (Argument)); end if; end Compose_From_Polar; function Compose_From_Polar ( Modulus, Argument, Cycle : Real'Base) return Complex is Arg : Real'Base; begin if Modulus = 0.0 then return (0.0, 0.0); elsif Cycle > 0.0 then if Argument = 0.0 then return (Modulus, 0.0); elsif Argument = Cycle / 4.0 then return (0.0, Modulus); elsif Argument = Cycle / 2.0 then return (-Modulus, 0.0); elsif Argument = 3.0 * Cycle / R (4.0) then return (0.0, -Modulus); else Arg := Two_Pi * Argument / Cycle; return (Modulus * Aux.Cos (Arg), Modulus * Aux.Sin (Arg)); end if; else raise Argument_Error; end if; end Compose_From_Polar; --------------- -- Conjugate -- --------------- function Conjugate (X : Complex) return Complex is begin return Complex'(X.Re, -X.Im); end Conjugate; -------- -- Im -- -------- function Im (X : Complex) return Real'Base is begin return X.Im; end Im; function Im (X : Imaginary) return Real'Base is begin return R (X); end Im; ------------- -- Modulus -- ------------- function Modulus (X : Complex) return Real'Base is Re2, Im2 : R; begin begin Re2 := X.Re ** 2; -- To compute (a**2 + b**2) ** (0.5) when a**2 may be out of bounds, -- compute a * (1 + (b/a) **2) ** (0.5). On a machine where the -- squaring does not raise constraint_error but generates infinity, -- we can use an explicit comparison to determine whether to use -- the scaling expression. -- The scaling expression is computed in double format throughout -- in order to prevent inaccuracies on machines where not all -- immediate expressions are rounded, such as PowerPC. -- ??? same weird test, why not Re2 > R'Last ??? if not (Re2 <= R'Last) then raise Constraint_Error; end if; exception when Constraint_Error => pragma Assert (X.Re /= 0.0); return R (abs (X.Re)) * Aux.Sqrt (1.0 + (R (X.Im) / R (X.Re)) ** 2); end; begin Im2 := X.Im ** 2; -- ??? same weird test if not (Im2 <= R'Last) then raise Constraint_Error; end if; exception when Constraint_Error => pragma Assert (X.Im /= 0.0); return R (abs (X.Im)) * Aux.Sqrt (1.0 + (R (X.Re) / R (X.Im)) ** 2); end; -- Now deal with cases of underflow. If only one of the squares -- underflows, return the modulus of the other component. If both -- squares underflow, use scaling as above. if Re2 = 0.0 then if X.Re = 0.0 then return abs (X.Im); elsif Im2 = 0.0 then if X.Im = 0.0 then return abs (X.Re); else if abs (X.Re) > abs (X.Im) then return R (abs (X.Re)) * Aux.Sqrt (1.0 + (R (X.Im) / R (X.Re)) ** 2); else return R (abs (X.Im)) * Aux.Sqrt (1.0 + (R (X.Re) / R (X.Im)) ** 2); end if; end if; else return abs (X.Im); end if; elsif Im2 = 0.0 then return abs (X.Re); -- In all other cases, the naive computation will do else return Aux.Sqrt (Re2 + Im2); end if; end Modulus; -------- -- Re -- -------- function Re (X : Complex) return Real'Base is begin return X.Re; end Re; ------------ -- Set_Im -- ------------ procedure Set_Im (X : in out Complex; Im : Real'Base) is begin X.Im := Im; end Set_Im; procedure Set_Im (X : out Imaginary; Im : Real'Base) is begin X := Imaginary (Im); end Set_Im; ------------ -- Set_Re -- ------------ procedure Set_Re (X : in out Complex; Re : Real'Base) is begin X.Re := Re; end Set_Re; end Ada.Numerics.Generic_Complex_Types;
AdaCore/training_material
Ada
1,302
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package rdseedintrin_h is -- Copyright (C) 2012-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC 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, or (at your option) -- any later version. -- GCC 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. -- 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/>. -- skipped func _rdseed16_step -- skipped func _rdseed32_step -- skipped func _rdseed64_step end rdseedintrin_h;
charlie5/cBound
Ada
1,687
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_set_clip_rectangles_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; ordering : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; gc : aliased xcb.xcb_gcontext_t; clip_x_origin : aliased Interfaces.Integer_16; clip_y_origin : aliased Interfaces.Integer_16; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_set_clip_rectangles_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_set_clip_rectangles_request_t.Item, Element_Array => xcb.xcb_set_clip_rectangles_request_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_set_clip_rectangles_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_set_clip_rectangles_request_t.Pointer, Element_Array => xcb.xcb_set_clip_rectangles_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_set_clip_rectangles_request_t;
Fabien-Chouteau/Ada_Drivers_Library
Ada
25,076
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of 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 Bitmap_Color_Conversion; use Bitmap_Color_Conversion; package body Soft_Drawing_Bitmap is subtype Dispatch is Soft_Drawing_Bitmap_Buffer'Class; ---------------- -- Set_Source -- ---------------- overriding procedure Set_Source (Buffer : in out Soft_Drawing_Bitmap_Buffer; ARGB : Bitmap_Color) is begin Dispatch (Buffer).Set_Source (Bitmap_Color_To_Word (Dispatch (Buffer).Color_Mode, ARGB)); end Set_Source; ------------ -- Source -- ------------ overriding function Source (Buffer : Soft_Drawing_Bitmap_Buffer) return Bitmap_Color is begin return Word_To_Bitmap_Color (Dispatch (Buffer).Color_Mode, Dispatch (Buffer).Source); end Source; --------------- -- Set_Pixel -- --------------- overriding procedure Set_Pixel (Buffer : in out Soft_Drawing_Bitmap_Buffer; Pt : Point; Color : Bitmap_Color) is begin Dispatch (Buffer).Set_Source (Color); Dispatch (Buffer).Set_Pixel (Pt); end Set_Pixel; --------------- -- Set_Pixel -- --------------- overriding procedure Set_Pixel (Buffer : in out Soft_Drawing_Bitmap_Buffer; Pt : Point; Native : UInt32) is begin Dispatch (Buffer).Set_Source (Native); Dispatch (Buffer).Set_Pixel (Pt); end Set_Pixel; overriding function Pixel (Buffer : Soft_Drawing_Bitmap_Buffer; Pt : Point) return Bitmap_Color is (Word_To_Bitmap_Color (Dispatch (Buffer).Color_Mode, Dispatch (Buffer).Pixel (Pt))); --------------- -- Draw_Line -- --------------- overriding procedure Draw_Line (Buffer : in out Soft_Drawing_Bitmap_Buffer; Start, Stop : Point; Thickness : Natural := 1; Fast : Boolean := True) is DX : constant Float := abs Float (Stop.X - Start.X); DY : constant Float := abs Float (Stop.Y - Start.Y); Err : Float; X : Natural := Start.X; Y : Natural := Start.Y; Step_X : Integer := 1; Step_Y : Integer := 1; procedure Draw_Point (P : Point) with Inline; ---------------- -- Draw_Point -- ---------------- procedure Draw_Point (P : Point) is begin if Thickness /= 1 then if not Fast then Dispatch (Buffer). Fill_Circle (Center => P, Radius => Thickness / 2); else Dispatch (Buffer).Fill_Rect (((P.X - (Thickness / 2), P.Y - (Thickness / 2)), Thickness, Thickness)); end if; else Dispatch (Buffer).Set_Pixel ((P.X, P.Y)); end if; end Draw_Point; begin if Start.X > Stop.X then Step_X := -1; end if; if Start.Y > Stop.Y then Step_Y := -1; end if; if DX > DY then Err := DX / 2.0; while X /= Stop.X loop Draw_Point ((X, Y)); Err := Err - DY; if Err < 0.0 then Y := Y + Step_Y; Err := Err + DX; end if; X := X + Step_X; end loop; else Err := DY / 2.0; while Y /= Stop.Y loop Draw_Point ((X, Y)); Err := Err - DX; if Err < 0.0 then X := X + Step_X; Err := Err + DY; end if; Y := Y + Step_Y; end loop; end if; Draw_Point ((X, Y)); end Draw_Line; ---------- -- Fill -- ---------- overriding procedure Fill (Buffer : in out Soft_Drawing_Bitmap_Buffer) is begin for Y in 0 .. Dispatch (Buffer).Height - 1 loop for X in 0 .. Dispatch (Buffer).Width - 1 loop Dispatch (Buffer).Set_Pixel ((X, Y)); end loop; end loop; end Fill; --------------- -- Fill_Rect -- --------------- overriding procedure Fill_Rect (Buffer : in out Soft_Drawing_Bitmap_Buffer; Area : Rect) is begin for Y0 in Area.Position.Y .. Area.Position.Y + Area.Height - 1 loop for X0 in Area.Position.X .. Area.Position.X + Area.Width - 1 loop Dispatch (Buffer).Set_Pixel ((X0, Y0)); end loop; end loop; end Fill_Rect; --------------- -- Copy_Rect -- --------------- overriding procedure Copy_Rect (Src_Buffer : Bitmap_Buffer'Class; Src_Pt : Point; Dst_Buffer : in out Soft_Drawing_Bitmap_Buffer; Dst_Pt : Point; Bg_Buffer : Bitmap_Buffer'Class; Bg_Pt : Point; Width : Natural; Height : Natural; Synchronous : Boolean) is begin raise Constraint_Error with "Not implemented yet."; end Copy_Rect; --------------- -- Copy_Rect -- --------------- overriding procedure Copy_Rect (Src_Buffer : Bitmap_Buffer'Class; Src_Pt : Point; Dst_Buffer : in out Soft_Drawing_Bitmap_Buffer; Dst_Pt : Point; Width : Natural; Height : Natural; Synchronous : Boolean) is pragma Unreferenced (Synchronous); Pix : Bitmap_Color; begin if Src_Pt.X + Width > Src_Buffer.Width or else Src_Pt.Y + Height > Src_Buffer.Height then raise Constraint_Error with "invalid copy area for source bitmap"; end if; if Dst_Pt.X + Width > Dispatch (Dst_Buffer).Width or else Dst_Pt.Y + Height > Dispatch (Dst_Buffer).Height then raise Constraint_Error with "invalid copy area for destination bitmap"; end if; for X in 0 .. Width - 1 loop for Y in 0 .. Height - 1 loop Pix := Src_Buffer.Pixel (Src_Pt + (X, Y)); Dispatch (Dst_Buffer).Set_Source (Pix); Dispatch (Dst_Buffer).Set_Pixel (Dst_Pt + (X, Y)); end loop; end loop; end Copy_Rect; --------------------- -- Copy_Rect_Blend -- --------------------- overriding procedure Copy_Rect_Blend (Src_Buffer : Soft_Drawing_Bitmap_Buffer; Src_Pt : Point; Dst_Buffer : in out Bitmap_Buffer'Class; Dst_Pt : Point; Width : Natural; Height : Natural; Synchronous : Boolean) is begin Copy_Rect (Src_Buffer => Dispatch (Src_Buffer), Src_Pt => Src_Pt, Dst_Buffer => Dst_Buffer, Dst_Pt => Dst_Pt, Bg_Buffer => Dst_Buffer, Bg_Pt => Dst_Pt, Width => Width, Height => Height, Synchronous => Synchronous); end Copy_Rect_Blend; ------------------------ -- Draw_Vertical_Line -- ------------------------ overriding procedure Draw_Vertical_Line (Buffer : in out Soft_Drawing_Bitmap_Buffer; Pt : Point; Height : Integer) is begin Fill_Rect (Dispatch (Buffer), (Position => Pt, Width => 1, Height => Height)); end Draw_Vertical_Line; -------------------------- -- Draw_Horizontal_Line -- -------------------------- overriding procedure Draw_Horizontal_Line (Buffer : in out Soft_Drawing_Bitmap_Buffer; Pt : Point; Width : Integer) is begin Fill_Rect (Dispatch (Buffer), (Position => Pt, Width => Width, Height => 1)); end Draw_Horizontal_Line; --------------- -- Draw_Rect -- --------------- overriding procedure Draw_Rect (Buffer : in out Soft_Drawing_Bitmap_Buffer; Area : Rect; Thickness : Natural := 1) is X0, Y0, X1, Y1 : Natural; begin X0 := Area.Position.X; Y0 := Area.Position.Y; X1 := Area.Position.X + Area.Width - 1; Y1 := Area.Position.Y + Area.Height - 1; Dispatch (Buffer).Fill_Rect ((Position => (X0 - Thickness / 2, Y0), Width => Thickness, Height => Area.Height + Thickness / 2)); Dispatch (Buffer).Fill_Rect ((Position => (X1 - Thickness / 2, Y0), Width => Thickness, Height => Area.Height + Thickness / 2)); Dispatch (Buffer).Fill_Rect ((Position => (X0, Y0 - Thickness / 2), Width => Area.Width + Thickness / 2, Height => Thickness)); Dispatch (Buffer).Fill_Rect ((Position => (X0, Y1 - Thickness / 2), Width => Area. Width + Thickness / 2, Height => Thickness)); end Draw_Rect; ----------------------- -- Draw_Rounded_Rect -- ----------------------- overriding procedure Draw_Rounded_Rect (Buffer : in out Soft_Drawing_Bitmap_Buffer; Area : Rect; Radius : Natural; Thickness : Natural := 1) is F : Integer := 1 - Radius; ddF_X : Integer := 0; ddF_Y : Integer := (-2) * Radius; X0 : Integer := 0; Y0 : Integer := Radius; Center_Top : constant Natural := Area.Position.Y + Radius; Center_Bot : constant Natural := Area.Position.Y + Area.Height - 1 - Radius; Center_Lft : constant Natural := Area.Position.X + Radius; Center_Rgt : constant Natural := Area.Position.X + Area.Width - 1 - Radius; procedure Draw_Point (X, Y : Natural) with Inline; ---------------- -- Draw_Point -- ---------------- procedure Draw_Point (X, Y : Natural) is begin if Thickness /= 1 then Dispatch (Buffer).Fill_Rect ((Position => (X - (Thickness / 2), Y - (Thickness / 2)), Width => Thickness, Height => Thickness)); else Dispatch (Buffer).Set_Pixel ((X, Y)); end if; end Draw_Point; begin if Radius = 0 then Draw_Rect (Buffer, Area, Thickness); return; end if; Dispatch (Buffer).Fill_Rect ((Position => (Area.Position.X - Thickness / 2, Area.Position.Y + Radius), Width => Thickness, Height => Area.Height - 2 * Radius)); Dispatch (Buffer).Fill_Rect ((Position => (Area.Position.X + Area.Width - Thickness / 2 - 1, Area.Position.Y + Radius), Width => Thickness, Height => Area.Height - 2 * Radius)); Dispatch (Buffer).Fill_Rect ((Position => (Area.Position.X + Radius, Area.Position.Y - Thickness / 2), Width => Area.Width - 2 * Radius, Height => Thickness)); Dispatch (Buffer).Fill_Rect ((Position => (Area.Position.X + Radius, Area.Position.Y + Area.Height - Thickness / 2 - 1), Width => Area.Width - 2 * Radius, Height => Thickness)); while X0 < Y0 loop if F >= 0 then Y0 := Y0 - 1; ddF_Y := ddF_Y + 2; F := F + ddF_Y; end if; X0 := X0 + 1; ddF_X := ddF_X + 2; F := F + ddF_X + 1; Draw_Point (Center_Rgt + X0, Center_Bot + Y0); Draw_Point (Center_Lft - X0, Center_Bot + Y0); Draw_Point (Center_Rgt + X0, Center_Top - Y0); Draw_Point (Center_Lft - X0, Center_Top - Y0); Draw_Point (Center_Rgt + Y0, Center_Bot + X0); Draw_Point (Center_Lft - Y0, Center_Bot + X0); Draw_Point (Center_Rgt + Y0, Center_Top - X0); Draw_Point (Center_Lft - Y0, Center_Top - X0); end loop; end Draw_Rounded_Rect; ----------------------- -- Fill_Rounded_Rect -- ----------------------- overriding procedure Fill_Rounded_Rect (Buffer : in out Soft_Drawing_Bitmap_Buffer; Area : Rect; Radius : Natural) is F : Integer := 1 - Radius; ddF_X : Integer := 0; ddF_Y : Integer := (-2) * Radius; X0 : Integer := 0; Y0 : Integer := Radius; Center_Top : constant Natural := Area.Position.Y + Radius; Center_Bot : constant Natural := Area.Position.Y + Area.Height - 1 - Radius; Center_Lft : constant Natural := Area.Position.X + Radius; begin if Radius = 0 then Dispatch (Buffer).Fill_Rect (Area'Update (Position => (X0, Y0))); return; end if; Dispatch (Buffer).Fill_Rect ((Position => (Area.Position.X, Center_Top), Width => Area.Width, Height => Area.Height - 2 * Radius)); while X0 < Y0 loop if F >= 0 then Y0 := Y0 - 1; ddF_Y := ddF_Y + 2; F := F + ddF_Y; end if; X0 := X0 + 1; ddF_X := ddF_X + 2; F := F + ddF_X + 1; Dispatch (Buffer).Draw_Horizontal_Line ((Center_Lft - X0, Center_Bot + Y0), Area.Width - 2 * Radius + 2 * X0); Dispatch (Buffer).Draw_Horizontal_Line ((Center_Lft - X0, Center_Top - Y0), Area.Width - 2 * Radius + 2 * X0); Dispatch (Buffer).Draw_Horizontal_Line ((Center_Lft - Y0, Center_Bot + X0), Area.Width - 2 * Radius + 2 * Y0); Dispatch (Buffer).Draw_Horizontal_Line ((Center_Lft - Y0, Center_Top - X0), Area.Width - 2 * Radius + 2 * Y0); end loop; end Fill_Rounded_Rect; -- http://rosettacode.org/wiki/Bitmap/Midpoint_circle_algorithm ----------------- -- Draw_Circle -- ----------------- overriding procedure Draw_Circle (Buffer : in out Soft_Drawing_Bitmap_Buffer; Center : Point; Radius : Natural) is F : Integer := 1 - Radius; ddF_X : Integer := 0; ddF_Y : Integer := (-2) * Radius; X : Integer := 0; Y : Integer := Radius; begin Dispatch (Buffer).Set_Pixel ((Center.X, Center.Y + Radius)); Dispatch (Buffer).Set_Pixel ((Center.X, Center.Y - Radius)); Dispatch (Buffer).Set_Pixel ((Center.X + Radius, Center.Y)); Dispatch (Buffer).Set_Pixel ((Center.X - Radius, Center.Y)); while X < Y loop if F >= 0 then Y := Y - 1; ddF_Y := ddF_Y + 2; F := F + ddF_Y; end if; X := X + 1; ddF_X := ddF_X + 2; F := F + ddF_X + 1; Dispatch (Buffer).Set_Pixel ((Center.X + X, Center.Y + Y)); Dispatch (Buffer).Set_Pixel ((Center.X - X, Center.Y + Y)); Dispatch (Buffer).Set_Pixel ((Center.X + X, Center.Y - Y)); Dispatch (Buffer).Set_Pixel ((Center.X - X, Center.Y - Y)); Dispatch (Buffer).Set_Pixel ((Center.X + Y, Center.Y + X)); Dispatch (Buffer).Set_Pixel ((Center.X - Y, Center.Y + X)); Dispatch (Buffer).Set_Pixel ((Center.X + Y, Center.Y - X)); Dispatch (Buffer).Set_Pixel ((Center.X - Y, Center.Y - X)); end loop; end Draw_Circle; ----------------- -- Fill_Circle -- ----------------- overriding procedure Fill_Circle (Buffer : in out Soft_Drawing_Bitmap_Buffer; Center : Point; Radius : Natural) is Buffer_Width : constant Natural := Dispatch (Buffer).Width; Buffer_Height : constant Natural := Dispatch (Buffer).Height; procedure Draw_Horizontal_Line (X, Y : Integer; Width : Natural); ------------------------ -- Draw_Vertical_Line -- ------------------------ procedure Draw_Vertical_Line (X, Y : Integer; Height : Natural); -------------------------- -- Draw_Horizontal_Line -- -------------------------- procedure Draw_Horizontal_Line (X, Y : Integer; Width : Natural) is X1, W1 : Natural; begin if Width = 0 then return; elsif Y < 0 or else Y >= Buffer_Height then return; elsif X + Width < 0 or else X >= Buffer_Width then return; end if; if X < 0 then X1 := 0; W1 := Width + X; else X1 := X; W1 := Width; end if; if X1 + W1 >= Buffer_Width then W1 := Buffer_Width - X1 - 1; end if; if W1 = 0 then return; end if; Dispatch (Buffer).Fill_Rect (((X1, Y), W1, 1)); end Draw_Horizontal_Line; ------------------------ -- Draw_Vertical_Line -- ------------------------ procedure Draw_Vertical_Line (X, Y : Integer; Height : Natural) is Y1, H1 : Natural; begin if Height = 0 then return; elsif X < 0 or else X >= Buffer_Width then return; elsif Y + Height < 0 or else Y >= Buffer_Height then return; end if; if Y < 0 then Y1 := 0; H1 := Height + Y; else Y1 := Y; H1 := Height; end if; if Y1 + H1 >= Buffer_Height then H1 := Buffer_Height - Y1 - 1; end if; if H1 = 0 then return; end if; Dispatch (Buffer).Fill_Rect (((X, Y1), 1, H1)); end Draw_Vertical_Line; F : Integer := 1 - Radius; ddF_X : Integer := 1; ddF_Y : Integer := -(2 * Radius); X : Integer := 0; Y : Integer := Radius; begin Draw_Vertical_Line (Center.X, Center.Y - Radius, 2 * Radius); Draw_Horizontal_Line (Center.X - Radius, Center.Y, 2 * Radius); while X < Y loop if F >= 0 then Y := Y - 1; ddF_Y := ddF_Y + 2; F := F + ddF_Y; end if; X := X + 1; ddF_X := ddF_X + 2; F := F + ddF_X; Draw_Horizontal_Line (Center.X - X, Center.Y + Y, 2 * X); Draw_Horizontal_Line (Center.X - X, Center.Y - Y, 2 * X); Draw_Horizontal_Line (Center.X - Y, Center.Y + X, 2 * Y); Draw_Horizontal_Line (Center.X - Y, Center.Y - X, 2 * Y); end loop; end Fill_Circle; ------------------------- -- Cubic_Bezier_Points -- ------------------------- procedure Cubic_Bezier_Points (P1, P2, P3, P4 : Point; N : Positive; Points : in out Point_Array) is begin for I in Points'Range loop declare T : constant Float := Float (I) / Float (N); A : constant Float := (1.0 - T)**3; B : constant Float := 3.0 * T * (1.0 - T)**2; C : constant Float := 3.0 * T**2 * (1.0 - T); D : constant Float := T**3; begin Points (I).X := Natural (A * Float (P1.X) + B * Float (P2.X) + C * Float (P3.X) + D * Float (P4.X)); Points (I).Y := Natural (A * Float (P1.Y) + B * Float (P2.Y) + C * Float (P3.Y) + D * Float (P4.Y)); end; end loop; end Cubic_Bezier_Points; --------------------------- -- Binomial_Coefficients -- --------------------------- procedure Binomial_Coefficients (Outputs : in out Natural_Array) is N : constant Integer := Outputs'Length - 1; F : constant Natural := Outputs'First; L : constant Natural := Outputs'Last; X : Natural; begin if N < 0 then return; end if; Outputs (F) := 1; Outputs (L) := 1; for I in 0 .. (N / 2) - 1 loop X := Outputs (F + I) * (N - I) / (I + 1); Outputs (F + I + 1) := X; Outputs (F + N - I - 1) := X; end loop; end Binomial_Coefficients; ------------------- -- Bezier_Points -- ------------------- procedure Bezier_Points (Input_Points : Point_Array; N : Positive; Points : in out Point_Array) is Degree : constant Integer := Input_Points'Last - Input_Points'First; Binomial_Coeffs : Natural_Array (0 .. Degree); Float_X, Float_Y, T, Total_Coeff : Float; ----------- -- Power -- ----------- function Power (A : Float; B : Natural) return Float; function Power (A : Float; B : Natural) return Float is Result : Float := 1.0; Exp : Natural := B; Base : Float := A; begin while Exp /= 0 loop if Exp mod 2 = 1 then Result := Result * Base; end if; Exp := Exp / 2; exit when Exp = 0; Base := Base * Base; end loop; return Result; end Power; begin Binomial_Coefficients (Binomial_Coeffs); for I in Points'Range loop Float_X := 0.0; Float_Y := 0.0; T := Float (I) / Float (N); for K in 0 .. Degree loop Total_Coeff := (Float (Binomial_Coeffs (K)) * Power ((1.0 - T), (Degree - K)) * Power (T, K)); Float_X := Float_X + (Total_Coeff * Float (Input_Points (Input_Points'First + K).X)); Float_Y := Float_Y + (Total_Coeff * Float (Input_Points (Input_Points'First + K).Y)); end loop; Points (I).X := Natural (Float_X); Points (I).Y := Natural (Float_Y); end loop; end Bezier_Points; ------------------ -- Cubic_Bezier -- ------------------ overriding procedure Cubic_Bezier (Buffer : in out Soft_Drawing_Bitmap_Buffer; P1, P2, P3, P4 : Point; N : Positive := 20; Thickness : Natural := 1) is Points : Point_Array (0 .. N); begin Cubic_Bezier_Points (P1, P2, P3, P4, N, Points); for I in Points'First .. Points'Last - 1 loop Dispatch (Buffer).Draw_Line (Points (I), Points (I + 1), Thickness => Thickness); end loop; end Cubic_Bezier; ------------ -- Bezier -- ------------ overriding procedure Bezier (Buffer : in out Soft_Drawing_Bitmap_Buffer; Input_Points : Point_Array; N : Positive := 20; Thickness : Natural := 1) is Points : Point_Array (0 .. N); begin Bezier_Points (Input_Points, N, Points); for I in Points'First .. Points'Last - 1 loop Dispatch (Buffer).Draw_Line (Points (I), Points (I + 1), Thickness => Thickness); end loop; end Bezier; end Soft_Drawing_Bitmap;
jscparker/math_packages
Ada
8,868
ads
-- package pc_2_coeff_20 -- -- Predictor_Rule : Integration_Rule renames Predictor_32_20; -- -- Corrector_Rule : Integration_Rule renames Corrector_33_20; -- -- Final_Step_Corrector : Real renames Final_Step_Corrector_33_20; generic type Real is digits <>; package pc_2_coeff_20 is subtype PC_Rule_Range is Integer range 0..31; type Integration_Rule is array(PC_Rule_Range) of Real; Starting_Id_of_First_Deriv_of_Y : constant PC_Rule_Range := 15; -- Center_Integration Rule, applied to (d/dt)**2 Y, takes a dY/dt here, and -- Integrates it one indice forward. Extrap_Factor: constant Real := 1.0 / 18.4; --using 20 order center integr. Corrector_33_20 : constant Integration_Rule := ( -8.55174773365542810125247903441564880E-4, 1.08799020509215653999792415002138806E-2, -5.98807243948632167226495496188008202E-2, 1.81488244958372219606123531287673514E-1, -3.09797512122888357321010504493372402E-1, 2.34403050273857971510590645531000542E-1, 9.79330522148025227287594602166299163E-2, -2.77633074988893655940917386903055705E-1, -1.68140788180143672682016210371683483E-2, 2.74388089831285514600129857755410670E-1, 2.42092847609618613267021265005431658E-2, -2.66016510267988522967136454952130358E-1, -7.82198779500683939243870921110280431E-2, 2.30528604881633225444771511001426156E-1, 1.32752900227021806218154527276514406E-1, -1.08633881162194363314746581547842899E-1, 1.88212765588327200749334042985019967E-1, 9.95407129402333404744846988537650387E-1, 1.45715395435233336079808363815157167E+0, 1.08867569153654151597403791053467495E+0, 5.68803773336973771436036563831289386E-1, 7.90282029197709581840721356274557683E-1, 1.41312770198894658653930470398104117E+0, 1.30251010240006755023323114993325085E+0, 5.60116554132292653591867459376320719E-1, 6.69718155148611411378976413930281279E-1, 1.59160406112984439522301118168937892E+0, 1.14338340854186182605157194557314430E+0, 1.28871618852683062320854062951279782E-1, 1.89739203673310992720763368551517101E+0, 4.93612805842445046458910141101008804E-1, 1.08617699811391691117663539822936064E+0 ); Final_Step_Corrector_33_20 : constant Real := 5.62189189814215277089068949024263372E-2; Predictor_31_20 : constant Integration_Rule := ( 0.0, 3.71108727678097765120276726234553336E-2, -5.06038283780681331759837219918580977E-1, 3.03190033247460216356241305150918101E+0, -1.02624653725186416859975775449901825E+1, 2.06141703499560139778153446612572425E+1, -2.19764888153009101002691735643159697E+1, 3.13103774290675475015870359794024959E+0, 1.93912629451531651643560470483880988E+1, -1.20519587833962811897580363143414478E+1, -1.62152600610790555528930054173145064E+1, 1.44034717082396648519595462951296246E+1, 1.62644082542022744526141395569760920E+1, -1.39480178119209560443676610096029311E+1, -1.85973168657304870015791067712523361E+1, 1.16857820996661055425682810828858984E+1, 2.22125383601620792778873230835801331E+1, -7.09700161239051889272953492931020167E+0, -2.37739076860647447532838799110126126E+1, 5.25733965636968199667570737237860034E+0, 2.87371707883292842124818226417648031E+1, -1.10196084133390662939033673460655251E+0, -3.01058675313311579880796252087668176E+1, 5.85282658159192545881160005723940358E+0, 3.59569294918921372966362335168302678E+1, -1.84771402800733597472621108139022118E+1, -2.90750967868685422705864101221125547E+1, 5.52922950325299794199805546971515784E+1, -4.06384245478824130835629088322035513E+1, 2.00982837254447949145367808103200651E+1, -4.52219057730644796527546378915980965E+0, 1.88260791529183098023814303683557297E+0 ); Center_Integration_32_20 : constant Integration_Rule := ( 3.15713968194170133919540213875143917E-5, -4.68054008955732353100985646310188096E-4, 3.07872579249862231519513009405313968E-3, -1.15997994611621236175002511977323250E-2, 2.65427741706869908147987953876501056E-2, -3.41143206815192906544786599038747983E-2, 1.20645063820463013734131783866792169E-2, 2.94493218168506239920090546327231263E-2, -3.18445717486473259824967360646315308E-2, -2.50397085225343097687547550717275702E-2, 4.76987615793932385807965774292440943E-2, 3.07886851486023175023595502260427314E-2, -7.38315319596948536351414208989101596E-2, -6.07773034846435767063660851642605318E-2, 1.69131632098663497836012986946412281E-1, 4.18889311481596203289861666823254893E-1, 4.18889311481596203289861666823254893E-1, 1.69131632098663497836012986946412281E-1, -6.07773034846435767063660851642605318E-2, -7.38315319596948536351414208989101596E-2, 3.07886851486023175023595502260427314E-2, 4.76987615793932385807965774292440943E-2, -2.50397085225343097687547550717275702E-2, -3.18445717486473259824967360646315308E-2, 2.94493218168506239920090546327231263E-2, 1.20645063820463013734131783866792169E-2, -3.41143206815192906544786599038747983E-2, 2.65427741706869908147987953876501056E-2, -1.15997994611621236175002511977323250E-2, 3.07872579249862231519513009405313968E-3, -4.68054008955732353100985646310188096E-4, 3.15713968194170133919540213875143917E-5 ); Center_Integration_32_22 : constant Integration_Rule := ( -5.48186298516234652810704051430422655E-6, 9.83867415088779031208187158666710319E-5, -8.07566491514156651234056438130100106E-4, 3.97340757417976466081704231342063697E-3, -1.28356892096129410337836800376618841E-2, 2.76864991077874453604989378001785406E-2, -3.73245825355348862199480292460505598E-2, 2.12653218023217359291463822190892211E-2, 2.13745306335366393296921989209611924E-2, -4.56656788294881115637614729100805322E-2, 3.89437307673685355200946981995831816E-3, 6.22684247056539251232690828593738376E-2, -3.61385003611128933128201417801336908E-2, -9.55657510587708441101932722470146491E-2, 1.33596784912141525960540060966517392E-1, 4.54185521795152227419174766084219910E-1, 4.54185521795152227419174766084219910E-1, 1.33596784912141525960540060966517392E-1, -9.55657510587708441101932722470146491E-2, -3.61385003611128933128201417801336908E-2, 6.22684247056539251232690828593738376E-2, 3.89437307673685355200946981995831816E-3, -4.56656788294881115637614729100805322E-2, 2.13745306335366393296921989209611924E-2, 2.12653218023217359291463822190892211E-2, -3.73245825355348862199480292460505598E-2, 2.76864991077874453604989378001785406E-2, -1.28356892096129410337836800376618841E-2, 3.97340757417976466081704231342063697E-3, -8.07566491514156651234056438130100106E-4, 9.83867415088779031208187158666710319E-5, -5.48186298516234652810704051430422655E-6 ); Center_to_End_Integration_32_20 : constant Integration_Rule := ( -2.86386061369796720288602153765466086E-3, 3.77465669564208701988194199064386183E-2, -2.16918716521626019186490223558167110E-1, 6.95426774390568532091465095269529112E-1, -1.29019469338161323733227504692181277E+0, 1.17298162653774707488654908953634099E+0, 1.37888543617482416082540041836111787E-1, -1.23211215373380283866528411256821590E+0, 3.14045424246911795127273180916596717E-1, 1.17432311655916972040956457499680797E+0, -3.64763399153107025837257593340386960E-1, -1.21280637011119196098904355440304660E+0, 1.82342156243146214443817819223431585E-1, 1.26500802055743604130463842953293533E+0, 2.04988866876595023257807452491015192E-1, -8.92041637190838025750940136713437543E-1, 3.67258034718844737504853759591653078E-1, 2.41065548250948746044603686271139350E+0, 2.01624831177845769971589032829444510E+0, -2.17574984937012348001512229695676207E-1, -3.84187387520669853052532264096051345E-1, 2.08730620069194768113347525743331340E+0, 2.67001607108536140451921505467397790E+0, -2.23523291208105397640505219542850802E-1, -8.00131026645121829127853190651542875E-1, 3.00262104565864983476416014660867486E+0, 2.15056777830019161263448757485324027E+0, -2.61092517941099763297880878634545940E+0, 4.40625889845489387749214282954584149E+0, -9.31878416636917660438034239401347078E-1, 1.82120219150496018217931474409591347E+0, 2.63036006376429618011370957257988852E-1 ); Center_to_End_Integration : Integration_Rule renames Center_to_End_Integration_32_20; Predictor_Rule : Integration_Rule renames Predictor_31_20; Corrector_Rule : Integration_Rule renames Corrector_33_20; Center_Integration : Integration_Rule renames Center_Integration_32_20; Final_Step_Corrector : Real renames Final_Step_Corrector_33_20; end pc_2_coeff_20;
zhmu/ananas
Ada
214
adb
-- { dg-do compile } package body Renaming11 is function F (Arg: Ptr3) return Integer is V : Ptr1 renames Arg.all.all; I : Integer renames V.A(1); begin return I; end; end Renaming11;
reznikmm/matreshka
Ada
4,007
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.Svg_Stroke_Width_Attributes; package Matreshka.ODF_Svg.Stroke_Width_Attributes is type Svg_Stroke_Width_Attribute_Node is new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node and ODF.DOM.Svg_Stroke_Width_Attributes.ODF_Svg_Stroke_Width_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Stroke_Width_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Svg_Stroke_Width_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Svg.Stroke_Width_Attributes;
afrl-rq/OpenUxAS
Ada
3,055
adb
with UxAS.Comms.Transport.ZeroMQ_Fabric; use UxAS.Comms.Transport; with String_Utils; use String_Utils; package body UxAS.Comms.Transport.Receiver.ZeroMQ is ---------------- -- Initialize -- ---------------- procedure Initialize (This : in out ZeroMq_Receiver_Base; Entity_Id : UInt32; Service_Id : UInt32; Socket_Configuration : ZeroMq_Socket_Configuration) is begin -- m_entityId = entityId; This.Entity_Id := Entity_Id; -- m_serviceId = serviceId; This.Service_Id := Service_Id; -- m_entityIdString = std::to_string(entityId); Copy (To_String (Entity_Id), To => This.Entity_Id_String); -- m_serviceIdString = std::to_string(serviceId); Copy (To_String (Service_Id), To => This.Service_Id_String); -- m_zeroMqSocketConfiguration = static_cast<ZeroMqSocketConfiguration&> (zeroMqSocketConfiguration); This.Socket_Configuration := Initialize.Socket_Configuration; -- m_zmqSocket = ZeroMqFabric::getInstance().createSocket(m_zeroMqSocketConfiguration); ZeroMQ_Fabric.Create_Socket (ZeroMQ_Fabric.Instance, Config => This.Socket_Configuration, Result => This.Zmq_Socket); end Initialize; ---------------------------------------- -- Add_Subscription_Address_To_Socket -- ---------------------------------------- overriding procedure Add_Subscription_Address_To_Socket (This : in out ZeroMq_Receiver_Base; Address : String; Result : out Boolean) is begin -- bool isAdded(false); -- if (m_zeroMqSocketConfiguration.m_zmqSocketType == ZMQ_SUB) -- { -- m_zmqSocket->setsockopt(ZMQ_SUBSCRIBE, address.c_str(), address.size()); -- isAdded = true; -- } -- return (isAdded); if This.Socket_Configuration.Zmq_Socket_Type = ZMQ.Sockets.SUB then This.Zmq_Socket.Establish_Message_Filter (Value => Address); Result := True; else Result := False; end if; end Add_Subscription_Address_To_Socket; --------------------------------------------- -- Remove_Subscription_Address_From_Socket -- --------------------------------------------- overriding procedure Remove_Subscription_Address_From_Socket (This : in out ZeroMq_Receiver_Base; Address : String; Result : out Boolean) is begin -- bool isRemoved(false); -- if (m_zeroMqSocketConfiguration.m_zmqSocketType == ZMQ_SUB) -- { -- m_zmqSocket->setsockopt(ZMQ_UNSUBSCRIBE, address.c_str(), address.size()); -- isRemoved = true; -- } -- return (isRemoved); if This.Socket_Configuration.Zmq_Socket_Type = ZMQ.Sockets.SUB then This.Zmq_Socket.Remove_Message_Filter (Value => Address); Result := True; else Result := False; end if; end Remove_Subscription_Address_From_Socket; end UxAS.Comms.Transport.Receiver.ZeroMQ;
flyx/OpenGLAda
Ada
816
adb
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with GL.API; with GL.Enums.Getter; package body GL.Culling is procedure Set_Front_Face (Face : Orientation) renames API.Front_Face; function Front_Face return Orientation is Ret : aliased Orientation; begin API.Get_Orientation (Enums.Getter.Front_Face, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Front_Face; procedure Set_Cull_Face (Selector : Face_Selector) renames API.Cull_Face; function Cull_Face return Face_Selector is Ret : aliased Face_Selector; begin API.Get_Face_Selector (Enums.Getter.Cull_Face_Mode, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Cull_Face; end GL.Culling;
AdaCore/training_material
Ada
313
adb
with Ada.Text_IO; use Ada.Text_IO; package body Protected_Objects is protected body Object is procedure Set (V : Integer) is begin Local := V; end Set; function Get return Integer is begin return Local; end Get; end Object; end Protected_Objects;
reznikmm/matreshka
Ada
4,439
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 Matreshka.DOM_Nodes; with XML.DOM.Attributes.Internals; package body ODF.DOM.Attributes.Draw.Start_Line_Spacing_Horizontal.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Horizontal.Draw_Start_Line_Spacing_Horizontal_Access) return ODF.DOM.Attributes.Draw.Start_Line_Spacing_Horizontal.ODF_Draw_Start_Line_Spacing_Horizontal is begin return (XML.DOM.Attributes.Internals.Create (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Horizontal.Draw_Start_Line_Spacing_Horizontal_Access) return ODF.DOM.Attributes.Draw.Start_Line_Spacing_Horizontal.ODF_Draw_Start_Line_Spacing_Horizontal is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.Draw.Start_Line_Spacing_Horizontal.Internals;
charlie5/aIDE
Ada
6,684
adb
with aIDE.Editor.of_enumeration_literal, AdaM.a_Type.enumeration_literal, Pango.Attributes, gLib.Error, Gtk.Builder, Gtk.Handlers, Ada.Containers; with Pango.Enums; package body aIDE.Editor.of_enumeration_type is use Gtk.Builder, Glib, glib.Error; function on_name_Entry_leave (the_Entry : access Gtk_Entry_Record'Class; Target : in AdaM.a_Type.enumeration_type.view) return Boolean is the_Text : constant String := the_Entry.Get_Text; begin Target.Name_is (the_Text); return False; end on_name_Entry_leave; procedure on_rid_Button_clicked (the_Button : access Gtk_Button_Record'Class; the_Editor : in aIDE.Editor.of_enumeration_type.view) is pragma Unreferenced (the_Editor); begin the_Button.get_Parent.destroy; end on_rid_Button_clicked; package Entry_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Entry_Record, Boolean, AdaM.a_Type.enumeration_type.view); package Button_Callbacks is new Gtk.Handlers.User_Callback (Gtk_Button_Record, aIDE.Editor.of_enumeration_type.view); function on_is_Label_clicked (the_Label : access Gtk_Label_Record'Class; Self : in aIDE.Editor.of_enumeration_type.view) return Boolean is pragma Unreferenced (the_Label); begin Self.Target.add_Literal ("literal"); Self.freshen; return False; end on_is_Label_clicked; package Label_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Label_Record, Boolean, aIDE.Editor.of_enumeration_type.view); package body Forge is function to_Editor (the_Target : in AdaM.a_Type.enumeration_type.view) return View is use AdaM, Glib; Self : constant Editor.of_enumeration_type.view := new Editor.of_enumeration_type.item; the_Builder : Gtk_Builder; Error : aliased GError; Result : Guint; pragma Unreferenced (Result); begin Self.Target := the_Target; Gtk_New (the_Builder); Result := the_Builder.Add_From_File ("glade/editor/enumeration_type_editor.glade", Error'Access); if Error /= null then raise Program_Error with "Error: adam.Editor.of_enumeration_type ~ " & Get_Message (Error); end if; Self.top_Box := gtk_Box (the_Builder.get_Object ("top_Box")); Self.name_Entry := Gtk_Entry (the_Builder.get_Object ("name_Entry")); Self.is_Label := Gtk_Label (the_Builder.get_Object ("is_Label")); Self.literals_Box := gtk_Box (the_Builder.get_Object ("literals_Box")); Self.rid_Button := gtk_Button (the_Builder.get_Object ("rid_Button")); Self.open_parenthesis_Label := Gtk_Label (the_Builder.get_Object ("open_parenthesis_Label")); Self.close_parenthesis_Label := Gtk_Label (the_Builder.get_Object ("close_parenthesis_Label")); Self.name_Entry.Set_Text (+Self.Target.Name); declare use type Ada.Containers.Count_Type; Attributes : Pango.Attributes.Pango_Attr_List := Pango.Attributes.Pango_Attr_List_New; Scale : gDouble := Gdouble (2 * Self.Target.Literals.Length); begin Attributes.Change (pango.Attributes.Attr_Scale_New (Scale)); Self. open_parenthesis_Label.set_Attributes (Attributes); Self.close_parenthesis_Label.set_Attributes (Attributes); -- Self.close_parenthesis_Label.Set_Size_Request (Height => 10); end; Entry_return_Callbacks.connect (Self.name_Entry, "focus-out-event", on_name_Entry_leave'Access, the_Target); Button_Callbacks.Connect (Self.rid_Button, "clicked", on_rid_Button_clicked'Access, Self); Label_return_Callbacks.Connect (Self.is_Label, "button-release-event", on_is_Label_clicked'Access, Self); Self.freshen; return Self; end to_Editor; end Forge; procedure destroy_Callback (Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class) is begin Widget.destroy; end destroy_Callback; overriding procedure freshen (Self : in out Item) is use gtk.Widget; the_Literals : AdaM.a_Type.enumeration_literal.vector renames Self.Target.Literals; literal_Editor : aIDE.Editor.of_enumeration_literal.view; begin Self.literals_Box.Foreach (destroy_Callback'Access); for Each of the_Literals loop literal_Editor := Editor.of_enumeration_literal.Forge.to_Editor (Each, targets_Parent => Self.Target.all'Access); Self.literals_Box.pack_Start (literal_Editor.top_Widget); end loop; declare use type Ada.Containers.Count_Type; Attributes : Pango.Attributes.Pango_Attr_List := Pango.Attributes.Pango_Attr_List_New; Scale : gDouble := Gdouble (2 * Self.Target.Literals.Length); begin Attributes.Change (pango.Attributes.Attr_Scale_New (Scale)); Self. open_parenthesis_Label.set_Attributes (Attributes); Attributes.change (pango.Attributes.Attr_Stretch_New (Stretch => Pango.Enums.Pango_Stretch_Expanded)); -- Self.open_parenthesis_Label.set_Attributes (Attributes); -- Self.open_parenthesis_Label.Set_Size_Request (Height => 10); Self.close_parenthesis_Label.set_Attributes (Attributes); -- Self.close_parenthesis_Label.Set_Size_Request (Height => 10); end; end freshen; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget is begin return gtk.Widget.Gtk_Widget (Self.top_Box); end top_Widget; end aIDE.Editor.of_enumeration_type;
Letractively/ada-ado
Ada
4,443
ads
----------------------------------------------------------------------- -- ADO Mysql Database -- MySQL Database connections -- Copyright (C) 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 Mysql.Mysql; use Mysql.Mysql; package ADO.Drivers.Connections.Mysql is type Mysql_Driver is limited private; -- Initialize the Mysql driver. procedure Initialize; private -- Create a new MySQL connection using the configuration parameters. procedure Create_Connection (D : in out Mysql_Driver; Config : in Configuration'Class; Result : out Database_Connection_Access); type Mysql_Driver is new ADO.Drivers.Connections.Driver with record Id : Natural := 0; end record; -- Deletes the Mysql driver. overriding procedure Finalize (D : in out Mysql_Driver); -- Database connection implementation type Database_Connection is new ADO.Drivers.Connections.Database_Connection with record Name : Unbounded_String := Null_Unbounded_String; Server_Name : Unbounded_String := Null_Unbounded_String; Login_Name : Unbounded_String := Null_Unbounded_String; Password : Unbounded_String := Null_Unbounded_String; Server : Mysql_Access := null; Connected : Boolean := False; -- MySQL autocommit flag Autocommit : Boolean := True; end record; type Database_Connection_Access is access all Database_Connection'Class; -- Get the database driver which manages this connection. overriding function Get_Driver (Database : in Database_Connection) return Driver_Access; overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access; overriding function Create_Statement (Database : in Database_Connection; Query : in String) return Query_Statement_Access; -- Create a delete statement. overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access; -- Create an insert statement. overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access; -- Create an update statement. overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access; -- Start a transaction. overriding procedure Begin_Transaction (Database : in out Database_Connection); -- Commit the current transaction. overriding procedure Commit (Database : in out Database_Connection); -- Rollback the current transaction. overriding procedure Rollback (Database : in out Database_Connection); procedure Execute (Database : in out Database_Connection; SQL : in Query_String); -- Closes the database connection overriding procedure Close (Database : in out Database_Connection); overriding procedure Finalize (Database : in out Database_Connection); -- Load the database schema definition for the current database. overriding procedure Load_Schema (Database : in Database_Connection; Schema : out ADO.Schemas.Schema_Definition); end ADO.Drivers.Connections.Mysql;
reznikmm/matreshka
Ada
3,773
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.Column_Width is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Column_Width_Node) return League.Strings.Universal_String is begin return ODF.Constants.Column_Width_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Column_Width;
charlie5/cBound
Ada
1,809
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_pixel_mapfv_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; pad1 : aliased swig.int8_t_Array (0 .. 3); n : aliased Interfaces.Unsigned_32; datum : aliased xcb.xcb_glx_float32_t; pad2 : aliased swig.int8_t_Array (0 .. 11); end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_pixel_mapfv_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_pixel_mapfv_reply_t.Item, Element_Array => xcb.xcb_glx_get_pixel_mapfv_reply_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_get_pixel_mapfv_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_pixel_mapfv_reply_t.Pointer, Element_Array => xcb.xcb_glx_get_pixel_mapfv_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_pixel_mapfv_reply_t;
clairvoyant/anagram
Ada
9,627
adb
-- Copyright (c) 2010-2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Anagram.Grammars.Tools is --------------- -- Get_First -- --------------- procedure Get_First (Input : Grammar; Value : out Terminal_Set_Per_Production) is Ignore : Non_Terminal_Set_Per_Production (Input.Last_Non_Terminal, Input.Last_Production); begin Get_First (Input, Value, Ignore); end Get_First; --------------- -- Get_First -- --------------- procedure Get_First (Input : Grammar; Value : out Terminal_Set_Per_Production; Value_NT : out Non_Terminal_Set_Per_Production) is procedure Set (P : Production_Index; T : Terminal_Count); procedure Set (P : Production_Index; NT : Non_Terminal_Index); function Accept_Empty_String (NT : Non_Terminal_Index) return Boolean; Again : Boolean := True; ------------------------- -- Accept_Empty_String -- ------------------------- function Accept_Empty_String (NT : Non_Terminal_Index) return Boolean is From : constant Production_Index := Input.Non_Terminal (NT).First; begin for Production in From .. Input.Non_Terminal (NT).Last loop if Value.Map (Production, ε) then return True; end if; end loop; return False; end Accept_Empty_String; --------- -- Set -- --------- procedure Set (P : Production_Index; T : Terminal_Count) is begin if not Value.Map (P, T) then Value.Map (P, T) := True; Again := True; end if; end Set; --------- -- Set -- --------- procedure Set (P : Production_Index; NT : Non_Terminal_Index) is First : constant Production_Index := Input.Non_Terminal (NT).First; begin if not Value_NT.Map (P, NT) then Value_NT.Map (P, NT) := True; Again := True; end if; for Production in First .. Input.Non_Terminal (NT).Last loop for T in 1 .. Input.Last_Terminal loop if not Value.Map (P, T) and Value.Map (Production, T) then Again := True; Value.Map (P, T) := True; end if; end loop; for J in 1 .. Input.Last_Non_Terminal loop if not Value_NT.Map (P, J) and Value_NT.Map (Production, J) then Again := True; Value_NT.Map (P, J) := True; end if; end loop; end loop; end Set; begin Value.Map := (others => (others => False)); Value_NT.Map := (others => (others => False)); while Again loop Again := False; -- Set will trigger Again if change Value for P in Input.Production'Range loop declare From : constant Part_Index := Input.Production (P).First; To : constant Part_Count := Input.Production (P).Last; begin if From > To then Set (P, ε); end if; for Part in From .. To loop if Input.Part (Part).Is_Terminal_Reference then Set (P, T => Input.Part (Part).Denote); exit; else Set (P, NT => Input.Part (Part).Denote); exit when not Accept_Empty_String (Input.Part (Part).Denote); end if; if Part = To then Set (P, ε); end if; end loop; end; end loop; end loop; end Get_First; --------------- -- Get_First -- --------------- procedure Get_First (Input : Grammar; Value : out Terminal_Set_Per_Non_Terminal) is Ignore : Non_Terminal_Set_Per_Non_Terminal (Input.Last_Non_Terminal); begin Get_First (Input, Value, Ignore); end Get_First; --------------- -- Get_First -- --------------- procedure Get_First (Input : Grammar; Value : out Terminal_Set_Per_Non_Terminal; Value_NT : out Non_Terminal_Set_Per_Non_Terminal) is First : Production_Index; Temp : Terminal_Set_Per_Production (Input.Last_Terminal, Input.Last_Production); Temp_NT : Non_Terminal_Set_Per_Production (Input.Last_Non_Terminal, Input.Last_Production); begin Get_First (Input, Temp, Temp_NT); for NT in 1 .. Input.Last_Non_Terminal loop First := Input.Non_Terminal (NT).First; for T in 0 .. Input.Last_Terminal loop Value.Map (NT, T) := False; for Production in First .. Input.Non_Terminal (NT).Last loop Value.Map (NT, T) := Value.Map (NT, T) or Temp.Map (Production, T); end loop; end loop; for J in 1 .. Input.Last_Non_Terminal loop Value_NT.Map (NT, J) := False; for Production in First .. Input.Non_Terminal (NT).Last loop Value_NT.Map (NT, J) := Value_NT.Map (NT, J) or Temp_NT.Map (Production, J); end loop; end loop; end loop; end Get_First; ---------------- -- Get_Follow -- ---------------- procedure Get_Follow (Input : Grammar; First : Terminal_Set_Per_Non_Terminal; Value : out Terminal_Set_Per_Non_Terminal) is Dummy : constant Non_Terminal_Set_Per_Non_Terminal := (Last_Non_Terminal => Input.Last_Non_Terminal, Map => (others => (others => False))); Ignore : Non_Terminal_Set_Per_Non_Terminal (Input.Last_Non_Terminal); begin Get_Follow (Input, First, Dummy, Value, Ignore); end Get_Follow; ---------------- -- Get_Follow -- ---------------- procedure Get_Follow (Input : Grammar; First : Terminal_Set_Per_Non_Terminal; First_NT : Non_Terminal_Set_Per_Non_Terminal; Value : out Terminal_Set_Per_Non_Terminal; Value_NT : out Non_Terminal_Set_Per_Non_Terminal) is procedure Set (NT : Non_Terminal_Index; T : Terminal_Count); procedure Set (Target : Non_Terminal_Index; Source : Non_Terminal_Index; From : Terminal_Set_Per_Non_Terminal; From_NT : Non_Terminal_Set_Per_Non_Terminal; Skip : Boolean); Again : Boolean := True; Is_Last : Boolean; --------- -- Set -- --------- procedure Set (NT : Non_Terminal_Index; T : Terminal_Count) is begin if not Value.Map (NT, T) then Value.Map (NT, T) := True; Again := True; end if; end Set; procedure Set (Target : Non_Terminal_Index; Source : Non_Terminal_Index; From : Terminal_Set_Per_Non_Terminal; From_NT : Non_Terminal_Set_Per_Non_Terminal; Skip : Boolean) is begin for T in Boolean'Pos (Skip) .. Input.Last_Terminal loop Value.Map (Target, T) := Value.Map (Target, T) or From.Map (Source, T); end loop; for NT in 1 .. Input.Last_Non_Terminal loop Value_NT.Map (Target, NT) := Value_NT.Map (Target, NT) or From_NT.Map (Source, NT); end loop; end Set; EOF : constant Terminal_Count := 0; begin Value.Map := (others => (others => False)); Value_NT.Map := (others => (others => False)); Value.Map (Input.Root, EOF) := True; while Again loop Again := False; -- Set will trigger Again if change Value for NT in 1 .. Input.Last_Non_Terminal loop for P in Production_Index'(Input.Non_Terminal (NT).First) .. Input.Non_Terminal (NT).Last loop Is_Last := True; for Part in reverse Part_Index'(Input.Production (P).First) .. Input.Production (P).Last loop if Input.Part (Part).Is_Non_Terminal_Reference then if Is_Last then Set (Input.Part (Part).Denote, NT, Value, Value_NT, Skip => False); if not First.Map (Input.Part (Part).Denote, ε) then Is_Last := False; end if; end if; if Part = Input.Production (P).Last then null; elsif Input.Part (Part + 1).Is_Terminal_Reference then Set (Input.Part (Part).Denote, Input.Part (Part + 1).Denote); else Set (Input.Part (Part).Denote, Input.Part (Part + 1).Denote, First, First_NT, Skip => True); end if; else Is_Last := False; end if; end loop; end loop; end loop; end loop; end Get_Follow; end Anagram.Grammars.Tools;
stcarrez/babel
Ada
4,006
adb
----------------------------------------------------------------------- -- babel-strategies -- Strategies to backup files -- 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. ----------------------------------------------------------------------- pragma Ada_2012; with Babel.Files.Signatures; with Util.Encoders.SHA1; with Util.Log.Loggers; with Babel.Streams.Refs; package body Babel.Strategies.Default is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Babel.Strategies.Default"); -- Returns true if there is a directory that must be processed by the current strategy. overriding function Has_Directory (Strategy : in Default_Strategy_Type) return Boolean is begin return false; -- not Strategy.Queue.Directories.Is_Empty; end Has_Directory; -- Get the next directory that must be processed by the strategy. overriding procedure Peek_Directory (Strategy : in out Default_Strategy_Type; Directory : out Babel.Files.Directory_Type) is Last : constant String := ""; -- Strategy.Queue.Directories.Last_Element; begin -- Strategy.Queue.Directories.Delete_Last; null; end Peek_Directory; -- Set the file queue that the strategy must use. procedure Set_Queue (Strategy : in out Default_Strategy_Type; Queue : in Babel.Files.Queues.File_Queue_Access) is begin Strategy.Queue := Queue; end Set_Queue; overriding procedure Execute (Strategy : in out Default_Strategy_Type) is use type Babel.Files.File_Type; File : Babel.Files.File_Type; SHA1 : Util.Encoders.SHA1.Hash_Array; Stream : Babel.Streams.Refs.Stream_Ref; begin Strategy.Queue.Queue.Dequeue (File, 0.1); if File = Babel.Files.NO_FILE then Log.Debug ("Dequeue NO_FILE"); else Log.Debug ("Dequeue {0}", Babel.Files.Get_Path (File)); Strategy.Read_File (File, Stream); Babel.Files.Signatures.Sha1 (Stream, SHA1); Babel.Files.Set_Signature (File, SHA1); if Babel.Files.Is_Modified (File) then Strategy.Backup_File (File, Stream); end if; end if; end Execute; -- Scan the directory overriding procedure Scan (Strategy : in out Default_Strategy_Type; Directory : in Babel.Files.Directory_Type; Container : in out Babel.Files.File_Container'Class) is procedure Add_Queue (File : in Babel.Files.File_Type) is begin Log.Debug ("Queueing {0}", Babel.Files.Get_Path (File)); Strategy.Queue.Add_File (File); end Add_Queue; begin Strategy_Type (Strategy).Scan (Directory, Container); Container.Each_File (Add_Queue'Access); end Scan; -- overriding -- procedure Add_File (Into : in out Default_Strategy_Type; -- Path : in String; -- Element : in Babel.Files.File) is -- begin -- Into.Queue.Add_File (Path, Element); -- end Add_File; -- -- overriding -- procedure Add_Directory (Into : in out Default_Strategy_Type; -- Path : in String; -- Name : in String) is -- begin -- Into.Queue.Add_Directory (Path, Name); -- end Add_Directory; end Babel.Strategies.Default;
riccardo-bernardini/eugen
Ada
488
adb
pragma Ada_2012; package body Line_Parsers.Receivers.Multi_Receivers is ------------- -- Receive -- ------------- overriding procedure Receive (Handler : in out Multi_Receiver; Name : String; Value : String; Position : Natural) is Basic : Basic_Receiver; begin Basic.Receive (Name, Value, Position); Handler.Values.Append (Basic); Handler.Set := True; end Receive; end Line_Parsers.Receivers.Multi_Receivers;
reznikmm/matreshka
Ada
4,123
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; with League.Holders.Generic_Integers; package Forum.Topics is pragma Preelaborate; -- type Topic_Identifier is private; type Topic_Identifier is range 0 .. 2 ** 63 - 1; function Encode (Item : Topic_Identifier) return League.Strings.Universal_String; function Decode (Image : League.Strings.Universal_String; Value : out Topic_Identifier) return Boolean; -- Functions to 'encode' and 'decode' topic identifiers to string -- representsation. Decode function returns True when category identifier -- was decoded successfully. package Topic_Identifier_Holders is new League.Holders.Generic_Integers (Topic_Identifier); -- private -- -- -- type Topic_Identifier is range 0 .. 2 ** 63 - 1; end Forum.Topics;
stcarrez/dynamo
Ada
9,825
adb
----------------------------------------------------------------------- -- gen-commands-project -- Project creation command for dynamo -- Copyright (C) 2011, 2012, 2013, 2014, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Ada.Text_IO; with Gen.Artifacts; with GNAT.Command_Line; with GNAT.OS_Lib; with Util.Log.Loggers; with Util.Strings.Transforms; package body Gen.Commands.Project is use Util.Log; Log : constant Loggers.Logger := Loggers.Create ("Gen.Commands.Project"); -- ------------------------------ -- Generator Command -- ------------------------------ function Get_Name_From_Email (Email : in String) return String; -- ------------------------------ -- Get the user name from the email address. -- Returns the possible user name from his email address. -- ------------------------------ function Get_Name_From_Email (Email : in String) return String is Pos : Natural := Util.Strings.Index (Email, '<'); begin if Pos > 0 then return Email (Email'First .. Pos - 1); end if; Pos := Util.Strings.Index (Email, '@'); if Pos > 0 then return Email (Email'First .. Pos - 1); else return Email; end if; end Get_Name_From_Email; -- ------------------------------ -- Execute the command with the arguments. -- ------------------------------ overriding procedure Execute (Cmd : in out Command; Name : in String; Args : in Argument_List'Class; Generator : in out Gen.Generator.Handler) is pragma Unreferenced (Name, Args); use GNAT.Command_Line; Web_Flag : aliased Boolean := False; Tool_Flag : aliased Boolean := False; Ado_Flag : aliased Boolean := False; Gtk_Flag : aliased Boolean := False; Lib_Flag : aliased Boolean := False; begin -- If a dynamo.xml file exists, read it. if Ada.Directories.Exists ("dynamo.xml") then Generator.Read_Project ("dynamo.xml"); else Generator.Set_Project_Property ("license", "apache"); Generator.Set_Project_Property ("author", "unknown"); Generator.Set_Project_Property ("author_email", "[email protected]"); end if; -- Parse the command line loop case Getopt ("l: ? -lib -web -tool -ado -gtk") is when ASCII.NUL => exit; when '-' => if Full_Switch = "-web" then Web_Flag := True; elsif Full_Switch = "-tool" then Tool_Flag := True; elsif Full_Switch = "-ado" then Ado_Flag := True; elsif Full_Switch = "-lib" then Lib_Flag := True; elsif Full_Switch = "-gtk" then Gtk_Flag := True; end if; when 'l' => declare L : constant String := Util.Strings.Transforms.To_Lower_Case (Parameter); begin Log.Info ("License {0}", L); if L = "apache" then Generator.Set_Project_Property ("license", "apache"); elsif L = "gpl" then Generator.Set_Project_Property ("license", "gpl"); elsif L = "gpl3" then Generator.Set_Project_Property ("license", "gpl3"); elsif L = "mit" then Generator.Set_Project_Property ("license", "mit"); elsif L = "bsd3" then Generator.Set_Project_Property ("license", "bsd3"); elsif L = "proprietary" then Generator.Set_Project_Property ("license", "proprietary"); else Generator.Error ("Invalid license: {0}", L); Generator.Error ("Valid licenses: apache, gpl, gpl3, mit, bsd3, proprietary"); return; end if; end; when others => null; end case; end loop; if not Web_Flag and not Ado_Flag and not Tool_Flag and not Gtk_Flag then Web_Flag := True; end if; declare Name : constant String := Get_Argument; Arg2 : constant String := Get_Argument; Arg3 : constant String := Get_Argument; begin if Name'Length = 0 then Generator.Error ("Missing project name"); Cmd.Usage (Name, Generator); return; end if; if Util.Strings.Index (Arg2, '@') > Arg2'First then Generator.Set_Project_Property ("author_email", Arg2); if Arg3'Length = 0 then Generator.Set_Project_Property ("author", Get_Name_From_Email (Arg2)); else Generator.Set_Project_Property ("author", Arg3); end if; elsif Util.Strings.Index (Arg3, '@') > Arg3'First then Generator.Set_Project_Property ("author", Arg2); Generator.Set_Project_Property ("author_email", Arg3); elsif Arg3'Length > 0 then Generator.Error ("The last argument should be the author's email address."); Cmd.Usage (Name, Generator); return; end if; Generator.Set_Project_Property ("is_web", Boolean'Image (Web_Flag)); Generator.Set_Project_Property ("is_tool", Boolean'Image (Tool_Flag)); Generator.Set_Project_Property ("is_ado", Boolean'Image (Ado_Flag)); Generator.Set_Project_Property ("is_gtk", Boolean'Image (Gtk_Flag)); Generator.Set_Project_Property ("is_lib", Boolean'Image (Lib_Flag)); Generator.Set_Project_Name (Name); Generator.Set_Force_Save (False); if Ado_Flag then Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project-ado"); elsif Gtk_Flag then Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project-gtk"); elsif Tool_Flag then Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project-tool"); elsif Lib_Flag then Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project-lib"); else Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project"); end if; Generator.Save_Project; declare use type GNAT.OS_Lib.String_Access; Path : constant GNAT.OS_Lib.String_Access := GNAT.OS_Lib.Locate_Exec_On_Path ("autoconf"); Args : GNAT.OS_Lib.Argument_List (1 .. 0); Status : Boolean; begin if Path = null then Generator.Error ("The 'autoconf' tool was not found. It is necessary to " & "generate the configure script."); Generator.Error ("Install 'autoconf' or launch it manually."); else Ada.Directories.Set_Directory (Generator.Get_Result_Directory); Log.Info ("Executing {0}", Path.all); GNAT.OS_Lib.Spawn (Path.all, Args, Status); if not Status then Generator.Error ("Execution of {0} failed", Path.all); else Log.Info (""); Ada.Text_IO.Put_Line ("Your project is now created."); Ada.Text_IO.Put_Line ("Run the following commands to build it:"); Ada.Text_IO.Put_Line (" ./configure"); Ada.Text_IO.Put_Line (" make generate build"); end if; end if; end; end; end Execute; -- ------------------------------ -- Write the help associated with the command. -- ------------------------------ overriding procedure Help (Cmd : in out Command; Name : in String; Generator : in out Gen.Generator.Handler) is pragma Unreferenced (Cmd, Name, Generator); use Ada.Text_IO; begin Put_Line ("create-project: Create a new Ada Web Application project"); Put_Line ("Usage: create-project [-l apache|gpl|gpl3|mit|bsd3|proprietary] [--web] [--tool]" & " [--lib] [--ado] [--gtk] NAME [AUTHOR] [EMAIL]"); New_Line; Put_Line (" Creates a new AWA application with the name passed in NAME."); Put_Line (" The application license is controlled with the -l option. "); Put_Line (" License headers can use either the Apache, the MIT license, the BSD 3 clauses"); Put_Line (" license, the GNU licenses or a proprietary license."); Put_Line (" The author's name and email addresses are also reported in generated files."); New_Line; Put_Line (" --web Generate a Web application (the default)"); Put_Line (" --tool Generate a command line tool"); Put_Line (" --ado Generate a database tool operation for ADO"); Put_Line (" --gtk Generate a GtkAda project"); Put_Line (" --lib Generate a library project"); end Help; end Gen.Commands.Project;
reznikmm/matreshka
Ada
4,024
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis; with Engines.Contexts; with League.Strings; package Properties.Definitions.Float_Point is function Size (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Text_Property) return League.Strings.Universal_String; function Typed_Array_Item_Type (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Text_Property) return League.Strings.Universal_String; function Alignment (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Integer_Property) return Integer; end Properties.Definitions.Float_Point;
reznikmm/matreshka
Ada
3,764
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Text_Underline_Type_Attributes is pragma Preelaborate; type ODF_Style_Text_Underline_Type_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Text_Underline_Type_Attribute_Access is access all ODF_Style_Text_Underline_Type_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Text_Underline_Type_Attributes;
zhmu/ananas
Ada
332
ads
package Discr1_Pkg is Maximum_Length : Natural := 80 ; subtype String_Length is Natural range 0 .. Maximum_Length; type Variable_String (Length : String_Length := 0) is record S : String (1 .. Length); end record; type Variable_String_Array is array (Natural range <>) of Variable_String; end Discr1_Pkg;
reznikmm/matreshka
Ada
3,973
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.Db_Type_Name_Attributes; package Matreshka.ODF_Db.Type_Name_Attributes is type Db_Type_Name_Attribute_Node is new Matreshka.ODF_Db.Abstract_Db_Attribute_Node and ODF.DOM.Db_Type_Name_Attributes.ODF_Db_Type_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Type_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Db_Type_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Db.Type_Name_Attributes;
zhmu/ananas
Ada
3,677
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . F L O A T _ C O N T R O L -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Control functions for floating-point unit package System.Float_Control is pragma Pure; -- This is not fully correct, but this unit is with-ed by pure units -- (eg s-imgrea). procedure Reset; pragma Inline (Reset); -- Reset the floating-point processor to the default state needed to get -- correct Ada semantics for the target. Some third party tools change -- the settings for the floating-point processor. Reset can be called -- to reset the floating-point processor into the mode required by GNAT -- for correct operation. Use this call after a call to foreign code if -- you suspect incorrect floating-point operation after the call. -- -- For example under Windows NT some system DLL calls change the default -- FPU arithmetic to 64 bit precision mode. However, since in Ada 95 it -- is required to provide full access to the floating-point types of the -- architecture, GNAT requires full 80-bit precision mode, and Reset makes -- sure this mode is established. -- -- Similarly on the PPC processor, it is important that overflow and -- underflow exceptions be disabled. -- -- The call to Reset simply has no effect if the target environment -- does not give rise to such concerns. end System.Float_Control;
reznikmm/matreshka
Ada
4,329
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 Matreshka.DOM_Nodes; with XML.DOM.Attributes.Internals; package body ODF.DOM.Attributes.Style.Font_Size_Complex.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.Style.Font_Size_Complex.Style_Font_Size_Complex_Access) return ODF.DOM.Attributes.Style.Font_Size_Complex.ODF_Style_Font_Size_Complex is begin return (XML.DOM.Attributes.Internals.Create (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Attributes.Style.Font_Size_Complex.Style_Font_Size_Complex_Access) return ODF.DOM.Attributes.Style.Font_Size_Complex.ODF_Style_Font_Size_Complex is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.Style.Font_Size_Complex.Internals;
zhmu/ananas
Ada
4,761
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . V X W O R K S . E X T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2008-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ -- This package provides vxworks specific support functions needed -- by System.OS_Interface. -- This is the VxWorks 6 RTP version of this package with Interfaces.C; package System.VxWorks.Ext is pragma Preelaborate; subtype SEM_ID is Long_Integer; -- typedef struct semaphore *SEM_ID; type sigset_t is mod 2 ** Long_Long_Integer'Size; type t_id is new Long_Integer; subtype int is Interfaces.C.int; subtype unsigned is Interfaces.C.unsigned; type STATUS is new int; -- Equivalent of the C type STATUS OK : constant STATUS := 0; ERROR : constant STATUS := -1; type BOOL is new int; -- Equivalent of the C type BOOL type vx_freq_t is new unsigned; -- Equivalent of the C type _Vx_freq_t type Interrupt_Handler is access procedure (parameter : System.Address); pragma Convention (C, Interrupt_Handler); type Interrupt_Vector is new System.Address; function Int_Lock return int; pragma Inline (Int_Lock); procedure Int_Unlock (Old : int); pragma Inline (Int_Unlock); function Interrupt_Connect (Vector : Interrupt_Vector; Handler : Interrupt_Handler; Parameter : System.Address := System.Null_Address) return STATUS; pragma Convention (C, Interrupt_Connect); function Interrupt_Context return BOOL; pragma Convention (C, Interrupt_Context); function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector; pragma Convention (C, Interrupt_Number_To_Vector); function semDelete (Sem : SEM_ID) return STATUS; pragma Convention (C, semDelete); function Task_Cont (tid : t_id) return STATUS; pragma Import (C, Task_Cont, "taskResume"); function Task_Stop (tid : t_id) return STATUS; pragma Import (C, Task_Stop, "taskSuspend"); function kill (pid : t_id; sig : int) return int; pragma Import (C, kill, "taskKill"); function getpid return t_id; pragma Import (C, getpid, "getpid"); function Set_Time_Slice (ticks : int) return STATUS; pragma Inline (Set_Time_Slice); -------------------------------- -- Processor Affinity for SMP -- -------------------------------- function taskCpuAffinitySet (tid : t_id; CPU : int) return int; pragma Convention (C, taskCpuAffinitySet); -- For SMP run-times set the CPU affinity. -- For uniprocessor systems return ERROR status. function taskMaskAffinitySet (tid : t_id; CPU_Set : unsigned) return int; pragma Convention (C, taskMaskAffinitySet); -- For SMP run-times set the CPU mask affinity. -- For uniprocessor systems return ERROR status. end System.VxWorks.Ext;
zhmu/ananas
Ada
2,327
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S C I L _ L L -- -- -- -- S p e c -- -- -- -- Copyright (C) 2010-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 extends the tree nodes with fields that are used to reference -- the SCIL node. with Types; use Types; package SCIL_LL is function Get_SCIL_Node (N : Node_Id) return Node_Id; -- Read the value of attribute SCIL node procedure Set_SCIL_Node (N : Node_Id; Value : Node_Id); -- Set the value of attribute SCIL node procedure Initialize; -- Initialize the table of SCIL nodes end SCIL_LL;
glencornell/ada-object-framework
Ada
314
adb
with Ada.Text_Io; package body Slots is procedure Xaa is begin Ada.Text_Io.Put_Line("Xaa() called"); end; procedure Xab is begin Ada.Text_Io.Put_Line("Xab() called"); end; procedure Xac is begin Ada.Text_Io.Put_Line("Xac() called"); end; end Slots;
reznikmm/matreshka
Ada
3,654
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Chart_Chart_Elements is pragma Preelaborate; type ODF_Chart_Chart is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Chart_Chart_Access is access all ODF_Chart_Chart'Class with Storage_Size => 0; end ODF.DOM.Chart_Chart_Elements;
soccasys/Ada_Drivers_Library
Ada
1,909
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Board : constant String := "STM32_H405"; -- From user input Architecture : constant String := "ARM"; -- From board definition Vendor : constant String := "STMicro"; -- From board definition Device_Family : constant String := "STM32F4"; -- From board definition Device_Name : constant String := "STM32F405RGTx"; -- From board definition CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition High_Speed_External_Clock : constant := 8_000_000; -- From board definition Number_Of_Interrupts : constant := 0; -- From user input Has_ZFP_Runtime : constant String := "False"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition Runtime_Profile : constant String := "ravenscar-full"; -- From user input Runtime_Name_Suffix : constant String := "stm32f4"; -- From board definition Runtime_Name : constant String := "ravenscar-full-stm32f4"; -- From user input Use_Startup_Gen : constant Boolean := False; -- From user input Max_Path_Length : constant := 1024; -- From user input Max_Mount_Points : constant := 2; -- From user input Max_Mount_Name_Length : constant := 128; -- From user input end ADL_Config;
reznikmm/matreshka
Ada
7,268
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. ------------------------------------------------------------------------------ with AMF.Internals.MOF_Elements; with AMF.MOF.Tags; with AMF.UML.Comments.Collections; with AMF.UML.Elements.Collections; with AMF.Visitors; package AMF.Internals.MOF_Tags is type MOF_Tag_Proxy is limited new AMF.Internals.MOF_Elements.MOF_Element_Proxy and AMF.MOF.Tags.MOF_Tag with null record; overriding function Get_Name (Self : not null access constant MOF_Tag_Proxy) return League.Strings.Universal_String; -- Getter of Tag::name. -- overriding procedure Set_Name (Self : not null access MOF_Tag_Proxy; To : League.Strings.Universal_String); -- Setter of Tag::name. -- overriding function Get_Value (Self : not null access constant MOF_Tag_Proxy) return League.Strings.Universal_String; -- Getter of Tag::value. -- overriding procedure Set_Value (Self : not null access MOF_Tag_Proxy; To : League.Strings.Universal_String); -- Setter of Tag::value. -- overriding function Get_Element (Self : not null access constant MOF_Tag_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of Tag::element. -- overriding function Get_Tag_Owner (Self : not null access constant MOF_Tag_Proxy) return AMF.UML.Elements.UML_Element_Access; -- Getter of Tag::tagOwner. -- overriding procedure Set_Tag_Owner (Self : not null access MOF_Tag_Proxy; To : AMF.UML.Elements.UML_Element_Access); -- Setter of Tag::tagOwner. -- overriding function Get_Owned_Comment (Self : not null access constant MOF_Tag_Proxy) return AMF.UML.Comments.Collections.Set_Of_UML_Comment; -- Getter of Element::ownedComment. -- -- The Comments owned by this element. overriding function Get_Owned_Element (Self : not null access constant MOF_Tag_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of Element::ownedElement. -- -- The Elements owned by this element. overriding function Get_Owner (Self : not null access constant MOF_Tag_Proxy) return AMF.UML.Elements.UML_Element_Access; -- Getter of Element::owner. -- -- The Element that owns this element. overriding function All_Owned_Elements (Self : not null access constant MOF_Tag_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Operation Element::allOwnedElements. -- -- The query allOwnedElements() gives all of the direct and indirect owned -- elements of an element. overriding function Must_Be_Owned (Self : not null access constant MOF_Tag_Proxy) return Boolean; -- Operation Element::mustBeOwned. -- -- The query mustBeOwned() indicates whether elements of this type must -- have an owner. Subclasses of Element that do not require an owner must -- override this operation. overriding procedure Enter_Element (Self : not null access constant MOF_Tag_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 MOF_Tag_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 MOF_Tag_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.MOF_Tags;
AdaCore/training_material
Ada
2,616
adb
-- PragmAda Reusable Component (PragmARC) -- Copyright (C) 2020 by PragmAda Software Engineering. All rights reserved. -- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses -- ************************************************************************** -- -- History: -- 2020 Nov 01 J. Carter V2.0--Initial Ada-12 version ---------------------------------------------------------------------------- -- 2016 Oct 01 J. Carter V1.3--Pulled out Random_Range into PragmARC.Random_Ranges -- 2016 Jun 01 J. Carter V1.2--Changed comment for empty declarative part -- 2013 Nov 01 J. Carter V1.1--Eliminated an impossible case -- 2013 Aug 01 J. Carter V1.0--Initial release package body PragmARC.Randomness.KISS is use type Raw_Value; procedure Set_Seed (State : in out Generator; New_W : in Raw_Value := Default_W; New_X : in Positive_Raw := Default_X; New_Y : in Positive_Raw := Default_Y; New_Z : in Positive_Raw := Default_Z) is -- Empty begin -- Set_Seed State.W := New_W; State.X := New_X; State.Y := New_Y; State.Z := New_Z; end Set_Seed; function Raw (State : in out Generator) return Raw_Value is function ML (Value : in Raw_Value; Shift : in Natural) return Raw_Value; -- Returns Value xor Shift_Left (Value, Shift) function MR (Value : in Raw_Value; Shift : in Natural) return Raw_Value; -- Returns Value xor Shift_Right (Value, Shift) function ML (Value : in Raw_Value; Shift : in Natural) return Raw_Value is (Value xor Interfaces.Shift_Left (Value, Shift) ); function MR (Value : in Raw_Value; Shift : in Natural) return Raw_Value is (Value xor Interfaces.Shift_Right (Value, Shift) ); begin -- Raw State.W := 30903 * (State.W and 65535) + Interfaces.Shift_Right (State.W, 16); State.X := 69069 * State.X + 1327217885; State.Y := ML (MR (ML (State.Y, 13), 17), 5); State.Z := 18000 * (State.Z and 65535) + Interfaces.Shift_Right (State.Z, 16); return State.X + State.Y + Interfaces.Shift_Left (State.Z, 16) + State.W; end Raw; function Random (State : in out Generator) return Result_Subtype is begin return Result_Subtype'Val (Result_Subtype'Pos (Result_Subtype'First) + (Raw (State) mod Raw_Value (Result_Subtype'Pos (Result_Subtype'Last) - Result_Subtype'Pos (Result_Subtype'First) + 1))); end Random; end PragmARC.Randomness.KISS;
damaki/SPARKNaCl
Ada
1,418
adb
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.Hashing; use SPARKNaCl.Hashing; with Interfaces; use Interfaces; procedure Hash is R1 : Digest; -- Case 1: same as NaCl standard test suite M3 : constant String (1 .. 8) := "testing" & ASCII.LF; -- Case 2: two blocks, with final block >= 112 bytes to cover -- final block padding M5 : constant Byte_Seq (0 .. 240) := (16#AA#, others => 0); -- FIPS 180-2 Appendix C. SHA-512 test cases -- C.1 One-block message C1 : constant String := "abc"; -- C.2 Multi-block message C2 : constant String := "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; -- C.3 Long message C3 : constant String (1 .. 1_000_000) := (others => 'a'); begin Hash (R1, To_Byte_Seq (M3)); DH ("Case 1 - Hash is", R1); -- Functional style interface R1 := Hash (M5); DH ("Case 2 - Hash is", R1); -- 180-2 C.1 Hash (R1, To_Byte_Seq (C1)); DH ("FIPS 180-2 C.1 procedural API - Hash is", R1); R1 := Hash (To_Byte_Seq (C1)); DH ("FIPS 180-2 C.1 functional API - Hash is", R1); -- 180-2 C.2 R1 := Hash (To_Byte_Seq (C2)); DH ("FIPS 180-2 C.2 functional API - Hash is", R1); -- 180-2 C.3 R1 := Hash (To_Byte_Seq (C3)); DH ("FIPS 180-2 C.3 functional API - Hash is", R1); end Hash;
KipodAfterFree/KAF-2019-FireHog
Ada
3,023
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample -- -- -- -- 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.5 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ package Sample is procedure Whow; end Sample;
HackInvent/Ada_Drivers_Library
Ada
23,991
ads
-- This spec has been automatically generated from STM32H7x3.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.PWR is pragma Preelaborate; --------------- -- Registers -- --------------- subtype PWR_CR1_PLS_Field is STM32_SVD.UInt3; subtype PWR_CR1_SVOS_Field is STM32_SVD.UInt2; subtype PWR_CR1_ALS_Field is STM32_SVD.UInt2; -- PWR control register 1 type PWR_CR1_Register is record -- Low-power Deepsleep with SVOS3 (SVOS4 and SVOS5 always use low-power, -- regardless of the setting of this bit) LPDS : Boolean := False; -- unspecified Reserved_1_3 : STM32_SVD.UInt3 := 16#0#; -- Programmable voltage detector enable PVDE : Boolean := False; -- Programmable voltage detector level selection These bits select the -- voltage threshold detected by the PVD. Note: Refer to Section -- Electrical characteristics of the product datasheet for more details. PLS : PWR_CR1_PLS_Field := 16#0#; -- Disable backup domain write protection In reset state, the RCC_BDCR -- register, the RTC registers (including the backup registers), BREN -- and MOEN bits in PWR_CR2 register, are protected against parasitic -- write access. This bit must be set to enable write access to these -- registers. DBP : Boolean := False; -- Flash low-power mode in DStop mode This bit allows to obtain the best -- trade-off between low-power consumption and restart time when exiting -- from DStop mode. When it is set, the Flash memory enters low-power -- mode when D1 domain is in DStop mode. FLPS : Boolean := False; -- unspecified Reserved_10_13 : STM32_SVD.UInt4 := 16#0#; -- System Stop mode voltage scaling selection These bits control the -- VCORE voltage level in system Stop mode, to obtain the best trade-off -- between power consumption and performance. SVOS : PWR_CR1_SVOS_Field := 16#3#; -- Peripheral voltage monitor on VDDA enable AVDEN : Boolean := False; -- Analog voltage detector level selection These bits select the voltage -- threshold detected by the AVD. ALS : PWR_CR1_ALS_Field := 16#0#; -- unspecified Reserved_19_31 : STM32_SVD.UInt13 := 16#1E00#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_CR1_Register use record LPDS at 0 range 0 .. 0; Reserved_1_3 at 0 range 1 .. 3; PVDE at 0 range 4 .. 4; PLS at 0 range 5 .. 7; DBP at 0 range 8 .. 8; FLPS at 0 range 9 .. 9; Reserved_10_13 at 0 range 10 .. 13; SVOS at 0 range 14 .. 15; AVDEN at 0 range 16 .. 16; ALS at 0 range 17 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype PWR_CSR1_ACTVOS_Field is STM32_SVD.UInt2; -- PWR control status register 1 type PWR_CSR1_Register is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4; -- Read-only. Programmable voltage detect output This bit is set and -- cleared by hardware. It is valid only if the PVD has been enabled by -- the PVDE bit. Note: since the PVD is disabled in Standby mode, this -- bit is equal to 0 after Standby or reset until the PVDE bit is set. PVDO : Boolean; -- unspecified Reserved_5_12 : STM32_SVD.Byte; -- Read-only. Voltage levels ready bit for currently used VOS and -- SDLEVEL This bit is set to 1 by hardware when the voltage regulator -- and the SD converter are both disabled and Bypass mode is selected in -- PWR control register 3 (PWR_CR3). ACTVOSRDY : Boolean; -- Read-only. VOS currently applied for VCORE voltage scaling selection. -- These bits reflect the last VOS value applied to the PMU. ACTVOS : PWR_CSR1_ACTVOS_Field; -- Read-only. Analog voltage detector output on VDDA This bit is set and -- cleared by hardware. It is valid only if AVD on VDDA is enabled by -- the AVDEN bit. Note: Since the AVD is disabled in Standby mode, this -- bit is equal to 0 after Standby or reset until the AVDEN bit is set. AVDO : Boolean; -- unspecified Reserved_17_31 : STM32_SVD.UInt15; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_CSR1_Register use record Reserved_0_3 at 0 range 0 .. 3; PVDO at 0 range 4 .. 4; Reserved_5_12 at 0 range 5 .. 12; ACTVOSRDY at 0 range 13 .. 13; ACTVOS at 0 range 14 .. 15; AVDO at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; -- This register is not reset by wakeup from Standby mode, RESET signal and -- VDD POR. It is only reset by VSW POR and VSWRST reset. This register -- shall not be accessed when VSWRST bit in RCC_BDCR register resets the -- VSW domain.After reset, PWR_CR2 register is write-protected. Prior to -- modifying its content, the DBP bit in PWR_CR1 register must be set to -- disable the write protection. type PWR_CR2_Register is record -- Backup regulator enable When set, the Backup regulator (used to -- maintain the backup RAM content in Standby and VBAT modes) is -- enabled. If BREN is reset, the backup regulator is switched off. The -- backup RAM can still be used in Run and Stop modes. However, its -- content will be lost in Standby and VBAT modes. If BREN is set, the -- application must wait till the Backup Regulator Ready flag (BRRDY) is -- set to indicate that the data written into the SRAM will be -- maintained in Standby and VBAT modes. BREN : Boolean := False; -- unspecified Reserved_1_3 : STM32_SVD.UInt3 := 16#0#; -- VBAT and temperature monitoring enable When set, the VBAT supply and -- temperature monitoring is enabled. MONEN : Boolean := False; -- unspecified Reserved_5_15 : STM32_SVD.UInt11 := 16#0#; -- Read-only. Backup regulator ready This bit is set by hardware to -- indicate that the Backup regulator is ready. BRRDY : Boolean := False; -- unspecified Reserved_17_19 : STM32_SVD.UInt3 := 16#0#; -- Read-only. VBAT level monitoring versus low threshold VBATL : Boolean := False; -- Read-only. VBAT level monitoring versus high threshold VBATH : Boolean := False; -- Read-only. Temperature level monitoring versus low threshold TEMPL : Boolean := False; -- Read-only. Temperature level monitoring versus high threshold TEMPH : Boolean := False; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_CR2_Register use record BREN at 0 range 0 .. 0; Reserved_1_3 at 0 range 1 .. 3; MONEN at 0 range 4 .. 4; Reserved_5_15 at 0 range 5 .. 15; BRRDY at 0 range 16 .. 16; Reserved_17_19 at 0 range 17 .. 19; VBATL at 0 range 20 .. 20; VBATH at 0 range 21 .. 21; TEMPL at 0 range 22 .. 22; TEMPH at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- Reset only by POR only, not reset by wakeup from Standby mode and RESET -- pad. The lower byte of this register is written once after POR and shall -- be written before changing VOS level or ck_sys clock frequency. No -- limitation applies to the upper bytes.Programming data corresponding to -- an invalid combination of SDLEVEL, SDEXTHP, SDEN, LDOEN and BYPASS bits -- (see Table9) will be ignored: data will not be written, the written-once -- mechanism will lock the register and any further write access will be -- ignored. The default supply configuration will be kept and the ACTVOSRDY -- bit in PWR control status register 1 (PWR_CSR1) will go on indicating -- invalid voltage levels. The system shall be power cycled before writing -- a new value. type PWR_CR3_Register is record -- Power management unit bypass BYPASS : Boolean := False; -- Low drop-out regulator enable LDOEN : Boolean := True; -- SD converter Enable SDEN : Boolean := True; -- unspecified Reserved_3_7 : STM32_SVD.UInt5 := 16#0#; -- VBAT charging enable VBE : Boolean := False; -- VBAT charging resistor selection VBRS : Boolean := False; -- unspecified Reserved_10_23 : STM32_SVD.UInt14 := 16#0#; -- Write-only. VDD33USB voltage level detector enable. USB33DEN : Boolean := False; -- USB regulator enable. USBREGEN : Boolean := False; -- Read-only. USB supply ready. USB33RDY : Boolean := False; -- unspecified Reserved_27_31 : STM32_SVD.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_CR3_Register use record BYPASS at 0 range 0 .. 0; LDOEN at 0 range 1 .. 1; SDEN at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; VBE at 0 range 8 .. 8; VBRS at 0 range 9 .. 9; Reserved_10_23 at 0 range 10 .. 23; USB33DEN at 0 range 24 .. 24; USBREGEN at 0 range 25 .. 25; USB33RDY at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; -- PWR_CPUCR_PDDS_D array type PWR_CPUCR_PDDS_D_Field_Array is array (1 .. 3) of Boolean with Component_Size => 1, Size => 3; -- Type definition for PWR_CPUCR_PDDS_D type PWR_CPUCR_PDDS_D_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PDDS_D as a value Val : STM32_SVD.UInt3; when True => -- PDDS_D as an array Arr : PWR_CPUCR_PDDS_D_Field_Array; end case; end record with Unchecked_Union, Size => 3; for PWR_CPUCR_PDDS_D_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- PWR_CPUCR_SBF_D array type PWR_CPUCR_SBF_D_Field_Array is array (1 .. 2) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PWR_CPUCR_SBF_D type PWR_CPUCR_SBF_D_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SBF_D as a value Val : STM32_SVD.UInt2; when True => -- SBF_D as an array Arr : PWR_CPUCR_SBF_D_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PWR_CPUCR_SBF_D_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- This register allows controlling CPU1 power. type PWR_CPUCR_Register is record -- D1 domain Power Down Deepsleep selection. This bit allows CPU1 to -- define the Deepsleep mode for D1 domain. PDDS_D : PWR_CPUCR_PDDS_D_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_3_4 : STM32_SVD.UInt2 := 16#0#; -- Read-only. STOP flag This bit is set by hardware and cleared only by -- any reset or by setting the CPU1 CSSF bit. STOPF : Boolean := False; -- Read-only. System Standby flag This bit is set by hardware and -- cleared only by a POR (Power-on Reset) or by setting the CPU1 CSSF -- bit SBF : Boolean := False; -- Read-only. D1 domain DStandby flag This bit is set by hardware and -- cleared by any system reset or by setting the CPU1 CSSF bit. Once -- set, this bit can be cleared only when the D1 domain is no longer in -- DStandby mode. SBF_D : PWR_CPUCR_SBF_D_Field := (As_Array => False, Val => 16#0#); -- Clear D1 domain CPU1 Standby, Stop and HOLD flags (always read as 0) -- This bit is cleared to 0 by hardware. CSSF : Boolean := False; -- unspecified Reserved_10_10 : STM32_SVD.Bit := 16#0#; -- Keep system D3 domain in Run mode regardless of the CPU sub-systems -- modes RUN_D3 : Boolean := False; -- unspecified Reserved_12_31 : STM32_SVD.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_CPUCR_Register use record PDDS_D at 0 range 0 .. 2; Reserved_3_4 at 0 range 3 .. 4; STOPF at 0 range 5 .. 5; SBF at 0 range 6 .. 6; SBF_D at 0 range 7 .. 8; CSSF at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; RUN_D3 at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype PWR_D3CR_VOS_Field is STM32_SVD.UInt2; -- This register allows controlling D3 domain power.Following reset VOSRDY -- will be read 1 by software type PWR_D3CR_Register is record -- unspecified Reserved_0_12 : STM32_SVD.UInt13 := 16#0#; -- Read-only. VOS Ready bit for VCORE voltage scaling output selection. -- This bit is set to 1 by hardware when Bypass mode is selected in PWR -- control register 3 (PWR_CR3). VOSRDY : Boolean := False; -- Voltage scaling selection according to performance These bits control -- the VCORE voltage level and allow to obtains the best trade-off -- between power consumption and performance: When increasing the -- performance, the voltage scaling shall be changed before increasing -- the system frequency. When decreasing performance, the system -- frequency shall first be decreased before changing the voltage -- scaling. VOS : PWR_D3CR_VOS_Field := 16#1#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_D3CR_Register use record Reserved_0_12 at 0 range 0 .. 12; VOSRDY at 0 range 13 .. 13; VOS at 0 range 14 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype PWR_WKUPCR_WKUPC_Field is STM32_SVD.UInt6; -- reset only by system reset, not reset by wakeup from Standby mode5 wait -- states are required when writing this register (when clearing a WKUPF -- bit in PWR_WKUPFR, the AHB write access will complete after the WKUPF -- has been cleared). type PWR_WKUPCR_Register is record -- Clear Wakeup pin flag for WKUP. These bits are always read as 0. WKUPC : PWR_WKUPCR_WKUPC_Field := 16#0#; -- unspecified Reserved_6_31 : STM32_SVD.UInt26 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_WKUPCR_Register use record WKUPC at 0 range 0 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- PWR_WKUPFR_WKUPF array type PWR_WKUPFR_WKUPF_Field_Array is array (1 .. 6) of Boolean with Component_Size => 1, Size => 6; -- Type definition for PWR_WKUPFR_WKUPF type PWR_WKUPFR_WKUPF_Field (As_Array : Boolean := False) is record case As_Array is when False => -- WKUPF as a value Val : STM32_SVD.UInt6; when True => -- WKUPF as an array Arr : PWR_WKUPFR_WKUPF_Field_Array; end case; end record with Unchecked_Union, Size => 6; for PWR_WKUPFR_WKUPF_Field use record Val at 0 range 0 .. 5; Arr at 0 range 0 .. 5; end record; -- reset only by system reset, not reset by wakeup from Standby mode type PWR_WKUPFR_Register is record -- Wakeup pin WKUPF flag. This bit is set by hardware and cleared only -- by a Reset pin or by setting the WKUPCn+1 bit in the PWR wakeup clear -- register (PWR_WKUPCR). WKUPF : PWR_WKUPFR_WKUPF_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_6_31 : STM32_SVD.UInt26 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_WKUPFR_Register use record WKUPF at 0 range 0 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- PWR_WKUPEPR_WKUPEN array type PWR_WKUPEPR_WKUPEN_Field_Array is array (1 .. 6) of Boolean with Component_Size => 1, Size => 6; -- Type definition for PWR_WKUPEPR_WKUPEN type PWR_WKUPEPR_WKUPEN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- WKUPEN as a value Val : STM32_SVD.UInt6; when True => -- WKUPEN as an array Arr : PWR_WKUPEPR_WKUPEN_Field_Array; end case; end record with Unchecked_Union, Size => 6; for PWR_WKUPEPR_WKUPEN_Field use record Val at 0 range 0 .. 5; Arr at 0 range 0 .. 5; end record; -- PWR_WKUPEPR_WKUPP array type PWR_WKUPEPR_WKUPP_Field_Array is array (1 .. 6) of Boolean with Component_Size => 1, Size => 6; -- Type definition for PWR_WKUPEPR_WKUPP type PWR_WKUPEPR_WKUPP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- WKUPP as a value Val : STM32_SVD.UInt6; when True => -- WKUPP as an array Arr : PWR_WKUPEPR_WKUPP_Field_Array; end case; end record with Unchecked_Union, Size => 6; for PWR_WKUPEPR_WKUPP_Field use record Val at 0 range 0 .. 5; Arr at 0 range 0 .. 5; end record; -- PWR_WKUPEPR_WKUPPUPD array element subtype PWR_WKUPEPR_WKUPPUPD_Element is STM32_SVD.UInt2; -- PWR_WKUPEPR_WKUPPUPD array type PWR_WKUPEPR_WKUPPUPD_Field_Array is array (1 .. 6) of PWR_WKUPEPR_WKUPPUPD_Element with Component_Size => 2, Size => 12; -- Type definition for PWR_WKUPEPR_WKUPPUPD type PWR_WKUPEPR_WKUPPUPD_Field (As_Array : Boolean := False) is record case As_Array is when False => -- WKUPPUPD as a value Val : STM32_SVD.UInt12; when True => -- WKUPPUPD as an array Arr : PWR_WKUPEPR_WKUPPUPD_Field_Array; end case; end record with Unchecked_Union, Size => 12; for PWR_WKUPEPR_WKUPPUPD_Field use record Val at 0 range 0 .. 11; Arr at 0 range 0 .. 11; end record; -- Reset only by system reset, not reset by wakeup from Standby mode type PWR_WKUPEPR_Register is record -- Enable Wakeup Pin WKUPn+1 Each bit is set and cleared by software. -- Note: An additional wakeup event is detected if WKUPn+1 pin is -- enabled (by setting the WKUPENn+1 bit) when WKUPn+1 pin level is -- already high when WKUPPn+1 selects rising edge, or low when WKUPPn+1 -- selects falling edge. WKUPEN : PWR_WKUPEPR_WKUPEN_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- Wakeup pin polarity bit for WKUPn-7 These bits define the polarity -- used for event detection on WKUPn-7 external wakeup pin. WKUPP : PWR_WKUPEPR_WKUPP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_14_15 : STM32_SVD.UInt2 := 16#0#; -- Wakeup pin pull configuration WKUPPUPD : PWR_WKUPEPR_WKUPPUPD_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_WKUPEPR_Register use record WKUPEN at 0 range 0 .. 5; Reserved_6_7 at 0 range 6 .. 7; WKUPP at 0 range 8 .. 13; Reserved_14_15 at 0 range 14 .. 15; WKUPPUPD at 0 range 16 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- PWR type PWR_Peripheral is record -- PWR control register 1 PWR_CR1 : aliased PWR_CR1_Register; -- PWR control status register 1 PWR_CSR1 : aliased PWR_CSR1_Register; -- This register is not reset by wakeup from Standby mode, RESET signal -- and VDD POR. It is only reset by VSW POR and VSWRST reset. This -- register shall not be accessed when VSWRST bit in RCC_BDCR register -- resets the VSW domain.After reset, PWR_CR2 register is -- write-protected. Prior to modifying its content, the DBP bit in -- PWR_CR1 register must be set to disable the write protection. PWR_CR2 : aliased PWR_CR2_Register; -- Reset only by POR only, not reset by wakeup from Standby mode and -- RESET pad. The lower byte of this register is written once after POR -- and shall be written before changing VOS level or ck_sys clock -- frequency. No limitation applies to the upper bytes.Programming data -- corresponding to an invalid combination of SDLEVEL, SDEXTHP, SDEN, -- LDOEN and BYPASS bits (see Table9) will be ignored: data will not be -- written, the written-once mechanism will lock the register and any -- further write access will be ignored. The default supply -- configuration will be kept and the ACTVOSRDY bit in PWR control -- status register 1 (PWR_CSR1) will go on indicating invalid voltage -- levels. The system shall be power cycled before writing a new value. PWR_CR3 : aliased PWR_CR3_Register; -- This register allows controlling CPU1 power. PWR_CPUCR : aliased PWR_CPUCR_Register; -- This register allows controlling D3 domain power.Following reset -- VOSRDY will be read 1 by software PWR_D3CR : aliased PWR_D3CR_Register; -- reset only by system reset, not reset by wakeup from Standby mode5 -- wait states are required when writing this register (when clearing a -- WKUPF bit in PWR_WKUPFR, the AHB write access will complete after the -- WKUPF has been cleared). PWR_WKUPCR : aliased PWR_WKUPCR_Register; -- reset only by system reset, not reset by wakeup from Standby mode PWR_WKUPFR : aliased PWR_WKUPFR_Register; -- Reset only by system reset, not reset by wakeup from Standby mode PWR_WKUPEPR : aliased PWR_WKUPEPR_Register; end record with Volatile; for PWR_Peripheral use record PWR_CR1 at 16#0# range 0 .. 31; PWR_CSR1 at 16#4# range 0 .. 31; PWR_CR2 at 16#8# range 0 .. 31; PWR_CR3 at 16#C# range 0 .. 31; PWR_CPUCR at 16#10# range 0 .. 31; PWR_D3CR at 16#18# range 0 .. 31; PWR_WKUPCR at 16#20# range 0 .. 31; PWR_WKUPFR at 16#24# range 0 .. 31; PWR_WKUPEPR at 16#28# range 0 .. 31; end record; -- PWR PWR_Periph : aliased PWR_Peripheral with Import, Address => PWR_Base; end STM32_SVD.PWR;
reznikmm/matreshka
Ada
3,644
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Time_Elements is pragma Preelaborate; type ODF_Text_Time is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Time_Access is access all ODF_Text_Time'Class with Storage_Size => 0; end ODF.DOM.Text_Time_Elements;
reznikmm/matreshka
Ada
9,968
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Internals.Elements; with AMF.Internals.Extents; with AMF.Internals.Helpers; with AMF.Internals.Links; with AMF.Internals.Listener_Registry; with AMF.Internals.Tables.Standard_Profile_L3_Metamodel; with AMF.Internals.Tables.UML_Constructors; package body AMF.Internals.Factories.Standard_Profile_L3_Factories is ----------------- -- Constructor -- ----------------- function Constructor (Extent : AMF.Internals.AMF_Extent) return not null AMF.Factories.Factory_Access is begin return new Standard_Profile_L3_Factory'(Extent => Extent); end Constructor; ----------------------- -- Convert_To_String -- ----------------------- overriding function Convert_To_String (Self : not null access Standard_Profile_L3_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Value : League.Holders.Holder) return League.Strings.Universal_String is begin raise Program_Error; return League.Strings.Empty_Universal_String; end Convert_To_String; ------------ -- Create -- ------------ overriding function Create (Self : not null access Standard_Profile_L3_Factory; Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class) return not null AMF.Elements.Element_Access is MC : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element; Element : AMF.Internals.AMF_Element; begin if MC = AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MC_Standard_Profile_L3_Build_Component then Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L3_Build_Component; elsif MC = AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MC_Standard_Profile_L3_Metamodel then Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L3_Metamodel; elsif MC = AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MC_Standard_Profile_L3_System_Model then Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L3_System_Model; else raise Program_Error; end if; AMF.Internals.Extents.Internal_Append (Self.Extent, Element); AMF.Internals.Listener_Registry.Notify_Instance_Create (AMF.Internals.Helpers.To_Element (Element)); return AMF.Internals.Helpers.To_Element (Element); end Create; ------------------------ -- Create_From_String -- ------------------------ overriding function Create_From_String (Self : not null access Standard_Profile_L3_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Image : League.Strings.Universal_String) return League.Holders.Holder is begin raise Program_Error; return League.Holders.Empty_Holder; end Create_From_String; ----------------- -- Create_Link -- ----------------- overriding function Create_Link (Self : not null access Standard_Profile_L3_Factory; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) return not null AMF.Links.Link_Access is pragma Unreferenced (Self); begin return AMF.Internals.Links.Proxy (AMF.Internals.Links.Create_Link (AMF.Internals.Elements.Element_Base'Class (Association.all).Element, AMF.Internals.Helpers.To_Element (First_Element), AMF.Internals.Helpers.To_Element (Second_Element))); end Create_Link; ----------------- -- Get_Package -- ----------------- overriding function Get_Package (Self : not null access constant Standard_Profile_L3_Factory) return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package is pragma Unreferenced (Self); begin return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do Result.Add (Get_Package); end return; end Get_Package; ----------------- -- Get_Package -- ----------------- function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is begin return AMF.CMOF.Packages.CMOF_Package_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MM_Standard_Profile_L3_Standard_Profile_L3)); end Get_Package; ---------------------------- -- Create_Build_Component -- ---------------------------- overriding function Create_Build_Component (Self : not null access Standard_Profile_L3_Factory) return AMF.Standard_Profile_L3.Build_Components.Standard_Profile_L3_Build_Component_Access is begin return AMF.Standard_Profile_L3.Build_Components.Standard_Profile_L3_Build_Component_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MC_Standard_Profile_L3_Build_Component)))); end Create_Build_Component; ---------------------- -- Create_Metamodel -- ---------------------- overriding function Create_Metamodel (Self : not null access Standard_Profile_L3_Factory) return AMF.Standard_Profile_L3.Metamodels.Standard_Profile_L3_Metamodel_Access is begin return AMF.Standard_Profile_L3.Metamodels.Standard_Profile_L3_Metamodel_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MC_Standard_Profile_L3_Metamodel)))); end Create_Metamodel; ------------------------- -- Create_System_Model -- ------------------------- overriding function Create_System_Model (Self : not null access Standard_Profile_L3_Factory) return AMF.Standard_Profile_L3.System_Models.Standard_Profile_L3_System_Model_Access is begin return AMF.Standard_Profile_L3.System_Models.Standard_Profile_L3_System_Model_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Standard_Profile_L3_Metamodel.MC_Standard_Profile_L3_System_Model)))); end Create_System_Model; end AMF.Internals.Factories.Standard_Profile_L3_Factories;
sparre/Command-Line-Parser-Generator
Ada
686
adb
with Ada.Text_IO; package body Web_Site_Generator.API is procedure Generate_All_Pages (Sources : in Directory_Name := "."; Target : in Directory_Name := "/var/www"; Documents : in String := "documents"; Debug : in Boolean := False) is use Ada.Text_IO; begin Put_Line ("Generate_All_Pages"); Put_Line (" (Sources => """ & String (Sources) & ""","); Put_Line (" Target => """ & String (Target) & ""","); Put_Line (" Documents => """ & Documents & ""","); Put_Line (" Debug => " & Boolean'Image (Debug) & ");"); end Generate_All_Pages; end Web_Site_Generator.API;
reznikmm/matreshka
Ada
4,011
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.Style_Num_Format_Attributes; package Matreshka.ODF_Style.Num_Format_Attributes is type Style_Num_Format_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Num_Format_Attributes.ODF_Style_Num_Format_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Num_Format_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Num_Format_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Num_Format_Attributes;
onox/orka
Ada
6,041
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 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 AWT.Inputs; with AWT.Monitors; package AWT.Windows with SPARK_Mode => On is pragma Preelaborate; type Size_Mode is (Default, Minimized, Maximized, Fullscreen); type Monitor_Presence is (Entered, Left); type Window_State is record Visible, Resizable, Decorated, Transparent : Boolean := False; Mode : Size_Mode := Default; Width, Height : Natural := 0; Margin : Natural := 0; end record; type Framebuffer_State is record Width, Height : Natural := 0; Scale : Positive := 1; end record; type Window is limited interface; procedure Create_Window (Object : aliased in out Window; ID, Title : String; Width, Height : Positive; Visible, Resizable, Decorated : Boolean := True; Transparent : Boolean := False) is abstract with Pre'Class => Is_Initialized; procedure Set_Application_ID (Object : in out Window; ID : String) is abstract; procedure Set_Title (Object : in out Window; Title : String) is abstract; procedure Set_Margin (Object : in out Window; Margin : Natural) is abstract; procedure Set_Size (Object : in out Window; Width, Height : Positive) is abstract; procedure Set_Size_Limits (Object : in out Window; Min_Width, Min_Height, Max_Width, Max_Height : Natural) is abstract with Pre'Class => (Max_Width = 0 or Max_Width >= Min_Width) and (Max_Height = 0 or Max_Height >= Min_Height); procedure Set_Size_Mode (Object : in out Window; Mode : Size_Mode) is abstract; -- Request the window to be fullscreen, maximized, minimized, or none -- of these -- -- A transparent window may not actually be transparent in fullscreen mode. procedure Set_Size_Mode (Object : in out Window; Mode : AWT.Windows.Size_Mode; Monitor : AWT.Monitors.Monitor'Class) is abstract with Pre'Class => Mode = Fullscreen; procedure Set_Framebuffer_Scale (Object : in out Window; Scale : Positive) is abstract; procedure Set_Raw_Pointer_Motion (Object : in out Window; Enable : Boolean) is abstract; procedure Set_Visible (Object : in out Window; Visible : Boolean) is abstract; procedure Set_Pointer_Cursor (Object : in out Window; Cursor : AWT.Inputs.Cursors.Pointer_Cursor) is abstract; procedure Set_Pointer_Mode (Object : in out Window; Mode : AWT.Inputs.Pointer_Mode) is abstract; function Raw_Pointer_Motion (Object : Window) return Boolean is abstract; function State (Object : Window) return Window_State is abstract; function State (Object : Window) return Framebuffer_State is abstract; function State (Object : in out Window) return AWT.Inputs.Pointer_State is abstract; function State (Object : in out Window) return AWT.Inputs.Keyboard_State is abstract; procedure Close (Object : in out Window) is abstract; function Should_Close (Object : Window) return Boolean is abstract; -- Return True if the window should be closed, False otherwise -- -- If True, then it is no longer needed to process any events and an event -- loop can be exited. procedure Swap_Buffers (Object : in out Window) is abstract; -- Swap the buffers of the default framebuffer -- -- Must be called by the task on which the GL context to which the default -- framebuffer belongs is current procedure Set_Vertical_Sync (Object : in out Window; Enable : Boolean) is abstract; -- Enable or disable vertical sync -- -- Has no effect on Wayland (because the compositor will always prevent tearing). -- -- Must be called by the task on which the GL context to which the default -- framebuffer belongs is current ---------------------------------------------------------------------------- -- Events -- ---------------------------------------------------------------------------- procedure On_Configure (Object : in out Window; State : Window_State) is null; -- Invoked when the state of the window has changed function On_Close (Object : Window) return Boolean is abstract; -- Invoked when the user wants to close the window -- -- Return True if the window should actually be closed, or return False -- and display a dialog window on the screen that asks the user for -- confirmation. procedure On_Move (Object : in out Window; Monitor : AWT.Monitors.Monitor'Class; Presence : Monitor_Presence) is null; -- Invoked when the window is moved to/from a monitor procedure On_Drag (Object : in out Window; X, Y : AWT.Inputs.Fixed) is null; -- Invoked when the user drag something over the window -- -- Call procedure Set_Action in AWT.Drag_And_Drop in response to this event. procedure On_Drop (Object : in out Window) is null; -- Invoked when the user drops something on the window -- -- To perform the drag-and-drop, call Get in AWT.Drag_And_Drop -- and then, after the given callback has been executed, accept -- or reject the drag-and-drop by calling Finish. -- -- Call procedure Get in AWT.Drag_And_Drop to receive data and -- call Finish to complete the data transfer. end AWT.Windows;
jscparker/math_packages
Ada
3,271
adb
------------------------------------------------------------------------------- -- package body Disorderly.Random.Clock_Entropy, Random Number Initialization -- Copyright (C) 1995-2018 Jonathan S. Parker -- -- 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.Calendar; with System; -- for Tick : Duration; package body Disorderly.Random.Clock_Entropy is ------------------------- -- Get_Seed_From_Clock -- ------------------------- -- Clock sets initial seed. -- Seconds (T) is <= 86_400.0. -- Day (T) is <= 31.0. -- procedure Get_Seed_From_Clock (Initiator : out Seed_Random_Int) is type Real is digits 15; Fake_Ticks_per_Second : constant Real := 77_777_777.0; Seconds_per_Day : constant Real := 86_400.0; Fake_Ticks_per_Day : constant Real := Fake_Ticks_per_Second * Seconds_per_Day; Min_Delay : constant Duration := System.Tick; T : Ada.Calendar.Time; Seed : Parent_Random_Int; begin delay Min_Delay * 3.0; T := Ada.Calendar.Clock; Seed := Random_Int (Real (Ada.Calendar.Seconds (T)) * Fake_Ticks_per_Second + Real (Ada.Calendar.Day (T)) * Fake_Ticks_per_Day); -- So Seed is the number of elapsed fake ticks in present month. -- -- Even if Seconds (T) = 0.0000123 we want -- Seconds (T)) * Fake_Ticks_per_Second to be big integer, so make -- Fake_Ticks_per_Second very large. -- -- Max val of Seed ~ 0.83 * 2^51. Initiator := Seed + 777_777; -- 0 < Seed <= Random_Int'Last delay Min_Delay * (7.0 + Duration (Initiator mod 77)); -- Minimize likelihood that next call to Reset_with_Calendar produces -- the same Initiator1, and hence the same state S. -- Doesn't guarantee that there is no relationship between successive -- seeds, but such a relationship would be difficult to see. -- All we need is 1 bit of difference between the outputs of two -- successive calls to Ada.Calendar.Clock, and the two 256 bit -- states generated by the successive calls will have no apparent -- similarities. end Get_Seed_From_Clock; ----------- -- Reset -- ----------- procedure Reset (S : out State) is Initiator1, Initiator2 : Seed_Random_Int; begin Get_Seed_From_Clock (Initiator1); Get_Seed_From_Clock (Initiator2); Disorderly.Random.Reset (S, Initiator1, Initiator2); end Reset; end Disorderly.Random.Clock_Entropy;
apple-oss-distributions/old_ncurses
Ada
5,406
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Aux -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- 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 body Terminal_Interface.Curses.Text_IO.Aux is procedure Put_Buf (Win : in Window; Buf : in String; Width : in Field; Signal : in Boolean := True; Ljust : in Boolean := False) is L : Field; Len : Field; W : Field := Width; LC : Line_Count; CC : Column_Count; Y : Line_Position; X : Column_Position; procedure Output (From, To : Field); procedure Output (From, To : Field) is begin if Len > 0 then if W = 0 then W := Len; end if; if Len > W then -- LRM A10.6 (7) says this W := Len; end if; pragma Assert (Len <= W); Get_Size (Win, LC, CC); if Column_Count (Len) > CC then if Signal then raise Layout_Error; else return; end if; else if Len < W and then not Ljust then declare Filler : constant String (1 .. (W - Len)) := (others => ' '); begin Put (Win, Filler); end; end if; Get_Cursor_Position (Win, Y, X); if (X + Column_Position (Len)) > CC then New_Line (Win); end if; Put (Win, Buf (From .. To)); if Len < W and then Ljust then declare Filler : constant String (1 .. (W - Len)) := (others => ' '); begin Put (Win, Filler); end; end if; end if; end if; end Output; begin pragma Assert (Win /= Null_Window); if Ljust then L := 1; for I in 1 .. Buf'Length loop exit when Buf (L) = ' '; L := L + 1; end loop; Len := L - 1; Output (1, Len); else -- input buffer is not left justified L := Buf'Length; for I in 1 .. Buf'Length loop exit when Buf (L) = ' '; L := L - 1; end loop; Len := Buf'Length - L; Output (L + 1, Buf'Length); end if; end Put_Buf; end Terminal_Interface.Curses.Text_IO.Aux;
reznikmm/matreshka
Ada
6,838
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_Db.Data_Source_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Db_Data_Source_Element_Node is begin return Self : Db_Data_Source_Element_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Db_Data_Source_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_Db_Data_Source (ODF.DOM.Db_Data_Source_Elements.ODF_Db_Data_Source_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 Db_Data_Source_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Data_Source_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Db_Data_Source_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_Db_Data_Source (ODF.DOM.Db_Data_Source_Elements.ODF_Db_Data_Source_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 Db_Data_Source_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Db_Data_Source (Visitor, ODF.DOM.Db_Data_Source_Elements.ODF_Db_Data_Source_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.Db_URI, Matreshka.ODF_String_Constants.Data_Source_Element, Db_Data_Source_Element_Node'Tag); end Matreshka.ODF_Db.Data_Source_Elements;
reznikmm/matreshka
Ada
4,599
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_Draw.Show_Unit_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Show_Unit_Attribute_Node is begin return Self : Draw_Show_Unit_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Show_Unit_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Show_Unit_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Show_Unit_Attribute, Draw_Show_Unit_Attribute_Node'Tag); end Matreshka.ODF_Draw.Show_Unit_Attributes;
zhmu/ananas
Ada
980
adb
-- { dg-do compile } -- { dg-options "-O -w" } package body Vect9 is function Cmove (X : in Unit; Y : in Unit; If_True : in Unit; If_False : in Unit) return Unit is Res : Unit; begin for P in Unit'Range loop if X (P) >= Y (P) then Res (P) := If_True (P); else Res (P) := If_False (P); end if; end loop; return Res; end; pragma Inline_Always (Cmove); procedure Proc (This : in Rec; CV : in Unit_Vector; Data : in out Unit_Vector) is begin for Index in Data'Range loop Data (Index) := Mul (Zero_Unit, Zero_Unit); declare Addend : constant Unit := Cmove (CV (Index), Zero_Unit, Zero_Unit, Zero_Unit) ; begin Data (Index) := Data(Index) + Addend; end; This.Data (Index) := Data (Index); end loop; end; end Vect9;
sebsgit/textproc
Ada
17,633
adb
with PixelArray; with ImageIO; with ImageRegions; with ImageMoments; with ImageFilters; with ImageThresholds; with Morphology; with Histogram; with HistogramDescriptor; with Ada.Text_IO; with Ada.Containers.Vectors; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Containers; with GpuImageProc; use GpuImageProc; with cl_objects; with opencl; use opencl; with PixelArray.Gpu; with GpuComponentLabeling; use GpuComponentLabeling; package body ShapeDatabase is Gauss_Filter_Kernel_Size: constant Positive := 7; Gauss_Filter_Sigma: constant Float := 2.4; Bernsen_Threshold_Circle_Radius: constant Positive := 10; Bernsen_Threshold_Contrast_Limit: constant PixelArray.Pixel := 35; Erode_Kernel_Size: constant Positive := 7; Dilate_Kernel_Size: constant Positive := 7; gpu_context: cl_objects.Context_Access; gpu_queue: cl_objects.Command_Queue_Access; gpu_processor: GpuImageProc.Processor_Access; gpu_detector: GpuComponentLabeling.Processor_Access; gpu_source_cache: PixelArray.Gpu.GpuImage_Access; gpu_target_cache: PixelArray.Gpu.GpuImage_Access; procedure Find_Gpu_Device(platf: out Platform_ID; dev: out Device_ID) is cl_code: opencl.Status; platform_ids: constant opencl.Platforms := opencl.Get_Platforms(cl_code); begin if cl_code = opencl.SUCCESS then for p_id of platform_ids loop declare device_ids: constant opencl.Devices := opencl.Get_Devices(id => p_id, dev_type => opencl.DEVICE_TYPE_GPU, result_status => cl_code); begin if cl_code = opencl.SUCCESS and device_ids'Length > 0 then platf := p_id; dev := device_ids(1); exit; end if; end; end loop; end if; end Find_Gpu_Device; procedure Init_Gpu is cl_status: opencl.Status := opencl.Init(opencl.Get_OpenCL_Path(opencl.ARCH_32)); platf_id: opencl.Platform_ID := 0; dev_id: opencl.Device_ID := 0; begin if cl_status /= opencl.SUCCESS then Ada.Text_IO.Put_Line("Cannot init OpenCL: " & cl_status'Image); return; end if; Find_Gpu_Device(platf_id, dev_id); if dev_id = 0 then Ada.Text_IO.Put_Line("Cannot find GPU device"); return; end if; gpu_context := new cl_objects.Context'(cl_objects.Create(context_platform => platf_id, context_device => dev_id, result_status => cl_status)); if cl_status /= opencl.SUCCESS then Ada.Text_IO.Put_Line("Cannot init GPU context: " & cl_status'Image); return; end if; gpu_queue := new cl_objects.Command_Queue'(gpu_context.Create_Command_Queue(cl_status)); if cl_status /= opencl.SUCCESS then Ada.Text_IO.Put_Line("Cannot init GPU queue: " & cl_status'Image); return; end if; gpu_processor := new GpuImageProc.Processor'(GpuImageProc.Create_Processor(context => gpu_context.all, status => cl_status)); if cl_status /= opencl.SUCCESS then Ada.Text_IO.Put_Line("Cannot init GPU processor: " & cl_status'Image); gpu_processor := null; return; end if; gpu_detector := new GpuComponentLabeling.Processor'(GpuComponentLabeling.Create(ctx => gpu_context, width => 256, height => 256, cl_code => cl_status)); if cl_status /= opencl.SUCCESS then Ada.Text_IO.Put_Line("Cannot init GPU detector: " & cl_status'Image); gpu_detector := null; return; end if; gpu_source_cache := new PixelArray.Gpu.GpuImage'(PixelArray.Gpu.Create(ctx => gpu_context.all, flags => (others => False), width => 256, height => 256, status => cl_status)); gpu_target_cache := new PixelArray.Gpu.GpuImage'(PixelArray.Gpu.Create(ctx => gpu_context.all, flags => (others => False), width => 256, height => 256, status => cl_status)); end Init_Gpu; function Ensure_Cache_Size(gpu_image: in out PixelArray.Gpu.GpuImage; context: in out cl_objects.Context; width, height: in Positive) return Boolean is begin if gpu_image.Get_Width /= width or gpu_image.Get_Height /= height then gpu_image.Set_Size(context => context, width => width, height => height); end if; return True; end Ensure_Cache_Size; function Ensure_Cache_Size(gpu_image: in out PixelArray.Gpu.GpuImage; context: in out cl_objects.Context; image: in PixelArray.ImagePlane) return Boolean is cl_code: constant opencl.Status := gpu_image.Upload_Image(context, gpu_queue.all, image); begin return (cl_code = opencl.SUCCESS); end Ensure_Cache_Size; procedure Detect_Image_Regions(image: in out PixelArray.ImagePlane; res: out ImageRegions.RegionVector.Vector) is cl_code: opencl.Status; begin if gpu_detector /= null then res := gpu_detector.Detect_Regions_And_Assign_Labels(preprocessed_cpu_image => image, cl_code => cl_code); else res := ImageRegions.detectRegions(image); end if; end Detect_Image_Regions; function Preprocess_Gpu(gpuSource: in out PixelArray.Gpu.GpuImage; cl_code: out opencl.Status) return cl_objects.Event is cache_status: Boolean := Ensure_Cache_Size(gpu_target_cache.all, gpu_context.all, gpuSource.Get_Width, gpuSource.Get_Height); gauss_proc_event: constant cl_objects.Event := gpu_processor.Gaussian_Filter(ctx => gpu_context.all, source => gpuSource, target => gpu_target_cache.all, size => Gauss_Filter_Kernel_Size, sigma => Gauss_Filter_Sigma, cl_code => cl_code); proc_event: constant cl_objects.Event := gpu_processor.Bernsen_Adaptative_Threshold(ctx => gpu_context.all, source => gpu_target_cache.all, target => gpuSource, radius => Bernsen_Threshold_Circle_Radius, c_min => Bernsen_Threshold_Contrast_Limit, events_to_wait => (1 => gauss_proc_event.Get_Handle), cl_code => cl_code); erode_event: constant cl_objects.Event := gpu_processor.Erode(ctx => gpu_context.all, source => gpuSource, target => gpu_target_cache.all, size => Erode_Kernel_Size, events_to_wait => (1 => proc_event.Get_Handle), cl_code => cl_code); begin return gpu_processor.Dilate(ctx => gpu_context.all, source => gpu_target_cache.all, target => gpuSource, size => Dilate_Kernel_Size, events_to_wait => (1 => erode_event.Get_Handle), cl_code => cl_code); end Preprocess_Gpu; function Preprocess_And_Detect_Regions(image: in PixelArray.ImagePlane; res: out ImageRegions.RegionVector.Vector) return PixelArray.ImagePlane is begin if gpu_detector = null or gpu_processor = null then return processed: PixelArray.ImagePlane := preprocess(image) do Detect_Image_Regions(processed, res); end return; else return result: PixelArray.ImagePlane := PixelArray.allocate(width => image.width, height => image.height) do declare cl_code: opencl.Status; cache_status: Boolean := Ensure_Cache_Size(gpu_source_cache.all, gpu_context.all, image); preproc_event: constant cl_objects.Event := Preprocess_Gpu(gpuSource => gpu_source_cache.all, cl_code => cl_code); begin res := gpu_detector.Detect_Regions_And_Assign_Labels(preprocessed_gpu_image => gpu_source_cache.all, target_cpu_image => result, events_to_wait => (1 => preproc_event.Get_Handle), cl_code => cl_code); end; end return; end if; end Preprocess_And_Detect_Regions; function preprocess(image: PixelArray.ImagePlane) return PixelArray.ImagePlane is fallback_to_cpu: Boolean := True; begin --TODO implement the whole preprocessing pipeline in opencl return result: PixelArray.ImagePlane := PixelArray.allocate(width => image.width, height => image.height) do -- threshold adaptative if gpu_processor /= null then declare cl_code: opencl.Status; cache_status: Boolean := Ensure_Cache_Size(gpu_source_cache.all, gpu_context.all, image); preproc_event: constant cl_objects.Event := Preprocess_Gpu(gpuSource => gpu_source_cache.all, cl_code => cl_code); downl_ev: cl_objects.Event := PixelArray.Gpu.Download(gpu_processor.Get_Command_Queue.all, gpu_source_cache.all, result, (1 => preproc_event.Get_Handle), cl_code); begin cl_code := downl_ev.Wait; if cl_code = opencl.SUCCESS then fallback_to_cpu := False; end if; end; end if; if fallback_to_cpu then Ada.Text_IO.Put_Line("GPU download failed, fallback to CPU"); result.assign(ImageFilters.gaussian(image, Gauss_Filter_Kernel_Size, Gauss_Filter_Sigma)); result.assign(ImageThresholds.bernsenAdaptative(result, radius => Bernsen_Threshold_Circle_Radius, c_min => Bernsen_Threshold_Contrast_Limit)); -- apply morphology to strenghten shapes result.assign(Morphology.erode(result, Erode_Kernel_Size)); result.assign(Morphology.dilate(result, Dilate_Kernel_Size)); end if; end return; end preprocess; function processRegion(image: PixelArray.ImagePlane; rect: ImageRegions.Region) return Descriptor is result: Descriptor; begin result.moments := ImageMoments.calculateMoments(image, rect); result.orientation := ImageMoments.orientationAngle(image, rect); result.histogram := HistogramDescriptor.create(image => image, region => rect.area); return result; end processRegion; function loadShape(cc: Character; path: String) return CharacterDescriptor is result: CharacterDescriptor; regions: ImageRegions.RegionVector.Vector; image: constant PixelArray.ImagePlane := Preprocess_And_Detect_Regions(ImageIO.load(path), regions); begin result.c := cc; result.d := processRegion(image, regions.First_Element); return result; end loadShape; procedure add(database: in out DB; desc: CharacterDescriptor) is begin database.shapes.Append(desc); end add; function getDB return DB is begin return staticDB; end getDB; function match(database: DB; image: PixelArray.ImagePlane; region: ImageRegions.Region) return MatchScore is result: MatchScore; tmp: Character; tmpScore: Float; regionDescriptor: ImageMoments.HuMoments; d1, d2, d3, d4: Float; begin result.cc := '-'; result.score := 99999.0; regionDescriptor := ImageMoments.calculateMoments(image, region); tmpScore := ImageMoments.orientationAngle(image, region); -- Ada.Text_IO.Put_Line("orient: " & tmpScore'Image); for i in 0 .. Integer(database.shapes.Length - 1) loop d1 := ImageMoments.match_I1(regionDescriptor, database.shapes.Element(i).d.moments); d2 := ImageMoments.match_I2(regionDescriptor, database.shapes.Element(i).d.moments); d3 := ImageMoments.match_I3(regionDescriptor, database.shapes.Element(i).d.moments); d4 := (d1 + d3) / 2.0; tmpScore := d4; tmp := database.shapes.Element(i).c; -- Ada.Text_IO.Put_Line("match with " & tmp'Image & " => " & tmpScore'Image); if tmpScore < result.score then result.score := tmpScore; result.cc := tmp; end if; end loop; return result; end match; function getCharacterString(imagePath: String) return Ada.Strings.Unbounded.Unbounded_String is firstDotPosition: Natural := 0; lastSlashPosition: Natural := 0; startIndex: Natural := 1; result: Ada.Strings.Unbounded.Unbounded_String; begin lastSlashPosition := Ada.Strings.Fixed.Index(imagePath, "/", Ada.Strings.Backward); if lastSlashPosition /= 0 then startIndex := lastSlashPosition + 1; end if; firstDotPosition := Ada.Strings.Fixed.Index(imagePath, ".", startIndex); result := Ada.Strings.Unbounded.To_Unbounded_String(imagePath); result := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Strings.Unbounded.Slice(result, startIndex, firstDotPosition - 1)); return result; end getCharacterString; function loadShapes(imagePath: String) return ShapeVector.Vector is result: ShapeVector.Vector; r: ImageRegions.RegionVector.Vector; image: constant PixelArray.ImagePlane := Preprocess_And_Detect_Regions(ImageIO.load(imagePath), r); basePath: constant Ada.Strings.Unbounded.Unbounded_String := getCharacterString(imagePath); begin if Integer(r.Length) /= Ada.Strings.Unbounded.Length(basePath) then raise Capacity_Error with imagePath & " --> " & Ada.Strings.Unbounded.To_String(basePath) & ": processing error"; end if; ImageRegions.sortRegions(r); for i in 0 .. r.Length - 1 loop declare desc: CharacterDescriptor; begin desc.c := imagePath(Integer(i + 1)); desc.d := processRegion(image, r(Integer(i))); result.Append(desc); end; end loop; return result; end loadShapes; procedure insertShapes(result: out DB; imagePath: String) is shapes: ShapeVector.Vector; begin shapes := loadShapes(imagePath); for d in 0 .. shapes.Length - 1 loop result.add(shapes(Integer(d))); end loop; end insertShapes; function init return DB is result: DB; begin result.add(loadShape('0', "0.jpg")); result.add(loadShape('1', "1.jpg")); result.add(loadShape('1', "1_1.jpg")); result.add(loadShape('2', "2.jpg")); result.add(loadShape('2', "2_.jpg")); result.add(loadShape('3', "3.jpg")); result.add(loadShape('4', "4.jpg")); result.add(loadShape('7', "7.jpg")); result.add(loadShape('8', "8.jpg")); result.add(loadShape('9', "9.jpg")); insertShapes(result, "20180501.1.jpg"); return result; end init; begin Init_Gpu; staticDB := init; end ShapeDatabase;
vasil-sd/ada-tlsf
Ada
488
ads
with BitOperations.Shift; with BitOperations.Types; generic with package Types is new BitOperations.Types (<>); package BitOperations.Mask with SPARK_Mode, Pure, Preelaborate is package Shift is new BitOperations.Shift(Types); use Types; use Shift; function Make (Size : Mask_Size) return Modular is (Logic_Right(Modular'Last, Modular'Size - Size)) with Pre => Size in 0 .. Modular'Size, Post => Make'Result = 2 ** Size -1; end BitOperations.Mask;
stcarrez/ada-awa
Ada
3,727
adb
----------------------------------------------------------------------- -- security-auth-fake -- A fake OAuth provider for unit tests -- Copyright (C) 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Security.Auth.Fake is -- Initialize the OpenID authentication realm. Get the <tt>openid.realm</tt> -- and <tt>openid.callback_url</tt> parameters to configure the realm. overriding procedure Initialize (Realm : in out Manager; Params : in Parameters'Class; Name : in String := PROVIDER_OPENID) is pragma Unreferenced (Realm, Params, Name); begin null; end Initialize; -- Discover the OpenID provider that must be used to authenticate the user. -- The <b>Name</b> can be an URL or an alias that identifies the provider. -- A cached OpenID provider can be returned. -- Read the XRDS document from the URI and initialize the OpenID provider end point. -- (See OpenID Section 7.3 Discovery) overriding procedure Discover (Realm : in out Manager; Name : in String; Result : out End_Point) is pragma Unreferenced (Realm, Name, Result); begin null; end Discover; -- Associate the application (relying party) with the OpenID provider. -- The association can be cached. -- (See OpenID Section 8 Establishing Associations) overriding procedure Associate (Realm : in out Manager; OP : in End_Point; Result : out Association) is pragma Unreferenced (Realm, OP, Result); begin null; end Associate; -- Get the authentication URL to which the user must be redirected for authentication -- by the authentication server. overriding function Get_Authentication_URL (Realm : in Manager; OP : in End_Point; Assoc : in Association) return String is pragma Unreferenced (Realm, OP, Assoc); begin return "/fake-authorization-server"; end Get_Authentication_URL; -- Verify the authentication result overriding procedure Verify (Realm : in out Manager; Assoc : in Association; Request : in Parameters'Class; Result : out Authentication) is pragma Unreferenced (Realm, Assoc); Email : constant String := Request.Get_Parameter ("email"); Claimed_Id : constant String := Request.Get_Parameter ("claimed_id"); Identity : constant String := Request.Get_Parameter ("id"); begin if Email'Length = 0 or else Identity'Length = 0 then Result.Status := Security.Auth.CANCEL; else Result.Status := Security.Auth.AUTHENTICATED; end if; Result.Identity := To_Unbounded_String (Identity); Result.Claimed_Id := To_Unbounded_String (Claimed_Id); Result.Email := To_Unbounded_String (Email); end Verify; end Security.Auth.Fake;
AdaCore/spat
Ada
917
adb
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); package body SPAT.Unique_Ids is Current_Id : aliased Id := Id'First; -- Start at zero. --------------------------------------------------------------------------- -- Next --------------------------------------------------------------------------- function Next return Id is (GNATCOLL.Atomic.Sync_Add_And_Fetch (Ptr => Current_Id'Access, Value => 1)); end SPAT.Unique_Ids;
reznikmm/matreshka
Ada
4,009
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Start_Guide_Attributes; package Matreshka.ODF_Draw.Start_Guide_Attributes is type Draw_Start_Guide_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Start_Guide_Attributes.ODF_Draw_Start_Guide_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Start_Guide_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Start_Guide_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Start_Guide_Attributes;
adamduracz/polypaver
Ada
20
ads
procedure PP_FPops;
xeenta/learning-ada
Ada
1,522
adb
with Animals.Humans; with Animals.Flying_Horses; use Animals; with Ada.Text_IO; use Ada.Text_IO; procedure Test_Humans_Horses is Rider : Humans.Human := Humans.Make ("Knight Rider", Humans.Male); Pegasus : Flying_Horses.Flying_Horse := Flying_Horses.Make (Flying_Horses.Snow_White); procedure Transform_Accordingly (O : in out Animal) is begin O.Add_Wings (2); O.Add_Legs (1); end Transform_Accordingly; procedure Transform_Accordingly_OK (O : in out Animal'Class) is begin O.Add_Wings (2); O.Add_Legs (1); end Transform_Accordingly_OK; NL : constant Character := Character'Val (10); begin Put_Line("Original Rider" & NL & Integer'Image (Rider.Wings) & " wings" & NL & Integer'Image (Rider.Legs) & " legs"); Put_Line("Original Pegasus" & NL & Integer'Image (Pegasus.Wings) & " wings" & NL & Integer'Image (Pegasus.Legs) & " legs"); -- This isn't what we want --Transform_Accordingly (Animal (Rider)); --Transform_Accordingly (Animal (Pegasus)); Transform_Accordingly_OK (Rider); Transform_Accordingly_OK (Pegasus); Put_Line("Trans Rider" & NL & Integer'Image (Rider.Wings) & " wings" & NL & Integer'Image (Rider.Legs) & " legs"); Put_Line("Trans Pegasus" & NL & Integer'Image (Pegasus.Wings) & " wings" & NL & Integer'Image (Pegasus.Legs) & " legs"); end Test_Humans_Horses;
afrl-rq/OpenUxAS
Ada
66,638
adb
with Ada.Text_IO; use Ada.Text_IO; package body Route_Aggregator with SPARK_Mode is pragma Unevaluated_Use_Of_Old (Allow); pragma Assertion_Policy (Ignore); -- Lemmas used to factor out reasonning about the redefined model of -- Int64_Formal_Set_Maps ------------------- -- Model_Include -- ------------------- procedure Model_Include (M1, M2 : Int64_Formal_Set_Maps.Formal_Model.M.Map; N1, N2 : Int_Set_Maps_M.Map) -- Lemma: Inclusion of old models implies inclusion of redefined models with Ghost, Global => null, Pre => Same_Mappings (M1, N1) and Same_Mappings (M2, N2) and M1 <= M2, Post => N1 <= N2; procedure Model_Include (M1, M2 : Int64_Formal_Set_Maps.Formal_Model.M.Map; N1, N2 : Int_Set_Maps_M.Map) is begin null; end Model_Include; ----------------------------- -- Lift_From_Keys_To_Model -- ----------------------------- procedure Lift_From_Keys_To_Model (PendingRoute : Int64_Formal_Set_Map) -- Lemma: Lift quantification done on Keys of the pending route map to its -- model. with Ghost, Global => null, Post => (for all Key of Model (PendingRoute) => (Find (Keys (PendingRoute), Key) > 0 and then Int_Set_Maps_K.Get (Keys (PendingRoute), Find (Keys (PendingRoute), Key)) = Key)); procedure Lift_From_Keys_To_Model (PendingRoute : Int64_Formal_Set_Map) is begin null; end Lift_From_Keys_To_Model; -- Subprograms wraping insertion and deletion in m_pendingRoute. They -- restate part of the postcondition of the callee, but also reestablish -- the predicate of Route_Aggregator_State and compute the effect of the -- modification on Plan_To_Route. ----------------------- -- Local subprograms -- ----------------------- procedure Check_All_Route_Plans_PendingAutoReq (Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State) with -- General invariants Pre => All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans) and Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans) and Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses) and (for all K in 1 .. Length (State.m_pendingRoute) => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))) -- History invariants and Valid_Events (State.m_routeRequestId) and No_RouteRequest_Lost (State.m_pendingRoute) and No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses) and All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses), -- General invariants Post => All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans) and Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans) and Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses) and No_Finished_Request (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses) -- History invariants and History'Old <= History and Valid_Events (State.m_routeRequestId) and No_RouteRequest_Lost (State.m_pendingRoute) and No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses) and All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses); procedure Check_All_Route_Plans_PendingRoute (Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State) with -- General invariants Pre => All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans) and Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans) and Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses) -- History invariants and Valid_Events (State.m_routeRequestId) and No_RouteRequest_Lost (State.m_pendingRoute) and No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses) and All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses), -- General invariants Post => All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans) and Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans) and Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses) and (for all K in 1 .. Length (State.m_pendingRoute) => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))) -- History invariants and History'Old <= History and Valid_Events (State.m_routeRequestId) and No_RouteRequest_Lost (State.m_pendingRoute) and No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses) and All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses); procedure Delete_PendingRequest (m_pendingRequest : in out Int64_Formal_Set_Map; otherPending : Int64_Formal_Set_Map; m_routeRequestId : Int64; Position : in out Int64_Formal_Set_Maps.Cursor) with Pre => Has_Element (m_pendingRequest, Position) and All_Pending_Requests_Seen (Model (m_pendingRequest), m_routeRequestId) and No_Overlaps (Model (m_pendingRequest)) and No_Overlaps (Model (m_pendingRequest), Model (otherPending)), Post => -- Predicate of State All_Pending_Requests_Seen (Model (m_pendingRequest), m_routeRequestId) and No_Overlaps (Model (m_pendingRequest)) and No_Overlaps (Model (m_pendingRequest), Model (otherPending)) -- Postcondition copied from Int64_Formal_Set_Maps.Delete and Length (m_pendingRequest) = Length (m_pendingRequest)'Old - 1 and not Int_Set_Maps_M.Has_Key (Model (m_pendingRequest), Key (m_pendingRequest, Position)'Old) and not Int_Set_Maps_P.Has_Key (Positions (m_pendingRequest), Position'Old) and Model (m_pendingRequest) <= Model (m_pendingRequest)'Old and Int_Set_Maps_M.Keys_Included_Except (Model (m_pendingRequest)'Old, Model (m_pendingRequest), Key (m_pendingRequest, Position)'Old) and Int_Set_Maps_K.Range_Equal (Left => Keys (m_pendingRequest)'Old, Right => Keys (m_pendingRequest), Fst => 1, Lst => Int_Set_Maps_P.Get (Positions (m_pendingRequest)'Old, Position'Old) - 1) and Int_Set_Maps_K.Range_Shifted (Left => Keys (m_pendingRequest), Right => Keys (m_pendingRequest)'Old, Fst => Int_Set_Maps_P.Get (Positions (m_pendingRequest)'Old, Position'Old), Lst => Length (m_pendingRequest), Offset => 1) and P_Positions_Shifted (Positions (m_pendingRequest), Positions (m_pendingRequest)'Old, Cut => Int_Set_Maps_P.Get (Positions (m_pendingRequest)'Old, Position'Old)) -- Effect on Plan_To_Route and Plan_To_Route (m_pendingRequest) <= Plan_To_Route (m_pendingRequest)'Old and (for all I of Plan_To_Route (m_pendingRequest)'Old => Has_Key (Plan_To_Route (m_pendingRequest), I) or else Get (Plan_To_Route (m_pendingRequest)'Old, I) = Key (m_pendingRequest, Position)'Old); procedure Insert_PendingRequest (m_pendingRequest : in out Int64_Formal_Set_Map; otherPending : Int64_Formal_Set_Map; m_routeRequestId : Int64; RequestID : Int64; PlanRequests : Int64_Formal_Set) with Pre => not Int_Set_Maps_M.Has_Key (Model (m_pendingRequest), RequestID) and Length (m_pendingRequest) < m_pendingRequest.Capacity and All_Pending_Requests_Seen (Model (m_pendingRequest), m_routeRequestId) and No_Overlaps (Model (m_pendingRequest)) and No_Overlaps (Model (m_pendingRequest), Model (otherPending)) and (for all Id of PlanRequests => Id <= m_routeRequestId) and (for all R_Id of Model (m_pendingRequest) => (for all E of Int_Set_Maps_M.Get (Model (m_pendingRequest), R_Id) => not Contains (PlanRequests, E))) and (for all R_Id of Model (otherPending) => (for all E of Int_Set_Maps_M.Get (Model (otherPending), R_Id) => not Contains (PlanRequests, E))), Post => -- Predicate of State All_Pending_Requests_Seen (Model (m_pendingRequest), m_routeRequestId) and No_Overlaps (Model (m_pendingRequest)) and No_Overlaps (Model (m_pendingRequest), Model (otherPending)) -- Part of the postcondition copied from Int64_Formal_Set_Maps.Insert and Model (m_pendingRequest)'Old <= Model (m_pendingRequest) and Contains (Model (m_pendingRequest), RequestID) and (for all E of Int_Set_Maps_M.Get (Model (m_pendingRequest), RequestID) => Contains (PlanRequests, E)) and (for all E of PlanRequests => Contains (Int_Set_Maps_M.Get (Model (m_pendingRequest), RequestID), E)) and (for all K of Model (m_pendingRequest) => Int_Set_Maps_M.Has_Key (Model (m_pendingRequest)'Old, K) or K = RequestID) -- Effect on Plan_To_Route and Plan_To_Route (m_pendingRequest)'Old <= Plan_To_Route (m_pendingRequest) and (for all I of PlanRequests => Has_Key (Plan_To_Route (m_pendingRequest), I) and then Get (Plan_To_Route (m_pendingRequest), I) = RequestID) and (for all I of Plan_To_Route (m_pendingRequest) => Contains (PlanRequests, I) or Has_Key (Plan_To_Route (m_pendingRequest)'Old, I)); --------------------------- -- Build_Matrix_Requests -- --------------------------- procedure Build_Matrix_Requests (Mailbox : in out Route_Aggregator_Mailbox; Data : Route_Aggregator_Configuration_Data; State : in out Route_Aggregator_State; ReqId : Int64) with SPARK_Mode => Off is sendAirPlanRequest : RPReq_Seq; sendGroundPlanRequest : RPReq_Seq; Empty_Formal_Set : Int64_Formal_Set; begin Insert (State.m_pendingAutoReq, ReqId, Empty_Formal_Set); if Length (Element (State.m_uniqueAutomationRequests, ReqId).EntityList) = 0 then declare AReq : UniqueAutomationRequest := Element (State.m_uniqueAutomationRequests, ReqId); begin AReq.EntityList := Data.m_entityStates; Replace (State.m_uniqueAutomationRequests, ReqId, AReq); end; end if; declare AReq : constant UniqueAutomationRequest := Element (State.m_uniqueAutomationRequests, ReqId); begin For_Each_Vehicle : for VehicleId of AReq.EntityList loop Make_Request : declare StartHeading_Deg : Real32 := 0.0; StartLocation : Location3D; FoundPlanningState : Boolean := False; Vehicle : EntityState; begin for PlanningState of AReq.PlanningStates loop if PlanningState.EntityID = VehicleId then StartLocation := PlanningState.PlanningPosition; StartHeading_Deg := PlanningState.PlanningHeading; FoundPlanningState := True; exit; end if; end loop; if FoundPlanningState or else (for some EntityId of Data.m_entityStates => (EntityId = VehicleId)) then Build_Eligible_Task_Options : declare TaskOptionList : TaskOption_Seq; Found_Elig : Boolean := False; PlanRequest : RoutePlanRequest; Set : Int64_Formal_Set := Element (State.m_pendingAutoReq, ReqId); begin for TaskId of AReq.TaskList loop if Contains (State.m_taskOptions, TaskId) then for Option of Element (State.m_taskOptions, TaskId).Options loop Found_Elig := False; for V of Option.EligibleEntities loop if V = VehicleId then Found_Elig := True; exit; end if; end loop; if Length (Option.EligibleEntities) = 0 or else Found_Elig then TaskOptionList := Add (TaskOptionList, Option); end if; end loop; end if; end loop; PlanRequest.AssociatedTaskID := 0; PlanRequest.IsCostOnlyRequest := False; PlanRequest.OperatingRegion := AReq.OperatingRegion; PlanRequest.VehicleID := VehicleId; State.m_routeRequestId := State.m_routeRequestId + 1; PlanRequest.RequestID := State.m_routeRequestId; Insert (Set, State.m_routeRequestId); Replace (State.m_pendingAutoReq, ReqId, Set); if not FoundPlanningState then Vehicle := ES_Maps.Get (Data.m_entityStatesInfo, VehicleId); StartLocation := Vehicle.Location; StartHeading_Deg := Vehicle.Heading; end if; for Option of TaskOptionList loop declare TOP : constant TaskOptionPair := (VehicleId, 0, 0, Option.TaskID, Option.OptionID); R : RouteConstraints; begin Insert (State.m_routeTaskPairing, State.m_routeId + 1, TOP); R.StartLocation := StartLocation; R.StartHeading := StartHeading_Deg; R.EndLocation := Option.StartLocation; R.EndHeading := Option.StartHeading; R.RouteID := State.m_routeId + 1; PlanRequest.RouteRequests := Add (PlanRequest.RouteRequests, R); State.m_routeId := State.m_routeId + 1; end; end loop; for T1 in TaskOptionList loop for T2 in TaskOptionList loop if T1 /= T2 then declare O1 : constant TaskOption := Get (TaskOptionList, T1); O2 : constant TaskOption := Get (TaskOptionList, T2); TOP : constant TaskOptionPair := (VehicleId, O1.TaskID, O1.OptionID, O2.TaskID, O2.OptionID); R : RouteConstraints; begin Insert (State.m_routeTaskPairing, State.m_routeId + 1, TOP); R.StartLocation := O1.EndLocation; R.StartHeading := O1.EndHeading; R.EndLocation := O2.StartLocation; R.EndHeading := O2.StartHeading; R.RouteID := State.m_routeId + 1; PlanRequest.RouteRequests := Add (PlanRequest.RouteRequests, R); State.m_routeId := State.m_routeId + 1; end; end if; end loop; end loop; if Contains (Data.m_groundVehicles, VehicleId) then sendGroundPlanRequest := Add (sendGroundPlanRequest, PlanRequest); else sendAirPlanRequest := Add (sendAirPlanRequest, PlanRequest); end if; end Build_Eligible_Task_Options; end if; end Make_Request; end loop For_Each_Vehicle; for RPReq of sendAirPlanRequest loop sendLimitedCastMessage (Mailbox, AircraftPathPlanner, RPReq); end loop; for RPReq of sendGroundPlanRequest loop if Data.m_fastPlan then Euclidean_Plan (Data, State.m_routePlanResponses, State.m_routePlans, RPReq); else sendLimitedCastMessage (Mailbox, GroundPathPlanner, RPReq); end if; end loop; if Data.m_fastPlan then Check_All_Route_Plans (Mailbox, State); end if; end; end Build_Matrix_Requests; --------------------------- -- Check_All_Route_Plans -- --------------------------- procedure Check_All_Route_Plans (Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State) is begin Check_All_Route_Plans_PendingRoute (Mailbox, State); Check_All_Route_Plans_PendingAutoReq (Mailbox, State); end Check_All_Route_Plans; ------------------------------------------ -- Check_All_Route_Plans_PendingAutoReq -- ------------------------------------------ procedure Check_All_Route_Plans_PendingAutoReq (Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State) is i : Int64_Formal_Set_Maps.Cursor := First (State.m_pendingAutoReq); D : Count_Type := 0 with Ghost; -- Number of removed elements begin -- Check pending automation requests while Has_Element (State.m_pendingAutoReq, i) loop pragma Loop_Invariant (Has_Element (State.m_pendingAutoReq, i)); pragma Loop_Invariant (D = Length (State.m_pendingAutoReq)'Loop_Entry - Length (State.m_pendingAutoReq)); pragma Loop_Invariant (Model (State.m_pendingAutoReq) <= Int_Set_Maps_M.Map'(Model (State.m_pendingAutoReq))'Loop_Entry); pragma Loop_Invariant (for all K in 1 .. Int_Set_Maps_P.Get (Positions (State.m_pendingAutoReq), i) - 1 => (for some L in 1 .. Int_Set_Maps_P.Get (Positions (State.m_pendingAutoReq), i) - 1 + D => Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq), K) = Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq)'Loop_Entry, L))); pragma Loop_Invariant (for all K in 1 .. Int_Set_Maps_P.Get (Positions (State.m_pendingAutoReq), i) - 1 => Is_Pending (Model (State.m_pendingAutoReq), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq), K))); pragma Loop_Invariant (for all K in Int_Set_Maps_P.Get (Positions (State.m_pendingAutoReq), i) .. Length (State.m_pendingAutoReq) => Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq), K) = Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq)'Loop_Entry, K + D)); -- General invariants pragma Loop_Invariant (All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans)); pragma Loop_Invariant (Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans)); pragma Loop_Invariant (Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); pragma Loop_Invariant (for all K in 1 .. Length (State.m_pendingRoute) => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))); -- History invariants pragma Loop_Invariant (History'Loop_Entry <= History); pragma Loop_Invariant (Valid_Events (State.m_routeRequestId)); pragma Loop_Invariant (No_RouteRequest_Lost (State.m_pendingRoute)); pragma Loop_Invariant (No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses)); pragma Loop_Invariant (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); declare isFulfilled : constant Boolean := (for all J of Element (State.m_pendingAutoReq, i) => Contains (State.m_routePlanResponses, J)); begin if isFulfilled then SendMatrix (Mailbox, State.m_uniqueAutomationRequests, State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlans, State.m_routeTaskPairing, State.m_routePlanResponses, State.m_taskOptions, Key (State.m_pendingAutoReq, i)); declare Dummy : Int64_Formal_Set_Maps.Cursor := i; UAR_Key : constant Int64 := Key (State.m_pendingAutoReq, i); Pos : constant Count_Type := Int_Set_Maps_P.Get (Positions (State.m_pendingAutoReq), i) with Ghost; begin Next (State.m_pendingAutoReq, i); Delete_PendingRequest (State.m_pendingAutoReq, State.m_pendingRoute, State.m_routeRequestId, Dummy); Delete (State.m_uniqueAutomationRequests, UAR_Key); D := D + 1; pragma Assert (for all K in 1 .. Pos - 1 => Is_Pending (Model (State.m_pendingAutoReq), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq), K))); end; else Next (State.m_pendingAutoReq, i); end if; end; end loop; -- Restablish No_Finished_Request pragma Assert (for all K in 1 .. Length (State.m_pendingRoute) => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))); Lift_From_Keys_To_Model (State.m_pendingRoute); pragma Assert (for all K in 1 .. Length (State.m_pendingAutoReq) => Is_Pending (Model (State.m_pendingAutoReq), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingAutoReq), K))); Lift_From_Keys_To_Model (State.m_pendingAutoReq); end Check_All_Route_Plans_PendingAutoReq; ---------------------------------------- -- Check_All_Route_Plans_PendingRoute -- ---------------------------------------- procedure Check_All_Route_Plans_PendingRoute (Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State) is i : Int64_Formal_Set_Maps.Cursor := First (State.m_pendingRoute); D : Count_Type := 0 with Ghost; -- Number of removed elements begin -- check pending route requests while Has_Element (State.m_pendingRoute, i) loop pragma Loop_Invariant (Has_Element (State.m_pendingRoute, i)); pragma Loop_Invariant (D = Length (State.m_pendingRoute)'Loop_Entry - Length (State.m_pendingRoute)); pragma Loop_Invariant (Model (State.m_pendingRoute) <= Int_Set_Maps_M.Map'(Model (State.m_pendingRoute))'Loop_Entry); pragma Loop_Invariant (for all K in 1 .. Int_Set_Maps_P.Get (Positions (State.m_pendingRoute), i) - 1 => (for some L in 1 .. Int_Set_Maps_P.Get (Positions (State.m_pendingRoute), i) - 1 + D => Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K) = Int_Set_Maps_K.Get (Keys (State.m_pendingRoute)'Loop_Entry, L))); pragma Loop_Invariant (for all K in 1 .. Int_Set_Maps_P.Get (Positions (State.m_pendingRoute), i) - 1 => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))); pragma Loop_Invariant (for all K in Int_Set_Maps_P.Get (Positions (State.m_pendingRoute), i) .. Length (State.m_pendingRoute) => Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K) = Int_Set_Maps_K.Get (Keys (State.m_pendingRoute)'Loop_Entry, K + D)); -- General invariants pragma Loop_Invariant (All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans)); pragma Loop_Invariant (Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans)); pragma Loop_Invariant (Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); -- History invariants pragma Loop_Invariant (History'Loop_Entry <= History); pragma Loop_Invariant (Valid_Events (State.m_routeRequestId)); pragma Loop_Invariant (No_RouteRequest_Lost (State.m_pendingRoute)); pragma Loop_Invariant (No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses)); pragma Loop_Invariant (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); declare isFulfilled : constant Boolean := (for all J of Element (State.m_pendingRoute, i) => Contains (State.m_routePlanResponses, J)); begin if isFulfilled then SendRouteResponse (Mailbox, State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses, State.m_routePlans, Key (State.m_pendingRoute, i)); declare Dummy : Int64_Formal_Set_Maps.Cursor := i; Pos : constant Count_Type := Int_Set_Maps_P.Get (Positions (State.m_pendingRoute), i) with Ghost; begin Next (State.m_pendingRoute, i); Delete_PendingRequest (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routeRequestId, Dummy); D := D + 1; pragma Assert (for all K in 1 .. Pos - 1 => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))); end; pragma Assert (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); else Next (State.m_pendingRoute, i); end if; end; end loop; pragma Assert (for all K in 1 .. Length (State.m_pendingRoute) => Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Int_Set_Maps_K.Get (Keys (State.m_pendingRoute), K))); end Check_All_Route_Plans_PendingRoute; ------------------------------------- -- Check_All_Task_Options_Received -- ------------------------------------- procedure Check_All_Task_Options_Received (Mailbox : in out Route_Aggregator_Mailbox; Data : Route_Aggregator_Configuration_Data; State : in out Route_Aggregator_State) with SPARK_Mode => Off is C : UAR_Maps.Cursor := First (State.m_uniqueAutomationRequests); begin while Has_Element (State.m_uniqueAutomationRequests, C) loop declare Areq : constant UniqueAutomationRequest := Element (State.m_uniqueAutomationRequests, C); AllReceived : constant Boolean := (for all TaskId of Areq.TaskList => Contains (State.m_taskOptions, TaskId)); begin if AllReceived then Build_Matrix_Requests (Mailbox, Data, State, Key (State.m_uniqueAutomationRequests, C)); end if; end; Next (State.m_uniqueAutomationRequests, C); end loop; end Check_All_Task_Options_Received; --------------------------- -- Delete_PendingRequest -- --------------------------- procedure Delete_PendingRequest (m_pendingRequest : in out Int64_Formal_Set_Map; otherPending : Int64_Formal_Set_Map; m_routeRequestId : Int64; Position : in out Int64_Formal_Set_Maps.Cursor) is pragma Unreferenced (otherPending, m_routeRequestId); Old_pendingRoute_M : constant Int64_Formal_Set_Maps.Formal_Model.M.Map := Int64_Formal_Set_Maps.Formal_Model.Model (m_pendingRequest) with Ghost; Old_pendingRoute : constant Int_Set_Maps_M.Map := Model (m_pendingRequest) with Ghost; begin Delete (m_pendingRequest, Position); -- Establish the effect on the redefined Model of maps of formal sets Model_Include (Int64_Formal_Set_Maps.Formal_Model.Model (m_pendingRequest), Old_pendingRoute_M, Model (m_pendingRequest), Old_pendingRoute); end Delete_PendingRequest; -------------------- -- Euclidean_Plan -- -------------------- procedure Euclidean_Plan (Data : Route_Aggregator_Configuration_Data; routePlanResponses : in out Int64_RouteResponse_Map; routePlans : in out Int64_IdPlanPair_Map; Request : RoutePlanRequest) is pragma Unreferenced (Data, routePlans, routePlanResponses, Request); -- -- UxAS::common::utilities::CUnitConversions flatEarth; -- FlatEarth : Conversions.Unit_Converter; -- -- int64_t regionId = request->getOperatingRegion(); -- RegionId : Int64 := Request.OperatingRegion; -- -- int64_t vehicleId = request->getVehicleID(); -- VehicleId : Int64 := Request.VehicleID; -- -- int64_t taskId = request->getAssociatedTaskID(); -- TaskId : Int64 := Request.AssociatedTaskID; -- -- double speed = 1.0; // default if no speed available -- Speed : Real64 := 1.0; begin raise Program_Error with "Euclidean_Plan is unimplemented"; -- if (m_entityConfigurations.find(vehicleId) != m_entityConfigurations.end()) -- { -- double speed = m_entityConfigurations[vehicleId]->getNominalSpeed(); -- if (speed < 1e-2) -- { -- speed = 1.0; // default to 1 if too small for division -- } -- } -- auto response = std::shared_ptr<UxAS::messages::route::RoutePlanResponse>(new UxAS::messages::route::RoutePlanResponse); -- response->setAssociatedTaskID(taskId); -- response->setOperatingRegion(regionId); -- response->setVehicleID(vehicleId); -- response->setResponseID(request->getRequestID()); -- -- for (size_t k = 0; k < request->getRouteRequests().size(); k++) -- { -- UxAS::messages::route::RouteConstraints* routeRequest = request->getRouteRequests().at(k); -- int64_t routeId = routeRequest->getRouteID(); -- VisiLibity::Point startPt, endPt; -- double north, east; -- -- UxAS::messages::route::RoutePlan* plan = new UxAS::messages::route::RoutePlan; -- plan->setRouteID(routeId); -- -- flatEarth.ConvertLatLong_degToNorthEast_m(routeRequest->getStartLocation()->getLatitude(), routeRequest->getStartLocation()->getLongitude(), north, east); -- startPt.set_x(east); -- startPt.set_y(north); -- -- flatEarth.ConvertLatLong_degToNorthEast_m(routeRequest->getEndLocation()->getLatitude(), routeRequest->getEndLocation()->getLongitude(), north, east); -- endPt.set_x(east); -- endPt.set_y(north); -- -- double linedist = VisiLibity::distance(startPt, endPt); -- plan->setRouteCost(linedist / speed * 1000); // milliseconds to arrive -- m_routePlans[routeId] = std::make_pair(request->getRequestID(), std::shared_ptr<UxAS::messages::route::RoutePlan>(plan)); -- } -- m_routePlanResponses[response->getResponseID()] = response; end Euclidean_Plan; -------------------------------- -- Handle_Route_Plan_Response -- -------------------------------- procedure Handle_Route_Plan_Response (Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State; Response : RoutePlanResponse) is begin pragma Assume (Length (History) < Count_Type'Last, "We still have room for a new event in History"); History := Add (History, (Kind => Receive_PlanResponse, Id => Response.ResponseID)); pragma Assert (No_RouteRequest_Lost (State.m_pendingRoute)); pragma Assume (Length (State.m_routePlanResponses) < State.m_routePlanResponses.Capacity, "We have some room for a new plan response"); Insert (State.m_routePlanResponses, Response.ResponseID, Response); pragma Assert (Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); pragma Assert (Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans)); for p in 1 .. Last (Response.RouteResponses) loop -- All plans are registered up to p pragma Loop_Invariant (for all RP of Model (State.m_routePlanResponses) => (if RP /= Response.ResponseID then (for all Pl of Element (State.m_routePlanResponses, RP).RouteResponses => Contains (State.m_routePlans, Pl.RouteID) and then Element (State.m_routePlans, Pl.RouteID).Id = RP))); pragma Loop_Invariant (for all K in 1 .. p - 1 => Contains (State.m_routePlans, Get (Response.RouteResponses, K).RouteID) and then Element (State.m_routePlans, Get (Response.RouteResponses, K).RouteID).Id = Response.ResponseID); pragma Loop_Invariant (for all K in p .. Last (Response.RouteResponses) => not Contains (State.m_routePlans, Get (Response.RouteResponses, K).RouteID)); -- Invariants pragma Loop_Invariant (Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans)); pragma Assume (Length (State.m_routePlans) < State.m_routePlans.Capacity, "We have enough room for all route plans"); declare ID : constant Int64 := Get (Response.RouteResponses, p).RouteID; Plan : constant RoutePlan := Get (Response.RouteResponses, p); begin Insert (State.m_routePlans, ID, IdPlanPair'(Id => Response.ResponseID, Plan => Plan, Cost => Get (Response.RouteResponses, p).RouteCost)); end; pragma Assert (Contains (Element (State.m_routePlanResponses, Response.ResponseID).RouteResponses, Get (Response.RouteResponses, p).RouteID)); end loop; pragma Assert (No_RouteRequest_Lost (State.m_pendingRoute)); pragma Assert (for all Pl of Element (State.m_routePlanResponses, Response.ResponseID).RouteResponses => Contains (State.m_routePlans, Pl.RouteID) and then Element (State.m_routePlans, Pl.RouteID).Id = Response.ResponseID); pragma Assert (for all RP of Model (State.m_routePlanResponses) => (for all Pl of Element (State.m_routePlanResponses, RP).RouteResponses => Contains (State.m_routePlans, Pl.RouteID) and then Element (State.m_routePlans, Pl.RouteID).Id = RP)); Check_All_Route_Plans (Mailbox, State); end Handle_Route_Plan_Response; -------------------------- -- Handle_Route_Request -- -------------------------- procedure Handle_Route_Request (Data : Route_Aggregator_Configuration_Data; Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State; Request : RouteRequest) is use all type History_Type; Vehicle_Ids : Int64_Seq := Request.VehicleID; PlanRequests : Int64_Formal_Set; begin pragma Assert (No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses)); pragma Assume (Length (History) < Count_Type'Last, "We still have room for a new event in History"); History := Add (History, (Kind => Receive_RouteRequest, Id => Request.RequestID)); pragma Assert (for all Pos in Event_Sequences.First .. Last (History) - 1 => (if Get (History, Pos).Kind = Receive_PlanResponse and Has_Key (Plan_To_Route (State.m_pendingRoute), Get (History, Pos).Id) then Contains (State.m_routePlanResponses, Get (History, Pos).Id))); pragma Assert (No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses)); --------------------------------------------------------------------------------------------------------------- -- this doesn't match the C++ exactly, because it doesn't put the new vehicle -- ids into the message parameter (which is "by reference" via pointer in C++) -- but that seems to be OK because only EuclidianPlan would use it, apparently if Length (Vehicle_Ids) = 0 then Vehicle_Ids := Data.m_entityStates; end if; --------------------------------------------------------------------------------------------------------------- -- We only have route plan responses with Ids smaller than State.m_routeRequestId pragma Assert (for all K of Model (State.m_routePlanResponses) => K <= State.m_routeRequestId); pragma Assert (for all E of History => (if E.Kind = Receive_PlanResponse then E.Id <= State.m_routeRequestId)); for K in 1 .. Last (Vehicle_Ids) loop -- We are only adding to planrequests new request ids pragma Loop_Invariant (State.m_routeRequestId'Loop_Entry <= State.m_routeRequestId); pragma Loop_Invariant (for all Id of Model (PlanRequests) => Id > State.m_routeRequestId'Loop_Entry and Id <= State.m_routeRequestId); pragma Loop_Invariant (for all Id of Model (State.m_pendingRoute) => (for all K of Int_Set_Maps_M.Get (Model (State.m_pendingRoute), Id) => K <= State.m_routeRequestId'Loop_Entry)); pragma Loop_Invariant (Length (PlanRequests) <= Count_Type (K - 1)); -- If fast planning is used, we may already have some responses for the -- new plan requests. pragma Loop_Invariant (for all K of Model (State.m_routePlanResponses) => Contains (Model (State.m_routePlanResponses)'Loop_Entry, K) or else (Data.m_fastPlan and then Contains (PlanRequests, K))); -- General Invariants pragma Loop_Invariant (All_Plans_Registered (State.m_routePlanResponses, State.m_routePlans)); pragma Loop_Invariant (Only_Pending_Plans (State.m_routePlanResponses, State.m_routePlans)); pragma Loop_Invariant (No_Finished_Request (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); -- Update of the history, it may contain new plan requests pragma Loop_Invariant (History'Loop_Entry <= History); pragma Loop_Invariant (for all I in 1 .. Last (History) => (if I > Last (History)'Loop_Entry then Get (History, I).Kind = Send_PlanRequest)); -- History Invariants pragma Loop_Invariant (Valid_Events (State.m_routeRequestId)); pragma Loop_Invariant (No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses)); pragma Loop_Invariant (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); pragma Loop_Invariant (for all Id of Model (PlanRequests) => PlanRequest_Processed (State.m_routePlanResponses, Id)); declare Vehicle_Id : Int64 renames Get (Vehicle_Ids, K); -- create a new route plan request pragma Assume (State.m_routeRequestId < Int64'Last, "The request ID does not overflow"); planRequest : constant RoutePlanRequest := (AssociatedTaskID => Request.AssociatedTaskID, IsCostOnlyRequest => Request.IsCostOnlyRequest, OperatingRegion => Request.OperatingRegion, VehicleID => Vehicle_Id, RequestID => State.m_routeRequestId + 1, RouteRequests => Request.RouteRequests); begin State.m_routeRequestId := State.m_routeRequestId + 1; pragma Assume (Length (PlanRequests) < PlanRequests.Capacity, "We have enough room for all vehicles in planRequests"); Insert (PlanRequests, planRequest.RequestID); if Contains (Data.m_groundVehicles, Vehicle_Id) then if Data.m_fastPlan then -- short-circuit and just plan with straight line planner Euclidean_Plan (Data, State.m_routePlanResponses, State.m_routePlans, planRequest); else -- send externally sendLimitedCastMessage (Mailbox, GroundPathPlanner, planRequest); pragma Assume (Length (History) < Count_Type'Last, "We still have room for a new event in History"); History := Add (History, (Kind => Send_PlanRequest, Id => planRequest.RequestID)); pragma Assert (PlanRequest_Sent (planRequest.RequestID)); end if; else pragma Assert (Contains (Data.m_airVehicles, Vehicle_Id) or else Contains (Data.m_surfaceVehicles, Vehicle_Id)); -- send to aircraft planner sendLimitedCastMessage (Mailbox, AircraftPathPlanner, planRequest); pragma Assume (Length (History) < Count_Type'Last, "We still have room for a new event in History"); History := Add (History, (Kind => Send_PlanRequest, Id => planRequest.RequestID)); pragma Assert (PlanRequest_Sent (planRequest.RequestID)); end if; end; pragma Assert (for all Id of Model (PlanRequests) => PlanRequest_Processed (State.m_routePlanResponses, Id)); pragma Assert (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); end loop; -- Restate part of the loop invariants after the loop pragma Assert (for all E of History => (if E.Kind = Receive_PlanResponse then not Contains (PlanRequests, E.Id))); pragma Assert (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); pragma Assert (No_Finished_Request (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); pragma Assert (for all R_Id of Model (State.m_pendingRoute) => (for all E of Int_Set_Maps_M.Get (Model (State.m_pendingRoute), R_Id) => not Contains (PlanRequests, E))); pragma Assume (Length (State.m_pendingRoute) < State.m_pendingRoute.Capacity, "We have enough room for a new pending route request"); Insert_PendingRequest (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routeRequestId, Request.RequestID, PlanRequests); -- System invariants have been reestablished pragma Assert (All_Pending_Plans_Sent (State.m_pendingRoute, State.m_routePlanResponses)); pragma Assert (Valid_Plan_Responses (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); pragma Assert (No_PlanResponse_Lost (State.m_pendingRoute, State.m_routePlanResponses)); -- if fast planning, then all routes should be complete; kick off response if Data.m_fastPlan then Check_All_Route_Plans (Mailbox, State); else pragma Assert (Is_Pending (Model (State.m_pendingRoute), Model (State.m_routePlanResponses), Request.RequestID)); pragma Assert (No_Finished_Request (State.m_pendingRoute, State.m_pendingAutoReq, State.m_routePlanResponses)); end if; end Handle_Route_Request; ------------------------------ -- Handle_Task_Plan_Options -- ------------------------------ procedure Handle_Task_Plan_Options (Mailbox : in out Route_Aggregator_Mailbox; Data : Route_Aggregator_Configuration_Data; State : in out Route_Aggregator_State; Options : TaskPlanOptions) with SPARK_Mode => Off is Id : constant Int64 := Options.TaskID; begin Insert (State.m_taskOptions, Id, Options); Check_All_Task_Options_Received (Mailbox, Data, State); end Handle_Task_Plan_Options; -------------------------------------- -- Handle_Unique_Automation_Request -- -------------------------------------- procedure Handle_Unique_Automation_Request (Data : Route_Aggregator_Configuration_Data; Mailbox : in out Route_Aggregator_Mailbox; State : in out Route_Aggregator_State; Areq : UniqueAutomationRequest) is begin Insert (State.m_uniqueAutomationRequests, State.m_autoRequestId + 1, Areq); State.m_autoRequestId := State.m_autoRequestId + 1; Check_All_Task_Options_Received (Mailbox, Data, State); end Handle_Unique_Automation_Request; --------------------------- -- Insert_PendingRequest -- --------------------------- procedure Insert_PendingRequest (m_pendingRequest : in out Int64_Formal_Set_Map; otherPending : Int64_Formal_Set_Map; m_routeRequestId : Int64; RequestID : Int64; PlanRequests : Int64_Formal_Set) is pragma Unreferenced (otherPending); Old_pendingRequest : constant Int_Set_Maps_M.Map := Model (m_pendingRequest) with Ghost; Old_pendingRequest_M : constant Int64_Formal_Set_Maps.Formal_Model.M.Map := Int64_Formal_Set_Maps.Formal_Model.Model (m_pendingRequest) with Ghost; begin Insert (m_pendingRequest, RequestID, PlanRequests); -- Establish the effect on the redefined Model of maps of formal sets Model_Include (Old_pendingRequest_M, Int64_Formal_Set_Maps.Formal_Model.Model (m_pendingRequest), Old_pendingRequest, Model (m_pendingRequest)); pragma Assert (No_Overlaps (Model (m_pendingRequest))); pragma Assert (All_Pending_Requests_Seen (Model (m_pendingRequest), m_routeRequestId)); end Insert_PendingRequest; -- Model functions used in contracts ----------- -- Model -- ----------- function Model (M : Int64_Formal_Set_Map) return Int_Set_Maps_M.Map is function Model (S : Int64_Formal_Set) return Int64_Set with Post => (for all E of Model'Result => Contains (S, E)) and (for all E of S => Contains (Model'Result, E)); function Model (S : Int64_Formal_Set) return Int64_Set is Res : Int64_Set; begin for C in S loop pragma Loop_Variant (Increases => Int_Set_P.Get (Positions (S), C)); pragma Loop_Invariant (Length (Res) = Int_Set_P.Get (Positions (S), C) - 1); pragma Loop_Invariant (for all E of Res => Contains (S, E)); pragma Loop_Invariant (for all K in 1 .. Int_Set_P.Get (Positions (S), C) - 1 => Contains (Res, Int_Set_E.Get (Elements (S), K))); pragma Loop_Invariant (for all K in Int_Set_P.Get (Positions (S), C) .. Length (S) => not Contains (Res, Int_Set_E.Get (Elements (S), K))); Res := Add (Res, Element (S, C)); end loop; return Res; end Model; Res : Int_Set_Maps_M.Map; begin for C in M loop pragma Loop_Variant (Increases => Int_Set_Maps_P.Get (Positions (M), C)); pragma Loop_Invariant (Int_Set_Maps_M.Length (Res) = Int_Set_Maps_P.Get (Positions (M), C) - 1); pragma Loop_Invariant (for all I of Res => Contains (M, I)); pragma Loop_Invariant (for all I of Res => (for all E of Int_Set_Maps_M.Get (Res, I) => Contains (Element (M, I), E))); pragma Loop_Invariant (for all I of Res => (for all E of Element (M, I) => Contains (Int_Set_Maps_M.Get (Res, I), E))); pragma Loop_Invariant (for all K in 1 .. Int_Set_Maps_P.Get (Positions (M), C) - 1 => Int_Set_Maps_M.Has_Key (Res, Int_Set_Maps_K.Get (Keys (M), K))); pragma Loop_Invariant (for all K in Int_Set_Maps_P.Get (Positions (M), C) .. Length (M) => not Int_Set_Maps_M.Has_Key (Res, Int_Set_Maps_K.Get (Keys (M), K))); Res := Int_Set_Maps_M.Add (Res, Key (M, C), Model (Element (M, C))); end loop; return Res; end Model; ---------------- -- SendMatrix -- ---------------- procedure SendMatrix (Mailbox : in out Route_Aggregator_Mailbox; m_uniqueAutomationRequests : Int64_UniqueAutomationRequest_Map; m_pendingRoute : Int64_Formal_Set_Map; m_pendingAutoReq : Int64_Formal_Set_Map; m_routePlans : in out Int64_IdPlanPair_Map; m_routeTaskPairing : in out Int64_TaskOptionPair_Map; m_routePlanResponses : in out Int64_RouteResponse_Map; m_taskOptions : in out Int64_TaskPlanOptions_Map; autoKey : Int64) is areq : constant UniqueAutomationRequest := Element (m_uniqueAutomationRequests, autoKey); matrix : AssignmentCostMatrix; pendingRequests : Int64_Formal_Set renames Element (m_pendingAutoReq, autoKey); Old_routePlanResponses : constant Int64_RouteResponse_Map := m_routePlanResponses with Ghost; begin matrix.CorrespondingAutomationRequestID := areq.RequestID; matrix.OperatingRegion := areq.OperatingRegion; matrix.TaskList := areq.TaskList; for Cu in pendingRequests loop pragma Loop_Invariant (for all I in 1 .. Int_Set_P.Get (Positions (pendingRequests), Cu) - 1 => not Contains (m_routePlanResponses, Int_Set_E.Get (Elements (pendingRequests), I))); pragma Loop_Invariant (for all I in Int_Set_P.Get (Positions (pendingRequests), Cu) .. Length (pendingRequests) => Contains (m_routePlanResponses, Int_Set_E.Get (Elements (pendingRequests), I))); pragma Loop_Invariant (for all Id of Old_routePlanResponses => (if not Contains (pendingRequests, Id) then Contains (m_routePlanResponses, Id))); pragma Loop_Invariant (for all Id of Model (m_routePlanResponses) => Contains (Old_routePlanResponses, Id)); -- Invariants pragma Loop_Invariant (Valid_Plan_Responses (m_pendingRoute, m_pendingAutoReq, m_routePlanResponses)); pragma Loop_Invariant (All_Plans_Registered (m_routePlanResponses, m_routePlans)); pragma Loop_Invariant (Only_Pending_Plans (m_routePlanResponses, m_routePlans)); -- History invariants pragma Loop_Invariant (No_RouteRequest_Lost (m_pendingRoute)); pragma Loop_Invariant (No_PlanResponse_Lost (m_pendingRoute, m_routePlanResponses)); pragma Loop_Invariant (All_Pending_Plans_Sent (m_pendingRoute, m_routePlanResponses)); declare rId : constant Int64 := Element (pendingRequests, Cu); pragma Assert (Contains (m_routePlanResponses, rId)); begin declare plan : Int64_RouteResponse_Maps.Cursor := Find (m_routePlanResponses, rId); -- NB. The if statement checking whether rId is in -- routePlanResponses was removed as SendRouteResponse is only -- called when all plan responses have been received. pragma Assert (Has_Element (m_routePlanResponses, plan)); resps : RP_Seq renames Element (m_routePlanResponses, plan).RouteResponses; begin -- delete all individual routes from storage for i in 1 .. Last (resps) loop -- We have removed all elements of resps from routePlans -- up to i. pragma Loop_Invariant (for all RP of Model (m_routePlanResponses) => (if RP /= rId then (for all Pl of Element (m_routePlanResponses, RP).RouteResponses => Contains (m_routePlans, Pl.RouteID) and then Element (m_routePlans, Pl.RouteID).Id = RP))); pragma Loop_Invariant (Only_Pending_Plans (m_routePlanResponses, m_routePlans)); pragma Loop_Invariant (for all Pl of Model (m_routePlans) => (if Element (m_routePlans, Pl).Id = rId then (for some K in i .. Last (resps) => Get (resps, K).RouteID = Pl))); pragma Loop_Invariant (for all K in i .. Last (resps) => Contains (m_routePlans, Get (resps, K).RouteID) and then Element (m_routePlans, Get (resps, K).RouteID).Id = rId); if Contains (m_routeTaskPairing, Get (resps, i).RouteID) then declare routeplan : constant IdPlanPair := Element (m_routePlans, Get (resps, i).RouteID); taskpair : constant TaskOptionPair := Element (m_routeTaskPairing, Get (resps, i).RouteID); toc : TaskOptionCost; begin if routeplan.Cost < 0 then Put_Line ("Route not found: V[" & taskpair.vehicleId'Image & "](" & taskpair.prevTaskId'Image & "," & taskpair.prevTaskOption'Image & ")-(" & taskpair.taskId'Image & "," & taskpair.taskOption'Image & ")"); end if; toc.DestinationTaskID := taskpair.taskId; toc.DestinationTaskOption := taskpair.taskOption; toc.InitialTaskID := taskpair.prevTaskId; toc.InitialTaskOption := taskpair.prevTaskOption; toc.TimeToGo := routeplan.Cost; toc.VehicleID := taskpair.vehicleId; pragma Assume (Length (matrix.CostMatrix) < Count_Type'Last, "we still have room in the matrix"); matrix.CostMatrix := Add (matrix.CostMatrix, toc); end; Delete (m_routeTaskPairing, Get (resps, i).RouteID); end if; -- We only delete plans associated to rId pragma Assert (Element (m_routePlans, Get (resps, i).RouteID).Id = rId); Delete (m_routePlans, Get (resps, i).RouteID); end loop; pragma Assert (for all Pl of Model (m_routePlans) => Element (m_routePlans, Pl).Id /= rId); pragma Assert (All_Pending_Plans_Sent (m_pendingRoute, m_routePlanResponses)); pragma Assert (No_Overlaps (Model (m_pendingRoute), Model (m_pendingAutoReq))); pragma Assert (for all Id of Plan_To_Route (m_pendingRoute) => Id /= Key (m_routePlanResponses, plan)); Delete (m_routePlanResponses, plan); pragma Assert (All_Pending_Plans_Sent (m_pendingRoute, m_routePlanResponses)); pragma Assert (Only_Pending_Plans (m_routePlanResponses, m_routePlans)); end; end; end loop; sendBroadcastMessage (Mailbox, matrix); Clear (m_taskOptions); end SendMatrix; ----------------------- -- SendRouteResponse -- ----------------------- procedure SendRouteResponse (Mailbox : in out Route_Aggregator_Mailbox; pendingRoute : Int64_Formal_Set_Map; pendingAutoReq : Int64_Formal_Set_Map; routePlanResponses : in out Int64_RouteResponse_Map; routePlans : in out Int64_IdPlanPair_Map; routeKey : Int64) is Response : RouteResponse; PlanResponses : Int64_Formal_Set renames Element (pendingRoute, routeKey); Old_routePlanResponses : constant RR_Maps_M.Map := Model (routePlanResponses) with Ghost; begin Response.ResponseID := routeKey; for Cu in PlanResponses loop -- Number of elements added to response.Routes pragma Loop_Invariant (Length (Response.Routes) < Int_Set_P.Get (Positions (PlanResponses), Cu)); -- We have removed all elements of PlanResponses from routePlanResponses -- up to Cu. pragma Loop_Invariant (for all I in 1 .. Int_Set_P.Get (Positions (PlanResponses), Cu) - 1 => not Contains (routePlanResponses, Int_Set_E.Get (Elements (PlanResponses), I))); pragma Loop_Invariant (for all I in Int_Set_P.Get (Positions (PlanResponses), Cu) .. Length (PlanResponses) => Contains (routePlanResponses, Int_Set_E.Get (Elements (PlanResponses), I))); pragma Loop_Invariant (for all Id of Old_routePlanResponses => (if not Contains (PlanResponses, Id) then Contains (routePlanResponses, Id))); pragma Loop_Invariant (for all Id of Model (routePlanResponses) => Contains (Old_routePlanResponses, Id)); -- Invariants pragma Loop_Invariant (Valid_Plan_Responses (pendingRoute, pendingAutoReq, routePlanResponses)); pragma Loop_Invariant (All_Plans_Registered (routePlanResponses, routePlans)); pragma Loop_Invariant (Only_Pending_Plans (routePlanResponses, routePlans)); -- History invariants: -- We have only removed responses associated to routeKey pragma Loop_Invariant (for all Id of Plan_To_Route (pendingRoute) => (if Get (Plan_To_Route (pendingRoute), Id) /= routeKey then Contains (routePlanResponses, Id) or else PlanRequest_Sent (Id))); pragma Loop_Invariant (for all E of History => (if E.Kind = Receive_PlanResponse and then Has_Key (Plan_To_Route (pendingRoute), E.Id) and then Get (Plan_To_Route (pendingRoute), E.Id) /= routeKey then Contains (routePlanResponses, E.Id))); declare rId : Int64 renames Element (PlanResponses, Cu); begin declare plan : Int64_RouteResponse_Maps.Cursor := Find (routePlanResponses, rId); -- NB. The if statement checking whether rId is in -- routePlanResponses was removed as SendRouteResponse is only -- called when all plan responses have been received. pragma Assert (Has_Element (routePlanResponses, plan)); resps : RP_Seq renames Element (routePlanResponses, plan).RouteResponses; begin Response.Routes := Add (Response.Routes, Element (routePlanResponses, plan)); -- delete all individual routes from storage for i in 1 .. Last (resps) loop -- We have removed all elements of resps from routePlans -- up to i. pragma Loop_Invariant (for all RP of Model (routePlanResponses) => (if RP /= rId then (for all Pl of Element (routePlanResponses, RP).RouteResponses => Contains (routePlans, Pl.RouteID) and then Element (routePlans, Pl.RouteID).Id = RP))); pragma Loop_Invariant (Only_Pending_Plans (routePlanResponses, routePlans)); pragma Loop_Invariant (for all Pl of Model (routePlans) => (if Element (routePlans, Pl).Id = rId then (for some K in i .. Last (resps) => Get (resps, K).RouteID = Pl))); pragma Loop_Invariant (for all K in i .. Last (resps) => Contains (routePlans, Get (resps, K).RouteID) and then Element (routePlans, Get (resps, K).RouteID).Id = rId); -- We only delete plans associated to rId pragma Assert (Element (routePlans, Get (resps, i).RouteID).Id = rId); Delete (routePlans, Get (resps, i).RouteID); end loop; pragma Assert (Only_Pending_Plans (routePlanResponses, routePlans)); pragma Assert (plan = Find (routePlanResponses, rId)); Delete (routePlanResponses, plan); end; end; end loop; pragma Assert (All_Plans_Registered (routePlanResponses, routePlans)); pragma Assert (for all Id of Plan_To_Route (pendingRoute) => (if Get (Plan_To_Route (pendingRoute), Id) /= routeKey then Contains (routePlanResponses, Id) or else PlanRequest_Sent (Id))); -- send the results of the query sendBroadcastMessage (Mailbox, Response); pragma Assume (Length (History) < Count_Type'Last, "We still have room for a new event in History"); History := Add (History, (Kind => Send_RouteResponse, Id => Response.ResponseID)); end SendRouteResponse; ----------------- -- Plan_To_Route -- ----------------- function Plan_To_Route (pendingRoute : Int64_Formal_Set_Map) return Int64_Map is Res : Int64_Map; begin for C in pendingRoute loop pragma Loop_Variant (Increases => Int_Set_Maps_P.Get (Positions (pendingRoute), C)); pragma Loop_Invariant (for all I of Res => Int_Set_Maps_M.Has_Key (Model (pendingRoute), Get (Res, I)) and then Contains (Int_Set_Maps_M.Get (Model (pendingRoute), Get (Res, I)), I)); pragma Loop_Invariant (for all J in 1 .. Int_Set_Maps_P.Get (Positions (pendingRoute), C) - 1 => (for all K of Int_Set_Maps_M.Get (Model (pendingRoute), Int_Set_Maps_K.Get (Keys (pendingRoute), J)) => Has_Key (Res, K) and then Get (Res, K) = Int_Set_Maps_K.Get (Keys (pendingRoute), J))); pragma Loop_Invariant (for all J in Int_Set_Maps_P.Get (Positions (pendingRoute), C) .. Length (pendingRoute) => (for all K of Int_Set_Maps_M.Get (Model (pendingRoute), Int_Set_Maps_K.Get (Keys (pendingRoute), J)) => not Has_Key (Res, K))); declare routePlans : Int64_Formal_Set renames Element (pendingRoute, C); begin for C2 in routePlans loop pragma Loop_Variant (Increases => Int_Set_P.Get (Positions (routePlans), C2)); pragma Loop_Invariant (for all I of Res => Int_Set_Maps_M.Has_Key (Model (pendingRoute), Get (Res, I)) and then Contains (Int_Set_Maps_M.Get (Model (pendingRoute), Get (Res, I)), I)); pragma Loop_Invariant (for all J in 1 .. Int_Set_Maps_P.Get (Positions (pendingRoute), C) - 1 => (for all K of Int_Set_Maps_M.Get (Model (pendingRoute), Int_Set_Maps_K.Get (Keys (pendingRoute), J)) => Has_Key (Res, K) and then Get (Res, K) = Int_Set_Maps_K.Get (Keys (pendingRoute), J))); pragma Loop_Invariant (for all J in Int_Set_Maps_P.Get (Positions (pendingRoute), C) + 1 .. Length (pendingRoute) => (for all K of Int_Set_Maps_M.Get (Model (pendingRoute), Int_Set_Maps_K.Get (Keys (pendingRoute), J)) => not Has_Key (Res, K))); pragma Loop_Invariant (for all J in 1 .. Int_Set_P.Get (Positions (routePlans), C2) - 1 => Has_Key (Res, Int_Set_E.Get (Elements (routePlans), J)) and then Get (Res, Int_Set_E.Get (Elements (routePlans), J)) = Key (pendingRoute, C)); pragma Loop_Invariant (for all J in Int_Set_P.Get (Positions (routePlans), C2) .. Length (routePlans) => not Has_Key (Res, Int_Set_E.Get (Elements (routePlans), J))); pragma Assume (Length (Res) < Count_Type'Last, "We have less than Count_Type'Last pending plan requests in total"); Res := Add (Res, Element (routePlans, C2), Key (pendingRoute, C)); end loop; end; end loop; return Res; end Plan_To_Route; end Route_Aggregator;
reznikmm/matreshka
Ada
6,902
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_Number.Time_Style_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Number_Time_Style_Element_Node is begin return Self : Number_Time_Style_Element_Node do Matreshka.ODF_Number.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Number_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Number_Time_Style_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_Number_Time_Style (ODF.DOM.Number_Time_Style_Elements.ODF_Number_Time_Style_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 Number_Time_Style_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Time_Style_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Number_Time_Style_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_Number_Time_Style (ODF.DOM.Number_Time_Style_Elements.ODF_Number_Time_Style_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 Number_Time_Style_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_Number_Time_Style (Visitor, ODF.DOM.Number_Time_Style_Elements.ODF_Number_Time_Style_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.Number_URI, Matreshka.ODF_String_Constants.Time_Style_Element, Number_Time_Style_Element_Node'Tag); end Matreshka.ODF_Number.Time_Style_Elements;
MinimSecure/unum-sdk
Ada
1,505
adb
-- Copyright 2008-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/>. procedure Comp_Bug is type Number_T (Exists : Boolean := False) is record case Exists is when True => Value : Natural range 0 .. 255; when False => null; end case; end record; pragma Pack (Number_T); X : Number_T; -- brobecker/2007-09-06: At the time when this issue (G904-017) was -- reported, the problem only reproduced if the variable was declared -- inside a function (in other words, stored on stack). Although -- the issue probably still existed when I tried moving this variable -- to a package spec, the symptoms inside GDB disappeared. begin X := (Exists => True, Value => 10); if X.Exists then -- STOP X.Value := X.Value + 1; end if; end Comp_Bug;
zhmu/ananas
Ada
3,449
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . I M A G E _ D -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-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. -- -- -- ------------------------------------------------------------------------------ with System.Img_Util; use System.Img_Util; package body System.Image_D is ------------------- -- Image_Decimal -- ------------------- procedure Image_Decimal (V : Int; S : in out String; P : out Natural; Scale : Integer) is pragma Assert (S'First = 1); begin -- Add space at start for non-negative numbers if V >= 0 then S (1) := ' '; P := 1; else P := 0; end if; Set_Image_Decimal (V, S, P, Scale, 1, Integer'Max (1, Scale), 0); end Image_Decimal; ----------------------- -- Set_Image_Decimal -- ----------------------- procedure Set_Image_Decimal (V : Int; S : in out String; P : in out Natural; Scale : Integer; Fore : Natural; Aft : Natural; Exp : Natural) is Digs : String := Int'Image (V); -- Sign and digits of decimal value begin Set_Decimal_Digits (Digs, Digs'Length, S, P, Scale, Fore, Aft, Exp); end Set_Image_Decimal; end System.Image_D;
stcarrez/ada-css
Ada
1,311
ads
----------------------------------------------------------------------- -- css-printer -- CSS printer tools -- Copyright (C) 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 Ada.Text_IO; package CSS.Printer.Text_IO is type File_Type is new CSS.Printer.File_Type with record File : Ada.Text_IO.File_Type; end record; overriding procedure New_Line (Stream : in out File_Type); overriding procedure Print (Stream : in out File_Type; Content : in String); overriding procedure Print (Stream : in out File_Type; Content : in Character); end CSS.Printer.Text_IO;
zhmu/ananas
Ada
8,614
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- ADA.EXCEPTIONS.STREAM_ATTRIBUTES -- -- -- -- B o d y -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ pragma Warnings (Off); -- Allow withing of non-Preelaborated units in Ada 2005 mode where this -- package will be categorized as Preelaborate. See AI-362 for details. -- It is safe in the context of the run-time to violate the rules. with System.Exception_Table; use System.Exception_Table; with System.Storage_Elements; use System.Storage_Elements; pragma Warnings (On); separate (Ada.Exceptions) package body Stream_Attributes is ------------------- -- EId_To_String -- ------------------- function EId_To_String (X : Exception_Id) return String is begin if X = Null_Id then return ""; else return Exception_Name (X); end if; end EId_To_String; ------------------ -- EO_To_String -- ------------------ -- We use the null string to represent the null occurrence, otherwise we -- output the Untailored_Exception_Information string for the occurrence. function EO_To_String (X : Exception_Occurrence) return String is begin if X.Id = Null_Id then return ""; else return Exception_Data.Untailored_Exception_Information (X); end if; end EO_To_String; ------------------- -- String_To_EId -- ------------------- function String_To_EId (S : String) return Exception_Id is begin if S = "" then return Null_Id; else return Exception_Id (Internal_Exception (S)); end if; end String_To_EId; ------------------ -- String_To_EO -- ------------------ function String_To_EO (S : String) return Exception_Occurrence is From : Natural; To : Integer; X : aliased Exception_Occurrence; -- This is the exception occurrence we will create procedure Bad_EO; pragma No_Return (Bad_EO); -- Signal bad exception occurrence string procedure Next_String; -- On entry, To points to last character of previous line of the -- message, terminated by LF. On return, From .. To are set to -- specify the next string, or From > To if there are no more lines. procedure Bad_EO is begin Raise_Exception (Program_Error'Identity, "bad exception occurrence in stream input"); -- The following junk raise of Program_Error is required because -- this is a No_Return procedure, and unfortunately Raise_Exception -- can return (this particular call can't, but the back end is not -- clever enough to know that). raise Program_Error; end Bad_EO; procedure Next_String is begin From := To + 2; if From < S'Last then To := From + 1; while To < S'Last - 1 loop if To >= S'Last then Bad_EO; elsif S (To + 1) = ASCII.LF then exit; else To := To + 1; end if; end loop; end if; end Next_String; -- Start of processing for String_To_EO begin if S = "" then return Null_Occurrence; end if; To := S'First - 2; Next_String; if S (From .. From + 6) /= "raised " then Bad_EO; end if; declare Name_Start : constant Positive := From + 7; begin From := Name_Start + 1; while From < To and then S (From) /= ' ' loop From := From + 1; end loop; X.Id := Exception_Id (Internal_Exception (S (Name_Start .. From - 1))); end; if From <= To then if S (From .. From + 2) /= " : " then Bad_EO; end if; X.Msg_Length := To - From - 2; X.Msg (1 .. X.Msg_Length) := S (From + 3 .. To); else X.Msg_Length := 0; end if; Next_String; X.Pid := 0; if From <= To and then S (From) = 'P' then if S (From .. From + 3) /= "PID:" then Bad_EO; end if; From := From + 5; -- skip past PID: space while From <= To loop X.Pid := X.Pid * 10 + (Character'Pos (S (From)) - Character'Pos ('0')); From := From + 1; end loop; Next_String; end if; X.Num_Tracebacks := 0; if From <= To then if S (From .. To) /= "Call stack traceback locations:" then Bad_EO; end if; Next_String; loop exit when From > To; declare Ch : Character; C : Integer_Address; N : Integer_Address; begin if S (From) /= '0' or else S (From + 1) /= 'x' then Bad_EO; else From := From + 2; end if; C := 0; while From <= To loop Ch := S (From); if Ch in '0' .. '9' then N := Character'Pos (S (From)) - Character'Pos ('0'); elsif Ch in 'a' .. 'f' then N := Character'Pos (S (From)) - Character'Pos ('a') + 10; elsif Ch = ' ' then From := From + 1; exit; else Bad_EO; end if; C := C * 16 + N; From := From + 1; end loop; if X.Num_Tracebacks = Max_Tracebacks then Bad_EO; end if; X.Num_Tracebacks := X.Num_Tracebacks + 1; X.Tracebacks (X.Num_Tracebacks) := TBE.TB_Entry_For (To_Address (C)); end; end loop; end if; -- The occurrence we're crafting is not currently being -- propagated. X.Machine_Occurrence := System.Null_Address; -- If an exception was converted to a string, it must have -- already been raised, so flag it accordingly and we are done. X.Exception_Raised := True; return X; end String_To_EO; end Stream_Attributes;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
20,047
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x1.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.I2C is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR1_PE_Field is STM32_SVD.Bit; subtype CR1_TXIE_Field is STM32_SVD.Bit; subtype CR1_RXIE_Field is STM32_SVD.Bit; subtype CR1_ADDRIE_Field is STM32_SVD.Bit; subtype CR1_NACKIE_Field is STM32_SVD.Bit; subtype CR1_STOPIE_Field is STM32_SVD.Bit; subtype CR1_TCIE_Field is STM32_SVD.Bit; subtype CR1_ERRIE_Field is STM32_SVD.Bit; subtype CR1_DNF_Field is STM32_SVD.UInt4; subtype CR1_ANFOFF_Field is STM32_SVD.Bit; subtype CR1_TXDMAEN_Field is STM32_SVD.Bit; subtype CR1_RXDMAEN_Field is STM32_SVD.Bit; subtype CR1_SBC_Field is STM32_SVD.Bit; subtype CR1_NOSTRETCH_Field is STM32_SVD.Bit; subtype CR1_WUPEN_Field is STM32_SVD.Bit; subtype CR1_GCEN_Field is STM32_SVD.Bit; subtype CR1_SMBHEN_Field is STM32_SVD.Bit; subtype CR1_SMBDEN_Field is STM32_SVD.Bit; subtype CR1_ALERTEN_Field is STM32_SVD.Bit; subtype CR1_PECEN_Field is STM32_SVD.Bit; -- Control register 1 type CR1_Register is record -- Peripheral enable PE : CR1_PE_Field := 16#0#; -- TX Interrupt enable TXIE : CR1_TXIE_Field := 16#0#; -- RX Interrupt enable RXIE : CR1_RXIE_Field := 16#0#; -- Address match interrupt enable (slave only) ADDRIE : CR1_ADDRIE_Field := 16#0#; -- Not acknowledge received interrupt enable NACKIE : CR1_NACKIE_Field := 16#0#; -- STOP detection Interrupt enable STOPIE : CR1_STOPIE_Field := 16#0#; -- Transfer Complete interrupt enable TCIE : CR1_TCIE_Field := 16#0#; -- Error interrupts enable ERRIE : CR1_ERRIE_Field := 16#0#; -- Digital noise filter DNF : CR1_DNF_Field := 16#0#; -- Analog noise filter OFF ANFOFF : CR1_ANFOFF_Field := 16#0#; -- unspecified Reserved_13_13 : STM32_SVD.Bit := 16#0#; -- DMA transmission requests enable TXDMAEN : CR1_TXDMAEN_Field := 16#0#; -- DMA reception requests enable RXDMAEN : CR1_RXDMAEN_Field := 16#0#; -- Slave byte control SBC : CR1_SBC_Field := 16#0#; -- Clock stretching disable NOSTRETCH : CR1_NOSTRETCH_Field := 16#0#; -- Wakeup from STOP enable WUPEN : CR1_WUPEN_Field := 16#0#; -- General call enable GCEN : CR1_GCEN_Field := 16#0#; -- SMBus Host address enable SMBHEN : CR1_SMBHEN_Field := 16#0#; -- SMBus Device Default address enable SMBDEN : CR1_SMBDEN_Field := 16#0#; -- SMBUS alert enable ALERTEN : CR1_ALERTEN_Field := 16#0#; -- PEC enable PECEN : CR1_PECEN_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register use record PE at 0 range 0 .. 0; TXIE at 0 range 1 .. 1; RXIE at 0 range 2 .. 2; ADDRIE at 0 range 3 .. 3; NACKIE at 0 range 4 .. 4; STOPIE at 0 range 5 .. 5; TCIE at 0 range 6 .. 6; ERRIE at 0 range 7 .. 7; DNF at 0 range 8 .. 11; ANFOFF at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; TXDMAEN at 0 range 14 .. 14; RXDMAEN at 0 range 15 .. 15; SBC at 0 range 16 .. 16; NOSTRETCH at 0 range 17 .. 17; WUPEN at 0 range 18 .. 18; GCEN at 0 range 19 .. 19; SMBHEN at 0 range 20 .. 20; SMBDEN at 0 range 21 .. 21; ALERTEN at 0 range 22 .. 22; PECEN at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CR2_SADD_Field is STM32_SVD.UInt10; subtype CR2_RD_WRN_Field is STM32_SVD.Bit; subtype CR2_ADD10_Field is STM32_SVD.Bit; subtype CR2_HEAD10R_Field is STM32_SVD.Bit; subtype CR2_START_Field is STM32_SVD.Bit; subtype CR2_STOP_Field is STM32_SVD.Bit; subtype CR2_NACK_Field is STM32_SVD.Bit; subtype CR2_NBYTES_Field is STM32_SVD.Byte; subtype CR2_RELOAD_Field is STM32_SVD.Bit; subtype CR2_AUTOEND_Field is STM32_SVD.Bit; subtype CR2_PECBYTE_Field is STM32_SVD.Bit; -- Control register 2 type CR2_Register is record -- Slave address bit (master mode) SADD : CR2_SADD_Field := 16#0#; -- Transfer direction (master mode) RD_WRN : CR2_RD_WRN_Field := 16#0#; -- 10-bit addressing mode (master mode) ADD10 : CR2_ADD10_Field := 16#0#; -- 10-bit address header only read direction (master receiver mode) HEAD10R : CR2_HEAD10R_Field := 16#0#; -- Start generation START : CR2_START_Field := 16#0#; -- Stop generation (master mode) STOP : CR2_STOP_Field := 16#0#; -- NACK generation (slave mode) NACK : CR2_NACK_Field := 16#0#; -- Number of bytes NBYTES : CR2_NBYTES_Field := 16#0#; -- NBYTES reload mode RELOAD : CR2_RELOAD_Field := 16#0#; -- Automatic end mode (master mode) AUTOEND : CR2_AUTOEND_Field := 16#0#; -- Packet error checking byte PECBYTE : CR2_PECBYTE_Field := 16#0#; -- unspecified Reserved_27_31 : STM32_SVD.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record SADD at 0 range 0 .. 9; RD_WRN at 0 range 10 .. 10; ADD10 at 0 range 11 .. 11; HEAD10R at 0 range 12 .. 12; START at 0 range 13 .. 13; STOP at 0 range 14 .. 14; NACK at 0 range 15 .. 15; NBYTES at 0 range 16 .. 23; RELOAD at 0 range 24 .. 24; AUTOEND at 0 range 25 .. 25; PECBYTE at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; subtype OAR1_OA1_Field is STM32_SVD.UInt10; subtype OAR1_OA1MODE_Field is STM32_SVD.Bit; subtype OAR1_OA1EN_Field is STM32_SVD.Bit; -- Own address register 1 type OAR1_Register is record -- Interface address OA1 : OAR1_OA1_Field := 16#0#; -- Own Address 1 10-bit mode OA1MODE : OAR1_OA1MODE_Field := 16#0#; -- unspecified Reserved_11_14 : STM32_SVD.UInt4 := 16#0#; -- Own Address 1 enable OA1EN : OAR1_OA1EN_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OAR1_Register use record OA1 at 0 range 0 .. 9; OA1MODE at 0 range 10 .. 10; Reserved_11_14 at 0 range 11 .. 14; OA1EN at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OAR2_OA2_Field is STM32_SVD.UInt7; subtype OAR2_OA2MSK_Field is STM32_SVD.UInt3; subtype OAR2_OA2EN_Field is STM32_SVD.Bit; -- Own address register 2 type OAR2_Register is record -- unspecified Reserved_0_0 : STM32_SVD.Bit := 16#0#; -- Interface address OA2 : OAR2_OA2_Field := 16#0#; -- Own Address 2 masks OA2MSK : OAR2_OA2MSK_Field := 16#0#; -- unspecified Reserved_11_14 : STM32_SVD.UInt4 := 16#0#; -- Own Address 2 enable OA2EN : OAR2_OA2EN_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OAR2_Register use record Reserved_0_0 at 0 range 0 .. 0; OA2 at 0 range 1 .. 7; OA2MSK at 0 range 8 .. 10; Reserved_11_14 at 0 range 11 .. 14; OA2EN at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TIMINGR_SCLL_Field is STM32_SVD.Byte; subtype TIMINGR_SCLH_Field is STM32_SVD.Byte; subtype TIMINGR_SDADEL_Field is STM32_SVD.UInt4; subtype TIMINGR_SCLDEL_Field is STM32_SVD.UInt4; subtype TIMINGR_PRESC_Field is STM32_SVD.UInt4; -- Timing register type TIMINGR_Register is record -- SCL low period (master mode) SCLL : TIMINGR_SCLL_Field := 16#0#; -- SCL high period (master mode) SCLH : TIMINGR_SCLH_Field := 16#0#; -- Data hold time SDADEL : TIMINGR_SDADEL_Field := 16#0#; -- Data setup time SCLDEL : TIMINGR_SCLDEL_Field := 16#0#; -- unspecified Reserved_24_27 : STM32_SVD.UInt4 := 16#0#; -- Timing prescaler PRESC : TIMINGR_PRESC_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TIMINGR_Register use record SCLL at 0 range 0 .. 7; SCLH at 0 range 8 .. 15; SDADEL at 0 range 16 .. 19; SCLDEL at 0 range 20 .. 23; Reserved_24_27 at 0 range 24 .. 27; PRESC at 0 range 28 .. 31; end record; subtype TIMEOUTR_TIMEOUTA_Field is STM32_SVD.UInt12; subtype TIMEOUTR_TIDLE_Field is STM32_SVD.Bit; subtype TIMEOUTR_TIMOUTEN_Field is STM32_SVD.Bit; subtype TIMEOUTR_TIMEOUTB_Field is STM32_SVD.UInt12; subtype TIMEOUTR_TEXTEN_Field is STM32_SVD.Bit; -- Status register 1 type TIMEOUTR_Register is record -- Bus timeout A TIMEOUTA : TIMEOUTR_TIMEOUTA_Field := 16#0#; -- Idle clock timeout detection TIDLE : TIMEOUTR_TIDLE_Field := 16#0#; -- unspecified Reserved_13_14 : STM32_SVD.UInt2 := 16#0#; -- Clock timeout enable TIMOUTEN : TIMEOUTR_TIMOUTEN_Field := 16#0#; -- Bus timeout B TIMEOUTB : TIMEOUTR_TIMEOUTB_Field := 16#0#; -- unspecified Reserved_28_30 : STM32_SVD.UInt3 := 16#0#; -- Extended clock timeout enable TEXTEN : TIMEOUTR_TEXTEN_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TIMEOUTR_Register use record TIMEOUTA at 0 range 0 .. 11; TIDLE at 0 range 12 .. 12; Reserved_13_14 at 0 range 13 .. 14; TIMOUTEN at 0 range 15 .. 15; TIMEOUTB at 0 range 16 .. 27; Reserved_28_30 at 0 range 28 .. 30; TEXTEN at 0 range 31 .. 31; end record; subtype ISR_TXE_Field is STM32_SVD.Bit; subtype ISR_TXIS_Field is STM32_SVD.Bit; subtype ISR_RXNE_Field is STM32_SVD.Bit; subtype ISR_ADDR_Field is STM32_SVD.Bit; subtype ISR_NACKF_Field is STM32_SVD.Bit; subtype ISR_STOPF_Field is STM32_SVD.Bit; subtype ISR_TC_Field is STM32_SVD.Bit; subtype ISR_TCR_Field is STM32_SVD.Bit; subtype ISR_BERR_Field is STM32_SVD.Bit; subtype ISR_ARLO_Field is STM32_SVD.Bit; subtype ISR_OVR_Field is STM32_SVD.Bit; subtype ISR_PECERR_Field is STM32_SVD.Bit; subtype ISR_TIMEOUT_Field is STM32_SVD.Bit; subtype ISR_ALERT_Field is STM32_SVD.Bit; subtype ISR_BUSY_Field is STM32_SVD.Bit; subtype ISR_DIR_Field is STM32_SVD.Bit; subtype ISR_ADDCODE_Field is STM32_SVD.UInt7; -- Interrupt and Status register type ISR_Register is record -- Transmit data register empty (transmitters) TXE : ISR_TXE_Field := 16#1#; -- Transmit interrupt status (transmitters) TXIS : ISR_TXIS_Field := 16#0#; -- Read-only. Receive data register not empty (receivers) RXNE : ISR_RXNE_Field := 16#0#; -- Read-only. Address matched (slave mode) ADDR : ISR_ADDR_Field := 16#0#; -- Read-only. Not acknowledge received flag NACKF : ISR_NACKF_Field := 16#0#; -- Read-only. Stop detection flag STOPF : ISR_STOPF_Field := 16#0#; -- Read-only. Transfer Complete (master mode) TC : ISR_TC_Field := 16#0#; -- Read-only. Transfer Complete Reload TCR : ISR_TCR_Field := 16#0#; -- Read-only. Bus error BERR : ISR_BERR_Field := 16#0#; -- Read-only. Arbitration lost ARLO : ISR_ARLO_Field := 16#0#; -- Read-only. Overrun/Underrun (slave mode) OVR : ISR_OVR_Field := 16#0#; -- Read-only. PEC Error in reception PECERR : ISR_PECERR_Field := 16#0#; -- Read-only. Timeout or t_low detection flag TIMEOUT : ISR_TIMEOUT_Field := 16#0#; -- Read-only. SMBus alert ALERT : ISR_ALERT_Field := 16#0#; -- unspecified Reserved_14_14 : STM32_SVD.Bit := 16#0#; -- Read-only. Bus busy BUSY : ISR_BUSY_Field := 16#0#; -- Read-only. Transfer direction (Slave mode) DIR : ISR_DIR_Field := 16#0#; -- Read-only. Address match code (Slave mode) ADDCODE : ISR_ADDCODE_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record TXE at 0 range 0 .. 0; TXIS at 0 range 1 .. 1; RXNE at 0 range 2 .. 2; ADDR at 0 range 3 .. 3; NACKF at 0 range 4 .. 4; STOPF at 0 range 5 .. 5; TC at 0 range 6 .. 6; TCR at 0 range 7 .. 7; BERR at 0 range 8 .. 8; ARLO at 0 range 9 .. 9; OVR at 0 range 10 .. 10; PECERR at 0 range 11 .. 11; TIMEOUT at 0 range 12 .. 12; ALERT at 0 range 13 .. 13; Reserved_14_14 at 0 range 14 .. 14; BUSY at 0 range 15 .. 15; DIR at 0 range 16 .. 16; ADDCODE at 0 range 17 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype ICR_ADDRCF_Field is STM32_SVD.Bit; subtype ICR_NACKCF_Field is STM32_SVD.Bit; subtype ICR_STOPCF_Field is STM32_SVD.Bit; subtype ICR_BERRCF_Field is STM32_SVD.Bit; subtype ICR_ARLOCF_Field is STM32_SVD.Bit; subtype ICR_OVRCF_Field is STM32_SVD.Bit; subtype ICR_PECCF_Field is STM32_SVD.Bit; subtype ICR_TIMOUTCF_Field is STM32_SVD.Bit; subtype ICR_ALERTCF_Field is STM32_SVD.Bit; -- Interrupt clear register type ICR_Register is record -- unspecified Reserved_0_2 : STM32_SVD.UInt3 := 16#0#; -- Write-only. Address Matched flag clear ADDRCF : ICR_ADDRCF_Field := 16#0#; -- Write-only. Not Acknowledge flag clear NACKCF : ICR_NACKCF_Field := 16#0#; -- Write-only. Stop detection flag clear STOPCF : ICR_STOPCF_Field := 16#0#; -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- Write-only. Bus error flag clear BERRCF : ICR_BERRCF_Field := 16#0#; -- Write-only. Arbitration lost flag clear ARLOCF : ICR_ARLOCF_Field := 16#0#; -- Write-only. Overrun/Underrun flag clear OVRCF : ICR_OVRCF_Field := 16#0#; -- Write-only. PEC Error flag clear PECCF : ICR_PECCF_Field := 16#0#; -- Write-only. Timeout detection flag clear TIMOUTCF : ICR_TIMOUTCF_Field := 16#0#; -- Write-only. Alert flag clear ALERTCF : ICR_ALERTCF_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICR_Register use record Reserved_0_2 at 0 range 0 .. 2; ADDRCF at 0 range 3 .. 3; NACKCF at 0 range 4 .. 4; STOPCF at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; BERRCF at 0 range 8 .. 8; ARLOCF at 0 range 9 .. 9; OVRCF at 0 range 10 .. 10; PECCF at 0 range 11 .. 11; TIMOUTCF at 0 range 12 .. 12; ALERTCF at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; subtype PECR_PEC_Field is STM32_SVD.Byte; -- PEC register type PECR_Register is record -- Read-only. Packet error checking register PEC : PECR_PEC_Field; -- unspecified Reserved_8_31 : STM32_SVD.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PECR_Register use record PEC at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype RXDR_RXDATA_Field is STM32_SVD.Byte; -- Receive data register type RXDR_Register is record -- Read-only. 8-bit receive data RXDATA : RXDR_RXDATA_Field; -- unspecified Reserved_8_31 : STM32_SVD.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RXDR_Register use record RXDATA at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype TXDR_TXDATA_Field is STM32_SVD.Byte; -- Transmit data register type TXDR_Register is record -- 8-bit transmit data TXDATA : TXDR_TXDATA_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TXDR_Register use record TXDATA at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Inter-integrated circuit type I2C_Peripheral is record -- Control register 1 CR1 : aliased CR1_Register; -- Control register 2 CR2 : aliased CR2_Register; -- Own address register 1 OAR1 : aliased OAR1_Register; -- Own address register 2 OAR2 : aliased OAR2_Register; -- Timing register TIMINGR : aliased TIMINGR_Register; -- Status register 1 TIMEOUTR : aliased TIMEOUTR_Register; -- Interrupt and Status register ISR : aliased ISR_Register; -- Interrupt clear register ICR : aliased ICR_Register; -- PEC register PECR : aliased PECR_Register; -- Receive data register RXDR : aliased RXDR_Register; -- Transmit data register TXDR : aliased TXDR_Register; end record with Volatile; for I2C_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; OAR1 at 16#8# range 0 .. 31; OAR2 at 16#C# range 0 .. 31; TIMINGR at 16#10# range 0 .. 31; TIMEOUTR at 16#14# range 0 .. 31; ISR at 16#18# range 0 .. 31; ICR at 16#1C# range 0 .. 31; PECR at 16#20# range 0 .. 31; RXDR at 16#24# range 0 .. 31; TXDR at 16#28# range 0 .. 31; end record; -- Inter-integrated circuit I2C1_Periph : aliased I2C_Peripheral with Import, Address => I2C1_Base; -- Inter-integrated circuit I2C2_Periph : aliased I2C_Peripheral with Import, Address => I2C2_Base; -- Inter-integrated circuit I2C3_Periph : aliased I2C_Peripheral with Import, Address => I2C3_Base; end STM32_SVD.I2C;
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_Table.Message_Type_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Message_Type_Attribute_Node is begin return Self : Table_Message_Type_Attribute_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Message_Type_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Message_Type_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Message_Type_Attribute, Table_Message_Type_Attribute_Node'Tag); end Matreshka.ODF_Table.Message_Type_Attributes;
reznikmm/matreshka
Ada
4,772
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Soft_Page_Break_Elements; package Matreshka.ODF_Text.Soft_Page_Break_Elements is type Text_Soft_Page_Break_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Soft_Page_Break_Elements.ODF_Text_Soft_Page_Break with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Soft_Page_Break_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Soft_Page_Break_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Soft_Page_Break_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Soft_Page_Break_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Soft_Page_Break_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Soft_Page_Break_Elements;
reznikmm/matreshka
Ada
4,651
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Draw_Path_Elements; package Matreshka.ODF_Draw.Path_Elements is type Draw_Path_Element_Node is new Matreshka.ODF_Draw.Abstract_Draw_Element_Node and ODF.DOM.Draw_Path_Elements.ODF_Draw_Path with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Draw_Path_Element_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Path_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Draw_Path_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Draw_Path_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Draw_Path_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Draw.Path_Elements;
muschellij2/FSL6.0.0
Ada
5,998
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.adb,v 1.3 2010/07/15 14:24:17 mwebster Exp $ with Ada.Unchecked_Deallocation; package body ZLib.Streams is ----------- -- Close -- ----------- procedure Close (Stream : in out Stream_Type) is procedure Free is new Ada.Unchecked_Deallocation (Stream_Element_Array, Buffer_Access); begin if Stream.Mode = Out_Stream or Stream.Mode = Duplex then -- We should flush the data written by the writer. Flush (Stream, Finish); Close (Stream.Writer); end if; if Stream.Mode = In_Stream or Stream.Mode = Duplex then Close (Stream.Reader); Free (Stream.Buffer); end if; end Close; ------------ -- Create -- ------------ procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size) is subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean); ----------------- -- Init_Filter -- ----------------- procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean) is begin if Compress then Deflate_Init (Filter, Level, Strategy, Header => Header); else Inflate_Init (Filter, Header => Header); end if; end Init_Filter; begin Stream.Back := Back; Stream.Mode := Mode; if Mode = Out_Stream or Mode = Duplex then Init_Filter (Stream.Writer, Back_Compressed); Stream.Buffer_Size := Write_Buffer_Size; else Stream.Buffer_Size := 0; end if; if Mode = In_Stream or Mode = Duplex then Init_Filter (Stream.Reader, not Back_Compressed); Stream.Buffer := new Buffer_Subtype; Stream.Rest_First := Stream.Buffer'Last + 1; Stream.Rest_Last := Stream.Buffer'Last; end if; end Create; ----------- -- Flush -- ----------- procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush) is Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); Last : Stream_Element_Offset; begin loop Flush (Stream.Writer, Buffer, Last, Mode); Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Flush; ------------- -- Is_Open -- ------------- function Is_Open (Stream : Stream_Type) return Boolean is begin return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); end Is_Open; ---------- -- Read -- ---------- procedure Read (Stream : in out Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Ada.Streams.Read (Stream.Back.all, Item, Last); end Read; procedure Read is new ZLib.Read (Read => Read, Buffer => Stream.Buffer.all, Rest_First => Stream.Rest_First, Rest_Last => Stream.Rest_Last); begin Read (Stream.Reader, Item, Last); end Read; ------------------- -- Read_Total_In -- ------------------- function Read_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Reader); end Read_Total_In; -------------------- -- Read_Total_Out -- -------------------- function Read_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Reader); end Read_Total_Out; ----------- -- Write -- ----------- procedure Write (Stream : in out Stream_Type; Item : in Stream_Element_Array) is procedure Write (Item : in Stream_Element_Array); ----------- -- Write -- ----------- procedure Write (Item : in Stream_Element_Array) is begin Ada.Streams.Write (Stream.Back.all, Item); end Write; procedure Write is new ZLib.Write (Write => Write, Buffer_Size => Stream.Buffer_Size); begin Write (Stream.Writer, Item, No_Flush); end Write; -------------------- -- Write_Total_In -- -------------------- function Write_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Writer); end Write_Total_In; --------------------- -- Write_Total_Out -- --------------------- function Write_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Writer); end Write_Total_Out; end ZLib.Streams;
reznikmm/matreshka
Ada
3,689
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Form_List_Property_Elements is pragma Preelaborate; type ODF_Form_List_Property is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Form_List_Property_Access is access all ODF_Form_List_Property'Class with Storage_Size => 0; end ODF.DOM.Form_List_Property_Elements;
GPUWorks/lumen2
Ada
23,044
ads
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010 -- Lumen would not be possible without the support and contributions of a cast -- of thousands, including and primarily Rod Kay. -- This code is covered by the ISC License: -- -- Copyright © 2010, NiEstu -- -- 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 System; package X11 is -- Xlib stuff needed by more than one of the routines below type Data_Format_Type is (Invalid, Bits_8, Bits_16, Bits_32); for Data_Format_Type use (Invalid => 0, Bits_8 => 8, Bits_16 => 16, Bits_32 => 32); type Atom is new Long_Integer; -- Values used to compute record rep clause values that are portable -- between 32- and 64-bit systems Is_32 : constant := Boolean'Pos (System.Word_Size = 32); Is_64 : constant := 1 - Is_32; Word_Bytes : constant := Integer'Size / System.Storage_Unit; Word_Bits : constant := Integer'Size - 1; Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit; Long_Bits : constant := Long_Integer'Size - 1; -- Xlib types needed only by Create subtype Dimension is Short_Integer; subtype Pixel is Long_Integer; subtype Position is Short_Integer; -- Used to simulate "out" param for C function type Int_Ptr is access all Integer; -- Actually an array, but only ever one element type FB_Config_Ptr is access all System.Address; -- OpenGL context ("visual") attribute specifiers type X11Context_Attribute_Name is ( Attr_None, Attr_Use_GL, -- unused Attr_Buffer_Size, -- color index buffer size, ignored if TrueColor Attr_Level, -- buffer level for over/underlays Attr_RGBA, -- set by Depth => TrueColor Attr_Doublebuffer, -- set by Animate => True Attr_Stereo, -- wow, you have stereo visuals? Attr_Aux_Buffers, -- number of auxiliary buffers Attr_Red_Size, -- bit depth, red Attr_Green_Size, -- bit depth, green Attr_Blue_Size, -- bit depth, blue Attr_Alpha_Size, -- bit depth, alpha Attr_Depth_Size, -- depth buffer size Attr_Stencil_Size, -- stencil buffer size Attr_Accum_Red_Size, -- accumulation buffer bit depth, red Attr_Accum_Green_Size, -- accumulation buffer bit depth, green Attr_Accum_Blue_Size, -- accumulation buffer bit depth, blue Attr_Accum_Alpha_Size -- accumulation buffer bit depth, alpha ); type X11Context_Attribute (Name : X11Context_Attribute_Name := Attr_None) is record case Name is when Attr_None | Attr_Use_GL | Attr_RGBA | Attr_Doublebuffer | Attr_Stereo => null; -- present or not, no value when Attr_Level => Level : Integer := 0; when Attr_Buffer_Size | Attr_Aux_Buffers | Attr_Depth_Size | Attr_Stencil_Size | Attr_Red_Size | Attr_Green_Size | Attr_Blue_Size | Attr_Alpha_Size | Attr_Accum_Red_Size | Attr_Accum_Green_Size | Attr_Accum_Blue_Size | Attr_Accum_Alpha_Size => Size : Natural := 0; end case; end record; type X11Context_Attributes is array (Positive range <>) of X11Context_Attribute; Max_GLX_Attributes : constant := 2 + (X11Context_Attribute_Name'Pos (X11Context_Attribute_Name'Last) + 1) * 2; type GLX_Attribute_List is array (1 .. Max_GLX_Attributes) of Integer; type GLX_Attribute_List_Ptr is new System.Address; ------------------------------------------------------------------------ type Display_Pointer is new System.Address; -- The maximum length of an event data record type Padding is array (1 .. 23) of Long_Integer; type Screen_Depth is new Natural; type Screen_Number is new Natural; type Visual_ID is new Long_Integer; type Window_ID is new Long_Integer; type Alloc_Mode is (Alloc_None, Alloc_All); type Atom_Array is array (Positive range <>) of Atom; type Colormap_ID is new Long_Integer; type X_Window_Attributes_Mask is mod 2 ** Integer'Size; type Window_Class is (Copy_From_Parent, Input_Output, Input_Only); type X_Event_Mask is mod 2 ** Long_Integer'Size; -- An extremely abbreviated version of the XSetWindowAttributes -- structure, containing only the fields we care about. -- -- NOTE: offset multiplier values differ between 32-bit and 64-bit -- systems since on 32-bit systems long size equals int size and the -- record has no padding. The byte and bit widths come from Internal. Start_32 : constant := 10; Start_64 : constant := 9; Start : constant := (Is_32 * Start_32) + (Is_64 * Start_64); ------------------------------------------------------------------------ Null_Display_Pointer : constant Display_Pointer := Display_Pointer (System.Null_Address); type X_Set_Window_Attributes is record Event_Mask : X_Event_Mask := 0; Colormap : Colormap_ID := 0; end record; for X_Set_Window_Attributes use record Event_Mask at (Start + 0) * Long_Bytes range 0 .. Long_Bits; Colormap at (Start + 3) * Long_Bytes range 0 .. Long_Bits; end record; -- The GL rendering context type type GLX_Context is new System.Address; type X_Visual_Info is record Visual : System.Address; Visual_Ident : Visual_ID; Screen : Screen_Number; Depth : Screen_Depth; Class : Integer; Red_Mask : Long_Integer; Green_Mask : Long_Integer; Blue_Mask : Long_Integer; Colormap_Size : Natural; Bits_Per_RGB : Natural; end record; type X_Visual_Info_Pointer is access all X_Visual_Info; type X_Class_Hint is record Instance_Name : System.Address; Class_Name : System.Address; end record; type X_Text_Property is record Value : System.Address; Encoding : Atom; Format : Data_Format_Type; NItems : Long_Integer; end record; --------------------------------------------------------------------------- -- X modifier mask and its values type Modifier_Mask is mod 2 ** Integer'Size; -- Xlib constants needed only by Create Configure_Event_Mask : constant X_Window_Attributes_Mask := 2#00_1000_0000_0000#; -- 11th bit Configure_Colormap : constant X_Window_Attributes_Mask := 2#10_0000_0000_0000#; -- 13th bit -- Atom names WM_Del : String := "WM_DELETE_WINDOW" & ASCII.NUL; Null_Context : constant GLX_Context := GLX_Context (System.Null_Address); -- X event type codes -- we don't actually use this, just there to define bounds X_Error : constant := 0; X_Key_Press : constant := 2; X_Key_Release : constant := 3; X_Button_Press : constant := 4; X_Button_Release : constant := 5; X_Motion_Notify : constant := 6; X_Enter_Notify : constant := 7; X_Leave_Notify : constant := 8; X_Focus_In : constant := 9; X_Focus_Out : constant := 10; X_Expose : constant := 12; X_Unmap_Notify : constant := 18; X_Map_Notify : constant := 19; X_Configure_Notify : constant := 22; X_Client_Message : constant := 33; -- we don't actually use this, just there to define bounds X_Generic_Event : constant := 35; X_First_Event : constant := X_Error; X_Last_Event : constant := X_Generic_Event + 1; -- Our "delete window" atom value Delete_Window_Atom : Atom; ------------------------------------------------------------------------ Shift_Mask : constant Modifier_Mask := 2#0000_0000_0000_0001#; Lock_Mask : constant Modifier_Mask := 2#0000_0000_0000_0010#; Control_Mask : constant Modifier_Mask := 2#0000_0000_0000_0100#; Mod_1_Mask : constant Modifier_Mask := 2#0000_0000_0000_1000#; Mod_2_Mask : constant Modifier_Mask := 2#0000_0000_0001_0000#; Mod_3_Mask : constant Modifier_Mask := 2#0000_0000_0010_0000#; Mod_4_Mask : constant Modifier_Mask := 2#0000_0000_0100_0000#; Mod_5_Mask : constant Modifier_Mask := 2#0000_0000_1000_0000#; Button_1_Mask : constant Modifier_Mask := 2#0000_0001_0000_0000#; Button_2_Mask : constant Modifier_Mask := 2#0000_0010_0000_0000#; Button_3_Mask : constant Modifier_Mask := 2#0000_0100_0000_0000#; Button_4_Mask : constant Modifier_Mask := 2#0000_1000_0000_0000#; Button_5_Mask : constant Modifier_Mask := 2#0001_0000_0000_0000#; type X_Event_Code is new Integer range X_First_Event .. X_Last_Event; Bytes : constant := Word_Bytes; Bits : constant := Word_Bits; Atom_Bits : constant := Atom'Size - 1; Base_1_32 : constant := 8; Base_2_32 : constant := 5; Base_3_32 : constant := 6; Base_4_32 : constant := 7; Base_1_64 : constant := 16; Base_2_64 : constant := 10; Base_3_64 : constant := 12; Base_4_64 : constant := 14; Base_1 : constant := (Base_1_32 * Is_32) + (Base_1_64 * Is_64); Base_2 : constant := (Base_2_32 * Is_32) + (Base_2_64 * Is_64); Base_3 : constant := (Base_3_32 * Is_32) + (Base_3_64 * Is_64); Base_4 : constant := (Base_4_32 * Is_32) + (Base_4_64 * Is_64); type X_Event_Data (X_Event_Type : X_Event_Code := X_Error) is record case X_Event_Type is when X_Key_Press | X_Key_Release => Key_X : Natural; Key_Y : Natural; Key_Root_X : Natural; Key_Root_Y : Natural; Key_State : Modifier_Mask; Key_Code : Natural; when X_Button_Press | X_Button_Release => Btn_X : Natural; Btn_Y : Natural; Btn_Root_X : Natural; Btn_Root_Y : Natural; Btn_State : Modifier_Mask; Btn_Code : Natural; when X_Motion_Notify => Mov_X : Natural; Mov_Y : Natural; Mov_Root_X : Natural; Mov_Root_Y : Natural; Mov_State : Modifier_Mask; when X_Enter_Notify | X_Leave_Notify => Xng_X : Natural; Xng_Y : Natural; Xng_Root_X : Natural; Xng_Root_Y : Natural; when X_Expose => Xps_X : Natural; Xps_Y : Natural; Xps_Width : Natural; Xps_Height : Natural; Xps_Count : Natural; when X_Configure_Notify => Cfg_X : Natural; Cfg_Y : Natural; Cfg_Width : Natural; Cfg_Height : Natural; when X_Client_Message => Msg_Value : Atom; when others => Pad : Padding; end case; end record; for X_Event_Data use record X_Event_Type at 0 * Bytes range 0 .. Bits; Key_X at (Base_1 + 0) * Bytes range 0 .. Bits; Key_Y at (Base_1 + 1) * Bytes range 0 .. Bits; Key_Root_X at (Base_1 + 2) * Bytes range 0 .. Bits; Key_Root_Y at (Base_1 + 3) * Bytes range 0 .. Bits; Key_State at (Base_1 + 4) * Bytes range 0 .. Bits; Key_Code at (Base_1 + 5) * Bytes range 0 .. Bits; Btn_X at (Base_1 + 0) * Bytes range 0 .. Bits; Btn_Y at (Base_1 + 1) * Bytes range 0 .. Bits; Btn_Root_X at (Base_1 + 2) * Bytes range 0 .. Bits; Btn_Root_Y at (Base_1 + 3) * Bytes range 0 .. Bits; Btn_State at (Base_1 + 4) * Bytes range 0 .. Bits; Btn_Code at (Base_1 + 5) * Bytes range 0 .. Bits; Mov_X at (Base_1 + 0) * Bytes range 0 .. Bits; Mov_Y at (Base_1 + 1) * Bytes range 0 .. Bits; Mov_Root_X at (Base_1 + 2) * Bytes range 0 .. Bits; Mov_Root_Y at (Base_1 + 3) * Bytes range 0 .. Bits; Mov_State at (Base_1 + 4) * Bytes range 0 .. Bits; Xng_X at (Base_1 + 0) * Bytes range 0 .. Bits; Xng_Y at (Base_1 + 1) * Bytes range 0 .. Bits; Xng_Root_X at (Base_1 + 2) * Bytes range 0 .. Bits; Xng_Root_Y at (Base_1 + 3) * Bytes range 0 .. Bits; Xps_X at (Base_2 + 0) * Bytes range 0 .. Bits; Xps_Y at (Base_2 + 1) * Bytes range 0 .. Bits; Xps_Width at (Base_2 + 2) * Bytes range 0 .. Bits; Xps_Height at (Base_2 + 3) * Bytes range 0 .. Bits; Xps_Count at (Base_2 + 4) * Bytes range 0 .. Bits; Cfg_X at (Base_3 + 0) * Bytes range 0 .. Bits; Cfg_Y at (Base_3 + 1) * Bytes range 0 .. Bits; Cfg_Width at (Base_3 + 2) * Bytes range 0 .. Bits; Cfg_Height at (Base_3 + 3) * Bytes range 0 .. Bits; Msg_Value at (Base_4 + 0) * Bytes range 0 .. Atom_Bits; end record; ------------------------------------------------------------------------ GL_TRUE : constant Character := Character'Val (1); ----------------------------- -- Imported Xlib functions -- ----------------------------- function GLX_Create_Context (Display : in Display_Pointer; Visual : in X_Visual_Info_Pointer; Share_List : in GLX_Context; Direct : in Character) return GLX_Context with Import => True, Convention => StdCall, External_Name => "glXCreateContext"; function GLX_Make_Current (Display : in Display_Pointer; Drawable : in Window_ID; Context : in GLX_Context) return Character with Import => True, Convention => StdCall, External_Name => "glXMakeCurrent"; function GLX_Make_Context_Current (Display : in Display_Pointer; Draw : in Window_ID; Read : in Window_ID; Context : in GLX_Context) return Character with Import => True, Convention => StdCall, External_Name => "glXMakeContextCurrent"; function X_Intern_Atom (Display : in Display_Pointer; Name : in System.Address; Only_If_Exists : in Natural) return Atom with Import => True, Convention => StdCall, External_Name => "XInternAtom"; procedure X_Set_Class_Hint (Display : in Display_Pointer; Window : in Window_ID; Hint : in X_Class_Hint) with Import => True, Convention => StdCall, External_Name => "XSetClassHint"; procedure X_Set_Icon_Name (Display : in Display_Pointer; Window : in Window_ID; Name : in System.Address) with Import => True, Convention => StdCall, External_Name => "XSetIconName"; procedure X_Set_WM_Icon_Name (Display : in Display_Pointer; Window : in Window_ID; Text_Prop : in System.Address) with Import => True, Convention => StdCall, External_Name => "XSetWMIconName"; procedure X_Set_WM_Name (Display : in Display_Pointer; Window : in Window_ID; Text_Prop : in System.Address) with Import => True, Convention => StdCall, External_Name => "XSetWMName"; function GLX_Choose_Visual (Display : in Display_Pointer; Screen : in Screen_Number; Attribute_List : in GLX_Attribute_List_Ptr) return X_Visual_Info_Pointer with Import => True, Convention => StdCall, External_Name => "glXChooseVisual"; function GLX_Choose_FB_Config (Display : in Display_Pointer; Screen : in Screen_Number; Attribute_List : in GLX_Attribute_List_Ptr; Num_Found : in Int_Ptr) return FB_Config_Ptr with Import => True, Convention => StdCall, External_Name => "glXChooseFBConfig"; function GLX_Get_Visual_From_FB_Config (Display : in Display_Pointer; Config : in System.Address) return X_Visual_Info_Pointer with Import => True, Convention => StdCall, External_Name => "glXGetVisualFromFBConfig"; procedure X_Next_Event (Display : in Display_Pointer; Event : in System.Address) with Import => True, Convention => StdCall, External_Name => "XNextEvent"; procedure GLX_Destroy_Context (Display : in Display_Pointer; Context : in GLX_Context) with Import => True, Convention => StdCall, External_Name => "glXDestroyContext"; function X_Create_Colormap (Display : in Display_Pointer; Window : in Window_ID; Visual : in System.Address; Alloc : in Alloc_Mode) return Colormap_ID with Import => True, Convention => StdCall, External_Name => "XCreateColormap"; function X_Create_Window (Display : in Display_Pointer; Parent : in Window_ID; X : in Position; Y : in Position; Width : in Dimension; Height : in Dimension; Border_Width : in Natural; Depth : in Screen_Depth; Class : in Window_Class; Visual : in System.Address; Valuemask : in X_Window_Attributes_Mask; Attributes : in System.Address) return Window_ID with Import => True, Convention => StdCall, External_Name => "XCreateWindow"; function X_Default_Screen (Display : in Display_Pointer) return Screen_Number with Import => True, Convention => StdCall, External_Name => "XDefaultScreen"; procedure X_Map_Window (Display : in Display_Pointer; Window : in Window_ID) with Import => True, Convention => StdCall, External_Name => "XMapWindow"; function X_Open_Display (Display_Name : in System.Address := System.Null_Address) return Display_Pointer with Import => True, Convention => StdCall, External_Name => "XOpenDisplay"; function X_Root_Window (Display : in Display_Pointer; Screen_Num : in Screen_Number) return Window_ID with Import => True, Convention => StdCall, External_Name => "XRootWindow"; procedure X_Set_WM_Protocols (Display : in Display_Pointer; Window : in Window_ID; Protocols : in System.Address; Count : in Integer) with Import => True, Convention => StdCall, External_Name => "XSetWMProtocols"; function X_Lookup_String (Event : in System.Address; Buffer : in System.Address; Limit : in Natural; Keysym : in System.Address; Compose : in System.Address) return Natural with Import => True, Convention => StdCall, External_Name => "XLookupString"; function X_Pending (Display : in Display_Pointer) return Natural with Import => True, Convention => StdCall, External_Name => "XPending"; procedure X_Resize_Window (Display : in Display_Pointer; Window : in Window_ID; Width : in Positive; Height : in Positive) with Import => True, Convention => StdCall, External_Name => "XResizeWindow"; procedure X_Warp_Pointer (Display : in Display_Pointer; Source_W : in Window_ID; Dest_W : in Window_ID; Source_X : in Integer; Source_Y : in Integer; Source_Width : in Natural; Source_Height : in Natural; Dest_X : in Integer; Dest_Y : in Integer) with Import => True, Convention => StdCall, External_Name => "XWarpPointer"; procedure X_Move_Window (Display : in Display_Pointer; Window : in Window_ID; X : in Natural; Y : in Natural) with Import => True, Convention => StdCall, External_Name => "XMoveWindow"; procedure X_Query_Pointer (Display : in Display_Pointer; Window : in Window_ID; Root : in System.Address; Child : in System.Address; Root_X : in System.Address; Root_Y : in System.Address; Win_X : in System.Address; Win_Y : in System.Address; Mask : in System.Address) with Import => True, Convention => StdCall, External_Name => "XQueryPointer"; procedure X_Raise_Window (Display : in Display_Pointer; Window : in Window_ID) with Import => True, Convention => StdCall, External_Name => "XRaiseWindow"; procedure X_Lower_Window (Display : in Display_Pointer; Window : in Window_ID) with Import => True, Convention => StdCall, External_Name => "XLowerWindow"; --------------------------------------------------------------------------- end X11;